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_Block $block
     * @return bool
     */
    public function update($block)
    {
        $id = $block->getId();
        $side = $block->getSide();
        $text = $block->getText();
        $is_text = $block->getIs_text();
        $stmt = $this->DB->prepare('UPDATE `site_block` SET
                                    `block_side`=:side,
									`block_text`=:text,
									`block_is_text`=:is_text
                                    WHERE `block_id`=:id');
        $stmt->bindParam(':id', $id);
        $stmt->bindParam(':side', $side);
        $stmt->bindParam(':text', $text);
        $stmt->bindParam(':is_text', $is_text);
        return $stmt->execute();
    }
Esempio n. 3
0
 /**
  * @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;
 }