function _getItemVersionLink($version, $noLink = false)
 {
     $html = '';
     if ($version !== null) {
         $title = '';
         $url = '';
         $itemType = Docman_ItemFactory::getItemTypeForItem($this->item);
         if ($itemType == PLUGIN_DOCMAN_ITEM_TYPE_EMBEDDEDFILE || $itemType == PLUGIN_DOCMAN_ITEM_TYPE_FILE) {
             $vFactory =& new Docman_VersionFactory();
             $v = $vFactory->getSpecificVersion($this->item, $version);
             if ($v) {
                 $url = Docman_View_View::buildUrl($this->url, array('action' => 'show', 'id' => $this->item->getId(), 'version_number' => $v->getNumber()));
                 if ($v->getLabel()) {
                     $title .= $this->hp->purify($v->getLabel()) . ' - ';
                 }
             }
         } elseif ($itemType == PLUGIN_DOCMAN_ITEM_TYPE_WIKI) {
             $url = '/wiki/index.php?group_id=' . $this->item->getGroupId() . '&pagename=' . $this->item->getPagename() . '&version=' . $version;
         }
         $title .= $GLOBALS['Language']->getText('plugin_docman', 'details_approval_version_link') . ' ' . $version;
         if ($noLink) {
             $html .= $title;
         } else {
             $html .= '<a href="' . $url . '">' . $title . '</a>';
         }
     }
     return $html;
 }
 function _getDirectLinkField()
 {
     $html = '';
     $itemFactory = new Docman_ItemFactory();
     if ($itemFactory->getItemTypeForItem($this->item) != PLUGIN_DOCMAN_ITEM_TYPE_FOLDER) {
         $dpm =& Docman_PermissionsManager::instance($this->item->getGroupId());
         $um =& UserManager::instance();
         $user = $um->getCurrentUser();
         if (!$this->item->isObsolete() || $this->item->isObsolete() && $dpm->userCanAdmin($user)) {
             $label = $GLOBALS['Language']->getText('plugin_docman', 'details_properties_view_doc_lbl');
             $url = $this->url . '&action=show&id=' . $this->item->getId();
             $href = '<a href="' . $url . '">' . $GLOBALS['Language']->getText('plugin_docman', 'details_properties_view_doc_val') . '</a>';
         }
         $html = $this->_getPropertyRow($GLOBALS['Language']->getText('plugin_docman', 'details_properties_view_doc_lbl'), $href);
     }
     return $html;
 }
 function getTable($params)
 {
     $html = '';
     // Get root
     $itemFactory = new Docman_ItemFactory($params['group_id']);
     $rootItem = $itemFactory->getRoot($params['group_id']);
     $nbItemsFound = 0;
     $itemIterator =& $itemFactory->getItemList($rootItem->getId(), $nbItemsFound, array('user' => $params['user'], 'ignore_collapse' => true, 'obsolete_only' => true));
     $table = html_build_list_table_top(array('Title', 'Obsolete date'));
     $altRowClass = 0;
     $itemIterator->rewind();
     while ($itemIterator->valid()) {
         $item =& $itemIterator->current();
         $type = $itemFactory->getItemTypeForItem($item);
         if ($type != PLUGIN_DOCMAN_ITEM_TYPE_FOLDER) {
             $trclass = html_get_alt_row_color($altRowClass++);
             $table .= "<tr class=\"" . $trclass . "\">\n";
             // Name
             $docmanIcons =& $this->_getDocmanIcons($params);
             $icon_src = $docmanIcons->getIconForItem($item, $params);
             $icon = '<img src="' . $icon_src . '" class="docman_item_icon" />';
             $table .= "<td>";
             $table .= '<span style="white-space: nowrap;">';
             $table .= $icon;
             $url = $this->buildActionUrl($params, array('action' => 'details', 'id' => $item->getId()), false, true);
             $table .= '<a href="' . $url . '">';
             $table .= htmlentities($item->getTitle(), ENT_QUOTES, 'UTF-8');
             $table .= '</a>';
             $table .= '</span>';
             $table .= "</td>\n";
             // Obsolete date
             $table .= "<td>";
             $table .= format_date("Y-m-j", $item->getObsolescenceDate());
             $table .= "</td>\n";
             $table .= "</tr>\n";
         }
         $itemIterator->next();
     }
     $table .= "</table>\n";
     $html = $table;
     return $html;
 }
 function _getSpecificProperties($params)
 {
     $html = '';
     $currentItemType = null;
     if (isset($params['force_item'])) {
         $currentItemType = Docman_ItemFactory::getItemTypeForItem($params['force_item']);
     }
     $specifics = array(array('type' => PLUGIN_DOCMAN_ITEM_TYPE_EMPTY, 'label' => $GLOBALS['Language']->getText('plugin_docman', 'new_document_empty'), 'obj' => isset($params['force_item']) && $currentItemType == PLUGIN_DOCMAN_ITEM_TYPE_EMPTY ? $params['force_item'] : new Docman_Empty(), 'checked' => $currentItemType == PLUGIN_DOCMAN_ITEM_TYPE_EMPTY), array('type' => PLUGIN_DOCMAN_ITEM_TYPE_LINK, 'label' => $GLOBALS['Language']->getText('plugin_docman', 'new_document_link'), 'obj' => isset($params['force_item']) && $currentItemType == PLUGIN_DOCMAN_ITEM_TYPE_LINK ? $params['force_item'] : new Docman_Link(), 'checked' => $currentItemType == PLUGIN_DOCMAN_ITEM_TYPE_LINK));
     $wikiAvailable = true;
     if (isset($params['group_id'])) {
         $pm = ProjectManager::instance();
         $go = $pm->getProject($params['group_id']);
         $wikiAvailable = $go->usesWiki() || $go->usesService('plugin_phpwiki');
     }
     if ($wikiAvailable) {
         $specifics[] = array('type' => PLUGIN_DOCMAN_ITEM_TYPE_WIKI, 'label' => $GLOBALS['Language']->getText('plugin_docman', 'new_document_wiki'), 'obj' => isset($params['force_item']) && $currentItemType == PLUGIN_DOCMAN_ITEM_TYPE_WIKI ? $params['force_item'] : new Docman_Wiki(), 'checked' => $currentItemType == PLUGIN_DOCMAN_ITEM_TYPE_WIKI);
     }
     $specifics[] = array('type' => PLUGIN_DOCMAN_ITEM_TYPE_FILE, 'label' => $GLOBALS['Language']->getText('plugin_docman', 'new_document_file'), 'obj' => isset($params['force_item']) && $currentItemType == PLUGIN_DOCMAN_ITEM_TYPE_FILE ? $params['force_item'] : new Docman_File(), 'checked' => $currentItemType !== null ? $currentItemType == PLUGIN_DOCMAN_ITEM_TYPE_FILE : true);
     if ($this->_controller->getProperty('embedded_are_allowed')) {
         $specifics[] = array('type' => PLUGIN_DOCMAN_ITEM_TYPE_EMBEDDEDFILE, 'label' => $GLOBALS['Language']->getText('plugin_docman', 'new_document_embedded'), 'obj' => isset($params['force_item']) && $currentItemType == PLUGIN_DOCMAN_ITEM_TYPE_EMBEDDEDFILE ? $params['force_item'] : new Docman_EmbeddedFile(), 'checked' => $currentItemType == PLUGIN_DOCMAN_ITEM_TYPE_EMBEDDEDFILE);
     }
     $get_specific_fields = new Docman_View_GetSpecificFieldsVisitor();
     foreach ($specifics as $specific) {
         $html .= '<div><label class="docman-create-doctype radio" for="item_item_type_' . $specific['type'] . '">';
         $html .= '<input type="radio" name="item[item_type]" value="' . $specific['type'] . '" id="item_item_type_' . $specific['type'] . '" ' . ($specific['checked'] ? 'checked="checked"' : '') . '/>';
         $html .= '<b>' . $specific['label'] . '</b></label></div>';
         $html .= '<div style="padding-left:20px" id="item_item_type_' . $specific['type'] . '_specific_properties">';
         $fields = $specific['obj']->accept($get_specific_fields, array('request' => &$this->controller->request));
         $html .= '<table>';
         foreach ($fields as $field) {
             $html .= '<tr style="vertical-align:top;"><td><label>' . $field->getLabel() . '</label></td><td>' . $field->getField() . '</td></tr>';
         }
         $html .= '</table>';
         $html .= '</div>';
     }
     return $html;
 }
 function visitWiki(&$item, $params = array())
 {
     $pagename = '';
     if (isset($params['force_item'])) {
         if (Docman_ItemFactory::getItemTypeForItem($params['force_item']) == PLUGIN_DOCMAN_ITEM_TYPE_WIKI) {
             $pagename = $params['force_item']->getPagename();
         }
     } else {
         $pagename = $item->getPagename();
     }
     return array(new Docman_MetadataHtmlWiki($pagename));
 }