Esempio n. 1
0
 /**
  * Should be transfered in Docman_Metadata
  * @param DOMDocument $doc
  * @return DOMNode
  */
 public function getMetadataDef(DOMDocument $doc)
 {
     $propdefs = $doc->createElement('propdefs');
     $mdFactory = new Docman_MetadataFactory($this->groupId);
     foreach ($mdFactory->getRealMetadataList() as $metadata) {
         $propdef = $doc->createElement('propdef');
         $propdef->setAttribute('name', $metadata->getName());
         switch ($metadata->getType()) {
             case PLUGIN_DOCMAN_METADATA_TYPE_TEXT:
                 $type = 'text';
                 break;
             case PLUGIN_DOCMAN_METADATA_TYPE_STRING:
                 $type = 'string';
                 break;
             case PLUGIN_DOCMAN_METADATA_TYPE_DATE:
                 $type = 'date';
                 break;
             case PLUGIN_DOCMAN_METADATA_TYPE_LIST:
                 $type = 'list';
                 break;
         }
         $propdef->setAttribute('type', $type);
         $propdef->setAttribute('multivalue', $metadata->getIsMultipleValuesAllowed() ? 'true' : 'false');
         $propdef->setAttribute('empty', $metadata->getIsEmptyAllowed() ? 'true' : 'false');
         if ($metadata->getType() == PLUGIN_DOCMAN_METADATA_TYPE_LIST) {
             $loveFactory = new Docman_MetadataListOfValuesElementFactory($metadata->getId());
             foreach ($loveFactory->getListByFieldId($metadata->getId(), $metadata->getLabel(), true) as $love) {
                 if ($love->getId() != 100) {
                     $value = $doc->createElement('value');
                     $value->appendChild($doc->createTextNode($love->getName()));
                     $propdef->appendChild($value);
                 }
             }
         }
         $propdefs->appendChild($propdef);
     }
     return $propdefs;
 }
 /**
  * Append elements of ListOfValues metadata.
  *
  * @param Docman_ListMetadata The metadata.
  * @param Boolean             Return only active values if true.
  */
 function appendMetadataValueList(&$md, $onlyActive = true)
 {
     if (is_a($md, 'Docman_ListMetadata')) {
         $mdLoveFactory = new Docman_MetadataListOfValuesElementFactory();
         $mdLoveArray =& $mdLoveFactory->getListByFieldId($md->getId(), $md->getLabel(), $onlyActive);
         $md->setListOfValueElements($mdLoveArray);
     }
 }
 /**
  * Returns the list of values for the given list metadata.
  */
 function getMetadataListOfValues()
 {
     $request =& $this->_controler->request;
     $groupId = $request->get('group_id');
     $metadataFactory = new Docman_MetadataFactory($groupId);
     $metadataLovFactory = new Docman_MetadataListOfValuesElementFactory();
     $label = $request->get('label');
     $md = $metadataFactory->getFromLabel($label);
     $res = array();
     if ($md->getType() == PLUGIN_DOCMAN_METADATA_TYPE_LIST) {
         foreach ($metadataLovFactory->getListByFieldId($md->id, $md->label, true) as $val) {
             $res[] = $val;
         }
     }
     $this->_controler->_viewParams['action_result'] = $res;
 }