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;
     }
 }
예제 #2
0
 /**
  * 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) . '")'));
 }
예제 #3
0
 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) . ')'));
 }
예제 #4
0
 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) . ')'));
 }