]> dev.renevier.net Git - syj.git/blob - application/views/helpers/Returnto.php
version 0.1
[syj.git] / application / views / helpers / Returnto.php
1 <?php
2 /*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
3     and is published under the AGPL license. */
4
5 class Syj_View_Helper_Returnto extends Zend_View_Helper_HtmlElement
6 {
7
8     protected function getHref() {
9         $param = Zend_Controller_Front::getInstance()->getRequest()->getQuery('redirect');
10         if (!isset($param)) {
11             return false;
12         }
13         $href = $this->view->escape(implode('/', array_map('urlencode', explode('/', $param ))));
14         return $href;
15     }
16
17     public function returnto() {
18         $returnto = $this->getHref();
19         $baseurl = $this->view->baseUrl();
20
21         if ($returnto === false) {
22             return $this->view->translate('You can now') . ' '
23                    . $this->view->anchor($baseurl, $this->view->translate('go to main page'));
24         } else if ($returnto == $baseurl) {
25             return $this->view->translate('You can now') . ' '
26             . $this->view->anchor($returnto, $this->view->translate('go back to %s', $returnto));
27         } else {
28             return $this->view->translate('You can now') . ' ' .
29                     $this->view->anchor($returnto, $this->view->translate('go back to %s', $returnto)) .
30                     ' ' . $this->view->translate('or you can') . ' ' .
31                     $this->view->anchor($baseurl, $this->view->translate('go to main page'));
32         }
33
34     }
35 }