|
|
|
@ -10,12 +10,17 @@
|
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
class AVE_SysBlock |
|
|
|
|
class Sysblocks |
|
|
|
|
{ |
|
|
|
|
/** |
|
|
|
|
* Проверка алиаса тега на валидность и уникальность |
|
|
|
|
/* |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| aliasValidate |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| |
|
|
|
|
| Проверка алиаса на валидность и уникальность |
|
|
|
|
| |
|
|
|
|
*/ |
|
|
|
|
function sys_blockValidate ($alias = '', $id = 0) |
|
|
|
|
public static function aliasValidate ($alias = '', $id = 0) |
|
|
|
|
{ |
|
|
|
|
global $AVE_DB; |
|
|
|
|
|
|
|
|
@ -23,63 +28,279 @@
|
|
|
|
|
if (empty ($alias) || preg_match('/^[A-Za-z0-9-_]{1,20}$/i', $alias) !== 1 || is_numeric($alias)) |
|
|
|
|
return 'syn'; |
|
|
|
|
|
|
|
|
|
//-- Уникальность |
|
|
|
|
return !(bool)$AVE_DB->Query(" |
|
|
|
|
SELECT 1 |
|
|
|
|
$sql = " |
|
|
|
|
SELECT |
|
|
|
|
1 |
|
|
|
|
FROM |
|
|
|
|
" . PREFIX . "_sysblocks |
|
|
|
|
WHERE |
|
|
|
|
sysblock_alias = '" . $alias . "' |
|
|
|
|
AND |
|
|
|
|
id != '" . $id . "' |
|
|
|
|
")->GetCell(); |
|
|
|
|
"; |
|
|
|
|
|
|
|
|
|
//-- Уникальность |
|
|
|
|
return !(bool)$AVE_DB->Query($sql)->GetCell(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Вывод списка системных блоков |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| startPage |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| |
|
|
|
|
| Гланая страница |
|
|
|
|
| |
|
|
|
|
*/ |
|
|
|
|
function sys_blockList () |
|
|
|
|
public static function startPage() |
|
|
|
|
{ |
|
|
|
|
global $AVE_DB, $AVE_Template; |
|
|
|
|
|
|
|
|
|
$sys_blocks = array(); |
|
|
|
|
//-- Группы |
|
|
|
|
$groups = []; |
|
|
|
|
|
|
|
|
|
$sql = $AVE_DB->Query(" |
|
|
|
|
$sql = " |
|
|
|
|
SELECT |
|
|
|
|
* |
|
|
|
|
FROM |
|
|
|
|
" . PREFIX . "_sysblocks_groups |
|
|
|
|
ORDER BY |
|
|
|
|
position ASC |
|
|
|
|
"; |
|
|
|
|
|
|
|
|
|
$query = $AVE_DB->Query($sql); |
|
|
|
|
|
|
|
|
|
while ($row = $query->FetchAssocArray()) |
|
|
|
|
{ |
|
|
|
|
$row['count'] = 0; |
|
|
|
|
$groups[$row['id']] = $row; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//-- Блоки |
|
|
|
|
$sysblocks = []; |
|
|
|
|
|
|
|
|
|
$sql = " |
|
|
|
|
SELECT |
|
|
|
|
a.*, |
|
|
|
|
a.sysblock_group_id |
|
|
|
|
FROM |
|
|
|
|
" . PREFIX . "_sysblocks AS a |
|
|
|
|
LEFT JOIN |
|
|
|
|
" . PREFIX . "_sysblocks_groups AS b |
|
|
|
|
ON a.sysblock_group_id = b.id |
|
|
|
|
ORDER BY |
|
|
|
|
b.position ASC, a.id ASC |
|
|
|
|
"; |
|
|
|
|
|
|
|
|
|
$query = $AVE_DB->Query($sql); |
|
|
|
|
|
|
|
|
|
while ($row = $query->FetchAssocArray()) |
|
|
|
|
{ |
|
|
|
|
$row['author'] = get_username_by_id($row['sysblock_author_id']); |
|
|
|
|
$sysblocks[$row['sysblock_group_id']][] = $row; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach ($sysblocks AS $_k => $_v) |
|
|
|
|
{ |
|
|
|
|
if ($_k == 0) |
|
|
|
|
{ |
|
|
|
|
$groups[$_k]['position'] = 0; |
|
|
|
|
$groups[$_k]['title'] = 'Без группы'; |
|
|
|
|
$groups[$_k]['description'] = 'Описание отсутсвует'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$groups[$_k]['count'] = count($sysblocks[$_k]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Debug::_echo($sysblocks, true); |
|
|
|
|
//Debug::_echo($groups, true); |
|
|
|
|
$AVE_Template->assign('groups', $groups); |
|
|
|
|
$AVE_Template->assign('sysblocks', $sysblocks); |
|
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/start.tpl')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| listBlocks |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| |
|
|
|
|
| Список системных блоков |
|
|
|
|
| |
|
|
|
|
*/ |
|
|
|
|
public static function listBlocks() |
|
|
|
|
{ |
|
|
|
|
global $AVE_DB, $AVE_Template; |
|
|
|
|
|
|
|
|
|
$sysblocks = []; |
|
|
|
|
|
|
|
|
|
$sql = " |
|
|
|
|
SELECT |
|
|
|
|
* |
|
|
|
|
FROM |
|
|
|
|
" . PREFIX . "_sysblocks |
|
|
|
|
ORDER BY |
|
|
|
|
id |
|
|
|
|
"); |
|
|
|
|
"; |
|
|
|
|
|
|
|
|
|
$query = $AVE_DB->Query($sql); |
|
|
|
|
|
|
|
|
|
// Формируем массив из полученных данных |
|
|
|
|
while ($row = $sql->FetchRow()) |
|
|
|
|
while ($row = $query->FetchRow()) |
|
|
|
|
{ |
|
|
|
|
$row->sysblock_author_id = get_username_by_id($row->sysblock_author_id); |
|
|
|
|
array_push($sys_blocks, $row); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$AVE_Template->assign('sid', 0); |
|
|
|
|
$AVE_Template->assign('sys_blocks', $sys_blocks); |
|
|
|
|
$AVE_Template->assign('sysblocks', $sysblocks); |
|
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/list.tpl')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Сохранение системного блока |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| listGroups |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| |
|
|
|
|
| Список групп системных блоков |
|
|
|
|
| |
|
|
|
|
*/ |
|
|
|
|
public static function listGroups() |
|
|
|
|
{ |
|
|
|
|
global $AVE_DB, $AVE_Template; |
|
|
|
|
|
|
|
|
|
$groups = []; |
|
|
|
|
|
|
|
|
|
$sql = " |
|
|
|
|
SELECT |
|
|
|
|
* |
|
|
|
|
* @param int $sysblock_id идентификатор системного блока |
|
|
|
|
FROM |
|
|
|
|
" . PREFIX . "_sysblocks_groups |
|
|
|
|
ORDER BY |
|
|
|
|
id |
|
|
|
|
"; |
|
|
|
|
|
|
|
|
|
$query = $AVE_DB->Query($sql); |
|
|
|
|
|
|
|
|
|
// Формируем массив из полученных данных |
|
|
|
|
while ($row = $query->FetchAssocArray()) |
|
|
|
|
array_push($groups, $row); |
|
|
|
|
|
|
|
|
|
$AVE_Template->assign('sid', 0); |
|
|
|
|
$AVE_Template->assign('groups', $groups); |
|
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/groups.tpl')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| newBlock |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| |
|
|
|
|
| Создание системного блока |
|
|
|
|
| |
|
|
|
|
*/ |
|
|
|
|
function sys_blockSave ($sysblock_id = null) |
|
|
|
|
public static function newBlock () |
|
|
|
|
{ |
|
|
|
|
global $AVE_Template; |
|
|
|
|
|
|
|
|
|
$row['sysblock_name'] = ''; |
|
|
|
|
$row['sysblock_alias'] = ''; |
|
|
|
|
$row['sysblock_text'] = ''; |
|
|
|
|
$row['sysblock_visual'] = (isset($_REQUEST['sysblock_visual']) && $_REQUEST['sysblock_visual'] != 0) ? $_REQUEST['sysblock_visual'] : ''; |
|
|
|
|
|
|
|
|
|
$AVE_Template->assign('sid', 0); |
|
|
|
|
|
|
|
|
|
if ((isset($_REQUEST['sysblock_visual']) && $_REQUEST['sysblock_visual'] == 1) || $row['sysblock_visual'] == 1) |
|
|
|
|
{ |
|
|
|
|
$oCKeditor = new CKeditor(); |
|
|
|
|
$oCKeditor->returnOutput = true; |
|
|
|
|
$oCKeditor->config['customConfig'] = 'sysblock.js'; |
|
|
|
|
$oCKeditor->config['toolbar'] = 'Big'; |
|
|
|
|
$oCKeditor->config['height'] = 400; |
|
|
|
|
$config = array(); |
|
|
|
|
$row['sysblock_text'] = $oCKeditor->editor('sysblock_text', $row['sysblock_text'], $config); |
|
|
|
|
|
|
|
|
|
$AVE_Template->assign($row); |
|
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/form_visual.tpl')); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
$AVE_Template->assign($row); |
|
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/form.tpl')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| editBlock |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| |
|
|
|
|
| Редактирование системного блока |
|
|
|
|
| |
|
|
|
|
*/ |
|
|
|
|
public static function editBlock () |
|
|
|
|
{ |
|
|
|
|
global $AVE_DB, $AVE_Template; |
|
|
|
|
|
|
|
|
|
$sysblock_id = (int)$_REQUEST['id']; |
|
|
|
|
|
|
|
|
|
$row = $AVE_DB->Query(" |
|
|
|
|
SELECT |
|
|
|
|
* |
|
|
|
|
FROM |
|
|
|
|
" . PREFIX . "_sysblocks |
|
|
|
|
WHERE |
|
|
|
|
id = '" . $sysblock_id . "' |
|
|
|
|
")->FetchAssocArray(); |
|
|
|
|
|
|
|
|
|
$AVE_Template->assign('sid', $sysblock_id); |
|
|
|
|
|
|
|
|
|
if ((isset($_REQUEST['sysblock_visual']) && $_REQUEST['sysblock_visual'] == 1) || $row['sysblock_visual'] == 1) |
|
|
|
|
{ |
|
|
|
|
$oCKeditor = new CKeditor(); |
|
|
|
|
$oCKeditor->returnOutput = true; |
|
|
|
|
$oCKeditor->config['customConfig'] = 'sysblock.js'; |
|
|
|
|
$oCKeditor->config['toolbar'] = 'Big'; |
|
|
|
|
$oCKeditor->config['height'] = 400; |
|
|
|
|
$config = array(); |
|
|
|
|
$row['sysblock_text'] = $oCKeditor->editor('sysblock_text', $row['sysblock_text'], $config); |
|
|
|
|
|
|
|
|
|
$AVE_Template->assign($row); |
|
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/form_visual.tpl')); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
$AVE_Template->assign($row); |
|
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/form.tpl')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| editBlock |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| |
|
|
|
|
| Сохранение системного блока |
|
|
|
|
| |
|
|
|
|
*/ |
|
|
|
|
public static function saveBlock() |
|
|
|
|
{ |
|
|
|
|
global $AVE_DB, $AVE_Template; |
|
|
|
|
|
|
|
|
|
$sysblock_id = $_REQUEST['id'] |
|
|
|
|
? (int)$_REQUEST['id'] |
|
|
|
|
: null; |
|
|
|
|
|
|
|
|
|
if (is_numeric($sysblock_id)) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
$_REQUEST['sysblock_external'] = (isset($_REQUEST['sysblock_external'])) ? $_REQUEST['sysblock_external'] : 0; |
|
|
|
|
$_REQUEST['sysblock_eval'] = (isset($_REQUEST['sysblock_eval'])) ? $_REQUEST['sysblock_eval'] : 0; |
|
|
|
|
$_REQUEST['sysblock_ajax'] = (isset($_REQUEST['sysblock_ajax'])) ? $_REQUEST['sysblock_ajax'] : 0; |
|
|
|
|
$_REQUEST['sysblock_eval'] = (isset($_REQUEST['sysblock_eval'])) ? $_REQUEST['sysblock_eval'] : 0; |
|
|
|
|
$_REQUEST['sysblock_visual'] = (isset($_REQUEST['sysblock_visual'])) ? $_REQUEST['sysblock_visual'] : 0; |
|
|
|
|
$_REQUEST['sysblock_alias'] = isset($_REQUEST['sysblock_alias']) ? $_REQUEST['sysblock_alias'] : ''; |
|
|
|
|
|
|
|
|
@ -112,7 +333,7 @@
|
|
|
|
|
$theme = 'accept'; |
|
|
|
|
|
|
|
|
|
//-- Стираем кеш сисблока |
|
|
|
|
$this->clearCache($sysblock_id, $_REQUEST['sysblock_alias']); |
|
|
|
|
self::clearCache($sysblock_id, $_REQUEST['sysblock_alias']); |
|
|
|
|
|
|
|
|
|
//-- Сохраняем системное сообщение в журнал |
|
|
|
|
reportLog($AVE_Template->get_config_vars('SYSBLOCK_SQLUPDATE') . " (" . stripslashes($_REQUEST['sysblock_name']) . ") (id: $sysblock_id)"); |
|
|
|
@ -160,93 +381,24 @@
|
|
|
|
|
header('Location:index.php?do=sysblocks&action=edit&&id=' . $sysblock_id . '&cp=' . SESSION); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Редактирование системного блока |
|
|
|
|
* |
|
|
|
|
* @param int $sysblock_id идентификатор системного блока |
|
|
|
|
*/ |
|
|
|
|
function sys_blockEdit ($sysblock_id) |
|
|
|
|
{ |
|
|
|
|
global $AVE_DB, $AVE_Template; |
|
|
|
|
|
|
|
|
|
$row = $AVE_DB->Query(" |
|
|
|
|
SELECT |
|
|
|
|
* |
|
|
|
|
FROM |
|
|
|
|
" . PREFIX . "_sysblocks |
|
|
|
|
WHERE |
|
|
|
|
id = '" . $sysblock_id . "' |
|
|
|
|
")->FetchAssocArray(); |
|
|
|
|
|
|
|
|
|
$AVE_Template->assign('sid', $sysblock_id); |
|
|
|
|
|
|
|
|
|
if ((isset($_REQUEST['sysblock_visual']) && $_REQUEST['sysblock_visual'] == 1) || $row['sysblock_visual'] == 1) |
|
|
|
|
{ |
|
|
|
|
$oCKeditor = new CKeditor(); |
|
|
|
|
$oCKeditor->returnOutput = true; |
|
|
|
|
$oCKeditor->config['customConfig'] = 'sysblock.js'; |
|
|
|
|
$oCKeditor->config['toolbar'] = 'Big'; |
|
|
|
|
$oCKeditor->config['height'] = 400; |
|
|
|
|
$config = array(); |
|
|
|
|
$row['sysblock_text'] = $oCKeditor->editor('sysblock_text', $row['sysblock_text'], $config); |
|
|
|
|
|
|
|
|
|
$AVE_Template->assign($row); |
|
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/form_visual.tpl')); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
$AVE_Template->assign($row); |
|
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/form.tpl')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Создание системного блока |
|
|
|
|
/* |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| delBlock |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| |
|
|
|
|
| Удаление системного блока |
|
|
|
|
| |
|
|
|
|
*/ |
|
|
|
|
function sys_blockNew () |
|
|
|
|
public static function delBlock () |
|
|
|
|
{ |
|
|
|
|
global $AVE_DB, $AVE_Template; |
|
|
|
|
|
|
|
|
|
$row['sysblock_name'] = ''; |
|
|
|
|
$row['sysblock_alias'] = ''; |
|
|
|
|
$row['sysblock_text'] = ''; |
|
|
|
|
$row['sysblock_eval'] = '1'; |
|
|
|
|
$row['sysblock_visual'] = (isset($_REQUEST['sysblock_visual']) && $_REQUEST['sysblock_visual'] != 0) ? $_REQUEST['sysblock_visual'] : ''; |
|
|
|
|
|
|
|
|
|
$AVE_Template->assign('sid', 0); |
|
|
|
|
|
|
|
|
|
if ((isset($_REQUEST['sysblock_visual']) && $_REQUEST['sysblock_visual'] == 1) || $row['sysblock_visual'] == 1) |
|
|
|
|
{ |
|
|
|
|
$oCKeditor = new CKeditor(); |
|
|
|
|
$oCKeditor->returnOutput = true; |
|
|
|
|
$oCKeditor->config['customConfig'] = 'sysblock.js'; |
|
|
|
|
$oCKeditor->config['toolbar'] = 'Big'; |
|
|
|
|
$oCKeditor->config['height'] = 400; |
|
|
|
|
$config = array(); |
|
|
|
|
$row['sysblock_text'] = $oCKeditor->editor('sysblock_text', $row['sysblock_text'], $config); |
|
|
|
|
|
|
|
|
|
$AVE_Template->assign($row); |
|
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/form_visual.tpl')); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
$AVE_Template->assign($row); |
|
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/form.tpl')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Удаление системного блока |
|
|
|
|
* |
|
|
|
|
* @param int $sysblock_id идентификатор системного блока |
|
|
|
|
*/ |
|
|
|
|
function sys_blockDelete ($sysblock_id) |
|
|
|
|
{ |
|
|
|
|
global $AVE_DB, $AVE_Template; |
|
|
|
|
$sysblock_id = $_REQUEST['id']; |
|
|
|
|
|
|
|
|
|
if (is_numeric($sysblock_id)) |
|
|
|
|
{ |
|
|
|
|
$row = $AVE_DB->Query(" |
|
|
|
|
$sysblock = $AVE_DB->Query(" |
|
|
|
|
SELECT |
|
|
|
|
* |
|
|
|
|
FROM |
|
|
|
@ -263,17 +415,25 @@
|
|
|
|
|
"); |
|
|
|
|
|
|
|
|
|
//-- Стираем кеш сисблока |
|
|
|
|
$this->clearCache($sysblock_id, $row->sysblock_alias); |
|
|
|
|
self::clearCache($sysblock_id, $sysblock->sysblock_alias); |
|
|
|
|
|
|
|
|
|
//-- Сохраняем системное сообщение в журнал |
|
|
|
|
reportLog($AVE_Template->get_config_vars('SYSBLOCK_SQLDEL') . " (" . stripslashes($row->sysblock_name) . ") (id: $sysblock_id)"); |
|
|
|
|
reportLog($AVE_Template->get_config_vars('SYSBLOCK_SQLDEL') . " (" . stripslashes($sysblock->sysblock_name) . ") (id: $sysblock_id)"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
header('Location:index.php?do=sysblocks&cp=' . SESSION); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function clearCache ($id, $alias = null) |
|
|
|
|
/* |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| editBlock |
|
|
|
|
|-------------------------------------------------------------------------------------- |
|
|
|
|
| |
|
|
|
|
| Очистка кеша системного блока |
|
|
|
|
| |
|
|
|
|
*/ |
|
|
|
|
public static function clearCache ($id, $alias = null) |
|
|
|
|
{ |
|
|
|
|
$from_id = BASE_DIR . '/tmp/cache/sql/sysblocks/' . $id; |
|
|
|
|
rrmdir($from_id); |
|
|
|
|