Exemple #1
0
    /**
     * @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();
    }
Exemple #2
0
 /**
  * @param int $id
  * @return String
  */
 public function getPage($id = null)
 {
     $id = $this->isAjax() ? intval($_POST['id']) : $id;
     $tree = $this->pageModel->getPage($id);
     $entity = new Entity_Page();
     $entity->init($tree);
     $toReplace = array('{action}', '{tree_title}', '{tree_name}', '{tree_pid}', '{id_value}', '{seo_title_value}', '{seo_keywords_value}', '{seo_description_value}');
     $replace = array(empty($id) ? 'add' : 'update', $tree['title'], $tree['name'], empty($id) ? intval($_POST['pid']) : $tree['pid'], $tree['id'], $entity->getSeoTitle(), $entity->getSeoKeywords(), $entity->getSeoDescription());
     $typeModel = new Admin_Models_Type();
     $type = $typeModel->getTypeByName('page');
     $fields = json_decode($type->getJson(), true);
     $cnt = count($fields);
     if (empty($id)) {
         for ($i = 0; $i < $cnt; $i++) {
             $cntJ = count($fields[$i]['variants']);
             for ($j = 0; $j < $cntJ; $j++) {
                 $toReplace[] = '{' . $fields[$i]['name'] . '_' . $j . '_value}';
                 $replace[] = $fields[$i]['selects'] == $j ? $fields[$i]['type'] == 'select' ? 'selected="selected"' : 'checked="checked"' : '';
             }
         }
     } else {
         for ($i = 0; $i < $cnt; $i++) {
             $cntJ = count($fields[$i]['variants']);
             $str = 'get' . ucfirst($fields[$i]['name']) . '()';
             $arr = explode(',', $entity->{$str});
             for ($j = 0; $j < $cntJ; $j++) {
                 $toReplace[] = '{' . $fields[$i]['name'] . '_' . $j . '_value}';
                 if (in_array($fields[$i]['variants'][$j], $arr)) {
                     $replace[] = $fields[$i]['type'] == 'select' ? 'selected="selected"' : 'checked="checked"';
                 } else {
                     $replace[] = '';
                 }
             }
         }
     }
     $file = file_get_contents(ADMIN . '/views/types/page.tpl');
     $result = str_replace($toReplace, $replace, $file);
     if ($this->isAjax()) {
         $this->putAjax($result);
     }
     return $result;
 }