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);
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'searchFields':
             break;
         case 'repository':
             // Get list of repositories
             $criteria = new Criteria();
             // Do source culture fallback
             $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitActor');
             $criteria->addAscendingOrderByColumn('authorized_form_of_name');
             $choices = array('' => '');
             foreach (QubitRepository::get($criteria) as $repository) {
                 $choices[$repository->id] = $repository;
             }
             $this->form->setValidator($name, new sfValidatorChoice(array('choices' => array_keys($choices))));
             $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' => $choices), array('style' => 'min-width: 50%; width: auto')));
             break;
         case 'mediatype':
             // Get list of media types
             $criteria = new Criteria();
             $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::MATERIAL_TYPE_ID);
             // Do source culture fallback
             $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitTerm');
             $criteria->addAscendingOrderByColumn('name');
             $choices = array('' => '');
             foreach (QubitTerm::get($criteria) as $mediatype) {
                 $choices[$mediatype->id] = $mediatype;
             }
             $this->form->setValidator($name, new sfValidatorChoice(array('choices' => array_keys($choices))));
             $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' => $choices), array('style' => 'width: auto')));
             break;
         case 'hasDigitalObject':
             $choices = array('' => '', 'true' => 'Yes', 'false' => 'No');
             $this->form->setValidator($name, new sfValidatorChoice(array('choices' => array_keys($choices))));
             $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' => $choices), array('style' => 'width: auto')));
             break;
     }
 }
 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);
 }
示例#4
0
 public static function getrepositorysRelatedBydescDetailIdById($id, array $options = array())
 {
     $criteria = new Criteria();
     self::addrepositorysRelatedBydescDetailIdCriteriaById($criteria, $id);
     return QubitRepository::get($criteria, $options);
 }