本文整理汇总了PHP中Zend_Controller_Request_Http::getRequestUri方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Http::getRequestUri方法的具体用法?PHP Zend_Controller_Request_Http::getRequestUri怎么用?PHP Zend_Controller_Request_Http::getRequestUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Request_Http
的用法示例。
在下文中一共展示了Zend_Controller_Request_Http::getRequestUri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($args = false)
{
if ($args === false) {
// Created with _getProcessor function
$registryKey = '_singleton/amfpc/fpc_front';
Mage::register($registryKey, $this, true);
}
if (isset($_SESSION)) {
$this->_sessionName = session_name();
} else {
$sessionName = (string) Mage::app()->getConfig()->getNode('global/amfpc/session_name');
if ($sessionName) {
$this->_sessionName = $sessionName;
}
}
$request = new Zend_Controller_Request_Http();
$pathInfo = trim(strtok($request->getRequestUri(), '?'), '/');
if ($this->getDbConfig('web/url/use_store')) {
$pathParts = explode('/', $pathInfo);
$storeCode = array_shift($pathParts);
$this->_urlInfo = array('store_code' => $storeCode, 'page' => implode('/', $pathParts));
} else {
$this->_urlInfo = array('store_code' => false, 'page' => $pathInfo);
}
}
示例2: getPaginator
/**
* Возвращает массив опций для построения постраничной навигации
* Необходимо дергать сразу после выполнения SQL-запроса с SQL_CAL_FOUND_ROWS
*
* @param array $options - Массив опций
*
* @return object
*/
function getPaginator($options = array())
{
$Paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Null($this->_db->fetchOne('SELECT FOUND_ROWS()')));
$Paginator->setItemCountPerPage(isset($options['perpage']) ? $options['perpage'] : $this->getPerPage());
if (isset($options['widgetid'])) {
$Paginator->setCurrentPageNumber($this->getCurrentPage($options['widgetid']));
} else {
$Paginator->setCurrentPageNumber($this->getCurrentPage());
}
$out = $Paginator->getPages();
$pageidentity = $this->getPageIdentity();
// Кроме стандартных параметров Zend_Paginator::getPages() возвращаем доп. параметры
// Полный путь без GET-запроса
$UrlInfo = parse_url($this->_request->getRequestUri());
$out->ClearUrl = $UrlInfo['path'];
// Обрабатываем GET-запрос
$query = $this->_request->getQuery();
if (isset($query[$pageidentity])) {
unset($query[$pageidentity]);
}
if (isset($query['widget'])) {
unset($query['widget']);
}
// Строим строку выражения
if (!empty($query)) {
$out->Query = http_build_query($query);
}
// Фактически, ссылку на первую страницу (без page и widget)
$out->FullUrl = isset($out->Query) ? $out->ClearUrl . '?' . $out->Query : $out->ClearUrl;
// Добавляем к выражению Id виджета
$widget = isset($options['widgetid']) ? 'widget=' . (int) $options['widgetid'] . '&' : '';
// Полную ссылку к которой в конце надо только добавить номер страницы
$out->PageUrl = isset($out->Query) ? $out->FullUrl . '&' . $widget . $pageidentity . '=' : $out->FullUrl . '?' . $widget . $pageidentity . '=';
return $out;
}
示例3: geraTagXml
private static function geraTagXml($type)
{
$request = new \Zend_Controller_Request_Http();
$arrRequest = explode('/', $request->getRequestUri());
if (!empty($arrRequest[3])) {
$rota = (string) $arrRequest[1] . '/' . $arrRequest[2] . '/' . $arrRequest[3];
} else {
$rota = (string) $arrRequest[1] . '/' . $arrRequest[2];
}
$xml = "<schema>";
$xml .= "<nome>corporativo</nome>";
$xml .= "<rota>{$rota}</rota>";
$xml .= "<tabela>";
foreach ($type as $key => $value) {
$nomeTabela = self::converteString($key);
$xml .= "<nome>" . $nomeTabela . "</nome>";
foreach ($value as $k => $v) {
if (!is_array($v) && !is_object($v)) {
$xml .= "<coluna>";
$palavraConvertida = self::converteString($k);
$v = self::procuraData($palavraConvertida) ? self::converteData($v) : $v;
$xml .= "<nome>" . $palavraConvertida . "</nome>";
$xml .= "<valor>" . $v . "</valor>";
$xml .= "</coluna>";
}
}
}
$xml .= "</tabela>";
$xml .= "</schema>";
return $xml;
}
示例4: insertBadRequest
public function insertBadRequest(Zend_Controller_Request_Http $request)
{
$updateService = new FFR_Service_Update();
if ($updateService->currentSchemaVersion('tools') >= 5) {
$this->_getRedirectLogGateway()->create(array('redirect_log_source' => $request->getRequestUri()))->save();
}
}
示例5: 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'));
}
示例6: match
public function match(Zend_Controller_Request_Http $request)
{
$sku = substr($request->getRequestUri(), 10);
$productID = Mage::getModel('catalog/product')->getIdBySku($sku);
// $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);
// echo $product->getName()."<br>";
// echo "<img src='".$product->getImageUrl()."' />";
// die();
$request->setModuleName('catalog')->setControllerName('product')->setActionName('view')->setParam('id', $productID);
return true;
}
示例7: init
/**
* 重載 繼承的 YUN_Controller_Action init 方法
*
*/
public function init()
{
parent::init();
$http = new Zend_Controller_Request_Http();
if (!$this->auth->isAllow('index.access')) {
if ($this->auth->isLogined()) {
$this->view->feedback(array('message' => '对不起,您没有权限执行该操作!', 'redirect' => $this->view->url(array('module' => 'default', 'controller' => 'user', 'action' => 'login')), 'linktext' => '点击继续'));
} else {
$this->view->Feedback(array('title' => '发生错误', 'message' => '对不起,您尚未登录', 'linktext' => '点击前往登录页面', 'redirect' => $this->view->url(array('module' => 'default', 'controller' => 'user', 'action' => 'login')) . '?u=' . urlencode('http://' . $http->getHttpHost() . $http->getRequestUri())));
}
}
$this->config = Zend_Registry::get('config');
}
示例8: languageswitcher
public function languageswitcher($clslang = "")
{
$t = new Zend_Controller_Request_Http();
$url = $t->getRequestUri();
$url = explode("?", $url);
if (count($url) > 0) {
$uri = $url[0];
} else {
$uri = $url;
}
$this->view->languages = Languages::getActiveLanguageList();
$this->view->clslang = $clslang;
$this->view->uri = $uri;
return $this->view->render('partials/languageswitcher.phtml');
}
示例9: canonicalizeRequestUrl
/**
* Canonicalizes the request URL based on the given link URL. Canonicalization will
* only happen when requesting an HTML page, as it is primarily an SEO benefit.
*
* A response exception will be thrown is redirection is required.
*
* @param string $linkUrl
*/
public function canonicalizeRequestUrl($linkUrl)
{
if ($this->getResponseType() != 'html') {
return;
}
if (!$this->_request->isGet()) {
return;
}
$linkUrl = strval($linkUrl);
if (strlen($linkUrl) == 0) {
return;
}
if ($linkUrl[0] == '.') {
$linkUrl = substr($linkUrl, 1);
}
$basePath = $this->_request->getBasePath();
$requestUri = $this->_request->getRequestUri();
if (substr($requestUri, 0, strlen($basePath)) != $basePath) {
return;
}
$routeBase = substr($requestUri, strlen($basePath));
if (isset($routeBase[0]) && $routeBase[0] === '/') {
$routeBase = substr($routeBase, 1);
}
if (preg_match('#^([^?]*\\?[^=&]*)(&(.*))?$#U', $routeBase, $match)) {
$requestUrlPrefix = $match[1];
$requestParams = isset($match[3]) ? $match[3] : false;
} else {
$parts = explode('?', $routeBase);
$requestUrlPrefix = $parts[0];
$requestParams = isset($parts[1]) ? $parts[1] : false;
}
if (preg_match('#^([^?]*\\?[^=&]*)(&(.*))?$#U', $linkUrl, $match)) {
$linkUrlPrefix = $match[1];
//$linkParams = isset($match[3]) ? $match[3] : false;
} else {
$parts = explode('?', $linkUrl);
$linkUrlPrefix = $parts[0];
//$linkParams = isset($parts[1]) ? $parts[1]: false;
}
if (urldecode($requestUrlPrefix) != urldecode($linkUrlPrefix)) {
$redirectUrl = $linkUrlPrefix;
if ($requestParams !== false) {
$redirectUrl .= (strpos($redirectUrl, '?') === false ? '?' : '&') . $requestParams;
}
throw $this->responseException($this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL_PERMANENT, $redirectUrl));
}
}
示例10: languageswitcher
public function languageswitcher()
{
$ns = new Zend_Session_Namespace('Admin');
$t = new Zend_Controller_Request_Http();
$url = $t->getRequestUri();
$url = explode("?", $url);
if (count($url) > 0) {
$uri = $url[0];
} else {
$uri = $url;
}
$this->view->languages = Languages::getActiveLanguageList();
$this->view->uri = $uri;
$this->view->langselected = $ns->lang;
return $this->view->render('partials/switcher.phtml');
}
示例11: logAdminRequest
public function logAdminRequest(Zend_Controller_Request_Http $request, array $requestData = null, $ipAddress = null)
{
$baseUrl = $request->getBaseUrl();
$requestUri = $request->getRequestUri();
if (substr($requestUri, 0, strlen($baseUrl)) == $baseUrl) {
$routeBase = substr($requestUri, strlen($baseUrl));
$routeBase = preg_replace('/^\\?/', '', $routeBase);
} else {
$routeBase = $requestUri;
}
if ($requestData === null) {
$requestData = $this->_filterAdminLogRequestData($_POST);
}
$ipAddress = XenForo_Helper_Ip::getBinaryIp(null, $ipAddress, '');
$this->_getDb()->insert('xf_admin_log', array('request_date' => XenForo_Application::$time, 'user_id' => XenForo_Visitor::getUserId(), 'ip_address' => $ipAddress, 'request_url' => $routeBase, 'request_data' => json_encode($requestData)));
}
示例12: getRoutePath
/**
* Gets the path the to be routed based on the URL of the request
*
* @param Zend_Controller_Request_Http Request object
*
* @return string Routing path
*/
public function getRoutePath(Zend_Controller_Request_Http $request)
{
$baseUrl = $request->getBaseUrl();
$requestUri = $request->getRequestUri();
$result = null;
if (substr($requestUri, 0, strlen($baseUrl)) == $baseUrl) {
$routeBase = substr($requestUri, strlen($baseUrl));
if (preg_match('#^/([^?]+)(\\?|$)#U', $routeBase, $match)) {
// rewrite approach (starts with /). Must be non-empty rewrite up to query string.
$result = urldecode($match[1]);
} else {
if (preg_match('#\\?([^=&]+)(&|$)#U', $routeBase, $match)) {
// query string approach. Must start with non-empty, non-named param.
$result = urldecode($match[1]);
}
}
}
if ($result === null) {
$namedRouteVar = $request->getParam('_');
if ($namedRouteVar !== null && is_string($namedRouteVar)) {
$result = $namedRouteVar;
}
}
if ($result !== null) {
return ltrim($result, '/');
}
return '';
}
示例13: testStrippingHttpProtocolHostAndNonStandardPortFromRequestUriOnlyWhenPresentAtBeginningOfUri
/**
* @group ZF-3161
* @group ZFI-233
* @group ZF-5818
*/
public function testStrippingHttpProtocolHostAndNonStandardPortFromRequestUriOnlyWhenPresentAtBeginningOfUri()
{
$_SERVER['REQUEST_URI'] = 'http://foo.example.com:8888/foo/bar?r=http://foo.example.com:8888/bar/baz';
$_SERVER['HTTP_HOST'] = '';
$_SERVER['SERVER_NAME'] = 'foo.example.com';
$_SERVER['SERVER_PORT'] = '8888';
$request = new Zend_Controller_Request_Http();
$test = $request->getRequestUri();
$this->assertEquals('/foo/bar?r=http://foo.example.com:8888/bar/baz', $test);
$_SERVER['REQUEST_URI'] = '/foo/bar?r=https://foo.example.com:8888/bar/baz';
$_SERVER['HTTP_HOST'] = '';
$_SERVER['SERVER_NAME'] = 'foo.example.com';
$_SERVER['SERVER_PORT'] = '8888';
$request = new Zend_Controller_Request_Http();
$test = $request->getRequestUri();
$this->assertEquals('/foo/bar?r=https://foo.example.com:8888/bar/baz', $test);
}
示例14: getRequestPaths
/**
* Gets the request paths from the specified request object.
*
* @param Zend_Controller_Request_Http $request
*
* @return array Keys: basePath, host, protocol, fullBasePath, requestUri
*/
public static function getRequestPaths(Zend_Controller_Request_Http $request)
{
$basePath = $request->getBasePath();
if ($basePath === '' || substr($basePath, -1) != '/') {
$basePath .= '/';
}
$host = $request->getServer('HTTP_HOST');
if (!$host) {
$host = $request->getServer('SERVER_NAME');
$serverPort = intval($request->getServer('SERVER_PORT'));
if ($serverPort && $serverPort != 80 && $serverPort != 443) {
$host .= ':' . $serverPort;
}
}
$protocol = $request->isSecure() ? 'https' : 'http';
$requestUri = $request->getRequestUri();
return array('basePath' => $basePath, 'host' => $host, 'protocol' => $protocol, 'fullBasePath' => $protocol . '://' . $host . $basePath, 'requestUri' => $requestUri, 'fullUri' => $protocol . '://' . $host . $requestUri);
}
示例15: logReroute
/**
* Log a message showing a reroute.
*
* @param Zend_Controller_Request_Http $request
* @param Zend_Config|array $rerouteTo where to reroute the request to
* @return void
*/
public static function logReroute(Zend_Controller_Request_Http $request, $rerouteTo, $reason)
{
if ($rerouteTo instanceof Zend_Config) {
$reroute = $rerouteTo->toArray();
} else {
$reroute = $rerouteTo;
}
self::log('Reroute from URI: ' . $request->getRequestUri() . ' (' . $request->getModuleName() . '/' . $request->getControllerName() . '/' . $request->getActionName() . '/' . ') to: ' . $reroute['moduleName'] . '/' . $reroute['controllerName'] . '/' . $reroute['actionName'] . " Reason: {$reason}");
}