本文整理汇总了PHP中Zend_Controller_Request_Abstract::getPathInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Abstract::getPathInfo方法的具体用法?PHP Zend_Controller_Request_Abstract::getPathInfo怎么用?PHP Zend_Controller_Request_Abstract::getPathInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Request_Abstract
的用法示例。
在下文中一共展示了Zend_Controller_Request_Abstract::getPathInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: route
/**
* Find a matching route to the current PATH_INFO and inject
* returning values to the Request object.
* @param Zend_Controller_Request_Abstract $request
* @return Zend_Controller_Request_Abstract
* @throws Zend_Controller_Router_Exception
*/
public function route(Zend_Controller_Request_Abstract $request)
{
if ($this->_useDefaultRoutes) {
$this->addDefaultRoutes();
}
// Find the matching route
$routeMatched = false;
foreach (array_reverse($this->_routes, true) as $name => $route) {
if (method_exists($route, 'isAbstract') && $route->isAbstract()) {
continue;
}
if (!method_exists($route, 'getVersion') || $route->getVersion() == 1) {
$match = $request->getPathInfo();
} else {
$match = $request;
}
if ($params = $route->match($match)) {
$this->_setRequestParams($request, $params);
$this->_currentRoute = $name;
$routeMatched = true;
break;
}
}
if (!$routeMatched) {
require_once 'Zend/Controller/Router/Exception.php';
throw new Zend_Controller_Router_Exception('No route matched the request', 404);
}
if ($this->_useCurrentParamsAsGlobal) {
$params = $request->getParams();
foreach ($params as $param => $value) {
$this->setGlobalParam($param, $value);
}
}
return $request;
}
示例2: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
// Kiem tra neu chua dang nhap thi bo qua
$identity = Digitalus_Auth::getIdentity();
if (!$identity) {
return;
}
////////////////////////////////////////
// $this->_cache = ZendX_Cache_Manager::getInstance();
$this->_cache = Digitalus_Cache_Manager::getInstance();
// La la cac phuong thuc khac get() no se khong lay tu content tu cache ra
if (!$request->isGet()) {
self::$doNotCache = true;
return;
}
$module = $request->getModuleName();
$controller = $request->getControllerName();
$action = $request->getActionName();
$path = $request->getPathInfo();
// co loi o day , xem link de biet cach sua
$this->_key = md5($path);
$this->_keyTags = array($module, "{$module}_{$controller}", "{$module}_{$controller}_{$action}");
if (false !== ($data = $this->getCache())) {
$response = $this->getResponse();
$response->setBody($data['default']);
$response->sendResponse();
exit;
}
}
示例3: preDispatch
public function preDispatch(AbstractRequest $request)
{
if ($request->module === 'default' && $request->controller === 'auth') {
return;
}
$frontController = FrontController::getInstance();
$bootstrap = $frontController->getParam('bootstrap');
$serviceManager = $bootstrap->getResource('ServiceManager');
$authService = $serviceManager->get('Zend\\Authentication\\AuthenticationService');
if (!$authService->hasIdentity()) {
$response = $this->getResponse();
$currentUri = sprintf('%s://%s%s%s', $request->getScheme(), $request->getHttpHost(), $request->getBaseUrl(), $request->getPathInfo());
$adapter = $authService->getAdapter();
$adapter->setLoginParameters(array('service' => $currentUri));
// Assume user is back here from a CAS authentication
if ($request->getQuery('ticket')) {
$adapter->setServiceValidateParameters(array('service' => $currentUri, 'ticket' => $request->getQuery('ticket')));
// Validate the ticket
$result = $authService->authenticate();
if (!$result->isValid()) {
$response->setRedirect($adapter->createLoginUri());
}
// Assume the user just got here
} else {
$response->setRedirect($adapter->createLoginUri());
}
}
}
示例4: routeShutdown
/**
* routeShutdown
* 在 路由器 完成请求的路由后被调用
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
/**
* 检测请求的Content-type类型
*/
$pathinfo = $request->getPathInfo();
if (!empty($pathinfo)) {
if ($extension = pathinfo($pathinfo, PATHINFO_EXTENSION)) {
if (preg_match('/^[-a-z0-9]+$/i', $extension)) {
$request->setParam(static::KEY_EXT, strtolower($extension));
}
}
}
/**
* 检测是否支持json响应
*/
if ($request->getParam(static::KEY_EXT) == '') {
$accept = $request->getServer('HTTP_ACCEPT');
if (!empty($accept)) {
if (strpos($accept, 'json') !== false) {
$request->setParam(static::KEY_EXT, 'json');
}
}
}
/**
* 格式化请求目标信息,不允许[-a-zA-Z0-9]以外的字符
*/
$pattern = '/[^-a-zA-Z0-9].*/';
$request->setModuleName(preg_replace($pattern, '', $request->getModuleName()));
$request->setControllerName(preg_replace($pattern, '', $request->getControllerName()));
$request->setActionName(preg_replace($pattern, '', $request->getActionName()));
}
示例5: routeStartup
/**
* routeStartup
* 在 路由器 完成请求的路由前被调用
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
// Do nothing...
return;
$hostname = $request->getHttpHost();
$pathinfo = $request->getPathInfo();
/**
* 根据二级域名检测请求的模块
*/
if (!empty($hostname)) {
$segments = explode('.', $hostname);
if (isset($segments[2])) {
$segmentNum = count($segments);
$rootDomain = $segments[$segmentNum - 2] . '.' . $segments[$segmentNum - 1];
if ($rootDomain === parse_url(URL_FTT, PHP_URL_HOST)) {
$subDomain2 = $segments[$segmentNum - 3];
if (array_key_exists($subDomain2, static::$_subDomain2ModuleMap)) {
$module = static::$_subDomain2ModuleMap[$subDomain2];
$hostel = explode('/', trim($pathinfo, '/'));
$hostel = trim(array_shift($hostel));
if ($hostel != '') {
$this->getResponse()->setRedirect(URL_FTT . '/' . $module . '/?' . static::KEY_INN . '=' . $hostel)->sendResponse();
exit;
}
}
}
}
}
}
示例6: routeShutdown
/**
* Sets the application locale and translation based on the locale param, if
* one is not provided it defaults to english
*
* @param Zend_Controller_Request_Abstract $request
* @return Void
*/
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
$config = Zend_Registry::get('config');
$frontController = Zend_Controller_Front::getInstance();
$params = $request->getParams();
$registry = Zend_Registry::getInstance();
// Steps setting the locale.
// 1. Default language is set in config
// 2. TLD in host header
// 3. Locale params specified in request
$locale = $registry->get('Zend_Locale');
// Check host header TLD.
$tld = preg_replace('/^.*\\./', '', $request->getHeader('Host'));
// Provide a list of tld's and their corresponding default languages
$tldLocales = $frontController->getParam('tldLocales');
if (is_array($tldLocales) && array_key_exists($tld, $tldLocales)) {
// The TLD in the request matches one of our specified TLD -> Locales
$locale->setLocale(strtolower($tldLocales[$tld]));
} elseif (isset($params['locale'])) {
// There is a locale specified in the request params.
$locale->setLocale(strtolower($params['locale']));
}
// Now that our locale is set, let's check which language has been selected
// and try to load a translation file for it.
$language = $locale->getLanguage();
$translate = Garp_I18n::getTranslateByLocale($locale);
Zend_Registry::set('Zend_Translate', $translate);
Zend_Form::setDefaultTranslator($translate);
if (!$config->resources->router->locale->enabled) {
return;
}
$path = '/' . ltrim($request->getPathInfo(), '/\\');
// If the language is in the path, then we will want to set the baseUrl
// to the specified language.
$langIsInUrl = preg_match('/^\\/' . $language . '\\/?/', $path);
$uiDefaultLangIsInUrl = false;
$uiDefaultLanguage = false;
if (isset($config->resources->locale->uiDefault)) {
$uiDefaultLanguage = $config->resources->locale->uiDefault;
$uiDefaultLangIsInUrl = preg_match('/^\\/' . $uiDefaultLanguage . '\\/?/', $path);
}
if ($langIsInUrl || $uiDefaultLangIsInUrl) {
if ($uiDefaultLangIsInUrl) {
$frontController->setBaseUrl($frontController->getBaseUrl() . '/' . $uiDefaultLanguage);
} else {
$frontController->setBaseUrl($frontController->getBaseUrl() . '/' . $language);
}
} elseif (!empty($config->resources->router->locale->enabled) && $config->resources->router->locale->enabled) {
$redirectUrl = '/' . $language . $path;
if ($frontController->getRouter()->getCurrentRouteName() === 'admin' && !empty($config->resources->locale->adminDefault)) {
$adminDefaultLanguage = $config->resources->locale->adminDefault;
$redirectUrl = '/' . $adminDefaultLanguage . $path;
} elseif ($uiDefaultLanguage) {
$redirectUrl = '/' . $uiDefaultLanguage . $path;
}
$this->getResponse()->setRedirect($redirectUrl, 301);
}
}
示例7: routeStartup
public function routeStartup(Zend_Controller_Request_Abstract $req)
{
$this->_time = microtime(true);
if ($req instanceof Zend_Controller_Request_Http) {
$this->_method = $req->getMethod();
$this->_path = $req->getPathInfo();
}
$this->_request = $req;
}
示例8: routeStartup
/**
* @param \Zend_Controller_Request_Abstract $request
*/
public function routeStartup(\Zend_Controller_Request_Abstract $request)
{
// this is a filter which checks for common used files (by browser, crawlers, ...) and prevent the default
// error page, because this is more resource-intensive than exiting right here
$found = false;
foreach (self::$files as $pattern) {
if (preg_match($pattern, $request->getPathInfo())) {
$found = true;
break;
}
}
if ($found) {
if ($request->getPathInfo() == "/robots.txt") {
// check for site
try {
$domain = Tool::getHostname();
$site = Site::getByDomain($domain);
} catch (\Exception $e) {
}
$siteSuffix = "";
if ($site instanceof Site) {
$siteSuffix = "-" . $site->getId();
}
// send correct headers
header("Content-Type: text/plain; charset=utf8");
while (@ob_end_flush()) {
}
// check for configured robots.txt in pimcore
$robotsPath = PIMCORE_CONFIGURATION_DIRECTORY . "/robots" . $siteSuffix . ".txt";
if (is_file($robotsPath)) {
readfile($robotsPath);
} else {
echo "User-agent: *\nDisallow:";
// default behavior
}
exit;
}
// if no other rule matches, exit anyway with a 404, to prevent the error page to be shown
header('HTTP/1.1 404 Not Found');
echo "HTTP/1.1 404 Not Found\nFiltered by common files filter";
exit;
}
}
示例9: _secureUrl
/**
* Check the request to see if it is secure. If it isn't
* rebuild a secure url, redirect and exit.
*
* @param Zend_Controller_Request_Abstract $request
* @return void
* @author Travis Boudreaux
*/
protected function _secureUrl(Zend_Controller_Request_Abstract $request)
{
$server = $request->getServer();
$hostname = $server['HTTP_HOST'];
if (!$request->isSecure()) {
//url scheme is not secure so we rebuild url with secureScheme
$url = Zend_Controller_Request_Http::SCHEME_HTTPS . "://" . $hostname . $request->getPathInfo();
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$redirector->setGoToUrl($url);
$redirector->redirectAndExit();
}
}
示例10: _forwardLogin
protected function _forwardLogin(Zend_Controller_Request_Abstract $request)
{
$request->setModuleName('kwf_controller_action_user');
$request->setControllerName('login');
$request->setDispatched(false);
if (substr($request->getActionName(), 0, 4) == 'json') {
$request->setActionName('json-login');
} else {
$params = array('location' => $request->getBaseUrl() . '/' . ltrim($request->getPathInfo(), '/'));
$request->setParams($params);
$request->setActionName('index');
}
}
示例11: dispatchLoopStartup
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
$response = $this->getResponse();
$url = parse_url($_SERVER['REQUEST_URI']);
$res = DOMAIN_PATH . $request->getPathInfo();
if ($request->controller == 'categories' & $request->action == 'catlist' || $request->controller == 'search' & $request->action == 'beginsearch') {
$s_url = DOMAIN_PATH . $url['path'] . (isset($url['query']) ? '?' . $url['query'] : '');
$n_url = glob_makeUrlFromCookie(glob_makeBaseUrl(array('search', 'extended')));
// echo $n_url.'-'.$s_url; exit;
if ($s_url !== $n_url) {
$response->setRedirect($n_url);
}
}
}
示例12: preDispatch
/**
* Called before an action is dispatched by Zend_Controller_Dispatcher.
*
* This callback allows for proxy or filter behavior. By altering the
* request and resetting its dispatched flag (via
* {@link Zend_Controller_Request_Abstract::setDispatched() setDispatched(false)}),
* the current action may be skipped.
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
// reset role & resource
Zend_Registry::set('Role', 'guest');
Zend_Registry::set('Resource', '');
// check if ErrorHandler wasn't fired
if ($request->getParam('error_handler')) {
return;
}
$module = $request->getModuleName();
$controller = $request->getControllerName();
$action = $request->getActionName();
$pathInfo = $request->getPathInfo();
$allow = false;
if ($this->_auth->hasIdentity()) {
$userId = $this->_auth->getIdentity();
$roleId = $this->_auth->getRoleId();
$rolesList = $this->_em->find('Roles', $roleId);
$roleName = $rolesList->getRoleName();
$role = new Zend_Acl_Role($roleName);
} else {
$roleName = 'guest';
$role = new Zend_Acl_Role($roleName);
}
$resource = $action == '' ? trim($controller) . '/index' : trim($controller) . '/' . trim($action);
$resource = $module == 'default' ? $resource : $module . "/" . $resource;
// on main page resource might be empty
if ($resource == '') {
$resource = 'index/index';
}
// if resource not exist in db then check permission for controller
if (!$this->_acl->has($resource) && $action != '') {
$resource = trim($controller);
}
// check if user is allowed to see the page
$allow = $this->_acl->isAllowed($role, $resource);
if ($allow == false && $this->_auth->hasIdentity()) {
// user logged in but denied permission
$request->setModuleName('default');
$request->setControllerName('error');
$request->setActionName('forbidden');
/* $this->_response->setHeader('Content-type', 'text/html');
$this->_response->setHttpResponseCode(403);
$this->_response->setBody('<h1>403 - Forbidden</h1>');
$this->_response->sendResponse(); */
}
Zend_Registry::set('Role', $role);
Zend_Registry::set('Resource', $resource);
}
示例13: route
/**
* Find a matching route to the current PATH_INFO and inject
* returning values to the Request object.
*
* @throws Zend_Controller_Router_Exception
* @return Zend_Controller_Request_Abstract Request object
*/
public function route(Zend_Controller_Request_Abstract $request)
{
if (($curRouteName = $this->_currentRoute) != null) {
$route = $this->getRoute($curRouteName);
if (!method_exists($route, 'getVersion') || $route->getVersion() == 1) {
$match = $request->getPathInfo();
} else {
$match = $request;
}
if ($params = $route->match($match)) {
$this->_setRequestParams($request, $params);
return $request;
}
}
return parent::route($request);
}
示例14: dispatchLoopStartup
/**
* Start caching
*
* Determine if we have a cache hit. If so, return the response; else,
* start caching.
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
if (!$request->isGet()) {
self::$_disableCache = true;
return;
}
$path = $request->getPathInfo();
$this->_key = md5($path);
$response = Zrt_Cache::load($this->_key);
if (false !== $response) {
$response->sendResponse();
if (!$this->_suppressExit) {
exit;
}
}
}
示例15: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$controller = strtolower($request->getControllerName());
$action = strtolower($request->getActionName());
$route = $controller . '/' . $action;
if (in_array($route, $this->_whitelist)) {
return;
}
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
return;
}
$request->setDispatched(false);
$request->setControllerName('user');
$request->setActionName('login');
$request->setParam('next_uri', $request->getPathInfo());
}