File: index.php

package info (click to toggle)
postfixadmin 2.3.5-2%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,200 kB
  • sloc: php: 25,767; xml: 14,485; perl: 964; sh: 664; python: 169; makefile: 84
file content (46 lines) | stat: -rw-r--r-- 1,281 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php

require_once(dirname(__FILE__).'/package.php');

$transform = "simpletest.org.xslt";
$source_path = "../../docs/source/";
$destination_path = "../../docs/simpletest.org/";

$languages = array("en/", "fr/");

foreach ($languages as $language) {
	$dir = opendir($source_path.$language);
	while (($file = readdir($dir)) !== false) {
		if (is_file($source_path.$language.$file)) {
		
			$source = simplexml_load_file($source_path.$language.$file, "SimpleTestXMLElement");
			$destination = $source->destination("map.xml");
			
			if (!empty($destination)) {
				$page = file_get_contents('template.html');
		
				$page = str_replace('TITLE', $source->title(), $page);
				$page = str_replace('CONTENT', $source->content(), $page);
				$links = $source->links("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);
				if ($ok) {
					$result = "OK";
				} else {
					$result = "KO";
				}
				echo $destination_path.$destination." : ".$result."<br />";
			}
		}
	}
	closedir($dir);
}
?>