本文整理汇总了PHP中Zend_Controller_Request_Http::setRequestUri方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Http::setRequestUri方法的具体用法?PHP Zend_Controller_Request_Http::setRequestUri怎么用?PHP Zend_Controller_Request_Http::setRequestUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Request_Http
的用法示例。
在下文中一共展示了Zend_Controller_Request_Http::setRequestUri方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _processRedirectOptions
/**
* Process redirect (R) and permanent redirect (RP)
*
* @return Mage_Core_Model_Url_Rewrite_Request
*/
protected function _processRedirectOptions()
{
$isPermanentRedirectOption = $this->_rewrite->hasOption('RP');
$external = substr($this->_rewrite->getTargetPath(), 0, 6);
if ($external === 'http:/' || $external === 'https:') {
$destinationStoreCode = $this->_app->getStore($this->_rewrite->getStoreId())->getCode();
$this->_setStoreCodeCookie($destinationStoreCode);
$this->_sendRedirectHeaders($this->_rewrite->getTargetPath(), $isPermanentRedirectOption);
}
$targetUrl = $this->_request->getBaseUrl() . '/' . $this->_rewrite->getTargetPath();
$storeCode = $this->_app->getStore()->getCode();
if (Mage::getStoreConfig('web/url/use_store') && !empty($storeCode)) {
$targetUrl = $this->_request->getBaseUrl() . '/' . $storeCode . '/' . $this->_rewrite->getTargetPath();
}
if ($this->_rewrite->hasOption('R') || $isPermanentRedirectOption) {
$this->_sendRedirectHeaders($targetUrl, $isPermanentRedirectOption);
}
$queryString = $this->_getQueryString();
if ($queryString) {
$targetUrl .= '?' . $queryString;
}
$this->_request->setRequestUri($targetUrl);
$this->_request->setPathInfo($this->_rewrite->getTargetPath());
return $this;
}
示例2: testSetRequestUri
public function testSetRequestUri()
{
$this->_request->setRequestUri('/archives/past/4?set=this&unset=that');
$this->assertEquals('/archives/past/4?set=this&unset=that', $this->_request->getRequestUri());
$this->assertEquals('this', $this->_request->getQuery('set'));
$this->assertEquals('that', $this->_request->getQuery('unset'));
}
示例3: _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()) {
return;
}
$homepageUri = trim(get_option(Omeka_Form_Navigation::HOMEPAGE_URI_OPTION_NAME));
if (strpos($homepageUri, ADMIN_BASE_URL) === 0) {
// homepage uri is an admin link
$this->_addHomepageRedirect($homepageUri, $router);
} else {
if (strpos($homepageUri, '?') === false) {
// left trim root directory off of the homepage uri
$relativeUri = $this->_leftTrim($homepageUri, PUBLIC_BASE_URL);
// make sure the new homepage is not the default homepage
if ($relativeUri == '' || $relativeUri == '/') {
return;
}
$homepageRequest = new Zend_Controller_Request_Http();
$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('/', $homepageRequest->getParams()));
return;
}
}
}
// homepage is some external link, a broken internal link, or has a
// query string
$this->_addHomepageRedirect($homepageUri, $router);
}
示例4: _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);
}
}
}
}
示例5: setRequestUri
/**
* Sets the REQUEST_URI on which the instance operates.
*
* If no request URI is passed, it uses the value in $_SERVER['REQUEST_URI'],
* $_SERVER['HTTP_X_REWRITE_URL'], or $_SERVER['ORIG_PATH_INFO'] + $_SERVER['QUERY_STRING'].
*
* @param string $requestUri
* @return Zend_Controller_Request_Http
*/
public function setRequestUri($requestUri = null)
{
parent::setRequestUri($requestUri);
if ($this->_requestUri === null && !empty($_SERVER['argc']) && $_SERVER['argc'] > 1) {
$this->setRequestUri($_SERVER['argv'][1]);
}
return $this;
}
示例6: testMatch
public function testMatch()
{
$route = new Mage_Webapi_Controller_Router_Route_Webapi(Mage_Webapi_Controller_Router_Route_Webapi::getApiRoute());
$testApiType = 'test_api';
$testUri = str_replace(':api_type', $testApiType, Mage_Webapi_Controller_Router_Route_Webapi::getApiRoute());
$request = new Zend_Controller_Request_Http();
$request->setRequestUri($testUri);
$match = $route->match($request);
$this->assertEquals($testApiType, $match['api_type']);
}
示例7: 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);
}
示例8: match
/**
* Rewritten function of the standard controller. Tries to match the pathinfo on url parameters.
*
* @see Mage_Core_Controller_Varien_Router_Standard::match()
*
* @param Zend_Controller_Request_Http $request The http request object that needs to be mapped on Action
* Controllers.
*/
public function match(Zend_Controller_Request_Http $request)
{
if (!Mage::isInstalled()) {
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
exit;
}
$identifier = trim($request->getPathInfo(), '/');
//URL Search after habbeda
$url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
//$identifier = trim($request->getPathInfo(), '/');
if (strpos($url, "/alle/") <= 0 && strpos($url, "/all/") <= 0) {
return false;
}
// if successfully gained url parameters, use them and dispatch ActionController action
$request->setRouteName('landingpagesaa')->setModuleName('landingpagesaa')->setControllerName('index')->setActionName('index');
//->setParam('test', "test");
$urlpara = explode("/filter/", $url);
if (!empty($urlpara[1])) {
$urlparas = explode("?", $urlpara[1]);
// Parse url params
$params = explode('/', trim($urlparas[0], '/'));
$layerParams = array();
$total = count($params);
for ($i = 0; $i < $total - 1; $i++) {
if (isset($params[$i + 1])) {
$layerParams[$params[$i]] = urldecode($params[$i + 1]);
++$i;
}
}
// Add post params to parsed ones from url
// Usefull to easily override params
$layerParams += $request->getPost();
// Add params to request
$request->setParams($layerParams);
// Save params in registry - used later to generate links
Mage::register('layer_params', $layerParams);
}
$request->setRequestUri($url);
$request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
return true;
}
示例9: handle
/**
* (non-PHPdoc)
* @see Tinebase_Server_Interface::handle()
*/
public function handle(\Zend\Http\Request $request = null, $body = null)
{
$this->_request = $request instanceof \Zend\Http\Request ? $request : Tinebase_Core::get(Tinebase_Core::REQUEST);
$this->_body = $this->_getBody($body);
try {
list($loginName, $password) = $this->_getAuthData($this->_request);
} catch (Tinebase_Exception_NotFound $tenf) {
header('WWW-Authenticate: Basic realm="ActiveSync for Tine 2.0"');
header('HTTP/1.1 401 Unauthorized');
return;
}
if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' is ActiveSync request.');
}
Tinebase_Core::initFramework();
try {
$authResult = $this->_authenticate($loginName, $password, $this->_request);
} catch (Exception $e) {
Tinebase_Exception::log($e);
$authResult = false;
}
if ($authResult !== true) {
header('WWW-Authenticate: Basic realm="ActiveSync for Tine 2.0"');
header('HTTP/1.1 401 Unauthorized');
return;
}
if (!$this->_checkUserPermissions($loginName)) {
return;
}
$this->_initializeRegistry();
$request = new Zend_Controller_Request_Http();
$request->setRequestUri($this->_request->getRequestUri());
$syncFrontend = new Syncroton_Server(Tinebase_Core::getUser()->accountId, $request, $this->_body);
$syncFrontend->handle();
Tinebase_Controller::getInstance()->logout();
}
示例10: makeHttpCall
/**
* For some functionality you absolutely need an HTTP context.
* This method mimics a standard Zend request.
*
* @param string $uri
* @return string The response body
*/
public static function makeHttpCall($uri)
{
$request = new Zend_Controller_Request_Http();
$request->setRequestUri($uri);
$application = Zend_Registry::get('application');
$front = $application->getBootstrap()->getResource('FrontController');
$default = $front->getDefaultModule();
if (null === $front->getControllerDirectory($default)) {
throw new Zend_Application_Bootstrap_Exception('No default controller directory registered with front controller');
}
$front->setParam('bootstrap', $application->getBootstrap());
// Make sure we aren't blocked from the ContentController as per the rules in the ACL
$front->unregisterPlugin('Garp_Controller_Plugin_Auth');
// Make sure no output is rendered
$front->returnResponse(true);
$response = $front->dispatch($request);
return $response;
}
示例11: array
$configModel = new Default_Model_Configuration();
$_SERVER['HTTP_HOST'] = $configModel->getKey('api_url');
// Valid things we can do
$routes = array('action' => array('add' => 'action/add', 'delete' => 'action/delete', 'test' => 'action/test'), 'actions' => array('list' => 'action/list', 'sync' => 'action/sync'), 'error' => array('add' => 'errors/add', 'delete' => 'errors/delete'), 'errors' => array('list' => 'errors/list'), 'partner' => array('add' => 'partner/add', 'delete' => 'partner/delete'), 'partners' => array('list' => 'partner/list'));
$tr = Zend_Registry::get('tr');
if ($argc < 3) {
echo $tr->_('USAGE_MSG') . PHP_EOL;
exit;
}
$action = $argv[1];
$module = $argv[2];
if (!isset($routes[$module][$action])) {
echo $tr->_('INVALID_MODULE_ACTION') . PHP_EOL;
echo $tr->_('VALID_OPTIONS') . ':' . PHP_EOL;
foreach ($routes as $module => $actions) {
echo $module . PHP_EOL;
foreach ($actions as $action_name => $controller) {
echo "\t" . $action_name . PHP_EOL;
}
}
exit;
}
// setup controller
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->addModuleDirectory(APPLICATION_PATH . DIRECTORY_SEPARATOR . 'modules');
$route = 'console/' . $routes[$module][$action];
$request = new Zend_Controller_Request_Http();
$request->setRequestUri($route);
$response = new Zend_Controller_Response_Cli();
$frontController->dispatch($request, $response);
示例12: dirname
public function test追加したルーティング先にディスパッチする()
{
$appPath = GENE_TEST_ROOT . '/var/config/routing.ini';
$config = Gene_Config::load($appPath);
$routing = new Gene_Application_Setting_Routing($config->routes);
$modules = dirname(__FILE__) . '/var/modules/';
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$routes = $routing->add($router)->getRouter();
$front->setDefaultModule('index')->addModuleDirectory($modules);
$request = new Zend_Controller_Request_Http('http://localhost');
$params = '/admin/list';
$request->setRequestUri($params);
$response = $front->returnResponse(true)->setParam('noViewRenderer', true)->dispatch($request);
$body = $response->getBody();
$this->assertEquals($body, 'Admin_IndexController::listAction');
$response->clearAllHeaders()->clearBody();
}
示例13: pages
/**
*
* @param string $pPanel = 'main'
* @return Zend_Navigation
*/
public function pages($pPanel = 'main')
{
$pages = array();
$req = Zend_Controller_front::getInstance()->getRequest();
$active_module = $req->getModuleName();
$active_controller = $req->getControllerName();
$sql = array('(required = 1) OR (active = 1)', 'sort_by');
$modules = Administer_Model_Modules::getInstance()->find_from_sql($sql, TRUE, FALSE);
foreach ($modules as $module) {
if (!$module->active) {
continue;
}
$module->load_menus();
$module_names[] = '"' . $module->folder . '"';
}
foreach ($this->find(array('panel' => $pPanel, 'parent' => 0), 'sort_by') as $menu) {
if ($new_page = $menu->page($active_module, $active_controller)) {
$pages[] = $new_page;
}
}
$router = Zend_Controller_Front::getInstance()->getRouter();
$fake_route = new Zend_Controller_Request_Http();
$fake_route->setRequestUri('/');
$router->route($fake_route);
return new Zend_Navigation($pages);
}
示例14: 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