public function indexAction() { if (null === ($q = $this->getRequest()->getParam('q'))) { $this->getResponse()->setHeader('X-Error-Msg', 'Missing required parameter `q`'); throw new Zend_Controller_Exception('Missing required parameter `q`', 400); } $q = Api_Models_Utils::addStatusToQuery($q); $concepts = $this->model->getConcepts($q, $this->shouldIncludeDeleted($q), false, $this->getRequest()->getParam('sort')); $context = $this->_helper->contextSwitch()->getCurrentContext(); if ($context === 'json' || $context === 'jsonp') { foreach ($concepts as $key => $val) { foreach ($val['docs'] as &$doc) { unset($doc['xml']); } $this->view->{$key} = $val; } } elseif ($context === 'xml') { $xpath = new DOMXPath($concepts); foreach ($xpath->query('/response/result/doc/str[@name="xml"]') as $node) { $node->parentNode->removeChild($node); } $this->view->response = $concepts; } else { $model = new OpenSKOS_Db_Table_Namespaces(); $this->view->namespaces = $model->fetchPairs(); $this->view->response = $concepts; } }
public function getNamespaces() { $model = new OpenSKOS_Db_Table_Namespaces(); $prefixes = $this->getNamespacePrefixes(); foreach ($prefixes as &$prefix) { $prefix = $model->getAdapter()->quote($prefix); } return $model->fetchPairs($model->select()->where('prefix IN (' . implode(',', $prefixes) . ')')); }
public function getNamespaces() { $model = new OpenSKOS_Db_Table_Namespaces(); //@FIXME Talk to Mark. Clarify what namespaces need to be included. $prefixes = array_merge($this['xmlns'], array('dc', 'dcterms', 'skos')); foreach ($prefixes as &$prefix) { $prefix = $model->getAdapter()->quote($prefix); } return $model->fetchPairs($model->select()->where('prefix IN (' . implode(',', $prefixes) . ')')); }
public function setNamespaces($namespaces) { $links = $this->findManyToManyRowset('OpenSKOS_Db_Table_Namespaces', 'OpenSKOS_Db_Table_CollectionHasNamespaces'); $model = new OpenSKOS_Db_Table_CollectionHasNamespaces(); foreach ($links as $link) { foreach ($model->find($this->id, $link->prefix) as $row) { $row->delete(); } } $Namespaces = new OpenSKOS_Db_Table_Namespaces(); foreach ($namespaces as $prefix => $uri) { $Namespace = $Namespaces->find($prefix)->current(); if (null === $Namespace) { $Namespace = $Namespaces->createRow(array('prefix' => $prefix, 'uri' => $uri)); $Namespace->save(); } $this->addNamespace($Namespace); } return $this; }
/** * Gets all namespaces that are used inside the concepts. * * @param array $concepts An array of Api_Models_Concept * @return array An array of type $prefix => $uri */ protected function _getConceptsNamespaces($concepts) { $namespacesPrefixes = array(); foreach ($concepts as $concept) { $namespacesPrefixes = array_unique(array_merge($namespacesPrefixes, $concept['xmlns'])); } $model = new OpenSKOS_Db_Table_Namespaces(); return $model->fetchPairs($model->select()->where('prefix IN ("' . implode('","', $namespacesPrefixes) . '")')); }
public function GetRecord() { $identifier = $this->getParam('identifier'); $result = OpenSkos_Solr::getInstance()->search('uuid:' . $identifier, array('rows' => 1)); if ($result['response']['numFound'] === 0) { throw new OaiPmh_Exception('Concept `' . $identifier . '` does not exist in this repository'); } $paginator = new Zend_Paginator(new OpenSKOS_Solr_Paginator('uuid:' . $identifier, array('rows' => 1))); $paginator->setItemCountPerPage(self::LIMIT)->setCurrentPageNumber($this->getPage()); $this->_view->data = $paginator; $this->_view->metadataPrefix = $this->getParam('metadataPrefix'); $this->_view->namespacesByCollection = OpenSKOS_Db_Table_Namespaces::getNamespacesByCollection(); $this->_view->conceptSchemes = $this->loadAllConceptSchemes(false); return $this->_view->render('index/ListRecords.phtml'); }