Beispiel #1
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 Pluf_HTTP_Request The request object of the current page.
  * @param string The full url of the login page (null)
  */
 function __construct($request, $loginurl = null)
 {
     if ($loginurl !== null) {
         $murl = new Pluf_HTTP_URL();
         $url = $murl->generate($loginurl, array('_redirect_after' => $request->uri), false);
         $encoded = $murl->generate($loginurl, array('_redirect_after' => $request->uri));
     } else {
         Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
         $url = Pluf_HTTP_URL_urlForView(Pluf::f('login_view', 'login_view'), array(), array('_redirect_after' => $request->uri), false);
         $encoded = Pluf_HTTP_URL_urlForView(Pluf::f('login_view', 'login_view'), array(), array('_redirect_after' => $request->uri));
     }
     $content = sprintf(__('<a href="%s">Please, click here to be redirected</a>.'), $encoded);
     parent::__construct($content);
     $this->headers['Location'] = $url;
     $this->status_code = 302;
 }
Beispiel #2
0
/**
 * Provide the full URL (without domain) to a view.
 *
 * @param string View.
 * @param array Parameters for the view (array()).
 * @param array Extra GET parameters for the view (array()).
 * @param bool Should the URL be encoded (true).
 * @return string URL.
 */
function Pluf_HTTP_URL_urlForView($view, $params = array(), $get_params = array(), $encoded = true)
{
    return Pluf_HTTP_URL::generate(Pluf_HTTP_URL_reverse($view, $params), $get_params, $encoded);
}
Beispiel #3
0
 public function testGenerateSimpleEncoded()
 {
     $murl = new Pluf_HTTP_URL('simple');
     $url = $murl->generate('/toto/titi/', array('param1' => 'value%*one', 'param2' => 'value&two'));
     $this->assertEquals('?_px_action=%2Ftoto%2Ftiti%2F&amp;param1=value%' . '25%2Aone&amp;param2=value%26two', $url);
 }
Beispiel #4
0
 /**
  * Logout the user.
  *
  * The success url is either an absolute url starting with
  * http(s):// or considered as an action.
  *
  * @param Request Request object
  * @param array Match
  * @param string Default redirect URL after login '/'
  * @return Response object
  */
 function logout($request, $match, $success_url = '/')
 {
     $user_model = Pluf::f('pluf_custom_user', 'Pluf_User');
     $request->user = new $user_model();
     $request->session->clear();
     $request->session->setData('logout_time', gmdate('Y-m-d H:i:s'));
     if (0 !== strpos($success_url, 'http')) {
         $murl = new Pluf_HTTP_URL();
         $success_url = Pluf::f('app_base') . $murl->generate($success_url);
     }
     return new Pluf_HTTP_Response_Redirect($success_url);
 }
Beispiel #5
0
/**
 * Generate a link.
 *
 * If the configuration variable 'wiki_create_action' is set to true and
 * the URL starts with '/' and does not contains a dot '.' an action is
 * created out of it, with 'app_base' as the base url.
 */
function Pluf_Text_Wiki_Configuration_buildlink($contents, $attr)
{
    $cnt = count($contents);
    $attribut = '';
    if ($cnt == 0) {
        return '[]';
    }
    if ($cnt == 1) {
        $contents[1] = $contents[0];
        if (strlen($contents[0]) > 40) {
            $contents[0] = substr($contents[0], 0, 40) . '(..)';
        }
        $cnt = 2;
    }
    if ($cnt > count($attr)) {
        $cnt = count($attr) + 1;
    }
    if (strpos($contents[1], 'javascript:') !== false) {
        // for security reason
        $contents[1] = '#';
    }
    if ('/' == $contents[1][0] and false === strpos($contents[1], '.')) {
        if (true === Pluf::f('wiki_create_action')) {
            $murl = new Pluf_HTTP_URL();
            $contents[1] = Pluf::f('app_base') . $murl->generate($contents[1]);
        }
    }
    for ($i = 1; $i < $cnt; $i++) {
        $attribut .= ' ' . $attr[$i - 1] . '="' . $contents[$i] . '"';
    }
    return '<a' . $attribut . '>' . $contents[0] . '</a>';
}