public function execute($request) { if (!isset($request->limit)) { $request->limit = sfConfig::get('app_hits_per_page'); } if (isset($request->subquery)) { try { // Parse query string $query = QubitSearch::getInstance()->parse($request->subquery); } catch (Exception $e) { $this->error = $e->getMessage(); return; } } else { $this->redirect(array('module' => 'repository', 'action' => 'browse')); } $query->addSubquery(QubitSearch::getInstance()->addTerm('QubitRepository', 'className'), true); $this->pager = new QubitArrayPager(); try { $this->pager->hits = QubitSearch::getInstance()->getEngine()->getIndex()->find($query); } catch (Exception $e) { $this->error = $e->getMessage(); return; } $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(QubitRepository::ID, $ids, Criteria::IN); $this->repositories = QubitRepository::get($criteria); }
public function execute($request) { $criteria = new Criteria(); $criteria->addJoin(QubitActor::ID, QubitActorI18n::ID); $criteria->add(QubitActorI18n::AUTHORIZED_FORM_OF_NAME, "{$request->query}%", Criteria::LIKE); $criteria->addAscendingOrderByColumn('authorized_form_of_name'); $criteria->setDistinct(); $criteria->setLimit(sfConfig::get('app_hits_per_page', 10)); $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitActor'); // Filter "denied" repositories if list for repository autocomplete on // information object form if (isset($request->aclAction)) { $repositoryList = array(); $repositoryAccess = QubitAcl::getRepositoryAccess($request->aclAction); // If all repositories are denied, no response if (1 == count($repositoryAccess) && QubitAcl::DENY == $repositoryAccess[0]['access']) { return sfView::NONE; } else { while ($repo = array_shift($repositoryAccess)) { if ('*' != $repo['id']) { $repositoryList[] = $repo['id']; } else { if (QubitAcl::DENY == $repo['access']) { // Require repositories to be specifically allowed (all others // prohibited) $criteria->add(QubitRepository::ID, $repositoryList + array('null'), Criteria::IN); } else { // Prohibit specified repositories (all others allowed) $criteria->add(QubitRepository::ID, $repositoryList, Criteria::NOT_IN); } } } } } $this->repositories = QubitRepository::get($criteria); }
public function filterQuery($query) { // limit to a repository if selected if (!empty($this->request->repository)) { $query->addSubquery(QubitSearch::getInstance()->addTerm($this->request->repository, 'repositoryId'), true); $this->queryTerms[] = array('term' => $this->getContext()->i18n->__('Repository') . ': ' . QubitRepository::getById($this->request->repository)->__toString(), 'operator' => 'and'); } // digital object filters if ('true' == $this->request->hasDigitalObject) { $query->addSubquery(QubitSearch::getInstance()->addTerm('true', 'hasDigitalObject'), true); $this->queryTerms[] = array('term' => $this->getContext()->i18n->__('Digital object is available'), 'operator' => 'and'); } else { if ('false' == $this->request->hasDigitalObject) { $query->addSubquery(QubitSearch::getInstance()->addTerm('false', 'hasDigitalObject'), true); $this->queryTerms[] = array('term' => $this->getContext()->i18n->__('No digital object is available'), 'operator' => 'and'); } } if (!empty($this->request->mediatype)) { $query->addSubquery(QubitSearch::getInstance()->addTerm($this->request->mediatype, 'do_mediaTypeId'), true); $this->queryTerms[] = array('term' => 'mediatype: ' . QubitTerm::getById($this->request->mediatyp)->__toString(), 'operator' => 'and'); } $query = parent::filterQuery($query); return $query; }
public function doSearch() { $criteria = new Criteria(); $this->sort = $this->request->getParameter('sort', 'updatedDown'); // This join seems to be necessary to avoid cross joining the local table // with the QubitObject table $criteria->addJoin(constant($this->className . '::ID'), QubitObject::ID); switch ($this->form->getValue('className')) { case 'QubitActor': $nameColumn = 'authorized_form_of_name'; $this->nameColumnDisplay = 'Name'; $criteria = QubitActor::addGetOnlyActorsCriteria($criteria); $criteria->add(QubitActor::PARENT_ID, null, Criteria::ISNOTNULL); break; case 'QubitFunction': $nameColumn = 'authorized_form_of_name'; $this->nameColumnDisplay = 'Name'; break; case 'QubitRepository': $nameColumn = 'authorized_form_of_name'; $this->nameColumnDisplay = 'Name'; $criteria = QubitRepository::addGetOnlyRepositoryCriteria($criteria); break; case 'QubitTerm': $nameColumn = 'name'; $this->nameColumnDisplay = 'Name'; $criteria->add(QubitTerm::PARENT_ID, null, Criteria::ISNOTNULL); break; // Default: information object // Default: information object default: $nameColumn = 'title'; $this->nameColumnDisplay = 'Title'; $criteria->add(QubitInformationObject::PARENT_ID, null, Criteria::ISNOTNULL); } if ('QubitInformationObject' == $this->className && 'all' != $this->form->getValue('publicationStatus')) { $criteria->addJoin(QubitObject::ID, QubitStatus::OBJECT_ID); $criteria->add(QubitStatus::STATUS_ID, $this->form->getValue('publicationStatus')); } // End date at midnight if (null != $this->form->getValue('dateEnd')) { $dateEnd = $this->form->getValue('dateEnd') . ' 24:00:00'; } // Add date criteria switch ($dateOf = $this->form->getValue('dateOf')) { case 'CREATED_AT': case 'UPDATED_AT': if (null !== $this->form->getValue('dateStart')) { $criteria->addAnd(constant('QubitObject::' . $dateOf), $this->form->getValue('dateStart'), Criteria::GREATER_EQUAL); } if (isset($dateEnd)) { $criteria->addAnd(constant('QubitObject::' . $dateOf), $dateEnd, Criteria::LESS_EQUAL); } break; default: if (null !== $this->form->getValue('dateStart')) { $c1 = $criteria->getNewCriterion(QubitObject::CREATED_AT, $this->form->getValue('dateStart'), Criteria::GREATER_EQUAL); $c2 = $criteria->getNewCriterion(QubitObject::UPDATED_AT, $this->form->getValue('dateStart'), Criteria::GREATER_EQUAL); $c1->addOr($c2); $criteria->addAnd($c1); } if (isset($dateEnd)) { $c3 = $criteria->getNewCriterion(QubitObject::CREATED_AT, $dateEnd, Criteria::LESS_EQUAL); $c4 = $criteria->getNewCriterion(QubitObject::UPDATED_AT, $dateEnd, Criteria::LESS_EQUAL); $c3->addOr($c4); $criteria->addAnd($c3); } } // Add sort criteria switch ($this->sort) { case 'nameDown': $criteria->addDescendingOrderByColumn($nameColumn); break; case 'nameUp': $criteria->addAscendingOrderByColumn($nameColumn); break; case 'updatedUp': $criteria->addAscendingOrderByColumn(QubitObject::UPDATED_AT); break; case 'updatedDown': default: $criteria->addDescendingOrderByColumn(QubitObject::UPDATED_AT); } // Add fallback criteria for name if ('nameDown' == $this->sort || 'nameUp' == $this->sort) { $criteria = QubitCultureFallback::addFallbackCriteria($criteria, $this->form->getValue('className')); } // Page results $this->pager = new QubitPager($this->className); $this->pager->setCriteria($criteria); $this->pager->setMaxPerPage($this->form->getValue('limit')); $this->pager->setPage($this->request->getParameter('page', 1)); }
<fieldset class="collapsible collapsed" id="repositoryArea"> <legend><?php echo __('Permissions by %1%', array('%1%' => sfConfig::get('app_ui_label_repository'))); ?> </legend> <?php if (0 < count($repositories)) { ?> <?php foreach ($repositories as $repositoryId => $permissions) { ?> <div class="form-item"> <?php echo get_component('aclGroup', 'aclTable', array('object' => QubitRepository::getById($repositoryId), 'permissions' => $permissions, 'actions' => $basicActions)); ?> </div> <?php } ?> <?php } ?> <?php echo javascript_tag(<<<EOL Drupal.behaviors.dialog2 = { attach: function (context) { Qubit.repoDialog = new QubitAclDialog('addRepository', '{$tableTemplate}', jQuery);
<td colspan="<?php echo $tableCols; ?> "><strong> <?php if ('' == $repoId && '' == $objectId) { ?> <em><?php echo __('All %1%', array('%1%' => sfConfig::get('app_ui_label_informationobject'))); ?> </em> <?php } elseif ('' != $repoId) { ?> <?php echo sfConfig::get('app_ui_label_repository') . ': ' . render_title(QubitRepository::getById($repoId)); ?> <?php } else { ?> <?php echo render_title(QubitInformationObject::getById($objectId)); ?> <?php } ?> </strong></td> </tr> <?php $row = 0; ?>
public function setIdentifierWithCodes($identifier, $options) { $this->setIdentifier($identifier); if ($repository = QubitRepository::getById($this->getRepositoryId())) { // if the repository doesn't already have a code, set it using the <unitid repositorycode=""> value if (isset($options['repositorycode'])) { if (!$repository->getIdentifier()) { $repository->setIdentifier($options['repositorycode']); $repository->save(); } } // if the repository doesn't already have an country code, set it using the <unitid countrycode=""> value if (isset($options['countrycode'])) { if (!$repository->getCountryCode()) { if ($primaryContact = $repository->getPrimaryContact()) { $primaryContact->setCountryCode(strtoupper($options['countrycode'])); $primaryContact->save(); } else { if (count($contacts = $repository->getContactInformation()) > 0) { $contacts[0]->setCountryCode(strtoupper($options['countrycode'])); $contacts[0]->save(); } else { $contactInformation = new QubitContactInformation(); $contactInformation->setCountryCode(strtoupper($options['countrycode'])); $contactInformation->setActorId($repository->id); $contactInformation->save(); } } } } } }
public function getRepository() { if (null !== ($repositoryId = $this->getConstants(array('name' => 'repositoryId')))) { return QubitRepository::getById($repositoryId); } }
<td colspan="<?php echo $tableCols; ?> "><strong> <?php if ('' == $repoId && '' == $objectId) { ?> <em><?php echo __('All %1%', array('%1%' => sfConfig::get('app_ui_label_informationobject'))); ?> </em> <?php } elseif ('' != $repoId) { ?> <?php echo __('%1%: %2%', array('%1%' => sfConfig::get('app_ui_label_repository'), '%2%' => render_title(QubitRepository::getById($repoId)))); ?> <?php } else { ?> <?php echo render_title(QubitInformationObject::getById($objectId)); ?> <?php } ?> </strong></td> </tr> <?php $row = 0;
public static function getrepositorysRelatedBydescDetailIdById($id, array $options = array()) { $criteria = new Criteria(); self::addrepositorysRelatedBydescDetailIdCriteriaById($criteria, $id); return QubitRepository::get($criteria, $options); }
protected function mapInformationObject($parameters) { // NB: any value for publication status means set to published if (!empty($parameters['publicationStatus'])) { $parameters['publicationStatus'] = QubitTerm::PUBLICATION_STATUS_PUBLISHED_ID; } if (!empty($parameters['repository'])) { $repo = QubitRepository::getByAuthorizedFormOfName($parameters['repository']); // if the repository does not exist, create it if (empty($repo)) { $repo = new QubitRepository(); $repo->authorizedFormOfName = $parameters['repository']; $repo->save(); } $parameters['repository'] = $this->context->routing->generate(null, array($repo, 'module' => 'repository')); } // subject access points if (!isset($this->subjects)) { foreach (QubitTerm::getSubjects() as $term) { $this->subjects[$term->__toString()] = $term; } } $n = 0; foreach (explode('|', $parameters['subjectAccessPoints']) as $new_subjectAccessPoint) { if (0 == strlen(trim($new_subjectAccessPoint))) { continue; } // if the subject does not exist, create it if (!in_array($new_subjectAccessPoint, $this->subjects) && !empty($new_subjectAccessPoint)) { $subject = new QubitTerm(); $subject->taxonomyId = QubitTaxonomy::SUBJECT_ID; $subject->name = $new_subjectAccessPoint; $subject->save(); $this->subjects[$subject->__toString()] = $subject; } $new_subjectAccessPoints['new' . $n] = $this->context->routing->generate(null, array($this->subjects[$new_subjectAccessPoint], 'module' => 'term')); $n++; } $parameters['subjectAccessPoints'] = $new_subjectAccessPoints; // place access points if (!isset($this->places)) { foreach (QubitTerm::getPlaces() as $term) { $this->places[$term->__toString()] = $term; } } $n = 0; foreach (explode('|', $parameters['placeAccessPoints']) as $new_placeAccessPoint) { if (0 == strlen(trim($new_placeAccessPoint))) { continue; } // if the place does not exist, create it if (!in_array($new_placeAccessPoint, $this->places) && !empty($new_placeAccessPoint)) { $place = new QubitTerm(); $place->taxonomyId = QubitTaxonomy::PLACE_ID; $place->name = $new_placeAccessPoint; $place->save(); $this->places[$place->__toString()] = $place; } $new_placeAccessPoints['new' . $n] = $this->context->routing->generate(null, array($this->places[$new_placeAccessPoint], 'module' => 'term')); $n++; } $parameters['placeAccessPoints'] = $new_placeAccessPoints; // name access points $n = 0; $this->getActors(); foreach (explode('|', $parameters['nameAccessPoints']) as $new_nameAccessPoint) { if (0 == strlen(trim($new_nameAccessPoint))) { continue; } // if the name does not exist, create it if (!isset($this->actors[$new_nameAccessPoint])) { $name = new QubitActor(); $name->authorizedFormOfName = $new_nameAccessPoint; $name->save(); $this->actors[$name->__toString()] = $name; } $new_nameAccessPoints['new' . $n] = $this->context->routing->generate(null, array($this->actors[$new_nameAccessPoint], 'module' => 'actor')); $n++; } $parameters['nameAccessPoints'] = $new_nameAccessPoints; return $parameters; }