public function execute($request) { $this->resource = $this->getRoute()->resource; // Check that this isn't the root if (!isset($this->resource->parent)) { $this->forward404(); } // Check user authorization if (!QubitAcl::check($this->resource, 'read')) { QubitAcl::forwardUnauthorized(); } $criteria = new Criteria(); $criteria->add(QubitRelation::OBJECT_ID, $this->resource->id); $criteria->addJoin(QubitRelation::SUBJECT_ID, QubitFunction::ID); $this->functions = QubitFunction::get($criteria); }
public function parse($doc) { require_once sfConfig::get('sf_root_dir') . '/vendor/FluentDOM/FluentDOM.php'; $fd = FluentDOM($doc)->namespaces(array('eac' => 'urn:isbn:1-931666-33-4')); $this->resource->sourceStandard = 'http://eac.staatsbibliothek-berlin.de/schema/cpf.xsd'; $this->resource->descriptionIdentifier = $fd->find('eac:control/eac:recordId')->text(); //$fd->find('eac:control/eac:otherRecordId'); $this->maintenanceStatus = $fd->find('eac:control/eac:maintenanceStatus')->text(); $this->publicationStatus = $fd->find('eac:control/eac:publicationStatus')->text(); // TODO <descriptiveNote/>, <otherAgencyCode/> $this->resource->institutionResponsibleIdentifier = $fd->find('eac:control/eac:maintenanceAgency/eac:agencyName')->text(); // TODO <descriptiveNote/> foreach ($fd->find('eac:control/eac:languageDeclaration/eac:language/@languageCode') as $node) { $this->resource->language[] = $node->textContent; } foreach ($fd->find('eac:control/eac:languageDeclaration/eac:script/@scriptCode') as $node) { $this->resource->script[] = $node->textContent; } // conventionDeclaration/abbreviation is an identifier, referenced by e.g. // <authorizedForm/> and <alternativeForm/> // // TODO <descriptiveNote/> $this->resource->rules = $fd->find('eac:control/eac:conventionDeclaration/eac:citation')->text(); // TODO <abbreviation/>, <descriptiveNote/> //$fd->find('eac:control/eac:localTypeDeclaration'); // TODO <date/>, <dateRange/>, <term/> //$this->resource->descriptionDetail = $fd->find('eac:control/eac:localControl')->text(); $this->maintenanceHistory = $fd->find('eac:control/eac:maintenanceHistory'); // TODO <descriptiveNote/>, @lastDateTimeVerified $this->resource->sources = $fd->find('eac:control/eac:sources/eac:source/eac:sourceEntry')->text(); // TODO eac:cpfDescription/eac:identity/@identityType $this->resource->corporateBodyIdentifiers = $fd->find('eac:cpfDescription/eac:identity/eac:entityId')->text(); $this->entityType = $fd->find('eac:cpfDescription/eac:identity/eac:entityType')->text(); // TODO <nameEntryParallel/>, <useDates/> $this->resource->authorizedFormOfName = $fd->find('eac:cpfDescription/eac:identity/eac:nameEntry[eac:authorizedForm]/eac:part')->text(); foreach ($fd->find('eac:cpfDescription/eac:identity/eac:nameEntry[not(eac:authorizedForm)]') as $node) { $item = new QubitOtherName(); $item->name = $fd->spawn()->add($node)->find('eac:part')->text(); $item->typeId = QubitTerm::OTHER_FORM_OF_NAME_ID; $this->resource->otherNames[] = $item; } //$fd->find('eac:cpfDescription/eac:identity/eac:nameEntry/eac:authorizedForm'); //$fd->find('eac:cpfDescription/eac:identity/eac:nameEntry/eac:alternativeForm'); //$fd->find('eac:cpfDescription/eac:identity/eac:nameEntry/eac:preferredForm'); // TODO eac:cpfDescription/eac:identity/eac:descriptiveNote $this->existDates = $fd->find('eac:cpfDescription/eac:description/eac:existDates'); // TODO <address/>, <addressLine/>, <date/>, <dateRange/>, <dateSet/>, // <descriptiveNote/>, <placeRole/>, <term/>, @accuracy, @altitude, // @countryCode, @latitude, @longitude, @vocabularySource $this->resource->places = $fd->find('eac:cpfDescription/eac:description/eac:place/eac:placeEntry|eac:cpfDescription/eac:description/eac:places/eac:place/eac:placeEntry')->text(); // TODO <date/>, <dateRange/>, <dateSet/>, <descriptiveNote/>, // <placeEntry/>, <term/> //$fd->find('eac:cpfDescription/eac:description/eac:localDescription'); //$fd->find('eac:cpfDescription/eac:description/eac:localDescriptions'); // TODO <date/>, <dateRange/>, <dateSet/>, <descriptiveNote/>, // <placeEntry/> $this->resource->legalStatus = $fd->find('eac:cpfDescription/eac:description/eac:legalStatus/eac:term|eac:cpfDescription/eac:description/eac:legalStatuses/eac:legalStatus/eac:term')->text(); // TODO <date/>, <dateRange/>, <dateSet/>, <descriptiveNote/>, // <placeEntry/> $this->resource->functions = $fd->find('eac:cpfDescription/eac:description/eac:function/eac:term|eac:cpfDescription/eac:description/eac:functions/eac:function/eac:term|eac:cpfDescription/eac:description/eac:occupation/eac:term|eac:cpfDescription/eac:description/eac:occupations/eac:occupation/eac:term')->text(); //$fd->find('eac:cpfDescription/eac:description/eac:languageUsed'); // TODO <date/>, <dateRange/>, <dateSet/>, <descriptiveNote/>, // <placeEntry/> $this->resource->mandates = $fd->find('eac:cpfDescription/eac:description/eac:mandate/eac:term|eac:cpfDescription/eac:description/eac:mandates/eac:mandate/eac:term')->text(); $this->internalStructures = $fd->find('eac:cpfDescription/eac:description/eac:structureOrGenealogy'); $this->generalContext = $fd->find('eac:cpfDescription/eac:description/eac:generalContext'); // TODO <abstract/>, <chronList/> $this->biogHist = $fd->find('eac:cpfDescription/eac:description/eac:biogHist'); // TODO @lastDateTimeVerified, <date/>, <dateRange/>, <dateSet/>, // <descriptiveNote/>, <placeEntry/> foreach ($fd->find('eac:cpfDescription/eac:relations/eac:cpfRelation') as $node) { $url = preg_replace('/^(?:[^:]+:\\/\\/[^\\/]+)?' . preg_quote(sfContext::getInstance()->request->getPathInfoPrefix(), '/') . '/', null, $node->getAttributeNS('http://www.w3.org/1999/xlink', 'href'), -1, $count); // @href is one of our resources if ($node->hasAttributeNS('http://www.w3.org/1999/xlink', 'href') && 0 < $count) { $params = sfContext::getInstance()->routing->parse($url); $item = $params['_sf_route']->resource; } else { $item = new QubitActor(); $item->authorizedFormOfName = $fd->spawn()->add($node)->find('eac:relationEntry')->text(); // TODO Cascade save through QubitEvent $item->save(); } $relation = new QubitRelation(); $relation->object = $item; $relation->typeId = self::fromCpfRelationType($node->getAttribute('cpfRelationType')); if (0 < count($date = self::parseDates($node))) { $relation->startDate = $date[0][0]; $relation->endDate = $date[count($date) - 1][1]; } // Multiple, non-contiguous dates if (1 < count($date)) { foreach ($date as $key => $value) { $date[$key] = Qubit::renderDate($value[0]) . ' - ' . Qubit::renderDate($value[1]); } $note = new QubitNote(); $note->typeId = QubitTerm::RELATION_NOTE_DATE_ID; $note->scope = 'QubitRelation'; $note->content = implode(', ', $date); $relation->notes[] = $note; } $this->resource->relationsRelatedBysubjectId[] = $relation; } // TODO @lastDateTimeVerified, <date/>, <dateRange/>, <dateSet/>, // <descriptiveNote/>, <placeEntry/> foreach ($fd->find('eac:cpfDescription/eac:relations/eac:resourceRelation') as $node) { $url = preg_replace('/^(?:[^:]+:\\/\\/[^\\/]+)?' . preg_quote(sfContext::getInstance()->request->getPathInfoPrefix(), '/') . '/', null, $node->getAttributeNS('http://www.w3.org/1999/xlink', 'href'), -1, $count); // @href is one of our resources if ($node->hasAttributeNS('http://www.w3.org/1999/xlink', 'href') && 0 < $count) { $params = sfContext::getInstance()->routing->parse($url); $item = $params['_sf_route']->resource; } else { $item = new QubitInformationObject(); $item->parentId = QubitInformationObject::ROOT_ID; $item->title = $fd->spawn()->add($node)->find('eac:relationEntry')->text(); // TODO Cascade save through QubitEvent $item->save(); } $event = new QubitEvent(); $event->informationObject = $item; $event->typeId = self::fromResourceRelationType($node->getAttribute('resourceRelationType')); if (0 < count($date = self::parseDates($node))) { $event->startDate = $date[0][0]; $event->endDate = $date[count($date) - 1][1]; } // Multiple, non-contiguous dates if (1 < count($date)) { foreach ($date as $key => $value) { $date[$key] = Qubit::renderDate($value[0]) . ' - ' . Qubit::renderDate($value[1]); } $event->date = implode(', ', $date); } $this->resource->events[] = $event; } // TODO <date/>, <dateRange/>, <dateSet/>, <descriptiveNote/>, // <placeEntry/>, @lastDateTimeVerified foreach ($fd->find('eac:cpfDescription/eac:relations/eac:functionRelation') as $node) { $url = preg_replace('/^(?:[^:]+:\\/\\/[^\\/]+)?' . preg_quote(sfContext::getInstance()->request->getPathInfoPrefix(), '/') . '/', null, $node->getAttributeNS('http://www.w3.org/1999/xlink', 'href'), -1, $count); // @href is one of our resources if ($node->hasAttributeNS('http://www.w3.org/1999/xlink', 'href') && 0 < $count) { $params = sfContext::getInstance()->routing->parse($url); $item = $params['_sf_route']->resource; } else { $item = new QubitFunction(); $item->authorizedFormOfName = $fd->spawn()->add($node)->find('eac:relationEntry')->text(); // TODO Cascade save through QubitEvent $item->save(); } $relation = new QubitRelation(); $relation->subject = $item; // TODO Set $relation->type by mapping to controlled vocabulary $this->resource->relationsRelatedByobjectId[] = $relation; } // TODO <alternativeSet/> return $this; }
public static function getfunctionsRelatedByparentIdById($id, array $options = array()) { $criteria = new Criteria(); self::addfunctionsRelatedByparentIdCriteriaById($criteria, $id); return QubitFunction::get($criteria, $options); }