Exemplo n.º 1
0
 function __construct()
 {
     if ($_POST) {
         DB::escapePost();
         News::setSubscribers();
         if ($_SERVER['HTTP_REFERER']) {
             $this->redirect($_SERVER['HTTP_REFERER']);
         } else {
             $this->redirect('/media/news/');
         }
     } else {
         $tree = Tree::getTreeByUrl('wide');
         Funcs::setMeta($tree);
         if (Funcs::$uri[2] == '') {
             $tree['pic'] = $tree['fields']['files_gal1'][0]['path'];
             $tree['list'] = News::getList($tree['id']);
             //$tree['tags']=News::getTagList($tree['id']);
             View::render('news/list', $tree);
         } else {
             //$tree['tags']=News::getTags($tree['id']);
             $tree['next'] = News::getNext($tree['id'], $tree['parent'], $tree['udate']);
             $tree['prev'] = News::getPrev($tree['id'], $tree['parent'], $tree['udate']);
             if (isset($_GET['print'])) {
                 View::render('news/print', $tree);
             } else {
                 View::render('news/one', $tree);
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * 新闻列表
  */
 public function listAction()
 {
     //当前页码
     $page_id = (int) $this->request->getQuery('page');
     $page_id = $page_id < 1 ? 1 : $page_id;
     //每页显示条数
     $limit = 20;
     //新闻分类
     $cat_id = (int) $this->request->getQuery('cat_id');
     //关键字
     $keyword = preg_replace('/[^\\da-z\\x{4e00}-\\x{9fa5}]/iu', '', mb_substr($this->request->getQuery('keyword'), 0, 10, 'utf-8'));
     //关键字长度小于10,并且只能是字符数字中文
     //新闻分类列表
     $model = new \News();
     $categories = $model->getCategorylist();
     array_unshift($categories, ['news_cat_id' => '', 'news_cat_name' => '所有分类']);
     //列表查询
     $list = $model->getList($page_id, $limit, $cat_id, $keyword);
     $page_html = $this->pageHtml($list['page']);
     $this->view->setVars(['cat_id' => $cat_id, 'keyword' => $keyword, 'categories' => $categories, 'list' => $list['list'], 'page_html' => $page_html]);
 }
Exemplo n.º 3
0
include_once "../config.inc.php";
include_once APP_INC_PATH . "class.template.php";
include_once APP_INC_PATH . "class.auth.php";
include_once APP_INC_PATH . "class.project.php";
include_once APP_INC_PATH . "class.news.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate("manage/index.tpl.html");
Auth::checkAuthentication(APP_COOKIE);
$tpl->assign("type", "news");
$role_id = Auth::getCurrentRole();
if ($role_id == User::getRoleID('administrator') || $role_id == User::getRoleID('manager')) {
    if ($role_id == User::getRoleID('administrator')) {
        $tpl->assign("show_setup_links", true);
    }
    if (@$HTTP_POST_VARS["cat"] == "new") {
        $tpl->assign("result", News::insert());
    } elseif (@$HTTP_POST_VARS["cat"] == "update") {
        $tpl->assign("result", News::update());
    } elseif (@$HTTP_POST_VARS["cat"] == "delete") {
        News::remove();
    }
    if (@$HTTP_GET_VARS["cat"] == "edit") {
        $tpl->assign("info", News::getAdminDetails($HTTP_GET_VARS["id"]));
    }
    $tpl->assign("list", News::getList());
    $tpl->assign("project_list", Project::getAll());
} else {
    $tpl->assign("show_not_allowed_msg", true);
}
$tpl->displayTemplate();
Exemplo n.º 4
0
 * @license GNU General Public License, version 2 or later (GPL-2+)
 *
 * For the full copyright and license information,
 * please see the COPYING and AUTHORS files
 * that were distributed with this source code.
 */
require_once __DIR__ . '/../../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('manage/news.tpl.html');
Auth::checkAuthentication();
$role_id = Auth::getCurrentRole();
if ($role_id < User::ROLE_MANAGER) {
    Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR);
    $tpl->displayTemplate();
    exit;
}
if (@$_POST['cat'] == 'new') {
    $res = News::insert();
    Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the news entry was added successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to add the news entry.'), Misc::MSG_ERROR), -2 => array(ev_gettext('Please enter the title for this news entry.'), Misc::MSG_ERROR), -3 => array(ev_gettext('Please enter the message for this news entry.'), Misc::MSG_ERROR)));
} elseif (@$_POST['cat'] == 'update') {
    $res = News::update();
    Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the news entry was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the news entry.'), Misc::MSG_ERROR), -2 => array(ev_gettext('Please enter the title for this news entry.'), Misc::MSG_ERROR), -3 => array(ev_gettext('Please enter the message for this news entry.'), Misc::MSG_ERROR)));
} elseif (@$_POST['cat'] == 'delete') {
    News::remove();
}
if (@$_GET['cat'] == 'edit') {
    $tpl->assign('info', News::getAdminDetails($_GET['id']));
}
$tpl->assign('list', News::getList());
$tpl->assign('project_list', Project::getAll());
$tpl->displayTemplate();
Exemplo n.º 5
0
 function run()
 {
     $id = Tree::getIdTreeByModule('news');
     $list = News::getList($id, 5);
     View::widget('news', array('list' => $list));
 }
Exemplo n.º 6
0
 public function getListAction()
 {
     $this->setTitle('News');
     $this->setParameter('news', News::getList(TRUE));
 }