ultimix
base_template_1_0_0 Class Reference

Public Member Functions

 __construct ()
 add_stylesheets ($File)
 parse ($File, $Variable, $Value)
 extract_template_name ()
 process ($File, $PageName, &$Changed)
 get_placeholder_parameters ($File, $PurePlaceHolderName)
 compile_string ($File, $Str)
 cleanup_placeholders ()
 cleanup ($File, $PageName)
 get_template ($File= '')
 set_template ($theTemplate)

Data Fields

 $Template = false
 $MacroSettings = false
 $CachedMultyFS = false
 $Lang = false
 $Security = false
 $Settings = false
 $String = false
 $Tags = false

Detailed Description

Class of the template.

Author
Dodonov A.A.

Definition at line 26 of file base_template.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Author
Dodonov A.A.

Definition at line 68 of file base_template.php.

{
try
{
$this->MacroSettings = get_package_object( 'settings::settings' , 'last' , __FILE__ );
$this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
$this->Lang = get_package( 'lang' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
$this->String = get_package( 'string' , 'last' , __FILE__ );
$this->Tags = get_package( 'string::tags' , 'last' , __FILE__ );
$this->StylesheetParsed = false;
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Member Function Documentation

add_stylesheets (   $File)

Function adds teplate's stylesheets.

Parameters
$File- Real path to the template script.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 105 of file base_template.php.

{
try
{
if( $this->CachedMultyFS->file_exists( dirname( $File ).'/res/css/css_list' ) )
{
$List = $this->CachedMultyFS->file_get_contents(
dirname( $File ).'/res/css/css_list' , 'exploded'
);
$PageCSS = get_package( 'page::page_css' , 'last' , __FILE__ );
foreach( $List as $k => $v )
{
$PageCSS->add_stylesheet(
str_replace( './' , '{http_host}/' , _get_package_relative_path( $File )."/res/css/$v" )
);
}
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
cleanup (   $File,
  $PageName 
)

Function clears all placeholder in the HTML code of the template.

Parameters
$File- Real path to the template script.
$PageName- Page name for precompilation.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 676 of file base_template.php.

{
try
{
if( $this->Template === false )
{
$this->Template = $this->get_template( $File );
}
$this->Template = $this->Tags->compile_ultimix_tags( $this->Template );
$this->standart_substitutions( $File , $PageName );
$this->Template = $this->compile_string( $File , $this->Template );
$this->Template = str_replace( array( '[lfb]' , '[rfb]' ) , array( '{' , '}' ) , $this->Template );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
cleanup_placeholders ( )

Function clears placeholders.

Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 622 of file base_template.php.

{
try
{
$PlaceHolders = array(
'{header}' , '{footer}' , '{title}' , '{some_menu}' , '{pathway}' , '{menu}' , '{error_message}' ,
'{success_message}' , '{main}' , '{bottom}' , '{banner}' , '{banners}'
);
$this->Template = str_replace( $PlaceHolders , '' , $this->Template );
$c = 0;
$PlaceHolders = array();
do
{
preg_match( '/\{([a-zA-Z0-9_]+)\}/' , $this->Template , $PlaceHolders );
$c = count( $PlaceHolders );
if( $c > 1 )
{
$this->Template = str_replace( '{'.$PlaceHolders[ 1 ].'}' , '' , $this->Template );
}
}
while( $c > 1 );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
compile_string (   $File,
  $Str 
)

Function clears all placeholder in the HTML code of the template.

Parameters
$File- Real path to the template script.
$Str- Processing string.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 489 of file base_template.php.

{
try
{
if( $this->Settings === false )
{
$this->Settings = get_package_object( 'settings::settings' , 'last' , __FILE__ );
if( $this->CachedMultyFS->file_exists( dirname( $File ).'/conf/cf_template_settings' ) )
{
$this->Settings->load_file( dirname( $File ).'/conf/cf_template_settings' );
}
}
$Str = str_replace(
array( '{color_scheme}' , '{locale}' ) ,
array( '{color_scheme:available=default}' , $this->Lang->get_locale() ) ,
$Str
);
$Str = $this->handle_color_scheme( $File , $Str );
return( $Str );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
extract_template_name ( )

Function tries override template.

Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 192 of file base_template.php.

{
try
{
if( $this->Security->get_gp( 'template' , 'set' ) )
{
$TemplateName = $this->Security->get_gp( 'template' , 'command' );
if( $TemplateName == 'ajax_result_template' ||
$TemplateName == 'primitive' ||
$TemplateName == 'print' ||
$TemplateName == 'standalone_view' )
{
return( $TemplateName );
}
else
{
throw( new Exception( "Template \"$TemplateName\" was not found" ) );
}
}
return( 'template' );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_placeholder_parameters (   $File,
  $PurePlaceHolderName 
)

Function returns Real placeholder's name.

Parameters
$File- Real path to the template script.
$PurePlaceHolderName- Name of the placeholder.
Returns
HTML code of the composed page.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 386 of file base_template.php.

{
try
{
if( $this->Template === false )
{
$this->Template = $this->get_template( $File );
}
if( $this->String->block_exists( $this->Template , $PurePlaceHolderName ) )
{
$Params = $this->String->get_macro_parameters( $this->Template , $PurePlaceHolderName );
return( $Params );
}
else
{
return( false );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_template (   $File = '')

Function returns HTML code of the template.

Parameters
$File- Real path to the template script.
Returns
HTML code of the template.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 723 of file base_template.php.

{
try
{
if( $this->Template === false )
{
/* чтение шаблона в переменную */
$TemplateName = $this->extract_template_name();
$this->Template = $this->CachedMultyFS->get_template( $File , "$TemplateName.tpl" );
}
/* pre-обработка шаблона завершена, поэтому можно отдавать его клиентским пакетам */
return( $this->Template );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
parse (   $File,
  $Variable,
  $Value 
)

Function parse variable with name $Variable.

Parameters
$File- Real path to the template script.
$Variable- name of the template variable.
$Value- value to place in the template.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 157 of file base_template.php.

{
try
{
if( $this->Template === false )
{
$this->Template = $this->get_template( $File );
}
if( strpos( $this->Template , '{'.$Variable.'}' ) !== false )
{
$Variable = $this->Security->get( $Variable , 'string' );
$this->Template = str_replace( '{'.$Variable.'}' , $Value.'{'.$Variable.'}' , $this->Template );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
process (   $File,
  $PageName,
$Changed 
)

Function precompiles template.

Parameters
$File- Real path to the template script.
$PageName- Page name for precompilation.
$Changed- true if any of the page's elements was compiled.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 338 of file base_template.php.

{
try
{
if( $this->Template === false )
{
$this->Template = $this->get_template( $File );
}
$this->Template = $this->get_template();
$this->handle_template_block( $PageName , $Changed );
$this->Template = $this->String->hide_unprocessed_blocks( $this->Template , 'template' , $Changed );
$this->handle_includes( $File , $Changed );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
set_template (   $theTemplate)

Function sets HTML code of the template.

Parameters
$theTemplate- template's HTML code.
Author
Dodonov A.A.

Definition at line 757 of file base_template.php.

{
$this->Template = $theTemplate;
}

Field Documentation

$CachedMultyFS = false

Definition at line 51 of file base_template.php.

$Lang = false

Definition at line 52 of file base_template.php.

$MacroSettings = false

Cached objects.

Author
Dodonov A.A.

Definition at line 50 of file base_template.php.

$Security = false

Definition at line 53 of file base_template.php.

$Settings = false

Definition at line 54 of file base_template.php.

$String = false

Definition at line 55 of file base_template.php.

$Tags = false

Definition at line 56 of file base_template.php.

$Template = false

Template content.

Author
Dodonov A.A.

Definition at line 38 of file base_template.php.


The documentation for this class was generated from the following file: