public function indexAction()
 {
     $model = new OpenSKOS_Db_Table_Collections();
     $context = $this->_helper->contextSwitch()->getCurrentContext();
     $select = $model->select();
     if (null !== ($allow_oai = $this->getRequest()->getParam('allow_oai'))) {
         switch (strtolower($allow_oai)) {
             case '1':
             case 'yes':
             case 'y':
             case 'true':
                 $select->where('allow_oai=?', 'Y');
                 break;
             case '0':
             case 'no':
             case 'n':
             case 'false':
                 $select->where('allow_oai=?', 'N');
                 break;
         }
     }
     if ($context == 'json' || $context == 'jsonp') {
         $this->view->assign('collections', $model->fetchAll($select)->toArray());
     } else {
         $this->view->collections = $model->fetchAll($select);
     }
 }
 /**
  * @return Editor_Forms_SearchOptions
  */
 protected function buildCollections()
 {
     $modelCollections = new OpenSKOS_Db_Table_Collections();
     $collections = $modelCollections->fetchAll($modelCollections->select()->where('tenant = ?', $this->_getCurrentTenant()->code));
     $collectionsOptions = array();
     foreach ($collections as $collection) {
         $collectionsOptions[$collection->id] = $collection->dc_title;
     }
     $this->addElement('multiselect', 'collections', array('label' => _('Collections'), 'multiOptions' => $collectionsOptions));
     return $this;
 }
Esempio n. 3
0
            fwrite(STDERR, "if you want to select a collection by it's code, a tenant code is required\n");
            exit(1);
        }
        $collection = $model->fetchRow($model->select()->where('code=?', $OPTS->collection)->where('tenant=?', $tenant));
        if (null === $collection) {
            fwrite(STDERR, "collection `{$OPTS->collection}` not found\n");
            exit(2);
        }
        if (!$collection->OAI_baseURL) {
            fwrite(STDERR, "collection `{$OPTS->collection}` has no OAI base URL\n");
            exit(3);
        }
        $collections = array($collection);
    }
} else {
    $collections = $model->fetchAll($model->select()->where('OAI_baseURL<>?', ''));
}
foreach ($collections as $collection) {
    if (null !== $OPTS->verbose) {
        fwrite(STDOUT, "processing collection `{$collection->tenant}/{$collection->dc_title}`: \n");
    }
    $from = $OPTS->from;
    if (null === $from) {
        //get last modified date from Solr:
        if (null !== $OPTS->verbose) {
            fwrite(STDOUT, "fetching last modified date from Solr: ");
        }
        $solr = Zend_Registry::get('OpenSKOS_Solr');
        $result = $solr->search("collection:{$collection->id} AND tenant:{$collection->tenant}", array('rows' => 1, 'fl' => 'timestamp', 'sort' => 'timestamp desc'));
        if ($result['response']['numFound'] == 0) {
            $ts = null;
Esempio n. 4
0
 /**
  * Parses the part of the query for searching for specified collections.
  * By default the search is performed for all collections.
  *
  * @return OpenSKOS_Solr_Queryparser_Editor
  */
 protected function _parseSearchForCollections()
 {
     $modelCollections = new OpenSKOS_Db_Table_Collections();
     $allCollections = $modelCollections->fetchAll($modelCollections->select()->where('tenant = ?', $this->_tenant->code));
     $searchInCollections = array();
     if (isset($this->_searchOptions['collections'])) {
         $searchInCollections = $this->_searchOptions['collections'];
     }
     if (!empty($searchInCollections) && count($searchInCollections) != count($allCollections)) {
         $query = '';
         foreach ($searchInCollections as $collectionId) {
             $query .= !empty($query) ? ' OR ' : '';
             $query .= 'collection:' . $collectionId;
         }
         if (!empty($query) && count($searchInCollections) > 1) {
             $query = '(' . $query . ')';
         }
         if (!empty($query)) {
             $this->_addDefaultQuerySeparator();
             $this->_query .= $query;
         }
     }
     return $this;
 }
Esempio n. 5
0
 public function ListSets()
 {
     $model = new OpenSKOS_Db_Table_Tenants();
     $this->_view->tenants = $model->fetchAll();
     $model = new OpenSKOS_Db_Table_Collections();
     $collections = array();
     foreach ($model->fetchAll() as $collection) {
         if (!isset($collections[$collection->tenant])) {
             $collections[$collection->tenant] = array();
         }
         $collections[$collection->tenant][$collection->id] = $collection;
     }
     $this->_view->collections = $collections;
     $this->_view->assign('conceptSchemes', $this->loadAllConceptSchemes());
     return $this->_view->render('index/ListSets.phtml');
 }