Detailed Description
Working with algorithms.
- Author
- Dodonov A.A.
Definition at line 26 of file category_algorithms.php.
Constructor & Destructor Documentation
Constructor.
- Author
- Dodonov A.A.
Definition at line 52 of file category_algorithms.php.
{
try
{
$this->CategoryAccess =
get_package(
'category::category_access' ,
'last' , __FILE__ );
$this->Link =
get_package(
'link' ,
'last' , __FILE__ );
$this->Security =
get_package(
'security' ,
'last' , __FILE__ );
}
catch( Exception $e )
{
}
}
Member Function Documentation
Creating record.
- Parameters
-
| $Record | Example for creation. |
- Returns
- id of the created record.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 330 of file category_algorithms.php.
{
try
{
$id = $this->CategoryAccess->create( $Record );
if(
get_field( $Record ,
'direct_category' ,
false ) ===
false )
{
{
$DirectCategory =
get_field( $RootCategory ,
'direct_category' );
$this->CategoryAccess->update( $id , array( 'direct_category' => $DirectCategory ) );
}
}
return( $id );
}
catch( Exception $e )
{
}
}
Function returns category by it's id.
- Parameters
-
| $id | - Id of the searching category. |
- Returns
- Category object.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 247 of file category_algorithms.php.
{
try
{
$id = $this->Security->get( $id , 'integer' );
$Users = $this->CategoryAccess->unsafe_select( $this->CategoryAccess->NativeTable.".id = $id" );
if( count( $Users ) === 0 || count( $Users ) > 1 )
{
throw( new Exception( 'Category with id '.$id.' was not found' ) );
}
else
{
return( $Users[ 0 ] );
}
}
catch( Exception $e )
{
}
}
| get_category_ids |
( |
|
$Names | ) |
|
Function returns ids of the categories by their names.
- Parameters
-
- Returns
- Ids.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 419 of file category_algorithms.php.
{
try
{
if( $Names == '' )
{
return( array() );
}
if( is_string( $Names ) )
{
$Names = explode( ',' , $Names );
}
$Ids = array();
foreach( $Names as $k => $v )
{
$Ids [] = $this->CategoryAccess->get_category_id( $v );
}
return( $Ids );
}
catch( Exception $e )
{
}
}
| get_children |
( |
|
$RootId, |
|
|
& |
$AllItems |
|
) |
| |
Function returns children.
- Parameters
-
| $RootId | - id of the tree's root. |
| $AllItems | - All elements of the tree. |
- Returns
- List of children.
- Exceptions
-
| Exception | - An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 94 of file category_algorithms.php.
{
try
{
$ReturnItems = array();
foreach( $AllItems as $k => $v )
{
{
$ReturnItems [] = $v;
}
}
return( $ReturnItems );
}
catch( Exception $e )
{
}
}
| get_children_by_name |
( |
|
$Name | ) |
|
Function returns subcategories.
- Parameters
-
| $Name | - Name of the category. |
- Returns
- Subcategories.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 470 of file category_algorithms.php.
{
try
{
$id = $this->CategoryAccess->get_category_id( $Name );
return( $this->CategoryAccess->get_children( $id ) );
}
catch( Exception $e )
{
}
}
| get_object_categories |
( |
|
$MasterId, |
|
|
|
$MasterType |
|
) |
| |
Function returns object's categories.
- Parameters
-
| $MasterId | - Master object's id. |
| $MasterType | - Master object's type. |
- Returns
- Records.
- Exceptions
-
| Exception | - An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 200 of file category_algorithms.php.
{
try
{
$Links = $this->Link->get_links( $MasterId , false , $MasterType , 'category' );
if( isset( $CategoryIds[ 0 ] ) )
{
$CategoryIds = implode( ',' , $CategoryIds );
return( $this->CategoryAccess->unsafe_select( "id IN ( $CategoryIds )" ) );
}
else
{
return( array() );
}
}
catch( Exception $e )
{
}
}
| get_previous_items |
( |
|
$AllItems, |
|
|
|
$LeafId |
|
) |
| |
Function returns subtree.
- Parameters
-
| $AllItems | - all elements of the tree. |
| $LeafId | - id of the leaf. |
- Returns
- List of parents.
- Exceptions
-
| Exception | - An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 142 of file category_algorithms.php.
{
try
{
$ReturnItems = array();
$CurrentId = $LeafId;
$ItemFound = false;
do
{
$ItemFound = false;
foreach( $AllItems as $k => $v )
{
if( $v->id == $CurrentId )
{
$ReturnItems [] = $v;
$CurrentId = $v->root_id;
$ItemFound = true;
break;
}
}
}
while( $ItemFound );
return( array_reverse( isset( $ReturnItems[ 1 ] ) ? $ReturnItems : array() ) );
}
catch( Exception $e )
{
}
}
Function validates object's existense.
- Parameters
-
- Returns
- true if the object exists.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 292 of file category_algorithms.php.
{
try
{
$id = $this->Security->get( $id , 'integer' );
$Records = $this->CategoryAccess->unsafe_select( $this->CategoryAccess->NativeTable.".id = $id" );
return( count( $Records ) === 1 );
}
catch( Exception $e )
{
}
}
| select_categories_list_by_name |
( |
|
$Name | ) |
|
Function returns all subcategories.
- Parameters
-
| $Name | - Name of the category. |
- Returns
- Subcategories.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 506 of file category_algorithms.php.
{
try
{
$id = $this->CategoryAccess->get_category_id( $Name );
return( $this->CategoryAccess->select_categories_list( $id ) );
}
catch( Exception $e )
{
}
}
| update_category_title |
( |
|
$cid, |
|
|
|
$Title |
|
) |
| |
Updating records.
- Parameters
-
| $cid | - Record's id. |
| $Title | - Category's title. |
- Returns
- Record.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 382 of file category_algorithms.php.
{
try
{
$cid = $this->Security->get( $cid , 'integer' );
$Title = $this->Security->get( $Title , 'string' );
$this->CategoryAccess->update( $cid , array( 'title' => $Title ) );
}
catch( Exception $e )
{
}
}
Field Documentation
The documentation for this class was generated from the following file: