Exemplo n.º 1
0
    /**
     * @copydoc DataSet::createBuilder
     */
    protected function createBuilder()
    {
        $tree = E()->getMap()->getTree();
        $treeData = array();
        //если у нас не раздел 1го уровня
        if ($parents = E()->getMap()->getParents($this->document->getID())) {
            $ancestorID = key($parents);
            //проходимся по всем прямым предкам
            foreach ($parents as $nodeID => $node) {
                //получаем дочерние разделы
                $nodeChilds = $this->dbh->select('
				    SELECT s.smap_id, s.smap_pid
				    FROM share_sitemap s
				    LEFT JOIN share_sitemap_translation st ON s.smap_id=st.smap_id
				    WHERE smap_pid  = ' . $nodeID . ' AND smap_is_disabled = 0 AND lang_id = ' . E()->getLanguage()->getCurrent() . '
				    ORDER BY smap_order_num ASC
				');
                if ($nodeChilds) {
                    $nodeChilds = array_map(create_function('$node', 'if($node["smap_pid"] == ' . $ancestorID . ') $node["smap_pid"] = false;
                            return $node;'), $nodeChilds);
                }
                $treeData = array_merge($treeData, $nodeChilds);
            }
        }
        //ниже 1го уровня получаем дочерние страницы
        if (!empty($parents)) {
            $childs = $this->dbh->select('share_sitemap', array('smap_id', 'smap_pid'), array('smap_pid' => $this->document->getID()), array('smap_order_num' => QAL::ASC));
        } else {
            $childs = $this->dbh->select('SELECT smap_id, null as smap_pid FROM share_sitemap WHERE smap_pid = %s ORDER BY smap_order_num', $this->document->getID());
        }
        if ($childs) {
            $treeData = array_merge($treeData, $childs);
        }
        $tree = TreeConverter::convert($treeData, 'smap_id', 'smap_pid');
        $builder = new TreeBuilder();
        $builder->setTree($tree);
        return $builder;
    }
Exemplo n.º 2
0
 /**
  * Build tab with division rights.
  *
  * @return DOMNode
  */
 private function buildDivRightsData()
 {
     $builder = new TreeBuilder();
     $builder->setTree(TreeConverter::convert($this->dbh->select('share_sitemap', ['smap_id', 'smap_pid'], null, ['smap_order_num' => QAL::ASC]), 'smap_id', 'smap_pid'));
     $id = $this->getFilter();
     $id = !empty($id) ? current($id) : '';
     $data = convertDBResult($this->dbh->select('select s.smap_id as Id, smap_pid as Pid, site_id as Site, smap_name as Name ' . 'from share_sitemap s ' . 'left join share_sitemap_translation st on st.smap_id = s.smap_id ' . 'where lang_id=%s', E()->getLanguage()->getCurrent()), 'Id');
     foreach ($data as $smapID => $smapInfo) {
         $data[$smapID]['RightsId'] = E()->getMap($smapInfo['Site'])->getDocumentRights($smapID, $id);
         $data[$smapID]['Site'] = E()->getSiteManager()->getSiteByID($smapInfo['Site'])->name;
     }
     $dataObject = new Data();
     $dataObject->load($data);
     $builder->setData($dataObject);
     $dataDescriptionObject = new DataDescription();
     $f = new FieldDescription('Id');
     $f->setType(FieldDescription::FIELD_TYPE_INT);
     $f->setProperty('key', true);
     $dataDescriptionObject->addFieldDescription($f);
     $f = new FieldDescription('Pid');
     $f->setType(FieldDescription::FIELD_TYPE_INT);
     $dataDescriptionObject->addFieldDescription($f);
     $f = new FieldDescription('Name');
     $f->setType(FieldDescription::FIELD_TYPE_STRING);
     $dataDescriptionObject->addFieldDescription($f);
     $f = new FieldDescription('Site');
     $f->setType(FieldDescription::FIELD_TYPE_STRING);
     $dataDescriptionObject->addFieldDescription($f);
     $f = new FieldDescription('RightsId');
     $f->setType(FieldDescription::FIELD_TYPE_SELECT);
     if ($this->getState() == 'view') {
         $f->setMode(FieldDescription::FIELD_MODE_READ);
     }
     $rights = $this->dbh->select('user_group_rights', ['right_id', 'right_const']);
     $rights = array_merge([['right_id' => 0, 'right_const' => 'NO_RIGHTS']], $rights);
     foreach ($rights as $key => $value) {
         $rights[$key]['right_const'] = $this->translate('TXT_' . $value['right_const']);
     }
     $f->loadAvailableValues($rights, 'right_id', 'right_const');
     $dataDescriptionObject->addFieldDescription($f);
     $builder->setData($dataObject);
     $builder->setDataDescription($dataDescriptionObject);
     $builder->build();
     return $builder->getResult();
 }
Exemplo n.º 3
0
 protected function createBuilder()
 {
     if ($this->isTree and is_array($data = $this->loadData())) {
         $builder = new TreeBuilder();
         $tree = TreeConverter::convert($data, 'comment_id', 'comment_parent_id');
         $builder->setTree($tree);
     } else {
         $builder = new SimpleBuilder();
     }
     $this->builder = $builder;
     return $this->builder;
 }