Example #1
0
 /**
  * get the url filename only
  */
 function get_url_file()
 {
     return basename_international(preg_replace("|^(.*)://|", "", $this->url));
 }
 function &_array_recurse($array, $categories = array())
 {
     if (!is_array($array)) {
         $array = array();
     }
     $node =& $this->_last_node;
     $current_node =& $node;
     $expandedIcon = 'folder-expanded.gif';
     foreach ($array as $id => $ar) {
         $icon = 'folder.gif';
         if (is_array($ar) || !empty($id)) {
             if ($node == null) {
                 //echo "r:" . $this->tree->get_node_name($id) . "<br>";
                 $rnode = new HTML_TreeNode(array("id" => $id, 'text' => $this->tree->get_node_name($id), 'link' => $this->_link("upload") . "parent_id=" . $id . "&", 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => false));
                 $this->_last_node =& $rnode;
                 $node =& $rnode;
                 $current_node =& $rnode;
             } else {
                 //echo "p:" . $this->tree->get_node_name($id) . "<br>";
                 $this->_last_node =& $node->addItem(new HTML_TreeNode(array("id" => $id, 'text' => $this->tree->get_node_name($id), 'link' => $this->_link("upload") . "parent_id=" . $id . "&", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
                 $current_node =& $this->_last_node;
             }
             $this->_array_recurse($ar, $categories);
         } else {
             if ($id === 0 && !empty($ar)) {
                 $info = $this->tree->get_node_info($id);
                 //echo "b:" . $this->tree->get_node_name($id) . "<br>";
                 $current_node =& $node->addItem(new HTML_TreeNode(array("id" => $id, 'text' => $info['value'], 'link' => $this->_link("upload") . "parent_id=" . $id . "&", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
             } else {
                 //there is a third case that is implicit here when title === 0 and $ar is empty, in that case we do not want to do anything
                 //this conditional tree could be more efficient but working with recursive trees makes my head hurt, TODO
                 if ($id !== 0 && is_object($node)) {
                     //echo "n:" . $this->tree->get_node_name($id) . "<br>";
                     $current_node =& $node->addItem(new HTML_TreeNode(array("id" => $id, 'text' => $this->tree->get_node_name($id), 'link' => $this->_link("upload") . "parent_id=" . $id . "&", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
                 }
             }
         }
         // If there are documents in this document category, then add their
         // attributes to the current node.
         $icon = "file3.png";
         if (is_array($categories[$id])) {
             foreach ($categories[$id] as $doc) {
                 if ($this->tree->get_node_name($id) == "CCR") {
                     $current_node->addItem(new HTML_TreeNode(array('text' => $doc['docdate'] . ' ' . basename_international($doc['url']), 'link' => $this->_link("view") . "doc_id=" . $doc['document_id'] . "&", 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'events' => array('Onclick' => "javascript:newwindow=window.open('ccr/display.php?type=CCR&doc_id=" . $doc['document_id'] . "','CCR');"))));
                 } elseif ($this->tree->get_node_name($id) == "CCD") {
                     $current_node->addItem(new HTML_TreeNode(array('text' => $doc['docdate'] . ' ' . basename_international($doc['url']), 'link' => $this->_link("view") . "doc_id=" . $doc['document_id'] . "&", 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'events' => array('Onclick' => "javascript:newwindow=window.open('ccr/display.php?type=CCD&doc_id=" . $doc['document_id'] . "','CCD');"))));
                 } else {
                     $current_node->addItem(new HTML_TreeNode(array('text' => $doc['docdate'] . ' ' . basename_international($doc['url']), 'link' => $this->_link("view") . "doc_id=" . $doc['document_id'] . "&", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
                 }
             }
         }
     }
     return $node;
 }