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
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Plume Framework is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
# ***** END LICENSE BLOCK ***** */
// Set the include path to have Pluf in it.
// If you have Pluf in your include path, you do not need that
$path_to_Pluf = dirname(__FILE__) . '/../../../src';
$path_to_Todo = dirname(__FILE__) . '/../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path_to_Pluf . PATH_SEPARATOR . $path_to_Todo);
// Load Pluf
require 'Pluf.php';
// Start the framework with the todo app configuration.
Pluf::start($path_to_Todo . '/Todo/conf/todo.php');
// As we are using a dispatcher, we need to load the corresponding
// view controllers. The controllers are just a mapping between the query
// string and corresponding classes and methods.
Pluf_Dispatcher::loadControllers(Pluf::f('todo_urls'));
// Dispatch the call. Note that the use of a dispatcher is not
// mandatory at all, you can create any number of .php file to dispatch
// manually. A dispatcher enables the use of only one index.php file.
Pluf_Dispatcher::dispatch(Pluf_HTTP_URL::getAction());
Beispiel #4
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 #5
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 #6
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>';
}