73 $this->CachedMultyFS =
get_package(
'cached_multy_fs' ,
'last' , __FILE__ );
74 $this->Lang =
get_package(
'lang' ,
'last' , __FILE__ );
75 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
76 $this->String =
get_package(
'string' ,
'last' , __FILE__ );
77 $this->Tags =
get_package(
'string::tags' ,
'last' , __FILE__ );
79 $this->StylesheetParsed =
false;
109 if( $this->CachedMultyFS->file_exists( dirname( $File ).
'/res/css/css_list' ) )
111 $List = $this->CachedMultyFS->file_get_contents(
112 dirname( $File ).
'/res/css/css_list' ,
'exploded'
115 $PageCSS =
get_package(
'page::page_css' ,
'last' , __FILE__ );
117 foreach( $List as $k => $v )
119 $PageCSS->add_stylesheet(
125 catch( Exception $e )
157 function parse( $File , $Variable , $Value )
161 if( $this->Template ===
false )
166 if( strpos( $this->Template ,
'{'.$Variable.
'}' ) !==
false )
168 $Variable = $this->Security->get( $Variable ,
'string' );
169 $this->Template = str_replace(
'{'.$Variable.
'}' , $Value.
'{'.$Variable.
'}' , $this->Template );
172 catch( Exception $e )
196 if( $this->Security->get_gp(
'template' ,
'set' ) )
198 $TemplateName = $this->Security->get_gp(
'template' ,
'command' );
200 if( $TemplateName ==
'ajax_result_template' ||
201 $TemplateName ==
'primitive' ||
202 $TemplateName ==
'print' ||
203 $TemplateName ==
'standalone_view' )
205 return( $TemplateName );
209 throw(
new Exception(
"Template \"$TemplateName\" was not found" ) );
213 return(
'template' );
215 catch( Exception $e )
243 private function handle_template_block( $PageName , &$Changed )
247 if( $this->String->block_exists( $this->Template ,
'template:'.$PageName ,
'template:~'.$PageName ) )
250 $this->Template = $this->String->show_block(
251 $this->Template ,
'template:'.$PageName ,
'template:~'.$PageName , $Changed
256 if( $this->String->block_exists( $this->Template ,
'template:_default_page' ,
257 'template:~_default_page' ) )
260 $this->Template = $this->String->show_block(
261 $this->Template ,
'template:_default_page' ,
'template:~_default_page' , $Changed
266 catch( Exception $e )
294 private function handle_includes( $File , &$Changed )
298 for( ; $BlockName = $this->String->get_macro_parameters( $this->Template ,
'include' ) ; )
300 $IncludedTemplate = $this->CachedMultyFS->get_template( $File ,
"$BlockName.tpl" );
302 $this->Template = str_replace(
"{include:$BlockName}" , $IncludedTemplate , $this->Template );
306 catch( Exception $e )
338 function process( $File , $PageName , &$Changed )
342 if( $this->Template ===
false )
348 $this->handle_template_block( $PageName , $Changed );
350 $this->Template = $this->String->hide_unprocessed_blocks( $this->Template ,
'template' , $Changed );
352 $this->handle_includes( $File , $Changed );
354 catch( Exception $e )
390 if( $this->Template ===
false )
395 if( $this->String->block_exists( $this->Template , $PurePlaceHolderName ) )
397 $Params = $this->String->get_macro_parameters( $this->Template , $PurePlaceHolderName );
405 catch( Exception $e )
437 private function handle_color_scheme( $File , $Str )
442 for( ; $Params = $this->String->get_macro_parameters( $Str ,
'color_scheme' ) ; )
444 $this->MacroSettings->load_settings( $Params );
445 $Available = explode(
',' , $this->MacroSettings->get_setting(
'available' ,
'default' ) );
447 $Sheme = $this->Settings->get_setting(
'color_scheme' ,
'default' );
449 if( array_search( $Sheme , $Available ) !==
false )
451 $Str = str_replace(
"{color_scheme:$Params}" , $Sheme , $Str );
455 $Str = str_replace(
"{color_scheme:$Params}" ,
'default' , $Str );
461 catch( Exception $e )
493 if( $this->Settings ===
false )
496 if( $this->CachedMultyFS->file_exists( dirname( $File ).
'/conf/cf_template_settings' ) )
498 $this->Settings->load_file( dirname( $File ).
'/conf/cf_template_settings' );
503 array(
'{color_scheme}' ,
'{locale}' ) ,
504 array(
'{color_scheme:available=default}' , $this->Lang->get_locale() ) ,
508 $Str = $this->handle_color_scheme( $File , $Str );
512 catch( Exception $e )
540 private function captcha_substitutions( $File , $PageName )
544 $PlaceHolders = array(
'{captcha_image}' ,
'{captcha_field}' );
547 '<img src="./captcha.html" align="top">' ,
548 '<input type="text" class="flat width_100" size="25" name="captcha" value="" '.
549 'style="text-align: center;">'
552 $this->Template = str_replace( $PlaceHolders , $Subs , $this->Template );
554 catch( Exception $e )
582 private function standart_substitutions( $File , $PageName )
586 global $StartGenerationTime;
588 $PlaceHolders = array(
589 '{template_path}' ,
'{gen_time}' ,
'{captcha}' ,
590 '[page_name]' ,
'/./' ,
'[random]' ,
'{request_uri}'
595 '{captcha_image} {captcha_field}' , $PageName ,
'/' , rand() ,
596 $this->Security->get_srv(
'REQUEST_URI' ,
'string' )
598 $this->Template = str_replace( $PlaceHolders , $Subs , $this->Template );
600 $this->captcha_substitutions( $File , $PageName );
602 catch( Exception $e )
626 $PlaceHolders = array(
627 '{header}' ,
'{footer}' ,
'{title}' ,
'{some_menu}' ,
'{pathway}' ,
'{menu}' ,
'{error_message}' ,
628 '{success_message}' ,
'{main}' ,
'{bottom}' ,
'{banner}' ,
'{banners}'
630 $this->Template = str_replace( $PlaceHolders ,
'' , $this->Template );
633 $PlaceHolders = array();
637 preg_match(
'/\{([a-zA-Z0-9_]+)\}/' , $this->Template , $PlaceHolders );
639 $c = count( $PlaceHolders );
643 $this->Template = str_replace(
'{'.$PlaceHolders[ 1 ].
'}' ,
'' , $this->Template );
648 catch( Exception $e )
680 if( $this->Template ===
false )
685 $this->Template = $this->Tags->compile_ultimix_tags( $this->Template );
687 $this->standart_substitutions( $File , $PageName );
691 $this->Template = $this->
compile_string( $File , $this->Template );
693 $this->Template = str_replace( array(
'[lfb]' ,
'[rfb]' ) , array(
'{' ,
'}' ) , $this->Template );
695 catch( Exception $e )
727 if( $this->Template ===
false )
731 $this->Template = $this->CachedMultyFS->get_template( $File ,
"$TemplateName.tpl" );
735 return( $this->Template );
737 catch( Exception $e )
759 $this->Template = $theTemplate;