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'); }
/** * 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; }
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); } }
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>"; }
/** * 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); */ }
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>"; }
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'); }
/** * 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); }
<?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);
$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 **/
/** * @expectedException InvalidArgumentException */ public function testGetMethodException() { $stub = $this->getMockBuilder('BaseModel')->disableOriginalConstructor()->getMock(); News::get($stub); }
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);
/** * 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); } }
/** * @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; }
<?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);
/** * Get all the items from a single newsholderPage. * @param $limit integer with chosen limit. Called from template via <% loop $NewsArchiveByHolderID(321,5) %> for the page with ID 321 and 5 latest items. * @todo many things, isn't finished * @fixed I refactored a bit. Only makes for a smaller function. * @author Marcio Barrientos */ public function NewsArchiveByHolderID($holderID = null, $limit = 5) { $filter = array('Live' => 1, 'NewsHolderPageID' => $holderID); if ($limit == 0) { $limit = null; } if (class_exists('Translatable')) { $filter['Locale'] = Translatable::get_current_locale(); } $exclude = array('PublishFrom:GreaterThan' => SS_Datetime::now()->Rfc2822()); $news = News::get()->filter($filter)->exclude($exclude)->limit($limit); if ($news->count() == 0) { return null; } return $news; }
<?php //$SQL='select COUNT(*) as rowCount from news02news where news02uin>0 '; ///$data=Query($SQL); //$page='News'; //$objCat= new NewsType(); $prefix = 'news02'; $obj = new News(); $list = $obj->get($prefix . 'hits>0 and ' . $prefix . 'date between DATE_ADD(NOW(), INTERVAL -30 DAY) AND NOW() ', $prefix . 'hits desc', 100, 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);
/** * @param News $otherNews * @param int $limit * @param bool|string $sort * @param bool $related * @param array $params * * @return DataList|null|SS_Limitable */ private function getArchiveItems($otherNews, $limit, $sort, $related, $params) { $filter = array('Live' => 1); if (class_exists('Translatable')) { $filter['Locale'] = Translatable::get_current_locale(); } $exclude = array('PublishFrom:GreaterThan' => SS_Datetime::now()->Rfc2822()); if ($related && $params['Action'] === 'show') { // @todo This only works with the default action, not allowed actions $filter = array_merge($filter, array('Tags.ID:ExactMatch' => $otherNews->Tags()->column('ID'))); $exclude = array_merge($exclude, array('ID' => $otherNews->ID)); } if ($sort) { $sort = 'RAND()'; } /** @var DataList||News[] $news */ $news = News::get()->filter($filter)->exclude($exclude)->sort($sort)->limit($limit); return $news; }
/** * test whether the URLSegment exists already on another Newsitem * @param string $URLSegment chosen URLSegment * @return boolean URLSegment already exists yes or no. */ private function LookForExistingURLSegment($URLSegment) { return News::get()->filter(array("URLSegment" => $URLSegment))->exclude(array("ID" => $this->ID))->count() != 0; }
public function searchCommentByUser($nickname) { return ($result = parent::get("SELECT * FROM {$this->prefix}commenti WHERE autore='{$nickname}' AND approvato='1'")) ? $result : false; }
<?php //var_dump( get_browser()); $id = 24; //$id=getREQUEST('_Id'); $objCat = new NewsType(); $obj = new News(); $list = $obj->get(array('highlight' => 1)); $data['title'] = 'प्रमुख समाचार'; $data['id'] = $id; $data['data'] = $list; $data['tot_page'] = ceil(count($list) / NEWS_PER_PAGE); //var_dump($data); //echo $list->rowCount(); if (isset($strModuleName)) { echo defaultModule($strModuleName, $data); } ?>
$prefix = 'news02'; $page = $_GET['page']; $per = $_GET['per']; $where = ''; if ($_GET['where'] != '') { if ($_GET['where'] == 'POPULAR') { $where = $prefix . 'hits>0 and ' . $prefix . 'date between DATE_ADD(NOW(), INTERVAL -30 DAY) AND NOW()'; $order = $prefix . 'hits desc'; } else { $where = $prefix . $_GET['where']; } } //echo $where;die(); //echo $page; $objNews = new News(); $_data = $objNews->get($where, $order, $per, $page); //var_dump($_data);die(); $uploadUrl = UPLOADS . $objNews->getUploadURL() . 'thumb/'; foreach ($_data as $row) { ?> <div class="news-items clearfix"> <?php echo LoadMyImage($uploadUrl, $row[$prefix . 'file'], $row[$prefix . 'title'], 'img-responsive'); ?> <div class="shadow"> <h5><a href="<?php echo getSiteLink('NewsArticle', '', $row[$prefix . 'title'], $row[$prefix . 'uin']); ?> "> <?php
/** * @return mixed */ public function lists() { return $this->news->get()->where('lang', $this->getLang())->lists('title', 'id'); }
private $logging; public function __construct() { parent::__construct('neo'); $this->logging = new Logging('/tmp/news.log'); } public function __destruct() { $this->logging->debug('news->get permission denied!!!'); $this->logging->close(); } public function add() { if (!$this->is_allowed(__CLASS__, __FUNCTION__)) { return; } print "Allowed!!! \r\n"; $this->logging->info('news->add ok'); } public function get() { if ($this->is_denied(__CLASS__, __FUNCTION__)) { print "Denied!!! \r\n"; $this->logging->warning('news->get permission denied!!!'); } } } $news = new News(); $news->add(); $news->get();
public function getNews() { $news = News::get()->filter(array('ShowInWidget' => 1)); return $news; }
public function getNewsToActivate() { $now = gmdate("Y-m-d H:i:s"); $activate_articles = News::get('News')->where("DateEmbargo < '{$now}' AND (DateExpire > '{$now}' OR DateExpire IS NULL) AND Approved = 0 AND Archived = 0 AND Deleted = 0")->toArray(); return $activate_articles; }