Beispiel #1
0
    /**

     * Return the URL

     *

     * @param string|array $urlOptions

     * @param string       $name

     * @param bool         $reset

     * @param bool         $encode

     * @return string

     */
    public function myUrl($urlOptions = array(), $name = null, $reset = false, $encode = true)
    {
        $front = Zend_Controller_Front::getInstance();
        $router = $front->getRouter();
        $extraUrlOptions = array();
        $extraOptions = Zend_Controller_Front::getInstance()->getRequest()->getParams();
        if (count($extraOptions)) {
            foreach ($extraOptions as $key => $value) {
                if ($key != 'module' && $key != 'controller' && $key != 'action') {
                    $extraUrlOptions[] = $key . '=' . ($encode ? urlencode($value) : $value);
                }
            }
        }
        if (is_string($urlOptions)) {
            $urlOptions = '/' . ltrim($urlOptions, '/');
            // Case the first character is ?
            $request = new Zend_Controller_Request_Http();
            // Creates a cleaned instance of request http
Beispiel #2
0
 /**
  * Adds the homepage route to the router (as specified by the navigation settings page)
  * The route will not be added if the user is currently on the admin theme.
  *
  * @param Zend_Controller_Router_Rewrite $router The router
  */
 private function _addHomepageRoute($router)
 {
     // Don't add the route if the user is on the admin theme
     if (!is_admin_theme()) {
         $homepageUri = get_option(Omeka_Form_Navigation::HOMEPAGE_URI_OPTION_NAME);
         $homepageUri = trim($homepageUri);
         $withoutAdminUri = $this->_leftTrim($this->_leftTrim($homepageUri, ADMIN_BASE_URL), '/' . ADMIN_WEB_DIR);
         if ($withoutAdminUri != $homepageUri) {
             // homepage uri is an admin link
             $homepageUri = WEB_ROOT . '/' . ADMIN_WEB_DIR . $withoutAdminUri;
             $this->addRedirectRouteForDefaultRoute(self::HOMEPAGE_ROUTE_NAME, $homepageUri, array(), $router);
         } else {
             // homepage uri is not an admin link
             // left trim root directory off of the homepage uri
             $homepageUri = $this->_leftTrim($homepageUri, PUBLIC_BASE_URL);
             // make sure the new homepage is not the default homepage
             if ($homepageUri == '' || $homepageUri == self::DEFAULT_ROUTE_NAME || $homepageUri == PUBLIC_BASE_URL) {
                 return;
             }
             $homepageRequest = new Zend_Controller_Request_Http();
             $homepageRequest->setBaseUrl(WEB_ROOT);
             // web root includes server and root directory
             $homepageRequest->setRequestUri($homepageUri);
             $router->route($homepageRequest);
             $dispatcher = Zend_Controller_Front::getInstance()->getDispatcher();
             if ($dispatcher->isDispatchable($homepageRequest)) {
                 // homepage is an internal link
                 $router->addRoute(self::HOMEPAGE_ROUTE_NAME, new Zend_Controller_Router_Route(self::DEFAULT_ROUTE_NAME, $homepageRequest->getParams()));
             } else {
                 // homepage is some external link or a broken internal link
                 $this->addRedirectRouteForDefaultRoute(self::HOMEPAGE_ROUTE_NAME, $homepageUri, array(), $router);
             }
         }
     }
 }
Beispiel #3
0
 protected function _initRequest(array $options = array())
 {
     // Ensure front controller instance is present, and fetch it
     $this->bootstrap('FrontController');
     $front = $this->getResource('FrontController');
     // Initialize the request object
     $request = new Zend_Controller_Request_Http();
     $request->setBaseUrl(dirname($_SERVER['SCRIPT_NAME']));
     // Add it to the front controller
     $front->setRequest($request);
     //$front->addControllerDirectory(APPLICATION_PATH . '/modules/forum/controllers', 'forum');
     // Bootstrap will store this value in the 'request' key of its container
     return $request;
 }
 /**
  * Return the URL
  *
  * @param string|array $urlOptions
  * @param string       $name
  * @param bool         $reset
  * @param bool         $encode
  * @return string
  */
 public function urlFor($urlOptions, $name = null, $reset = false, $encode = true)
 {
     $front = Zend_Controller_Front::getInstance();
     $router = $front->getRouter();
     if (is_string($urlOptions)) {
         $urlOptions = '/' . ltrim($urlOptions, '/');
         // Case the first character is a '?
         $request = new Zend_Controller_Request_Http();
         // Creates a cleaned instance of request http
         $request->setBaseUrl($front->getBaseUrl());
         $request->setRequestUri($urlOptions);
         $route = $router->route($request);
         // Return the request route with params modifieds
         $urlOptions = $route->getParams();
         /*var_dump($route->getParams());
           die();*/
     }
     return $router->assemble((array) $urlOptions, $name, $reset, $encode);
 }
Beispiel #5
0
 public function testSetBaseUrl()
 {
     $this->_request->setBaseUrl('/news');
     $this->assertEquals('/news', $this->_request->getBaseUrl());
 }
 public function testSetGotoUrlWithBaseUrlUsingPrependBaseOption()
 {
     $this->request->setBaseUrl('/my');
     $this->redirector->setGotoUrl('/foo/bar', array('prependBase' => true));
     $this->assertEquals('/my/foo/bar', $this->redirector->getRedirectUrl());
 }
Beispiel #7
0
 /**
  * @group ZF-3527
  */
 public function testPathInfoShouldRespectNonEncodedRequestUri()
 {
     $request = new Zend_Controller_Request_Http();
     $request->setBaseUrl('~user');
     $_SERVER['REQUEST_URI'] = '~user/module/controller/action';
     $pathInfo = $request->getPathInfo();
     $this->assertEquals('/module/controller/action', $pathInfo, $pathInfo);
 }
Beispiel #8
0
/**
 * @package     Engine_Core
 * @version     $Id: mobile.php 7539 2010-10-04 04:41:38Z john $
 * @copyright   Copyright (c) 2008 Webligo Developments
 * @license     http://www.socialengine.net/license/
 */
$_GET['m'] = 'mobile';
// Trick main loader
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'index.php';
$application->bootstrap();
// Return site info
if (empty($_REQUEST['action'])) {
    $site = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.general.site');
    $info = array('site' => $site);
    echo Zend_Json::encode($info);
    exit;
}
// Parse action param
$action = preg_replace('/[^a-zA-Z0-9\\/_-]/', '', $_GET['action']);
$action = explode('/', $action);
if (count($action) != 2 && count($action) != 3) {
    echo Zend_Json::encode(array('error' => true, 'core' => 404));
    exit;
}
$action = join('/', $action);
// Dispatch
$front = Zend_Controller_Front::getInstance();
//$front->setBaseUrl($front->getBaseUrl().'/index.php');
$request = new Zend_Controller_Request_Http('http://' . $_SERVER['HTTP_HOST'] . $front->getBaseUrl() . '/' . $action);
$request->setBaseUrl($front->getBaseUrl());
$front->dispatch($request);
Beispiel #9
0
	/**
	 *
	 */
    protected function _initRequest()
    {
        // Ensure the front controller is initialized
        $this->bootstrap('FrontController');
 
        // Retrieve the front controller from the bootstrap registry
        $front = $this->getResource('FrontController');

        $request = new Zend_Controller_Request_Http();
        $request->setBaseUrl('/');
        $front->setRequest($request);
 
        // Ensure the request is stored in the bootstrap registry
        return $request;
    }
Beispiel #10
0
 /**
  * @group ZF-9091
  */
 public function testSetPathInfoShouldNotStripBaseUrlIfBaseUrlNotInRequestUri()
 {
     $request = new Zend_Controller_Request_Http();
     $request->setBaseUrl('/app');
     $_SERVER['REQUEST_URI'] = '/index/index';
     $pathInfo = $request->getPathInfo();
     $this->assertEquals('/index/index', $pathInfo);
 }