Esempio n. 1
0
 /**
  * @param Entity_Tree $tree
  * @param Entity_Block $block
  * @return bool
  */
 public function updateBlock($tree, $block)
 {
     $old = new Entity_Tree();
     $old->init($this->treeDAO->getOne($tree->getId()));
     $link = rtrim($old->getLink(), $old->getName()) . $tree->getName();
     $tree->setLink($link);
     $block->setId($old->getTypeId());
     return $this->blockDAO->update($block) && $this->treeDAO->updateTree($tree);
 }
Esempio n. 2
0
 /**
  * @param Entity_Tree $tree
  * @param Entity_Page $page
  * @return bool
  */
 public function updatePage($tree, $page)
 {
     $old = new Entity_Tree();
     $old->init($this->treeDAO->getOne($tree->getId()));
     $link = rtrim($old->getLink(), $old->getName()) . $tree->getName();
     $tree->setLink($link);
     $page->setId($old->getTypeId());
     return $this->pageDAO->update($page) && $this->treeDAO->updateTree($tree);
 }
Esempio n. 3
0
    public function moveBlock($id, $index)
    {
        $daoTree = new DAO_Tree();
        $moveElem = $daoTree->getOne($id);
        $parent = $daoTree->getOne($moveElem['pid']);
        $childs = $daoTree->getChild($parent['id']);
        $stmt = $this->DB->prepare('UPDATE `site_tree`
									SET `left_key`=:lkey, `right_key`=:rkey
									WHERE `id`=:id');
        $stmt->bindParam(':lkey', $childs[$index]['left_key']);
        $stmt->bindParam(':rkey', $childs[$index]['right_key']);
        $stmt->bindParam(':id', $id);
        $stmt->execute();
        if ($moveElem['left_key'] > $childs[$index]['left_key']) {
            $stmt = $this->DB->prepare('UPDATE `site_tree`
									SET `left_key`=`left_key`+2,`right_key`=`right_key`+2
									WHERE `left_key`>:pleft
									AND `right_key`<:pright
									AND `left_key`>=:left
									AND `left_key`<:mleft
									AND `id`!=:id');
            $stmt->bindParam(':pleft', $parent['left_key']);
            $stmt->bindParam(':pright', $parent['right_key']);
            $stmt->bindParam(':left', $childs[$index]['left_key']);
            $stmt->bindParam(':mleft', $moveElem['left_key']);
            $stmt->bindParam(':id', $id);
            $stmt->execute();
        } else {
            $stmt = $this->DB->prepare('UPDATE `site_tree`
									SET `left_key`=`left_key`-2,`right_key`=`right_key`-2
									WHERE `left_key`>:pleft
									AND `right_key`<:pright
									AND `left_key`<=:left
									AND `left_key`>:mleft
									AND `id`!=:id');
            $stmt->bindParam(':pleft', $parent['left_key']);
            $stmt->bindParam(':pright', $parent['right_key']);
            $stmt->bindParam(':left', $childs[$index]['left_key']);
            $stmt->bindParam(':mleft', $moveElem['left_key']);
            $stmt->bindParam(':id', $id);
            $stmt->execute();
        }
        return true;
    }
Esempio n. 4
0
 public function delete($id)
 {
     $tree = new DAO_Tree();
     $elem = new Entity_Tree();
     $elem->init($tree->getOne($id));
     $elem_id = $elem->getTypeId();
     $q1 = $this->deleteFromTable($elem_id);
     $dao = new Dev_DAO_Tree();
     $q2 = $dao->deleteTree($elem);
     return $q1 && $q2;
 }