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); } }
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); } }
/** * 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); }
/** * Get first ObjectTermRelation with given $objectId * * @param integer $objectId foreign key to object * @return QubitObjectTermRelation object */ public static function getOneByObjectId($objectId) { $c = new Criteria(); $c->add(QubitObjectTermRelation::OBJECT_ID, $objectId); return QubitObjectTermRelation::getOne($c); }
/** * Get related term object by id (should be unique) * * @param */ public function getTermRelation($termId) { $criteria = new Criteria(); $criteria->add(QubitObjectTermRelation::OBJECT_ID, $this->id); $criteria->add(QubitObjectTermRelation::TERM_ID, $termId); return QubitObjectTermRelation::getOne($criteria); }
protected function processForm() { // If object is being duplicated if (isset($this->request->sourceId)) { $sourceInformationObject = QubitInformationObject::getById($this->request->sourceId); // Duplicate physical object relations foreach ($sourceInformationObject->getPhysicalObjects() as $physicalObject) { $this->resource->addPhysicalObject($physicalObject); } // Duplicate notes foreach ($sourceInformationObject->notes as $sourceNote) { if (!isset($this->request->delete_notes[$sourceNote->id])) { $note = new QubitNote(); $note->content = $sourceNote->content; $note->typeId = $sourceNote->type->id; $note->userId = $this->context->user->getAttribute('user_id'); $this->resource->notes[] = $note; } } foreach (QubitRelation::getRelationsBySubjectId($sourceInformationObject->id, array('typeId' => QubitTerm::RIGHT_ID)) as $item) { $sourceRight = $item->object; if (false === array_search($this->context->routing->generate(null, array($sourceRight, 'module' => 'right')), (array) $this->request->deleteRights)) { $right = new QubitRights(); $right->act = $sourceRight->act; $right->startDate = $sourceRight->startDate; $right->endDate = $sourceRight->endDate; $right->basis = $sourceRight->basis; $right->restriction = $sourceRight->restriction; $right->copyrightStatus = $sourceRight->copyrightStatus; $right->copyrightStatusDate = $sourceRight->copyrightStatusDate; $right->copyrightJurisdiction = $sourceRight->copyrightJurisdiction; $right->statuteNote = $sourceRight->statuteNote; // Right holder if (isset($sourceRight->rightsHolder)) { $right->rightsHolder = $sourceRight->rightsHolder; } // I18n $right->rightsNote = $sourceRight->rightsNote; $right->copyrightNote = $sourceRight->copyrightNote; $right->licenseIdentifier = $sourceRight->licenseIdentifier; $right->licenseTerms = $sourceRight->licenseTerms; $right->licenseNote = $sourceRight->licenseNote; $right->statuteJurisdiction = $sourceRight->statuteJurisdiction; $right->statuteCitation = $sourceRight->statuteCitation; $right->statuteDeterminationDate = $sourceRight->statuteDeterminationDate; foreach ($sourceRight->rightsI18ns as $sourceRightI18n) { if ($this->context->user->getCulture() == $sourceRightI18n->culture) { continue; } $rightI18n = new QubitRightsI18n(); $rightI18n->rightNote = $sourceRightI18n->rightNote; $rightI18n->copyrightNote = $sourceRightI18n->copyrightNote; $rightI18n->licenseIdentifier = $sourceRightI18n->licenseIdentifier; $rightI18n->licenseTerms = $sourceRightI18n->licenseTerms; $rightI18n->licenseNote = $sourceRightI18n->licenseNote; $rightI18n->statuteJurisdiction = $sourceRightI18n->statuteJurisdiction; $rightI18n->statuteCitation = $sourceRightI18n->statuteCitation; $rightI18n->statuteNote = $sourceRightI18n->statuteNote; $rightI18n->culture = $sourceRightI18n->culture; $right->rightsI18ns[] = $rightI18n; } $right->save(); $relation = new QubitRelation(); $relation->object = $right; $relation->typeId = QubitTerm::RIGHT_ID; $this->resource->relationsRelatedBysubjectId[] = $relation; } } if ('sfIsadPlugin' != $this->request->module) { foreach ($sourceInformationObject->events as $sourceEvent) { if (false === array_search($this->context->routing->generate(null, array($sourceEvent, 'module' => 'event')), (array) $this->request->deleteEvents)) { $event = new QubitEvent(); $event->actorId = $sourceEvent->actorId; $event->typeId = $sourceEvent->typeId; $event->startDate = $sourceEvent->startDate; $event->endDate = $sourceEvent->endDate; $event->sourceCulture = $sourceEvent->sourceCulture; // I18n $event->name = $sourceEvent->name; $event->description = $sourceEvent->description; $event->date = $sourceEvent->date; foreach ($sourceEvent->eventI18ns as $sourceEventI18n) { if ($this->context->user->getCulture() == $sourceEventI18n->culture) { continue; } $eventI18n = new QubitEventI18n(); $eventI18n->name = $sourceEventI18n->name; $eventI18n->description = $sourceEventI18n->description; $eventI18n->date = $sourceEventI18n->date; $eventI18n->culture = $sourceEventI18n->culture; $event->eventI18ns[] = $eventI18n; } // Place if (null !== ($place = QubitObjectTermRelation::getOneByObjectId($sourceEvent->id))) { $termRelation = new QubitObjectTermRelation(); $termRelation->term = $place->term; $event->objectTermRelationsRelatedByobjectId[] = $termRelation; } $this->resource->events[] = $event; } } } } parent::processForm(); $this->deleteNotes(); $this->updateChildLevels(); $this->updateStatus(); // Must come after updateChildLevels() }
public static function getobjectTermRelationsById($id, array $options = array()) { $criteria = new Criteria(); self::addobjectTermRelationsCriteriaById($criteria, $id); return QubitObjectTermRelation::get($criteria, $options); }