ACL Extension  0.3
 All Data Structures Namespaces Files Functions Variables
PmPathManager Class Reference

Static Public Member Functions

static appendToPath ($path, $id)
static getParentPath ($path)
static buildMultiplePathCondition ($field, $paths, $additionalCondition= '')
static getSeparator ()

Detailed Description

Definition at line 13 of file PmPathManager.php.


Member Function Documentation

static appendToPath (   $path,
  $id 
)
static

Appends the given ID (denoting an element) to the given path

Parameters:
string$path
string$id
Returns:
string the full path including the new element

Definition at line 22 of file PmPathManager.php.

{
if(strlen($path) > 0 && $path[strlen($path) -1] != $separator)
$path .= $separator;
return $path.$id.self::getSeparator();
}
static buildMultiplePathCondition (   $field,
  $paths,
  $additionalCondition = '' 
)
static

Builds an sql-condition like: ($field LIKE [...] [AND condition]) OR ($field LIKE [...] [AND condition]) for all the given paths

Parameters:
string$fieldthe field to match (for example: path)
array[string]$paths
string$additionalConditionIf given, this will be used as an additional condition to every single path-like-condition (bound with and) Occurences of :path will be replaced with the provided path
Returns:
string the condition

Definition at line 59 of file PmPathManager.php.

{
$condition = '';
foreach($paths as $path){
//If we aren'T at the beginning
if(strlen($condition) != 0)
$condition .= ' OR ';
$condition .= " (".$field." REGEXP CONCAT('^', '".$path."') ".
($additionalCondition ? ' AND '.str_replace(':path', $path, $additionalCondition) : '')
." ) ";
}
return $condition;
}
static getParentPath (   $path)
static

Returns the parent path of the given path and the ID of the parent

Parameters:
array[stringpath, string ID] $path

Definition at line 33 of file PmPathManager.php.

{
$pos = strrpos($path, PmPathManager::getSeparator());
//If it's like: /blablubb/dong/
//But consider path "4" ^^
if($pos == strlen($path) - 1 && strlen($path) > 1 ){
$path = substr($path, 0, -1);
$pos = strrpos($path, PmPathManager::getSeparator());
}
//Why? If the separator hasn't been found, we don't need to omit him!
$id = substr($path, $pos + ($pos !== false ? 1 : 0));
$newPath = substr($path, 0, $pos);
return array('path' => $newPath,'id' => $id);
}
static getSeparator ( )
static

Definition at line 75 of file PmPathManager.php.

{
return '/';
}

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