.

PathStack Class Reference
[Lib]

Transform path into array and apply stack functionality. More...

List of all members.

Public Member Functions

  __construct ($path= '')
  adjust ($path)
  Points current element to first element not covered by $path_adjust.
  append_to_back ($path)
  Appends given path to back.
  clear_front ()
  Pushes all front items to back.
  count_front ()
  Returns the numbers of items in front.
  current ()
  Returns current item in path.
  get_path ()
  Return original path as string.
  implode_back ()
  Return path processed as string.
  implode_front ()
  Return path yet to process as string.
  next ()
  Takes current element, moves it to back, moves pointer forward and returns new current element.
  prepend_to_front ($path)
  Prepends given path to front.
  set_path ($path)
  Set path from string.
  shift ()
  Returns current element and moves pointer forward one step.

Detailed Description

Transform path into array and apply stack functionality.

Author:
Gerd Riesselmann

Definition at line 8 of file pathstack.cls.php.


Constructor & Destructor Documentation

PathStack::__construct ( path = ''  ) 

Definition at line 12 of file pathstack.cls.php.

00012                                                 {
00013                 $this->set_path($path);
00014         }

Member Function Documentation

PathStack::adjust ( path  ) 

Points current element to first element not covered by $path_adjust.

Returns:
True, if success, false otherwise

Definition at line 84 of file pathstack.cls.php.

00084                                       {
00085                 $adjust_stack = new PathStack($path);
00086                 $this_stack = clone($this);
00087                 
00088                 $cur = $adjust_stack->current(); 
00089                 while($cur !== false) {
00090                         if ($cur !== $this_stack->current()) {
00091                                 return false;
00092                         }
00093 
00094                         $cur = $adjust_stack->next();
00095                         $this_stack->do_next();
00096                 }
00097                 
00098                 $this->path_back = $this_stack->path_back;
00099                 $this->path_front = $this_stack->path_front;
00100                 return true;
00101         }
PathStack::append_to_back ( path  ) 

Appends given path to back.

Definition at line 113 of file pathstack.cls.php.

00113                                               {
00114                 $arr = array($this->implode_back());
00115                 if ($path !== '') {
00116                         $arr[] = $path;
00117                 }
00118                 return implode('/', $arr);
00119         }
PathStack::clear_front (  ) 

Pushes all front items to back.

Definition at line 149 of file pathstack.cls.php.

00149                                       {
00150                 while($this->next()) { }
00151         }
PathStack::count_front (  ) 

Returns the numbers of items in front.

Definition at line 142 of file pathstack.cls.php.

00142                                       {
00143                 return count($this->path_front);
00144         }
PathStack::current (  ) 

Returns current item in path.

Definition at line 41 of file pathstack.cls.php.

00041                                   {
00042                 if (count($this->path_front) > 0) {
00043                         return $this->path_front[0];
00044                 }
00045                 
00046                 return false;
00047         }
PathStack::get_path (  ) 

Return original path as string.

Definition at line 33 of file pathstack.cls.php.

00033                                    {
00034                 return $this->append_to_back($this->implode_front());
00035         }
PathStack::implode_back (  ) 

Return path processed as string.

Definition at line 106 of file pathstack.cls.php.

00106                                        {
00107                 return implode('/' , $this->path_back);
00108         }
PathStack::implode_front (  ) 

Return path yet to process as string.

Definition at line 135 of file pathstack.cls.php.

00135                                         {
00136                 return implode('/' , $this->path_front);
00137         }
PathStack::next (  ) 

Takes current element, moves it to back, moves pointer forward and returns new current element.

Definition at line 63 of file pathstack.cls.php.

00063                                {
00064                 $this->do_next();
00065                 return $this->current();
00066         }
PathStack::prepend_to_front ( path  ) 

Prepends given path to front.

Definition at line 124 of file pathstack.cls.php.

00124                                                 {
00125                 $arr = array($this->implode_front());
00126                 if ($path !== '') {
00127                         array_unshift($arr, $path);
00128                 }
00129                 return implode('/', $arr);              
00130         }
PathStack::set_path ( path  ) 

Set path from string.

Definition at line 19 of file pathstack.cls.php.

00019                                         {
00020                 $path = trim($path, '/');
00021                 if (!empty($path)) {
00022                         $this->path_front = explode('/', $path);
00023                 }
00024                 else {
00025                         $this->path_front = array();
00026                 }
00027                 $this->path_back = array();             
00028         }
PathStack::shift (  ) 

Returns current element and moves pointer forward one step.

Definition at line 71 of file pathstack.cls.php.

00071                                 {
00072                 $ret = $this->current();
00073                 if ($ret !== false) {
00074                         $this->do_next();
00075                 }
00076                 return $ret;
00077         }

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