Exemple #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);
 }
Exemple #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);
 }
Exemple #3
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;
 }
Exemple #4
0
 public function getBlocksForPage($page)
 {
     $tree = new DAO_Tree();
     return $tree->getChild(Config::$lang . '/pages/' . $page, array('block'));
 }
Exemple #5
0
    /**
     * @param Entity_Tree $elem
     * @return bool
     */
    public function deleteTree($elem)
    {
        $rk = $elem->getRightKey();
        $lk = $elem->getLeftKey();
        $tree = new DAO_Tree();
        $res = $tree->getChild($elem->getId());
        $this->deleteChildFromTable($res);
        $del = $this->DB->prepare('DELETE FROM `site_tree`
									WHERE `left_key`>=:left
									AND `right_key`<=:right');
        $del->bindParam(':left', $lk);
        $del->bindParam(':right', $rk);
        $q1 = $del->execute();
        $del = $this->DB->prepare('UPDATE `site_tree`
								   SET `right_key`=`right_key`-(:right-:left+1)
								   WHERE `right_key`>:right AND `left_key`<:left');
        $del->bindParam(':left', $lk);
        $del->bindParam(':right', $rk);
        $del->execute();
        $del = $this->DB->prepare('UPDATE `site_tree`
								   SET `left_key`=`left_key`-(:right-:left+1),
								   	   `right_key`=`right_key`-(:right-:left+1)
								   WHERE `left_key`>:right');
        $del->bindParam(':left', $lk);
        $del->bindParam(':right', $rk);
        $del->execute();
        return $q1;
    }