module_path = $site_root; } function Generator() { $this->__construct(); } function PrepareTemplate( $template_name ) { // Load the template file then parse for it's tags $template_filename = $this->module_path . '/hidden/templates/' . $template_name; if( @file_exists( $template_filename ) ) { // Grab contents the parse for tags $this->html_content = @file_get_contents( $template_filename ); $this->html_content = $this->ParseTags( $this->html_content ); return true; } return ErrorMessage( 'Template file (' . basename( $template_name ) . ') does not exist.', __FILE__, __LINE__ ); } function RenderOutput( $filename ) { // Render the new template to a static page @file_put_contents( $filename, $this->html_content ); } function ParseTags( $content ) { $pattern = '||i'; if( @preg_match_all( $pattern, $content, $matches ) ) { foreach( $matches[1] as $tag ) { // Module exists, grab contenst and replace tag if( @file_exists( $this->module_path . '/modules/' . strtolower( $tag ) . '.inc.php' ) ) { $tag_content = $this->GrabModuleContent( $this->module_path . '/modules/' . strtolower( $tag ) . '.inc.php', false ); $content = str_replace( '', $tag_content, $content ); } else if( @file_exists( $this->module_path . '/modules/' . strtolower( $tag ) . '.gen.php' ) ) { $tag_content = $this->GrabModuleContent( $this->module_path . '/modules/' . strtolower( $tag ) . '.gen.php', true ); $content = str_replace( '', $tag_content, $content ); } else { Message( 'Module (' . $tag . ') does not exist, ignoring...', __FILE__, __LINE__ ); } } } return $content; } // Grab contents from a module, and store the result in a variable function GrabModuleContent( $filename, $generate = false ) { if( @file_exists( $filename ) ) { // use ob to intercept include, and place data into // a variable to use in template if( $generate ) { @ob_start(); include $filename; $output = @ob_get_contents(); @ob_end_clean(); return $output; } else { return ''; } } return ErrorMessage( 'Module (' . basename( $filename ) . ') does not exist, can not parse...', __FILE__, __LINE__ ); } } ?>