本文整理汇总了PHP中AdminHelper::getRewriteRules方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminHelper::getRewriteRules方法的具体用法?PHP AdminHelper::getRewriteRules怎么用?PHP AdminHelper::getRewriteRules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdminHelper
的用法示例。
在下文中一共展示了AdminHelper::getRewriteRules方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRealPath
/**
* Returns script filename by URL
*
* @param string $site Site ID.
* @param string $url URL.
* @return string|null
*/
public static function getRealPath($site, $url)
{
$docRoot = rtrim(\Bitrix\Main\SiteTable::getDocumentRoot($site), '/');
$url = str_replace('\\', '/', $url);
$url = \CHTTP::urnEncode($url);
$uri = new \Bitrix\Main\Web\Uri($url);
$path = \CHTTP::urnDecode($uri->getPath());
if (substr($path, -1, 1) == '/') {
$path .= 'index.php';
}
$file = new \Bitrix\Main\IO\File($docRoot . $path);
if ($file->isExists()) {
return substr($file->getPath(), strlen($docRoot));
}
if ($rewriteRules = AdminHelper::getRewriteRules($site)) {
$pathQuery = \CHTTP::urnDecode($uri->getPathQuery());
foreach ($rewriteRules as &$item) {
if (preg_match($item['CONDITION'], $pathQuery)) {
$url = empty($item['PATH']) && !empty($item['RULE']) ? preg_replace($item['CONDITION'], $item['RULE'], $pathQuery) : $item['PATH'];
$url = \CHTTP::urnEncode($url);
$uri = new \Bitrix\Main\Web\Uri($url);
$path = \CHTTP::urnDecode($uri->getPath());
$file = new \Bitrix\Main\IO\File($docRoot . $path);
if ($file->isExists()) {
$pathTmp = str_replace('.', '', strtolower(ltrim($path, '/\\')));
$pathTmp7 = substr($pathTmp, 0, 7);
if ($pathTmp7 == 'upload/' || $pathTmp7 == 'bitrix/') {
continue;
}
if ($file->getExtension() != 'php') {
continue;
}
return substr($file->getPath(), strlen($docRoot));
}
}
}
}
return null;
}