Ejemplo n.º 1
0
 /**
  * check if current class is configured to return any result for
  * given path and request params
  * @param  array   &$pathArray
  * @param  array   &$requestParams
  * @return boolean
  */
 protected function acceptedPath(&$pathArray, &$requestParams)
 {
     if (parent::acceptedPath($pathArray, $requestParams)) {
         $lastNode = $pathArray[sizeof($pathArray) - 1];
         if (sizeof($pathArray) > 1 && get_class($lastNode) != get_class($this)) {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * get param for this node
  *
  * @param  varchar $param for now using to get 'facets' or 'DC'
  * @return array
  */
 public function getNodeParam($param = 'facets')
 {
     $rez = false;
     $sort = null;
     $id = $this->id . '_' . $param;
     if (!empty($this->config[$id])) {
         $rez = $this->config[$id];
     }
     if (!empty($this->config[$id . '_sort'])) {
         $sort = $this->config[$id . '_sort'];
     }
     if ($rez === false) {
         return parent::getNodeParam($param);
     }
     return array('from' => $this->getId(), 'data' => $rez, 'sort' => $sort);
 }
Ejemplo n.º 3
0
 /**
  * check if current class is configured to return any result for
  * given path and request params
  * @param  array   &$pathArray
  * @param  array   &$requestParams
  * @return boolean
  */
 protected function acceptedPath(&$pathArray, &$requestParams)
 {
     return parent::acceptedPath($pathArray, $requestParams) && Security::isAdmin();
 }
Ejemplo n.º 4
0
 /**
  * get param for this node
  *
  * @param  varchar $param for now using to get 'facets' or 'DC'
  * @return array
  */
 public function getNodeParam($param = 'facets')
 {
     $rez = false;
     $from = $this->getId();
     //check if cached
     $cacheParam = 'nodeParam_' . $param . '_' . $from;
     if (Cache::exist($cacheParam)) {
         return Cache::get($cacheParam);
     }
     //select configs from tree and template of the current node
     $sql = 'SELECT t.cfg, t.template_id, tt.cfg `templateCfg`
         FROM tree t
         LEFT JOIN templates tt
             ON (t.template_id = tt.id)
                 OR ((tt.id = $2) AND (t.template_id IS NULL))
         WHERE t.id = $1';
     //if template_id specified in config then select directly from templates table
     if (empty($from) && !empty($this->config['template_id'])) {
         $from = 'template_' . $this->config['template_id'];
         $sql = 'SELECT null `cfg`, t.id template_id, t.cfg `templateCfg`
             FROM templates t
             WHERE t.id = $2';
     }
     //check node configuration and/or its template for facets definitions
     $res = DB\dbQuery($sql, array($this->id, @$this->config['template_id'])) or die(DB\dbQueryError());
     if ($r = $res->fetch_assoc()) {
         $cfg = Util\toJSONArray($r['cfg']);
         if (isset($cfg[$param])) {
             $rez = $cfg[$param];
         } else {
             $cfg = Util\toJSONArray($r['templateCfg']);
             if (isset($cfg[$param])) {
                 $rez = $cfg[$param];
                 $from = 'template_' . $r['template_id'];
             }
         }
         //add grouping param for DC
         if ($param == 'DC' && $rez !== false) {
             if (!empty($cfg['view']['group'])) {
                 $rez['group'] = $cfg['view']['group'];
             } elseif (!empty($cfg['group'])) {
                 $rez['group'] = $cfg['group'];
             }
         }
     }
     $res->close();
     if ($rez === false) {
         $rez = parent::getNodeParam($param);
     } else {
         $rez = array('from' => $from, 'data' => $rez);
     }
     Cache::set($cacheParam, $rez);
     return $rez;
 }
Ejemplo n.º 5
0
 /**
  * get param for this node
  *
  * @param  varchar $param for now using to get 'facets' or 'DC'
  * @return array
  */
 public function getNodeParam($param = 'facets')
 {
     $rez = false;
     $from = $this->getId();
     //check if cached
     $cacheParam = 'nodeParam_' . $param . '_' . $from;
     if (Cache::exist($cacheParam)) {
         return Cache::get($cacheParam);
     }
     $cfg = array();
     $templateId = null;
     $tplCfg = array();
     if (!empty($this->id) && is_numeric($this->id)) {
         $r = DM\Tree::read($this->id);
     }
     if (!empty($r)) {
         $cfg = $r['cfg'];
         $templateId = $r['template_id'];
     }
     if (!empty($this->config['template_id'])) {
         $templateId = $this->config['template_id'];
     }
     if (!empty($templateId)) {
         $r = DM\Templates::read($templateId);
         if (!empty($r)) {
             $tplCfg = $r['cfg'];
         }
     }
     if (isset($cfg[$param])) {
         $rez = $cfg[$param];
     } elseif (isset($tplCfg[$param])) {
         $cfg = $tplCfg;
         $rez = $cfg[$param];
         $from = 'template_' . $templateId;
     }
     //add grouping param for DC
     if ($param == 'DC' && $rez !== false) {
         if (!empty($cfg['view']['group'])) {
             $rez['group'] = $cfg['view']['group'];
         } elseif (!empty($cfg['group'])) {
             $rez['group'] = $cfg['group'];
         }
     }
     if ($rez === false) {
         $rez = parent::getNodeParam($param);
     } else {
         $rez = array('from' => $from, 'data' => $rez);
     }
     Cache::set($cacheParam, $rez);
     return $rez;
 }