Пример #1
0
 function testOfSynchronisationNecessary()
 {
     $source = dirname(__FILE__) . "/package/fr/synchronisation.xml";
     $synchro = new PackagingSynchronisation($source);
     $this->assertEqual($synchro->revision(), "1672");
     $this->assertEqual($synchro->sourceRevision(), "1671");
     $this->assertEqual($synchro->sourceLang(), "en");
     $this->assertEqual($synchro->lastSynchroRevision(), "1475");
     $this->assertEqual($synchro->result(), "late");
 }
Пример #2
0
 public function testOfSynchronisationNecessary()
 {
     $source = dirname(__FILE__) . "/package/fr/synchronisation.xml";
     $synchro = new PackagingSynchronisation($source);
     $this->assertEqual($synchro->revision(), "1672");
     $this->assertEqual($synchro->sourceRevision(), "1671");
     $this->assertEqual($synchro->sourceLang(), "en");
     $this->assertEqual($synchro->lastSynchroRevision(), "1475");
     $this->assertPattern("/style=\"color : red\"/", $synchro->result());
 }
Пример #3
0
 function sourceRevision()
 {
     $source_lang = $this->sourceLang();
     $source_file = str_replace("/" . $this->lang . "/", "/" . $source_lang . "/", $this->file);
     if (file_exists($source_file)) {
         $source = new PackagingSynchronisation($source_file, $source_lang);
         return $source->revision();
     }
     return false;
 }
Пример #4
0
            $destination = $source->destination(dirname(__FILE__) . '/map.xml');
            if (!empty($destination)) {
                $page = file_get_contents(dirname(__FILE__) . '/template.html');
                $page = str_replace('KEYWORDS', $source->keywords(), $page);
                $page = str_replace('TITLE', $source->title(), $page);
                $page = str_replace('CONTENT', $source->content(), $page);
                $page = str_replace('INTERNAL', $source->internal(), $page);
                $page = str_replace('EXTERNAL', $source->external(), $page);
                $links = $source->links(dirname(__FILE__) . '/map.xml');
                foreach ($links as $category => $link) {
                    $page = str_replace("LINKS_" . strtoupper($category), $link, $page);
                }
                $destination_dir = dirname($destination_path . $destination);
                if (!is_dir($destination_dir)) {
                    mkdir($destination_dir);
                }
                $ok = file_put_contents($destination_path . $destination, $page);
                touch($destination_path . $destination, filemtime($source_path . $language . $file));
                if ($ok) {
                    $result = "OK";
                } else {
                    $result = "KO";
                }
                $synchronisation = new PackagingSynchronisation($source_path . $language . $file);
                $result .= " " . $synchronisation->result();
                echo $destination_path . $destination . " : " . $result . "\n";
            }
        }
    }
    closedir($dir);
}