Пример #1
0
 public function action_edit()
 {
     $id = $this->request->param('id', null);
     if ($id) {
         $news = Model_News::find_by_id($id);
     } else {
         $news = new Model_News();
     }
     if ($this->request->is_post()) {
         $post = $this->cleaned_post();
         $news->update($post);
         $news->defunct = Model_News::DEFUNCT_NO;
         $news->importance = Model_News::TYPE_NORMAL;
         $news->content = $this->get_raw_post('content');
         if (isset($post['defunct'])) {
             $news->defunct = Model_News::DEFUNCT_YES;
         }
         if (isset($post['top'])) {
             $news->importance = Model_News::TYPE_TOP;
         }
         if (is_null($news->user_id)) {
             $news->user_id = $this->current_user->user_id;
         }
         if ($news->save()) {
             $this->redirect('/admin/news');
         } else {
             $this->flash_error(__('common.error'));
         }
     }
     $this->template_data['title'] = __('admin.news.edit.edit_news_:name', array(':name' => $news->title));
     $this->template_data['news'] = $news;
 }
Пример #2
0
 public function action_news()
 {
     $slug = $this->request->param('slug');
     $pageData = $this->newsModel->findNews(null, null, $slug == 'all' ? null : $slug, 'all');
     $content = $this->contentModel->getContent('news', $pageData);
     $footer = View::factory('footer')->set('pagesImgs', []);
     $this->template->set('content', $content)->set('footer', $footer);
     $this->response->body($this->template);
 }
Пример #3
0
 public function action_index()
 {
     $model_News = new Model_News();
     // wybieram widok
     $this->view = View::factory('template');
     // ustawiam dane w widoku
     $this->view->title = 'Strona Główna';
     $this->view->content = View::factory('start/index');
     $this->view->content->news = $model_News->getAll();
 }
Пример #4
0
 /**
  * Fonction permettant de mettre a jour une news
  * @param  Int $id_news Id de la news
  */
 public function updateNews($id_news)
 {
     $news = new Model_News();
     if (!empty($_POST)) {
         $id_news = $_POST['id_news'];
         $title = $_POST['title-new'];
         $content = $_POST['content-new'];
         $url = $_POST['url-new'];
         $id_admin = $_POST['id_admin'];
         $news->updateNews($title, $content, $url, $id_admin, $id_news);
     }
     $newsDetails = $news->loadNews($id_news);
     require_once $_SERVER['DOCUMENT_ROOT'] . "/ecommerce/views/admin/news/update_news.php";
 }
Пример #5
0
 public function __construct($reader, $writer)
 {
     parent::__construct($reader, $writer);
     $data = $this->reader->get_data();
     if (empty($data['id']) || !Check::id($data['id'])) {
         throw new Error_Update('Incorrect Id');
     }
     $model = new Model_News($data['id']);
     $model->load();
     if ($model->is_phantom()) {
         throw new Error_Update('Incorrect Id');
     }
     $this->model = $model;
 }
Пример #6
0
 public static function top_news()
 {
     $orderby = array('news_id' => self::ORDER_DESC);
     $filter = array('importance' => self::TYPE_TOP, 'defunct' => Model_News::DEFUNCT_NO);
     $news_list = Model_News::find($filter, 1, 10, $orderby);
     return $news_list;
 }
Пример #7
0
 public function action_add()
 {
     $model_News = new Model_News();
     // obsluga formularza
     if (isset($_POST['add'])) {
         $valid = $model_News->validation($_POST);
         if ($valid === TRUE) {
             $model_News->add($_POST);
         }
     }
     // wybieram widok
     $this->view = View::factory('template');
     // ustawiam dane w widoku
     $this->view->title = 'Dodaj artykuł';
     $this->view->content = View::factory('news/add');
     $this->view->content->valid = $valid;
 }
 /**
  * 删除资讯
  */
 public function cDel()
 {
     $this->_modelNews = $this->getGlobal('model/News', 'Model_News');
     if ($this->_modelNews->delete($this->getR('id'))) {
         $this->success(false);
     } else {
         $this->error('删除失败');
     }
 }
Пример #9
0
 /**
  * добавление новости
  */
 public function action_news_edit()
 {
     $params = $this->request->post('params');
     $result = Model_News::editNews($params);
     if (empty($result)) {
         $this->jsonResult(false);
     }
     $this->jsonResult(true);
 }
Пример #10
0
 public function action_delete($id = null)
 {
     if ($news = Model_News::find($id)) {
         $news->delete();
         Session::set_flash('success', 'Deleted news #' . $id);
     } else {
         Session::set_flash('error', 'Could not delete news #' . $id);
     }
     Response::redirect('news');
 }
Пример #11
0
 public function action_news()
 {
     $id = $this->request->param('id');
     $news = Model_News::find_by_id($id);
     if ($news and $news->is_public()) {
         $this->template_data['title'] = $news->title;
         $this->template_data['news'] = $news;
     } else {
         throw new Exception_Page(__('common.news_not_found'));
     }
 }
Пример #12
0
 public function main()
 {
     $post = $this->correct_main_data($this->reader->get_data());
     if (!$post['title']) {
         $this->writer->set_message('Вы забыли указать заголовок для новости.');
         return;
     }
     if ($post['author'] != def::user('name') && $post['author']) {
         $cookie = new dynamic__cookie();
         $cookie->inner_set('user.name', $post['author']);
     }
     $worker = new Transform_Meta();
     $category = $worker->category($post['category']);
     $parsed_author = $worker->parse($post['author'], def::user('author'));
     $author = $worker->author($parsed_author);
     $text = Transform_Text::format($post['text']);
     $item = new Model_News();
     $item->set_array(array('title' => $post['title'], 'text' => $text, 'pretty_text' => undo_safety($post['text']), 'image' => $post['image']['image'], 'extension' => $post['image']['extension'], 'author' => $author, 'category' => $category));
     $item->insert();
     $this->writer->set_success()->set_message('Ваша новость успешно добавлена, и доступна по адресу ' . '<a href="/news/' . $item->get_id() . '/">http://4otaku.org/news/' . $item->get_id() . '/</a>.');
 }
Пример #13
0
 public function action_index()
 {
     if ($this->user->birthday == "0000-00-00") {
         Response::redirect("teachers/setting/new");
     }
     $data["reservations"] = Model_Lessontime::find("all", ["where" => [["deleted_at", 0], ["teacher_id", $this->user->id], ["status", 1], ["freetime_at", ">=", time()]], "order_by" => [["id", "desc"]]]);
     $data["feedbacks"] = Model_Lessontime::find("all", ["where" => [["deleted_at", 0], ["teacher_id", $this->user->id], ["status", "<>", 0], ["status", "<>", 3], ["feedback", ""], ["freetime_at", "<=", time()]], "order_by" => [["id", "desc"]]]);
     $data["news"] = Model_News::find("all", ["where" => [["deleted_at", 0], ["for_teachers", 1]], "order_by" => [["id", "desc"]], "limit" => 5]);
     $data["user"] = $this->user;
     $view = View::forge("teachers/top", $data);
     $this->template->content = $view;
 }
Пример #14
0
 public function action_delete($id = null)
 {
     if (!Auth::has_access('news.delete')) {
         Session::set_flash('warning', 'You don\'t have the right to delete a news');
         Response::redirect('admin');
     }
     if ($news = Model_News::find($id)) {
         $news->delete();
         Session::set_flash('success', 'Deleted news #' . $id);
     } else {
         Session::set_flash('error', 'Could not delete news #' . $id);
     }
     Response::redirect('news');
 }
 /**
  * トップページ
  *
  * @access public
  * @return void
  * @author ida
  * @author shimma
  */
 public function action_index()
 {
     $view_model = \ViewModel::forge('top/index');
     $view_model->set('news_headlines', \Model_News::getHeadlines());
     $view_model->set('upcomming', \ViewModel::forge('component/upcomming'), false);
     $view_model->set('calendar', \ViewModel::forge('component/calendar'), false);
     $view_model->set('search', \ViewModel::forge('component/search')->set('is_top', true), false);
     $view_model->set('popular_ranking', \ViewModel::forge('component/popular'), false);
     $view_model->set('latest', \ViewModel::forge('component/latest'), false);
     Asset::js('jquery.carouFredSel.js', array(), 'add_js');
     Asset::js('jquery.rwdImageMaps.min.js', array(), 'add_js');
     Asset::js('top.js', array(), 'add_js');
     Asset::css('top.css', array(), 'add_css');
     $this->template->content = $view_model;
 }
Пример #16
0
 public function action_index()
 {
     if ($this->user->birthday == "0000-00-00") {
         Response::redirect("students/setting/new");
     }
     $data["reservations"] = Model_Lessontime::find("all", ["where" => [["deleted_at", 0], ["student_id", $this->user->id], ["status", 1], ["freetime_at", ">=", time()]], "order_by" => [["id", "desc"]]]);
     $data["lastClass"] = Model_Lessontime::find("last", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", 0)], ["deleted_at", 0]]]);
     $data["lesson"] = Model_Lessontime::find("first", ["where" => [["deleted_at", 0], ["student_id", $this->user->id], ["status", 1], ["freetime_at", "<=", time() + 1800], ["freetime_at", ">=", time() - 1800]]]);
     $data["news"] = Model_News::find("all", ["where" => [["deleted_at", 0], ["for_students", 1]], "order_by" => [["id", "desc"]], "limit" => 5]);
     $data["pasts"] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", 0)], ["deleted_at", 0]]]);
     $data["donetrial"] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", -1)], ["deleted_at", 0]]]);
     $data["user"] = $this->user;
     $view = View::forge("students/top", $data);
     $this->template->content = $view;
 }
Пример #17
0
 public static function get_list($limit, $page = 1, $is_auth = false, $news_category_id = 0, $news_ids = array())
 {
     $where_conds = array(array('is_published', 1), array('published_at', '<', \DB::expr('NOW()')));
     if (!$is_auth) {
         $where_conds[] = array('is_secure', 0);
     }
     if ($news_category_id) {
         $where_conds[] = array('news_category_id', $news_category_id);
     }
     if ($news_ids) {
         $where_conds[] = array('id', 'in', $news_ids);
     }
     $data = Model_News::get_pager_list(array('related' => array('news_category'), 'where' => $where_conds, 'limit' => $limit, 'order_by' => array('published_at' => 'desc')), $page);
     return $data;
 }
Пример #18
0
 public static function get_slug()
 {
     $main = date('ymd');
     $suffix = '';
     $slug = $main . $suffix;
     $max = \Config::get('news.max_articles_per_day');
     $i = 0;
     while (Model_News::check_exists4slug($slug)) {
         if ($i > $max) {
             throw \FuelException('Posted news exceeded the limit on par day.');
         }
         $suffix = \Util_string::get_next_alpha_str($suffix);
         $slug = $main . $suffix;
         $i++;
     }
     return $slug;
 }
Пример #19
0
 public function action_detail($id)
 {
     $data["news"] = Model_News::find($id, ["where" => [["deleted_at", 0], ["for_teachers", 1]]]);
     if ($data["news"] == null) {
         Response::redirect("teachers/news");
     }
     $is_read = Model_Readnews::find("first", ["where" => [["user_id" => $this->user->id], ["news_id" => $id]]]);
     if ($is_read == null) {
         $is_read = Model_Readnews::forge();
         $is_read->user_id = $this->user->id;
         $is_read->news_id = $id;
         $is_read->save();
     }
     $data["user"] = $this->user;
     $view = View::forge("teachers/news/detail", $data);
     $this->template->content = $view;
 }
Пример #20
0
 /**
  * The basic welcome message
  * 
  * @access  public
  * @return  Response
  */
 public function action_index()
 {
     list($driver, $user_id) = Auth::get_user_id();
     $this_user = Model_User::find($user_id);
     $latest_news_q = Model_News::query()->where('call_center_id', $this_user->call_center_id)->or_where('call_center_id', 0)->order_by('created_at', 'DESC');
     if ($latest_news_q->count() > 0) {
         $latest_news = $latest_news_q->get();
     } else {
         $latest_news = null;
     }
     $invalid_logins_q = Model_Users_Log_Login::query()->where('user_id', $user_id)->where('status', 2)->order_by('login_time', 'DESC');
     if ($invalid_logins_q->count() > 0) {
         $invalid_logins = $invalid_logins_q->get();
     } else {
         $invalid_logins = null;
     }
     $this->template->title = 'Projects &raquo; Index';
     $this->template->content = View::forge('welcome/index', array('invalid_logins' => $invalid_logins, 'latest_news' => $latest_news))->auto_filter(FALSE);
 }
Пример #21
0
 public function action_detail($id)
 {
     $data["news"] = Model_News::find($id, ["where" => [["deleted_at", 0], ["for_students", 1]]]);
     $data['pasts'] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", 0)], ["deleted_at", 0]]]);
     $data["donetrial"] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", -1)], ["deleted_at", 0]]]);
     if ($data["news"] == null) {
         Response::redirect("students/news");
     }
     $is_read = Model_Readnews::find("first", ["where" => [["user_id" => $this->user->id], ["news_id" => $id]]]);
     if ($is_read == null) {
         $is_read = Model_Readnews::forge();
         $is_read->user_id = $this->user->id;
         $is_read->news_id = $id;
         $is_read->save();
     }
     $data["user"] = $this->user;
     $view = View::forge("students/news/detail", $data);
     $this->template->content = $view;
 }
Пример #22
0
 public function post_delnews()
 {
     $code = 0;
     $message = "ok";
     if ($this->auth_status) {
         $news = Model_News::find(Input::post("id", 0));
         if ($news != null) {
             $news->deleted_at = time();
             $news->save();
         } else {
             $code = 404;
             $message = "Content not found.";
         }
     } else {
         $code = 500;
         $message = "Auth error.";
     }
     $this->response(array('code' => $code, 'message' => $message));
 }
 /**
  * メインページ
  *
  * @access public
  * @return void
  * @author shimma
  *
  * @todo メインページのテンプレートからJSを分離
  */
 public function action_index()
 {
     Asset::css('jquery-ui.min.css', array(), 'add_css');
     Asset::js('jquery-ui.min.js', array(), 'add_js');
     Asset::js('jquery.carouFredSel.js', array(), 'add_js');
     $fleamarkets_all['reserved'] = $this->login_user->getReservedEntries(1, 3);
     $fleamarkets_all['waiting'] = $this->login_user->getWaitingEntries(1, 3);
     $fleamarkets_all['mylist'] = $this->login_user->getFavorites(1, 3);
     $fleamarkets_all['myfleamarket'] = $this->login_user->getMyFleamarkets(1, 3);
     $fleamarkets_view = array();
     foreach ($fleamarkets_all as $type => $fleamarkets) {
         foreach ($fleamarkets as $fleamarket) {
             $fleamarkets_view[$type][] = ViewModel::forge('component/fleamarket')->set('type', $type)->set('fleamarket', $fleamarket)->set('user', $this->login_user)->set('no_box', true);
         }
     }
     $view_model = View::forge('mypage/index');
     $view_model->set('fleamarkets_view', $fleamarkets_view, false);
     $view_model->set('news_headlines', \Model_News::getHeadlines());
     $view_model->set('calendar', \ViewModel::forge('component/calendar'), false);
     $view_model->set('search', \ViewModel::forge('component/search')->set('is_top', false), false);
     $view_model->set('popular_ranking', \ViewModel::forge('component/popular'), false);
     $view_model->set('fleamarket_latest', \ViewModel::forge('component/latest'), false);
     $this->template->content = $view_model;
 }
Пример #24
0
 function getNotices($nums = 5)
 {
     $sql = "select * from `ws_news` where `type`=1 and `delflg`=0";
     $rets = $this->_modelNews->findBySql($sql, $nums);
     return $rets;
 }
Пример #25
0
 /**
  * 更新文章当天的统计
  * @param $iType 1:访问量,2:分享量
  * @param $ikey的格式 :v20150204,s20150204
  */
 public static function updateNewsDayStatis($iNewsID, $iType = 1)
 {
     if (!($aNews = self::getNewsByID($iNewsID))) {
         return 0;
     }
     $iCityID = $aNews['iCityID'];
     switch ($iType) {
         case 1:
             $iRKey = $iCityID . '_v_' . date('Ymd');
             $sMKey = 'iVisitNum';
             break;
         case 2:
             $iRKey = $iCityID . '_s_' . date('Ymd');
             $sMKey = 'iShareTimes';
             break;
         default:
             $iRKey = $iCityID . '_v_' . date('Ymd');
             $sMKey = 'iVisitNum';
     }
     //mysql统计总访问量
     $aNews[$sMKey] += 1;
     if (!Model_News::updData($aNews)) {
         return 0;
     }
     //redis统计当天访问量
     $redis = Util_Common::getRedis();
     $iMember = $iNewsID;
     return $redis->ZINCRBY($iRKey, 1, $iMember);
 }
Пример #26
0
 /**
  * 增加资讯
  *
  * @return boolean
  */
 public function addAction()
 {
     if ($this->isPost()) {
         $aNews = $this->_checkData();
         if (empty($aNews)) {
             return null;
         }
         $sAction = '保存';
         if ($this->getParam('iOptype') > 0) {
             $aNews['iPublishStatus'] = 1;
             //发布需要将该字段改为1
             $sAction = '发布';
         }
         //增加需要加上当前添加人ID
         $aCurrUserInfo = $this->aCurrUser;
         $aNews['iUpdateUserID'] = $aCurrUserInfo['iUserID'];
         $aNews['iCreateUserID'] = $aCurrUserInfo['iUserID'];
         $iNewsID = Model_News::addData($aNews);
         if ($iNewsID > 0) {
             return $this->showMsg(['sMsg' => '资讯信息' . $sAction . '成功!', 'iNewsID' => $iNewsID], true);
         } else {
             return $this->showMsg('资讯信息' . $sAction . '失败!', false);
         }
     } else {
         $this->_response->setHeader('Access-Control-Allow-Origin', '*.*');
         $aCategory = Model_Category::getPairCategorys($this->_getTypeCategory());
         $aTag = $this->_getTagList();
         //Model_Tag::getPairTags($this->_getTypeTag());
         $this->assign('iTypeID', $this->_getTypeID());
         $this->assign('iCityID', $this->_getCityID());
         $this->assign('aCategory', $aCategory);
         $this->assign('aTag', $aTag);
         $this->assign('sUploadUrl', Yaf_G::getConf('upload', 'url'));
         $this->assign('sFileBaseUrl', 'http://' . Yaf_G::getConf('file', 'domain'));
     }
 }
Пример #27
0
 function getNew($id)
 {
     $sql = "select * from `ws_news` where newsid={$id} and `delflg`=0";
     $rets = $this->_modelNews->findBySql($sql, null);
     return $rets;
 }
Пример #28
0
 /**
  * Get additional content data selected
  * 
  * @param $result = Query result
  */
 public static function post_find($result)
 {
     if ($result !== null) {
         if (is_array($result)) {
             foreach ($result as $item) {
                 // It will first check if we already have result in temporary result,
                 // and only execute query if we dont. That way we dont have duplicate queries
                 // Get content images
                 $item->get_images = static::lazy_load(function () use($item) {
                     return Model_Image::find(array('where' => array('content_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'images');
                 // Get content files
                 $item->get_files = static::lazy_load(function () use($item) {
                     return Model_File::find(array('where' => array('content_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'files');
                 // Get content videos
                 $item->get_videos = static::lazy_load(function () use($item) {
                     return Model_Video::find(array('where' => array('content_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'videos');
                 // Get content children
                 $item->get_children = static::lazy_load(function () use($item) {
                     return Model_News::find(array('where' => array('parent_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'children');
                 // Get content accordions
                 $item->get_accordions = static::lazy_load(function () use($item) {
                     return Model_Accordion::find(array('where' => array('parent_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'accordions');
                 // Get content children
                 $item->get_seo = static::lazy_load(function () use($item) {
                     return Model_Seo::find_one_by_content_id($item->id);
                 }, $item->id, 'seo', 'object');
             }
         }
     }
     // return the result
     return $result;
 }
Пример #29
0
<?php

$error = "";
if (isset($_POST['add_news'])) {
    $title = $desc = $full = "";
    if ($_POST['txtnews_title'] == NULL) {
        $error[] = "Please input your title";
    } else {
        $title = $_POST['txtnews_title'];
    }
    $desc = $_POST['txtnews_desc'];
    $full = $_POST['txtnews_full'];
    if ($title) {
        $mnews = new Model_News();
        $mnews->setNewstitle($title);
        $mnews->setNewsdesc($desc);
        $mnews->setNewsfull($full);
        $mnews->insertNews();
        redirect("{$baseurl}/news/list");
    }
}
$title = 'Add news page';
require 'views/news/add_view.php';
Пример #30
0
<?php

$mnews = new Model_News();
$data = $mnews->listNews();
$title = 'List news has added';
require 'views/news/list_view.php';