public function executeLastPoliticoRadicali() { $id = $this->getRequestParameter('id'); $politico = OppPoliticoPeer::retrieveByPk($id); $this->forward404Unless($politico instanceof OppPolitico); $c = oppNewsPeer::getNewsForItemCriteria('OppPolitico', $id); $c->addDescendingOrderByColumn(NewsPeer::DATE); $c->add(NewsPeer::GENERATOR_PRIMARY_KEYS, null, Criteria::ISNOTNULL); $c->setLimit(30); $news = oppNewsPeer::doSelect($c); $feed = $this->_make_feed_from_news('Ultime per ' . $politico, '@parlamentare?id=' . $id . '&slug=' . Util::slugify($politico), $news, 2); $this->_send_output($feed); return sfView::NONE; }
public function executeAct() { $this->act_id = $this->getRequestParameter('id'); $this->act = OppAttoPeer::retrieveByPK($this->act_id); $this->n_news = oppNewsPeer::countNewsForItem('OppAtto', $this->act_id); $this->getResponse()->setTitle('tutte le notizie su ' . $this->act->getOppTipoAtto()->getDescrizione() . ' ' . Text::denominazioneAttoShort($this->act) . ' - ' . sfConfig::get('app_main_title')); $this->response->addMeta('description', 'Tutte le notizie aggiornate quotidianamente su presentazione e iter ' . $this->act->getOppTipoAtto()->getDescrizione() . ' ' . Text::denominazioneAttoShort($this->act), true); $c = oppNewsPeer::getNewsForItemCriteria('OppAtto', $this->act_id); $c->addDescendingOrderByColumn(NewsPeer::DATE); if ($this->hasRequestParameter('itemsperpage')) { $this->getUser()->setAttribute('itemsperpage', $this->getRequestParameter('itemsperpage')); } $itemsperpage = $this->getUser()->getAttribute('itemsperpage', sfConfig::get('app_pagination_limit')); $pager = new deppNewsPager('News', $itemsperpage); $pager->setCriteria($c); $pager->setPage($this->getRequestParameter('page', 1)); $pager->init(); $this->pager = $pager; }
private function _fetchNewsForItem($item_model, $item_id) { $n_news = oppNewsPeer::countNewsForItem($item_model, $item_id); $c = oppNewsPeer::getNewsForItemCriteria($item_model, $item_id); $c->addDescendingOrderByColumn(NewsPeer::DATE); $c->setLimit(sfConfig::get('app_news_dropdown_limit', 10)); $news = oppNewsPeer::doSelect($c); $grouped_news = array(); foreach ($news as $n) { $date = strtotime($n->getDate()); if ((is_string($date) || is_integer($date)) && !array_key_exists($date, $grouped_news)) { $grouped_news[$date] = array(); } else { $grouped_news['nessuna data'] = array(); } $grouped_news[$date][] = $n; } krsort($grouped_news); $this->grouped_news = $grouped_news; $this->has_more = 0; if ($n_news > count($news)) { $this->has_more = $n_news; } }