本文整理汇总了PHP中Mage_Core_Controller_Request_Http::getRequestString方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Controller_Request_Http::getRequestString方法的具体用法?PHP Mage_Core_Controller_Request_Http::getRequestString怎么用?PHP Mage_Core_Controller_Request_Http::getRequestString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Controller_Request_Http
的用法示例。
在下文中一共展示了Mage_Core_Controller_Request_Http::getRequestString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetRequestString
public function testGetRequestString()
{
$this->assertEmpty($this->_model->getRequestString());
$this->_model->setRequestUri('test');
$this->_model->setPathInfo();
$this->assertEquals('test', $this->_model->getRequestString());
}
示例2: getSearchQuery
/**
* @param Mage_Core_Controller_Request_Http $request
*
* @return string $query
*/
private function getSearchQuery(Mage_Core_Controller_Request_Http $request)
{
$maxQueryLength = (int) Mage::getStoreConfig('catalog/search/max_query_length') > 0 ? (int) Mage::getStoreConfig('catalog/search/max_query_length') : 128;
$query = preg_replace('/(\\W|html|php)+/', ' ', $request->getRequestString());
if (count($request->getQuery()) > 0) {
$query .= implode(' ', $request->getQuery());
}
return substr($query, 0, $maxQueryLength);
}
示例3: isAllowed
/**
* Checks whether route/controller action is allowed to be reached depending on initializer state
*
* @param Mage_Core_Controller_Request_Http $request
* @return bool
*/
public function isAllowed(Mage_Core_Controller_Request_Http $request)
{
if ($this->isDataCollected()) {
return true;
}
if (count($this->_restrictions) == 1) {
$initializerAclNode = Mage::getConfig()->getNode('default/xcom/initializer_acl');
if ($initializerAclNode) {
$this->_restrictions += $initializerAclNode->asArray();
}
}
$parts = array('module' => str_replace('_adminhtml', '', strtolower($request->getControllerModule())), 'controller' => strtolower($request->getControllerName()), 'action' => strtolower($request->getActionName()), 'urn' => trim(strtolower($request->getRequestString()), '/'));
$moduleParts = explode('_', $parts['module']);
$parts['namespace'] = $moduleParts[0];
$this->_currentMatch = array('scopeWeight' => 0, 'directionWeight' => 2, 'urn' => '');
foreach ($this->_restrictions as $issuer => $rules) {
if ($issuer != '*') {
if (!Mage::getResourceModel('xcom_initializer/job')->hasJobsLeft($issuer)) {
continue;
}
}
foreach (array('allowed', 'denied') as $direction) {
if (empty($rules[$direction])) {
continue;
}
foreach ($rules[$direction] as $scope => $values) {
if (!is_array($values)) {
Mage::log(printf('Invalid configuration for scope node %s', $scope));
continue;
}
foreach ($values as $value) {
$value = strtolower(is_array($value) ? current($value) : $value);
$hasMatched = false;
if (empty($value)) {
Mage::log(printf('Empty node inside scope %s', $scope));
continue;
}
switch (strtolower($scope)) {
case 'namespace':
if ('denied' == $direction) {
$hasMatched = $value == $parts['namespace'];
} else {
Mage::log('<namespace> node allowed in <denied> section only');
}
break;
case 'action':
case 'controller':
$pattern = '(?P<module>.+)/(?P<controller>.+)';
$scopes = array('module', 'controller');
if ('action' == $scope) {
$pattern .= '::(?P<action>.+)';
$scopes[] = 'action';
}
if (preg_match('#' . $pattern . '#', $value, $matches)) {
// Split value into module and controller (and action, if it's 'action' rule)
$hasMatched = true;
foreach ($scopes as $_scope) {
if (!in_array($matches[$_scope], array('*', $parts[$_scope]))) {
// Value part doesn't match corresponding part of current request or '*'
$hasMatched = false;
break;
}
}
} else {
Mage::log(printf('Invalid action/controller definition: %s. Allowed pattern: namespace_module/controller::action', $value));
}
break;
case 'module':
$hasMatched = $value == $parts['module'];
break;
case 'urn':
$value = trim($value, '/');
$hasMatched = 0 === strpos($parts['urn'], $value);
break;
default:
Mage::log(printf('Unknown rule scope: %s', $scope));
}
if ($hasMatched) {
$this->_matched($scope, $direction, 'urn' == $scope ? $value : '');
}
}
}
}
}
return $this->_isAllowed();
}
示例4: _applyCustomMaxAgeFromDb
/**
* Apply custom Cache-Control: max-age from db
*
* @param Mage_Core_Controller_Request_Http $request
* @param Mage_Core_Controller_Response_Http $response
*/
protected function _applyCustomMaxAgeFromDb(Mage_Core_Controller_Request_Http $request, Mage_Core_Controller_Response_Http $response)
{
if (!$this->messagesToShow) {
// apply custom max-age from db
$urls = array($request->getRequestString());
$alias = $request->getAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS);
if ($alias) {
$urls[] = $alias;
}
/** @var $customUrlModel Aoe_Static_Model_CustomUrl */
$customUrlModel = Mage::getModel('aoestatic/customUrl');
$customUrlModel->setStoreId(Mage::app()->getStore()->getId());
$customUrlModel->loadByRequestPath($urls);
if ($customUrlModel->getId() && $customUrlModel->getMaxAge()) {
$response->setHeader('Cache-Control', 'max-age=' . (int) $customUrlModel->getMaxAge(), true);
$response->setHeader('X-Magento-Lifetime', (int) $customUrlModel->getMaxAge(), true);
$response->setHeader('aoestatic', 'cache', true);
}
}
}