public function RecentEvents($limit = null, $filter = null, $announcement_filter = null) { $start_date = new sfDate(); $end_date = $start_date; $events = $this->Events($filter, $start_date->subtractMonth(Calendar::$defaultFutureMonths), $end_date->yesterday(), true, $limit === null ? $this->DefaultEventDisplay : $limit, $announcement_filter); $events->sort('StartDate', 'DESC'); return $events; }
protected function getNavigationOptions() { $options = new DataObjectSet(); $counter = new sfDate($this->start_date->get()); $counter->subtractMonth(6); for ($i = 0; $i < 12; $i++) { $options->push(new ArrayData(array('Link' => $this->ShowMonthLink($counter->format('Ym')), 'Selected' => $this->start_date->format('Ym') == $counter->format('Ym') ? 'selected="selected"' : '', 'Month' => CalendarUtil::i18n_date('%B, %Y', $counter->get())))); $counter->addMonth(); } unset($counter); return $options; }
$t = new lime_test(9, new lime_output_color()); $dispatcher = new sfEventDispatcher(); $request = new sfWebRequest($dispatcher); $guard_user = Doctrine::getTable('sfGuardUser')->findOneBy('Username', 'test'); $user = new SiwappUser($dispatcher, new sfSessionTestStorage(array('session_path' => '/tmp'))); $user->signin($guard_user); $request->setParameter('searchNamespace', 'invoices'); $t->diag('->updateSearch()'); $user->updateSearch($request); $request->setParameter('page', 2); $user->updateSearch($request); $t->is($user->getAttribute('page', null, 'invoices'), 2, '->updateSearch() sets the page to request page parameter'); $request->setParameter('search', array('query' => 'galaxy')); $user->updateSearch($request); $t->is($user->getAttribute('page', null, 'invoices'), 1, '->updateSearch() sets the page to 1 if the search changes'); $request->setParameter('page', 4); $user->updateSearch($request); $request->setParameter('sort', array('customer_name', 'asc')); $user->updateSearch($request); $t->is($user->getAttribute('page', null, 'invoices'), 1, '->updateSearch() sets the page to 1 if the sort changes'); $t->diag('Testing the default search filter settings'); $user->getProfile()->setSearchFilter('last_month'); $user->updateSearch($request); $search = $user->getAttribute('search', null, 'invoices'); $today = new sfDate(); $t->is($search['to']['year'], $today->getYear(), 'sets right the to_year'); $t->is($search['to']['month'], $today->getMonth(), 'sets right the to_month'); $t->is($search['to']['day'], $today->getDay(), 'sets right the to_day'); $t->is($search['from']['year'], $today->subtractMonth(1)->getYear(), 'sets right the from_year'); $t->is($search['from']['month'], $today->getMonth(), 'sets right the from_month'); $t->is($search['from']['day'], $today->getDay(), 'sets right the from_day');