コード例 #1
0
ファイル: menu.php プロジェクト: CrazyBobik/4J
 /**
  * @param Entity_Tree $leaf
  * @param string $fa
  * @param string $clazz
  * @return string
  */
 private function genOnePoint(&$leaf, $fa = '', $clazz = '', $subMenu = '', $panel = true)
 {
     $toggle = '<div class="toggle-sub-menu float-right"><i class="fa fa-chevron-down"></i></div>';
     $toReplace = array('{class}', '{id}', '{type}', '{faIcon}', '{title}', '{toggle}', '{subMenu}', '{panel}');
     $replace = array($clazz, $leaf->getId(), $leaf->getType(), $fa, $leaf->getTitle(), $subMenu === '' ? '' : $toggle, $subMenu, $panel ? file_get_contents($this->views . '/panel.tpl') : '');
     $file = file_get_contents($this->views . '/one-item.tpl');
     return str_replace($toReplace, $replace, $file);
 }
コード例 #2
0
ファイル: block.php プロジェクト: CrazyBobik/4J
 /**
  * @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);
 }
コード例 #3
0
ファイル: page.php プロジェクト: CrazyBobik/4J
 /**
  * @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);
 }
コード例 #4
0
ファイル: tree.php プロジェクト: CrazyBobik/4J
    /**
     * @param Entity_Tree $tree
     * @return bool
     */
    public function updateTree($tree)
    {
        $id = $tree->getId();
        $title = $tree->getTitle();
        $name = $tree->getName();
        $link = $tree->getLink();
        $stmt = $this->DB->prepare('UPDATE `site_tree` SET
									`title`=:title,
									`name`=:name,
									`link`=:link
                                    WHERE `id`=:id');
        $stmt->bindParam(':id', $id);
        $stmt->bindParam(':title', $title);
        $stmt->bindParam(':name', $name);
        $stmt->bindParam(':link', $link);
        return $stmt->execute();
    }
コード例 #5
0
ファイル: page.php プロジェクト: CrazyBobik/4J
 /**
  * @param array $data
  * @return bool
  */
 public function updatePage($data = array())
 {
     $tree = new Entity_Tree();
     $tree->setId($this->isAjax() ? strip_tags($_POST['id']) : $data['id']);
     $tree->setTitle($this->isAjax() ? strip_tags($_POST['title']) : $data['tree_title']);
     $tree->setName($this->isAjax() ? strip_tags($_POST['name']) : $data['tree_name']);
     $id = $tree->getId();
     $title = $tree->getTitle();
     $name = $tree->getName();
     $validator = new Libs_Validator(array('title' => 'Титулка', 'name' => 'Имя', 'pid' => 'Ид родителя'));
     $data = array('title' => $title, 'name' => $name, 'id' => $id);
     $valid = array('title' => array('required' => true), 'name' => array('required' => true), 'id' => array('required' => true));
     if (!$validator->isValid($data, $valid)) {
         if ($this->isAjax()) {
             $json = array('error' => true, 'mess' => $validator->getErrors());
             $this->putJSON($json);
         }
         return $validator->getErrors();
     }
     $entity = new Entity_Page();
     $entity->setSeoTitle($this->isAjax() ? strip_tags($_POST['seo_title']) : $data['seo_title']);
     $entity->setSeoKeywords($this->isAjax() ? strip_tags($_POST['seo_keywords']) : $data['seo_keywords']);
     $entity->setSeoDescription($this->isAjax() ? strip_tags($_POST['seo_description']) : $data['seo_description']);
     $id = $this->pageModel->updatePage($tree, $entity);
     if ($this->isAjax()) {
         $json = array();
         if ($id) {
             $json['error'] = false;
             $json['mess'] = 'Обновлено';
             $json['clear'] = false;
             $json['callback'] = 'function callback(){reloadMenu();}';
         } else {
             $json['error'] = true;
             $json['mess'] = 'Ошибка';
         }
         $this->putJSON($json);
     }
     return $id;
 }
コード例 #6
0
ファイル: block.php プロジェクト: CrazyBobik/4J
 /**
  * @param array $data
  * @return bool
  */
 public function updateBlock($data = array())
 {
     $tree = new Entity_Tree();
     $tree->setId($this->isAjax() ? strip_tags($_POST['id']) : $data['id']);
     $tree->setTitle($this->isAjax() ? strip_tags($_POST['title']) : $data['tree_title']);
     $tree->setName($this->isAjax() ? strip_tags($_POST['name']) : $data['tree_name']);
     $id = $tree->getId();
     $title = $tree->getTitle();
     $name = $tree->getName();
     $validator = new Libs_Validator(array('title' => 'Титулка', 'name' => 'Имя', 'pid' => 'Ид родителя'));
     $data = array('title' => $title, 'name' => $name, 'id' => $id);
     $valid = array('title' => array('required' => true), 'name' => array('required' => true), 'id' => array('required' => true));
     if (!$validator->isValid($data, $valid)) {
         if ($this->isAjax()) {
             $json = array('error' => true, 'mess' => $validator->getErrors());
             $this->putJSON($json);
         }
         return $validator->getErrors();
     }
     $entity = new Entity_Block();
     $entity->setSide($this->isAjax() ? strip_tags($_POST['block_side']) : $data['block_side']);
     $entity->setText($this->isAjax() ? strip_tags($_POST['block_text']) : $data['block_text']);
     $entity->setIsText($this->isAjax() ? strip_tags($_POST['block_is_text']) : $data['block_is_text']);
     $result = $this->blockModel->updateBlock($tree, $entity);
     if ($this->isAjax()) {
         $json = array();
         if ($result) {
             $json['error'] = false;
             $json['mess'] = 'Обновлено';
             $json['clear'] = false;
             $json['callback'] = 'function callback(){reloadMenu();}';
         } else {
             $json['error'] = true;
             $json['mess'] = 'Ошибка';
         }
         $this->putJSON($json);
     }
     return $result;
 }
コード例 #7
0
ファイル: tree.php プロジェクト: CrazyBobik/4J
    /**
     * @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;
    }