/**
  * Return form to create a new metadata
  */
 function getNewMetadataForm($groupId)
 {
     $content = '';
     $content .= '<h3>' . $GLOBALS['Language']->getText('plugin_docman', 'admin_metadata_new_title') . '</h3>' . "\n";
     $content .= '<form name="admin_create_metadata" method="post" action="?group_id=' . $groupId . '&action=admin_create_metadata" class="docman_form">';
     $content .= '<table>';
     $md = new Docman_Metadata();
     $md->setCanChangeName(true);
     $md->setCanChangeType(true);
     $md->setCanChangeDescription(true);
     $md->setCanChangeIsEmptyAllowed(true);
     $md->setCanChangeIsMultipleValuesAllowed(true);
     $md->setIsEmptyAllowed(true);
     $md->setIsMultipleValuesAllowed(false);
     $sthCanChange = '';
     $metaMdHtml = new Docman_MetaMetadataHtml($md);
     $content .= $metaMdHtml->getName($sthCanChange);
     $content .= $metaMdHtml->getDescription($sthCanChange);
     $content .= $metaMdHtml->getType($sthCanChange);
     $content .= $metaMdHtml->getEmptyAllowed($sthCanChange);
     $content .= $metaMdHtml->getMultipleValuesAllowed($sthCanChange);
     $content .= $metaMdHtml->getUseIt($sthCanChange);
     $content .= '<tr>';
     $content .= '<td colspan="2">';
     $content .= '<input name="submit" type="submit" value="' . $GLOBALS['Language']->getText('plugin_docman', 'admin_metadata_new_submit') . '" />';
     $content .= '</td>';
     $content .= '</tr>';
     $content .= '</table>';
     $content .= '</form>';
     return $content;
 }
 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>';
 }