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