TemplateCompiler.php (1640B)
1 <?php 2 3 header('Content-Type: text/plain'); 4 5 /** 6 * Using the Component classes and generating a XSD-File. 7 */ 8 error_reporting(E_ALL); 9 ini_set('display_errors', 1); 10 ini_set('display_startup_errors', 1); 11 12 use cms\base\Startup; 13 use template_engine\AppInfo; 14 use template_engine\engine\TemplateContext; 15 use template_engine\engine\TemplateEngine; 16 use util\FileUtils; 17 18 Startup::initialize(); 19 20 AppInfo::$styleClassPrefix = Startup::CSS_PREFIX; 21 22 $searchDir = __DIR__ . '/../../modules/cms/ui/themes/default/html/views'; 23 24 25 echo "Searching in $searchDir\n"; 26 27 $count = 0; 28 29 30 foreach(FileUtils::readDir( $searchDir ) as $action ) 31 { 32 if ( !is_dir($searchDir.'/'.$action ) ) 33 continue; 34 35 echo "Action: $action\n"; 36 37 foreach(FileUtils::readDir( $searchDir.'/'.$action ) as $file ) 38 { 39 if ( substr($file,-12 ) == '.tpl.src.xml' ) 40 { 41 $count++; 42 $method = substr($file, 0,-12 ); 43 echo "\tMethod $method\n"; 44 45 $templateFile = $searchDir.'/'.$action.'/'.$file; 46 $outFile = $searchDir.'/'.$action.'/'.$method.'.php'; 47 48 $engine = new TemplateEngine(); 49 50 // We are creating a fake request, because the template compiler needs to know 51 // the action and subaction in which it will be executed. 52 $context = new TemplateContext(); 53 $context->action = $action; 54 $context->method = $method; 55 $engine->context = $context; 56 57 echo "\t\tcompiling $templateFile\n\t\t to $outFile\n"; 58 59 $engine->compile( $templateFile,$outFile ); 60 } 61 } 62 } 63 echo "\nSummary: Compiled $count files.\n"; 64