Example #1
0
 public function testGetContent()
 {
     Yii::app()->getModule('news');
     Yii::import('application.modules.news.models.*');
     $model = new News();
     $model->setAttributes(array('text' => 'comment 1', 'status' => News::STATE_ACTIVE), false);
 }
Example #2
0
 protected function loadNewsList()
 {
     $this->num_per_page = $this->db->real_escape_string($this->num_per_page);
     $this->page_num = $this->db->real_escape_string($this->page_num);
     $this->categoryID = trim($this->db->real_escape_string($this->categoryID));
     $start_record = $this->page_num * $this->num_per_page;
     $query = "select *,admin.username, na.createdDateTime as nacreatedDateTime from `newsarticle` na \n\t\t\t\tinner join `category` c on na.categoryID = c.categoryID\n\t\t\t\tinner join `administrator` admin on na.adminID = admin.adminID\n\t\t\t\twhere na.newsStatus = '" . $this->newsStatus . "'";
     if ($this->categoryID != "" && $this->categoryID > 0) {
         $query .= " and na.categoryID = " . $this->categoryID;
     }
     if ($this->onlyFollowed) {
         $query .= " and na.adminID in (select admin_id from editor_user where user_id=" . $this->onlyFollowed . ")";
     }
     $query .= " order by na.createdDateTime desc";
     $query .= " limit {$start_record}, {$this->num_per_page}";
     $newsArray = $this->db->query($query);
     if (is_array($newsArray) && count($newsArray) > 0) {
         $newsObj = new News(0, $this->summary_len);
         foreach ($newsArray as $id => $news) {
             $newsResult = $newsObj->setModelNews($news)->getArray();
             $newsArray[$id] = $newsResult["news"];
         }
         $this->newsMetaArr["newsMetaList"] = $newsArray;
     }
 }
Example #3
0
function admin_news_create()
{
    if (isset($_REQUEST['create'])) {
        $news = new News();
        $news->title = $_REQUEST['title'];
        $news->content = $_REQUEST['content'];
        $news->tags = $_REQUEST['tags'];
        $news->protected = $_REQUEST['protected'];
        $news->custom_sidebar = $_POST['custom_sidebar'];
        if ($_POST['start_date_check'] == 1) {
            $news->start_date = strtotime($_POST['start_date']['year'] . "-" . $_POST['start_date']['month'] . "-" . $_POST['start_date']['day'] . "  " . str_pad($_POST['start_date']['hour'], 2, "0", STR_PAD_LEFT) . ":" . str_pad($_POST['start_date']['minute'], 2, "0", STR_PAD_LEFT) . "" . $_POST['start_date']['meridiem']);
        } else {
            $news->start_date = 0;
        }
        if ($_POST['end_date_check'] == 1) {
            $news->end_date = strtotime($_POST['end_date']['year'] . "-" . $_POST['end_date']['month'] . "-" . $_POST['end_date']['day'] . "  " . str_pad($_POST['end_date']['hour'], 2, "0", STR_PAD_LEFT) . ":" . str_pad($_POST['end_date']['minute'], 2, "0", STR_PAD_LEFT) . "" . $_POST['end_date']['meridiem']);
        } else {
            $news->end_date = 0;
        }
        $news->save();
        $news->created_on = date("Y-m-d H:i:s", strtotime($_POST['created_on']['year'] . "-" . $_POST['created_on']['month'] . "-" . $_POST['created_on']['day'] . "  " . str_pad($_POST['created_on']['hour'], 2, "0", STR_PAD_LEFT) . ":" . str_pad($_POST['created_on']['minute'], 2, "0", STR_PAD_LEFT) . "" . $_POST['created_on']['meridiem']));
        $news->save();
        render('news_list');
        return true;
    }
    render();
}
 /**
  * Load your component.
  * 
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function load(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $_CORELANG, $page, $objTemplate, $subMenuTitle;
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND:
             $newsObj = new News(\Env::get('cx')->getPage()->getContent());
             \Env::get('cx')->getPage()->setContent($newsObj->getNewsPage());
             $newsObj->getPageTitle(\Env::get('cx')->getPage()->getTitle());
             // Set the meta page description to the teaser text if displaying news details
             $teaser = $newsObj->getTeaser();
             if ($teaser !== null) {
                 //news details, else getTeaser would return null
                 $page->setMetadesc(contrexx_raw2xhtml(contrexx_strip_tags(html_entity_decode($teaser, ENT_QUOTES, CONTREXX_CHARSET))));
             }
             if (substr($page->getCmd(), 0, 7) == 'details') {
                 \Env::get('cx')->getPage()->setTitle($newsObj->newsTitle);
                 \Env::get('cx')->getPage()->setContentTitle($newsObj->newsTitle);
                 \Env::get('cx')->getPage()->setMetaTitle($newsObj->newsTitle);
             }
             break;
         case \Cx\Core\Core\Controller\Cx::MODE_BACKEND:
             $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'LegacyContentMaster.html');
             $objTemplate = $this->cx->getTemplate();
             \Permission::checkAccess(10, 'static');
             $subMenuTitle = $_CORELANG['TXT_NEWS_MANAGER'];
             $objNews = new NewsManager();
             $objNews->getPage();
             break;
         default:
             break;
     }
 }
Example #5
0
 /**
  * 新闻列表
  * 
  * @return null
  * 
  */
 function go()
 {
     if (isset($_GET['get']) && $_GET['get'] == 1) {
         require_once "./protected/models/news.class.php";
         $newsList = new News();
         echo json_encode(array("rows" => $newsList->getPage($_POST['start'], $_POST['limit']), "results" => $newsList->countNum()));
     } else {
         if (isset($_POST['saveType'])) {
             $param1 = array();
             $param2 = array();
             if ($_POST['saveType'] === 'add') {
                 $param1 = array("id" => $_POST['id'], "title" => $_POST['title'], "content" => $_POST['content']);
             } else {
                 if ($_POST['saveType'] === 'remove') {
                     $param2 = explode(',', $_POST['ids']);
                 } else {
                     if ($_POST['saveType'] === 'update') {
                         $param1 = array("id" => $_POST['id'], "title" => $_POST['title'], "content" => $_POST['content']);
                     }
                 }
             }
             require_once "./protected/models/news.class.php";
             $news = new News($param1);
             echo json_encode($news->{$_POST}['saveType']($param2));
         } else {
             $pageInfo = $this->getPageInfo();
             $this->renderLayout('main', 'list', array('pageInfo' => $pageInfo));
         }
     }
 }
Example #6
0
function news_show()
{
    global $news_show;
    $news = new News();
    $news_show = $news->find($_GET['id']);
    render();
}
 function getContent()
 {
     $err_msg = $_SESSION['LOGIN_RESULT'];
     $_SESSION['LOGIN_RESULT'] = "";
     $p = array();
     $d = new News($this->db_conn);
     //$d->debug = 1;
     $limit_str = " LIMIT 0, 5";
     $p['news_type'] = 1;
     $lists1 = $d->getListArray($p, $limit_str);
     $p['news_type'] = 2;
     $lists2 = $d->getListArray($p, $limit_str);
     $a = new Article($this->db_conn);
     $p['article_type'] = 1;
     $art1 = $a->getListArray($p, " LIMIT 0, 1");
     $p['article_type'] = 2;
     $art2 = $a->getListArray($p, " LIMIT 0, 1");
     $this->assign('data', $d);
     $this->assign('lists1', $lists1);
     $this->assign('lists2', $lists2);
     $this->assign('art1', $art1[0]);
     $this->assign('art2', $art2[0]);
     $this->assign('errmsg', $err_msg);
     //$this->assign('content_page', $this->template.$this->list_tpl);
 }
 public function actionAddRandomNews()
 {
     $news = new News();
     $news->title = "Item #" . rand(1, 10000);
     $news->created_on = time();
     $news->save();
     echo "OK";
 }
 public function save(News $news)
 {
     if ($news->isValid()) {
         $news->isNew() ? $this->add($news) : $this->update($news);
     } else {
         throw new RuntimeException('La news doit être valide pour être enregistrée');
     }
 }
Example #10
0
 static function addNew($titre, $image, $texte)
 {
     $new = new News();
     $new->titre = $titre;
     $new->image = "Vue/Image/" . $image;
     $new->contenu = $texte;
     $new->date = date("Y-m-d H:i:s");
     $new->save();
 }
 protected function update(News $news)
 {
     $requete = $this->db->prepare('UPDATE news SET auteur = :auteur, titre = :titre, contenu = :contenu, dateModif = NOW() WHERE id = :id');
     $requete->bindValue(':titre', $news->titre());
     $requete->bindValue(':auteur', $news->auteur());
     $requete->bindValue(':contenu', $news->contenu());
     $requete->bindValue(':id', $news->id(), PDO::PARAM_INT);
     $requete->execute();
 }
 public function actionAdd()
 {
     $NewsHeader = isset($_POST['NewsHeader']) ? $_POST['NewsHeader'] : null;
     $NewsPreview = isset($_POST['NewsPreview']) ? $_POST['NewsPreview'] : null;
     $NewsText = isset($_POST['NewsText']) ? $_POST['NewsText'] : null;
     $NewsTags = isset($_POST['NewsTags']) ? $_POST['NewsTags'] : null;
     $news = new News();
     $result = $news->CreateRecord($NewsHeader, $NewsPreview, $NewsText, $NewsTags);
     header('Location: ./index.php?block=News&action=getAll');
 }
Example #13
0
    public static function get_news($condition, array $parameters = array())
    {
        $row = self::$db_querier->select_single_row_query('SELECT news.*, member.*
		FROM ' . NewsSetup::$news_table . ' news 
		LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = news.author_user_id
		' . $condition, $parameters);
        $news = new News();
        $news->set_properties($row);
        return $news;
    }
Example #14
0
 public function articleForm()
 {
     $form = new \Ease\TWB\Form('NewsArticle');
     $form->addItem(new \Ease\Html\InputHiddenTag('id', $this->newsEngine->getMyKey()));
     $form->addInput(new \Ease\Html\InputTextTag('name'), _('Name'));
     $form->addInput(new WISWYG('text'), _('Text'));
     $form->addItem(new \Ease\TWB\SubmitButton('Ok', 'success'));
     $form->fillUp($this->newsEngine->getData());
     return $form;
 }
Example #15
0
 public function DeleteNews()
 {
     $news_obj = new News();
     $id = Input::get('id');
     if ($news_obj->DeleteNews($id)) {
         return Redirect::to('admin/listnews')->with('bao_thanh_cong', 'Xóa Thành Công');
     } else {
         return Redirect::back()->with('bao_loi', 'Xóa Thất Bại');
     }
 }
Example #16
0
 protected function actionAdd()
 {
     $addart = new View('view/forms.php');
     $addart->display();
     if (isset($_POST['text']) && isset($_POST['title'])) {
         $article = new News();
         $article->title = $_POST['title'];
         $article->text = $_POST['text'];
         $article->save();
     }
 }
 public function actionAdd()
 {
     $NewsHeader = isset($_POST['NewsHeader']) ? $_POST['NewsHeader'] : null;
     $NewsPreview = isset($_POST['NewsPreview']) ? $_POST['NewsPreview'] : null;
     $NewsText = isset($_POST['NewsText']) ? $_POST['NewsText'] : null;
     $NewsTags = isset($_POST['NewsTags']) ? $_POST['NewsTags'] : null;
     $news = new News();
     $result = $news->AddNews($NewsHeader, $NewsPreview, $NewsText, $NewsTags);
     //echo $result.' Added';
     header('Location: ./index.php?ctrl=News&act=All');
 }
 public function actionList()
 {
     $this->breadcrumbs[] = array('title' => "Новости", 'url' => $this->createUrl("list"));
     $this->Title = "Новости";
     $model = new News("search");
     if (!empty($_GET['filter'])) {
         $model->attributes = $_GET['filter'];
     }
     $dataProvider = $model->search();
     $this->render("list", ["dP" => $dataProvider]);
 }
 public function testUniqueTitle()
 {
     $news = new News();
     $news->title = 'News';
     $news->body = 'FooBar';
     $this->assertTrue($news->save());
     $news = new News();
     $news->body = 'Ananas';
     $news->title = 'News';
     $this->assertFalse($news->save());
 }
Example #20
0
 public function articleForm()
 {
     $form = new \Ease\TWB\Form('NewsArticle');
     $form->addItem(new \Ease\Html\InputHiddenTag('id', $this->newsEngine->getMyKey()));
     $form->addInput(new \Ease\Html\InputTextTag('title'), _('Name'));
     $form->addInput(new WISWYG('text'), _('Text'));
     $form->addInput(new \Ease\Html\Select('language', ['cs' => _('Czech'), 'en' => _('English')]), _('Language'));
     $form->addItem(new \Ease\TWB\SubmitButton('Ok', 'success'));
     $form->fillUp($this->newsEngine->getData());
     return $form;
 }
 public function actionUpdate()
 {
     $NewsRecord = new News();
     $NewsRecord->NewsHeader = isset($_POST['NewsHeader']) ? $_POST['NewsHeader'] : null;
     $NewsRecord->NewsPreview = isset($_POST['NewsPreview']) ? $_POST['NewsPreview'] : null;
     $NewsRecord->NewsText = isset($_POST['NewsText']) ? $_POST['NewsText'] : null;
     $NewsRecord->NewsTags = isset($_POST['NewsTags']) ? $_POST['NewsTags'] : null;
     $NewsId = isset($_GET['id']) ? (int) $_GET['id'] : null;
     $NewsRecord->WHERE = [':NewsId' => $NewsId];
     $NewsRecord->update();
     header('Location: ./index.php');
 }
 public function run()
 {
     DB::table('news')->delete();
     $user = User::all()->first();
     $news = new News();
     $news->title = "The first discount";
     $news->description = "Neque molestiae nobis ex sint incidunt animi. Ipsa eum repellat quisquam quasi dolorem sapiente porro repellat. Praesentium non enim quod corrupti maxime impedit illum. Minus ea quo labore et. Quas quia laudantium fuga est. Nihil exercitationem nam incidunt rerum animi repellat. Sit sapiente temporibus voluptate in. Rerum consequatur non sed delectus pariatur harum accusantium sint. Repellendus explicabo sapiente itaque ipsum. Saepe ipsum assumenda voluptatem aut. Ut rerum enim qui facere. Et quod ipsam id amet. Error id molestiae aut ut sit ducimus.";
     $news->save();
     $news = new News();
     $news->title = "The second discount";
     $news->description = "Neque molestiae nobis ex sint incidunt animi. Ipsa eum repellat quisquam quasi dolorem sapiente porro repellat. Praesentium non enim quod corrupti maxime impedit illum. Minus ea quo labore et. Quas quia laudantium fuga est. Nihil exercitationem nam incidunt rerum animi repellat. Sit sapiente temporibus voluptate in. Rerum consequatur non sed delectus pariatur harum accusantium sint. Repellendus explicabo sapiente itaque ipsum. Saepe ipsum assumenda voluptatem aut. Ut rerum enim qui facere. Et quod ipsam id amet. Error id molestiae aut ut sit ducimus.";
     $news->save();
 }
 private function build_sources_view(News $news)
 {
     $sources = $news->get_sources();
     $nbr_sources = count($sources);
     if ($nbr_sources) {
         $this->tpl->put('news.C_SOURCES', $nbr_sources > 0);
         $i = 1;
         foreach ($sources as $name => $url) {
             $this->tpl->assign_block_vars('news.sources', array('C_SEPARATOR' => $i < $nbr_sources, 'NAME' => $name, 'URL' => $url));
             $i++;
         }
     }
 }
Example #24
0
 public function newsFormSubmited(NAppForm $form)
 {
     if ($form['addnews']->isSubmittedBy()) {
         $values = $form->getValues();
         $id = (int) $this->getParam('id');
         $ref = new News(array('id' => $id));
         if ($id > 0) {
             $ref->update($id, $values);
         } else {
             $ref->insert($values);
         }
         $this->flashMessage('Novinka uložena.');
     }
     $this->redirect('News:default');
 }
Example #25
0
File: list.php Project: hqd276/bigs
 function draw()
 {
     global $display;
     $type = (int) $_SESSION['type'];
     if ($type < 0) {
         $type = 0;
     }
     $cat_id = intval(Url::get('catid', 0));
     if ($cat_id != 0) {
         $where = ' AND category_id = ' . $cat_id;
     }
     $where .= ' AND type = ' . $type;
     $item_per_page = 5;
     $list_news = News::get_news($where, 0, $item_per_page);
     if (count($list_news > 0)) {
         foreach ($list_news as $key => $value) {
             // $list_news[$key]['title'] = Util::split_char($value['title'],40,-1) . ' ...';
             if ($value['uid'] > 0) {
                 $author = User::getUserById($value['uid']);
                 // var_dump($author);die;
                 if ($author['full_name'] == '') {
                     $list_news[$key]['author'] = $author['user_name'];
                 } else {
                     $list_news[$key]['author'] = $author['full_name'];
                 }
             }
         }
     }
     $display->add('list_news', $list_news);
     $display->add('cid', $cat_id);
     $display->add('uid', User::id());
     $display->output("List");
 }
Example #26
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     #if (Yii::app()->user->isGuest) {
     #    $this->render('index');
     #} else {
     #    if (Yii::app()->user->checkAccess('admin')) {
     #        $this->redirect(array('admin/index'));
     #    } else {
     #        $this->redirect(array('user/accountBalance', 'id'=>Yii::app()->user->_id));
     #    }
     #}
     $form = new SearchForm();
     // Use for Form
     $dataset = new Dataset();
     // Use for auto suggestion
     $datasetModel = $this->getDatasetByType(0);
     // Use for image slider content
     $publicIds = Yii::app()->db->createCommand()->select("id")->from("dataset")->where("upload_status = 'Published'")->queryAll();
     $datasettypes_hints = Type::model()->findAll(array('order' => 'name ASC'));
     $news = News::model()->findAll("start_date<=current_date AND end_date>=current_date");
     $criteria = new CDbCriteria();
     $criteria->limit = 10;
     $criteria->condition = "upload_status = 'Published'";
     #$criteria->order = "id DESC";
     $criteria->order = 'publication_date DESC';
     $latest_datasets = Dataset::model()->findAll($criteria);
     $criteria->condition = null;
     $criteria->order = 'publication_date DESC';
     $latest_messages = RssMessage::model()->findAll($criteria);
     $rss_arr = array_merge($latest_datasets, $latest_messages);
     $this->sortRssArray($rss_arr);
     $this->render('index', array('datasets' => $datasetModel, 'form' => $form, 'dataset' => $dataset, 'news' => $news, 'dataset_hint' => $datasettypes_hints, 'rss_arr' => $rss_arr, 'count' => count($publicIds), 'latest_datasets' => $latest_datasets));
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         News::create([]);
     }
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 100) as $index) {
         News::create(['title' => $faker->text(20 + $faker->numberBetween(10, 100)), 'content' => $faker->text(400 + $faker->numberBetween(10, 250)), 'image' => 'http://www.bumultimedia.com/trabajos/marcaDiferenciada/mansionMascotas/images/news_' . $faker->numberBetween(1, 5) . '.png', 'publish' => $faker->randomElement([1, 2])]);
     }
 }
Example #29
0
 public static function GetComments($ArticleID)
 {
     global $FCCore;
     $Statement = News::$CConnection->prepare('
         SELECT
             c.*,
             ch.race as poster_race,
             ch.class as poster_class,
             ch.gender as poster_gender
         FROM
             ' . $FCCore['Database']['database'] . '.comments c, characters ch
         WHERE
                 c.comment_by = ch.name
             AND
                 article_id = :articleid
             AND
                 replied_to IS NULL
         ORDER BY
           id
         DESC');
     $Statement->bindParam(':articleid', $ArticleID);
     $Statement->execute();
     $Result = $Statement->fetchAll(PDO::FETCH_ASSOC);
     $ArrayIndex = 0;
     foreach ($Result as $Comment) {
         $Result[$ArrayIndex]['nested_comments'] = News::GetNestedComments($Comment['article_id'], $Comment['id']);
         $ArrayIndex++;
     }
     return $Result;
 }
Example #30
0
 public function actionIndex()
 {
     $this->checkCookieEnabled();
     $this->htmlPageId = 'index';
     $page = Menu::model()->findByPk(InfoPages::MAIN_PAGE_ID);
     if (issetModule('seo')) {
         $seo = SeoFriendlyUrl::model()->findByAttributes(array('model_name' => 'InfoPages', 'model_id' => InfoPages::MAIN_PAGE_ID));
         if ($seo) {
             $this->setSeo($seo);
         }
     }
     $langs = Lang::getActiveLangs();
     $countLangs = count($langs);
     if (!isFree() && !isset($_GET['lang']) && ($countLangs > 1 || $countLangs == 1 && param('useLangPrefixIfOneLang'))) {
         $canonicalUrl = Yii::app()->getBaseUrl(true);
         $canonicalUrl .= '/' . Yii::app()->language;
         Yii::app()->clientScript->registerLinkTag('canonical', null, $canonicalUrl);
     }
     Yii::app()->user->setState('searchUrl', NULL);
     $lastNews = News::getLastNews();
     if (Yii::app()->request->isAjaxRequest) {
         //			$modeListShow = User::getModeListShow();
         //			if ($modeListShow == 'table') {
         //				# нужны скрипты и стили, поэтому processOutput установлен в true только для table
         //				$this->renderPartial('index', array('page' => $page, 'newsIndex' => $lastNews), false, true);
         //			}
         //			else {
         $this->renderPartial('index', array('page' => $page, 'newsIndex' => $lastNews));
         //			}
     } else {
         $this->render('index', array('page' => $page, 'newsIndex' => $lastNews));
     }
 }