function getRankField($value = 'end')
 {
     $html = '';
     $html .= '<tr>';
     $html .= '<td>' . $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_create_rank') . '</td>';
     $vals = array('beg', 'end', '--');
     $texts = array($GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_create_rank_beg'), $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_create_rank_end'), '----');
     $i = 3;
     $vIter =& $this->md->getListOfValueIterator();
     $vIter->rewind();
     while ($vIter->valid()) {
         $e =& $vIter->current();
         if ($e->getStatus() == 'A' || $e->getStatus() == 'P') {
             $vals[$i] = $e->getRank() + 1;
             $texts[$i] = $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_create_rank_after') . ' ' . Docman_MetadataHtmlList::_getElementName($e);
             $i++;
         }
         $vIter->next();
     }
     $html .= '<td>';
     $html .= html_build_select_box_from_arrays($vals, $texts, 'rank', $value, false, '');
     $html .= '</td>';
     $html .= '</tr>';
     return $html;
 }
 function _content($params)
 {
     $md =& $params['md'];
     $sthCanChange = false;
     $mdContent = '';
     $mdContent .= '<h3>' . $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_param_title') . '</h3>';
     $mdContent .= '<table>';
     $metaMdHtml = new Docman_MetaMetadataHtml($md);
     $mdContent .= $metaMdHtml->getName($sthCanChange);
     $mdContent .= $metaMdHtml->getDescription($sthCanChange);
     $mdContent .= $metaMdHtml->getType($sthCanChange);
     $mdContent .= $metaMdHtml->getEmptyAllowed($sthCanChange);
     if ($md->getType() == PLUGIN_DOCMAN_METADATA_TYPE_LIST) {
         $mdContent .= $metaMdHtml->getMultipleValuesAllowed($sthCanChange);
     }
     $mdContent .= $metaMdHtml->getUseIt($sthCanChange);
     $mdContent .= $metaMdHtml->getKeepHistory($sthCanChange);
     $mdContent .= '</table>';
     if ($sthCanChange) {
         $act_url = $this->buildUrl($params['default_url'], array());
         echo '<form name="md_details_update" method="POST" action="' . $act_url . '" class="docman_form">';
         echo '<input type="hidden" name="label" value="' . $md->getLabel() . '" />';
         echo '<input type="hidden" name="action" value="admin_md_details_update" />';
         echo $mdContent;
         echo '<input type="submit" name="submit" value="' . $GLOBALS['Language']->getText('plugin_docman', 'admin_md_details_update') . '" />';
         echo '</form>';
     } else {
         echo $mdContent;
     }
     //
     // Display list of values
     //
     if ($md->getType() == PLUGIN_DOCMAN_METADATA_TYPE_LIST) {
         echo '<h3>' . $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_title') . '</h3>';
         echo '<div class="docman_admin_list_values">' . "\n";
         echo html_build_list_table_top(array($GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_name'), $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_desc'), $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_status'), $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_delete')));
         $vIter =& $md->getListOfValueIterator();
         $vIter->rewind();
         $rowColorIdx = 0;
         while ($vIter->valid()) {
             $e =& $vIter->current();
             // Status
             $canDelete = false;
             $displayed = true;
             switch ($e->getStatus()) {
                 case 'A':
                     $canDelete = true;
                     $status = $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_active');
                     break;
                 case 'P':
                     $status = $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_perm');
                     break;
                 case 'D':
                     $displayed = false;
                     break;
                 default:
                     $status = $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_inactive');
             }
             if ($displayed) {
                 $class = ' class="' . html_get_alt_row_color($rowColorIdx++) . '"';
                 echo '<tr' . $class . '>';
                 // Name
                 $name = Docman_MetadataHtmlList::_getElementName($e);
                 if ($e->getId() > 100) {
                     $url = $this->buildUrl($params['default_url'], array('action' => 'admin_display_love', 'md' => $md->getLabel(), 'loveid' => $e->getId()));
                     $href = '<a href="' . $url . '">' . $name . '</a>';
                 } else {
                     $href = $name;
                 }
                 echo '<td>' . $href . '</td>';
                 // Description
                 echo '<td>' . Docman_MetadataHtmlList::_getElementDescription($e) . '</td>';
                 // Status
                 echo '<td>' . $status . '</td>';
                 // Delete
                 $trash = '-';
                 if ($canDelete) {
                     $link = '?group_id=' . $params['group_id'] . '&action=admin_delete_love&loveid=' . $e->getId() . '&md=' . $md->getLabel();
                     $warn = $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_delete_warn', array($name));
                     $alt = $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_delete_alt', array($name));
                     $trash = html_trash_link($link, $warn, $alt);
                 }
                 echo '<td>' . $trash . '</td>';
                 echo '</tr>';
             }
             $vIter->next();
         }
         echo '</table>';
         echo '</div><!--  docman_admin_list_values -->' . "\n";
         if ($md->getLabel() != 'status') {
             echo '<h3>' . $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_create_title') . '</h3>';
             $loveDetailsHtml = new Docman_View_LoveDetails($md);
             echo '<form name="md_create_love" method="POST" action="?group_id=' . $params['group_id'] . '&action=admin_create_love" class="docman_form">';
             echo $loveDetailsHtml->getHiddenFields();
             echo '<table>';
             echo $loveDetailsHtml->getNameField();
             echo $loveDetailsHtml->getDescriptionField();
             echo $loveDetailsHtml->getRankField();
             echo '</table>';
             echo '<input type="submit" name="submit" value="' . $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_val_create_submit') . '" />';
             echo '</form>';
         }
     }
     $backUrl = $this->buildUrl($params['default_url'], array('action' => 'admin_metadata'));
     echo '<p><a href="' . $backUrl . '">' . $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detail_backtomenu') . '</a></p>';
 }
 function _title($params)
 {
     echo '<h2>' . $this->_getTitle($params) . ' - ' . $GLOBALS['Language']->getText('plugin_docman', 'admin_md_detupdlove_title', array($params['md']->getName(), Docman_MetadataHtmlList::_getElementName($params['love']))) . '</h2>';
 }
 function _valueSelectorHtml($formName = 0)
 {
     $vIter =& $this->filter->md->getListOfValueIterator();
     $vIter->rewind();
     while ($vIter->valid()) {
         $e =& $vIter->current();
         if ($e->getStatus() == 'A' || $e->getStatus() == 'P') {
             $vals[] = $e->getId();
             $txts[] = Docman_MetadataHtmlList::_getElementName($e);
         }
         $vIter->next();
     }
     $html = $this->buildSelectBox($vals, $txts);
     return $html;
 }
 /**
  *
  * Same algo used in Docman_View_ItemDetailsSectionPaste::_checkLoveToImport
  */
 function getLoveCompareTable($srcMd, $dstMd, $mdMap, &$sthToImport)
 {
     $html = '';
     if ($srcMd->getLabel() == 'status') {
         // No differences possible with status.
         return $html;
     }
     // Get list of ListOfValues elements from dst project
     $srcLoveFactory = new Docman_MetadataListOfValuesElementFactory($srcMd->getId());
     $srcLoveIter = $srcLoveFactory->getIteratorByFieldId($srcMd->getId(), $srcMd->getLabel(), true);
     // Get list of ListOfValues elements from dst project
     $dstLoveFactory = new Docman_MetadataListOfValuesElementFactory($dstMd->getId());
     $dstLoveIter = $dstLoveFactory->getIteratorByFieldId($dstMd->getId(), $dstMd->getLabel(), true);
     $dstLoveArray = $this->getArrayFromIterator($dstLoveIter, 'getId');
     $maxRow = max($srcLoveIter->count(), $dstLoveIter->count());
     // Keep a trace of matching love
     $matchingLove = array();
     while ($srcLoveIter->valid()) {
         $srcLove = $srcLoveIter->current();
         $rowStyle = 'missing';
         // Compute the differences
         $dstLove = false;
         if (isset($mdMap['love'][$srcLove->getId()])) {
             $dstLove = $dstLoveArray[$mdMap['love'][$srcLove->getId()]];
             $matchingLove[$dstLove->getId()] = true;
             $rowStyle = 'equals';
         } else {
             $sthToImport = true;
         }
         $html .= "<tr>\n";
         // Name
         $html .= "<td style=\"padding-left: 2em;\"></td>\n";
         $html .= "<td>" . Docman_MetadataHtmlList::_getElementName($srcLove) . "</td>\n";
         // Presence in source project
         $html .= '<td align="center"><img src="' . $this->docmanIcons->getThemeIcon('tick.png') . '" /></td>';
         // Presence in destination project
         $html .= "<td align=\"center\">";
         switch ($rowStyle) {
             case 'equals':
                 $html .= '<img src="' . $this->docmanIcons->getThemeIcon('tick.png') . '" />';
                 break;
         }
         $html .= "</td>\n";
         // Differences
         $html .= "<td class=\"docman_md_" . $rowStyle . "\">";
         switch ($rowStyle) {
             case 'missing':
                 $html .= $GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_tbl_status_' . $rowStyle);
         }
         $html .= "</td>\n";
         // Action
         $html .= "<td>";
         switch ($rowStyle) {
             case 'missing':
                 $html .= $GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_tbl_act_import_love', array($srcLove->getName()));
         }
         $html .= "</td\n>";
         $html .= "</tr>\n";
         $srcLoveIter->next();
     }
     // Append to the table the list of values elements in the dst project
     // that where not present in the src project.
     foreach ($dstLoveArray as $love) {
         if (!isset($matchingLove[$love->getId()])) {
             $html .= "<tr>\n";
             // Name
             $html .= "<td>&nbsp;</td>\n";
             $html .= "<td>" . $love->getName() . "</td>\n";
             // Presence in source project
             $html .= "<td></td>\n";
             // Presence in destination project
             $html .= '<td align="center"><img src="' . $this->docmanIcons->getThemeIcon('tick.png') . '" /></td>';
             // Differences
             $html .= "<td></td>\n";
             // Action
             $html .= "<td></td>\n";
             $html .= "</tr>\n";
         }
     }
     return $html;
 }