1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-26 11:40:48 +03:00

Для задания правил вывода блоков добавлен параметр path. В конфигурации приведен пример - вывод блоков на записях блогов.

Исправлены некоторые ошибки в работе анализатора правил js\css файлов.
This commit is contained in:
Alexey Kachayev 2009-10-15 22:13:16 +00:00
parent bbb77bdfaa
commit 111db4bf45
2 changed files with 28 additions and 8 deletions

View file

@ -285,8 +285,12 @@ $config['router']['config']['action_not_found'] = 'error';
* Настройки вывода блоков
*/
$config['block']['rule_index_blog'] = array(
'path' => array(
$config['path']['root']['web'].'/blog/*/*\.html$',
$config['path']['root']['web'].'/blog/*\.html$',
),
'action' => array(
'index' => array('index'), 'blog',
'index' => array('index'),
),
'blocks' => array(
'right' => array('stream','tags','blogs'=>array('params'=>array(),'priority'=>1))

View file

@ -453,11 +453,11 @@ class LsViewer extends Module {
*/
if(!array_key_exists('blocks',$aRule)) continue;
/**
* Если не задан action для исполнения,
* Если не задан action для исполнения и нет ни одного шаблона path,
* или текущий не входит в перечисленные в правиле
* то выбираем следующее правило
*/
if(!$aRule['action']) continue;
if(!$aRule['action'] && !$aRule['path']) continue;
if(in_array($sAction, (array)$aRule['action'])) $bUse=true;
if(array_key_exists($sAction,(array)$aRule['action'])) {
/**
@ -483,6 +483,24 @@ class LsViewer extends Module {
}
}
}
/**
* Если не найдено совпадение по паре Action/Event,
* переходим к поиску по regexp путей.
*/
if(!$bUse && $aRule['path']) {
$sPath = rtrim(Router::GetPathWebCurrent(),"/");
/**
* Проверяем последовательно каждый regexp
*/
foreach((array)$aRule['path'] as $sRulePath) {
$sPattern = "~".str_replace(array('/','*'),array('\/','\w+'), $sRulePath)."~";
if(preg_match($sPattern, $sPath)) {
$bUse=true;
break 1;
}
}
}
if($bUse){
/**
@ -604,9 +622,7 @@ class LsViewer extends Module {
* @return bool
*/
protected function BuildHeadFiles() {
$aPath = Router::GetPathWebCurrent();
$aPath = rtrim($aPath,"/")."/";
$sPath = Router::GetPathWebCurrent();
/**
* По умолчанию имеем дефаултовые настройки
*/
@ -616,8 +632,8 @@ class LsViewer extends Module {
if(!$aRule['path']) continue;
foreach((array)$aRule['path'] as $sRulePath) {
$sPattern = "~".str_replace(array('/','*'),array('\/','[\w+]'), $sRulePath)."~";
if(preg_match($sPattern, $aPath)) {
$sPattern = "~".str_replace(array('/','*'),array('\/','\w+'), $sRulePath)."~";
if(preg_match($sPattern, $sPath)) {
/**
* Преобразование JS
*/