protected function processField($field) { switch ($field->getName()) { case 'type': $value = $filtered = array(); foreach ($this->form->getValue('type') as $item) { $params = $this->context->routing->parse(Qubit::pathInfo($item)); $resource = $params['_sf_route']->resource; $value[$resource->id] = $filtered[$resource->id] = $resource; } foreach ($this->relations as $item) { if (isset($value[$item->term->id])) { unset($filtered[$item->term->id]); } else { $item->delete(); } } foreach ($filtered as $item) { $relation = new QubitObjectTermRelation(); $relation->term = $item; $this->resource->objectTermRelationsRelatedByobjectId[] = $relation; } break; default: return parent::processField($field); } }
public function execute($request) { $this->resource = $this->getRoute()->resource; $value = array(); if (isset($this->resource->actor)) { $value['actor'] = $this->context->routing->generate(null, array($this->resource->actor, 'module' => 'actor')); } if (isset($this->resource->date)) { $value['date'] = $this->resource->date; } $value['endDate'] = Qubit::renderDate($this->resource->endDate); $value['startDate'] = Qubit::renderDate($this->resource->startDate); if (isset($this->resource->description)) { $value['description'] = $this->resource->description; } if (isset($this->resource->informationObject)) { $value['informationObject'] = $this->context->routing->generate(null, array($this->resource->informationObject, 'module' => 'informationobject')); } $place = $this->resource->getPlace(); if (isset($place)) { $value['place'] = $this->context->routing->generate(null, array($place, 'module' => 'term')); } if (isset($this->resource->type)) { $value['type'] = $this->context->routing->generate(null, array($this->resource->type, 'module' => 'term')); } return $this->renderText(json_encode($value)); }
protected function processField($field) { switch ($field->getName()) { case 'resource': // Update the object of the relation, unless the current resource is // the object if ($this->resource->id != $this->relation->objectId) { unset($this->relation->object); } else { unset($this->relation->subject); } $value = $this->form->getValue('resource'); if (isset($value)) { $params = $this->context->routing->parse(Qubit::pathInfo($value)); if ($this->resource->id != $this->relation->objectId) { $this->relation->object = $params['_sf_route']->resource; } else { $this->relation->subject = $params['_sf_route']->resource; } } break; default: return parent::processField($field); } }
public function execute($request) { if (!isset($request->limit)) { $request->limit = sfConfig::get('app_hits_per_page'); } $criteria = new Criteria(); $criteria->addJoin(QubitActor::ID, QubitActorI18n::ID); $criteria->add(QubitActorI18n::CULTURE, $this->context->user->getCulture()); $criteria->addJoin(QubitActor::ID, QubitObject::ID); // Filter out non-authority Actors $criteria->add(QubitObject::CLASS_NAME, 'QubitUser', Criteria::NOT_EQUAL); $criteria->add(QubitObject::CLASS_NAME, 'QubitDonor', Criteria::NOT_EQUAL); // Sort alphabetically by name $criteria->addAscendingOrderByColumn('authorized_form_of_name'); if (isset($request->showOnlyActors) && 'true' == $request->showOnlyActors) { $criteria->add(QubitObject::CLASS_NAME, 'QubitActor'); } if (isset($request->query)) { $criteria->add(QubitActorI18n::AUTHORIZED_FORM_OF_NAME, "{$request->query}%", Criteria::LIKE); } // Exclude the calling actor from the list $params = $this->context->routing->parse(Qubit::pathInfo($request->getReferer())); $resource = $params['_sf_route']->resource; if (isset($resource->id)) { $criteria->add(QubitActor::ID, $resource->id, Criteria::NOT_EQUAL); } $this->pager = new QubitPager('QubitActor'); $this->pager->setCriteria($criteria); $this->pager->setMaxPerPage($request->limit); $this->pager->setPage($request->page); $this->actors = $this->pager->getResults(); $this->setTemplate('list'); }
protected function processForm() { foreach ($this->request->acl as $key => $value) { // If key has an underscore, then we are creating a new permission if (1 == preg_match('/([\\w]+)_(.*)/', $key, $matches)) { list($action, $uri) = array_slice($matches, 1, 2); $params = $this->context->routing->parse(Qubit::pathInfo($uri)); $resource = $params['_sf_route']->resource; if (QubitAcl::INHERIT != $value && isset(QubitAcl::$ACTIONS[$action])) { $aclPermission = new QubitAclPermission(); $aclPermission->action = $action; $aclPermission->grantDeny = QubitAcl::GRANT == $value ? 1 : 0; switch ($resource->className) { case 'QubitTaxonomy': // Taxonomy specific rules $aclPermission->objectId = QubitTerm::ROOT_ID; $aclPermission->setTaxonomy($resource); break; default: $aclPermission->objectId = $resource->id; } $this->resource->aclPermissions[] = $aclPermission; } } else { if (null !== ($aclPermission = QubitAclPermission::getById($key))) { if ($value == QubitAcl::INHERIT) { $aclPermission->delete(); } else { $aclPermission->grantDeny = QubitAcl::GRANT == $value ? 1 : 0; $this->resource->aclPermissions[] = $aclPermission; } } } } }
protected function processField($field) { switch ($field->getName()) { case 'creators': $value = $filtered = array(); foreach ($this->form->getValue('creators') as $item) { $params = $this->context->routing->parse(Qubit::pathInfo($item)); $resource = $params['_sf_route']->resource; $value[$resource->id] = $filtered[$resource->id] = $resource; } foreach ($this->events as $item) { if (isset($value[$item->actor->id])) { unset($filtered[$item->actor->id]); } else { if (!isset($this->request->sourceId)) { $item->delete(); } } } foreach ($filtered as $item) { $event = new QubitEvent(); $event->actor = $item; $event->typeId = QubitTerm::CREATION_ID; $this->resource->events[] = $event; } break; default: return parent::processField($field); } }
protected function processField($field) { switch ($field->getName()) { // Override RelationEditComponent case 'resource': unset($this->relation->object); $value = $this->form->getValue('resource'); if (isset($value)) { $params = $this->context->routing->parse(Qubit::pathInfo($value)); $this->relation->object = $params['_sf_route']->resource; if (null === ($this->contactInformation = $this->relation->object->getPrimaryContact())) { $this->contactInformation = new QubitContactInformation(); } } break; case 'city': case 'contactPerson': case 'countryCode': case 'email': case 'postalCode': case 'region': case 'streetAddress': case 'telephone': $this->contactInformation[$field->getName()] = $this->form->getValue($field->getName()); break; default: parent::processField($field); } }
protected function processField($field) { switch ($field->getName()) { case 'actor': unset($this->event->actor); $value = $this->form->getValue('actor'); if (isset($value)) { $params = $this->context->routing->parse(Qubit::pathInfo($value)); $this->event->actor = $params['_sf_route']->resource; } break; case 'place': $value = $this->form->getValue('place'); if (isset($value)) { $params = $this->context->routing->parse(Qubit::pathInfo($value)); } foreach ($this->event->objectTermRelationsRelatedByobjectId as $item) { if (isset($value) && $params['_sf_route']->resource->id == $item->id) { unset($value); } else { $item->delete(); } } if (isset($value)) { $relation = new QubitObjectTermRelation(); $relation->term = $params['_sf_route']->resource; $this->event->objectTermRelationsRelatedByobjectId[] = $relation; } break; default: return parent::processField($field); } }
protected function earlyExecute() { parent::earlyExecute(); $this->isad = new sfEhriIsadPlugin($this->resource); if (isset($this->request->repository)) { $params = $this->context->routing->parse(Qubit::pathInfo($this->request->repository)); $this->resource->repository = $params['_sf_route']->resource; } $title = $this->context->i18n->__('Add new EHRI archival description'); if (isset($this->getRoute()->resource)) { if (1 > strlen($title = $this->resource)) { $title = $this->context->i18n->__('Untitled'); } $title = $this->context->i18n->__('Edit %1%', array('%1%' => $title)); } $this->response->setTitle("{$title} - {$this->response->getTitle()}"); // FIXME: Hack way of setting default values if (!$this->resource->levelOfDescription) { $this->resource->setLevelOfDescriptionByName("Collection"); } if (!$this->resource->descriptionIdentifier) { $this->resource->descriptionIdentifier = "EHRI"; } if (!$this->resource->institutionResponsibleIdentifier) { $this->resource->institutionResponsibleIdentifier = "EHRI"; } if (!$this->resource->rules) { $this->resource->rules = "ISAD(G)"; } if (!$this->resource->scriptOfDescription) { $this->resource->scriptOfDescription = "Latn"; } }
public function processForm() { if (isset($this->request->deleteRelations)) { foreach ($this->request->deleteRelations as $item) { $params = $this->context->routing->parse(Qubit::pathInfo($item)); $params['_sf_route']->resource->delete(); } } return parent::processForm(); }
protected function processField($field) { switch ($field->getName()) { case 'type': unset($this->resource->type); $params = $this->context->routing->parse(Qubit::pathInfo($this->form->getValue('type'))); $this->resource->type = $params['_sf_route']->resource; break; default: return parent::processField($field); } }
public static function renderDateStartEnd($date, $start, $end) { if (isset($date)) { return $date; } if (isset($start) || isset($end)) { $start = Qubit::renderDate($start); $end = Qubit::renderDate($end); if ($end == $start) { return $start; } return "{$start} - {$end}"; } }
public function __toString() { $string = array(); if (isset($this->basis)) { $string[] = $this->basis; } if (isset($this->act)) { $string[] = $this->act; } $string = implode(' - ', $string); if (null !== ($date = Qubit::renderDateStartEnd(null, $this->startDate, $this->endDate))) { $string .= ' (' . $date . ')'; } return $string; }
public function processForm() { if ($this->request->hasParameter('csvimport')) { if ($this->request->getParameterHolder()->has('datesOfCreation')) { $this->request->editEvents = $this->request->getParameterHolder()->get('datesOfCreation'); } } $params = array($this->request->editEvent); if (isset($this->request->editEvents)) { // If dialog JavaScript did it's work, then use array of parameters $params = $this->request->editEvents; } foreach ($params as $item) { // Continue only if user typed something if (1 > strlen($item['date']) && 1 > strlen($item['endDate']) && 1 > strlen($item['startDate'])) { continue; } // Ignore item if it was removed and it was being duplicated if (isset($item['id']) && false !== array_search($item['id'], (array) $this->request->deleteEvents)) { continue; } $this->form->bind($item); if ($this->form->isValid()) { if (!isset($this->request->sourceId) && isset($item['id'])) { $params = $this->context->routing->parse(Qubit::pathInfo($item['id'])); $this->event = $params['_sf_route']->resource; } else { $this->resource->events[] = $this->event = new QubitEvent(); } foreach ($this->form as $field) { if (isset($item[$field->getName()])) { $this->processField($field); } } } } if (!isset($this->request->sourceId) && isset($this->request->deleteEvents)) { foreach ($this->request->deleteEvents as $item) { $params = $this->context->routing->parse(Qubit::pathInfo($item)); $params['_sf_route']->resource->delete(); } } }
public function execute($request) { $this->resource = $this->getRoute()->resource; $value = array(); $value['date'] = $this->resource->date; $value['endDate'] = Qubit::renderDate($this->resource->endDate); $value['startDate'] = Qubit::renderDate($this->resource->startDate); $value['description'] = $this->resource->description; if (isset($this->resource->object)) { $value['object'] = $this->context->routing->generate(null, array($this->resource->object)); } if (isset($this->resource->subject)) { $value['subject'] = $this->context->routing->generate(null, array($this->resource->subject)); } if (isset($this->resource->type)) { $value['type'] = $this->context->routing->generate(null, array($this->resource->type, 'module' => 'term')); } if (method_exists($this, 'extraQueries')) { $value = $this->extraQueries($value); } return $this->renderText(json_encode($value)); }
protected function processForm() { foreach ($this->form->getValue('containers') as $item) { $params = $this->context->routing->parse(Qubit::pathInfo($item)); $this->resource->addPhysicalObject($params['_sf_route']->resource); } if (null !== $this->form->getValue('name') || null !== $this->form->getValue('location')) { $physicalObject = new QubitPhysicalObject(); $physicalObject->name = $this->form->getValue('name'); $physicalObject->location = $this->form->getValue('location'); $params = $this->context->routing->parse(Qubit::pathInfo($this->form->getValue('type'))); $physicalObject->type = $params['_sf_route']->resource; $physicalObject->save(); $this->resource->addPhysicalObject($physicalObject); } if (isset($this->request->delete_relations)) { foreach ($this->request->delete_relations as $item) { $params = $this->context->routing->parse(Qubit::pathInfo($item)); $params['_sf_route']->resource->delete(); } } }
public function execute($request) { if (!isset($request->limit)) { $request->limit = sfConfig::get('app_hits_per_page'); } $criteria = new Criteria(); $criteria->addJoin(QubitFunction::ID, QubitFunctionI18n::ID); $criteria->add(QubitFunctionI18n::CULTURE, $this->context->user->getCulture()); if (isset($request->query)) { $criteria->add(QubitFunctionI18n::AUTHORIZED_FORM_OF_NAME, "{$request->query}%", Criteria::LIKE); } // Exclude the calling function from the list $params = $this->context->routing->parse(Qubit::pathInfo($request->getReferer())); $resource = $params['_sf_route']->resource; if (isset($resource->id)) { $criteria->add(QubitFunction::ID, $resource->id, Criteria::NOT_EQUAL); } // Page results $this->pager = new QubitPager('QubitFunction'); $this->pager->setCriteria($criteria); $this->pager->setMaxPerPage($request->limit); $this->pager->setPage(1); $this->setTemplate('list'); }
</td><td> <div class="animateNicely"> <?php echo $form->getWidgetSchema()->renderField('date', $item->getDate(array('cultureFallback' => true))); ?> </div> </td><td> <div class="animateNicely"> <?php echo $form->getWidgetSchema()->renderField('startDate', Qubit::renderDate($item->startDate)); ?> </div> </td><td> <div class="animateNicely"> <?php echo $form->getWidgetSchema()->renderField('endDate', Qubit::renderDate($item->endDate)); ?> </div> </td><td style="text-align: right"> <div class="animateNicely"> <input class="multiDelete" name="deleteEvents[]" type="checkbox" value="<?php echo url_for(array($item, 'module' => 'event')); ?> "/> </div> </td> </tr> <?php } ?>
</li> <?php } ?> </ul> </div> <?php } ?> <?php echo render_show(__('Accession number'), render_value($resource->identifier)); ?> <?php echo render_show(__('Acquisition date'), render_value(Qubit::renderDate($resource->date))); ?> <?php echo render_show(__('Source of acquisition'), render_value($resource->getSourceOfAcquisition(array('cultureFallback' => true)))); ?> <?php echo render_show(__('Location information'), render_value($resource->getLocationInformation(array('cultureFallback' => true)))); ?> <div class="section" id="donorArea"> <?php echo link_to_if(QubitAcl::check($resource, 'update'), '<h2>' . __('Donor/Transferring body area') . '</h2>', array($resource, 'module' => 'accession', 'action' => 'edit'), array('anchor' => 'donorArea', 'title' => __('Edit donor/transferring body area'))); ?>
echo render_value($relatedEntity->getDatesOfExistence(array('cultureFallback' => true))); ?> )</span><?php } ?> <?php echo render_show(__('Identifier of the related entity'), render_value($relatedEntity->descriptionIdentifier)); ?> <?php echo render_show(__('Category of the relationship'), render_value($item->type)); ?> <?php echo render_show(__('Dates of the relationship'), Qubit::renderDateStartEnd($item->date, $item->startDate, $item->endDate)); ?> <?php echo render_show(__('Description of relationship'), render_value($item->description)); ?> </div> </div> <?php } ?> <?php foreach ($functions as $item) { ?>
public function execute($request) { $this->resource = $this->getRoute()->resource; $value = array(); if (isset($this->resource->act)) { $value['act'] = $this->context->routing->generate(null, array($this->resource->act, 'module' => 'term')); } $value['restriction'] = $this->resource->restriction; $value['startDate'] = Qubit::renderDate($this->resource->startDate); $value['endDate'] = Qubit::renderDate($this->resource->endDate); if (isset($this->resource->rightsHolder)) { $value['rightsHolder'] = $this->context->routing->generate(null, array($this->resource->rightsHolder, 'module' => 'rightsholder')); } if (isset($this->resource->rightsNote)) { $value['rightsNote'] = $this->resource->rightsNote; } if (isset($this->resource->basis)) { $value['basis'] = $this->context->routing->generate(null, array($this->resource->basis, 'module' => 'term')); } /** * Basis: copyright */ if (isset($this->resource->copyrightStatus)) { $value['copyrightStatus'] = $this->context->routing->generate(null, array($this->resource->copyrightStatus, 'module' => 'term')); } if (isset($this->resource->copyrightStatusDate)) { $value['copyrightStatusDate'] = $this->resource->copyrightStatusDate; } if (isset($this->resource->copyrightJurisdiction)) { $value['copyrightJurisdiction'] = $this->resource->copyrightJurisdiction; } if (isset($this->resource->copyrightNote)) { $value['copyrightNote'] = $this->resource->copyrightNote; } /** * Basis: license */ if (isset($this->resource->licenseIdentifier)) { $value['licenseIdentifier'] = $this->resource->licenseIdentifier; } if (isset($this->resource->licenseTerms)) { $value['licenseTerms'] = $this->resource->licenseTerms; } if (isset($this->resource->licenseNote)) { $value['licenseNote'] = $this->resource->licenseNote; } /** * Basis: statute */ if (isset($this->resource->statuteJurisdiction)) { $value['statuteJurisdiction'] = $this->resource->statuteJurisdiction; } if (isset($this->resource->statuteCitation)) { $value['statuteCitation'] = $this->resource->statuteCitation; } if (isset($this->resource->statuteDeterminationDate)) { $value['statuteDeterminationDate'] = $this->resource->statuteDeterminationDate; } if (isset($this->resource->statuteNote)) { $value['statuteNote'] = $this->resource->statuteNote; } return $this->renderText(json_encode($value)); }
public function generateReport($request) { // Get "file" term in "level of description" taxonomy $c2 = new Criteria(); $c2->addJoin(QubitTerm::ID, QubitTermI18n::ID, Criteria::INNER_JOIN); $c2->add(QubitTermI18n::NAME, 'file'); $c2->add(QubitTermI18n::CULTURE, 'en'); $c2->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::LEVEL_OF_DESCRIPTION_ID); $lod = QubitTermI18n::getOne($c2); if (null === $lod) { throw new sfException('Can\'t find "file" level of description in term table'); } $criteria = new Criteria(); $criteria->add(QubitInformationObject::LFT, $this->resource->lft, Criteria::GREATER_EQUAL); $criteria->add(QubitInformationObject::RGT, $this->resource->rgt, Criteria::LESS_EQUAL); $criteria->addAscendingOrderByColumn(QubitInformationObject::LFT); // Filter drafts $criteria = QubitAcl::addFilterDraftsCriteria($criteria); $this->results = array(); $this->resultCount = 0; $informationObjects = QubitInformationObject::get($criteria); foreach ($informationObjects as $item) { if ($lod->id == $item->levelOfDescriptionId) { $parentIsad = new sfIsadPlugin($item->parent); $isad = new sfIsadPlugin($item); $creationDates = self::getCreationDates($item); $this->results[$parentIsad->__toString()][] = array('resource' => $item, 'referenceCode' => $isad->referenceCode, 'title' => $item->getTitle(array('cultureFallback' => true)), 'dates' => isset($creationDates) ? Qubit::renderDateStartEnd($creationDates->getDate(array('cultureFallback' => true)), $creationDates->startDate, $creationDates->endDate) : ' ', 'startDate' => isset($creationDates) ? $creationDates->startDate : null, 'accessConditions' => $item->getAccessConditions(array('cultureFallback' => true)), 'locations' => self::getLocationString($item)); $this->resultCount++; } } // Sort items by selected criteria $sortBy = $this->form->getValue('sortBy'); foreach ($this->results as $key => &$items) { uasort($items, function ($a, $b) use($sortBy) { return strnatcasecmp($a[$sortBy], $b[$sortBy]); }); } }
public function execute($request) { if (!isset($request->limit)) { $request->limit = sfConfig::get('app_hits_per_page'); } // For term module show only preferred term $params = $this->context->routing->parse(Qubit::pathInfo($request->getReferer())); if ('term' == $params['module']) { $criteria = new Criteria(); // Exclude the calling object and it's descendants from the list (prevent // circular inheritance) if (isset($params['id'])) { // TODO Self join would be ideal $term = QubitTerm::getById($params['id']); if (isset($term)) { $criteria->add($criteria->getNewCriterion(QubitTerm::LFT, $term->lft, Criteria::LESS_THAN)->addOr($criteria->getNewCriterion(QubitTerm::RGT, $term->rgt, Criteria::GREATER_THAN))); } } $params = $this->context->routing->parse(Qubit::pathInfo($request->taxonomy)); $criteria->add(QubitTerm::TAXONOMY_ID, $params['_sf_route']->resource->id); $criteria->addJoin(QubitTerm::ID, QubitTermI18n::ID); $criteria->add(QubitTermI18n::CULTURE, $this->context->user->getCulture()); // Narrow results by query if (isset($request->query)) { $criteria->add(QubitTermI18n::NAME, "{$request->query}%", Criteria::LIKE); } // Sort by name $criteria->addAscendingOrderByColumn(QubitTermI18n::NAME); $criteria->setLimit(10); $this->terms = QubitTerm::get($criteria); } else { $s1 = 'SELECT qt.id, null, qti.name FROM ' . QubitTerm::TABLE_NAME . ' qt LEFT JOIN ' . QubitTermI18n::TABLE_NAME . ' qti ON qt.id = qti.id WHERE taxonomy_id = :p1 AND qti.culture = :p2'; $s2 = 'SELECT qt.id, qon.id as altId, qoni.name FROM ' . QubitOtherName::TABLE_NAME . ' qon INNER JOIN ' . QubitOtherNameI18n::TABLE_NAME . ' qoni ON qon.id = qoni.id INNER JOIN ' . QubitTerm::TABLE_NAME . ' qt ON qon.object_id = qt.id WHERE qt.taxonomy_id = :p1 AND qoni.culture = :p2'; // Narrow results by query if (isset($request->query)) { $s1 .= ' AND qti.name LIKE :p3'; $s2 .= ' AND qoni.name LIKE :p3'; } $connection = Propel::getConnection(); $statement = $connection->prepare("({$s1}) UNION ALL ({$s2}) ORDER BY name LIMIT 10"); $params = $this->context->routing->parse(Qubit::pathInfo($request->taxonomy)); $statement->bindValue(':p1', $params['_sf_route']->resource->id); $statement->bindValue(':p2', $this->context->user->getCulture()); if (isset($request->query)) { $statement->bindValue(':p3', "{$request->query}%"); } $statement->execute(); $this->terms = array(); $rows = $statement->fetchAll(); foreach ($rows as $row) { if (isset($row[1])) { // Alternative term $this->terms[] = array(QubitTerm::getById($row[0]), $row[2]); } else { // Preferred term $this->terms[] = QubitTerm::getById($row[0]); } } } }
public function getChildYuiNodes($options = array()) { $limit = isset($options['limit']) ? $options['limit'] : 0; $offset = isset($options['offset']) ? $options['offset'] : 0; $nodes = array(); $criteria = new Criteria(); $criteria->add(QubitTerm::PARENT_ID, $this->id); if (QubitTerm::ROOT_ID == $this->id) { $params = sfContext::getInstance()->routing->parse(Qubit::pathInfo(sfContext::getInstance()->request->getReferer())); $refererTerm = $params['_sf_route']->resource; if (isset($refererTerm)) { $criteria->add(QubitTerm::TAXONOMY_ID, $refererTerm->taxonomyId); } } $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitTerm'); $criteria->addAscendingOrderByColumn('name'); $countCriteria = clone $criteria; $totalChildren = intval(BasePeer::doCount($countCriteria)->fetchColumn(0)); if (0 < $limit) { $criteria->setLimit($limit); } if (0 < $offset) { $criteria->setOffset($offset); } if (0 < count($children = QubitTerm::get($criteria))) { foreach ($children as $child) { $nodes[] = $child; } } $shownChildren = $offset + count($children); if ($totalChildren > $shownChildren) { $nodes[] = array('total' => $totalChildren, 'limit' => $limit, 'parentId' => $this->id); } return self::renderYuiNodes($nodes); }
<?php } else { ?> <?php echo render_title($item->object); ?> <?php } ?> </td><td> <?php echo $item->type; ?> </td><td> <?php echo Qubit::renderDateStartEnd($item->date, $item->startDate, $item->endDate); ?> </td><td> <?php echo $item->description; ?> </td><td style="text-align: center"> <input class="multiDelete" name="deleteRelations[]" type="checkbox" value="<?php echo url_for(array($item, 'module' => 'relation')); ?> "/> </td> </tr> <?php } ?>
public static function renderDates($item) { $dates = null; if (isset($item->startDate)) { $startDate = Qubit::renderDate($item->startDate); if (isset($item->endDate)) { $endDate = Qubit::renderDate($item->endDate); $dates = <<<str <dateRange> <fromDate standardDate="{$startDate}">{$startDate}</fromDate> <toDate standardDate="{$endDate}">{$endDate}</toDate> </dateRange> str; } else { $dates = <<<str <date standardDate="{$startDate}">{$startDate}</date> str; } } return $dates; }
public function execute($request) { // Default items per page if (!isset($request->limit)) { $request->limit = sfConfig::get('app_hits_per_page'); } $this->form = new sfForm(); $this->resource = $this->getRoute()->resource; // Check that the object exists and that it is not the root if (!isset($this->resource) || !isset($this->resource->parent)) { $this->forward404(); } // Check authorization if (!QubitAcl::check($this->resource, 'update')) { QubitAcl::forwardUnauthorized(); } // "parent" form field $this->form->setValidator('parent', new sfValidatorString(array('required' => true))); $this->form->setWidget('parent', new sfWidgetFormInputHidden()); // Root is default parent if ($this->resource instanceof QubitInformationObject) { $this->form->bind($request->getGetParameters() + array('parent' => $this->context->routing->generate(null, array(QubitInformationObject::getById(QubitInformationObject::ROOT_ID), 'module' => 'informationobject')))); } else { if ($this->resource instanceof QubitTerm) { $this->form->bind($request->getGetParameters() + array('parent' => $this->context->routing->generate(null, array(QubitTerm::getById(QubitTerm::ROOT_ID), 'module' => 'term')))); } } if ($request->isMethod('post')) { $this->form->bind($request->getPostParameters()); if ($this->form->isValid()) { $params = $this->context->routing->parse(Qubit::pathInfo($this->form->parent->getValue())); // In term treeview, root node links (href) to taxonomy, but it represents the term root object if ($this->resource instanceof QubitTerm && QubitObject::getById($params['_sf_route']->resource->id) instanceof QubitTaxonomy) { $this->resource->parentId = QubitTerm::ROOT_ID; } else { $this->resource->parentId = $params['_sf_route']->resource->id; } $this->resource->save(); if ($request->isXmlHttpRequest()) { return $this->renderText(''); } else { if ($this->resource instanceof QubitInformationObject) { $this->redirect(array($this->resource, 'module' => 'informationobject')); } else { if ($this->resource instanceof QubitTerm) { $this->redirect(array($this->resource, 'module' => 'term')); } } } } } $params = $this->context->routing->parse(Qubit::pathInfo($this->form->parent->getValue())); $this->parent = QubitObject::getById($params['_sf_route']->resource->id); $query = QubitSearch::getInstance()->addTerm($this->parent->slug, 'parent'); if (isset($request->query)) { $query = $request->query; } $this->pager = new QubitArrayPager(); $this->pager->hits = QubitSearch::getInstance()->getEngine()->getIndex()->find($query); $this->pager->setMaxPerPage($request->limit); $this->pager->setPage($request->page); $ids = array(); foreach ($this->pager->getResults() as $hit) { $ids[] = $hit->getDocument()->id; } $criteria = new Criteria(); $criteria->add(QubitObject::ID, $ids, Criteria::IN); $this->results = QubitObject::get($criteria); }
/** * Populate a digital object from a resource pointed to by a URI * This is for, eg. importing encoded digital objects from XML * * @param string $uri URI pointing to the resource * @return boolean success or failure */ public function importFromURI($uri, $options = array()) { // Parse URL into components and get file/base name $uriComponents = parse_url($uri); // Initialize web browser $browser = new sfWebBrowser(array(), null, array('Timeout' => 10)); // Add asset to digital object assets array if (true !== $browser->get($uri)->responseIsError() && 0 < strlen($filename = basename($uriComponents['path']))) { $asset = new QubitAsset($uri, $browser->getResponseText()); $this->assets[] = $asset; } else { throw new sfException('Encountered error fetching external resource.'); } // Set digital object as external URI $this->usageId = QubitTerm::EXTERNAL_URI_ID; // Save filestream temporary, because sfImageMagickAdapter does not support load data from streams $this->localPath = Qubit::saveTemporaryFile($filename, $asset->getContents()); $this->name = $filename; $this->path = $uri; $this->checksum = $asset->getChecksum(); $this->checksumType = $asset->getChecksumAlgorithm(); $this->byteSize = strlen($browser->getResponseText()); $this->setMimeAndMediaType(); }
</div> </div> <div class="field"> <h3><?php echo __('Date(s)'); ?> </h3> <div> <ul> <?php foreach ($resource->getDates() as $item) { ?> <li> <?php echo Qubit::renderDateStartEnd($item->getDate(array('cultureFallback' => true)), $item->startDate, $item->endDate); ?> (<?php echo $item->getType(array('cultureFallback' => true)); ?> ) <?php if (isset($item->actor)) { ?> <?php echo link_to(render_title($item->actor), array($item->actor, 'module' => 'actor')); ?> <?php } ?> </li>
protected function processField($field) { switch ($field->getName()) { 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 'titleProperOfPublishersSeries': case 'titleStatementOfResponsibility': $this->rad[$field->getName()] = $this->form->getValue($field->getName()); break; case 'type': $value = $filtered = array(); foreach ($this->form->getValue('type') as $item) { $params = $this->context->routing->parse(Qubit::pathInfo($item)); $resource = $params['_sf_route']->resource; $value[$resource->id] = $filtered[$resource->id] = $resource; } foreach ($this->relations as $item) { if (isset($value[$item->term->id])) { unset($filtered[$item->term->id]); } else { $item->delete(); } } foreach ($filtered as $item) { $relation = new QubitObjectTermRelation(); $relation->term = $item; $this->resource->objectTermRelationsRelatedByobjectId[] = $relation; } break; default: return parent::processField($field); } }