本文整理汇总了PHP中News类的典型用法代码示例。如果您正苦于以下问题:PHP News类的具体用法?PHP News怎么用?PHP News使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了News类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetContent
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);
}
示例2: loadNewsList
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;
}
}
示例3: admin_news_create
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();
}
示例4: load
/**
* 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;
}
}
示例5: go
/**
* 新闻列表
*
* @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));
}
}
}
示例6: news_show
function news_show()
{
global $news_show;
$news = new News();
$news_show = $news->find($_GET['id']);
render();
}
示例7: getContent
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);
}
示例8: actionAddRandomNews
public function actionAddRandomNews()
{
$news = new News();
$news->title = "Item #" . rand(1, 10000);
$news->created_on = time();
$news->save();
echo "OK";
}
示例9: save
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');
}
}
示例10: addNew
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();
}
示例11: update
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();
}
示例12: actionAdd
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');
}
示例13: get_news
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;
}
示例14: articleForm
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;
}
示例15: DeleteNews
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');
}
}