public function build($runData)
 {
     $site = $runData->getTemp("site");
     // now just get notifications for the site...
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $c->addOrderDescending('notification_id');
     $c->setLimit(20);
     $nots = DB_AdminNotificationPeer::instance()->select($c);
     $channel['title'] = _('Admin notifications for site') . ' "' . htmlspecialchars($site->getName()) . '"';
     $channel['link'] = "http://" . $site->getDomain() . "/admin:manage/start/notifications";
     $items = array();
     foreach ($nots as $not) {
         $extra = $not->getExtra();
         $item = array();
         $item['title'] = $not->getTitle();
         switch ($not->getType()) {
             case "NEW_MEMBER_APPLICATION":
                 $item['link'] = "http://" . $site->getDomain() . "/admin:manage/start/ma";
                 break;
             default:
                 $item['link'] = "http://" . $site->getDomain() . "/admin:manage/start/notifications" . "#notification-" . $not->getNotificationId();
         }
         $body = $not->getBody();
         $body = preg_replace('/onclick="[^"]+"/', '', $body);
         $item['description'] = $body;
         $item['guid'] = $channel['link'] . "#notification-" . $not->getNotificationId();
         $item['date'] = date('r', $not->getDate()->getTimestamp());
         // TODO: replace relative links with absolute links!
         $content = '';
         $items[] = $item;
     }
     $runData->contextAdd("channel", $channel);
     $runData->contextAdd("items", $items);
 }
 public function build($runData)
 {
     $siteId = $runData->getTemp("site")->getSiteId();
     $pl = $runData->getParameterList();
     $pageNumber = $pl->getParameterValue("page");
     if ($pageNumber == null || !is_numeric($pageNumber) || $pageNumber < 1) {
         $pageNumber = 1;
     }
     // now just get notifications for the user...
     $perPage = 30;
     $offset = ($pageNumber - 1) * $perPage;
     $count = $perPage * 2 + 1;
     $c = new Criteria();
     $c->add("site_id", $siteId);
     $c->addOrderDescending('notification_id');
     $c->setLimit($count, $offset);
     $nots = DB_AdminNotificationPeer::instance()->select($c);
     // now see if number of selected is equal $perPage + 1. If so -
     // there is at least 1 more page to show...
     $counted = count($nots);
     $pagerData = array();
     $pagerData['current_page'] = $pageNumber;
     if ($counted > $perPage * 2) {
         $knownPages = $pageNumber + 2;
         $pagerData['known_pages'] = $knownPages;
     } elseif ($counted > $perPage) {
         $knownPages = $pageNumber + 1;
         $pagerData['total_pages'] = $knownPages;
     } else {
         $totalPages = $pageNumber;
         $pagerData['total_pages'] = $totalPages;
     }
     $nots = array_slice($nots, 0, $perPage);
     $runData->contextAdd("pagerData", $pagerData);
     $runData->contextAdd("notifications", $nots);
     $runData->contextAdd("notificationsCount", count($nots));
 }