function fetchFolder($folder, $params)
 {
     $hp = Codendi_HTMLPurifier::instance();
     $selected = '';
     if (!isset($params['selected']) || !$params['selected']) {
         if ($this->docman->userCanWrite($folder['id']) && (!$params['select'] || $params['select'] == $folder['id'])) {
             $selected = 'checked="checked"';
             $params['selected'] = true;
         }
     }
     $disabled = $this->docman->userCanWrite($folder['id']) ? '' : 'disabled="disabled"';
     $label_classes = $selected ? 'docman_item_actual_parent' : '';
     $h = '<li  class="' . Docman_View_Browse::getItemClasses(array('is_last' => $params['is_last'])) . '">';
     $h .= '<label for="item_parent_id_' . $folder['id'] . '" class="' . $label_classes . '" >';
     $h .= '<input type="radio" ' . $selected . ' name="' . $params['input_name'] . '" value="' . $folder['id'] . '" id="item_parent_id_' . $folder['id'] . '" ' . $disabled . ' />';
     $h .= '<img src="' . $folder['icon_src'] . '" class="docman_item_icon" />';
     $h .= $hp->purify($folder['title'], CODENDI_PURIFIER_CONVERT_HTML) . '</label>';
     $h .= '<script type="text/javascript">docman.addParentFoldersForNewItem(' . $folder['id'] . ', ' . $folder['parent_id'] . ", '" . $hp->purify(addslashes($folder['title']), CODENDI_PURIFIER_CONVERT_HTML) . "');</script>\n";
     $h .= '<ul class="docman_items">';
     $params['is_last'] = false;
     $nb = count($folder['items']);
     $i = 0;
     foreach ($folder['items'] as $item) {
         $i++;
         if ($i == $nb) {
             $params['is_last'] = true;
         }
         $h .= $this->fetchFolder($item, $params);
     }
     return $h . '</ul></li>';
 }
 function _displayItem(&$item, $params)
 {
     $li_displayed = false;
     if ($this->stripFirstNode && !$this->firstNodeStripped) {
         $this->firstNodeStripped = true;
         if (isset($this->params['display_description']) && $this->params['display_description']) {
             $this->html .= '<p>' . $item->getDescription() . '</p>';
         }
     } else {
         if ($item !== null && $this->_canDisplayItem($item)) {
             $this->html .= '<li id="item_' . $item->getId() . '" class="' . Docman_View_Browse::getItemClasses($params) . '">';
             $params['expanded'] = true;
             $open = '_open';
             if (!isset($this->params['item_to_move']) && user_get_preference(PLUGIN_DOCMAN_EXPAND_FOLDER_PREF . '_' . $item->getGroupId() . '_' . $item->getId()) === false) {
                 $params['expanded'] = false;
                 $open = '';
             }
             $icon_src = $this->params['docman_icons']->getIconForItem($item, $params);
             $icon = '<img src="' . $icon_src . '" class="docman_item_icon" />';
             $this->html .= '<div>';
             $action = isset($this->params['item_to_move']) ? false : $item->accept($this->get_action_on_icon, array('view' => &$this->view));
             if ($action) {
                 $class = $item->accept($this->get_class_for_link, array('view' => &$this->view));
                 if ($class) {
                     $class .= $open;
                 }
                 $url = Docman_View_View::buildUrl($this->params['default_url'], array('action' => $action, 'id' => $item->getId()));
                 $this->html .= '<a href="' . $url . '" class="' . $class . '">';
             }
             $this->html .= $icon;
             if ($action) {
                 $this->html .= '</a>';
             }
             $this->html .= '<span class="docman_item_title">';
             if ($action) {
                 $url = Docman_View_View::buildActionUrl($this->params, array('action' => 'show', 'id' => $item->getId()), false, isset($params['popup_doc']) ? true : false);
                 $this->html .= '<a href="' . $url . '" id="docman_item_title_link_' . $item->getId() . '">';
             }
             $this->html .= $this->hp->purify($item->getTitle(), CODENDI_PURIFIER_CONVERT_HTML);
             if ($action) {
                 $this->html .= '</a>';
             }
             $this->html .= '</span>';
             $this->html .= $this->view->getItemMenu($item, $this->params);
             $this->js .= $this->view->getActionForItem($item);
             $this->html .= '</div>';
             if (trim($item->getDescription()) != '') {
                 $this->html .= '<div class="docman_item_description">' . $this->hp->purify($item->getDescription(), CODENDI_PURIFIER_BASIC, $item->getGroupId()) . '</div>';
             }
             $li_displayed = true;
         }
     }
     return $li_displayed;
 }
 function _displayItem(&$item, $params)
 {
     $hp = Codendi_HTMLPurifier::instance();
     $html = '<div id="item_' . $item->getId() . '" class="' . Docman_View_Browse::getItemClasses($params) . '" style="position:relative;">';
     $show_options = isset($params['show_options']) && $params['show_options'] == $item->getId();
     $icon_src = $params['docman_icons']->getIconForItem($item, $params);
     $icon = '<img src="' . $icon_src . '" class="docman_item_icon" style="vertical-align:middle; text-decoration:none;" />';
     $icon_url = $this->buildUrl($params['default_url'], array('action' => $item->accept($params['get_action_on_icon'], array('view' => $this)), 'id' => $item->getId()));
     $title_url = $this->buildUrl($params['default_url'], array('action' => 'show', 'id' => $item->getId()));
     $html .= '<div><a href="' . $icon_url . '">' . $icon . '</a>';
     $html .= '<span class="docman_item_title"><a href="' . $title_url . '" id="docman_item_title_link_' . $item->getId() . '">' . $hp->purify($item->getTitle(), CODENDI_PURIFIER_CONVERT_HTML) . '</a></span>';
     $html .= '</a>';
     //Show/hide options {{{
     $html .= $this->getItemMenu($item, $params);
     $this->javascript .= $this->getActionForItem($item);
     //}}}
     if (trim($item->getDescription()) != '') {
         $html .= '<div class="docman_item_description">' . $hp->purify($item->getDescription(), CODENDI_PURIFIER_BASIC) . '</div>';
     }
     $html .= '</div>';
     $html .= '</div>';
     return $html;
 }