Exemplo n.º 1
0
 public function getPlace(array $options = array())
 {
     $criteria = new Criteria();
     $criteria->add(QubitObjectTermRelation::OBJECT_ID, $this->id);
     $criteria->addJoin(QubitObjectTermRelation::TERM_ID, QubitTerm::ID);
     $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::PLACE_ID);
     $relation = QubitObjectTermRelation::get($criteria);
     if (count($relation) > 0) {
         return $relation[0]->getTerm();
     } else {
         return null;
     }
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'type':
             $criteria = new Criteria();
             $this->resource->addObjectTermRelationsRelatedByObjectIdCriteria($criteria);
             QubitObjectTermRelation::addJoinTermCriteria($criteria);
             $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::MODS_RESOURCE_TYPE_ID);
             $value = array();
             foreach ($this->relations = QubitObjectTermRelation::get($criteria) as $item) {
                 $value[] = $this->context->routing->generate(null, array($item->term, 'module' => 'term'));
             }
             $this->form->setDefault('type', $value);
             $this->form->setValidator('type', new sfValidatorPass());
             $choices = array();
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::MODS_RESOURCE_TYPE_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('type', new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true)));
             break;
         default:
             return parent::addField($name);
     }
 }
Exemplo n.º 3
0
 public function delete($connection = null)
 {
     // Cascade delete descendants
     if (0 < count($children = $this->getChildren())) {
         foreach ($children as $child) {
             $child->delete($connection);
         }
     }
     // Delete relations
     $criteria = new Criteria();
     $cton1 = $criteria->getNewCriterion(QubitRelation::OBJECT_ID, $this->id);
     $cton2 = $criteria->getNewCriterion(QubitRelation::SUBJECT_ID, $this->id);
     $cton1->addOr($cton2);
     $criteria->add($cton1);
     if (0 < count($relations = QubitRelation::get($criteria))) {
         foreach ($relations as $relation) {
             $relation->delete($connection);
         }
     }
     // Delete relation to objects
     $criteria = new Criteria();
     $criteria->add(QubitObjectTermRelation::TERM_ID, $this->id);
     if (0 < count($otRelations = QubitObjectTermRelation::get($criteria))) {
         foreach ($otRelations as $otRelation) {
             $otRelation->delete($connection);
         }
     }
     parent::delete($connection);
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'type':
             $criteria = new Criteria();
             $criteria = $this->resource->addObjectTermRelationsRelatedByObjectIdCriteria($criteria);
             $criteria->addJoin(QubitObjectTermRelation::TERM_ID, QubitTerm::ID);
             $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::REPOSITORY_TYPE_ID);
             $value = array();
             foreach ($this->relations = QubitObjectTermRelation::get($criteria) as $item) {
                 $value[] = $this->context->routing->generate(null, array($item->term, 'module' => 'term'));
             }
             $this->form->setDefault('type', $value);
             $this->form->setValidator('type', new sfValidatorPass());
             $choices = array();
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::REPOSITORY_TYPE_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item->__toString();
             }
             $this->form->setWidget('type', new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true)));
             break;
         case 'descDetail':
         case 'descStatus':
             $this->form->setDefault($name, $this->context->routing->generate(null, array($this->resource[$name], 'module' => 'term')));
             $this->form->setValidator($name, new sfValidatorString());
             switch ($name) {
                 case 'descDetail':
                     $id = QubitTaxonomy::DESCRIPTION_DETAIL_LEVEL_ID;
                     break;
                 case 'descStatus':
                     $id = QubitTaxonomy::DESCRIPTION_STATUS_ID;
                     break;
             }
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTermsById($id) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'identifier':
         case 'authorizedFormOfName':
         case 'descIdentifier':
         case 'descInstitutionIdentifier':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
             break;
         case 'history':
         case 'geoculturalContext':
         case 'mandates':
         case 'internalStructures':
         case 'collectingPolicies':
         case 'buildings':
         case 'holdings':
         case 'findingAids':
         case 'openingTimes':
         case 'accessConditions':
         case 'disabledAccess':
         case 'researchServices':
         case 'reproductionServices':
         case 'publicFacilities':
         case 'descRules':
         case 'descRevisionHistory':
         case 'descSources':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormTextarea());
             break;
         default:
             return parent::addField($name);
     }
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'alternateTitle':
         case 'edition':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
             break;
         case 'editionStatementOfResponsibility':
         case 'issuingJurisdictionAndDenomination':
         case 'noteOnPublishersSeries':
         case 'numberingWithinPublishersSeries':
         case 'otherTitleInformation':
         case 'otherTitleInformationOfPublishersSeries':
         case 'parallelTitleOfPublishersSeries':
         case 'standardNumber':
         case 'statementOfCoordinates':
         case 'statementOfProjection':
         case 'statementOfResponsibilityRelatingToPublishersSeries':
         case 'statementOfScaleArchitectural':
         case 'statementOfScaleCartographic':
         case 'titleStatementOfResponsibility':
         case 'titleProperOfPublishersSeries':
             $this->form->setDefault($name, $this->rad[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
             break;
         case 'type':
             $criteria = new Criteria();
             $this->resource->addObjectTermRelationsRelatedByObjectIdCriteria($criteria);
             QubitObjectTermRelation::addJoinTermCriteria($criteria);
             $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::MATERIAL_TYPE_ID);
             $value = array();
             foreach ($this->relations = QubitObjectTermRelation::get($criteria) as $item) {
                 $value[] = $this->context->routing->generate(null, array($item->term, 'module' => 'term'));
             }
             $this->form->setDefault('type', $value);
             $this->form->setValidator('type', new sfValidatorPass());
             $choices = array();
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::MATERIAL_TYPE_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('type', new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true)));
             break;
         default:
             return parent::addField($name);
     }
 }
Exemplo n.º 6
0
 /**
  * Get many-to-many links to QubitTerm objects
  *
  * @param mixed $taxonomyId  Limit results by taxonomy type
  * @return QubitQuery collection of QubitObjectTermRelation objects
  */
 public function getTermRelations($taxonomyId = 'all')
 {
     $criteria = new Criteria();
     $criteria->add(QubitObjectTermRelation::OBJECT_ID, $this->id);
     if ($taxonomyId != 'all') {
         $criteria->addJoin(QubitObjectTermRelation::TERM_ID, QubitTERM::ID);
         $criteria->add(QubitTerm::TAXONOMY_ID, $taxonomyId);
     }
     return QubitObjectTermRelation::get($criteria);
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'levelOfDescription':
             $this->form->setDefault('levelOfDescription', $this->context->routing->generate(null, array($this->resource->levelOfDescription, 'module' => 'term')));
             $this->form->setValidator('levelOfDescription', new sfValidatorString());
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTaxonomyTerms(QubitTaxonomy::LEVEL_OF_DESCRIPTION_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('levelOfDescription', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'publicationStatus':
             $publicationStatus = $this->resource->getStatus(array('typeId' => QubitTerm::STATUS_TYPE_PUBLICATION_ID));
             if (isset($publicationStatus)) {
                 $this->form->setDefault('publicationStatus', $publicationStatus->statusId);
             } else {
                 $this->form->setDefault('publicationStatus', sfConfig::get('app_defaultPubStatus'));
             }
             $this->form->setValidator('publicationStatus', new sfValidatorString());
             if (isset($this->resource) && QubitAcl::check($this->resource, 'publish') || !isset($this->resurce) && QubitAcl::check($this->parent, 'publish')) {
                 $choices = array();
                 foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::PUBLICATION_STATUS_ID) as $item) {
                     $choices[$item->id] = $item;
                 }
                 $this->form->setWidget('publicationStatus', new sfWidgetFormSelect(array('choices' => $choices)));
             } else {
                 $choices = array();
                 if (isset($publicationStatus)) {
                     $choices = array($publicationStatus->id => $publicationStatus->status->__toString());
                 } else {
                     $status = QubitTerm::getById(sfConfig::get('app_defaultPubStatus'));
                     $choices = array($status->id => $status->__toString());
                 }
                 // Disable widget if user doesn't have "publish" permission
                 $this->form->setWidget('publicationStatus', new sfWidgetFormSelect(array('choices' => $choices), array('disabled' => true)));
             }
             break;
         case 'repository':
             $this->form->setDefault('repository', $this->context->routing->generate(null, array($this->resource->repository, 'module' => 'repository')));
             $this->form->setValidator('repository', new sfValidatorString());
             $choices = array();
             if (isset($this->resource->repository)) {
                 $choices[$this->context->routing->generate(null, array($this->resource->repository, 'module' => 'repository'))] = $this->resource->repository;
             }
             $this->form->setWidget('repository', new sfWidgetFormSelect(array('choices' => $choices)));
             if (isset($this->getRoute()->resource)) {
                 $this->repoAcParams = array('module' => 'repository', 'action' => 'autocomplete', 'aclAction' => 'update');
             } else {
                 $this->repoAcParams = array('module' => 'repository', 'action' => 'autocomplete', 'aclAction' => 'create');
             }
             break;
         case 'accessConditions':
         case 'accruals':
         case 'acquisition':
         case 'archivalHistory':
         case 'arrangement':
         case 'extentAndMedium':
         case 'findingAids':
         case 'locationOfCopies':
         case 'locationOfOriginals':
         case 'physicalCharacteristics':
         case 'relatedUnitsOfDescription':
         case 'reproductionConditions':
         case 'revisionHistory':
         case 'rules':
         case 'scopeAndContent':
         case 'sources':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormTextarea());
             break;
         case 'descriptionIdentifier':
         case 'identifier':
         case 'institutionResponsibleIdentifier':
         case 'title':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
             break;
         case 'subjectAccessPoints':
         case 'placeAccessPoints':
             $criteria = new Criteria();
             $criteria->add(QubitObjectTermRelation::OBJECT_ID, $this->resource->id);
             $criteria->addJoin(QubitObjectTermRelation::TERM_ID, QubitTerm::ID);
             switch ($name) {
                 case 'subjectAccessPoints':
                     $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::SUBJECT_ID);
                     break;
                 case 'placeAccessPoints':
                     $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::PLACE_ID);
                     break;
             }
             $value = $choices = array();
             foreach ($this[$name] = QubitObjectTermRelation::get($criteria) as $item) {
                 $choices[$value[] = $this->context->routing->generate(null, array($item->term, 'module' => 'term'))] = $item->term;
             }
             $this->form->setDefault($name, $value);
             $this->form->setValidator($name, new sfValidatorPass());
             $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true)));
             break;
         case 'nameAccessPoints':
             $criteria = new Criteria();
             $criteria->add(QubitRelation::SUBJECT_ID, $this->resource->id);
             $criteria->add(QubitRelation::TYPE_ID, QubitTerm::NAME_ACCESS_POINT_ID);
             $value = $choices = array();
             foreach ($this->nameAccessPoints = QubitRelation::get($criteria) as $item) {
                 $choices[$value[] = $this->context->routing->generate(null, array($item->object, 'module' => 'actor'))] = $item->object;
             }
             $this->form->setDefault($name, $value);
             $this->form->setValidator($name, new sfValidatorPass());
             $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true)));
             break;
         default:
             return parent::addField($name);
     }
 }
Exemplo n.º 8
0
 public static function getobjectTermRelationsById($id, array $options = array())
 {
     $criteria = new Criteria();
     self::addobjectTermRelationsCriteriaById($criteria, $id);
     return QubitObjectTermRelation::get($criteria, $options);
 }