Ejemplo n.º 1
0
     $category = new Category($id);
     if ($category->Edit($name, $priority, $desc)) {
         $info .= lng('CAT_UPDATED');
     } else {
         $info .= lng('CAT_EXIST');
     }
 } elseif ($id and Filter::input('delete', 'post', 'bool')) {
     $category = new Category($id);
     if ($category->Delete()) {
         $info .= lng('CAT_DELETED');
     } else {
         $info .= lng('CAT_NOT_EXIST');
     }
     $id = false;
 }
 $cat_list = CategoryManager::GetList($id);
 include View::Get('category_header.html', $st_subdir . 'category/');
 if ($id) {
     $cat_item = new Category($id);
     if ($cat_item->Exist()) {
         $cat_name = $cat_item->GetName();
         $cat_desc = $cat_item->GetDescription();
         $cat_priority = $cat_item->GetPriority();
         include View::Get('category_edit.html', $st_subdir . 'category/');
         if (!$cat_item->IsSystem()) {
             include View::Get('category_delete.html', $st_subdir . 'category/');
         }
     }
     unset($cat_item);
 } else {
     include View::Get('category_add.html', $st_subdir . 'category/');
Ejemplo n.º 2
0
 public function ShowNewsEditor()
 {
     global $bd_names;
     $editorTitle = 'Добавить новость';
     $editorButton = 'Добавить';
     $editInfo = array('vote' => !Filter::input('hide_vote', 'post', 'bool'), 'discus' => !Filter::input('hide_discus', 'post', 'bool'));
     $editCategory = Filter::input('cid', 'post', 'int', true);
     $editMode = Filter::input('editMode', 'post', 'int');
     $editTitle = Filter::input('title', 'post', 'string', true);
     $editMessage = Filter::input('message', 'post', 'html', true);
     $editMessage_Full = Filter::input('message_full', 'post', 'html', true);
     $error = '';
     if ($editCategory !== false and $editTitle !== false and $editMessage !== false) {
         ob_start();
         $state = 'error';
         if (!$editCategory or !$editMessage or !$editTitle) {
             $text_str = 'Заполните необходимые поля.';
         } else {
             if ($editMode > 0) {
                 $news_item = new News_Item($editMode, $this->st_subdir);
                 if ($news_item->Edit($editCategory, $editTitle, $editMessage, $editMessage_Full, $editInfo['vote'], $editInfo['discus'])) {
                     $state = 'success';
                     $text_str = 'Новость обновлена';
                 } else {
                     $text_str = 'Недостаточно прав';
                 }
                 $editMode = 0;
             } else {
                 $news_item = new News_Item();
                 $news_item->Create($editCategory, $editTitle, $editMessage, $editMessage_Full, $editInfo['vote'], $editInfo['discus']);
                 $state = 'success';
                 $text_str = 'Новость добавлена';
             }
         }
         include $this->GetView('news_admin_mess.html');
         $error = ob_get_clean();
     } elseif (Filter::input('delete', 'get', 'int')) {
         $news_item = new News_Item(Filter::input('delete', 'get', 'int'));
         $news_item->Delete();
         header("Location: " . $this->work_link . "ok");
     } elseif (Filter::input('edit', 'get', 'int')) {
         $editorTitle = 'Обновить новость';
         $editorButton = 'Изменить';
         $news_item = new News_Item(Filter::input('edit', 'get', 'int'));
         if (!$news_item->Exist()) {
             return '';
         }
         $editInfo = $news_item->getInfo();
         $editMode = $editInfo['id'];
         $editCategory = $editInfo['category_id'];
         $editTitle = TextBase::HTMLDestruct($editInfo['title']);
         $editMessage = TextBase::HTMLDestruct($editInfo['text']);
         $editMessage_Full = TextBase::HTMLDestruct($editInfo['text_full']);
     }
     ob_start();
     $cat_list = CategoryManager::GetList($editCategory);
     include $this->GetView('news_add.html');
     return ob_get_clean();
 }