/** * @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); }
/** * @param Entity_Page $page * @return bool */ public function update($page) { $id = $page->getId(); $seo_title = $page->getSeoTitle(); $seo_keywords = $page->getSeoKeywords(); $seo_description = $page->getSeoDescription(); $stmt = $this->DB->prepare('UPDATE `site_page` SET `page_seo_title`=:seo_title, `page_seo_keywords`=:seo_keywords, `page_seo_description`=:seo_description WHERE `page_id`=:id'); $stmt->bindParam(':id', $id); $stmt->bindParam(':seo_title', $seo_title); $stmt->bindParam(':seo_keywords', $seo_keywords); $stmt->bindParam(':seo_description', $seo_description); return $stmt->execute(); }
/** * @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; }