本文整理汇总了PHP中news类的典型用法代码示例。如果您正苦于以下问题:PHP news类的具体用法?PHP news怎么用?PHP news使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了news类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index($arguments)
{
$news = new news(ConnectionFactory::get('mongo'));
$articles = new articles(ConnectionFactory::get('mongo'));
$notices = new notices(ConnectionFactory::get('redis'));
$irc = new irc(ConnectionFactory::get('redis'));
$quotes = new quotes(ConnectionFactory::get('mongo'));
$forums = new forums(ConnectionFactory::get('redis'));
// Set all site-wide notices.
foreach ($notices->getAll() as $notice) {
Error::set($notice, true);
}
// Fetch the easy data.
$this->view['news'] = $news->getNewPosts();
$this->view['shortNews'] = $news->getNewPosts(true);
$this->view['newArticles'] = $articles->getNewPosts('new', 1, 5);
$this->view['ircOnline'] = $irc->getOnline();
$this->view['randomQuote'] = $quotes->getRandom();
$this->view['fPosts'] = $forums->getNew();
// Get online users.
$apc = new APCIterator('user', '/' . Cache::PREFIX . 'user_.*/');
$this->view['onlineUsers'] = array();
while ($apc->valid()) {
$current = $apc->current();
array_push($this->view['onlineUsers'], substr($current['key'], strlen(Cache::PREFIX) + 5));
$apc->next();
}
// Set title.
Layout::set('title', 'Home');
}
示例2: displayNews
/**
* @package pragyan
* @copyright (c) 2008 Pragyan Team
* @license http://www.gnu.org/licenses/ GNU Public License
* For more details, see README
*/
function displayNews()
{
$news = <<<NEWS
\t\t<style type="text/css">
\t\ta.tickl{font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px;line-height:12px;text-decoration:none;color:#fff;font-weight:bold;}
\t\t.tickls{color:#666;}
\t\t</style>
\t\t<div id="newsbox" style="font-size:0.9em;position:absolute;right:45px;width:375px;top:80px;color:#fff;z-index:2;">
\t\t<div class="ticki" >
\t\t<a class="tickl" href="/08/home/news/"><span class="tickls">UPDATES</span></a>
\t\t<a id="tickerAnchor" class="tickl" target="_top" href=""></a>
\t\t</div>
\t\t</div>
\t\t<script type="text/javascript" language="JavaScript">
\t\t <!--
\t\t var theCharacterTimeout = 50;
\t\t var theStoryTimeout = 5000;
\t\t var theWidgetOne = "_";
\t\t var theWidgetTwo = "-";
\t\t var theWidgetNone = "";
\t\t var theLeadString = ": ";
\t\t var theSummaries = new Array();
\t\t var theSiteLinks = new Array();
NEWS;
global $sourceFolder;
global $moduleFolder;
global $urlRequestRoot;
global $pageIdArray;
require_once "{$sourceFolder}/{$moduleFolder}/news.lib.php";
$tmpNewsObj = new news();
$pageFullPath = "/news/";
///<Replace with path of news page
$pageId = parseUrlReal($pageFullPath, $pageIdArray);
$pageInfo = getPageInfo($pageId);
$newsArray = $tmpNewsObj->getNewsArray($pageInfo['page_modulecomponentid']);
$news .= "var theItemCount =" . sizeof($newsArray) . ";";
for ($i = 0; $i < sizeof($newsArray); $i++) {
$newsFeed = $newsArray[$i]['news_title'];
$newsFeed .= " - " . $newsArray[$i]['news_feed'];
$newsLink = $newsArray[$i]['news_link'];
// displayerror()
if (strlen($newsFeed) >= 48) {
$newsFeed = substr($newsFeed, 0, 48);
$newsFeed = substr($newsFeed, 0, strrpos($newsFeed, " "));
$newsFeed .= "...";
}
$news .= "theSummaries[{$i}] = \"{$newsFeed}\";";
if ($newsLink == "") {
$newsLink = $urlRequestRoot . $pageFullPath . "&id=" . $newsArray[$i]['news_id'];
}
$news .= "theSiteLinks[{$i}] = \"{$newsLink}\";";
}
$news .= <<<NEWS
\t\t startTicker();
\t\t //-->
\t\t</script>
NEWS;
return $news;
}
示例3: index
public function index($arguments)
{
Layout::set('title', 'Search');
if (empty($_POST['query'])) {
return Error::set('No search query found.');
}
$query = substr(trim(htmlentities($_POST['query'], ENT_QUOTES, 'ISO8859-1', false)), 0, 250);
$results = Search::query($query);
if ($results['hits']['total'] == 0) {
return Error::set('No results found.');
}
$this->view['results'] = array();
$news = new news(ConnectionFactory::get('mongo'));
$articles = new articles(ConnectionFactory::get('mongo'));
$lectures = new lectures(ConnectionFactory::get('mongo'));
$i = 1;
if (empty($results['hits']['hits'])) {
return;
}
foreach ($results['hits']['hits'] as $result) {
$entry = $result['_source'];
switch ($entry['type']) {
case 'news':
$post = $news->get($result['_id'], false, true);
if (empty($post)) {
continue;
}
$post['type'] = 'news';
array_push($this->view['results'], $post);
break;
case 'article':
$article = $articles->get($result['_id'], false, true);
if (empty($article)) {
continue;
}
$article['type'] = 'article';
array_push($this->view['results'], $article);
break;
case 'lecture':
$lecture = $lectures->get($result['_id'], false, true);
if (empty($lecture)) {
continue;
}
$lecture['type'] = 'lecture';
array_push($this->view['results'], $lecture);
break;
}
if ($i == 5) {
break;
}
++$i;
}
}
示例4: load
public function load(ObjectManager $manager)
{
$information = new Information();
$information->setTitle("About Me");
$information->setBody("<p>Rofilde Hasudungan research are in DNA based Computer</p>");
$information->setPublished(true);
$manager->persist($information);
$news = new news();
$news->setTitle("About Me");
$news->setBody("<p>Rofilde Hasudungan research are in DNA based Computer</p>");
$news->setPublished(true);
$manager->persist($news);
$manager->flush();
}
示例5:
if ($mode == 'own') {
$where = 'news.author=' . $_SESSION['userid'];
}
$query = 'news.id,
news.active,
news.start,
news.end,
news.author,
person.first_name as author_first_name,
person.last_name as author_last_name,
news.topic,
news.text
from news
join person on
示例6: pageNews
public function pageNews()
{
$lang = services::getService('lang');
$params = services::getService('pageParams');
$this->page();
$this->setTemplate('news.tpl');
// newsscript: show news headlines
$shownews = new news();
$shownews->id = $params->getParam('news_id');
$shownews->find(true);
$this->shownews = array('name' => $shownews->name, 'abstract' => $shownews->abstract, 'text' => $shownews->text, 'date' => date('d. m. Y', $shownews->date), 'id' => $shownews->id);
// output
$this->assignAll();
$this->display();
}
示例7: actionGetArticle
public function actionGetArticle($view)
{
$article_id = (int) $_GET['article'];
$article = news::getArticle($article_id);
$view->article = $article;
echo $view->render('article.php');
}
示例8: vote
public function vote($arguments)
{
if (!CheckAcl::can('voteOnNews')) {
return Error::set('You can not vote on news posts.');
}
if (empty($arguments[0]) || empty($arguments[1])) {
return Error::set('Vote or news id not found.');
}
$news = new news(ConnectionFactory::get('mongo'));
$result = $news->castVote($arguments[0], $arguments[1]);
$post = $news->get($arguments[0], false, true);
if (is_string($result)) {
return Error::set($result, false, array('Back' => Url::format('/news/view/' . Id::create($post, 'news'))));
}
Error::set('Vote cast!', true, array('Back' => Url::format('/news/view/' . Id::create($post, 'news'))));
}
示例9: actionAll
public function actionAll()
{
$news = news::getAll();
$view = new view();
$view->items = $news;
$view->display('news/all.php');
}
示例10: get_cha
function get_cha()
{
if ($_GET['module'] == 'news') {
if (intval($_GET['cha']) > 0) {
return intval($_GET['cha']);
} elseif (intval($_GET['cat']) > 0) {
$cat = new category_news();
$row = $cat->detail($_GET['cat']);
return $row['cha_id'];
} elseif (intval($_GET['id']) > 0) {
$news = new news();
$row = $news->detail('cha_id', $_GET['id']);
return $row['cha_id'];
}
} else {
return 0;
}
}
示例11: displayNew
function displayNew()
{
global $sourceFolder;
global $moduleFolder;
global $urlRequestRoot;
global $pageIdArray;
require_once "{$sourceFolder}/{$moduleFolder}/news.lib.php";
$tmpNewsObj = new news();
$pageFullPath = "/whatsnew/";
///<Replace with path of news page
$pageId = parseUrlReal($pageFullPath, $pageIdArray);
$pageInfo = getPageInfo($pageId);
$newsArray = $tmpNewsObj->getNewsArray($pageInfo['page_modulecomponentid']);
$newsFeed = '';
for ($i = 0; $i < sizeof($newsArray); $i++) {
$newsTitle = str_replace("'", "'", $newsArray[$i]['news_title']);
$newsBody = str_replace("'", "'", $newsArray[$i]['news_feed']);
$newsTitle = rtrim($newsTitle);
$newsBody = rtrim($newsBody);
$days = 20;
// if(time()<(strtotime($newsArray[$i]['news_date'])+($days*24*60*60))) {
// $newsBody .= '<font color="#f9dc72"><strong> NEW!</strong></font>';
// }
if ($newsArray[$i]['news_link'] == '') {
$newsFeed .= '\'<a href=/09/home/whatsnew>' . $newsTitle . ' ' . $newsBody . '</a>\',';
} else {
$newsFeed .= '\'<a href=' . $newsArray[$i]['news_link'] . '>' . $newsTitle . ' ' . $newsBody . '</a>\',';
}
}
$newsFeed = rtrim($newsFeed, ',');
/**
if (strlen($newsFeed) >= 48) {
$newsFeed = substr($newsFeed, 0, 48);
$newsFeed = substr($newsFeed, 0, strrpos($newsFeed, " "));
$newsFeed .= "...";
}
*/
$news = <<<NEWS
<script>
var pausecontent2=new Array({$newsFeed})
</script>
NEWS;
return $news;
}
示例12: load
public static function load($view_rep, $view_file)
{
if (tg('_tsk') == 'news') {
$instance = new news();
$array = $instance->index();
}
if (isset($array)) {
$titre = lg('TITR') . ' | ' . $array['titre'];
$content = htmlentities($array['titre']);
$image = "http://{$_SERVER['HTTP_HOST']}" . criimg_link('upload/news/' . $array['img'], 200, 200, 'PNG');
$actual_link = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
} else {
$titre = lg('TITR');
$content = 'Site Internet Officiel de la présidence de la République du Tchad.';
$image = './img/header.jpg';
$actual_link = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
}
include_once AFFICH_REP . 'layout/header.php';
include_once AFFICH_REP . 'layout/limen.php';
include_once AFFICH_REP . $view_rep . SLASH . $view_file . '_v.php';
}
示例13: displayNews2
/**
* @package pragyan
* @copyright (c) 2008 Pragyan Team
* @license http://www.gnu.org/licenses/ GNU Public License
* For more details, see README
*/
function displayNews2()
{
global $sourceFolder;
global $moduleFolder;
global $urlRequestRoot;
global $pageIdArray;
require_once "{$sourceFolder}/{$moduleFolder}/news.lib.php";
$tmpNewsObj = new news();
$pageFullPath = "/news/";
///<Replace with path of news page
$pageId = parseUrlReal($pageFullPath, $pageIdArray);
$pageInfo = getPageInfo($pageId);
$newsArray = $tmpNewsObj->getNewsArray(0);
for ($i = 0; $i < sizeof($newsArray); $i++) {
$divopen = "<div class=\"news_style\" rel=\"{$newsArray[$i]}[news_title]\" id=\"news{$i}\">";
$heading = "<h4>{$newsArray[$i]}[news_title]</h4>";
$content = "{$newsArray[$i]}[news_feed]";
$divclose = "</div>";
$fulldiv = $divopen . $heading . $content . $divclose;
echo $fulldiv;
}
return 1;
}
示例14: array_slice
}
$smarty->assign("T_FORUM_OPTIONS", $forum_options);
//Assign forum options to smarty
/*Lesson announcements list*/
if (!isset($currentUser->coreAccess['news']) || $currentUser->coreAccess['news'] != 'hidden') {
if (!empty($lessons_list)) {
if ($currentUser->getType() == "student") {
//See only non-expired news
$news = news::getNews(0, true) + news::getNews($lessons_list, true);
} else {
//See both expired and non-expired news
$news = news::getNews(0, true) + news::getNews($lessons_list, false);
}
} else {
//Administrator news, he doesn't have to see lesson news (since he can't actually access them)
$news = news::getNews(0, true);
}
$news = array_slice($news, 0, 10, true);
$smarty->assign("T_NEWS", $news);
//Assign announcements to smarty
}
/*Comments list*/
if (!empty($lessons_list)) {
$comments = eF_getTableData("comments cm JOIN content c JOIN lessons l ON c.lessons_ID = l.id", "cm.id AS id, cm.data AS data, cm.users_LOGIN AS users_LOGIN, cm.timestamp AS timestamp, c.name AS content_name, c.id AS content_ID, c.ctg_type AS content_type, l.name as show_lessons_name, l.id as show_lessons_id", "c.lessons_ID IN ('" . implode("','", $lessons_list) . "') AND cm.content_ID=c.id AND c.active=1 AND cm.active=1 AND cm.private=0", "cm.timestamp DESC LIMIT 5");
if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) {
//this applies to supervisors only
$currentBranch = new EfrontBranch($_SESSION['s_current_branch']);
$branchTreeUsers = array_keys($currentBranch->getBranchTreeUsers());
foreach ($comments as $key => $value) {
if (!in_array($value['users_LOGIN'], $branchTreeUsers)) {
unset($comments[$key]);
示例15: intval
if ($action == 'all' || $action == 'cat') {
$sub_action = intval(varset($tmp[1], 0));
}
if ($action == 'extend' && empty($sub_action)) {
$defaultUrl = e107::getUrl()->create('news/list/items');
e107::getRedirect()->go($defaultUrl, null, 301);
exit;
}
/*
Variables Used:
$action - the basic display format/filter
$sub_action - category number or news item number
$newsfrom - first item number in list (default 0) - derived from nextprev
$order - sets the listing order for 'list' format
*/
$ix = new news();
$nobody_regexp = "'(^|,)(" . str_replace(",", "|", e_UC_NOBODY) . ")(,|\$)'";
// URL settings (nextprev)
$newsUrlparms = array('page' => '--FROM--');
if ($sub_action) {
switch ($action) {
case 'list':
$newsUrlparms['id'] = $sub_action;
$newsRoute = 'list/category';
break;
case 'cat':
$newsUrlparms['id'] = $sub_action;
$newsRoute = 'list/short';
break;
case 'day':
case 'month':