Browse Source

Fixes

pull/3/head
M@dD3n 5 years ago
parent
commit
470ea6bb4c
  1. 2
      admin/lang/ru/sysblocks.txt
  2. 83
      admin/sysblocks.php
  3. 2
      admin/templates/request/form.tpl
  4. 2
      admin/templates/sysblocks/form.tpl
  5. 0
      admin/templates/sysblocks/form_visual.tpl
  6. 30
      admin/templates/sysblocks/list.tpl
  7. 0
      admin/templates/sysblocks/multi.tpl
  8. 0
      admin/templates/sysblocks/nav.tpl
  9. 8
      class/class.docs.php
  10. 368
      class/class.sysblocks.php

2
admin/lang/ru/sysblocks.txt

@ -76,4 +76,4 @@ SYSBLOCK_ER_SYN = "Неверный алиас!<br> Алиас не долже
SYSBLOCK_ER_EXISTS = "Неверный алиас!<br> Данный алиас уже привязан к другоому системному блоку" SYSBLOCK_ER_EXISTS = "Неверный алиас!<br> Данный алиас уже привязан к другоому системному блоку"
// v 3.25 // v 3.25
SYSBLOCK_EVAL = "Выполнять PHP перед выозвращением результата" SYSBLOCK_EVAL = "Выполнять PHP перед возвращением результата"

83
admin/sysblocks.php

@ -20,109 +20,74 @@
global $AVE_DB, $AVE_Template; global $AVE_DB, $AVE_Template;
require(BASE_DIR . '/class/class.sysblocks.php'); require(BASE_DIR . '/class/class.sysblocks.php');
$AVE_SysBlock = new AVE_SysBlock;
new Sysblocks;
$AVE_Template->config_load(BASE_DIR . '/admin/lang/' . $_SESSION['admin_language'] . '/sysblocks.txt', 'sysblocks'); $AVE_Template->config_load(BASE_DIR . '/admin/lang/' . $_SESSION['admin_language'] . '/sysblocks.txt', 'sysblocks');
switch ($_REQUEST['action']) switch ($_REQUEST['action'])
{ {
// Список системных блоков
case '': case '':
if (check_permission_acp('sysblocks_view')) if (check_permission_acp('sysblocks_view'))
{ {
$AVE_SysBlock->sys_blockList(); Sysblocks::startPage();
}
break;
// Список групп системных блоков
case 'groups':
if (check_permission_acp('sysblocks_view'))
{
Sysblocks::listGroups();
} }
break; break;
// Создать новый системный блок
case 'new': case 'new':
if (check_permission_acp('sysblocks_edit')) if (check_permission_acp('sysblocks_edit'))
{ {
$AVE_SysBlock->sys_blockNew(); Sysblocks::newBlock();
} }
break; break;
// Редактировать системный блок
case 'edit': case 'edit':
if (check_permission_acp('sysblocks_edit')) if (check_permission_acp('sysblocks_edit'))
{ {
$AVE_SysBlock->sys_blockEdit(isset($_REQUEST['id']) ? $_REQUEST['id'] : null); Sysblocks::editBlock();
} }
break; break;
// Сохранить системный блок
case 'save': case 'save':
if (check_permission_acp('sysblocks_edit')) if (check_permission_acp('sysblocks_edit'))
{ {
$AVE_SysBlock->sys_blockSave(isset($_REQUEST['id']) ? $_REQUEST['id'] : null); Sysblocks::saveBlock();
} }
break; break;
// Удалить системный блок
case 'del': case 'del':
if (check_permission_acp('sysblocks_edit')) if (check_permission_acp('sysblocks_edit'))
{ {
$AVE_SysBlock->sys_blockDelete($_REQUEST['id']); Sysblocks::delBlock();
} }
break; break;
// Проверка алиаса
case 'alias': case 'alias':
if (check_permission_acp('sysblocks_edit')) if (check_permission_acp('sysblocks_edit'))
{ {
echo $AVE_SysBlock->sys_blockValidate($_REQUEST['alias'], (int)$_REQUEST['id']); echo Sysblocks::aliasValidate($_REQUEST['alias'], (int)$_REQUEST['id']);
} }
exit; exit;
// Копирование системного блока
case 'multi': case 'multi':
if (check_permission_acp('sysblocks_edit')) if (check_permission_acp('sysblocks_edit'))
{ {
$_REQUEST['sub'] = (!isset($_REQUEST['sub'])) ? '' : $_REQUEST['sub']; //
$errors = array();
switch ($_REQUEST['sub'])
{
case 'save':
$ok = true;
$row = $AVE_DB->Query("
SELECT sysblock_name
FROM " . PREFIX . "_sysblocks
WHERE sysblock_name = '" . $_REQUEST['sysblock_name'] . "'
")->FetchRow();
if (@$row->sysblock_name != '')
{
array_push($errors, $AVE_Template->get_config_vars('SYSBLOCK_EXIST'));
$AVE_Template->assign('errors', $errors);
$ok = false;
}
if ($_REQUEST['sysblock_name'] == '')
{
array_push($errors, $AVE_Template->get_config_vars('SYSBLOCK_COPY_TIP'));
$AVE_Template->assign('errors', $errors);
$ok = false;
}
if ($ok)
{
$row = $AVE_DB->Query("
SELECT sysblock_text
FROM " . PREFIX . "_sysblocks
WHERE id = '" . (int)$_REQUEST['id'] . "'
")->FetchRow();
$AVE_DB->Query("
INSERT
INTO " . PREFIX . "_sysblocks
SET
Id = '',
sysblock_name = '" . $_REQUEST['sysblock_name'] . "',
sysblock_text = '" . addslashes($row->sysblock_text) . "',
sysblock_author_id = '" . $_SESSION['user_id'] . "',
sysblock_created = '" . time() . "'
");
reportLog($_SESSION['user_name'] . ' - создал копию системного блока (' . (int)$_REQUEST['id'] . ')', 2, 2);
header('Location:index.php?do=sysblocks'.'&cp=' . SESSION);
}
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/multi.tpl'));
break;
}
} }
} }
?> ?>

2
admin/templates/request/form.tpl

@ -142,7 +142,7 @@ function changeRub(select) {ldelim}
<div class="pr12"> <div class="pr12">
<input type="text" name="request_alias" value="{if $smarty.request.Id != ''}{$row->request_alias}{else}{$smarty.request.request_alias}{/if}" id="request_alias" value="" class="mousetrap" data-accept="{#REQUEST_ACCEPT#}" data-error-syn="{#REQUEST_ER_SYN#}" data-error-exists="{#REQUEST_ER_EXISTS#}" placeholder="{#REQUEST_ALIAS#}" maxlength="20" style="width: 200px;" autocomplete="off" />&nbsp; <input type="text" name="request_alias" value="{if $smarty.request.Id != ''}{$row->request_alias}{else}{$smarty.request.request_alias}{/if}" id="request_alias" value="" class="mousetrap" data-accept="{#REQUEST_ACCEPT#}" data-error-syn="{#REQUEST_ER_SYN#}" data-error-exists="{#REQUEST_ER_EXISTS#}" placeholder="{#REQUEST_ALIAS#}" maxlength="20" style="width: 200px;" autocomplete="off" />&nbsp;
<input type="text" id="request_alias_tag" value="[tag:request:{if $smarty.request.Id != ''}{if $row->request_alias != ''}{$row->request_alias}{else}{$smarty.request.Id}{/if}{else}{$smarty.request.request_alias}{/if}]" readonly size="40" class="mousetrap" style="width: 200px;" /> <input type="text" id="request_alias_tag" value="[tag:request:{if $smarty.request.Id != ''}{if $row->request_alias != ''}{$row->request_alias}{else}{$smarty.request.Id}{/if}{else}{$smarty.request.request_alias}{/if}]" readonly size="40" class="mousetrap" style="width: 200px;" />
<a style="text-align: center; padding: 5px 3px 4px 3px;" class="whiteBtn copyBtn" href="javascript:void(0);" data-clipboard-action="copy" data-clipboard-target="#sysblock_alias_tag"> <a style="text-align: center; padding: 5px 3px 4px 3px;" class="whiteBtn copyBtn" href="javascript:void(0);" data-clipboard-action="copy" data-clipboard-target="#request_alias_tag">
<img style="margin-top: -3px; position: relative; top: 4px; padding: 0 3px;" class="clippy" src="{$ABS_PATH}admin/templates/images/clippy.svg" width="13"> <img style="margin-top: -3px; position: relative; top: 4px; padding: 0 3px;" class="clippy" src="{$ABS_PATH}admin/templates/images/clippy.svg" width="13">
</a> </a>
</div> </div>

2
admin/templates/sysblocks/form.tpl

@ -249,7 +249,7 @@
{if $smarty.request.action != 'new'} {if $smarty.request.action != 'new'}
<script language="javascript"> <script language="javascript">
var sett_options = {ldelim} var sett_options = {ldelim}
url: 'index.php?do=sysblocks&action=save&cp={$sess}&ajax=1', url: 'index.php?do=sysblocks&action=save&cp={$sess}',
dataType: 'json', dataType: 'json',
beforeSubmit: Request, beforeSubmit: Request,
success: Response success: Response

0
admin/templates/sysblocks/form_visual.tpl

30
admin/templates/sysblocks/list.tpl

@ -42,7 +42,7 @@
<h5>{#SYSBLOCK_EDIT#}</h5> <h5>{#SYSBLOCK_EDIT#}</h5>
</div> </div>
<div class="widget" style="margin-top: 0px;"> <div class="widget" style="margin-top: 0;">
<div class="body"> <div class="body">
{#SYSBLOCK_EDIT_TIP#} {#SYSBLOCK_EDIT_TIP#}
</div> </div>
@ -57,6 +57,28 @@
</div> </div>
</div> </div>
<div class="widgets">
<table class="first tableButtons" cellpadding="0" cellspacing="0" width="100%" id="sysblocksButtons">
<col width="25%">
<col width="25%">
<col width="25%">
<col width="25%">
<tr>
<td>
<a class="button basicBtn topBtn" href="index.php?do=modules&action=modedit&mod=basket&moduleaction=basket_history&cp={$sess}">1</a>
</td>
<td>
<a class="button basicBtn topBtn" href="index.php?do=modules&action=modedit&mod=basket&moduleaction=basket_coupon&cp={$sess}">2</a>
</td>
<td>
<a class="button basicBtn topBtn" href="index.php?do=modules&action=modedit&mod=basket&moduleaction=basket_settings&cp={$sess}">3</a>
</td>
<td>
<a class="button basicBtn topBtn" href="index.php?do=modules&action=modedit&mod=basket&moduleaction=templates&cp={$sess}">4</a>
</td>
</tr>
</table>
</div>
<div class="widget first"> <div class="widget first">
<ul class="tabs"> <ul class="tabs">
@ -81,7 +103,7 @@
<col width="20"> <col width="20">
<col width="20"> <col width="20">
{if $sys_blocks} {if $sysblocks}
<thead> <thead>
<tr> <tr>
<td>{#SYSBLOCK_ID#}</td> <td>{#SYSBLOCK_ID#}</td>
@ -97,7 +119,7 @@
</thead> </thead>
<tbody> <tbody>
{foreach from=$sys_blocks item=sysblock} {foreach from=$sysblocks item=sysblock}
<tr id="tr{$sysblock->id}"> <tr id="tr{$sysblock->id}">
<td align="center">{$sysblock->id}</td> <td align="center">{$sysblock->id}</td>
<td align="center">{if $sysblock->sysblock_external}<a class="icon_sprite ico_globus topDir" title="{#SYSBLOCK_EXTERNAL_GO#}" href="http://{$smarty.server.HTTP_HOST}/?sysblock={if $sysblock->sysblock_alias}{$sysblock->sysblock_alias}{else}{$sysblock->id}{/if}" target="_blank"></a>{else}<span class="icon_sprite ico_globus_no"></span>{/if}</td> <td align="center">{if $sysblock->sysblock_external}<a class="icon_sprite ico_globus topDir" title="{#SYSBLOCK_EXTERNAL_GO#}" href="http://{$smarty.server.HTTP_HOST}/?sysblock={if $sysblock->sysblock_alias}{$sysblock->sysblock_alias}{else}{$sysblock->id}{/if}" target="_blank"></a>{else}<span class="icon_sprite ico_globus_no"></span>{/if}</td>
@ -120,7 +142,7 @@
<td align="center">{$sysblock->sysblock_author_id|escape}</td> <td align="center">{$sysblock->sysblock_author_id|escape}</td>
<td align="center"> <td align="center">
<span class="date_text dgrey">{$sysblock->sysblock_created|date_format:$TIME_FORMAT|translate_date}</span> <span class="date_text dgrey">{$sysblock->sysblock_created|date_format:$TIME_FORMAT|pretty_date}</span>
</td> </td>
<td> <td>

0
admin/templates/sysblocks/multi.tpl

0
admin/templates/sysblocks/nav.tpl

8
class/class.docs.php

@ -327,7 +327,7 @@
$sql_where_field = ''; $sql_where_field = '';
$field_link = ''; $field_link = '';
if ($_REQUEST['field_id'] && (int)$_REQUEST['field_id'] > 0) if (isset($_REQUEST['field_id']) && (int)$_REQUEST['field_id'] > 0)
{ {
$sql_join_field = " $sql_join_field = "
LEFT JOIN LEFT JOIN
@ -340,7 +340,7 @@
df1.document_id = df2.document_id df1.document_id = df2.document_id
"; ";
if ($_REQUEST['field_request'] == 'eq') if ($_REQUEST['field_request'] == 'eq' && $_REQUEST['field_search'] != '')
{ {
$sql_where_field = " $sql_where_field = "
AND AND
@ -351,7 +351,7 @@
df1.field_number_value = '" . mb_strtoupper($_REQUEST['field_search']) . "')) df1.field_number_value = '" . mb_strtoupper($_REQUEST['field_search']) . "'))
"; ";
} }
else if ($_REQUEST['field_request'] == 'like') else if ($_REQUEST['field_request'] == 'like' && $_REQUEST['field_search'] != '')
{ {
$sql_where_field = " $sql_where_field = "
AND AND
@ -391,9 +391,7 @@
$fields = array(); $fields = array();
while($row = $sql->FetchRow()) while($row = $sql->FetchRow())
{
array_push($fields, $row); array_push($fields, $row);
}
$AVE_Template->assign('fields', $fields); $AVE_Template->assign('fields', $fields);
} }

368
class/class.sysblocks.php

@ -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; global $AVE_DB;
@ -23,63 +28,279 @@
if (empty ($alias) || preg_match('/^[A-Za-z0-9-_]{1,20}$/i', $alias) !== 1 || is_numeric($alias)) if (empty ($alias) || preg_match('/^[A-Za-z0-9-_]{1,20}$/i', $alias) !== 1 || is_numeric($alias))
return 'syn'; return 'syn';
//-- Уникальность $sql = "
return !(bool)$AVE_DB->Query(" SELECT
SELECT 1 1
FROM FROM
" . PREFIX . "_sysblocks " . PREFIX . "_sysblocks
WHERE WHERE
sysblock_alias = '" . $alias . "' sysblock_alias = '" . $alias . "'
AND AND
id != '" . $id . "' id != '" . $id . "'
")->GetCell(); ";
//-- Уникальность
return !(bool)$AVE_DB->Query($sql)->GetCell();
} }
/**
* Вывод списка системных блоков /*
|--------------------------------------------------------------------------------------
| startPage
|--------------------------------------------------------------------------------------
|
| Гланая страница
|
*/ */
function sys_blockList () public static function startPage()
{ {
global $AVE_DB, $AVE_Template; 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 SELECT
* *
FROM FROM
" . PREFIX . "_sysblocks " . PREFIX . "_sysblocks
ORDER BY ORDER BY
id 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); $row->sysblock_author_id = get_username_by_id($row->sysblock_author_id);
array_push($sys_blocks, $row); array_push($sys_blocks, $row);
} }
$AVE_Template->assign('sid', 0); $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')); $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; 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)) if (is_numeric($sysblock_id))
{ {
$_REQUEST['sysblock_external'] = (isset($_REQUEST['sysblock_external'])) ? $_REQUEST['sysblock_external'] : 0; $_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_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_visual'] = (isset($_REQUEST['sysblock_visual'])) ? $_REQUEST['sysblock_visual'] : 0;
$_REQUEST['sysblock_alias'] = isset($_REQUEST['sysblock_alias']) ? $_REQUEST['sysblock_alias'] : ''; $_REQUEST['sysblock_alias'] = isset($_REQUEST['sysblock_alias']) ? $_REQUEST['sysblock_alias'] : '';
@ -112,7 +333,7 @@
$theme = 'accept'; $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)"); 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); 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 |--------------------------------------------------------------------------------------
* | delBlock
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'));
}
}
/**
* Создание системного блока
*/ */
function sys_blockNew () public static function delBlock ()
{ {
global $AVE_DB, $AVE_Template; global $AVE_DB, $AVE_Template;
$row['sysblock_name'] = ''; $sysblock_id = $_REQUEST['id'];
$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;
if (is_numeric($sysblock_id)) if (is_numeric($sysblock_id))
{ {
$row = $AVE_DB->Query(" $sysblock = $AVE_DB->Query("
SELECT SELECT
* *
FROM 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); 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; $from_id = BASE_DIR . '/tmp/cache/sql/sysblocks/' . $id;
rrmdir($from_id); rrmdir($from_id);

Loading…
Cancel
Save