本文整理汇总了PHP中Zend_Controller_Request_Http::setBaseUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Http::setBaseUrl方法的具体用法?PHP Zend_Controller_Request_Http::setBaseUrl怎么用?PHP Zend_Controller_Request_Http::setBaseUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Request_Http
的用法示例。
在下文中一共展示了Zend_Controller_Request_Http::setBaseUrl方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _addHomepageRoute
/**
* 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);
}
}
}
}
示例2: _initRequest
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;
}
示例3: urlFor
/**
* 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);
}
示例4: testSetBaseUrl
public function testSetBaseUrl()
{
$this->_request->setBaseUrl('/news');
$this->assertEquals('/news', $this->_request->getBaseUrl());
}
示例5: testSetGotoUrlWithBaseUrlUsingPrependBaseOption
public function testSetGotoUrlWithBaseUrlUsingPrependBaseOption()
{
$this->request->setBaseUrl('/my');
$this->redirector->setGotoUrl('/foo/bar', array('prependBase' => true));
$this->assertEquals('/my/foo/bar', $this->redirector->getRedirectUrl());
}
示例6: testPathInfoShouldRespectNonEncodedRequestUri
/**
* @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);
}
示例7: dirname
/**
* @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);
示例8: _initRequest
/**
*
*/
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;
}
示例9: testSetPathInfoShouldNotStripBaseUrlIfBaseUrlNotInRequestUri
/**
* @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);
}
示例10: myUrl
/**
* 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