Esempio n. 1
0
 /**
  * Generates JSON from FeaturesList and DataDescription that initializes ARDesigner.
  *
  */
 function features()
 {
     $document =& JFactory::getDocument();
     $document->setMimeEncoding('application/json');
     $viewName = JRequest::getVar('view', 'features');
     $viewType = 'raw';
     $view =& $this->getView($viewName, $viewType);
     $query_id = JRequest::getInt('id_query', NULL);
     $view->assign('value', '');
     if ($query_id != NULL) {
         if (!class_exists('KbiModelQueries')) {
             $kbi = JComponentHelper::getComponent('com_kbi', true);
             if ($kbi->enabled) {
                 JLoader::import('queries', self::$com_kbi_admin . DS . 'models');
                 JLoader::import('sources', self::$com_kbi_admin . DS . 'models');
             } else {
                 throw new Exception(JText::_('Component com_kbi not found / enabled!'));
             }
         }
         $model_queries = new KbiModelQueries();
         $query = $model_queries->getQuery($query_id);
         $model_sources = new KbiModelSources();
         $source = $model_sources->getSource(JRequest::getInt('id_source', NULL));
         KBIDebug::log($source);
         $featurelist = !empty($query->featurelist) ? $query->featurelist : $this->featurelist;
         if (!empty($source->dictionaryquery)) {
             $datadescription = $source->dictionaryquery;
         } else {
             $kbi_source = KBIntegrator::create(get_object_vars($source));
             if ($kbi_source instanceof ISynchronable) {
                 $datadescription = $kbi_source->getDataDescription();
             } else {
                 $datadescription = $this->datadescription;
             }
         }
     } else {
         $featurelist = $this->featurelist;
         $datadescription = $this->datadescription;
     }
     if (class_exists('KBIDebug')) {
         KBIDebug::log(array('featurelist' => $featurelist, 'datadescription' => $datadescription), 'Loading ARD with FL and DL');
     }
     $sr = new GetDataARBuilderQuery($datadescription, $featurelist, null, 'en');
     $result = $sr->getData();
     $view->assignRef('value', $result);
     $view->display();
 }
Esempio n. 2
0
 /**
  * Sets query to perform.
  *
  * @param KBIQuery | int | string Query
  */
 function setQuery($value)
 {
     if ($value instanceof KBIQuery) {
         $this->query = $value;
         return $this;
     }
     if (is_numeric($value)) {
         if (!class_exists('KbiModelQueries')) {
             JLoader::import('queries', COM_KBI_ADMIN . DS . 'models');
         }
         $queries = new KbiModelQueries();
         $db = get_object_vars($queries->getQuery($value));
         $query = new KBIQuery();
         // TODO: implement all properties
         $query->setQuery($db['query']);
         $query->setDelimiter($db['delimiter']);
         $query->setXslt($db['paramsxsl']);
         $this->query = $query;
     } elseif (is_string($value)) {
         $query = new KBIQuery();
         $query->setQuery($value);
         $this->query = $query;
     }
     if ($this->query != NULL) {
         $query->setOptions($this->getOptions, 'GET');
         $query->setOptions($this->postOptions, 'POST');
         return $this->query->setParameters($this->getParams());
     }
     return $this;
 }