コード例 #1
0
ファイル: coreurlTest.php プロジェクト: photon/photon
 public function testUrlGenerate()
 {
     Conf::set('urls', array(array('regex' => '#^/home/(.+)/$#', 'view' => array('\\helloworld\\views\\Views', 'you'), 'name' => 'home')));
     $this->assertequals('/home/', URL::generate('/home/'));
     $this->assertequals('/home/?p=foo', URL::generate('/home/', array('p' => 'foo')));
     $this->assertequals('/home/?p=foo&b=bar', URL::generate('/home/', array('p' => 'foo', 'b' => 'bar'), false));
     $this->assertequals('/home/?p=foo&b=bar', URL::generate('/home/', array('p' => 'foo', 'b' => 'bar')));
 }
コード例 #2
0
ファイル: response.php プロジェクト: photon/photon
 /**
  * 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;
 }