Ejemplo n.º 1
0
 function redirect($request, $match, $view)
 {
     return new Redirect(URL::forView($view[0], $view[1]));
 }
Ejemplo n.º 2
0
 public function testViewInSub2()
 {
     $views = array(array('regex' => '#^/#', 'sub' => array(array('regex' => '#^$#', 'view' => array('\\helloworld\\views\\Views', 'you'), 'name' => 'home'))));
     $tests = array(array('/', 'home', array('')));
     foreach ($tests as $t) {
         $this->assertequals($t[0], URL::reverse($views, $t[1], $t[2]));
     }
 }
Ejemplo n.º 3
0
 /**
  * Display the URL of a view.
  *
  * @param $view View name
  * @param $params Parameters for the view (array())
  * @param $get_params Extra get parameters (array())
  */
 function start($view, $params = array(), $get_params = array())
 {
     echo \photon\core\URL::forView($view, $params, $get_params);
 }
Ejemplo n.º 4
0
 public function redirect($request, $match)
 {
     $url = URL::forView('hello_view');
     return new Redirect($url);
 }
Ejemplo n.º 5
0
 /**
  * Dump from a view name defined in the configuration
  *
  * @param string path of the file to create (i.e. /home/foobar/index.html).
  * @param string View.
  * @param array Parameters for the view (array()).
  * @param array Extra GET parameters for the view (array()).
  */
 static function fromView($path, $view, $params = array(), $get_params = array())
 {
     $url = \photon\core\URL::forView($view, $params, $get_params);
     static::fromURL($path, $url);
 }
Ejemplo n.º 6
0
 /**
  * The $request object is used to know what the post login
  * redirect url should be.
  *
  * If the action url of the login page is not set, it will try to
  * get the url from the login view from the 'login_view'
  * configuration key.
  *
  * @param Request The request object of the current page.
  * @param string The full url of the login page (null)
  */
 function __construct($request, $loginurl = null)
 {
     $redirect = array('_redirect_after' => \photon\crypto\Sign::dumps($request->path, Conf::f('secret_key')));
     if ($loginurl !== null) {
         $url = URL::generate($loginurl, $redirect, false);
         $encoded = URL::generate($loginurl, $redirect);
     } else {
         $url = URL::forView(Conf::f('login_view', 'login_view'), array(), $redirect, false);
         $encoded = URL::forView(Conf::f('login_view', 'login_view'), array(), $redirect);
     }
     $content = sprintf(__('<a href="%s">Please, click here to be redirected</a>.'), $encoded);
     parent::__construct($content);
     $this->headers['Location'] = $url;
     $this->status_code = 302;
 }