Exemplo n.º 1
0
 public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
 {
     $this->_mapper = $GLOBALS['injector']->getInstance('Horde_Routes_Mapper');
     $this->_matchDict = new Horde_Support_Array($this->_mapper->match($request->getPath()));
     $injector = $this->getInjector();
     switch ($this->_matchDict->action) {
         case 'category':
             $driver = $injector->getInstance('Dolcore_Factory_Driver')->create($injector);
             $categories = $driver->getCategoriesApi();
             $discussionApi = $driver->getDiscussionApi();
             $category = $categories->getCategory($this->_matchDict->category);
             /* Write a category's currently running Umfragen */
             $now = new Horde_Date(time());
             $template = $this->getInjector()->createInstance('Horde_Template');
             $template->set('updated', $now->format(DATE_ATOM));
             $template->set('category_caption', $category->getCaption());
             $template->set('category_id', $category->id);
             $discussions = array();
             foreach ($discussionApi->listDiscussions(array('category' => $category->id)) as $discussion) {
                 $discussions[$discussion->id]['title'] = $discussion->text;
                 $discussions[$discussion->id]['details'] = $discussion->hintergrund;
                 $discussions[$discussion->id]['modified'] = $discussion->erstelldatum;
                 $discussions[$discussion->id]['id'] = Dolcore::getUrlFor('discussion', array('discussion_id' => $discussion->id), true, true);
                 $discussions[$discussion->id]['url'] = Dolcore::getUrlFor('discussion', array('discussion_id' => $discussion->id), true, true);
             }
             $template->set('discussions', $discussions);
             $response->setBody($template->fetch(DOLCORE_TEMPLATES . '/feeds/atom.xml'));
             break;
         case 'categories':
             break;
     }
 }
Exemplo n.º 2
0
 public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
 {
     $id = Horde_Util::getFormData('bookmark');
     $gateway = $this->getInjector()->getInstance('Trean_Bookmarks');
     $notification = $this->getInjector()->getInstance('Horde_Notification');
     try {
         $bookmark = $gateway->getBookmark($id);
         $old_url = $bookmark->url;
         $bookmark->url = Horde_Util::getFormData('bookmark_url');
         $bookmark->title = Horde_Util::getFormData('bookmark_title');
         $bookmark->description = Horde_Util::getFormData('bookmark_description');
         $bookmark->tags = Horde_Util::getFormData('treanBookmarkTags');
         if ($old_url != $bookmark->url) {
             $bookmark->http_status = '';
         }
         $bookmark->save();
         $result = array('data' => 'saved');
     } catch (Horde_Exception $e) {
         $notification->push(sprintf(_("There was an error saving the bookmark: %s"), $e->getMessage()), 'horde.error');
         $result = array('error' => $e->getMessage());
     }
     if (Horde_Util::getFormData('format') == 'json') {
         $response->setContentType('application/json');
         $response->setBody(json_encode($result));
     } else {
         $response->setRedirectUrl(Horde_Util::getFormData('url', Horde::url('browse.php', true)));
     }
 }
Exemplo n.º 3
0
 public function processResponse(Horde_Controller_Request $request, Horde_Controller_Response $response, Horde_Controller $controller)
 {
     $body = $response->getBody();
     $body = gzencode($body);
     $response->setHeader('Content-Encoding', 'gzip');
     $response->setHeader('Content-Length', $this->_byteCount($body));
     $response->setBody($body);
     return $response;
 }
Exemplo n.º 4
0
 /**
  *
  * @param Horde_Controller_Response $response
  */
 protected function _index(Horde_Controller_Response $response)
 {
     $view = $this->getView();
     $view->page_title = 'Downloads - The Horde Project';
     $view->appListController = array('controller' => 'download', 'action' => 'app');
     $layout = $this->getInjector()->getInstance('Horde_Core_Ui_Layout');
     $layout->setView($view);
     $layout->setLayoutName('main');
     $response->setBody($layout->render('index'));
 }
Exemplo n.º 5
0
 public function testStreamOutput()
 {
     $output = 'BODY';
     $body = new Horde_Support_StringStream($output);
     $response = new Horde_Controller_Response();
     $response->setBody($body->fopen());
     $writer = new Horde_Controller_ResponseWriter_Web();
     ob_start();
     $writer->writeResponse($response);
     $this->assertEquals('BODY', ob_get_clean());
 }
Exemplo n.º 6
0
 public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
 {
     /* Toggle the task's completion status if we're provided with a
      * valid task ID. */
     $requestVars = $request->getRequestVars();
     if (isset($requestVars['task']) && isset($requestVars['tasklist'])) {
         $nag_task = new Nag_CompleteTask();
         $result = $nag_task->result($requestVars['task'], $requestVars['tasklist']);
     } else {
         $result = array('error' => 'missing parameters');
     }
     $requestVars = $request->getGetVars();
     if (!empty($requestVars['format']) && $requestVars['format'] == 'json') {
         $response->setContentType('application/json');
         $response->setBody(json_encode($result));
     } elseif ($requestVars['url']) {
         $response->setRedirectUrl($requestVars['url']);
     }
 }
Exemplo n.º 7
0
 public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
 {
     $id = Horde_Util::getFormData('bookmark');
     $gateway = $this->getInjector()->getInstance('Trean_Bookmarks');
     $notification = $this->getInjector()->getInstance('Horde_Notification');
     try {
         $bookmark = $gateway->getBookmark($id);
         $gateway->removeBookmark($bookmark);
         $notification->push(_("Deleted bookmark: ") . $bookmark->title, 'horde.success');
         $result = array('data' => 'deleted');
     } catch (Horde_Exception $e) {
         $notification->push(sprintf(_("There was a problem deleting the bookmark: %s"), $e->getMessage()), 'horde.error');
         $result = array('error' => $e->getMessage());
     }
     if (Horde_Util::getFormData('format') == 'json') {
         $response->setContentType('application/json');
         $response->setBody(json_encode($result));
     } else {
         $response->setRedirectUrl(Horde_Util::getFormData('url', Horde::url('browse.php', true)));
     }
 }
Exemplo n.º 8
0
 /**
  * Fetch remote data.
  *
  * @param Horde_Controller_Response  $response The response handler.
  *
  * @return NULL
  */
 public function _passThrough(Horde_Controller_Response $response)
 {
     $url = $this->getUrlWithCredentials($this->_user->getPrimaryId(), $this->_user->getPassword());
     $origin = $this->_client->get($url);
     if ($origin->code !== 200) {
         $url = $this->getUrlWithCredentials($this->_user, 'XXX');
         throw new Horde_Kolab_FreeBusy_Exception_Unauthorized(sprintf('Unable to read free/busy information from %s', $url));
     }
     $response->setHeader('X-Redirect-To', $url);
     $response->setBody($origin->getStream());
 }
Exemplo n.º 9
0
 /**
  *
  * @param Horde_Controller_Response $response
  */
 protected function _index(Horde_Controller_Response $response)
 {
     $view = $this->getView();
     $view->page_title = 'The Horde Project';
     $view->maxHordeItems = 5;
     $view->maxPlanetItems = 10;
     $cache = $GLOBALS['injector']->getInstance('Horde_Cache');
     // Get the planet feed.
     if ($planet = $cache->get('planet', 600)) {
         $view->planet = unserialize($planet);
     } else {
         try {
             $view->planet = Horde_Feed::readUri('http://planet.horde.org/rss/');
         } catch (Exception $e) {
             $view->planet = null;
         }
         $cache->set('planet', serialize($view->planet));
     }
     // Get the complete Horde feed (no tags)
     if ($hordefeed = $cache->get('hordefeed', 600)) {
         $view->hordefeed = unserialize($hordefeed);
     } else {
         try {
             $view->hordefeed = Horde_Feed::readUri($GLOBALS['feed_url']);
         } catch (Exception $e) {
             $view->hordefeed = null;
         }
         $cache->set('hordefeed', serialize($view->hordefeed));
     }
     $layout = $this->getInjector()->getInstance('Horde_Core_Ui_Layout');
     $layout->setView($view);
     $layout->setLayoutName('home');
     $response->setBody($layout->render('index'));
 }
Exemplo n.º 10
0
 public function delete(Horde_Controller_Response $response, $params = array())
 {
     $response->setBody('deleted data for user "' . $params->owner . '"');
 }
Exemplo n.º 11
0
 protected function _pageGone(Horde_Controller_Response $response)
 {
     $view = $this->getView();
     $view->page_title = '410 - Page Gone';
     $layout = $this->getInjector()->getInstance('Horde_Core_Ui_Layout');
     $layout->setView($view);
     $layout->setLayoutName('main');
     $response->setHeaders(array('Status' => '410 Page Gone', 'HTTP/1.0' => '410 Page Gone'));
     $response->setBody($layout->render('410'));
 }
Exemplo n.º 12
0
 /**
  * Library documentation section.
  *
  * @param Horde_Controller_Response $response
  */
 protected function _docs(Horde_Controller_Response $response)
 {
     $view = $this->getView();
     $layout = $this->getInjector()->getInstance('Horde_Core_Ui_Layout');
     if ($this->_isKnownLibrary($view)) {
         $template = 'docs';
         Horde::startBuffer();
         include $GLOBALS['fs_base'] . '/app/views/Library/libraries/' . $view->libraryName . '/docs/' . ($this->_matchDict->file ? $this->_matchDict->file : 'docs') . '.html';
         $view->content = Horde::endBuffer();
     } else {
         $template = '404';
     }
     $layout->setView($view);
     $layout->setLayoutName('main');
     $response->setBody($layout->render($template));
 }
Exemplo n.º 13
0
 protected function _screenshots(Horde_Controller_Response $response, $type)
 {
     $page_output = $GLOBALS['injector']->getInstance('Horde_PageOutput');
     $page_output->addScriptFile($script);
     $script = new Horde_Script_File_External($GLOBALS['host_base'] . '/js/jquery.lightbox-0.5.min.js');
     $page_output->addScriptFile($script);
     $css = new Horde_Themes_Element('jquery.lightbox-0.5.css', array('data' => array('fs' => $GLOBALS['fs_base'] . '/css/jquery.lightbox-0.5.css', 'uri' => $GLOBALS['host_base'] . '/css/jquery.lightbox-0.5.css')));
     $page_output->addStylesheet($css->fs, $css->uri);
     $js = '$(function() { $("a.lightbox").lightBox(
         {"imageBtnPrev": "' . $GLOBALS['host_base'] . '/images/lightbox-btn-prev.gif",
          "imageBtnNext": "' . $GLOBALS['host_base'] . '/images/lightbox-btn-next.gif",
          "imageLoading": "' . $GLOBALS['host_base'] . '/images/lightbox-ico-loading.gif",
          "imageBtnClose": "' . $GLOBALS['host_base'] . '/images/lightbox-btn-close.gif",
          "imageBlank": "' . $GLOBALS['host_base'] . '/images/lightbox-blank.gif"});})';
     $page_output->addInlineScript($js);
     $view = $this->getView();
     $view->page_title = 'Screenshots - ' . $view->appnameHuman . ' - The Horde Project';
     $layout = $this->getInjector()->getInstance('Horde_Core_Ui_Layout');
     $layout->setView($view);
     $layout->setLayoutName('main');
     $response->setBody($layout->render($type));
 }
Exemplo n.º 14
0
 /**
  */
 public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
 {
     $response->setHeader('HTTP/1.0 404 ', 'Not Found');
     $response->setBody('<!DOCTYPE html><html><head><title>404 File Not Found</title></head><body><h1>404 File Not Found</h1></body></html>');
 }