Esempio n. 1
0
 /**
  * Get the tree string needed by the text edition applet
  * format is :
  * 	pageID/roottitle/subroottitle/pagetitle:::[SAME AS BEFORE...]
  * where ::: is the separator passed as argument
  * Static function.
  * Recursive function
  *
  * @param string $separator The pages separator.
  * @return string the tree string
  * @access public
  */
 static function getTreeString(&$user, $pageID, $separator, &$treeString)
 {
     static $treeStringInfos;
     $root = CMS_tree::getRoot();
     $lineage = CMS_tree::getLineage($root->getID(), $pageID, false);
     $treeString .= $pageID;
     //add ancestors
     if (is_array($lineage) && $lineage) {
         foreach ($lineage as $ancestor) {
             //to reduce the total time of the function (really long on big websites).
             if (!$treeStringInfos[$ancestor]) {
                 $ancestor = CMS_tree::getPageByID($ancestor);
                 $ancestorTitle = $treeStringInfos[$ancestor->getID()] = $ancestor->getTitle();
             } else {
                 $ancestorTitle = $treeStringInfos[$ancestor];
             }
             //test the presence of the separator in the sibling title
             if (io::strpos($ancestorTitle, $separator) !== false) {
                 CMS_grandFather::raiseError("Page has the separator in its title (transformed) : " . $ancestorTitle);
                 $title = str_replace($separator, "[SEPARATOR]", $ancestorTitle);
             } else {
                 $title = $ancestorTitle;
             }
             $treeString .= "/" . addslashes($title);
         }
     }
     $treeString .= $separator;
     //get siblings and recursively show them
     $sibs = CMS_tree::getSiblings($pageID, false, false);
     if (!$sibs) {
         return $treeString;
     }
     foreach ($sibs as $sib) {
         CMS_tree::getTreeString($user, $sib, $separator, $treeString);
     }
 }