本文整理汇总了PHP中News::get方法的典型用法代码示例。如果您正苦于以下问题:PHP News::get方法的具体用法?PHP News::get怎么用?PHP News::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类News
的用法示例。
在下文中一共展示了News::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: form
public function form()
{
$this->views = new Views(new Template("admin"));
Phalanx::loadClasses('News');
$this->views->data = News::get($this->get->id);
$this->views->display('news_form.phtml');
}
示例2: sourceRecords
/**
* Setup the list of records to show.
*
* @param array $params array of filter-rules.
* @param array $sort
* @param integer $limit
*
* @return ArrayList with the records.
*/
public function sourceRecords($params, $sort, $limit)
{
if ($sort) {
$parts = explode(' ', $sort);
$field = $parts[0];
$direction = $parts[1];
}
$filter = array('Comments.ID:GreaterThan' => 0);
if (count($params) > 0 && isset($params['Title'])) {
$filter['News.Title:PartialMatch'] = $params['Title'];
}
/** @var ArrayList|News[] $ret */
$ret = News::get()->filter($filter);
/** @var ArrayList $returnSet */
$returnSet = ArrayList::create();
if ($ret) {
foreach ($ret as $record) {
$record->Commentcount = $record->Comments()->count();
$record->Spamcount = $record->Comments()->filter(array('AkismetMarked' => 1))->count();
$record->Hiddencount = $record->Comments()->filter(array('AkismetMarked' => 0, 'Visible' => 0))->count();
if (isset($params['Comment']) && $params['Comment'] == 'SPAMCOUNT' && $record->Spamcount > 0) {
$returnSet->push($record);
} elseif (isset($params['Comment']) && $params['Comment'] == 'HIDDENCOUNT' && $record->Hiddencount > 0) {
$returnSet->push($record);
} elseif (isset($params['Comment']) && $params['Comment'] == '' || !isset($params['Comment'])) {
$returnSet->push($record);
}
}
}
return $returnSet;
}
示例3: get_index
public function get_index()
{
// $news = News::where('status','=',0)->get();
$news = News::get();
if (is_null($news)) {
return json_encode('News not found', 404);
} else {
return json_encode($news);
}
}
示例4: up
function up()
{
echo "Starting Migration Proc ...<BR>";
//check if migration already had ran ...
$migration = DataObject::get_one("Migration", "Name='{$this->title}'");
if (!$migration) {
$result = News::get();
foreach ($result as $news) {
$news->SummaryHtmlFree = strip_tags($news->Summary);
$news->BodyHtmlFree = strip_tags($news->Body);
$news->Write();
}
}
echo "Ending Migration Proc ...<BR>";
}
示例5: testItemPublished
/**
* Check if only the items with a date in the past AND Live items are there.
* Since all items are linked to page1, we only check if page1 has them all indeed.
* And the children should only be the published or in the past, thus there should be 2 excluded at first run.
*
* The future-published-test fails because mock_now doesn't work as expected?!
*/
public function testItemPublished()
{
$member = Member::currentUser();
if ($member) {
$member->logout();
}
$page1 = $this->objFromFixture('NewsHolderPage', 'page1');
$allItems = News::get();
$this->assertEquals($allItems->count(), 7, 'Total items');
$this->assertEquals($page1->Newsitems()->count(), 7, 'Total items available');
$this->assertEquals($page1->Children()->count(), 5, 'Amount of visible items');
/*
SS_Datetime::set_mock_now("2020-01-01");
$this->assertEquals($page1->Children()->count(), 6);
*/
}
示例6: up
function up()
{
echo "Starting Migration Proc ...<BR>";
//check if migration already had ran ...
$migration = DataObject::get_one("Migration", "Name='{$this->title}'");
if (!$migration) {
$result = News::get();
foreach ($result as $news) {
if (empty($news->DateEmbargo)) {
$news->DateEmbargo = $news->Date;
}
$news->Write();
}
$migration = new Migration();
$migration->Name = $this->title;
$migration->Description = $this->description;
$migration->Write();
}
echo "Ending Migration Proc ...<BR>";
}
示例7: sitemap
public function sitemap()
{
$sitemap = App::make("sitemap");
// set item's url, date, priority, freq
$sitemap->add(Request::root(), '2012-08-25T20:10:00+02:00', '1.0', 'daily');
$sitemap->add(Request::root() . "/marketing", '2013-08-20T20:20:00+02:00', '1.0', 'monthly');
$sitemap->add(Request::root() . "/puskice", '2013-08-20T20:20:00+02:00', '1.0', 'monthly');
if (Cache::has('posts_query')) {
$posts = Cache::get('posts_query');
} else {
$posts = News::get();
Cache::put('posts_query', $posts, 10080);
}
foreach ($posts as $post) {
if ($post->post_type == 1) {
$sitemap->add(Request::root() . "/vest/" . Puskice::dateToUrl($post->created_at) . "/" . $post->permalink, $post->updated_at, '1.0', 'daily');
}
if ($post->post_type == 2) {
$sitemap->add(Request::root() . "/stranica/" . $post->permalink, $post->updated_at, '1.0', 'daily');
}
if ($post->post_type == 3) {
$subject = Subject::where('news_id', '=', $post->id)->first();
if ($subject != null) {
$sitemap->add(Request::root() . "/" . Puskice::getYear($subject->semester) . "/" . Puskice::getDepartment($subject->department) . "/" . $post->permalink, $post->updated_at, '1.0', 'monthly');
} else {
Log::info('Predmet za vest: ' . $post->id . ' nije definisan');
}
}
}
if (Cache::has('meme_query')) {
$memes = Cache::get('meme_query');
} else {
$memes = MemeInstance::get();
Cache::put('meme_query', $memes, 10080);
}
foreach ($memes as $meme) {
$sitemap->add(Request::root() . "/meme/" . $meme->id . "-" . $meme->permalink, $meme->updated_at, '1.0', 'daily');
}
// show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf')
return $sitemap->render('xml');
}
示例8: __construct
/**
* Setup the Commenting-form for posting comments
* @param Controller $controller The current controller
* @param String $name Name of the field
* @param SiteConfig $siteconfig Current active SiteConfig
* @param array $params Current URL Parameters
*/
public function __construct($controller, $name, $siteconfig, $params)
{
$fields = singleton('Comment')->getFrontendFields();
/** Include the ID of the current item. Otherwise we can't link correctly. */
$NewsID = Controller::curr()->request->postVar('NewsID');
if ($NewsID == null) {
$newsItem = News::get()->filter(array('URLSegment' => $params['ID']))->first();
$fields->push(HiddenField::create('NewsID', '', $newsItem->ID));
}
/** Check the Readme.MD for details about extra spam-protection */
if ($siteconfig->ExtraSecurity) {
$fields->push(TextField::create('Extra', _t('CommentForm.EXTRA', 'Extra')));
}
if ($siteconfig->NoscriptSecurity) {
$fields->push(LiteralField::create('noscript', '<noscript><input type="hidden" value="1" name="nsas" /></noscript>'));
}
$actions = FieldList::create(FormAction::create('CommentStore', 'Send'));
$required_fields = array('Name', 'Title', 'Email', 'Comment');
$validator = RequiredFields::create($required_fields);
parent::__construct($controller, $name, $fields, $actions, $validator);
}
示例9: defaultModule
<?php
//$SQL='select COUNT(*) as rowCount from news02news where news02uin>0 ';
///$data=Query($SQL);
//$page='News';
//$objCat= new NewsType();
$obj = new News();
$list = $obj->get();
//echo ($list->rowCount());
//var_dump($list);
//$Cat=$objCat->getById($id);
$data['title'] = "ताजा खबर";
$data['data'] = $list;
$data['tot_page'] = ceil($list->rowCount() / NEWS_PER_PAGE);
//echo $list->rowCount();
echo defaultModule($strModuleName, $data);
示例10: getREQUEST
$id = 0;
$Type = getREQUEST('Type');
$message = '';
$data['message'] = '';
if (!$Type) {
forceRedirect('home.php');
}
$obj = new News();
$objCat = new NewsType();
$newsType = $objCat->getById($Type);
$data['module_Title'] = $newsType['news01title'];
if (isset($_GET['_Id'])) {
$id = $_GET['_Id'];
$data['_data'] = $obj->getByID($id);
} else {
$data['_data'] = $obj->get(array('news01uin' => $Type));
$data['list_fields'] = $obj->getListField();
}
//$data['_extraModule'] = array(array('Commitments', 'Commit&action=Commitlist'));
$data['prefix'] = $obj->getPrefix();
$field_list = $obj->getUpdateFields();
$_data = $obj->getByID($id);
//$data['obj']=$obj;
$data['lists'] = $obj->getListField();
$upload_dir = UPLOADS_DIR . $obj->getUploadURL();
$data['upload_dir'] = $upload_dir;
$data['uploadUrl'] = '../uploads/' . $obj->getUploadURL();
/***************** END of these fields are required ************************************/
/**
* $fields_post :: This list is the list of all fields which are affected while inserting in database
**/
示例11: testGetMethodException
/**
* @expectedException InvalidArgumentException
*/
public function testGetMethodException()
{
$stub = $this->getMockBuilder('BaseModel')->disableOriginalConstructor()->getMock();
News::get($stub);
}
示例12: defaultModule
if ($menuItem[$MenuPrefix . 'hasChild'] == 1) {
echo '<span class="caret"></span>';
}
}
echo '</a>';
//$objSub= new NewsType();
if ($menuItem[$MenuPrefix . 'hasChild']) {
$datasubMenu = $ObjMenu->getByParent($menuItem[$MenuPrefix . 'uin']);
if (count($datasubMenu) > 0) {
//echo $menuItem[$MenuPrefix.'uin'].' '.$menuItem[$MenuPrefix.'module'];
BuildMenu($menuItem[$MenuPrefix . 'uin'], $menuItem[$MenuPrefix . 'module']);
}
}
echo '</li>';
}
echo '</ul>';
//return $menu;
}
$objNews = new News();
$scrolling = $objNews->get(array('scrolling' => 1), '', 5, 1);
/*include_once(ADMIN_MODULE.'modules/nepali_calendar.php');
$myCalendar= new Nepali_Calendar();
$date = date('d-m-Y');
$d=explode('-',$date);
$cdate=$myCalendar->eng_to_nep($d[2],$d[1],$d[0]);
$nepaliDate=$cdate['day'].' '.$cdate['nmonth'].' '.$cdate['date'].' , '.$cdate['year'];
$date=date('l jS F Y');*/
$data['prefix'] = 'news02';
//$data['NepaliDate']=$nepaliDate;
$data['scrolling_data'] = $scrolling;
echo defaultModule($strModuleName, $data);
示例13: needsRedirect
/**
* This feature is cleaner for redirection.
* Saves requests to the database if I'm not mistaken.
* @return $this|null redirect to either the correct page/object or do nothing (In that case, the item exists and we're gonna show it lateron).
*/
private function needsRedirect()
{
/** @var int|string $id */
$id = $this->getRequest()->param('ID');
/** @var string $action */
$action = $this->getRequest()->param('Action');
/** @var array $handlers */
$handlers = self::$url_handlers;
if (isset($handlers[$action]) && $handlers[$action] == 'show' && !($news = $this->getNews())) {
if ($id && is_numeric($id)) {
/** @var News $redirect */
$redirect = $this->Newsitems()->byId($id);
$this->redirect($redirect->Link(), 301);
} else {
/** @var Renamed $renamed */
$renamed = Renamed::get()->filter(array('OldLink' => $id));
if ($renamed->count() > 0) {
$this->redirect($renamed->First()->News()->Link(), 301);
} else {
$this->redirect($this->Link(), 404);
}
}
} elseif ($action === 'latest') {
/** @var News $item */
$item = News::get()->filter(array('Live' => true))->first();
$this->redirect($item->Link(), 302);
}
}
示例14: getStandByNews
/**
* @return INews[]
*/
public function getStandByNews()
{
$where_string = "Featured = 0 AND Slider = 0 AND Approved = 0 AND Archived = 0 AND Deleted = 0";
$list = News::get()->where($where_string)->sort('Created', 'DESC')->limit(1000)->toArray();
return $list;
}
示例15: defaultModule
<?php
//$SQL='select COUNT(*) as rowCount from news02news where news02uin>0 ';
///$data=Query($SQL);
//$page='News';
//$objCat= new NewsType();
$obj = new News();
$list = $obj->get(array('highlight' => 1), '', 1000, 1);
//$list=$obj->get(array('headline'=>1));
//echo ($list->rowCount());
//var_dump($list);
//$Cat=$objCat->getById($id);
$data['title'] = "प्रमुख समाचार ";
//var_dump($list);
$data['tot_page'] = ceil($list->rowCount() / NEWS_PER_PAGE);
//$data['data']=$list;
//echo $list->rowCount();
echo defaultModule($strModuleName, $data);