/** * @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); }
/** * @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); }
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; }
/** * @param Entity_Tree $tree * @return mixed */ public function addTree($tree) { $rk = $tree->getRightKey(); $lev = $tree->getLevel(); $tit = $tree->getTitle(); $nam = $tree->getName(); $link = $tree->getLink(); $typ = $tree->getType(); $tid = $tree->getTypeId(); $pid = $tree->getPid(); $stmt = $this->DB->prepare('UPDATE `site_tree` SET `right_key` = `right_key` + 2, `left_key` = IF(`left_key` > :right_key, `left_key` + 2, `left_key`) WHERE `right_key` >= :right_key'); $stmt->bindParam(':right_key', $rk); $stmt->execute(); $stmt = $this->DB->prepare('INSERT INTO `site_tree` SET `left_key` = :right_key, `right_key` = :right_key + 1, `level` = :level + 1, `title`=:title, `name`=:name, `link`=:link, `type`=:type, `type_id`=:type_id, `pid`=:pid'); $stmt->bindParam(':right_key', $rk); $stmt->bindParam(':level', $lev); $stmt->bindParam(':title', $tit); $stmt->bindParam(':name', $nam); $stmt->bindParam(':link', $link); $stmt->bindParam(':type', $typ); $stmt->bindParam(':type_id', $tid); $stmt->bindParam(':pid', $pid); $stmt->execute(); return $this->DB->lastInsertId(); }