ACL Extension  0.3
 All Data Structures Namespaces Files Functions Variables
PmPathManager.php
Go to the documentation of this file.
1 <?php
2 
14 
22  public static function appendToPath($path, $id){
23  $separator = PmPathManager::getSeparator();
24  if(strlen($path) > 0 && $path[strlen($path) -1] != $separator)
25  $path .= $separator;
26  return $path.$id.self::getSeparator();
27  }
28 
33  public static function getParentPath($path){
34  $pos = strrpos($path, PmPathManager::getSeparator());
35 
36  //If it's like: /blablubb/dong/
37  //But consider path "4" ^^
38  if($pos == strlen($path) - 1 && strlen($path) > 1 ){
39  $path = substr($path, 0, -1);
40  $pos = strrpos($path, PmPathManager::getSeparator());
41  }
42  //Why? If the separator hasn't been found, we don't need to omit him!
43  $id = substr($path, $pos + ($pos !== false ? 1 : 0));
44  $newPath = substr($path, 0, $pos);
45 
46  return array('path' => $newPath,'id' => $id);
47  }
48 
59  public static function buildMultiplePathCondition($field, $paths, $additionalCondition = ''){
60  $condition = '';
61 
62  foreach($paths as $path){
63  //If we aren'T at the beginning
64  if(strlen($condition) != 0)
65  $condition .= ' OR ';
66 
67  $condition .= " (".$field." REGEXP CONCAT('^', '".$path."') ".
68  ($additionalCondition ? ' AND '.str_replace(':path', $path, $additionalCondition) : '')
69  ." ) ";
70  }
71 
72  return $condition;
73  }
74 
75  public static function getSeparator(){
76  return '/';
77  }
78 
79 }
80 
81 ?>