示例#1
0
 function query()
 {
     $viewName = JRequest::getVar('view', 'results');
     $viewType = 'raw';
     $view =& $this->getView($viewName, $viewType);
     $config = array('source' => JRequest::getVar('source', NULL, 'default', 'none', JREQUEST_ALLOWRAW), 'query' => JRequest::getVar('query', NULL, 'default', 'none', JREQUEST_ALLOWRAW), 'xslt' => JRequest::getVar('xslt', NULL, 'default', 'none', JREQUEST_ALLOWRAW), 'parameters' => JRequest::getVar('parameters', NULL, 'default', 'none', JREQUEST_ALLOWRAW));
     try {
         $model = new KbiModelTransformator($config);
         $view->assignRef('value', $model->transform());
     } catch (Exception $e) {
         $view->assign('value', "<p class=\"kbierror\">Chyba dotazu: {$e->getMessage()}</p>");
     }
     $view->display();
 }
示例#2
0
文件: kbi.php 项目: KIZI/sewebar-cms
 function replace($match)
 {
     if (!isset($match[1]) || empty($match[1])) {
         return;
     }
     try {
         //WYSIWYG editor zalamuje XHTML neparove znacky na \ /> aby zustal validni JSON je potreba to vratit spet na \/>
         $json = str_replace('\\ />', '\\/>', $match[1]);
         $config = json_decode($json, true);
         if ($config === NULL) {
             KBIDebug::log($match[1], 'Element not parsed as JSON');
             return $match[1];
         }
         $transfomator = new KbiModelTransformator($config);
         //var_dump($match);
         //var_dump($config);
         //var_dump($transfomator);
         return $transfomator->transform();
     } catch (Exception $ex) {
         KBIDebug::log(array($ex, $config), 'Query not succesfull');
     }
 }
示例#3
0
         FB::error(['error' => 'data description does not exist']);
     }
     $responseContent = ['status' => 'error'];
     goto sendResponse;
 }
 $serializer = new TaskSettingSerializer($DDPath);
 $requestData = array('source' => $id, 'query' => $serializer->serialize($data), 'template' => $debug ? '4ftMiner.Task.Template.PMML' : '4ftMiner.Task.ARD.Template.PMML', 'pooler' => $taskMode);
 $numRequests = 0;
 // save LM task
 $taskPath = 'temp/4ft_task_' . date('md_His') . '.pmml';
 file_put_contents($taskPath, $requestData['query']);
 // run task
 sendRequest:
 $config = array('source' => intval($id), 'query' => $requestData['query'], 'xslt' => NULL, 'parameters' => NULL);
 $model = new KbiModelTransformator($config);
 $document = $model->transform();
 $ok = strpos($document, 'kbierror') === false && !preg_match('/status=\\"failure\\"/', $document);
 if (++$numRequests < MAX_MINING_REQUESTS && !$ok) {
     sleep(REQUEST_DELAY);
     goto sendRequest;
 }
 if (FB_ENABLED && $debug) {
     // log into console
     FB::info(['num requests' => $numRequests, 'request' => $requestData, 'response' => $document]);
 }
 if ($ok) {
     // save LM result
     $resultPath = 'temp/4ft_result_' . date('md_His') . '.pmml';
     file_put_contents($resultPath, $document);
     $DP = new DataParser($DDPath, unserialize(FLPath), FGCPath, $document, null, $lang);
     $DP->loadData();
示例#4
0
 function hits()
 {
     $document =& JFactory::getDocument();
     $viewName = JRequest::getVar('view', 'hits');
     $viewType = $document->getType();
     $view =& $this->getView($viewName, $viewType);
     $data = JRequest::getVar('data', '', 'post', 'string', JREQUEST_ALLOWRAW);
     if ($viewType == 'raw' && $data != NULL) {
         $config = array('source' => JRequest::getVar('id_source', NULL, 'default', 'none', JREQUEST_ALLOWRAW), 'query' => NULL, 'xslt' => NULL, 'parameters' => NULL);
         try {
             $com_kbi = JComponentHelper::getComponent('com_kbi', true);
             if (!$com_kbi->enabled) {
                 throw new Exception('KBI component not intalled or enabled');
             }
             JLoader::import('transformator', JPATH_COMPONENT . DS . '..' . DS . $com_kbi->option . DS . 'models');
             $model = new KbiModelTransformator($config);
             $sr = self::createSerializeRules($model->getSource());
             $model->setQuery($sr->serializeRules($data));
             $dd = null;
             $fl = null;
             $er = $model->transform();
             $sr = new GetDataARBuilderQuery($dd, $fl, $er, 'en');
             $data = $sr->getData();
             $view->assignRef('value', $data);
             KBIDebug::log($er);
         } catch (Exception $e) {
             $view->assign('value', "<p class=\"kbierror\">Chyba dotazu: {$e->getMessage()}</p>");
         }
     }
     $view->display();
 }