ultimix
template_content_access_1_0_0 Class Reference

Public Member Functions

 __construct ()
 set_add_condition ($theAddCondition)
 select_list ($id)
 update ($id, $Record)
 try_virtual_path ($VirtualPath)
 get_content_path ($Template)
 get_content ($Template)
 get_package_template ($PackageName, $PackageVersion, $Template)
 get_package_file (&$Options)
 get_content_ex ($Options)

Data Fields

 $CachedMultyFS = false
 $Security = false
 $SecurityParser = false
 $AddCondition = false

Detailed Description

This class provides access to the templates.

Author
Dodonov A.A.

Definition at line 26 of file template_content_access.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Author
Dodonov A.A.

Definition at line 52 of file template_content_access.php.

{
try
{
$this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
$this->SecurityParser = get_package( 'security::security_parser' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Member Function Documentation

get_content (   $Template)

Function returns content.

Parameters
$Template- Content's file name.
Returns
Static content.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 313 of file template_content_access.php.

{
try
{
$Path = $this->get_content_path( $Template );
if( $Path !== false && $this->CachedMultyFS->file_exists( $Path ) )
{
return( $this->CachedMultyFS->file_get_contents( $Path ) );
}
else
{
throw( new Exception( "The content \"$Template\" was not found. Path : $Path" ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_content_ex (   $Options)

Function returns content.

Parameters
$Options- Display options.
Returns
Static content.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 442 of file template_content_access.php.

{
try
{
$PackageName = $Options->get_setting( 'package_name' , false );
if( $PackageName === false )
{
return( $this->get_content( $Options->get_setting( 'template' ) ) );
}
else
{
return( $this->get_package_file( $Options ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_content_path (   $Template)

Function returns content.

Parameters
$Template- Content's file name.
Returns
Path to the content file.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 272 of file template_content_access.php.

{
try
{
$VirtualPath = dirname( __FILE__ )."/res/templates/$Template";
if( ( $Path = $this->try_virtual_path( $VirtualPath ) ) !== false )
{
return( $Path );
}
return( false );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_package_file ( $Options)

Function returns content for package.

Parameters
$Options- Display options.
Returns
Static content.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 404 of file template_content_access.php.

{
try
{
$PackageName = $Options->get_setting( 'package_name' , false );
$PackageVersion = $Options->get_setting( 'package_version' , 'last' );
$FileName = $Options->get_setting( 'template' , false );
return( $this->get_package_template( $PackageName , $PackageVersion , $FileName ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_package_template (   $PackageName,
  $PackageVersion,
  $Template 
)

Function returns content.

Parameters
$PackageName- Package name.
$PackageVersion- Package version.
$Template- Templates's file name.
Returns
Static content.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 364 of file template_content_access.php.

{
try
{
$PackageName = $this->Security->get( $PackageName , 'string' );
$PackageVersion = $this->Security->get( $PackageVersion , 'string' );
$Template = $this->Security->get( $Template , 'string' );
$Path = _get_package_relative_path_ex( $PackageName , $PackageVersion )."/res/templates/$Template";
return( $this->CachedMultyFS->file_get_contents( $Path ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
select_list (   $id)

Function selects list of objects.

Parameters
$id- Comma separated list of record's id.
Returns
Array of records.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 137 of file template_content_access.php.

{
try
{
$id = $this->Security->get( $id , 'string' );
$id = explode( ',' , $id );
$Return = array();
foreach( $id as $k => $v )
{
$Return [] = array( 'content' => $this->Security->get( $this->get_content( $v ) , 'string' ) );
}
return( $Return );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
set_add_condition (   $theAddCondition)

Function sets additional conditions.

Parameters
$theAddCondition- Additional conditions.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 96 of file template_content_access.php.

{
try
{
if( $this->AddCondition === false )
{
$this->AddCondition = $theAddCondition;
}
else
{
throw( new Exception( '"AddCondition" was already set' ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
try_virtual_path (   $VirtualPath)

Function checks virtual path.

Parameters
$VirtualPath- Path to the content's file name.
Returns
Path to the content file.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 226 of file template_content_access.php.

{
try
{
$Path = false;
if( $this->AddCondition !== false )
{
$Path = $this->CachedMultyFS->get_file_path( $VirtualPath."_$this->AddCondition" , false );
}
if( $Path === false )
{
$Path = $this->CachedMultyFS->get_file_path( $VirtualPath , false );
}
return( $Path );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
update (   $id,
  $Record 
)

Updating record.

Parameters
$id- Comma separated list of record's id.
$Record- Example for update.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 182 of file template_content_access.php.

{
try
{
$id = $this->Security->get( $id , 'string' );
$id = explode( ',' , $id );
$Record = $this->SecurityParser->parse_parameters( $Record , 'content:string' , 'allow_not_set' );
$Template = get_field( $Record , 'content' );
$Template = $this->Security->get( $Template , 'unsafe_string' );
foreach( $id as $k => $v )
{
$this->CachedMultyFS->file_put_contents( $this->get_content_path( $v ) , $Template );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Field Documentation

$AddCondition = false

Definition at line 76 of file template_content_access.php.

$CachedMultyFS = false

Cached objects.

Author
Dodonov A.A.

Definition at line 38 of file template_content_access.php.

$Security = false

Definition at line 39 of file template_content_access.php.

$SecurityParser = false

Definition at line 40 of file template_content_access.php.


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