ultimix
page_access_1_0_0 Class Reference

Public Member Functions

 __construct ()
 set_add_limitations ($theAddLimitation)
 get_raw_page ($PageName)
 parse_raw_page ($RawData)
 get_package_appliance ($PageName, $Parse=true)
 set_package_appliance ($PageName, $Packages)
 get_page_description ($PageName)
 get_list_of_pages ()
 select ($Start, $Limit, $Field=false, $Order=false, $Condition=false)
 page_exists ($PageName)
 create (&$Record)
 update ($PageName, $Title, $Template, $TemplateVersion, $PredefinedPackages)
 delete ($PageNames)
 add_package ($PageName, $PackageName, $PackageVersion, $Params, $PlaceHolder)
 select_list ($PageNames)

Data Fields

 $CachedMultyFS = false
 $Security = false
 $AddLimitations = '1 = 1'

Detailed Description

Class provides access for data about pages.

Author
Dodonov A.A.

Definition at line 26 of file page_access.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Author
Dodonov A.A.

Definition at line 51 of file page_access.php.

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

Member Function Documentation

add_package (   $PageName,
  $PackageName,
  $PackageVersion,
  $Params,
  $PlaceHolder 
)

Function adds package to page.

Parameters
$PageName- Name of the page.
$PackageName- Package's name.
$PackageVersion- Package version.
$Params- Parameters.
$PlaceHolder- Placeholder.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 811 of file page_access.php.

{
try
{
$PageName = $this->Security->get( $PageName , 'command' );
$CachedFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
$CachedFS->file_put_contents(
dirname( __FILE__ ).'/data/pa_'.$PageName ,
$PackageName.'#'.$PackageVersion.'#'.$Params.'#'.$PlaceHolder."\r\n" , FILE_APPEND
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
create ( $Record)

Function creates page.

Parameters
$Record- Data.
Returns
Title of the created page.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 657 of file page_access.php.

{
try
{
$PageName = $this->Security->get( get_field( $Record , 'page_alias' ) , 'command' );
if( $this->page_exists( $PageName ) )
{
return( $PageName );
}
$Page = $this->compile_create_data( $Record );
$this->CachedMultyFS->file_put_contents( dirname( __FILE__ )."/data/".$PageName , $Page );
$this->CachedMultyFS->file_put_contents( dirname( __FILE__ )."/data/pa_".$PageName , '' );
return( $PageName );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
delete (   $PageNames)

Function deletes page.

Parameters
$PageNames- Name of pages.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 754 of file page_access.php.

{
try
{
$PageNames = explode( ',' , $PageNames );
foreach( $PageNames as $i => $PageName )
{
$PageName = $this->Security->get( $PageName , 'command' );
@unlink( dirname( __FILE__ ).'/data/'.$PageName );
@unlink( dirname( __FILE__ ).'/data/pa_'.$PageName );
$EventManager = get_package( 'event_manager' , 'last' , __FILE__ );
$EventManager->trigger_event( 'on_after_delete_page' , array( 'page_name' => $PageName ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_list_of_pages ( )

Function returns a list of pages.

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

Definition at line 415 of file page_access.php.

{
try
{
$ListOfPages = array();
$MountedStorages = $this->CachedMultyFS->get_mounted_storages();
$MountedStorages [] = dirname( __FILE__ ).'/data';
foreach( $MountedStorages as $ms )
{
if( $Handle = @opendir( $ms ) )
{
while( false !== ( $File = readdir( $Handle ) ) )
{
$Flag = strpos( $File , 'pa_' ) !== 0 && strpos( $File , 'index.html' ) !== 0;
if( is_file( dirname( __FILE__ ).'/data/'.$File ) && $Flag )
{
$ListOfPages [] = $this->get_page_description( $File );
}
}
closedir( $Handle );
}
}
return( $ListOfPages );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_package_appliance (   $PageName,
  $Parse = true 
)

Function returns list of packages wich are applied to the page $PageName.

Parameters
$PageName- Name of the page.
$Parse- Parse data or not.
Returns
Information about all packages wich are applied to the page.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 235 of file page_access.php.

{
try
{
$RawData = $this->get_raw_page( $PageName );
if( $Parse == true )
{
if( strlen( $RawData ) !== 0 )
{
return( $this->parse_raw_page( $RawData ) );
}
return( array() );
}
return( $RawData );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_page_description (   $PageName)

Function returns description of the requested page.

Parameters
$PageName- Name of the requested page.
Returns
Description of the requesting page in the folowing representation : array( 0 => array( id , title , name , template , template_version ) )
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 374 of file page_access.php.

{
try
{
$PageName = $this->Security->get( $PageName , 'command' );
if( $this->CachedMultyFS->file_exists( dirname( __FILE__ ).'/data/'.$PageName ) )
{
$RawData = $this->CachedMultyFS->file_get_contents( dirname( __FILE__ ).'/data/'.$PageName );
return( $this->create_object( $RawData , $PageName ) );
}
return( false );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_raw_page (   $PageName)

Function returns content of the page file.

Parameters
$PageName- Name of the page.
Returns
Content of the page file
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 135 of file page_access.php.

{
try
{
$PageName = $this->Security->get( $PageName , 'command' );
$FileName = dirname( __FILE__ ).'/data/pa_'.$PageName;
if( $this->CachedMultyFS->file_exists( $FileName ) )
{
$RawData = $this->CachedMultyFS->file_get_contents( $FileName , 'cleaned' );
}
else
{
$RawData = '';
}
return( $RawData );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
page_exists (   $PageName)

Does page exists.

Parameters
$PageName- Name of the requested page.
Returns
true if the page exists
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 582 of file page_access.php.

{
try
{
$PageName = $this->Security->get( $PageName , 'command' );
return( $this->CachedMultyFS->file_exists( dirname( __FILE__ )."/data/".$PageName ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
parse_raw_page (   $RawData)

Function parses page packages.

Parameters
$RawData- Content of the page file.
Returns
Information about all packages wich are applied to the page.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 182 of file page_access.php.

{
try
{
$Appliance = array();
$RawData = explode( "\n" , $RawData );
$c = count( $RawData );
for( $i = 0 ; $i < $c ; $i++ )
{
$RawDataInfo = explode( '#' , $RawData[ $i ] );
$Appliance [] = array(
'package' => @$RawDataInfo[ 0 ] , 'package_version' => @$RawDataInfo[ 1 ] ,
'options' => @$RawDataInfo[ 2 ] , 'placeholder' => @$RawDataInfo[ 3 ]
);
}
return( $Appliance );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
select (   $Start,
  $Limit,
  $Field = false,
  $Order = false,
  $Condition = false 
)

Function returns list of pages.

Parameters
$Start- Number of the first record.
$Limit- Count of records limitation.
$Field- Field to sort by.
$Order- Sorting order.
Returns
List of pages.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 536 of file page_access.php.

{
try
{
$ListOfPages = $this->get_list_of_pages();
if( $Order !== false )
{
$SortSign = $Order === 'ascending' ? '<' : '>';
$SortFunc = create_function(
'$a , $b' , "if( \$a[ '$Field' ] == \$b[ '$Field' ] )".
"return(0);return( \$a[ '$Field' ] $SortSign \$b[ '$Field' ] ? -1 : 1 );"
);
usort( $ListOfPages , $SortFunc );
}
return( $this->filter_pages( $ListOfPages , $Limit ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
select_list (   $PageNames)

Function selects list of objects.

Parameters
$PageNames- List of page names.
Returns
Array of records.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 851 of file page_access.php.

{
try
{
if( is_string( $PageNames ) )
{
$PageNames = explode( ',' , $PageNames );
}
$Pages = array();
foreach( $PageNames as $i => $PageName )
{
$Pages [] = $this->get_page_description( $PageName );
}
return( $Pages );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
set_add_limitations (   $theAddLimitation)

Function sets additional limitations.

Parameters
$theAddLimitation- Additional limitations.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 94 of file page_access.php.

{
try
{
if( $this->AddLimitations === '1 = 1' )
{
$this->AddLimitations = $theAddLimitation;
}
else
{
throw( new Exception( '"AddLimitations" was already set' ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
set_package_appliance (   $PageName,
  $Packages 
)

Function sets list of packages wich are applied to the page $PageName.

Parameters
$PageName- Name of the page.
$Packages- Packages.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 281 of file page_access.php.

{
try
{
$PageName = $this->Security->get( $PageName , 'command' );
$Packages = $this->Security->get( $Packages , 'unsafe_string' );
$this->CachedMultyFS->file_put_contents( dirname( __FILE__ ).'/data/pa_'.$PageName , $Packages );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
update (   $PageName,
  $Title,
  $Template,
  $TemplateVersion,
  $PredefinedPackages 
)

Function updates page.

Parameters
$PageName- Name of the page.
$Title- Page's title.
$Template- Template name.
$TemplateVersion- Template version.
$PredefinedPackages- Page's settings.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 715 of file page_access.php.

{
try
{
$PageName = $this->Security->get( $PageName , 'command' );
$Page = $this->get_page_description( $PageName );
$Title = $this->Security->get( $Title , 'string' );
$Template = $this->Security->get( $Template , 'string' );
$TemplateVersion = $this->Security->get( $TemplateVersion , 'command' );
$PredefinedPackages = $this->Security->get( $PredefinedPackages , 'string' );
$Path = dirname( __FILE__ )."/data/$PageName";
$this->CachedMultyFS->file_put_contents( $Path , "$Title#$Template#$TemplateVersion#$Options" );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Field Documentation

$AddLimitations = '1 = 1'

Definition at line 74 of file page_access.php.

$CachedMultyFS = false

Cached objects.

Author
Dodonov A.A.

Definition at line 38 of file page_access.php.

$Security = false

Definition at line 39 of file page_access.php.


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