Tree
[ class tree: Tree ] [ index: Tree ] [ all elements ]

Source for file treeClass.php

Documentation is available at treeClass.php

  1. <?php
  2. //
  3. //  $Log$
  4. //  Revision 1.1  2002/08/23 17:18:28  cain
  5. //  - a good example to show how the tree works
  6. //
  7. //
  8.  
  9. require_once('Tree/Memory.php');
  10.  
  11.  
  12. class treeClass extends Tree_Memory
  13. {
  14.  
  15.     function getPathAsString$id )
  16.     {
  17.         return preg_replace('/Root\s-\s/','',parent::getPathAsString$id ' - ' ));
  18.     }
  19.  
  20.     /**
  21.     *   just a wrapper to be compatible to vp_DB_Common
  22.     *
  23.     */
  24.     function &getAll()
  25.     {
  26.         return $this->getNode();
  27.     }
  28.  
  29.     /**
  30.     *   this is only for the getAllVisible it is called by the walk-method
  31.     *   to retreive only the nodes that shall be visible
  32.     *
  33.     *   @param      array   this is the node to check
  34.     *   @return     mixed   an array if the node shall be visible
  35.     *                        nothing if the node shall not be shown
  36.     */
  37.     function _walkForGettingVisibleFolders$node )
  38.     {
  39.         global $session;
  40.  
  41.         if$node['id']==$this->getRootId() )
  42.             return $node;
  43.  
  44.         $parentsIds $this->getParentsIds($node['id']);
  45.         if!@$this->_unfoldAll )
  46.         {
  47.             foreach$parentsIds as $aParentId )
  48.             {
  49.                 if!@$session->temp->openProjectFolders[$aParentId&&
  50.                     $aParentId!=$node['id'])    // dont check the node itself, since we only look if the parents are openend, then this $node is shown!
  51.                     return false;
  52.             }
  53.         }
  54.         else
  55.         {
  56.             // if all folders shall be unfolded save the unfold-ids in the session
  57.             $session->temp->openProjectFolders[$node['id']] $node['id'];
  58.         }
  59.         return $node;
  60.     }
  61.  
  62.     /**
  63.     *   this returns all the visible projects, the folders returned
  64.     *   are those which are unfolded, the explorer-like way
  65.     *   it also handles the 'unfold' parameter, which we simply might be given
  66.     *   so the unfold/fold works on every page that shows only visible folders
  67.     *   i think that is really cool :-)
  68.     *
  69.     *   @return     array   only those folders which are visible
  70.     */
  71.     function getAllVisible()
  72.     {
  73.         $this->unfoldHandler();
  74.         return $this->walkarray(&$this,'_walkForGettingVisibleFolders''ifArray' );
  75.     }
  76.  
  77.     function unfoldHandler()
  78.     {
  79.         global $session;
  80.  
  81.         if@$_REQUEST['unfoldAll')
  82.         {
  83.             $this->_unfoldAll = true;
  84.         }
  85.  
  86.         if@$_REQUEST['unfold')
  87.         {
  88.             if@$session->temp->openProjectFolders[$_REQUEST['unfold']] )
  89.             {
  90.                 unset($session->temp->openProjectFolders[$_REQUEST['unfold']]);
  91.             }
  92.             else
  93.             {
  94.                 $session->temp->openProjectFolders[$_REQUEST['unfold']] $_REQUEST['unfold'];
  95.             }
  96.         }
  97.     }
  98.  
  99.  
  100. }
  101.  
  102. ?>

Documentation generated on Mon, 11 Mar 2019 15:47:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.