示例#1
0
文件: App.php 项目: horde/horde-web
 /**
  *
  * Specific application's page
  *
  * @param Horde_Controller_Response $response
  */
 protected function _app(Horde_Controller_Response $response)
 {
     $view = $this->getView();
     $view->page_title = $view->appnameHuman . ' - The Horde Project';
     $layout = $this->getInjector()->getInstance('Horde_Core_Ui_Layout');
     $template = 'app';
     // Do we know about this app?
     if (file_exists($GLOBALS['fs_base'] . '/app/views/App/apps/' . urlencode($this->_matchDict->app)) === false) {
         $view->page_title = '404 Not Found';
         $template = '404';
     }
     // Build the bug/news widget
     // The tag for the search should *normally* be the app name
     $cache = HordeWeb_Utils::getCache();
     $slugs = array($this->_matchDict->app);
     $view->latestNews = array();
     foreach ($slugs as $slug) {
         $base_feed_url = Horde::url($GLOBALS['feed_url'])->add('tag_id', $slug)->setRaw(true);
         if ($latestnews = $cache->get('hordefeed' . $slug, 600)) {
             $view->latestNews = unserialize($latestnews);
         } else {
             try {
                 $i = 1;
                 foreach (Horde_Feed::readUri($base_feed_url) as $entry) {
                     $view->latestNews[] = $entry;
                     if (++$i > 5) {
                         break;
                     }
                 }
             } catch (Exception $e) {
             }
             $cache->set('hordefeed' . $slug, serialize($view->latestNews));
         }
     }
     $layout->setView($view);
     $layout->setLayoutName('main');
     $response->setBody($layout->render($template));
 }