+
+ {#RUBRIK_FIELD_DEFAULT#} |
{#RUBRIK_FILED_TEMPLATE_DESCR#} |
-
+
+
+ |
+
+
+
|
+ INT, STRING, JSON |
|
DIV |
@@ -250,6 +253,7 @@ $(document).ready(function(){ldelim}
{rdelim});
{literal}
+ setTimeout(function(){editorrftdf.refresh();}, 20);
setTimeout(function(){editorrft.refresh();}, 20);
setTimeout(function(){editorrftr.refresh();}, 20);
setTimeout(function(){editorrftd.refresh();}, 20);
@@ -258,6 +262,7 @@ $(document).ready(function(){ldelim}
{rdelim});
-{include file="$codemirror_editor" conn_id="rftd" textarea_id='rubric_field_description' ctrls='$(".SaveEditFieldTemplate").trigger("click");' height=80}
-{include file="$codemirror_editor" conn_id="rft" textarea_id='rubric_field_template' ctrls='$(".SaveEditFieldTemplate").trigger("click");' height=130}
-{include file="$codemirror_editor" conn_id="rftr" textarea_id='rubric_field_template_request' ctrls='$(".SaveEditFieldTemplate").trigger("click");' height=130}
\ No newline at end of file
+{include file="$codemirror_editor" conn_id="rftd" textarea_id='rubric_field_description' ctrls='$(".SaveEditFieldTemplate").trigger("click");' height=120}
+{include file="$codemirror_editor" conn_id="rftdf" textarea_id='rubric_field_default' ctrls='$(".SaveEditFieldTemplate").trigger("click");' height=120}
+{include file="$codemirror_editor" conn_id="rft" textarea_id='rubric_field_template' ctrls='$(".SaveEditFieldTemplate").trigger("click");' height=180}
+{include file="$codemirror_editor" conn_id="rftr" textarea_id='rubric_field_template_request' ctrls='$(".SaveEditFieldTemplate").trigger("click");' height=180}
\ No newline at end of file
diff --git a/admin/templates/rubs/fields_list.tpl b/admin/templates/rubs/fields_list.tpl
index bd40329..8e48932 100644
--- a/admin/templates/rubs/fields_list.tpl
+++ b/admin/templates/rubs/fields_list.tpl
@@ -199,7 +199,7 @@ function openAliasWindow(fieldId, rubId, width, height, target) {ldelim}
|
-
+
|
{/foreach}
@@ -290,10 +290,9 @@ function openAliasWindow(fieldId, rubId, width, height, target) {ldelim}
-
+
-
[?] |
@@ -301,7 +300,6 @@ function openAliasWindow(fieldId, rubId, width, height, target) {ldelim}
{#RUBRIK_FIELD_NAME#} |
{#RUBRIK_FIELD_TYPE#} |
{#RUBRIK_FIELD_GROUP#} |
- {#RUBRIK_FIELD_DEFAULT#} |
@@ -328,11 +326,6 @@ function openAliasWindow(fieldId, rubId, width, height, target) {ldelim}
{/foreach}
-
-
-
-
- |
@@ -631,8 +624,7 @@ $(document).ready(function(){ldelim}
function resetForms(){ldelim}
$('#newfld').find('a.jqTransformCheckbox').removeClass('jqTransformChecked');
- $('#newfld').find('select').prop('selectedIndex',0);
- $('#newfld').find('select').trigger('refresh');
+ $('#newfld').find('input[type="checkbox"]').prop('checked', false).trigger('refresh');
$('#newfld input[type=text]').val('');
$('#newfld').trigger('refresh');
{rdelim}
diff --git a/admin/templates/settings/pagination_edit.tpl b/admin/templates/settings/pagination_edit.tpl
index 22cfae7..31dade3 100644
--- a/admin/templates/settings/pagination_edit.tpl
+++ b/admin/templates/settings/pagination_edit.tpl
@@ -28,8 +28,8 @@
{if check_permission('cache_thumb')}{#MAIN_STAT_CLEAR_THUMB#} {/if}
{if check_permission('document_revisions')}{#MAIN_STAT_CLEAR_REV#} {/if}
{if check_permission('gen_settings')}{#MAIN_STAT_CLEAR_COUNT#} {/if}
- {if check_permission('gen_settings_robots')}{#SETTINGS_FILE_ROBOTS#} {/if}
- {if check_permission('gen_settings_fcustom')}{#SETTINGS_FILE_CUSTOM#}{/if}
+ {if check_permission('gen_settings_robots')}{#SETTINGS_FILE_ROBOTS#} {/if}
+ {if check_permission('gen_settings_fcustom')}{#SETTINGS_FILE_CUSTOM#}{/if}
diff --git a/admin/templates/settings/settings_case.tpl b/admin/templates/settings/settings_case.tpl
index eec8f05..95f321e 100644
--- a/admin/templates/settings/settings_case.tpl
+++ b/admin/templates/settings/settings_case.tpl
@@ -22,8 +22,8 @@
{if check_permission('cache_thumb')}{#MAIN_STAT_CLEAR_THUMB#} {/if}
{if check_permission('document_revisions')}{#MAIN_STAT_CLEAR_REV#} {/if}
{if check_permission('gen_settings')}{#MAIN_STAT_CLEAR_COUNT#} {/if}
- {if check_permission('gen_settings_robots')}{#SETTINGS_FILE_ROBOTS#} {/if}
- {if check_permission('gen_settings_fcustom')}{#SETTINGS_FILE_CUSTOM#}{/if}
+ {if check_permission('gen_settings_robots')}{#SETTINGS_FILE_ROBOTS#} {/if}
+ {if check_permission('gen_settings_fcustom')}{#SETTINGS_FILE_CUSTOM#}{/if}
diff --git a/admin/templates/settings/settings_countries.tpl b/admin/templates/settings/settings_countries.tpl
index adadccf..e15702b 100644
--- a/admin/templates/settings/settings_countries.tpl
+++ b/admin/templates/settings/settings_countries.tpl
@@ -23,8 +23,8 @@
{if check_permission('cache_thumb')}{#MAIN_STAT_CLEAR_THUMB#} {/if}
{if check_permission('document_revisions')}{#MAIN_STAT_CLEAR_REV#} {/if}
{if check_permission('gen_settings')}{#MAIN_STAT_CLEAR_COUNT#} {/if}
- {if check_permission('gen_settings_robots')}{#SETTINGS_FILE_ROBOTS#} {/if}
- {if check_permission('gen_settings_fcustom')}{#SETTINGS_FILE_CUSTOM#}{/if}
+ {if check_permission('gen_settings_robots')}{#SETTINGS_FILE_ROBOTS#} {/if}
+ {if check_permission('gen_settings_fcustom')}{#SETTINGS_FILE_CUSTOM#}{/if}
diff --git a/admin/templates/settings/settings_lang.tpl b/admin/templates/settings/settings_lang.tpl
index 746fd77..eefb15b 100644
--- a/admin/templates/settings/settings_lang.tpl
+++ b/admin/templates/settings/settings_lang.tpl
@@ -22,8 +22,8 @@
{if check_permission('cache_thumb')}{#MAIN_STAT_CLEAR_THUMB#} {/if}
{if check_permission('document_revisions')}{#MAIN_STAT_CLEAR_REV#} {/if}
{if check_permission('gen_settings')}{#MAIN_STAT_CLEAR_COUNT#} {/if}
- {if check_permission('gen_settings_robots')}{#SETTINGS_FILE_ROBOTS#} {/if}
- {if check_permission('gen_settings_fcustom')}{#SETTINGS_FILE_CUSTOM#}{/if}
+ {if check_permission('gen_settings_robots')}{#SETTINGS_FILE_ROBOTS#} {/if}
+ {if check_permission('gen_settings_fcustom')}{#SETTINGS_FILE_CUSTOM#}{/if}
diff --git a/admin/templates/settings/settings_main.tpl b/admin/templates/settings/settings_main.tpl
index 9bdc8af..62844b4 100644
--- a/admin/templates/settings/settings_main.tpl
+++ b/admin/templates/settings/settings_main.tpl
@@ -23,8 +23,8 @@
{if check_permission('cache_thumb')}{#MAIN_STAT_CLEAR_THUMB#} {/if}
{if check_permission('document_revisions')}{#MAIN_STAT_CLEAR_REV#} {/if}
{if check_permission('gen_settings')}{#MAIN_STAT_CLEAR_COUNT#} {/if}
- {if check_permission('gen_settings_robots')}{#SETTINGS_FILE_ROBOTS#} {/if}
- {if check_permission('gen_settings_fcustom')}{#SETTINGS_FILE_CUSTOM#}{/if}
+ {if check_permission('gen_settings_robots')}{#SETTINGS_FILE_ROBOTS#} {/if}
+ {if check_permission('gen_settings_fcustom')}{#SETTINGS_FILE_CUSTOM#}{/if}
diff --git a/admin/templates/settings/settings_pagination.tpl b/admin/templates/settings/settings_pagination.tpl
index 8b4c20c..e7dc982 100644
--- a/admin/templates/settings/settings_pagination.tpl
+++ b/admin/templates/settings/settings_pagination.tpl
@@ -23,8 +23,8 @@
{if check_permission('cache_thumb')}{#MAIN_STAT_CLEAR_THUMB#} {/if}
{if check_permission('document_revisions')}{#MAIN_STAT_CLEAR_REV#} {/if}
{if check_permission('gen_settings')}{#MAIN_STAT_CLEAR_COUNT#} {/if}
- {if check_permission('gen_settings_robots')}{#SETTINGS_FILE_ROBOTS#} {/if}
- {if check_permission('gen_settings_fcustom')}{#SETTINGS_FILE_CUSTOM#}{/if}
+ {if check_permission('gen_settings_robots')}{#SETTINGS_FILE_ROBOTS#} {/if}
+ {if check_permission('gen_settings_fcustom')}{#SETTINGS_FILE_CUSTOM#}{/if}
diff --git a/admin/templates/sysblocks/list.tpl b/admin/templates/sysblocks/list.tpl
index b71f84e..1346805 100644
--- a/admin/templates/sysblocks/list.tpl
+++ b/admin/templates/sysblocks/list.tpl
@@ -120,7 +120,7 @@
{$sysblock->sysblock_author_id|escape} |
- {$sysblock->sysblock_created|date_format:$TIME_FORMAT|pretty_date}
+ {$sysblock->sysblock_created|date_format:$TIME_FORMAT|translate_date}
|
diff --git a/class/class.core.php b/class/class.core.php
index 3d3c98e..a444acc 100755
--- a/class/class.core.php
+++ b/class/class.core.php
@@ -16,11 +16,6 @@
class AVE_Core
{
-
- /**
- * Свойства класса
- */
-
/**
* Текущий документ
*
@@ -70,9 +65,6 @@
*/
public $_module_not_found = 'Запрашиваемый модуль не найден.';
- /**
- * Внутренние методы класса
- */
/**
* Получение основных настроек сисблока
@@ -268,6 +260,9 @@
{
global $AVE_DB;
+ if (isset($_REQUEST['module']) && ! preg_match('/^[A-Za-z0-9-_]{1,20}$/i', $_REQUEST['module']))
+ return '';
+
// Если папка, с запрашиваемым модулем не существует, выполняем редирект
// на главную страницу и отображаем сообщение с ошибкой
if (! is_dir(BASE_DIR . '/modules/' . $_REQUEST['module']))
@@ -368,6 +363,7 @@
}
}
+
/**
* Метод, предназначенный для обработки события 404 Not Found, т.е. когда страница не найдена.
*
@@ -403,6 +399,7 @@
exit;
}
+
/**
* Метод, предназначенный для формирования хэша страницы
*
@@ -418,6 +415,7 @@
return md5($hash);
}
+
/**
* Метод, предназначенный для проверки существования документа в БД
*
@@ -520,7 +518,7 @@
/**
* Метод, предназначенный для получения МЕТА-тегов для различных модулей.
- *
+ * ToDo
* @return boolean
*/
function _coreModuleMetatagsFetch()
@@ -649,9 +647,134 @@
return $combine;
}
- /**
- * Внешние методы класса
- */
+
+ function _main_content ($main_content, $id, $rubTmpl)
+ {
+ global $AVE_DB, $AVE_Template;
+
+ // Проверяем теги полей в шаблоне рубрики на условие != ''
+ $main_content = preg_replace("/\[tag:if_notempty:fld:([a-zA-Z0-9-_]+)\]/u", '<'.'?php if((htmlspecialchars(document_get_field(\'$1\'), ENT_QUOTES)) != \'\') { '.'?'.'>', $rubTmpl);
+ $main_content = preg_replace("/\[tag:if_empty:fld:([a-zA-Z0-9-_]+)\]/u", '<'.'?php if((htmlspecialchars(document_get_field(\'$1\'), ENT_QUOTES)) == \'\') { '.'?'.'>', $main_content);
+ $main_content = str_replace('[tag:if:else]', '', $main_content);
+ $main_content = str_replace('[tag:/if]', '', $main_content);
+
+ // Парсим элементы полей
+ $main_content = preg_replace_callback(
+ '/\[tag:fld:([a-zA-Z0-9-_]+)\]\[([0-9]+)]\[([0-9]+)]/',
+ create_function(
+ '$m',
+ 'return get_field_element($m[1], $m[2], $m[3], ' . $this->curentdoc->Id . ');'
+ ),
+ $main_content
+ );
+
+ // Парсим теги полей документа в шаблоне рубрики
+ $main_content = preg_replace_callback('/\[tag:fld:([a-zA-Z0-9-_]+)(|[:(\d)])+?\]/', 'document_get_field', $main_content);
+
+ // Повторно парсим элементы полей
+ $main_content = preg_replace_callback(
+ '/\[tag:fld:([a-zA-Z0-9-_]+)\]\[([0-9]+)]\[([0-9]+)]/',
+ create_function(
+ '$m',
+ 'return get_field_element($m[1], $m[2], $m[3], ' . $this->curentdoc->Id . ');'
+ ),
+ $main_content
+ );
+
+ // Повторно парсим теги полей документа в шаблоне рубрики
+ $main_content = preg_replace_callback('/\[tag:fld:([a-zA-Z0-9-_]+)(|[:(\d)])+?\]/', 'document_get_field', $main_content);
+
+ // Watermarks
+ $main_content = preg_replace_callback('/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/', 'watermarks', $main_content);
+
+ // Thumbnail
+ $main_content = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $main_content);
+
+ // Возвращаем поле из БД документа
+ $main_content = preg_replace_callback('/\[tag:doc:([a-zA-Z0-9-_]+)\]/u',
+ function ($match)
+ {
+ return isset($this->curentdoc->{$match[1]})
+ ? $this->curentdoc->{$match[1]}
+ : null;
+ },
+ $main_content
+ );
+
+ // Если пришел вызов на активацию языковых файлов
+ $main_content = preg_replace_callback(
+ '/\[tag:langfile:([a-zA-Z0-9-_]+)\]/u',
+ function ($match)
+ {
+ global $AVE_Template;
+
+ return $AVE_Template->get_config_vars($match[1]);
+ },
+ $main_content
+ );
+
+ // Удаляем ошибочные теги полей документа в шаблоне рубрики
+ $main_content = preg_replace('/\[tag:watermark:\w*\]/', '', $main_content);
+ $main_content = preg_replace('/\[tag:fld:\d*\]/', '', $main_content);
+ $main_content = preg_replace('/\[tag:doc:\w*\]/', '', $main_content);
+ $main_content = preg_replace('/\[tag:langfile:\w*\]/', '', $main_content);
+
+ // парсим теги в шаблоне рубрики
+ $main_content = preg_replace_callback(
+ '/\[tag:date:([a-zA-Z0-9-. \/]+)\]/',
+ create_function('$m','return translate_date(date($m[1], '.$this->curentdoc->document_published.'));
+ '),
+ $main_content
+ );
+
+ $main_content = str_replace('[tag:docdate]', pretty_date(strftime(DATE_FORMAT, $this->curentdoc->document_published)), $main_content);
+ $main_content = str_replace('[tag:doctime]', pretty_date(strftime(TIME_FORMAT, $this->curentdoc->document_published)), $main_content);
+ $main_content = str_replace('[tag:humandate]', human_date($this->curentdoc->document_published), $main_content);
+ $main_content = str_replace('[tag:docauthorid]', $this->curentdoc->document_author_id, $main_content);
+
+ if (preg_match('[tag:docauthor]', $main_content))
+ $main_content = str_replace('[tag:docauthor]', get_username_by_id($this->curentdoc->document_author_id), $main_content);
+
+ if (CACHE_DOC_TPL && empty($_POST))
+ {
+ $cache_id = (int)$this->curentdoc->Id;
+ $cache_id = 'compiled/' . (floor($cache_id / 1000)) . '/' . $cache_id;
+
+ $cache_file = $this->_get_cache_hash();
+
+ $cache_dir = BASE_DIR . '/cache/sql/' . (trim($cache_id) > ''
+ ? trim($cache_id) . '/'
+ : substr($cache_file, 0, 2) . '/' . substr($cache_file, 2, 2) . '/' . substr($cache_file, 4, 2) . '/');
+
+ // кэширование разрешено
+ // сохраняем скомпилированный шаблон в кэш
+ if (CACHE_DOC_FILE)
+ {
+ if (! is_dir($cache_dir))
+ mkdir($cache_dir, 0766, true);
+
+ file_put_contents($cache_dir . $cache_file, $main_content);
+ }
+
+ // кэширование разрешено
+ // сохраняем скомпилированный шаблон в кэш
+ $AVE_DB->Query("
+ INSERT INTO
+ " . PREFIX . "_rubric_template_cache
+ SET
+ hash = '" . $cache_file . "',
+ rub_id = '" . RUB_ID . "',
+ rub_tmpl_id = '" . $this->curentdoc->rubric_tmpl_id . "',
+ grp_id = '" . UGROUP . "',
+ doc_id = '" . $id . "',
+ compiled = '" . addslashes($main_content) . "'
+ ");
+
+ unset ($cache_id, $cache_file, $cache_dir);
+ }
+
+ return $main_content;
+ }
/**
* Метод, предназначенный для обработки системных тегов модулей. Здесь подключаются только те файлы модулей,
@@ -663,11 +786,14 @@
*/
function coreModuleTagParse($template)
{
- global $AVE_DB, $AVE_Template;
+ global $AVE_DB, $AVE_Template, $AVE_Module;
$pattern = array(); // Массив системных тегов
$replace = array(); // Массив функций, на которые будут заменены системные теги
+ if (null !== $AVE_Module->moduleListGet())
+ $this->install_modules = $AVE_Module->moduleListGet();
+
// Если уже имеются данные об установленных модулях
if (null !== $this->install_modules)
{
@@ -752,7 +878,7 @@
// получаем php код функции, в противном случае формируем сообщение с ошибкой
$replace[] = function_exists($row->ModuleFunction)
? $row->ModulePHPTag
- : ($this->_module_error . ' "' . $row->ModuleName . '"');
+ : ($this->_module_error . ' "' . $row->ModuleSysName . '"');
}
// Сохряняем информацию о модуле
$this->install_modules[$row->ModuleSysName] = $row;
@@ -760,7 +886,7 @@
elseif ($row->ModuleAveTag) // Если файла module.php не существует, формируем сообщение с ошибкой
{
$pattern[] = $row->ModuleAveTag;
- $replace[] = $this->_module_error . ' "' . $row->ModuleName . '"';
+ $replace[] = $this->_module_error . ' "' . $row->ModuleSysName . '"';
}
}
else
@@ -768,6 +894,7 @@
$this->install_modules[$row->ModuleSysName] = $row;
}
}
+
// Выполняем замену систеного тега на php код и возвращаем результат
return preg_replace($pattern, $replace, $template);
}
@@ -946,7 +1073,7 @@
}
}
- if (CACHE_DOC_TPL && empty ($_POST) && !(isset ($_SESSION['user_adminmode']) && $_SESSION['user_adminmode'] == 1))
+ if (CACHE_DOC_TPL && empty ($_POST))
{
// Кэширование разрешено
// Извлекаем скомпилированный шаблон документа из кэша
@@ -1036,109 +1163,17 @@
}
else
{
- // Проверяем теги полей в шаблоне рубрики на условие != ''
- $main_content = preg_replace("/\[tag:if_notempty:fld:([a-zA-Z0-9-_]+)\]/u", '<'.'?php if((htmlspecialchars(document_get_field(\'$1\'), ENT_QUOTES)) != \'\') { '.'?'.'>', $rubTmpl);
- $main_content = preg_replace("/\[tag:if_empty:fld:([a-zA-Z0-9-_]+)\]/u", '<'.'?php if((htmlspecialchars(document_get_field(\'$1\'), ENT_QUOTES)) == \'\') { '.'?'.'>', $main_content);
- $main_content = str_replace('[tag:if:else]', '', $main_content);
- $main_content = str_replace('[tag:/if]', '', $main_content);
-
- // Парсим теги полей документа в шаблоне рубрики
- $main_content = preg_replace_callback('/\[tag:fld:([a-zA-Z0-9-_]+)\]\[([0-9]+)]\[([0-9]+)]/', 'return_element', $main_content);
- $main_content = preg_replace_callback('/\[tag:fld:([a-zA-Z0-9-_]+)\]/', 'document_get_field', $main_content);
- $main_content = preg_replace_callback('/\[tag:fld:([a-zA-Z0-9-_]+)\]\[([0-9]+)]\[([0-9]+)]/', 'return_element', $main_content);
- $main_content = preg_replace_callback('/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/', 'watermarks', $main_content);
- $main_content = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $main_content);
-
- // Возвращаем поле из БД документа
- $main_content = preg_replace_callback('/\[tag:doc:([a-zA-Z0-9-_]+)\]/u',
- function ($match)
- {
- return isset($this->curentdoc->{$match[1]})
- ? $this->curentdoc->{$match[1]}
- : null;
- },
- $main_content
- );
-
- // Если пришел вызов на активацию языковых файлов
- $main_content = preg_replace_callback(
- '/\[tag:langfile:([a-zA-Z0-9-_]+)\]/u',
- function ($match)
- {
- global $AVE_Template;
-
- return $AVE_Template->get_config_vars($match[1]);
- },
- $main_content
- );
-
- // Удаляем ошибочные теги полей документа в шаблоне рубрики
- $main_content = preg_replace('/\[tag:watermark:\w*\]/', '', $main_content);
- $main_content = preg_replace('/\[tag:fld:\d*\]/', '', $main_content);
- $main_content = preg_replace('/\[tag:doc:\w*\]/', '', $main_content);
- $main_content = preg_replace('/\[tag:langfile:\w*\]/', '', $main_content);
-
- if (CACHE_DOC_TPL && empty ($_POST) && !(isset ($_SESSION['user_adminmode']) && $_SESSION['user_adminmode'] == 1))
- {
- $cache_id = (int)$this->curentdoc->Id;
- $cache_id = 'compiled/' . (floor($cache_id / 1000)) . '/' . $cache_id;
-
- $cache_file = $this->_get_cache_hash();
-
- $cache_dir = BASE_DIR . '/cache/sql/' . (trim($cache_id) > ''
- ? trim($cache_id) . '/'
- : substr($cache_file, 0, 2) . '/' . substr($cache_file, 2, 2) . '/' . substr($cache_file, 4, 2) . '/');
-
- // кэширование разрешено
- // сохраняем скомпилированный шаблон в кэш
- if (CACHE_DOC_FILE)
- {
- if(! is_dir($cache_dir))
- mkdir($cache_dir, 0777, true);
-
- file_put_contents($cache_dir . $cache_file, $main_content);
- }
-
- // кэширование разрешено
- // сохраняем скомпилированный шаблон в кэш
- $AVE_DB->Query("
- INSERT " . PREFIX . "_rubric_template_cache
- SET
- hash = '" . $cache_file . "',
- rub_id = '" . RUB_ID . "',
- rub_tmpl_id = '" . $this->curentdoc->rubric_tmpl_id . "',
- grp_id = '" . UGROUP . "',
- doc_id = '" . $id . "',
- compiled = '" . addslashes($main_content) . "'
- ");
-
- unset($cache_id, $cache_file, $cache_dir);
- }
+ // Обрабатываем основные поля рубрики
+ $main_content = $this->_main_content($main_content, $id, $rubTmpl);
}
}
-
- // парсим теги в шаблоне рубрики
- $main_content = preg_replace_callback(
- '/\[tag:date:([a-zA-Z0-9-. \/]+)\]/',
- create_function('$m','return translate_date(date($m[1], '.$this->curentdoc->document_published.'));
- '),
- $main_content
- );
-
- $main_content = str_replace('[tag:docdate]', pretty_date(strftime(DATE_FORMAT, $this->curentdoc->document_published)), $main_content);
- $main_content = str_replace('[tag:doctime]', pretty_date(strftime(TIME_FORMAT, $this->curentdoc->document_published)), $main_content);
- $main_content = str_replace('[tag:humandate]', human_date($this->curentdoc->document_published), $main_content);
- $main_content = str_replace('[tag:docauthorid]', $this->curentdoc->document_author_id, $main_content);
-
- if (preg_match('[tag:docauthor]', $main_content))
- $main_content = str_replace('[tag:docauthor]', get_username_by_id($this->curentdoc->document_author_id), $main_content);
}
$out = str_replace('[tag:maincontent]', $main_content, $out);
- unset($this->curentdoc->rubric_template, $this->curentdoc->template);
+ unset ($this->curentdoc->rubric_template, $this->curentdoc->template);
}
- // Конец вывода документа
+ //-- Конец вывода документа
//Работа с условиями
/*
@@ -1519,6 +1554,9 @@
$get_url = implode('/', $get_url);
}
+ //-- Экранируем поступающий URL
+ $get_url = $AVE_DB->ClearUrl($get_url);
+
//-- Проверяем есть ли данный URL в таблице алиасов модулей
$sql = "
SELECT
@@ -1554,15 +1592,10 @@
Id = '" . (int)$_REQUEST['id'] . "'
")->GetCell();
}
+
// Выполняем запрос к БД на получение всей необходимой
// информации о документе
- // Экранируем поступающий URL
- $get_url = $AVE_DB->EscStr($get_url);
-
- if (mb_strlen($get_url) > 255)
- $get_url = '';
-
// Забираем нужные данные
$sql = $AVE_DB->Query("
SELECT
diff --git a/class/class.database.php b/class/class.database.php
index 7693e49..05d9476 100755
--- a/class/class.database.php
+++ b/class/class.database.php
@@ -1,1204 +1,1367 @@
_result = $_result;
+ /**
+ * @param string $e
+ */
+ function __construct($e)
+ {
+ parent::__construct($e);
+ }
}
-
- /**
- * Метод, предназначенный для обработки результата запроса.
- * Возвращает как ассоциативный, так и численный массив.
- *
- * @return array
- */
- public function FetchArray()
+ /***************************************************************************
+ * Класс, предназначенный для работы с результатами выполнения MySQL-запроса
+ ***************************************************************************/
+ class AVE_DB_Result
{
- if (is_array($this->_result))
+ /**
+ * Конечный результат выполнения запроса
+ *
+ * @var resource
+ */
+ public $_result = null;
+
+
+ /**
+ * Конструктор, возвращает объект с указателем на результат выполнения SQL-запроса
+ *
+ * @param $_result
+ *
+ * @internal param resource $result указателем на результат выполнения SQL-запроса
+ * @return \AVE_DB_Result object
+ */
+ public function __construct($_result)
{
- $a = current($this->_result);
+ $this->_result = $_result;
+ }
- next($this->_result);
- $b = array();
+ /**
+ * Метод, предназначенный для обработки результата запроса.
+ * Возвращает как ассоциативный, так и численный массив.
+ *
+ * @return array
+ */
+ public function FetchArray()
+ {
+ if (is_array($this->_result))
+ {
+ $a = current($this->_result);
- if (! is_array($a))
- return false;
+ next($this->_result);
- foreach($a as $k => $v)
- $b[] = $v;
+ $b = array();
- return array_merge($b, $a);
- }
+ if (! is_array($a))
+ return false;
- return mysqli_fetch_array($this->_result);
- }
+ foreach($a as $k => $v)
+ $b[] = $v;
+ return array_merge($b, $a);
+ }
- /**
- * Метод, предназначенный для обработки результата запроса.
- * Возвращает только ассоциативный массив.
- *
- * @return array
- */
- public function FetchAssocArray()
- {
- if (is_array($this->_result))
+ return mysqli_fetch_array($this->_result);
+ }
+
+
+ /**
+ * Метод, предназначенный для обработки результата запроса.
+ * Возвращает только ассоциативный массив.
+ *
+ * @return array
+ */
+ public function FetchAssocArray()
{
- $a = current($this->_result);
+ if (is_array($this->_result))
+ {
+ $a = current($this->_result);
- next($this->_result);
+ next($this->_result);
- return $a;
- }
+ return $a;
+ }
- return mysqli_fetch_assoc($this->_result);
- }
+ return mysqli_fetch_assoc($this->_result);
+ }
- /**
- * Метод, предназначенный для обработки результата запроса, возвращая данные в виде объекта.
- *
- * @return object
- */
- public function FetchRow()
- {
- if (is_array($this->_result))
+ /**
+ * Метод, предназначенный для обработки результата запроса, возвращая данные в виде объекта.
+ *
+ * @return object
+ */
+ public function FetchRow()
{
- $a = $this->FetchAssocArray();
+ if (is_array($this->_result))
+ {
+ $a = $this->FetchAssocArray();
- return array2object($a);
- }
+ return array2object($a);
+ }
- return mysqli_fetch_object($this->_result);
- }
+ return mysqli_fetch_object($this->_result);
+ }
- /**
- * Метод, предназначенный для возвращения данных результата запроса
- *
- * @return mixed
- */
- public function GetCell()
- {
- if (is_array($this->_result))
+ /**
+ * Метод, предназначенный для возвращения данных результата запроса
+ *
+ * @return mixed
+ */
+ public function GetCell()
{
- $a = current($this->_result);
+ if (is_array($this->_result))
+ {
+ $a = current($this->_result);
- if (is_array($a))
- return current($a);
- else
- return false;
- }
+ if (is_array($a))
+ return current($a);
+ else
+ return false;
+ }
- if ($this->NumRows())
- {
- $a = mysqli_fetch_row($this->_result);
- return $a[0];
+ if ($this->NumRows())
+ {
+ $a = mysqli_fetch_row($this->_result);
+ return $a[0];
+ }
+
+ return false;
}
- return false;
- }
- /**
- * Метод, предназначенный для перемещения внутреннего указателя в результате запроса
- *
- * @param int $id - номер ряда результатов запроса
- * @return bool
- */
- public function DataSeek($id = 0)
- {
- if(is_array($this->_result))
+
+ /**
+ * Метод, предназначенный для обработки результата запроса.
+ * Возвращает полный ассоциативный массив.
+ *
+ * @return array
+ */
+ public function GetArray()
{
- //не нашел как переместить указатель в массиве на конкретный
- reset($this->_result);
+ if (is_array($this->_result))
+ {
+ $data = current($this->_result);
- for($x = 0; $x == $id; $x++)
next($this->_result);
- return $id; //эээ а что вернуть то надо было?
- }
- return mysqli_data_seek($this->_result, $id);
- }
+ return $data;
+ }
- /**
- * Метод, предназначенный для получения количества рядов результата запроса
- *
- * @return int
- */
- public function NumRows()
- {
- if (is_array($this->_result))
- {
- return (int)count($this->_result);
+ $array = array();
+
+ while ($row = mysqli_fetch_assoc($this->_result))
+ array_push($array, $row);
+
+ return $array;
}
- return (int)mysqli_num_rows($this->_result);
- }
- /**
- * Метод, предназначенный для получения количества полей результата запроса
- *
- * @return int
- */
- public function NumFields()
- {
- if (is_array($this->_result))
+ /**
+ * Метод, предназначенный для обработки результата запроса.
+ * Возвращает данные в виде объекта.
+ *
+ * @return array
+ */
+ public function GetObject()
{
- $a = current($this->_result);
+ if (is_array($this->_result))
+ {
+ $data = $this->FetchAssocArray();
+
+ return array2object($data);
+ }
+
+ $array = array();
+
+ while ($row = mysqli_fetch_object($this->_result))
+ array_push($array, $row);
- return count($a);
+ return $array;
}
- return (int)mysqli_num_fields($this->_result);
- }
- /**
- * Метод, предназначенный для получения названия указанной колонки результата запроса
- *
- * @param int $i - индекс колонки
- * @return string
- */
- public function FieldName($i)
- {
- if(is_array($this->_result)){
+ /**
+ * Метод, предназначенный для перемещения внутреннего указателя в результате запроса
+ *
+ * @param int $id - номер ряда результатов запроса
+ * @return bool
+ */
+ public function DataSeek($id = 0)
+ {
+ if (is_array($this->_result))
+ {
+ //не нашел как переместить указатель в массиве на конкретный
+ reset($this->_result);
- $a = current($this->_result);
+ for ($x = 0; $x == $id; $x++)
+ next ($this->_result);
- $b = array_keys($a);
+ return $id; //эээ а что вернуть то надо было?
+ }
- return($b[$i]);
+ return mysqli_data_seek($this->_result, $id);
}
- mysqli_field_seek($this->_result, $i);
- $field = mysqli_fetch_field($this->_result);
- return $field->name;
- }
+ /**
+ * Метод, предназначенный для получения количества рядов результата запроса
+ *
+ * @return int
+ */
+ public function NumRows()
+ {
+ if (is_array($this->_result))
+ return (int)count($this->_result);
- /**
- * Метод, предназначенный для освобождения памяти от результата запроса
- *
- * @return bool
- */
- public function Close()
- {
- if (! is_array($this->_result))
- @mysqli_free_result($this->_result);
+ return (int)mysqli_num_rows($this->_result);
+ }
- return true;
- }
- /**
- * Возвращает объект результата _result.
- *
- * @internal param $void
- * @return resource
- */
- public function getResult()
- {
- return $this->_result;
- }
+ /**
+ * Метод, предназначенный для получения количества полей результата запроса
+ *
+ * @return int
+ */
+ public function NumFields()
+ {
+ if (is_array($this->_result))
+ {
+ $a = current($this->_result);
- /**
- * Удаляем объект
- */
- public function __destruct()
- {
- $this->Close();
- }
-}
+ return count($a);
+ }
+ return (int)mysqli_num_fields($this->_result);
+ }
-/**************************************************************
- *
- * Класс, предназначенный для работы непосредственно с MySQL БД
- *
- **************************************************************/
-class AVE_DB
-{
-/**
- * Свойства класса
- */
+ /**
+ * Метод, предназначенный для получения названия указанной колонки результата запроса
+ *
+ * @param int $i - индекс колонки
+ * @return string
+ */
+ public function FieldName($i)
+ {
+ if (is_array($this->_result))
+ {
+ $a = current($this->_result);
- /**
- * Хост
- *
- * @var string
- */
- protected $db_host;
+ $b = array_keys($a);
- /**
- * Имя пользователя
- *
- * @var string
- */
- protected $db_user;
+ return($b[$i]);
+ }
- /**
- * Пароль
- *
- * @var string
- */
- protected $db_pass;
+ mysqli_field_seek($this->_result, $i);
- /**
- * Номер порта
- *
- * @var int
- */
- protected $db_port;
+ $field = mysqli_fetch_field($this->_result);
- /**
- * Сокет
- *
- * @var int
- */
- protected $db_socket;
+ return $field->name;
+ }
- /**
- * Имя текущей БД.
- *
- * @var string
- */
- protected $db_name;
- /**
- * Префикс БД.
- *
- * @var string
- */
- protected $db_prefix;
+ /**
+ * Метод, предназначенный для освобождения памяти от результата запроса
+ *
+ * @return bool
+ */
+ public function Close()
+ {
+ if (! is_array($this->_result))
+ @mysqli_free_result($this->_result);
- /**
- * Стандартный объект соединения сервером MySQL.
- *
- * @var mysqli
- */
- protected $mysqli;
+ return true;
+ }
- /**
- * Список выполненных запросов
- *
- * @var array
- */
- public $_query_list;
- /**
- * Метки времени до и после выполнения SQL-запроса
- *
- * @var array
- */
- public $_time_exec;
+ /**
+ * Возвращает объект результата _result.
+ *
+ * @internal param $void
+ * @return resource
+ */
+ public function getResult()
+ {
+ return $this->_result;
+ }
- /**
- * Последний запрос SQL-запроса
- *
- * @var array
- */
- public $_last_query;
- /**
- * Конструктор
+ /**
+ * Удаляем объект
+ */
+ public function __destruct()
+ {
+ $this->Close();
+ }
+ }
+
+
+ /**************************************************************
*
- * @param $db
+ * Класс, предназначенный для работы непосредственно с MySQL БД
*
- * @throws AVE_DB_Exception
- * @return \AVE_DB AVE_DB - объект
- */
- private function __construct($db)
+ **************************************************************/
+ class AVE_DB
{
- $this->db_host = $db['dbhost'];
- $this->db_user = $db['dbuser'];
- $this->db_password = $db['dbpass'];
- $this->db_prefix = $db['dbpref'];
+ /**
+ * Хост
+ *
+ * @var string
+ */
+ protected $db_host;
+
+ /**
+ * Имя пользователя
+ *
+ * @var string
+ */
+ protected $db_user;
+
+ /**
+ * Пароль
+ *
+ * @var string
+ */
+ protected $db_pass;
+
+ /**
+ * Номер порта
+ *
+ * @var int
+ */
+ protected $db_port;
+
+ /**
+ * Сокет
+ *
+ * @var int
+ */
+ protected $db_socket;
+
+ /**
+ * Имя текущей БД.
+ *
+ * @var string
+ */
+ protected $db_name;
+
+ /**
+ * Префикс БД.
+ *
+ * @var string
+ */
+ protected $db_prefix;
+
+ /**
+ * Стандартный объект соединения сервером MySQL.
+ *
+ * @var mysqli
+ */
+ protected $mysqli;
+
+ /**
+ * Список выполненных запросов
+ *
+ * @var array
+ */
+ public $_query_list;
+
+ /**
+ * Метки времени до и после выполнения SQL-запроса
+ *
+ * @var array
+ */
+ public $_time_exec;
+
+ /**
+ * Последний запрос SQL-запроса
+ *
+ * @var array
+ */
+ public $_last_query;
+
+ /**
+ * Конструктор
+ *
+ * @param $db
+ *
+ * @throws AVE_DB_Exception
+ * @return \AVE_DB AVE_DB - объект
+ */
+ private function __construct($db)
+ {
+ $this->db_host = $db['dbhost'];
+ $this->db_user = $db['dbuser'];
+ $this->db_password = $db['dbpass'];
+ $this->db_prefix = $db['dbpref'];
+
+ if(!isset($db['dbport']))
+ $this->db_port = ini_get ('mysqli.default_port');
+ else
+ $this->db_port = (isset($db['dbport']) ? $db['dbport'] : null);
+
+ if(!isset($db['dbsock']))
+ $this->db_socket = ini_get ('mysqli.default_socket');
+ else
+ $this->db_port = (isset($db['dbsock']) ? $db['dbsock'] : null);
- if(!isset($db['dbport']))
- $this->db_port = ini_get ('mysqli.default_port');
- else
- $this->db_port = (isset($db['dbport']) ? $db['dbport'] : null);
+ $this->Connect();
- if(!isset($db['dbsock']))
- $this->db_socket = ini_get ('mysqli.default_socket');
- else
- $this->db_port = (isset($db['dbsock']) ? $db['dbsock'] : null);
+ // Определяем профилирование
+ if (defined('SQL_PROFILING') && SQL_PROFILING)
+ {
+ // mysqli_query($this->mysqli, "QUERY_CACHE_TYPE = OFF");
+ // mysqli_query($this->mysqli, "FLUSH TABLES");
+ if (mysqli_query($this->mysqli, "SET PROFILING_HISTORY_SIZE = 100"))
+ {
+ mysqli_query($this->mysqli,"SET PROFILING = 1");
+ }
+ }
+ }
- $this->Connect();
- // Определяем профилирование
- if (defined('SQL_PROFILING') && SQL_PROFILING)
+ /**
+ * Устанавливает соеденение с базой данных.
+ *
+ * @throws AVE_DB_Exception
+ * @internal param void
+ * @return void
+ */
+ private function Connect()
{
- // mysqli_query($this->mysqli, "QUERY_CACHE_TYPE = OFF");
- // mysqli_query($this->mysqli, "FLUSH TABLES");
- if (mysqli_query($this->mysqli, "SET PROFILING_HISTORY_SIZE = 100"))
+ if (!is_object($this->mysqli) || !$this->mysqli instanceof mysqli)
{
- mysqli_query($this->mysqli,"SET PROFILING = 1");
+ $this->mysqli = @new mysqli($this->db_host, $this->db_user, $this->db_password, null, $this->db_port, $this->db_socket);
+ if ($this->mysqli->connect_error)
+ {
+ throw new AVE_DB_Exception(__METHOD__ . ': ' . $this->mysqli->connect_error);
+ }
}
}
- }
- /**
- * Устанавливает соеденение с базой данных.
- *
- * @throws AVE_DB_Exception
- * @internal param void
- * @return void
- */
- private function Connect()
- {
- if (!is_object($this->mysqli) || !$this->mysqli instanceof mysqli)
+
+ /**
+ * Задает набор символов по умолчанию.
+ *
+ * @param string $charset
+ *
+ * @throws AVE_DB_Exception
+ * @return AVE_DB
+ */
+ public function setCharset($charset)
{
- $this->mysqli = @new mysqli($this->db_host, $this->db_user, $this->db_password, null, $this->db_port, $this->db_socket);
- if ($this->mysqli->connect_error)
+ if (!$this->mysqli->set_charset($charset))
{
- throw new AVE_DB_Exception(__METHOD__ . ': ' . $this->mysqli->connect_error);
+ throw new AVE_DB_Exception(__METHOD__ . ': ' . $this->mysqli->error);
}
+
+ return $this;
}
- }
- /**
- * Задает набор символов по умолчанию.
- *
- * @param string $charset
- *
- * @throws AVE_DB_Exception
- * @return AVE_DB
- */
- public function setCharset($charset)
- {
- if (!$this->mysqli->set_charset($charset))
+ /**
+ * Устанавливает имя используемой СУБД.
+ *
+ * @param string $database_name - имя базы данных
+ * @throws AVE_DB_Exception
+ * @return AVE_DB
+ */
+ public function setDatabaseName($database_name)
{
- throw new AVE_DB_Exception(__METHOD__ . ': ' . $this->mysqli->error);
+ if (!$database_name)
+ {
+ throw new AVE_DB_Exception(__METHOD__ . ': Не указано имя базы данных');
+ }
+
+ $this->db_name = $database_name;
+
+ if (!$this->mysqli->select_db($this->db_name))
+ {
+ throw new AVE_DB_Exception(__METHOD__ . ': ' . $this->mysqli->error);
+ }
+
+ return $this;
}
- return $this;
- }
+ /**
+ * Создает инстанс данного класса.
+ *
+ * @uses $AVE_DB = AVE_DB::getInstance($server, $username, $password, $port, $socket);
+ * @param $db
+ * @return object возвращает инстанс данного класса.
+ */
+ public static function getInstance($db = array())
+ {
+ return new self($db);
+ }
- /**
- * Устанавливает имя используемой СУБД.
- *
- * @param string $database_name - имя базы данных
- * @throws AVE_DB_Exception
- * @return AVE_DB
- */
- public function setDatabaseName($database_name)
- {
- if (!$database_name)
+
+ /**
+ * Возвращает префикс БД.
+ *
+ * @param void
+ * @return string
+ */
+ public function getPrefix()
{
- throw new AVE_DB_Exception(__METHOD__ . ': Не указано имя базы данных');
+ return $this->db_prefix;
}
- $this->db_name = $database_name;
- if (!$this->mysqli->select_db($this->db_name))
+ /**
+ * Возвращает кодировку по умолчанию, установленную для соединения с БД.
+ *
+ * @param void
+ * @return string
+ */
+ public function getCharset()
{
- throw new AVE_DB_Exception(__METHOD__ . ': ' . $this->mysqli->error);
+ return $this->mysqli->character_set_name();
}
- return $this;
- }
+ /**
+ * Возвращает имя текущей БД.
+ *
+ * @param void
+ * @return string
+ */
+ public function getDatabaseName()
+ {
+ return $this->db_name;
+ }
- /**
- * Создает инстанс данного класса.
- *
- * @uses $AVE_DB = AVE_DB::getInstance($server, $username, $password, $port, $socket);
- * @param $db
- * @return object возвращает инстанс данного класса.
- */
- public static function getInstance($db = array())
- {
- return new self($db);
- }
+ /**
+ * Получает количество рядов, задействованных в предыдущей MySQL-операции.
+ * Возвращает количество рядов, задействованных в последнем запросе INSERT, UPDATE или DELETE.
+ * Если последним запросом был DELETE без оператора WHERE,
+ * все записи таблицы будут удалены, но функция возвратит ноль.
+ *
+ * @see mysqli_affected_rows
+ * @param void
+ * @return int
+ */
+ public function getAffectedRows()
+ {
+ return $this->mysqli->affected_rows;
+ }
- /**
- * Возвращает префикс БД.
- *
- * @param void
- * @return string
- */
- public function getPrefix()
- {
- return $this->db_prefix;
- }
+ /**
+ * Возвращает последний выполненный MySQL-запрос.
+ *
+ * @param void
+ * @return string
+ */
+ public function getQueryString()
+ {
+ return $this->_last_query;
+ }
- /**
- * Возвращает кодировку по умолчанию, установленную для соединения с БД.
- *
- * @param void
- * @return string
- */
- public function getCharset()
- {
- return $this->mysqli->character_set_name();
- }
+ /**
+ * Возвращает массив со всеми исполненными SQL-запросами в рамках текущего объекта.
+ *
+ * @param void
+ * @return array
+ */
+ public function getQueries()
+ {
+ return $this->_query_list;
+ }
- /**
- * Возвращает имя текущей БД.
- *
- * @param void
- * @return string
- */
- public function getDatabaseName()
- {
- return $this->db_name;
- }
+ public function prepareQuery($string)
+ {
+ $search = array(
+ "/[\t]/",
+ '/(\s)+/s',
+ '/(GROUP BY |STRAIGHT_JOIN |UNION |FROM |WHERE |LIMIT |ORDER BY |LEFT JOIN|INNER JOIN|RIGHT JOIN|JOIN|ON |AND |OR |SET)/s'
+ );
+
+ $replace = array(
+ " ",
+ '\\1',
+ "\r\n$1"
+ );
+
+ return trim(preg_replace($search, $replace, $string));
+ }
+
+
+ public function showAllQueries ()
+ {
+ if (! is_array($this->_query_list))
+ return false;
+
+ foreach ($this->_query_list AS $k => $v)
+ {
+ $_caller = '';
+
+ if (is_array($v['caller']))
+ {
+ foreach ($v['caller'] AS $caller)
+ {
+ $_caller .= 'File: ' . $caller['call_file'] . PHP_EOL;
+ $_caller .= 'Func: ' . $caller['call_func'] . PHP_EOL;
+ $_caller .= 'Line: ' . $caller['call_line'] . PHP_EOL;
+ $_caller .= PHP_EOL;
+ }
+ }
+
+ $_ttl = $v['ttl'] > 0 ? $v['ttl'] : 'None';
+
+ if ($v['cache'])
+ $_ttl .= PHP_EOL . $v['cache'];
+
+ $_query = $this->prepareQuery($v['query']);
+
+ $div = '
+ ' .
+ ' ' .
+ '' . $k . '' .
+ ' ' .
+ ' ' .
+ 'Trace:' . PHP_EOL .
+ $_caller .
+ 'Cache:' . PHP_EOL .
+ $_ttl . PHP_EOL .
+ PHP_EOL .
+ 'Query:' . PHP_EOL .
+ '' .
+ $_query .
+ ' ' .
+ ' ' .
+ '
+ ';
+
+ echo($div);
+ }
+ }
+
+ /**
+ * Возвращает id, сгенерированный предыдущей операцией INSERT.
+ *
+ * @see mysqli_insert_id
+ * @param void
+ * @return int
+ */
+ public function getLastInsertId()
+ {
+ return $this->mysqli->insert_id;
+ }
- /**
- * Получает количество рядов, задействованных в предыдущей MySQL-операции.
- * Возвращает количество рядов, задействованных в последнем запросе INSERT, UPDATE или DELETE.
- * Если последним запросом был DELETE без оператора WHERE,
- * все записи таблицы будут удалены, но функция возвратит ноль.
- *
- * @see mysqli_affected_rows
- * @param void
- * @return int
- */
- public function getAffectedRows()
- {
- return $this->mysqli->affected_rows;
- }
+ /**
+ * Метод, предназначенный для возвращения ID записи, сгенерированной при последнем INSERT-запросе
+ *
+ * @return int
+ */
+ public function InsertId()
+ {
+ return (int)mysqli_insert_id($this->mysqli);
+ }
- /**
- * Возвращает последний выполненный MySQL-запрос.
- *
- * @param void
- * @return string
- */
- public function getQueryString()
- {
- return $this->_last_query;
- }
+ /**
+ * Метод, предназначенный для получения функции из которой пришел запрос с ошибкой
+ *
+ * @return string
+ */
+ public function getCaller()
+ {
+ if (! function_exists('debug_backtrace'))
+ return '';
- /**
- * Возвращает массив со всеми исполненными SQL-запросами в рамках текущего объекта.
- *
- * @param void
- * @return array
- */
- public function getQueries()
- {
- return $this->_query_list;
- }
+ $stack = debug_backtrace();
+ $stack = array_reverse($stack);
+ $caller = array();
- /**
- * Возвращает id, сгенерированный предыдущей операцией INSERT.
- *
- * @see mysqli_insert_id
- * @param void
- * @return int
- */
- public function getLastInsertId()
- {
- return $this->mysqli->insert_id;
- }
+ foreach ((array)$stack as $call)
+ {
+ if (@$call['class'] == __CLASS__)
+ continue;
+ $function = $call['function'];
- /**
- * Метод, предназначенный для возвращения ID записи, сгенерированной при последнем INSERT-запросе
- *
- * @return int
- */
- public function InsertId()
- {
- return (int)mysqli_insert_id($this->mysqli);
- }
+ if (isset($call['class']))
+ {
+ $function = $call['class'] . "->$function";
+ }
+ $caller[] =
+ (array (
+ 'call_file' => (isset($call['file']) ? $call['file'] : 'Unknown'),
+ 'call_func' => $function,
+ 'call_line' => (isset($call['line']) ? $call['line'] : 'Unknown')
+ ));
+ }
+ return $caller;
+ }
- /**
- * Метод, предназначенный для получения функции из которой пришел запрос с ошибкой
- *
- * @return string
- */
- public function getCaller()
- {
- if (! function_exists('debug_backtrace')) return '';
- $stack = debug_backtrace();
- $stack = array_reverse($stack);
+ /************************* Внешние методы класса *************************/
- $caller = array();
- foreach ((array)$stack as $call)
+ /**
+ * Метод, предназначенный для выполнения запроса к MySQL
+ *
+ * @param string $query - текст SQL-запроса
+ * @param bool $log - записать ошибки в лог? по умолчанию включено
+ * @return object/bool - объект с указателем на результат выполнения запроса
+ */
+ public function Real_Query($query, $log = true, $TTL = null)
{
- if (@$call['class'] == __CLASS__)
- continue;
+ $result = @mysqli_query($this->mysqli, $query);
+
+ // Запоминаем последний запрос
+ $this->_last_query = $query;
+
+ // Если стоит в настройках, запоминать все запросы
+ if (defined('SQL_PROFILING') && SQL_PROFILING)
+ {
+ $_caller = $this->getCaller();
+ $this->_query_list[] = array('caller' => $_caller, 'query' => $query, 'ttl' => $TTL);
+ }
- $function = $call['function'];
+ // Если нет результата и стоит выводить логи, выводим лог ошибки
+ if (! $result && $log)
+ $this->_error('query', $query);
- if (isset($call['class']))
+ if (is_object($result) && $result instanceof mysqli_result)
{
- $function = $call['class'] . "->$function";
+ return new AVE_DB_Result($result);
}
- $caller[] =
- (array (
- 'call_file' => (isset($call['file']) ? $call['file'] : 'Unknown'),
- 'call_func' => $function,
- 'call_line' => (isset($call['line']) ? $call['line'] : 'Unknown')
- ));
+
+ return $result;
}
- return $caller;
- }
+ /**
+ * Метод, предназначенный для выполнения запроса к MySQL и возвращение результата в виде асоциативного массива с поддержкой кеша
+ *
+ * @param string $query - текст SQL-запроса
+ * @param integer $TTL - время жизни кеша (-1 безусловный кеш)
+ * @param string $cache_id - Id файла кеша
+ * @param bool $log - записать ошибки в лог? по умолчанию включено
+ * @return array - асоциативный массив с результом запроса
+ */
+ public function Query($query, $TTL = null, $cache_id = '', $log = true)
+ {
+ // Если это документ, то меняем расположение
+ if (substr($cache_id, 0, 3) == 'doc')
+ {
+ $cache_id = (int)str_replace('doc_', '', $cache_id);
+ $cache_id = 'doc/' . (floor($cache_id / 1000)) . '/' . $cache_id;
+ }
- /************************* Внешние методы класса *************************/
+ // Принудительная фильтрация запроса
+ if (defined(SQL_QUERY_SANITIZE) && SQL_QUERY_SANITIZE)
+ $query = filter_var($query, FILTER_SANITIZE_STRING);
+ $result = array();
- /**
- * Метод, предназначенный для выполнения запроса к MySQL
- *
- * @param string $query - текст SQL-запроса
- * @param bool $log - записать ошибки в лог? по умолчанию включено
- * @return object/bool - объект с указателем на результат выполнения запроса
- */
- public function Real_Query($query, $log = true)
- {
- $result = @mysqli_query($this->mysqli, $query);
+ // Если это SELECT - то отслеживаем кеширование
+ $TTL = strtoupper(substr(trim($query), 0, 6)) == 'SELECT'
+ ? $TTL
+ : null;
- // Запоминаем последний запрос
- $this->_last_query = $query;
+ // Если включен DEV MODE, то отключаем кеширование запросов
+ if (defined('DEV_MODE') AND DEV_MODE)
+ $TTL = null;
- // Если стоит в настройках, запоминать все запросы
- if (SQL_PROFILING)
- {
- $this->_query_list[] = $query;
- }
- // Если нет результата и стоит выводить логи, выводим лог ошибки
- if (! $result && $log)
- $this->_error('query', $query);
+ if ($TTL && ($TTL != 'nocache' AND $TTL != null))
+ {
+ $cache_file = md5($query);
- if (is_object($result) && $result instanceof mysqli_result)
- {
- return new AVE_DB_Result($result);
- }
+ $cache_dir = BASE_DIR . '/cache/sql/' . (trim($cache_id) > ''
+ ? trim($cache_id) . '/'
+ : substr($cache_file, 0, 2) . '/' . substr($cache_file, 2, 2) . '/' . substr($cache_file, 4, 2) . '/');
- return $result;
- }
+ if (! file_exists($cache_dir))
+ mkdir($cache_dir, 0777, true);
+ // Если стоит в настройках, запоминать все запросы
+ if (defined('SQL_PROFILING') && SQL_PROFILING)
+ {
+ $_caller = $this->getCaller();
+ $this->_query_list[] = array('caller' => $_caller, 'query' => $query, 'ttl' => $TTL, 'cache' => $cache_dir . $cache_file);
+ }
- /**
- * Метод, предназначенный для выполнения запроса к MySQL и возвращение результата в виде асоциативного массива с поддержкой кеша
- *
- * @param string $query - текст SQL-запроса
- * @param integer $TTL - время жизни кеша (-1 безусловный кеш)
- * @param string $cache_id - Id файла кеша
- * @param bool $log - записать ошибки в лог? по умолчанию включено
- * @return array - асоциативный массив с результом запроса
- */
- public function Query($query, $TTL = null, $cache_id = '', $log = true)
- {
- // Если это документ, то меняем расположение
- if (substr($cache_id, 0, 3) == 'doc')
+ if (! (file_exists($cache_dir . $cache_file) && ($TTL == -1 ? true : time() - filemtime($cache_dir . $cache_file) < $TTL)))
+ {
+ $res = $this->Real_Query($query, $log);
+
+ while ($mfa = $res->FetchAssocArray())
+ $result[] = $mfa;
+
+ file_put_contents($cache_dir . $cache_file, serialize($result));
+ }
+ else
+ {
+ $result = unserialize(file_get_contents($cache_dir . $cache_file));
+ }
+
+ return new AVE_DB_Result($result);
+ }
+
+ else
+ return $this->Real_Query($query, $log, $TTL);
+ }
+
+
+ /**
+ * This method is needed for prepared statements. They require
+ * the data type of the field to be bound with "i" s", etc.
+ * This function takes the input, determines what type it is,
+ * and then updates the param_type.
+ *
+ * @param mixed $item Input to determine the type.
+ *
+ * @return string The joined parameter types.
+ */
+ protected function DetermineType($item)
{
- $cache_id = (int)str_replace('doc_', '', $cache_id);
- $cache_id = 'doc/' . (floor($cache_id / 1000)) . '/' . $cache_id;
+ switch (gettype($item))
+ {
+ case 'NULL':
+ case 'string':
+ return 's';
+ break;
+
+ case 'boolean':
+ case 'integer':
+ return 'i';
+ break;
+
+ case 'blob':
+ return 'b';
+ break;
+
+ case 'double':
+ return 'd';
+ break;
+ }
+ return '';
}
- // Принудительная фильтрация запроса
- //$query = filter_var($query, FILTER_SANITIZE_STRING);
- $result = array();
+ /**
+ * Метод, предназначенный для экранирования специальных символов в строках для использования в выражениях SQL
+ *
+ * @param mixed $value - обрабатываемое значение
+ * @return mixed
+ */
+ public function Escape($value)
+ {
+ if (! is_numeric($value))
+ {
+ $value = mysqli_real_escape_string($this->mysqli, $value);
+ }
- // Если это SELECT - то отслеживаем кеширование
- $TTL = strtoupper(substr(trim($query), 0, 6)) == 'SELECT'
- ? $TTL
- : null;
+ return $value;
+ }
- // Если включен DEV MODE, то отключаем кеширование запросов
- if (defined('DEV_MODE') AND DEV_MODE)
- $TTL = null;
- if ($TTL && ($TTL != 'nocache' AND $TTL != null))
+ /**
+ * Метод, предназначенный для экранирования специальных символов в строках для использования в выражениях SQL
+ *
+ * @param mixed $value - обрабатываемое значение
+ * @return mixed - возвращает строку запроса вычещенной
+ */
+ public function EscStr($value)
{
- $cache_file = md5($query);
+ $search = array(
+ '&' => '&',
+ '>' => '>',
+ '<' => '<',
+ ';' => ':',
+ '|' => '|',
+ '>' => '>',
+ "'" => ''',
+ '"' => '"',
+ ')' => ')',
+ '(' => '(',
+ '{' => '{',
+ '}' => '}',
+ '$' => '$'
+ );
- $cache_dir = BASE_DIR . '/cache/sql/' . (trim($cache_id) > ''
- ? trim($cache_id) . '/'
- : substr($cache_file, 0, 2) . '/' . substr($cache_file, 2, 2) . '/' . substr($cache_file, 4, 2) . '/');
+ $value = str_replace(array_keys($search), array_values($search), $value);
+ $value = str_ireplace('%3Cscript', '', $value);
- if (! file_exists($cache_dir))
- mkdir($cache_dir, 0777, true);
+ $value = htmlspecialchars($value, ENT_QUOTES);
- if (! (file_exists($cache_dir . $cache_file) && ($TTL == -1 ? true : time() - filemtime($cache_dir . $cache_file) < $TTL)))
+ if (! is_array($value))
{
- $res = $this->Real_Query($query, $log);
-
- while ($mfa = $res->FetchAssocArray())
- $result[] = $mfa;
-
- file_put_contents($cache_dir . $cache_file, serialize($result));
+ $value = mysqli_real_escape_string($this->mysqli, $value);
}
else
{
- $result = unserialize(file_get_contents($cache_dir . $cache_file));
+ $value = array_map(array($AVE_DB, 'Escape'), $value);
}
- return new AVE_DB_Result($result);
+ return $value;
}
- else
- return $this->Real_Query($query, $log);
- }
-
- /**
- * This method is needed for prepared statements. They require
- * the data type of the field to be bound with "i" s", etc.
- * This function takes the input, determines what type it is,
- * and then updates the param_type.
- *
- * @param mixed $item Input to determine the type.
- *
- * @return string The joined parameter types.
- */
- protected function DetermineType($item)
- {
- switch (gettype($item))
+ /**
+ * Метод, предназначенный для экранирования и очищения значения при поиске url в базе
+ *
+ * @param string $value - обрабатываемое значение
+ * @return string - возвращает строку запроса вычещенной
+ */
+ function ClearUrl($url)
{
- case 'NULL':
- case 'string':
- return 's';
- break;
-
- case 'boolean':
- case 'integer':
- return 'i';
- break;
-
- case 'blob':
- return 'b';
- break;
-
- case 'double':
- return 'd';
- break;
- }
- return '';
- }
+ // Убираем пробелы
+ $url = trim($url);
+ // Условия
+ $search = array('<', ';', '|', '&', '>', "'", '"', ')', '(', '{', '}', '$', '=');
- /**
- * Метод, предназначенный для экранирования специальных символов в строках для использования в выражениях SQL
- *
- * @param mixed $value - обрабатываемое значение
- * @return mixed
- */
- public function Escape($value)
- {
- if (! is_numeric($value))
- {
- $value = mysqli_real_escape_string($this->mysqli, $value);
- }
+ // Убираем пробелы
+ $url = preg_replace('/[\s,]+/i', '', $url);
- return $value;
- }
+ // Проходимся условиями
+ $url = str_replace($search, '', $url);
+ $url = str_ireplace('%3Cscript', '', $url);
+ // Применяем встроенный SANITIZE
+ $url = filter_var($url, FILTER_SANITIZE_STRING);
- /**
- * Метод, предназначенный для экранирования специальных символов в строках для использования в выражениях SQL
- *
- * @param mixed $value - обрабатываемое значение
- * @return mixed - возвращает строку запроса вычещенной
- */
- public function EscStr($value)
- {
- $value = htmlspecialchars($value);
-
- $search = array(
- '<' => '<',
- ';' => ':',
- '|' => '|',
- '&' => '&',
- '>' => '>',
- "'" => ''',
- '"' => '"',
- ')' => ')',
- '(' => '(',
- '{' => '{',
- '}' => '}',
- '$' => '$',
- '>' => '>'
- );
-
- $value = str_replace(array_keys($search), array_values($search), $value);
- $value = str_ireplace('%3Cscript', '', $value);
-
- $value = filter_var($value, FILTER_SANITIZE_STRING);
-
- if (! is_array($value))
- {
- $value = $this->mysqli->real_escape_string($value);
- }
- else
+ // Переводим html в сущности, если чтото осталось
+ $url = htmlspecialchars($url);
+
+ // Если это не массив
+ if (! is_array($url))
{
- $value = array_map(array($this, 'escape'), $value);
+ // Проходимся функцией от MySQL
+ $url = $this->mysqli->real_escape_string($url);
}
+ // Иначе вообще очищаем строку
+ else
+ {
+ $url = array_map(array($AVE_DB, 'Escape'), $url);
+ }
- return $value;
- }
-
+ return $url;
+ }
- /**
- * Метод, предназначенный для возвращения количества всех найденных записей (после запроса)
- *
- * @return int
- */
- public function GetFoundRows()
- {
- $result = $this->Query('SELECT FOUND_ROWS();');
- $strRow = $result->FetchArray();
- return (int)$strRow[0];
- }
+ /**
+ * Метод, предназначенный для возвращения количества всех найденных записей (после запроса)
+ *
+ * @return int
+ */
+ public function GetFoundRows()
+ {
+ $result = $this->Query('SELECT FOUND_ROWS();');
+ $strRow = $result->FetchArray();
+ return (int)$strRow[0];
+ }
- /**
- * Метод, предназначенный для возвращения количества всех найденных записей (после запроса типа "SELECT SQL_CALC_FOUND_ROWS * ...")
- *
- * @param $query
- * @param null $TTL
- * @param string $cache_id
- * @return int
- */
- public function NumAllRows($query, $TTL = null, $cache_id = '')
- {
- // Если включен DEV MODE, то отключаем кеширование запросов
- if (defined('DEV_MODE') AND DEV_MODE)
- $TTL = null;
- if ($TTL AND ($TTL != "nocache" AND $TTL != null))
+ /**
+ * Метод, предназначенный для возвращения количества всех найденных записей (после запроса типа "SELECT SQL_CALC_FOUND_ROWS * ...")
+ *
+ * @param $query
+ * @param null $TTL
+ * @param string $cache_id
+ * @return int
+ */
+ public function NumAllRows($query, $TTL = null, $cache_id = '')
{
- // Кол-во
- $cache_file = md5($query) . '.count';
+ // Если включен DEV MODE, то отключаем кеширование запросов
+ if (defined('DEV_MODE') AND DEV_MODE)
+ $TTL = null;
- $cache_dir = BASE_DIR . '/cache/sql/' . (trim($cache_id) > ''
- ? trim($cache_id) . '/'
- : substr($cache_file, 0, 2) . '/'. substr($cache_file, 2, 2) . '/' . substr($cache_file, 4, 2) . '/');
+ if ($TTL AND ($TTL != "nocache" AND $TTL != null))
+ {
+ // Кол-во
+ $cache_file = md5($query) . '.count';
- if (! file_exists($cache_dir))
- mkdir($cache_dir, 0777, true);
+ $cache_dir = BASE_DIR . '/cache/sql/' . (trim($cache_id) > ''
+ ? trim($cache_id) . '/'
+ : substr($cache_file, 0, 2) . '/'. substr($cache_file, 2, 2) . '/' . substr($cache_file, 4, 2) . '/');
- if (! (file_exists($cache_dir . $cache_file) && ($TTL == -1 ? true : time() - filemtime($cache_dir . $cache_file) < $TTL)))
- {
- if ($query <> $this->_last_query)
+ if (! file_exists($cache_dir))
+ mkdir($cache_dir, 0777, true);
+
+ if (! (file_exists($cache_dir . $cache_file) && ($TTL == -1 ? true : time() - filemtime($cache_dir . $cache_file) < $TTL)))
{
- $res = $this->Real_Query($query);
+ if ($query <> $this->_last_query)
+ {
+ $res = $this->Real_Query($query);
+ }
+ else
+ {
+ $res = (int)$this->Query("SELECT FOUND_ROWS();")->GetCell();
+
+ file_put_contents($cache_dir . $cache_file, $res);
+ }
+
+ return $res;
}
else
{
- $res = (int)$this->Query("SELECT FOUND_ROWS()")->GetCell();
- file_put_contents($cache_dir . $cache_file, $res);
+ return file_get_contents($cache_dir . $cache_file);
}
-
- return $res;
}
- else
- {
- return file_get_contents($cache_dir . $cache_file);
- }
- }
- return (int)$this->Query("SELECT FOUND_ROWS()")->GetCell();
- }
+ return (int)$this->Query("SELECT FOUND_ROWS();")->GetCell();
+ }
- /**
- * Метод, предназначенный для формирования статистики выполнения SQL-запросов.
- *
- * @param string $type - тип запрашиваемой статистики
- *
- * Возможные значения:
- * list - список выполненых зпаросов
- * time - время исполнения зпросов
- * count - количество выполненных запросов
- *
- * @return mixed
- */
- public function DBStatisticGet($type = '')
- {
- switch ($type)
+ /**
+ * Метод, предназначенный для формирования статистики выполнения SQL-запросов.
+ *
+ * @param string $type - тип запрашиваемой статистики
+ *
+ * Возможные значения:
+ * list - список выполненых зпаросов
+ * time - время исполнения зпросов
+ * count - количество выполненных запросов
+ *
+ * @return mixed
+ */
+ public function DBStatisticGet($type = '')
{
- case 'list':
- list($s_dec, $s_sec) = explode(' ', $GLOBALS['start_time']);
+ switch ($type)
+ {
+ case 'list':
+ list($s_dec, $s_sec) = explode(' ', $GLOBALS['start_time']);
- $query_list = '';
+ $query_list = '';
- $nq = 0;
+ $nq = 0;
- //$time_exec = 0;
- $arr = $this->_time_exec;
+ //$time_exec = 0;
+ $arr = $this->_time_exec;
- $co = sizeof($arr);
+ $co = sizeof($arr);
- for ($it = 0; $it < $co;)
- {
- list($a_dec, $a_sec) = explode(' ', $arr[$it++]);
- list($b_dec, $b_sec) = explode(' ', $arr[$it++]);
+ for ($it = 0; $it < $co;)
+ {
+ list($a_dec, $a_sec) = explode(' ', $arr[$it++]);
+ list($b_dec, $b_sec) = explode(' ', $arr[$it++]);
- $time_main = ($a_sec - $s_sec + $a_dec - $s_dec)*1000;
- $time_exec = ($b_sec - $a_sec + $b_dec - $a_dec)*1000;
+ $time_main = ($a_sec - $s_sec + $a_dec - $s_dec)*1000;
+ $time_exec = ($b_sec - $a_sec + $b_dec - $a_dec)*1000;
- $query = sizeof(array_keys($this->_query_list, $this->_query_list[$nq])) > 1
- ? "" . $this->_query_list[$nq++] . ""
- : $this->_query_list[$nq++];
+ $query = sizeof(array_keys($this->_query_list, $this->_query_list[$nq])) > 1
+ ? "" . $this->_query_list[$nq++] . ""
+ : $this->_query_list[$nq++];
- $query_list .= (($time_exec > 1) ? "(" : "(")
- . round($time_main) . " ms) " . $time_exec . " ms " . $query . "\n";
- }
+ $query_list .= (($time_exec > 1) ? "(" : "(")
+ . round($time_main) . " ms) " . $time_exec . " ms " . $query . "\n";
+ }
- return $query_list;
- break;
+ return $query_list;
+ break;
- case 'time':
- $arr = $this->_time_exec;
+ case 'time':
+ $arr = $this->_time_exec;
- $time_exec = 0;
+ $time_exec = 0;
- $co = sizeof($arr);
+ $co = sizeof($arr);
- for ($it = 0; $it < $co;)
- {
- list($a_dec, $a_sec) = explode(" ", $arr[$it++]);
- list($b_dec, $b_sec) = explode(" ", $arr[$it++]);
+ for ($it = 0; $it < $co;)
+ {
+ list($a_dec, $a_sec) = explode(" ", $arr[$it++]);
+ list($b_dec, $b_sec) = explode(" ", $arr[$it++]);
- $time_exec += $b_sec - $a_sec + $b_dec - $a_dec;
- }
+ $time_exec += $b_sec - $a_sec + $b_dec - $a_dec;
+ }
- return $time_exec;
- break;
+ return $time_exec;
+ break;
- case 'count':
- return sizeof($this->_query_list);
- break;
+ case 'count':
+ return sizeof($this->_query_list);
+ break;
- default:
- return '';
- break;
+ default:
+ return '';
+ break;
+ }
}
- }
- /**
- * Метод, предназначенный для формирования статистики выполнения SQL-запросов.
- *
- * @param string $type - тип запрашиваемой статистики
- *
- * Возможные значения:
- * list - список выполненых зпаросов
- * time - время исполнения зпросов
- * count - количество выполненных запросов
- *
- * @return mixed
- */
- public function DBProfilesGet($type = '')
- {
- static $result, $list, $time, $count;
-
- if (! defined('SQL_PROFILING') OR ! SQL_PROFILING)
- return false;
-
- if (! $result)
+ /**
+ * Метод, предназначенный для формирования статистики выполнения SQL-запросов.
+ *
+ * @param string $type - тип запрашиваемой статистики
+ *
+ * Возможные значения:
+ * list - список выполненых зпаросов
+ * time - время исполнения зпросов
+ * count - количество выполненных запросов
+ *
+ * @return mixed
+ */
+ public function DBProfilesGet($type = '')
{
- $list = ""
- . "\n\t\n\t";
+ static $result, $list, $time, $count;
- $result = mysqli_query($this->mysqli, "SHOW PROFILES");
+ if (! defined('SQL_PROFILING') OR ! SQL_PROFILING)
+ return false;
- while (list($qid, $qtime, $qstring) = @mysqli_fetch_row($result))
+ if (! $result)
{
- $time += $qtime;
-
- $qstring = preg_replace('/\t+/', '', $qstring);
-
- $list .= "\n\t\n\t\t"
- . $qid
- . " | \n\t\t"
- . number_format($qtime * 1, 6, ',', '')
- . " | \n\t\t"
- . $qstring
- . " | \n\t ";
-
- $res = mysqli_query($this->mysqli, "
- SELECT
- STATE,
- FORMAT(DURATION, 6) AS DURATION
- FROM
- INFORMATION_SCHEMA.PROFILING
- WHERE
- QUERY_ID = " . $qid
- );
+ $list = ""
+ . "\n\t\n\t";
+
+ $result = mysqli_query($this->mysqli, "SHOW PROFILES");
- while (list($state, $duration) = @mysqli_fetch_row($res))
+ while (list($qid, $qtime, $qstring) = @mysqli_fetch_row($result))
{
- $list .= "\n\t\n\t\t | "
- . number_format($duration * 1, 6, ',', '')
- . " | \n\t\t" . $state . " | \n\t ";
+ $time += $qtime;
+
+ $qstring = preg_replace('/\t+/', '', $qstring);
+
+ $list .= "\n\t\n\t\t"
+ . $qid
+ . " | \n\t\t"
+ . number_format($qtime * 1, 6, ',', '')
+ . " | \n\t\t"
+ . $qstring
+ . " | \n\t ";
+
+ $res = mysqli_query($this->mysqli, "
+ SELECT
+ STATE,
+ FORMAT(DURATION, 6) AS DURATION
+ FROM
+ INFORMATION_SCHEMA.PROFILING
+ WHERE
+ QUERY_ID = " . $qid
+ );
+
+ while (list($state, $duration) = @mysqli_fetch_row($res))
+ {
+ $list .= "\n\t\n\t\t | "
+ . number_format($duration * 1, 6, ',', '')
+ . " | \n\t\t" . $state . " | \n\t ";
+ }
}
+
+ $time = number_format($time * 1, 6, ',', '');
+ $list .= "\n ";
+ $count = @mysqli_num_rows($result);
}
- $time = number_format($time * 1, 6, ',', '');
- $list .= "\n ";
- $count = @mysqli_num_rows($result);
- }
+ switch ($type)
+ {
+ case 'list': return $list; break;
+ case 'time': return $time; break;
+ case 'count': return $count; break;
+ }
- switch ($type)
- {
- case 'list': return $list; break;
- case 'time': return $time; break;
- case 'count': return $count; break;
+ return false;
}
- return false;
- }
-
- /**
- * Закрывает MySQL-соединение.
- *
- * @param void
- * @return AVE_DB
- */
- public function Close()
- {
- if (is_object($this->mysqli) && $this->mysqli instanceof mysqli)
+ /**
+ * Закрывает MySQL-соединение.
+ *
+ * @param void
+ * @return AVE_DB
+ */
+ public function Close()
{
- @$this->mysqli->close();
- }
-
- return $this;
- }
-
+ if (is_object($this->mysqli) && $this->mysqli instanceof mysqli)
+ {
+ @$this->mysqli->close();
+ }
- /**
- * Метод, предназначенный для обработки ошибок
- *
- * @param string $type - тип ошибки (при подключении к БД или при выполнении SQL-запроса)
- * @param string $query - текст SQL запроса вызвавшего ошибку
- * @access private
- */
- public function _error($type, $query = '')
- {
+ return $this;
+ }
- if ($type != 'query')
- {
- display_notice('Error ' . $type . ' MySQL database.');
- }
- else
+ /**
+ * Метод, предназначенный для обработки ошибок
+ *
+ * @param string $type - тип ошибки (при подключении к БД или при выполнении SQL-запроса)
+ * @param string $query - текст SQL запроса вызвавшего ошибку
+ * @access private
+ */
+ public function _error($type, $query = '')
{
- $my_error = mysqli_error($this->mysqli);
-
- $log = array(
- 'sql_error' => $my_error,
- 'sql_query' => htmlentities(stripslashes($query), ENT_QUOTES),
- 'caller' => $this->getCaller(),
- 'url' => HOST . $_SERVER['SCRIPT_NAME']. '?' . $_SERVER['QUERY_STRING']
- );
- reportSqlLog($log);
- // Если в настройках системы установлен параметр на отправку сообщений на e-mail, тогда
- if (SEND_SQL_ERROR)
+ if ($type != 'query')
{
- // Формируем текст сообщения с ошибкой
- $mail_body = (
- 'SQL ERROR: ' . $my_error . PHP_EOL
- . 'TIME: ' . date('d-m-Y, H:i:s') . PHP_EOL
- . 'URL: ' . HOST . $_SERVER['SCRIPT_NAME']
- . '?' . $_SERVER['QUERY_STRING'] . PHP_EOL
- . $this->getCaller() . PHP_EOL
- . 'QUERY: ' . stripslashes($query) . PHP_EOL
- );
+ display_notice('Error ' . $type . ' MySQL database.');
+ }
+ else
+ {
+ $my_error = mysqli_error($this->mysqli);
- // Отправляем сообщение
- send_mail(
- get_settings('mail_from'),
- $mail_body,
- 'MySQL Error!',
- get_settings('mail_from'),
- get_settings('mail_from_name'),
- 'text'
+ $log = array(
+ 'sql_error' => $my_error,
+ 'sql_query' => htmlentities(stripslashes($query), ENT_QUOTES),
+ 'caller' => $this->getCaller(),
+ 'url' => HOST . $_SERVER['SCRIPT_NAME']. '?' . $_SERVER['QUERY_STRING']
);
+
+ reportSqlLog($log);
+
+ // Если в настройках системы установлен параметр на отправку сообщений на e-mail, тогда
+ if (SEND_SQL_ERROR)
+ {
+ // Формируем текст сообщения с ошибкой
+ $mail_body = (
+ 'SQL ERROR: ' . $my_error . PHP_EOL
+ . 'TIME: ' . date('d-m-Y, H:i:s') . PHP_EOL
+ . 'URL: ' . HOST . $_SERVER['SCRIPT_NAME']
+ . '?' . $_SERVER['QUERY_STRING'] . PHP_EOL
+ . $this->getCaller() . PHP_EOL
+ . 'QUERY: ' . stripslashes($query) . PHP_EOL
+ );
+
+ // Отправляем сообщение
+ send_mail(
+ get_settings('mail_from'),
+ $mail_body,
+ 'MySQL Error!',
+ get_settings('mail_from'),
+ get_settings('mail_from_name'),
+ 'text'
+ );
+ }
}
}
- }
- /**
- * Удаляем объект
- *
- * @param void
- */
- public function __destruct()
- {
- $this->Close();
- }
+ /**
+ * Удаляем объект
+ *
+ * @param void
+ */
+ public function __destruct()
+ {
+ $this->Close();
+ }
- /**
- * Метод, предназначенный для получения информации о сервере MySQL
- *
- * @param void
- * @return string
- */
- public function mysql_version()
- {
- return @mysqli_get_server_info($this->mysqli);
- }
+ /**
+ * Метод, предназначенный для получения информации о сервере MySQL
+ *
+ * @param void
+ * @return string
+ */
+ public function mysql_version()
+ {
+ return @mysqli_get_server_info($this->mysqli);
+ }
- /**
- * Метод, предназначенный для очищения кеша документов
- *
- * @param $cache_id
- * @return bool
- */
- public function clearcache($cache_id)
- {
- $cache_id = (substr($cache_id, 0, 3) == 'doc'
- ? 'doc/' . intval(floor((int)substr($cache_id, 4)) / 1000) . '/' . (int)substr($cache_id, 4)
- : $cache_id);
+ /**
+ * Метод, предназначенный для очищения кеша документов
+ *
+ * @param $cache_id
+ * @return bool
+ */
+ public function clearcache($cache_id)
+ {
+ $cache_id = (substr($cache_id, 0, 3) == 'doc'
+ ? 'doc/' . intval(floor((int)substr($cache_id, 4)) / 1000) . '/' . (int)substr($cache_id, 4)
+ : $cache_id);
- $cache_dir = BASE_DIR . '/cache/sql/' . (trim($cache_id) > ''
- ? trim($cache_id) . '/'
- : '');
+ $cache_dir = BASE_DIR . '/cache/sql/' . (trim($cache_id) > ''
+ ? trim($cache_id) . '/'
+ : '');
- return rrmdir($cache_dir);
- }
+ return rrmdir($cache_dir);
+ }
- /**
- * Метод, предназначенный для очищения кеша запросов
- *
- * @param $cache_id
- * @return bool
- */
- public function clearcacherequest($cache_id)
- {
- $cache_id = (substr($cache_id, 0, 3) == 'doc'
- ? 'request/' . (int)substr($cache_id, 4)
- : $cache_id);
+ /**
+ * Метод, предназначенный для очищения кеша запросов
+ *
+ * @param $cache_id
+ * @return bool
+ */
+ public function clearcacherequest($cache_id)
+ {
+ $cache_id = (substr($cache_id, 0, 3) == 'doc'
+ ? 'request/' . (int)substr($cache_id, 4)
+ : $cache_id);
- $cache_dir = BASE_DIR . '/cache/sql/' . (trim($cache_id) > ''
- ? trim($cache_id) . '/'
- : '');
+ $cache_dir = BASE_DIR . '/cache/sql/' . (trim($cache_id) > ''
+ ? trim($cache_id) . '/'
+ : '');
- return rrmdir($cache_dir);
- }
+ return rrmdir($cache_dir);
+ }
- /**
- * Метод, предназначенный для очищения кеша шаблонов
- *
- * @param $cache_id
- * @return bool
- */
- public function clearcompile($cache_id)
- {
- $cache_id = (substr($cache_id, 0, 3) == 'doc'
- ? 'compiled/' . intval(floor((int)substr($cache_id, 4)) / 1000) . '/' . (int)substr($cache_id, 4)
- : $cache_id);
+ /**
+ * Метод, предназначенный для очищения кеша шаблонов
+ *
+ * @param $cache_id
+ * @return bool
+ */
+ public function clearcompile($cache_id)
+ {
+ $cache_id = (substr($cache_id, 0, 3) == 'doc'
+ ? 'compiled/' . intval(floor((int)substr($cache_id, 4)) / 1000) . '/' . (int)substr($cache_id, 4)
+ : $cache_id);
- $cache_dir = BASE_DIR . '/cache/sql/' . (trim($cache_id) > ''
- ? trim($cache_id) . '/'
- : '');
+ $cache_dir = BASE_DIR . '/cache/sql/' . (trim($cache_id) > ''
+ ? trim($cache_id) . '/'
+ : '');
- return rrmdir($cache_dir);
- }
+ return rrmdir($cache_dir);
+ }
- /**
- * Метод, предназначенный для очищения кеша запросов
- *
- * @param $cache_id
- * @return bool
- */
- public function clear_request($cache_id)
- {
- $request = request_get_settings($cache_id);
+ /**
+ * Метод, предназначенный для очищения кеша запросов
+ *
+ * @param $cache_id
+ * @return bool
+ */
+ public function clear_request($cache_id)
+ {
+ $request = request_get_settings($cache_id);
- $cache_from_id = BASE_DIR . '/cache/sql/request/settings/' . (trim($request->Id) > ''
- ? trim($request->Id) . '/'
- : '');
+ $cache_from_id = BASE_DIR . '/cache/sql/request/settings/' . (trim($request->Id) > ''
+ ? trim($request->Id) . '/'
+ : '');
- $cache_from_alias = BASE_DIR . '/cache/sql/request/settings/' . (trim($request->request_alias) > ''
- ? trim($request->request_alias) . '/'
- : '');
+ $cache_from_alias = BASE_DIR . '/cache/sql/request/settings/' . (trim($request->request_alias) > ''
+ ? trim($request->request_alias) . '/'
+ : '');
- return (rrmdir($cache_from_id) AND rrmdir($cache_from_alias));
- }
+ return (rrmdir($cache_from_id) AND rrmdir($cache_from_alias));
+ }
-} // End AVE_DB class
+ } // End AVE_DB class
?>
\ No newline at end of file
diff --git a/class/class.dbdump.php b/class/class.dbdump.php
index 1b8a2a2..f021a02 100644
--- a/class/class.dbdump.php
+++ b/class/class.dbdump.php
@@ -1,648 +1,640 @@
_database_dump = '';
+ $search = array("\x00", "\x0a", "\x0d", "\x1a");
+ $replace = array('\0', '\n', '\r', '\Z');
- // Циклически обрабатываем каждую таблицу
- foreach ($_REQUEST['ta'] as $table)
- {
- if (! DB_EXPORT_PREFIX)
- $table_export = preg_replace('/^' . PREFIX . '/', '%%PRFX%%', $table);
+ $this->_database_dump = '';
- // Если таблица имеет корректный префикс
- if (preg_match('/^' . preg_quote(PREFIX) . '_/', $table))
+ // Циклически обрабатываем каждую таблицу
+ foreach ($_REQUEST['ta'] as $table)
{
- $row = $AVE_DB->Query("SHOW CREATE TABLE " . $table)->FetchArray();
- // Сохраняем CREATE и DROP запросы
- $this->_database_dump .= "DROP TABLE IF EXISTS `" . (! DB_EXPORT_PREFIX ? $table_export : $table) . "`;" . $this->_delimiter . "\n";
-
if (! DB_EXPORT_PREFIX)
- $this->_database_dump .= str_replace('CREATE TABLE `' . PREFIX . '_', 'CREATE TABLE `%%PRFX%%_', $row[1]) . ";" . $this->_delimiter . "\n\n";
- else
- $this->_database_dump .= $row[1] . ";" . $this->_delimiter . "\n\n";
+ $table_export = preg_replace('/^' . PREFIX . '/', '%%PRFX%%', $table);
- $nums = 0;
+ // Если таблица имеет корректный префикс
+ if (preg_match('/^' . preg_quote(PREFIX) . '_/', $table))
+ {
+ $row = $AVE_DB->Query("SHOW CREATE TABLE " . $table)->FetchArray();
+ // Сохраняем CREATE и DROP запросы
+ $this->_database_dump .= "DROP TABLE IF EXISTS `" . (! DB_EXPORT_PREFIX ? $table_export : $table) . "`;" . $this->_delimiter . "\n";
- // Получаем данные, которые в дальнейшем будут вставлены в INSERT запросы.
- $sql = $AVE_DB->Query('SELECT * FROM `' . $table . '`');
+ if (! DB_EXPORT_PREFIX)
+ $this->_database_dump .= str_replace('CREATE TABLE `' . PREFIX . '_', 'CREATE TABLE `%%PRFX%%_', $row[1]) . ";" . $this->_delimiter . "\n\n";
+ else
+ $this->_database_dump .= $row[1] . ";" . $this->_delimiter . "\n\n";
- while ($row = $sql->FetchArray())
- {
- if ($nums == 0)
- {
- $nums = $sql->NumFields();
+ $nums = 0;
- $temp_array = array();
+ // Получаем данные, которые в дальнейшем будут вставлены в INSERT запросы.
+ $sql = $AVE_DB->Query('SELECT * FROM `' . $table . '`');
- for ($i = 0; $i < $nums; $i++)
+ while ($row = $sql->FetchArray())
+ {
+ if ($nums == 0)
{
- $temp_array[] = $sql->FieldName($i);
- }
+ $nums = $sql->NumFields();
- $table_list = '(`' . implode('`, `', $temp_array) . '`)';
- }
+ $temp_array = array();
- $temp_array = array();
+ for ($i = 0; $i < $nums; $i++)
+ {
+ $temp_array[] = $sql->FieldName($i);
+ }
- for ($i=0; $i<$nums; $i++)
- {
- if (! isset($row[$i]))
- {
- $temp_array[] = 'NULL';
- }
- elseif ($row[$i] != '')
- {
- $temp_array[] = "'" . str_replace($search, $replace, addslashes($row[$i])) . "'";
+ $table_list = '(`' . implode('`, `', $temp_array) . '`)';
}
- else
+
+ $temp_array = array();
+
+ for ($i=0; $i<$nums; $i++)
{
- $temp_array[] = "''";
+ if (! isset($row[$i]))
+ {
+ $temp_array[] = 'NULL';
+ }
+ elseif ($row[$i] != '')
+ {
+ $temp_array[] = "'" . str_replace($search, $replace, addslashes($row[$i])) . "'";
+ }
+ else
+ {
+ $temp_array[] = "''";
+ }
}
- }
- // Сохряняем INSERT запросы
- $this->_database_dump .= 'INSERT INTO `' . (! DB_EXPORT_PREFIX ? $table_export : $table) . '` ' . $table_list . ' VALUES (' . implode(', ', $temp_array) . ");" . $this->_delimiter . "\n";
- }
+ // Сохряняем INSERT запросы
+ $this->_database_dump .= 'INSERT INTO `' . (! DB_EXPORT_PREFIX ? $table_export : $table) . '` ' . $table_list . ' VALUES (' . implode(', ', $temp_array) . ");" . $this->_delimiter . "\n";
+ }
- $this->_database_dump .= "\n";
+ $this->_database_dump .= "\n";
- $sql->Close();
+ $sql->Close();
+ }
}
- }
-
- return ! empty($this->_database_dump);
- }
+ return ! empty($this->_database_dump);
+ }
- /**
- * Метод, предназначенный для формирования файла дампа базы данных
- *
- * @return boolean
- */
- function _databaseTopDumpCreate()
- {
- global $AVE_DB;
-
- $dbtables = array();
-
- $sql = $AVE_DB->Query("SHOW TABLES LIKE '" . PREFIX . "_%'");
- while ($row = $sql->FetchArray())
+ /**
+ * Метод, предназначенный для формирования файла дампа базы данных
+ *
+ * @return boolean
+ */
+ function _databaseTopDumpCreate()
{
- array_push($dbtables, $row[0]);
- }
-
- $search = array("\x00", "\x0a", "\x0d", "\x1a");
- $replace = array('\0', '\n', '\r', '\Z');
+ global $AVE_DB;
- $this->_database_dump = '';
+ $dbtables = array();
- // Циклически обрабатываем каждую таблицу
- foreach ($dbtables as $table)
- {
- if (! DB_EXPORT_PREFIX)
- $table_export = preg_replace('/^' . PREFIX . '/', '%%PRFX%%', $table);
+ $sql = $AVE_DB->Query("SHOW TABLES LIKE '" . PREFIX . "_%'");
- // Если таблица имеет корректный префикс
- if (preg_match('/^' . preg_quote(PREFIX) . '_/', $table))
+ while ($row = $sql->FetchArray())
{
- $row = $AVE_DB->Query("SHOW CREATE TABLE " . $table)->FetchArray();
+ array_push($dbtables, $row[0]);
+ }
- // Сохраняем CREATE и DROP запросы
- $this->_database_dump .= "DROP TABLE IF EXISTS `" . (! DB_EXPORT_PREFIX ? $table_export : $table) . "`;" . $this->_delimiter . "\n";
+ $search = array("\x00", "\x0a", "\x0d", "\x1a");
+ $replace = array('\0', '\n', '\r', '\Z');
+ $this->_database_dump = '';
+
+ // Циклически обрабатываем каждую таблицу
+ foreach ($dbtables as $table)
+ {
if (! DB_EXPORT_PREFIX)
- $this->_database_dump .= str_replace('CREATE TABLE `' . PREFIX . '_', 'CREATE TABLE `%%PRFX%%_', $row[1]) . ";" . $this->_delimiter . "\n\n";
- else
- $this->_database_dump .= $row[1] . ";" . $this->_delimiter . "\n\n";
+ $table_export = preg_replace('/^' . PREFIX . '/', '%%PRFX%%', $table);
- $nums = 0;
+ // Если таблица имеет корректный префикс
+ if (preg_match('/^' . preg_quote(PREFIX) . '_/', $table))
+ {
+ $row = $AVE_DB->Query("SHOW CREATE TABLE " . $table)->FetchArray();
- // Получаем данные, которые в дальнейшем будут вставлены в INSERT запросы.
- $sql = $AVE_DB->Query('SELECT * FROM `' . $table . '`');
+ // Сохраняем CREATE и DROP запросы
+ $this->_database_dump .= "DROP TABLE IF EXISTS `" . (! DB_EXPORT_PREFIX ? $table_export : $table) . "`;" . $this->_delimiter . "\n";
- while ($row = $sql->FetchArray())
- {
- if ($nums==0)
- {
- $nums = $sql->NumFields();
+ if (! DB_EXPORT_PREFIX)
+ $this->_database_dump .= str_replace('CREATE TABLE `' . PREFIX . '_', 'CREATE TABLE `%%PRFX%%_', $row[1]) . ";" . $this->_delimiter . "\n\n";
+ else
+ $this->_database_dump .= $row[1] . ";" . $this->_delimiter . "\n\n";
- $temp_array = array();
- for ($i=0; $i<$nums; $i++)
- {
- $temp_array[] = $sql->FieldName($i);
- }
- $table_list = '(`' . implode('`, `', $temp_array) . '`)';
- }
+ $nums = 0;
- $temp_array = array();
+ // Получаем данные, которые в дальнейшем будут вставлены в INSERT запросы.
+ $sql = $AVE_DB->Query('SELECT * FROM `' . $table . '`');
- for ($i=0; $i<$nums; $i++)
+ while ($row = $sql->FetchArray())
{
- if (!isset($row[$i]))
- {
- $temp_array[] = 'NULL';
- }
- elseif ($row[$i] != '')
+ if ($nums==0)
{
- $temp_array[] = "'" . str_replace($search, $replace, addslashes($row[$i])) . "'";
+ $nums = $sql->NumFields();
+
+ $temp_array = array();
+ for ($i=0; $i<$nums; $i++)
+ {
+ $temp_array[] = $sql->FieldName($i);
+ }
+ $table_list = '(`' . implode('`, `', $temp_array) . '`)';
}
- else
+
+ $temp_array = array();
+
+ for ($i=0; $i<$nums; $i++)
{
- $temp_array[] = "''";
+ if (!isset($row[$i]))
+ {
+ $temp_array[] = 'NULL';
+ }
+ elseif ($row[$i] != '')
+ {
+ $temp_array[] = "'" . str_replace($search, $replace, addslashes($row[$i])) . "'";
+ }
+ else
+ {
+ $temp_array[] = "''";
+ }
}
- }
- // Сохряняем INSERT запросы
- $this->_database_dump .= 'INSERT INTO `' . (! DB_EXPORT_PREFIX ? $table_export : $table) . '` ' . $table_list . ' VALUES (' . implode(', ', $temp_array) . ");" . $this->_delimiter . "\n";
- }
+ // Сохряняем INSERT запросы
+ $this->_database_dump .= 'INSERT INTO `' . (! DB_EXPORT_PREFIX ? $table_export : $table) . '` ' . $table_list . ' VALUES (' . implode(', ', $temp_array) . ");" . $this->_delimiter . "\n";
+ }
- $this->_database_dump .= "\n";
+ $this->_database_dump .= "\n";
- $sql->Close();
+ $sql->Close();
+ }
}
- }
-
- return ! empty($this->_database_dump);
- }
+ return ! empty($this->_database_dump);
+ }
-/**
- * Внешние методы класса
- */
/**
- * Метод, предназначенный для сохранения файла дампа базы данных на жеский диск
- *
+ * Внешние методы класса
*/
- function databaseDumpExport($top = 0, $exit = 0)
- {
- global $AVE_Template;
- // Если дамп не удалось создать, тогда завершаем работу
- if ($top)
+ /**
+ * Метод, предназначенный для сохранения файла дампа базы данных на жеский диск
+ *
+ */
+ function databaseDumpExport($top = 0, $exit = 0)
{
- if (! $this->_databaseTopDumpCreate())
- exit;
- }
- else
- {
- if (! $this->_databaseDumpCreate())
- exit;
- }
-
- // Готовим шаблон имени файла
- $file_name = preg_replace_ru(array("/%SERVER%/", "/%DATE%/", "/%TIME%/"), array($_SERVER['SERVER_NAME'], date('d.m.y'), date('H.i.s')), DB_EXPORT_TPL);
+ global $AVE_Template;
- $dump = (defined('DB_EXPORT_GZ') && DB_EXPORT_GZ
- ? gzencode($this->_database_dump)
- : $this->_database_dump);
-
- if (isset($_REQUEST['server']) && $_REQUEST['server'] == 1)
- {
- if(! is_dir(BASE_DIR . '/backup/'))
+ // Если дамп не удалось создать, тогда завершаем работу
+ if ($top)
{
- @mkdir(BASE_DIR . '/backup/', 0777);
- write_htaccess_deny(BASE_DIR . '/backup/');
+ if (! $this->_databaseTopDumpCreate())
+ exit;
+ }
+ else
+ {
+ if (! $this->_databaseDumpCreate())
+ exit;
}
- @file_put_contents(BASE_DIR . '/backup/'. $file_name . '.sql'. (defined('DB_EXPORT_GZ') && DB_EXPORT_GZ ? '.gz' : ''), $dump);
+ // Готовим шаблон имени файла
+ $file_name = preg_replace_ru(array("/%SERVER%/", "/%DATE%/", "/%TIME%/"), array($_SERVER['SERVER_NAME'], date('d.m.y'), date('H.i.s')), DB_EXPORT_TPL);
- @chmod(BASE_DIR . '/backup/'. $file_name . '.sql', 0777);
+ $dump = (defined('DB_EXPORT_GZ') && DB_EXPORT_GZ
+ ? gzencode($this->_database_dump)
+ : $this->_database_dump);
- if (! $exit)
- header('Location:index.php?do=dbsettings&cp=' . SESSION);
- else
- return BASE_DIR . '/backup/'. $file_name . '.sql'. (defined('DB_EXPORT_GZ') && DB_EXPORT_GZ ? '.gz' : '');
- }
- else
- {
- // Формируем заголовок
- header('Content-Type: text/plain');
- header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
- header('Content-Disposition: attachment; filename=' . $file_name . '.sql'. (defined('DB_EXPORT_GZ') && DB_EXPORT_GZ ? '.gz' : ''));
- header('Content-Length: ' . strlen($dump));
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Pragma: public');
-
- // Выводим данные
- echo $dump;
+ if (isset($_REQUEST['server']) && $_REQUEST['server'] == 1)
+ {
+ if(! is_dir(BASE_DIR . '/backup/'))
+ {
+ @mkdir(BASE_DIR . '/backup/', 0777);
+ write_htaccess_deny(BASE_DIR . '/backup/');
+ }
- $this->_database_dump = '';
- }
+ @file_put_contents(BASE_DIR . '/backup/'. $file_name . '.sql'. (defined('DB_EXPORT_GZ') && DB_EXPORT_GZ ? '.gz' : ''), $dump);
- // Выполняем запись системного сообщения в журнал
- reportLog($AVE_Template->get_config_vars('DB_REPORT_DUMP'));
- exit;
- }
+ @chmod(BASE_DIR . '/backup/'. $file_name . '.sql', 0777);
+ if (! $exit)
+ header('Location:index.php?do=dbsettings&cp=' . SESSION);
+ else
+ return BASE_DIR . '/backup/'. $file_name . '.sql'. (defined('DB_EXPORT_GZ') && DB_EXPORT_GZ ? '.gz' : '');
+ }
+ else
+ {
+ // Формируем заголовок
+ header('Content-Type: text/plain');
+ header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+ header('Content-Disposition: attachment; filename=' . $file_name . '.sql'. (defined('DB_EXPORT_GZ') && DB_EXPORT_GZ ? '.gz' : ''));
+ header('Content-Length: ' . strlen($dump));
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+ header('Pragma: public');
+
+ // Выводим данные
+ echo $dump;
+
+ $this->_database_dump = '';
+ }
- /**
- * Метод, предназначенный для сохранения файла дампа базы данных на жеский диск
- *
- */
- function databaseDumpFileSave($file = '')
- {
- global $AVE_Template;
+ // Выполняем запись системного сообщения в журнал
+ reportLog($AVE_Template->get_config_vars('DB_REPORT_DUMP'));
+ exit;
+ }
- $file = BASE_DIR . '/backup/'. $file;
- // Если дамп не удалось создать, тогда завершаем работу
- if (! is_file($file))
- return false;
+ /**
+ * Метод, предназначенный для сохранения файла дампа базы данных на жеский диск
+ *
+ */
+ function databaseDumpFileSave($file = '')
+ {
+ global $AVE_Template;
- header('Content-Description: File Transfer');
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename=' . basename($file));
- header('Content-Transfer-Encoding: binary');
- header('Expires: 0');
- header('Cache-Control: must-revalidate');
- header('Pragma: public');
- header('Content-Length: ' . filesize($file));
+ $file = BASE_DIR . '/backup/'. $file;
- ob_clean();
+ // Если дамп не удалось создать, тогда завершаем работу
+ if (! is_file($file))
+ return false;
- flush();
+ header('Content-Description: File Transfer');
+ header('Content-Type: application/octet-stream');
+ header('Content-Disposition: attachment; filename=' . basename($file));
+ header('Content-Transfer-Encoding: binary');
+ header('Expires: 0');
+ header('Cache-Control: must-revalidate');
+ header('Pragma: public');
+ header('Content-Length: ' . filesize($file));
- readfile($file);
+ ob_clean();
- exit;
- }
+ flush();
+ readfile($file);
- /**
- * Метод, предназначенный для восстановления базы данных из дампа
- *
- * @param string $tempdir путь к папке в которую загружается файл дампа
- */
- function databaseDumpImport($tempdir)
- {
- global $AVE_DB, $AVE_Template;
+ exit;
+ }
- $insert = false;
- // Если файл не пустой
- if ($_FILES['file']['size'] != 0)
+ /**
+ * Метод, предназначенный для восстановления базы данных из дампа
+ *
+ * @param string $tempdir путь к папке в которую загружается файл дампа
+ */
+ function databaseDumpImport($tempdir)
{
- // Получаем имя файла и его расширение (должно быть sql)
- $fupload_name = $_FILES['file']['name'];
- $gz = substr($fupload_name, -3)=='.gz';
- $end = substr($fupload_name, -3);
+ global $AVE_DB, $AVE_Template;
+
+ $insert = false;
- // Если расширение sql, тогда
- if ($gz || $end == 'sql')
+ // Если файл не пустой
+ if ($_FILES['file']['size'] != 0)
{
- // Если файл не удалось загрузить, формируем сообщение с ошибкой
- if (! @move_uploaded_file($_FILES['file']['tmp_name'], $tempdir . $fupload_name))
- die('Ошибка при загрузке файла!');
+ // Получаем имя файла и его расширение (должно быть sql)
+ $fupload_name = $_FILES['file']['name'];
+ $gz = substr($fupload_name, -3)=='.gz';
+ $end = substr($fupload_name, -3);
+
+ // Если расширение sql, тогда
+ if ($gz || $end == 'sql')
+ {
+ // Если файл не удалось загрузить, формируем сообщение с ошибкой
+ if (! @move_uploaded_file($_FILES['file']['tmp_name'], $tempdir . $fupload_name))
+ die('Ошибка при загрузке файла!');
- // Устанавливаем права чтения, записи, выполнения на файл
- @chmod($fupload_name, 0777);
+ // Устанавливаем права чтения, записи, выполнения на файл
+ @chmod($fupload_name, 0777);
- // Определяем флаг готовности к записи данных в БД
- $insert = true;
- }
- else
- {
- // В противном случае, если расширение файла НЕ sql, формируем сообщение с ошибкой
- $AVE_Template->assign('msg', 'Ошибка: ' . $AVE_Template->get_config_vars('MAIN_SQL_FILE_ERROR') . '');
+ // Определяем флаг готовности к записи данных в БД
+ $insert = true;
+ }
+ else
+ {
+ // В противном случае, если расширение файла НЕ sql, формируем сообщение с ошибкой
+ $AVE_Template->assign('msg', 'Ошибка: ' . $AVE_Template->get_config_vars('MAIN_SQL_FILE_ERROR') . '');
+ }
}
- }
- // Если флаг готовности записи установлен, тогда
- if ($insert)
- {
- // Еще раз провреяем наличие загруженного файла
- if ($fupload_name != '' && file_exists($tempdir . $fupload_name))
+ // Если флаг готовности записи установлен, тогда
+ if ($insert)
{
- // Читаем данные из файла
- $handle = @fopen($tempdir . $fupload_name, 'r');
+ // Еще раз провреяем наличие загруженного файла
+ if ($fupload_name != '' && file_exists($tempdir . $fupload_name))
+ {
+ // Читаем данные из файла
+ $handle = @fopen($tempdir . $fupload_name, 'r');
- $db_q = @fread($handle, filesize($tempdir . $fupload_name));
+ $db_q = @fread($handle, filesize($tempdir . $fupload_name));
- fclose($handle);
+ fclose($handle);
- if ($gz)
- $db_q = gzdecode($db_q);
+ if ($gz)
+ $db_q = gzdecode($db_q);
- $m_ok = 0;
+ $m_ok = 0;
- $m_fail = 0;
+ $m_fail = 0;
- // Формируем массив запросов ориентируясь по разделителю указанному в свойстве _delimiter
- $querys = @explode($this->_delimiter, $db_q);
+ // Формируем массив запросов ориентируясь по разделителю указанному в свойстве _delimiter
+ $querys = @explode($this->_delimiter, $db_q);
- // Циклически обрабатываем массив, выполняя каждый запрос
- foreach ($querys as $val)
- {
- if (chop($val) != '')
+ // Циклически обрабатываем массив, выполняя каждый запрос
+ foreach ($querys as $val)
{
- $q = str_replace("\n",'',$val);
-
- $q = $q . ';';
-
- if ($AVE_DB->Query($q))
+ if (chop($val) != '')
{
- $m_ok++;
- }
- else
- {
- $m_fail++;
+ $q = str_replace("\n",'',$val);
+
+ $q = $q . ';';
+
+ if ($AVE_DB->Query($q))
+ {
+ $m_ok++;
+ }
+ else
+ {
+ $m_fail++;
+ }
}
}
- }
- // Удаляем файл дампа
- @unlink($tempdir . $fupload_name);
+ // Удаляем файл дампа
+ @unlink($tempdir . $fupload_name);
- // Формируем сопроводительные сообщения
- $msg = '' . $AVE_Template->get_config_vars('MAIN_RESTORE_OK') . '
'
- . $AVE_Template->get_config_vars('MAIN_TABLE_SUCC')
- . '' . $m_ok . ' '
- . $AVE_Template->get_config_vars('MAIN_TABLE_ERROR')
- . '' . $m_fail . '';
+ // Формируем сопроводительные сообщения
+ $msg = '' . $AVE_Template->get_config_vars('MAIN_RESTORE_OK') . '
'
+ . $AVE_Template->get_config_vars('MAIN_TABLE_SUCC')
+ . '' . $m_ok . ' '
+ . $AVE_Template->get_config_vars('MAIN_TABLE_ERROR')
+ . '' . $m_fail . '';
- $AVE_Template->assign('msg', $msg);
- }
- else // В противном случае, если файл не найден, формируем сообщение с ошибкой
- {
- $AVE_Template->assign('msg', ''.$AVE_Template->get_config_vars('DB_REPORT_DUMP_ER').'');
+ $AVE_Template->assign('msg', $msg);
+ }
+ else // В противном случае, если файл не найден, формируем сообщение с ошибкой
+ {
+ $AVE_Template->assign('msg', ''.$AVE_Template->get_config_vars('DB_REPORT_DUMP_ER').'');
+ }
}
+
+ // Выполняем запись системного сообщения в журнал
+ reportLog($AVE_Template->get_config_vars('DB_REPORT_DUMP_RECOVER'));
}
- // Выполняем запись системного сообщения в журнал
- reportLog($AVE_Template->get_config_vars('DB_REPORT_DUMP_RECOVER'));
- }
+ /**
+ * Метод, предназначенный для удаления файла дампа на сервере
+ *
+ * @param string $file путь к файлу дампа
+ */
+ function databaseDumpFileDelete($file = '')
+ {
+ global $AVE_DB, $AVE_Template;
- /**
- * Метод, предназначенный для удаления файла дампа на сервере
- *
- * @param string $file путь к файлу дампа
- */
- function databaseDumpFileDelete($file = '')
- {
- global $AVE_DB, $AVE_Template;
+ $file = BASE_DIR . '/backup/'. $file;
- $file = BASE_DIR . '/backup/'. $file;
+ if (! is_file($file))
+ return false;
- if (! is_file($file))
- return false;
+ if (@unlink($file))
+ {
+ reportLog($AVE_Template->get_config_vars('DB_REPORT_DUMP_DEL_OK') . ' ('.basename($file).')');
+ }
+ else
+ {
+ reportLog($AVE_Template->get_config_vars('DB_REPORT_DUMP_DEL_ER') . ' ('.basename($file).')');
+ }
- if (@unlink($file))
- {
- reportLog($AVE_Template->get_config_vars('DB_REPORT_DUMP_DEL_OK') . ' ('.basename($file).')');
+ header('Location:index.php?do=dbsettings&cp=' . SESSION);
}
- else
- {
- reportLog($AVE_Template->get_config_vars('DB_REPORT_DUMP_DEL_ER') . ' ('.basename($file).')');
- }
-
- header('Location:index.php?do=dbsettings&cp=' . SESSION);
- }
- /**
- * Метод, предназначенный для восстановления базы данных из дампа на сервере
- *
- * @param string $file путь к файлу дампа
- */
- function databaseDumpFileImport($file = '')
- {
- global $AVE_DB, $AVE_Template;
-
- $insert = false;
+ /**
+ * Метод, предназначенный для восстановления базы данных из дампа на сервере
+ *
+ * @param string $file путь к файлу дампа
+ */
+ function databaseDumpFileImport($file = '')
+ {
+ global $AVE_DB, $AVE_Template;
- $file = BASE_DIR . '/backup/'. $file;
+ $insert = false;
- // Если дамп не удалось создать, тогда завершаем работу
- if (! is_file($file)) $insert = false;
+ $file = BASE_DIR . '/backup/'. $file;
- // Если файл не пустой
- if (filesize($file) != 0)
- {
- // Получаем имя файла и его расширение (должно быть sql)
- $file_name = basename($file);
- $gz = substr($file_name, -3)=='.gz';
- $end = substr($file_name, -3);
+ // Если дамп не удалось создать, тогда завершаем работу
+ if (! is_file($file)) $insert = false;
- // Если расширение sql, тогда
- if ($gz || $end == 'sql')
+ // Если файл не пустой
+ if (filesize($file) != 0)
{
- // Определяем флаг готовности к записи данных в БД
- $insert = true;
- }
- else
- {
- // В противном случае, если расширение файла НЕ sql, формируем сообщение с ошибкой
- $AVE_Template->assign('msg', 'Ошибка: ' . $AVE_Template->get_config_vars('MAIN_SQL_FILE_ERROR') . '');
+ // Получаем имя файла и его расширение (должно быть sql)
+ $file_name = basename($file);
+ $gz = substr($file_name, -3)=='.gz';
+ $end = substr($file_name, -3);
+
+ // Если расширение sql, тогда
+ if ($gz || $end == 'sql')
+ {
+ // Определяем флаг готовности к записи данных в БД
+ $insert = true;
+ }
+ else
+ {
+ // В противном случае, если расширение файла НЕ sql, формируем сообщение с ошибкой
+ $AVE_Template->assign('msg', 'Ошибка: ' . $AVE_Template->get_config_vars('MAIN_SQL_FILE_ERROR') . '');
+ }
}
- }
- // Если флаг готовности записи установлен, тогда
- if ($insert)
- {
- // Еще раз провреяем наличие загруженного файла
- if ($file_name != '' && file_exists($file))
+ // Если флаг готовности записи установлен, тогда
+ if ($insert)
{
- // Читаем данные из файла
- $handle = @fopen($file, 'r');
+ // Еще раз провреяем наличие загруженного файла
+ if ($file_name != '' && file_exists($file))
+ {
+ // Читаем данные из файла
+ $handle = @fopen($file, 'r');
- $db_q = @fread($handle, filesize($file));
+ $db_q = @fread($handle, filesize($file));
- fclose($handle);
+ fclose($handle);
- if($gz)$db_q=gzdecode($db_q);
+ if($gz)$db_q=gzdecode($db_q);
- $m_ok = 0;
+ $m_ok = 0;
- $m_fail = 0;
+ $m_fail = 0;
- // Формируем массив запросов ориентируясь по разделителю указанному в свойстве _delimiter
- $querys = @explode($this->_delimiter, $db_q);
+ // Формируем массив запросов ориентируясь по разделителю указанному в свойстве _delimiter
+ $querys = @explode($this->_delimiter, $db_q);
- // Циклически обрабатываем массив, выполняя каждый запрос
- foreach ($querys as $val)
- {
- if (chop($val) != '')
+ // Циклически обрабатываем массив, выполняя каждый запрос
+ foreach ($querys as $val)
{
- $q = str_replace("\n",'',$val);
+ if (chop($val) != '')
+ {
+ $q = str_replace("\n",'',$val);
- $q = $q . ';';
+ $q = $q . ';';
- @$q = str_replace('%%PRFX%%', PREFIX, $q);
+ @$q = str_replace('%%PRFX%%', PREFIX, $q);
- if ($AVE_DB->Query($q))
- {
- $m_ok++;
- }
- else
- {
- $m_fail++;
+ if ($AVE_DB->Query($q))
+ {
+ $m_ok++;
+ }
+ else
+ {
+ $m_fail++;
+ }
}
}
- }
- // Формируем сопроводительные сообщения
- $msg = '' . $AVE_Template->get_config_vars('MAIN_RESTORE_OK') . '
'
- . $AVE_Template->get_config_vars('MAIN_TABLE_SUCC')
- . '' . $m_ok . ' '
- . $AVE_Template->get_config_vars('MAIN_TABLE_ERROR')
- . '' . $m_fail . '';
+ // Формируем сопроводительные сообщения
+ $msg = '' . $AVE_Template->get_config_vars('MAIN_RESTORE_OK') . '
'
+ . $AVE_Template->get_config_vars('MAIN_TABLE_SUCC')
+ . '' . $m_ok . ' '
+ . $AVE_Template->get_config_vars('MAIN_TABLE_ERROR')
+ . '' . $m_fail . '';
- $AVE_Template->assign('msg', $msg);
- }
- else // В противном случае, если файл не найден, формируем сообщение с ошибкой
- {
- $AVE_Template->assign('msg', ''.$AVE_Template->get_config_vars('DB_REPORT_DUMP_ER').'');
+ $AVE_Template->assign('msg', $msg);
+ }
+ else // В противном случае, если файл не найден, формируем сообщение с ошибкой
+ {
+ $AVE_Template->assign('msg', ''.$AVE_Template->get_config_vars('DB_REPORT_DUMP_ER').'');
+ }
}
- }
-
- // Выполняем запись системного сообщения в журнал
- reportLog($AVE_Template->get_config_vars('DB_REPORT_DUMP_RECOVER') . ' ('.$file_name.')');
- }
-
- /**
- * Метод, предназначенный для оптимизации таблиц базы данных
- *
- */
- function databaseTableOptimize()
- {
- global $AVE_DB, $AVE_Template;
-
- if (! empty($_POST['ta']) && is_array($_POST['ta']))
- {
- // Выполняем запрос на оптимизацию
- $AVE_DB->Query("OPTIMIZE TABLE `" . implode("`, `", $_POST['ta']) . "`");
// Выполняем запись системного сообщения в журнал
- reportLog($AVE_Template->get_config_vars('DB_REPORT_DUMP_OPTIM'));
+ reportLog($AVE_Template->get_config_vars('DB_REPORT_DUMP_RECOVER') . ' ('.$file_name.')');
}
- }
- /**
- * Метод, предназначенный для восстановления повреждённых таблиц базы данных
- *
- */
- function databaseTableRepair()
- {
- global $AVE_DB, $AVE_Template;
-
- if (! empty($_POST['ta']) && is_array($_POST['ta']))
+ /**
+ * Метод, предназначенный для оптимизации таблиц базы данных
+ *
+ */
+ function databaseTableOptimize()
{
- // Выполняем запрос на восстановление
- $AVE_DB->Query("REPAIR TABLE `" . implode("`, `", $_POST['ta']) . "`");
+ global $AVE_DB, $AVE_Template;
- // Выполняем запись системного сообщения в журнал
- reportLog($AVE_Template->get_config_vars('DB_REPORT_DUMP_TABLE'));
+ if (! empty($_POST['ta']) && is_array($_POST['ta']))
+ {
+ // Выполняем запрос на оптимизацию
+ $AVE_DB->Query("OPTIMIZE TABLE `" . implode("`, `", $_POST['ta']) . "`");
+
+ // Выполняем запись системного сообщения в журнал
+ reportLog($AVE_Template->get_config_vars('DB_REPORT_DUMP_OPTIM'));
+ }
}
- }
- /**
- * Метод, предназначенный для формирования списка всех таблиц в БД
- *
- * @return string
- */
- function databaseTableGet()
- {
- global $AVE_DB;
+ /**
+ * Метод, предназначенный для восстановления повреждённых таблиц базы данных
+ *
+ */
+ function databaseTableRepair()
+ {
+ global $AVE_DB, $AVE_Template;
- $tables = '';
+ if (! empty($_POST['ta']) && is_array($_POST['ta']))
+ {
+ // Выполняем запрос на восстановление
+ $AVE_DB->Query("REPAIR TABLE `" . implode("`, `", $_POST['ta']) . "`");
- // Получаем список всех таблиц, которые имею префикс, указанный в конфигурации системы
- $sql = $AVE_DB->Query("SHOW TABLES LIKE '" . PREFIX . "_%'");
+ // Выполняем запись системного сообщения в журнал
+ reportLog($AVE_Template->get_config_vars('DB_REPORT_DUMP_TABLE'));
+ }
+ }
- while ($row = $sql->FetchArray())
+ /**
+ * Метод, предназначенный для формирования списка всех таблиц в БД
+ *
+ * @return string
+ */
+ function databaseTableGet()
{
- $tables .= '';
- }
+ global $AVE_DB;
- $sql->Close();
+ $tables = '';
- // Возвращаем полученный список
- return $tables;
- }
+ // Получаем список всех таблиц, которые имею префикс, указанный в конфигурации системы
+ $sql = $AVE_DB->Query("SHOW TABLES LIKE '" . PREFIX . "_%'");
- /**
- * Метод, предназначенный для вывода всех sql файлов в папке backup
- *
- * @return string
- */
- function databaseFilesGet()
- {
- $dir = BASE_DIR . '/backup/';
+ while ($row = $sql->FetchArray())
+ {
+ $tables .= '';
+ }
+
+ $sql->Close();
- if($handle = opendir($dir))
+ // Возвращаем полученный список
+ return $tables;
+ }
+
+ /**
+ * Метод, предназначенный для вывода всех sql файлов в папке backup
+ *
+ * @return string
+ */
+ function databaseFilesGet()
{
- $files = array();
+ $dir = BASE_DIR . '/backup/';
- while (false !== ($file = readdir($handle)))
+ if($handle = opendir($dir))
{
- if ($file != "." && $file != ".." && (substr($file, -3) == 'sql' || substr($file, -2) == 'gz'))
+ $files = array();
+
+ while (false !== ($file = readdir($handle)))
{
- if(is_file($dir . '/' . $file))
+ if ($file != "." && $file != ".." && (substr($file, -3) == 'sql' || substr($file, -2) == 'gz'))
{
- $files[] = array(
- 'name' => $file,
- 'data' => (filectime($dir . '/' . $file)),
- 'size' => (filesize($dir . '/' . $file))
- );
+ if(is_file($dir . '/' . $file))
+ {
+ $files[] = array(
+ 'name' => $file,
+ 'data' => (filectime($dir . '/' . $file)),
+ 'size' => (filesize($dir . '/' . $file))
+ );
+ }
}
}
+ closedir($handle);
}
- closedir($handle);
- }
- return msort($files, 'data', null, SORT_DESC);
+ return msort($files, 'data', null, SORT_DESC);
+ }
}
-}
-?>
+?>
\ No newline at end of file
diff --git a/class/class.debug.php b/class/class.debug.php
index 0c67029..0c5a45e 100644
--- a/class/class.debug.php
+++ b/class/class.debug.php
@@ -30,12 +30,13 @@
//
}
+
/**
* Функция для вывода переменной (для отладки)
*
* @param mixed $var любая переменная
*/
- public static function _echo($var, $exit = false)
+ public static function _echo($var, $exit = false, $bg = null)
{
$backtrace = debug_backtrace();
@@ -52,14 +53,14 @@
$line = 0;
while (++$line <= $backtrace['line'])
- {
$code = fgets($fh);
- }
fclose($fh);
preg_match('/' . __FUNCTION__ . '\s*\((.*)\)\s*;/u', $code, $name);
+ unset ($code, $backtrace);
+
ob_start();
var_dump($var);
@@ -70,17 +71,31 @@
$var_dump = htmlspecialchars($var_dump);
- $var_dump = preg_replace('/(=> )+([a-zA-Z]+\(\d+\))/', '$1$2', $var_dump);
+ $var_dump = preg_replace('/(=>)/', '$1', $var_dump);
ob_end_clean();
- $fn_name = ! empty($name)
- ? $name[1]
- : 'EVAL';
+ if (! empty($name))
+ {
+ $fn_name = explode(',', $name[1]);
+ $fn_name = array_shift($fn_name);
+ }
+ else
+ $fn_name = 'EVAL';
+
+ if (! $bg)
+ {
+ $br = '2a5885';
+ $bg = '43648c';
+ }
+ else
+ {
+ $br = $bg;
+ }
$var_dump = '
-
-
+
+
var_dump(' . trim($fn_name) . ') - ' . self::_trace() .
'
'
@@ -91,7 +106,8 @@
echo $var_dump;
- if ($exit) exit;
+ if ($exit)
+ exit;
}
@@ -100,7 +116,7 @@
*
* @param mixed $var любая переменная
*/
- public static function _print($var, $exit = false)
+ public static function _print($var, $exit = false, $bg = null)
{
$backtrace = debug_backtrace();
@@ -135,13 +151,27 @@
ob_end_clean();
- $fn_name = !empty($name)
- ? $name[1]
- : 'EVAL';
+ if (! empty($name))
+ {
+ $fn_name = explode(',', $name[1]);
+ $fn_name = array_shift($fn_name);
+ }
+ else
+ $fn_name = 'EVAL';
+
+ if (! $bg)
+ {
+ $br = '365899';
+ $bg = '4e5665';
+ }
+ else
+ {
+ $br = $bg;
+ }
$var_dump = '
-
-
+
+
print_r(' . trim($fn_name) . ') - ' . self::_trace() .
'
'
@@ -152,7 +182,8 @@
echo $var_dump;
- if ($exit) exit;
+ if ($exit)
+ exit;
}
@@ -161,7 +192,7 @@
*
* @param mixed $var любая переменная
*/
- public static function _exp($var, $exit = false)
+ public static function _exp($var, $exit = false, $bg = null)
{
$backtrace = debug_backtrace();
@@ -190,9 +221,23 @@
var_export($var);
- $fn_name = !empty($name)
- ? $name[1]
- : 'EVAL';
+ if (! empty($name))
+ {
+ $fn_name = explode(',', $name[1]);
+ $fn_name = array_shift($fn_name);
+ }
+ else
+ $fn_name = 'EVAL';
+
+ if (! $bg)
+ {
+ $br = 'bbb';
+ $bg = 'ccc';
+ }
+ else
+ {
+ $br = $bg;
+ }
$var_export = htmlspecialchars(ob_get_contents());
@@ -201,8 +246,8 @@
ob_end_clean();
$var_dump = '
-
- var_export( '
+
+ var_export('
. trim($fn_name) . ') - ' . self::_trace() .
'
'
@@ -213,7 +258,8 @@
echo $var_dump;
- if ($exit) exit;
+ if ($exit)
+ exit;
}
@@ -277,14 +323,13 @@
}
-
/**
* Функция для записи переменной в файл (для отладки)
*
* @param mixed $var любая переменная
* @param bool $exit true - остановливает дальнейшее выполнение скрипта, false - продолжает выполнять скрипт
*/
- public static function _dump($var, $append = true, $exit = false)
+ public static function _dump($var, $append = true, $exit = false, $bg = null)
{
$backtrace = debug_backtrace();
@@ -323,13 +368,27 @@
ob_end_clean();
- $fn_name = ! empty($name)
- ? $name[1]
- : 'EVAL';
+ if (! empty($name))
+ {
+ $fn_name = explode(',', $name[1]);
+ $fn_name = array_shift($fn_name);
+ }
+ else
+ $fn_name = 'EVAL';
+
+ if (! $bg)
+ {
+ $br = '2a5885';
+ $bg = '43648c';
+ }
+ else
+ {
+ $br = $bg;
+ }
$var_dump = '
-
-
+
+
' . date("j F Y, H:i:s") . ' - var_dump(' . trim($fn_name) . ') - ' . self::_trace() .
'
'
@@ -386,6 +445,7 @@
return sprintf('Class: %s | Type: %s | Function: %s | File: %s line %s', $class, $type, $function, $file, $line);
}
+
/**
* Функция отвечает за начало таймера
*
@@ -396,6 +456,7 @@
Debug::$time[$name] = microtime(true);
}
+
/**
* Функция отвечает за окончание таймера
*
@@ -408,6 +469,7 @@
return sprintf("%01.4f", microtime(true) - Debug::$time[$name]) . ' sec';
}
+
/**
* Функция отвечает за начало подсчета используеой памяти
*
@@ -418,6 +480,7 @@
Debug::$memory[$name] = memory_get_usage();
}
+
/**
* Функция отвечает за окончание подсчета используемой памяти
*
@@ -430,6 +493,7 @@
return Debug::formatSize(memory_get_usage() - Debug::$memory[$name]);
}
+
/**
* Форматированный вывод размера
*
@@ -458,6 +522,7 @@
return $size;
}
+
/**
* Форматированный вывод чисел
*
diff --git a/class/class.docs.php b/class/class.docs.php
index 60042a2..22ff970 100755
--- a/class/class.docs.php
+++ b/class/class.docs.php
@@ -163,19 +163,20 @@ class AVE_Document
$func = 'get_field_'.$field_type;
if (! is_callable($func))
- $func='get_field_default';
+ $func = 'get_field_default';
$field = $func($field_value, 'edit', $field_id, '', 0, $x, 0, 0, $default);
return $field;
}
+
function _documentFieldSave($field_type, $field_value, $field_id, $default = '')
{
$func = 'get_field_'.$field_type;
if (! is_callable($func))
- $func='get_field_default';
+ $func = 'get_field_default';
$field = $func($field_value, 'save', $field_id, '', 0, $x, 0, 0, $default);
@@ -340,7 +341,9 @@ class AVE_Document
AND
(df1.rubric_field_id = '" . (int)$_REQUEST['field_id'] . "'
AND
- UPPER(CONCAT_WS('', df1.field_value, NULLIF(df2.field_value, '')) = '" . mb_strtoupper($_REQUEST['field_search']) . "'))
+ UPPER(CONCAT_WS('', df1.field_value, NULLIF(df2.field_value, '')) = '" . mb_strtoupper($_REQUEST['field_search']) . "')
+ OR
+ df1.field_number_value = '" . mb_strtoupper($_REQUEST['field_search']) . "')
";
}
else if ($_REQUEST['field_request'] == 'like')
@@ -349,7 +352,9 @@ class AVE_Document
AND
(df1.rubric_field_id = '" . (int)$_REQUEST['field_id'] . "'
AND
- UPPER(CONCAT_WS('', df1.field_value, NULLIF(df2.field_value, '')) LIKE '%" . mb_strtoupper($_REQUEST['field_search']) . "%'))
+ UPPER(CONCAT_WS('', df1.field_value, NULLIF(df2.field_value, '')) LIKE '%" . mb_strtoupper($_REQUEST['field_search']) . "%')
+ OR
+ df1.field_number_value LIKE '%" . mb_strtoupper($_REQUEST['field_search']) . "%')
";
}
diff --git a/class/class.modules.php b/class/class.modules.php
index 941a7db..2750951 100644
--- a/class/class.modules.php
+++ b/class/class.modules.php
@@ -14,11 +14,13 @@
{
public $_modules = array();
+
function __construct()
{
$this->_modules = $this->getModules();
}
+
/**
* Метод, который обрабатывает все module.php и записывает как свойство класса списки модулей
*/
@@ -61,7 +63,7 @@
$module = array();
- if (! (is_file($module_dir . '/info.php') && @include($module_dir . '/info.php')))
+ if (! (is_file($module_dir . '/info.php') && @include_once($module_dir . '/info.php')))
{
// Если не удалось подключить основной файл модуля module.php - Фиксируем ошибку
$modules['errors'][] = $entry;
@@ -113,6 +115,7 @@
return $modules;
}
+
/**
* Метод, преданзначеный для выода модулей
*
@@ -196,25 +199,38 @@
$modules = array();
- // Условие, определяющее статус документа для запроса к БД
- $where_status = ($status !== null)
- ? "WHERE ModuleStatus = '" . (int)$status . "'"
- : '';
-
- // Выполняем запрос к БД и получаем список документов,
- // согласно статусу, либо все модули, если статус не указан
- $sql = $AVE_DB->Query("
- SELECT
- *
- FROM
- " . PREFIX . "_module
- " . $where_status . "
- ORDER BY
- ModuleName ASC
- ");
+ if (! empty($this->_modules))
+ {
+ foreach ($this->_modules AS $k => $v)
+ {
+ if ($status && $v['status'] != $status)
+ continue;
- while ($row = $sql->FetchRow())
- $modules[$row->ModuleSysName] = $row;
+ $modules[$k] = $v;
+ }
+ }
+ else
+ {
+ // Условие, определяющее статус документа для запроса к БД
+ $where_status = ($status !== null)
+ ? "WHERE ModuleStatus = '" . (int)$status . "'"
+ : '';
+
+ // Выполняем запрос к БД и получаем список документов,
+ // согласно статусу, либо все модули, если статус не указан
+ $sql = $AVE_DB->Query("
+ SELECT
+ *
+ FROM
+ " . PREFIX . "_module
+ " . $where_status . "
+ ORDER BY
+ ModuleName ASC
+ ");
+
+ while ($row = $sql->FetchRow())
+ $modules[$row->ModuleSysName] = $row;
+ }
// Возвращаем список модулей
return $modules;
@@ -248,6 +264,7 @@
exit;
}
+
/**
* Метод, предназанченный для установки или переустановки модуля
*
@@ -328,6 +345,7 @@
exit;
}
+
/**
* Метод, предназначенный для обновления модуля при увеличении номера версии модуля
*
@@ -385,6 +403,7 @@
exit;
}
+
/**
* Метод, предназанченный для удаление модуля
*
@@ -425,6 +444,7 @@
exit;
}
+
/**
* Метод, предназначенный для отключения/включение модуля в Панели управления
*
diff --git a/class/class.request.php b/class/class.request.php
index 1c5fe0f..d396930 100644
--- a/class/class.request.php
+++ b/class/class.request.php
@@ -1,869 +1,868 @@
_limit;
- $start = get_current_page() * $limit - $limit;
+ global $AVE_DB, $AVE_Template;
- // Получаем общее количество запросов
- $num = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_request")->GetCell();
+ $limit = '';
- // Если количество больше, чем установленный лимит, тогда формируем постраничную навигацию
- if ($num > $limit)
+ // Если используется постраничная навигация
+ if ($pagination)
{
- $page_nav = " {t}";
- $page_nav = get_pagination(ceil($num / $limit), 'page', $page_nav);
- $AVE_Template->assign('page_nav', $page_nav);
- }
-
- $limit = $pagination ? "LIMIT " . $start . "," . $limit : '';
- }
+ // Определяем лимит записей на страницу и начало диапазона выборки
+ $limit = $this->_limit;
+ $start = get_current_page() * $limit - $limit;
- // Выполняем запрос к БД на получение списка запросов с учетом лимита вывода на страницу (если необходимо)
- $items = array();
+ // Получаем общее количество запросов
+ $num = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_request")->GetCell();
- $sql = $AVE_DB->Query("
- SELECT *
- FROM " . PREFIX . "_request
- ORDER BY Id ASC
- " . $limit . "
- ");
+ // Если количество больше, чем установленный лимит, тогда формируем постраничную навигацию
+ if ($num > $limit)
+ {
+ $page_nav = " {t}";
+ $page_nav = get_pagination(ceil($num / $limit), 'page', $page_nav);
+ $AVE_Template->assign('page_nav', $page_nav);
+ }
- // Формируем массив из полученных данных
- while ($row = $sql->FetchRow())
- {
- $row->request_author = get_username_by_id($row->request_author_id);
- array_push($items, $row);
- }
+ $limit = $pagination ? "LIMIT " . $start . "," . $limit : '';
+ }
- // Возвращаем массив
- return $items;
- }
+ // Выполняем запрос к БД на получение списка запросов с учетом лимита вывода на страницу (если необходимо)
+ $items = array();
- /**
- * Получить наименование и описание Запроса по идентификатору
- *
- * @param int $request_id идентификатор Запроса
- * @return object наименование Запроса
- */
- function get_request_by_id($request_id = 0)
- {
- global $AVE_DB;
+ $sql = $AVE_DB->Query("
+ SELECT *
+ FROM " . PREFIX . "_request
+ ORDER BY Id ASC
+ " . $limit . "
+ ");
- static $requests = array();
+ // Формируем массив из полученных данных
+ while ($row = $sql->FetchRow())
+ {
+ $row->request_author = get_username_by_id($row->request_author_id);
+ array_push($items, $row);
+ }
- if (!isset($requests[$request_id]))
- {
- $requests[$request_id] = $AVE_DB->Query("
- SELECT
- rubric_id,
- request_title,
- request_description
- FROM " . PREFIX . "_request
- WHERE Id = '" . $request_id . "'
- LIMIT 1
- ")->FetchRow();
+ // Возвращаем массив
+ return $items;
}
- return $requests[$request_id];
- }
+ /**
+ * Получить наименование и описание Запроса по идентификатору
+ *
+ * @param int $request_id идентификатор Запроса
+ * @return object наименование Запроса
+ */
+ function get_request_by_id($request_id = 0)
+ {
+ global $AVE_DB;
- /**
- * Проверка алиаса тега на валидность и уникальность
- */
- function requestValidate ($alias = '', $id = 0)
- {
- global $AVE_DB;
-
- //-- Соответствие требованиям
- 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
- FROM
- " . PREFIX . "_request
- WHERE
- request_alias = '" . $alias . "'
- AND
- Id != '" . $id . "'
- ")->GetCell();
- }
+ static $requests = array();
-/**
- * Внешние методы класса
- */
+ if (!isset($requests[$request_id]))
+ {
+ $requests[$request_id] = $AVE_DB->Query("
+ SELECT
+ rubric_id,
+ request_title,
+ request_description
+ FROM " . PREFIX . "_request
+ WHERE Id = '" . $request_id . "'
+ LIMIT 1
+ ")->FetchRow();
+ }
- /**
- * Метод, предназначенный для формирования списка Запросов
- *
- */
- function requestListFetch()
- {
- global $AVE_Template;
+ return $requests[$request_id];
+ }
- $AVE_Template->assign('conditions', $this->_requestListGet(false));
- }
+ /**
+ * Проверка алиаса тега на валидность и уникальность
+ */
+ function requestValidate ($alias = '', $id = 0)
+ {
+ global $AVE_DB;
+
+ //-- Соответствие требованиям
+ 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
+ FROM
+ " . PREFIX . "_request
+ WHERE
+ request_alias = '" . $alias . "'
+ AND
+ Id != '" . $id . "'
+ ")->GetCell();
+ }
/**
- * Метод, предназначенный для отображения списка Запросов
- *
+ * Внешние методы класса
*/
- function requestListShow()
- {
- global $AVE_Template;
-
- $AVE_Template->assign('rid', 0);
- // Получаем список запросов
- $AVE_Template->assign('items', $this->_requestListGet());
-
- // Передаем в шаблон и отображаем страницу со списком
- $AVE_Template->assign('content', $AVE_Template->fetch('request/list.tpl'));
- }
+ /**
+ * Метод, предназначенный для формирования списка Запросов
+ *
+ */
+ function requestListFetch()
+ {
+ global $AVE_Template;
- /**
- * Метод, предназначенный для создания нового Запроса
- *
- */
- function requestNew()
- {
- global $AVE_DB, $AVE_Template;
+ $AVE_Template->assign('conditions', $this->_requestListGet(false));
+ }
- // Определяем действие пользователя
- switch ($_REQUEST['sub'])
+ /**
+ * Метод, предназначенный для отображения списка Запросов
+ *
+ */
+ function requestListShow()
{
- // Действие не определено
- case '':
- $AVE_Template->assign('rid', 0);
- // Отображаем пустую форму для создания нового запроса
- $AVE_Template->assign('formaction', 'index.php?do=request&action=new&sub=save&cp=' . SESSION);
- $AVE_Template->assign('content', $AVE_Template->fetch('request/form.tpl'));
- break;
+ global $AVE_Template;
- // Нажата кнопка Сохранить запрос
- case 'save':
- $save = true;
- $errors = array();
-
- $row->request_template_item = pretty_chars($_REQUEST['request_template_item']);
- $row->request_template_item = stripslashes($row->request_template_item);
- $row->request_template_main = pretty_chars($_REQUEST['request_template_main']);
- $row->request_template_main = stripslashes($row->request_template_main);
- $row->request_title = stripslashes($_REQUEST['request_title']);
- $row->rubric_id = stripslashes($_REQUEST['rubric_id']);
- $row->request_items_per_page = stripslashes($_REQUEST['request_items_per_page']);
- $row->request_order_by = stripslashes($_REQUEST['request_order_by']);
- $row->request_order_by_nat = stripslashes($_REQUEST['request_order_by_nat']);
- $row->request_asc_desc = stripslashes($_REQUEST['request_asc_desc']);
- $row->request_description = stripslashes($_REQUEST['request_description']);
- $row->request_show_pagination = (isset($_REQUEST['request_show_pagination']) ? (int)($_REQUEST['request_show_pagination']) : 0);
- $row->request_pagination = (isset($_REQUEST['request_pagination']) ? (int)($_REQUEST['request_pagination']) : 1);
- $row->request_only_owner = (isset($_REQUEST['request_only_owner']) ? (int)($_REQUEST['request_only_owner']) : 0);
- $row->request_cache_lifetime = (int)($_REQUEST['request_cache_lifetime']);
- $row->request_lang = (isset($_REQUEST['request_lang']) ? (int)$_REQUEST['request_lang'] : 0);
- $row->request_cache_elements = (isset($_REQUEST['request_cache_elements']) ? (int)$_REQUEST['request_cache_elements'] : 0);
- $row->request_external = (isset($_REQUEST['request_external']) ? (int)$_REQUEST['request_external'] : 0);
- $row->request_ajax = (isset($_REQUEST['request_ajax']) ? (int)$_REQUEST['request_ajax'] : 0);
- $row->request_show_sql = (isset($_REQUEST['request_show_sql']) ? (int)$_REQUEST['request_show_sql'] : 0);
-
- if (empty($_REQUEST['rubric_id']))
- {
- $save = false;
- $message = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_RUBRIC');
- $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_RUBRIC');
- }
+ $AVE_Template->assign('rid', 0);
- if (empty($_REQUEST['request_title']))
- {
- $save = false;
- $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_TITLE');
- }
-
- if (empty($_REQUEST['request_template_main']))
- {
- $save = false;
- $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_TEXT');
- }
+ // Получаем список запросов
+ $AVE_Template->assign('items', $this->_requestListGet());
- $check_code_template_item = strtolower($_REQUEST['request_template_item']);
- $check_code_template_main = strtolower($_REQUEST['request_template_main']);
+ // Передаем в шаблон и отображаем страницу со списком
+ $AVE_Template->assign('content', $AVE_Template->fetch('request/list.tpl'));
+ }
- if ((is_php_code($check_code_template_item) || is_php_code($check_code_template_main)) && !check_permission('request_php'))
- {
- $save = false;
- $message = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_PHP');
- $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_PHP');
- reportLog($AVE_Template->get_config_vars('REQUEST_REPORT_ERR_PHP_N') . ' (' . stripslashes(htmlspecialchars($_REQUEST['request_title'], ENT_QUOTES)) . ')');
- }
+ /**
+ * Метод, предназначенный для создания нового Запроса
+ *
+ */
+ function requestNew()
+ {
+ global $AVE_DB, $AVE_Template;
- if ($save === false)
- {
- $AVE_Template->assign('row', $row);
- $AVE_Template->assign('errors', $errors);
+ // Определяем действие пользователя
+ switch ($_REQUEST['sub'])
+ {
+ // Действие не определено
+ case '':
+ $AVE_Template->assign('rid', 0);
+ // Отображаем пустую форму для создания нового запроса
$AVE_Template->assign('formaction', 'index.php?do=request&action=new&sub=save&cp=' . SESSION);
$AVE_Template->assign('content', $AVE_Template->fetch('request/form.tpl'));
- }
- else
- {
- // Выполняем запрос к БД и сохраняем введенную пользователем информацию
- $AVE_DB->Query("
- INSERT " . PREFIX . "_request
- SET
- rubric_id = '" . (int)$_REQUEST['rubric_id'] . "',
- request_alias = '" . $_REQUEST['request_alias'] . "',
- request_title = '" . $_REQUEST['request_title'] . "',
- request_items_per_page = '" . $_REQUEST['request_items_per_page'] . "',
- request_template_item = '" . $_REQUEST['request_template_item'] . "',
- request_template_main = '" . $_REQUEST['request_template_main'] . "',
- request_order_by = '" . $_REQUEST['request_order_by'] . "',
- request_order_by_nat = '" . $_REQUEST['request_order_by_nat'] . "',
- request_asc_desc = '" . $_REQUEST['request_asc_desc'] . "',
- request_author_id = '" . (int)$_SESSION['user_id'] . "',
- request_created = '" . time() . "',
- request_description = '" . $_REQUEST['request_description'] . "',
- request_show_pagination = '" . (isset($_REQUEST['request_show_pagination']) ? (int)$_REQUEST['request_show_pagination'] : 0) . "',
- request_pagination = '" . (isset($_REQUEST['request_pagination']) ? (int)$_REQUEST['request_pagination'] : 1) . "',
- request_use_query = '" . (isset($_REQUEST['request_use_query']) ? (int)$_REQUEST['request_use_query'] : 0) . "',
- request_hide_current = '" . (int)$_REQUEST['request_hide_current'] . "',
- request_only_owner = '" . (int)$_REQUEST['request_only_owner'] . "',
- request_cache_lifetime = '" . (int)$_REQUEST['request_cache_lifetime'] . "',
- request_lang = '" . (isset($_REQUEST['request_lang']) ? (int)$_REQUEST['request_lang'] : 0) . "',
- request_cache_elements = '" . (isset($_REQUEST['request_cache_elements']) ? (int)$_REQUEST['request_cache_elements'] : 0). "',
- request_show_statistic = '" . (isset($_REQUEST['request_show_statistic']) ? (int)$_REQUEST['request_show_statistic'] : 0). "',
- request_external = '" . (isset($_REQUEST['request_external']) ? (int)$_REQUEST['request_external'] : 0). "',
- request_ajax = '" . (isset($_REQUEST['request_ajax']) ? (int)$_REQUEST['request_ajax'] : 0). "',
- request_show_sql = '" . (isset($_REQUEST['request_show_sql']) ? (int)$_REQUEST['request_show_sql'] : 0). "'
- ");
+ break;
+
+ // Нажата кнопка Сохранить запрос
+ case 'save':
+ $save = true;
+ $errors = array();
+
+ $row->request_template_item = pretty_chars($_REQUEST['request_template_item']);
+ $row->request_template_item = stripslashes($row->request_template_item);
+ $row->request_template_main = pretty_chars($_REQUEST['request_template_main']);
+ $row->request_template_main = stripslashes($row->request_template_main);
+ $row->request_title = stripslashes($_REQUEST['request_title']);
+ $row->rubric_id = stripslashes($_REQUEST['rubric_id']);
+ $row->request_items_per_page = stripslashes($_REQUEST['request_items_per_page']);
+ $row->request_order_by = stripslashes($_REQUEST['request_order_by']);
+ $row->request_order_by_nat = stripslashes($_REQUEST['request_order_by_nat']);
+ $row->request_asc_desc = stripslashes($_REQUEST['request_asc_desc']);
+ $row->request_description = stripslashes($_REQUEST['request_description']);
+ $row->request_show_pagination = (isset($_REQUEST['request_show_pagination']) ? (int)($_REQUEST['request_show_pagination']) : 0);
+ $row->request_pagination = (isset($_REQUEST['request_pagination']) ? (int)($_REQUEST['request_pagination']) : 1);
+ $row->request_only_owner = (isset($_REQUEST['request_only_owner']) ? (int)($_REQUEST['request_only_owner']) : 0);
+ $row->request_cache_lifetime = (int)($_REQUEST['request_cache_lifetime']);
+ $row->request_lang = (isset($_REQUEST['request_lang']) ? (int)$_REQUEST['request_lang'] : 0);
+ $row->request_cache_elements = (isset($_REQUEST['request_cache_elements']) ? (int)$_REQUEST['request_cache_elements'] : 0);
+ $row->request_external = (isset($_REQUEST['request_external']) ? (int)$_REQUEST['request_external'] : 0);
+ $row->request_ajax = (isset($_REQUEST['request_ajax']) ? (int)$_REQUEST['request_ajax'] : 0);
+ $row->request_show_sql = (isset($_REQUEST['request_show_sql']) ? (int)$_REQUEST['request_show_sql'] : 0);
+
+ if (empty($_REQUEST['rubric_id']))
+ {
+ $save = false;
+ $message = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_RUBRIC');
+ $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_RUBRIC');
+ }
+
+ if (empty($_REQUEST['request_title']))
+ {
+ $save = false;
+ $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_TITLE');
+ }
- // Получаем id последней записи
- $iid = $AVE_DB->InsertId();
+ if (empty($_REQUEST['request_template_main']))
+ {
+ $save = false;
+ $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_TEXT');
+ }
- // Сохраняем системное сообщение в журнал
- reportLog($AVE_Template->get_config_vars('REQUEST_ADD_NEW_SUC') . ' (' . stripslashes(htmlspecialchars($_REQUEST['request_title'], ENT_QUOTES)) . ') (' . $iid . ')');
+ $check_code_template_item = strtolower($_REQUEST['request_template_item']);
+ $check_code_template_main = strtolower($_REQUEST['request_template_main']);
- // Если в запросе пришел параметр на продолжение редактирования запроса
- if ($_REQUEST['reedit'] == 1)
+ if ((is_php_code($check_code_template_item) || is_php_code($check_code_template_main)) && !check_permission('request_php'))
{
- // Выполняем переход на страницу с редактированием запроса
- header('Location:index.php?do=request&action=edit&Id=' . $iid . '&rubric_id=' . $_REQUEST['rubric_id'] . '&cp=' . SESSION);
+ $save = false;
+ $message = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_PHP');
+ $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_PHP');
+ reportLog($AVE_Template->get_config_vars('REQUEST_REPORT_ERR_PHP_N') . ' (' . stripslashes(htmlspecialchars($_REQUEST['request_title'], ENT_QUOTES)) . ')');
+ }
+
+ if ($save === false)
+ {
+ $AVE_Template->assign('row', $row);
+ $AVE_Template->assign('errors', $errors);
+ $AVE_Template->assign('formaction', 'index.php?do=request&action=new&sub=save&cp=' . SESSION);
+ $AVE_Template->assign('content', $AVE_Template->fetch('request/form.tpl'));
}
else
{
- // В противном случае выполняем переход к списку запросов
- if (!$_REQUEST['next_edit']) {
- header('Location:index.php?do=request&cp=' . SESSION);
- } else {
- header('Location:index.php?do=request&action=edit&Id=' . $iid . '&rubric_id='.$_REQUEST['rubric_id'].'&cp=' . SESSION);
+ // Выполняем запрос к БД и сохраняем введенную пользователем информацию
+ $AVE_DB->Query("
+ INSERT " . PREFIX . "_request
+ SET
+ rubric_id = '" . (int)$_REQUEST['rubric_id'] . "',
+ request_alias = '" . $_REQUEST['request_alias'] . "',
+ request_title = '" . $_REQUEST['request_title'] . "',
+ request_items_per_page = '" . $_REQUEST['request_items_per_page'] . "',
+ request_template_item = '" . $_REQUEST['request_template_item'] . "',
+ request_template_main = '" . $_REQUEST['request_template_main'] . "',
+ request_order_by = '" . $_REQUEST['request_order_by'] . "',
+ request_order_by_nat = '" . $_REQUEST['request_order_by_nat'] . "',
+ request_asc_desc = '" . $_REQUEST['request_asc_desc'] . "',
+ request_author_id = '" . (int)$_SESSION['user_id'] . "',
+ request_created = '" . time() . "',
+ request_description = '" . $_REQUEST['request_description'] . "',
+ request_show_pagination = '" . (isset($_REQUEST['request_show_pagination']) ? (int)$_REQUEST['request_show_pagination'] : 0) . "',
+ request_pagination = '" . (isset($_REQUEST['request_pagination']) ? (int)$_REQUEST['request_pagination'] : 1) . "',
+ request_use_query = '" . (isset($_REQUEST['request_use_query']) ? (int)$_REQUEST['request_use_query'] : 0) . "',
+ request_hide_current = '" . (int)$_REQUEST['request_hide_current'] . "',
+ request_only_owner = '" . (int)$_REQUEST['request_only_owner'] . "',
+ request_cache_lifetime = '" . (int)$_REQUEST['request_cache_lifetime'] . "',
+ request_lang = '" . (isset($_REQUEST['request_lang']) ? (int)$_REQUEST['request_lang'] : 0) . "',
+ request_cache_elements = '" . (isset($_REQUEST['request_cache_elements']) ? (int)$_REQUEST['request_cache_elements'] : 0). "',
+ request_show_statistic = '" . (isset($_REQUEST['request_show_statistic']) ? (int)$_REQUEST['request_show_statistic'] : 0). "',
+ request_external = '" . (isset($_REQUEST['request_external']) ? (int)$_REQUEST['request_external'] : 0). "',
+ request_ajax = '" . (isset($_REQUEST['request_ajax']) ? (int)$_REQUEST['request_ajax'] : 0). "',
+ request_show_sql = '" . (isset($_REQUEST['request_show_sql']) ? (int)$_REQUEST['request_show_sql'] : 0). "'
+ ");
+
+ // Получаем id последней записи
+ $iid = $AVE_DB->InsertId();
+
+ // Сохраняем системное сообщение в журнал
+ reportLog($AVE_Template->get_config_vars('REQUEST_ADD_NEW_SUC') . ' (' . stripslashes(htmlspecialchars($_REQUEST['request_title'], ENT_QUOTES)) . ') (' . $iid . ')');
+
+ // Если в запросе пришел параметр на продолжение редактирования запроса
+ if ($_REQUEST['reedit'] == 1)
+ {
+ // Выполняем переход на страницу с редактированием запроса
+ header('Location:index.php?do=request&action=edit&Id=' . $iid . '&rubric_id=' . $_REQUEST['rubric_id'] . '&cp=' . SESSION);
+ }
+ else
+ {
+ // В противном случае выполняем переход к списку запросов
+ if (!$_REQUEST['next_edit']) {
+ header('Location:index.php?do=request&cp=' . SESSION);
+ } else {
+ header('Location:index.php?do=request&action=edit&Id=' . $iid . '&rubric_id='.$_REQUEST['rubric_id'].'&cp=' . SESSION);
+ }
}
+ exit;
}
- exit;
}
- }
- }
-
- /**
- * Метод, предназначенный для редактирования Запроса
- *
- * @param int $request_id идентификатор запроса
- */
- function requestEdit($request_id)
- {
- global $AVE_DB, $AVE_Template;
+ }
- // Определяем действие пользователя
- switch ($_REQUEST['sub'])
+ /**
+ * Метод, предназначенный для редактирования Запроса
+ *
+ * @param int $request_id идентификатор запроса
+ */
+ function requestEdit($request_id)
{
- // Если действие не определено
- case '':
- // Выполняем запрос к БД и получаем всю информацию о запросе
- $sql = $AVE_DB->Query("
- SELECT *
- FROM " . PREFIX . "_request
- WHERE Id = '" . $request_id . "'
- ");
+ global $AVE_DB, $AVE_Template;
- if ($sql->_result->num_rows == 0)
- {
- header('Location:index.php?do=request&cp=' . SESSION);
- exit;
- }
+ // Определяем действие пользователя
+ switch ($_REQUEST['sub'])
+ {
+ // Если действие не определено
+ case '':
+ // Выполняем запрос к БД и получаем всю информацию о запросе
+ $sql = $AVE_DB->Query("
+ SELECT *
+ FROM " . PREFIX . "_request
+ WHERE Id = '" . $request_id . "'
+ ");
- $row = $sql->FetchRow();
+ if ($sql->_result->num_rows == 0)
+ {
+ header('Location:index.php?do=request&cp=' . SESSION);
+ exit;
+ }
- // Получаем постраничную навигацию
- $sql = $AVE_DB->Query("
- SELECT
- id,
- pagination_name
- FROM
- " . PREFIX . "_paginations
- ");
+ $row = $sql->FetchRow();
- $paginations = array();
+ // Получаем постраничную навигацию
+ $sql = $AVE_DB->Query("
+ SELECT
+ id,
+ pagination_name
+ FROM
+ " . PREFIX . "_paginations
+ ");
- while ($pages = $sql->FetchRow())
- {
- array_push($paginations, $pages);
- }
+ $paginations = array();
- // Передаем данные в шаблон и отображаем страницу с редактированием запроса
- $AVE_Template->assign('row', $row);
- $AVE_Template->assign('rid', $request_id);
- $AVE_Template->assign('paginations', $paginations);
- $AVE_Template->assign('formaction', 'index.php?do=request&action=edit&sub=save&Id=' . $request_id . '&cp=' . SESSION);
- $AVE_Template->assign('content', $AVE_Template->fetch('request/form.tpl'));
+ while ($pages = $sql->FetchRow())
+ {
+ array_push($paginations, $pages);
+ }
- break;
+ // Передаем данные в шаблон и отображаем страницу с редактированием запроса
+ $AVE_Template->assign('row', $row);
+ $AVE_Template->assign('rid', $request_id);
+ $AVE_Template->assign('paginations', $paginations);
+ $AVE_Template->assign('formaction', 'index.php?do=request&action=edit&sub=save&Id=' . $request_id . '&cp=' . SESSION);
+ $AVE_Template->assign('content', $AVE_Template->fetch('request/form.tpl'));
- // Пользователь нажал кнопку Сохранить изменения
- case 'save':
+ break;
- $sql = $AVE_DB->Query("
- SELECT *
- FROM " . PREFIX . "_request
- WHERE Id = '" . $request_id . "'
- ");
+ // Пользователь нажал кнопку Сохранить изменения
+ case 'save':
- if($sql->_result->num_rows == 0) {
- header('Location:index.php?do=request&cp=' . SESSION);
- exit;
- }
+ $sql = $AVE_DB->Query("
+ SELECT *
+ FROM " . PREFIX . "_request
+ WHERE Id = '" . $request_id . "'
+ ");
- $save = true;
- $errors = array();
- $row = new stdClass();
- $row->request_template_item = (isset($_REQUEST['request_template_item']) ? stripslashes(pretty_chars($_REQUEST['request_template_item'])) : '');
- $row->request_template_main = (isset($_REQUEST['request_template_main']) ? stripslashes(pretty_chars($_REQUEST['request_template_main'])) : '');
- $row->request_title = (isset($_REQUEST['request_title']) ? stripslashes($_REQUEST['request_title']) : '');
- $row->rubric_id = (isset($_REQUEST['rubric_id']) ? stripslashes($_REQUEST['rubric_id']) : 0);
- $row->request_items_per_page = (isset($_REQUEST['request_items_per_page']) ? stripslashes($_REQUEST['request_items_per_page']) : 0);
- $row->request_order_by = (isset($_REQUEST['request_order_by']) ? stripslashes($_REQUEST['request_order_by']) : '');
- $row->request_order_by_nat = (isset($_REQUEST['request_order_by_nat']) ? stripslashes($_REQUEST['request_order_by_nat']) : '');
- $row->request_asc_desc = (isset($_REQUEST['request_asc_desc']) ? stripslashes($_REQUEST['request_asc_desc']) : 'DESC');
- $row->request_description = (isset($_REQUEST['request_description']) ? stripslashes($_REQUEST['request_description']) : '');
- $row->request_show_pagination = (isset($_REQUEST['request_show_pagination']) ? $_REQUEST['request_show_pagination'] : 0);
- $row->request_pagination = (isset($_REQUEST['request_pagination']) ? (int)($_REQUEST['request_pagination']) : 1);
- $row->request_use_query = (isset($_REQUEST['request_use_query']) ? $_REQUEST['request_use_query'] : 0);
- $row->request_only_owner = (isset($_REQUEST['request_only_owner']) ? (int)($_REQUEST['request_only_owner']) : 0);
- $row->request_cache_lifetime = (isset($_REQUEST['request_cache_lifetime']) ? (int)($_REQUEST['request_cache_lifetime']) : 0);
- $row->request_lang = (isset($_REQUEST['request_lang']) ? (int)$_REQUEST['request_lang'] : 0);
- $row->request_cache_elements = (isset($_REQUEST['request_cache_elements']) ? (int)$_REQUEST['request_cache_elements'] : 0);
- $row->request_show_statistic = (isset($_REQUEST['request_show_statistic']) ? (int)$_REQUEST['request_show_statistic'] : 0);
- $row->request_external = (isset($_REQUEST['request_external']) ? (int)$_REQUEST['request_external'] : 0);
- $row->request_ajax = (isset($_REQUEST['request_ajax']) ? (int)$_REQUEST['request_ajax'] : 0);
- $row->request_show_sql = (isset($_REQUEST['request_show_sql']) ? (int)$_REQUEST['request_show_sql'] : 0);
-
- if (empty($_REQUEST['rubric_id']))
- {
- $save = false;
- $message = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_RUBRIC');
- $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_RUBRIC');
- }
+ if($sql->_result->num_rows == 0) {
+ header('Location:index.php?do=request&cp=' . SESSION);
+ exit;
+ }
- if (empty($_REQUEST['request_title']))
- {
- $save = false;
- $message = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_TITLE');
- $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_TITLE');
- }
+ $save = true;
+ $errors = array();
+ $row = new stdClass();
+ $row->request_template_item = (isset($_REQUEST['request_template_item']) ? stripslashes(pretty_chars($_REQUEST['request_template_item'])) : '');
+ $row->request_template_main = (isset($_REQUEST['request_template_main']) ? stripslashes(pretty_chars($_REQUEST['request_template_main'])) : '');
+ $row->request_title = (isset($_REQUEST['request_title']) ? stripslashes($_REQUEST['request_title']) : '');
+ $row->rubric_id = (isset($_REQUEST['rubric_id']) ? stripslashes($_REQUEST['rubric_id']) : 0);
+ $row->request_items_per_page = (isset($_REQUEST['request_items_per_page']) ? stripslashes($_REQUEST['request_items_per_page']) : 0);
+ $row->request_order_by = (isset($_REQUEST['request_order_by']) ? stripslashes($_REQUEST['request_order_by']) : '');
+ $row->request_order_by_nat = (isset($_REQUEST['request_order_by_nat']) ? stripslashes($_REQUEST['request_order_by_nat']) : '');
+ $row->request_asc_desc = (isset($_REQUEST['request_asc_desc']) ? stripslashes($_REQUEST['request_asc_desc']) : 'DESC');
+ $row->request_description = (isset($_REQUEST['request_description']) ? stripslashes($_REQUEST['request_description']) : '');
+ $row->request_show_pagination = (isset($_REQUEST['request_show_pagination']) ? $_REQUEST['request_show_pagination'] : 0);
+ $row->request_pagination = (isset($_REQUEST['request_pagination']) ? (int)($_REQUEST['request_pagination']) : 1);
+ $row->request_use_query = (isset($_REQUEST['request_use_query']) ? $_REQUEST['request_use_query'] : 0);
+ $row->request_only_owner = (isset($_REQUEST['request_only_owner']) ? (int)($_REQUEST['request_only_owner']) : 0);
+ $row->request_cache_lifetime = (isset($_REQUEST['request_cache_lifetime']) ? (int)($_REQUEST['request_cache_lifetime']) : 0);
+ $row->request_lang = (isset($_REQUEST['request_lang']) ? (int)$_REQUEST['request_lang'] : 0);
+ $row->request_cache_elements = (isset($_REQUEST['request_cache_elements']) ? (int)$_REQUEST['request_cache_elements'] : 0);
+ $row->request_show_statistic = (isset($_REQUEST['request_show_statistic']) ? (int)$_REQUEST['request_show_statistic'] : 0);
+ $row->request_external = (isset($_REQUEST['request_external']) ? (int)$_REQUEST['request_external'] : 0);
+ $row->request_ajax = (isset($_REQUEST['request_ajax']) ? (int)$_REQUEST['request_ajax'] : 0);
+ $row->request_show_sql = (isset($_REQUEST['request_show_sql']) ? (int)$_REQUEST['request_show_sql'] : 0);
+
+ if (empty($_REQUEST['rubric_id']))
+ {
+ $save = false;
+ $message = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_RUBRIC');
+ $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_RUBRIC');
+ }
- if (empty($_REQUEST['request_template_main']))
- {
- $save = false;
- $message = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_TEXT');
- $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_TEXT');
- }
+ if (empty($_REQUEST['request_title']))
+ {
+ $save = false;
+ $message = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_TITLE');
+ $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_TITLE');
+ }
- $check_code_template_item = strtolower($_REQUEST['request_template_item']);
- $check_code_template_main = strtolower($_REQUEST['request_template_main']);
+ if (empty($_REQUEST['request_template_main']))
+ {
+ $save = false;
+ $message = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_TEXT');
+ $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_TEXT');
+ }
- if ((is_php_code($check_code_template_item) || is_php_code($check_code_template_main)) && !check_permission('request_php'))
- {
- $save = false;
- $message = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_PHP');
- $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_PHP');
- reportLog($AVE_Template->get_config_vars('REQUEST_REPORT_ERR_PHP_E') . ' (' . stripslashes(htmlspecialchars($_REQUEST['request_title'], ENT_QUOTES)) . ') (Id:' . $request_id . ')');
- }
+ $check_code_template_item = strtolower($_REQUEST['request_template_item']);
+ $check_code_template_main = strtolower($_REQUEST['request_template_main']);
- if ($save === false)
- {
- if(isAjax())
+ if ((is_php_code($check_code_template_item) || is_php_code($check_code_template_main)) && !check_permission('request_php'))
{
- $header = $AVE_Template->get_config_vars('REQUEST_ERROR');
- echo json_encode(array('message' => $message, 'header' => $header, 'theme' => 'error'));
- exit;
+ $save = false;
+ $message = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_PHP');
+ $errors[] = $AVE_Template->get_config_vars('REQUEST_REPORT_ERR_PHP');
+ reportLog($AVE_Template->get_config_vars('REQUEST_REPORT_ERR_PHP_E') . ' (' . stripslashes(htmlspecialchars($_REQUEST['request_title'], ENT_QUOTES)) . ') (Id:' . $request_id . ')');
}
- $AVE_Template->assign('row', $row);
- $AVE_Template->assign('errors', $errors);
- $AVE_Template->assign('formaction', 'index.php?do=request&action=edit&sub=save&Id=' . $request_id . '&cp=' . SESSION);
- $AVE_Template->assign('content', $AVE_Template->fetch('request/form.tpl'));
- }
- else
- {
- // Выполняем запрос к БД и обновляем имеющиеся данные
- $AVE_DB->Query("
- UPDATE " . PREFIX . "_request
- SET
- rubric_id = '" . (int)$_REQUEST['rubric_id'] . "',
- request_alias = '" . $_REQUEST['request_alias'] . "',
- request_title = '" . $_REQUEST['request_title'] . "',
- request_items_per_page = '" . $_REQUEST['request_items_per_page'] . "',
- request_template_item = '" . $_REQUEST['request_template_item'] . "',
- request_template_main = '" . $_REQUEST['request_template_main'] . "',
- request_order_by = '" . $_REQUEST['request_order_by'] . "',
- request_order_by_nat = '" . $_REQUEST['request_order_by_nat'] . "',
- request_description = '" . $_REQUEST['request_description'] . "',
- request_asc_desc = '" . $_REQUEST['request_asc_desc'] . "',
- request_show_pagination = '" . (isset($_REQUEST['request_show_pagination']) ? (int)$_REQUEST['request_show_pagination'] : 0) . "',
- request_pagination = '" . (isset($_REQUEST['request_pagination']) ? (int)$_REQUEST['request_pagination'] : 1) . "',
- request_use_query = '" . (isset($_REQUEST['request_use_query']) ? (int)$_REQUEST['request_use_query'] : 0) . "',
- request_hide_current = '" . @(int)$_REQUEST['request_hide_current'] . "',
- request_only_owner = '" . @(int)$_REQUEST['request_only_owner'] . "',
- request_cache_lifetime = '" . (int)($_REQUEST['request_cache_lifetime']>'' ? $_REQUEST['request_cache_lifetime'] : '-1') . "',
- request_lang = '" . (isset($_REQUEST['request_lang']) ? (int)$_REQUEST['request_lang'] : 0). "',
- request_cache_elements = '" . (isset($_REQUEST['request_cache_elements']) ? (int)$_REQUEST['request_cache_elements'] : 0). "',
- request_show_statistic = '" . (isset($_REQUEST['request_show_statistic']) ? (int)$_REQUEST['request_show_statistic'] : 0). "',
- request_external = '" . (isset($_REQUEST['request_external']) ? (int)$_REQUEST['request_external'] : 0). "',
- request_ajax = '" . (isset($_REQUEST['request_ajax']) ? (int)$_REQUEST['request_ajax'] : 0). "',
- request_show_sql = '" . (isset($_REQUEST['request_show_sql']) ? (int)$_REQUEST['request_show_sql'] : 0). "'
- WHERE
- Id = '" . $request_id . "'
- ");
+ if ($save === false)
+ {
+ if(isAjax())
+ {
+ $header = $AVE_Template->get_config_vars('REQUEST_ERROR');
+ echo json_encode(array('message' => $message, 'header' => $header, 'theme' => 'error'));
+ exit;
+ }
- $sql = $AVE_DB->Query("SELECT Id FROM " . PREFIX . "_documents WHERE rubric_id = ".$_REQUEST['rubric_id']);
+ $AVE_Template->assign('row', $row);
+ $AVE_Template->assign('errors', $errors);
+ $AVE_Template->assign('formaction', 'index.php?do=request&action=edit&sub=save&Id=' . $request_id . '&cp=' . SESSION);
+ $AVE_Template->assign('content', $AVE_Template->fetch('request/form.tpl'));
+ }
+ else
+ {
+ // Выполняем запрос к БД и обновляем имеющиеся данные
+ $AVE_DB->Query("
+ UPDATE " . PREFIX . "_request
+ SET
+ rubric_id = '" . (int)$_REQUEST['rubric_id'] . "',
+ request_alias = '" . $_REQUEST['request_alias'] . "',
+ request_title = '" . $_REQUEST['request_title'] . "',
+ request_items_per_page = '" . $_REQUEST['request_items_per_page'] . "',
+ request_template_item = '" . $_REQUEST['request_template_item'] . "',
+ request_template_main = '" . $_REQUEST['request_template_main'] . "',
+ request_order_by = '" . $_REQUEST['request_order_by'] . "',
+ request_order_by_nat = '" . $_REQUEST['request_order_by_nat'] . "',
+ request_description = '" . $_REQUEST['request_description'] . "',
+ request_asc_desc = '" . $_REQUEST['request_asc_desc'] . "',
+ request_show_pagination = '" . (isset($_REQUEST['request_show_pagination']) ? (int)$_REQUEST['request_show_pagination'] : 0) . "',
+ request_pagination = '" . (isset($_REQUEST['request_pagination']) ? (int)$_REQUEST['request_pagination'] : 1) . "',
+ request_use_query = '" . (isset($_REQUEST['request_use_query']) ? (int)$_REQUEST['request_use_query'] : 0) . "',
+ request_hide_current = '" . @(int)$_REQUEST['request_hide_current'] . "',
+ request_only_owner = '" . @(int)$_REQUEST['request_only_owner'] . "',
+ request_cache_lifetime = '" . (int)($_REQUEST['request_cache_lifetime']>'' ? $_REQUEST['request_cache_lifetime'] : '-1') . "',
+ request_lang = '" . (isset($_REQUEST['request_lang']) ? (int)$_REQUEST['request_lang'] : 0). "',
+ request_cache_elements = '" . (isset($_REQUEST['request_cache_elements']) ? (int)$_REQUEST['request_cache_elements'] : 0). "',
+ request_show_statistic = '" . (isset($_REQUEST['request_show_statistic']) ? (int)$_REQUEST['request_show_statistic'] : 0). "',
+ request_external = '" . (isset($_REQUEST['request_external']) ? (int)$_REQUEST['request_external'] : 0). "',
+ request_ajax = '" . (isset($_REQUEST['request_ajax']) ? (int)$_REQUEST['request_ajax'] : 0). "',
+ request_show_sql = '" . (isset($_REQUEST['request_show_sql']) ? (int)$_REQUEST['request_show_sql'] : 0). "'
+ WHERE
+ Id = '" . $request_id . "'
+ ");
- $AVE_DB->clear_request($request_id);
+ $sql = $AVE_DB->Query("SELECT Id FROM " . PREFIX . "_documents WHERE rubric_id = ".$_REQUEST['rubric_id']);
- while ($row = $sql->FetchRow())
- {
- $AVE_DB->clearcacherequest('doc_' . $row->Id);
- }
+ $AVE_DB->clear_request($request_id);
- // Сохраняем системное сообщение в журнал
- reportLog($AVE_Template->get_config_vars('REQUEST_SAVE_CHA_SUC') . ' (' . stripslashes(htmlspecialchars($_REQUEST['request_title'], ENT_QUOTES)) . ') (Id:' . $request_id . ')');
+ while ($row = $sql->FetchRow())
+ {
+ $AVE_DB->clearcacherequest('doc_' . $row->Id);
+ }
- // В противном случае выполняем переход к списку запросов
- if (! isAjax())
- {
- header('Location:index.php?do=request&cp=' . SESSION);
- exit;
- } else {
- $message = $AVE_Template->get_config_vars('REQUEST_TEMPLATE_SAVED');
- $header = $AVE_Template->get_config_vars('REQUEST_SUCCESS');
- $theme = 'accept';
- echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme));
- exit;
+ // Сохраняем системное сообщение в журнал
+ reportLog($AVE_Template->get_config_vars('REQUEST_SAVE_CHA_SUC') . ' (' . stripslashes(htmlspecialchars($_REQUEST['request_title'], ENT_QUOTES)) . ') (Id:' . $request_id . ')');
+
+ // В противном случае выполняем переход к списку запросов
+ if (! isAjax())
+ {
+ header('Location:index.php?do=request&cp=' . SESSION);
+ exit;
+ } else {
+ $message = $AVE_Template->get_config_vars('REQUEST_TEMPLATE_SAVED');
+ $header = $AVE_Template->get_config_vars('REQUEST_SUCCESS');
+ $theme = 'accept';
+ echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme));
+ exit;
+ }
}
- }
- break;
+ break;
+ }
}
- }
- /**
- * Метод, предназначенный для создания копии Запроса
- *
- * @param int $request_id идентификатор запроса
- */
- function requestCopy($request_id)
- {
- global $AVE_DB, $AVE_Template;
+ /**
+ * Метод, предназначенный для создания копии Запроса
+ *
+ * @param int $request_id идентификатор запроса
+ */
+ function requestCopy($request_id)
+ {
+ global $AVE_DB, $AVE_Template;
- // Выполняем запрос к БД на получение информации о копиреумом запросе
- $sql = $AVE_DB->Query("
- SELECT *
- FROM " . PREFIX . "_request
- WHERE Id = '" . $request_id . "'
- ");
+ // Выполняем запрос к БД на получение информации о копиреумом запросе
+ $sql = $AVE_DB->Query("
+ SELECT *
+ FROM " . PREFIX . "_request
+ WHERE Id = '" . $request_id . "'
+ ");
- if($sql->_result->num_rows == 0) {
- header('Location:index.php?do=request&cp=' . SESSION);
- exit;
- }
+ if($sql->_result->num_rows == 0) {
+ header('Location:index.php?do=request&cp=' . SESSION);
+ exit;
+ }
- $row = $sql->FetchRow();
-
- // Выполняем запрос к БД на добавление нового запроса на основании полученных ранее данных
- $AVE_DB->Query("
- INSERT " . PREFIX . "_request
- SET
- rubric_id = '" . (int)$row->rubric_id . "',
- request_items_per_page = '" . $row->request_items_per_page . "',
- request_title = '" . $_REQUEST['cname'] . "',
- request_template_item = '" . addslashes($row->request_template_item) . "',
- request_template_main = '" . addslashes($row->request_template_main) . "',
- request_order_by = '" . addslashes($row->request_order_by) . "',
- request_order_by_nat = '" . addslashes($row->request_order_by_nat) . "',
- request_author_id = '" . (int)$_SESSION['user_id'] . "',
- request_created = '" . time() . "',
- request_description = '" . addslashes($row->request_description) . "',
- request_asc_desc = '" . $row->request_asc_desc . "',
- request_show_pagination = '" . $row->request_show_pagination . "',
- request_use_query = '" . $row->request_use_query . "',
- request_hide_current = '" . $row->request_hide_current . "',
- request_lang = '" . $row->request_lang . "',
- request_cache_elements = '" . (isset($row->request_cache_elements) ? $row->request_cache_elements : 0) . "'
- ");
-
- // Получаем id добавленной записи
- $iid = $AVE_DB->InsertId();
-
- // Сохраняем системное сообщение в журнал
- reportLog($AVE_Template->get_config_vars('REQUEST_COPY_SUC') . ' (' . stripslashes(htmlspecialchars($this->get_request_by_id($request_id)->request_title, ENT_QUOTES)) . ') ( Id:'.$iid.' )');
-
- // Выполняем запрос к БД и получаем все условия запроса для копируемого запроса
- $sql = $AVE_DB->Query("
- SELECT *
- FROM " . PREFIX . "_request_conditions
- WHERE request_id = '" . $request_id . "'
- ");
-
- // Обрабатываем полученные данные и
- while ($row_cond = $sql->FetchRow())
- {
- // Выполняем запрос к БД на добавление условий для нового, скопированного запроса
+ $row = $sql->FetchRow();
+
+ // Выполняем запрос к БД на добавление нового запроса на основании полученных ранее данных
$AVE_DB->Query("
- INSERT " . PREFIX . "_request_conditions
+ INSERT " . PREFIX . "_request
SET
- request_id = '" . $iid . "',
- condition_compare = '" . $row_cond->condition_compare . "',
- condition_field_id = '" . $row_cond->condition_field_id . "',
- condition_value = '" . $row_cond->condition_value . "',
- condition_join = '" . $row_cond->condition_join . "'
+ rubric_id = '" . (int)$row->rubric_id . "',
+ request_items_per_page = '" . $row->request_items_per_page . "',
+ request_title = '" . $_REQUEST['cname'] . "',
+ request_template_item = '" . addslashes($row->request_template_item) . "',
+ request_template_main = '" . addslashes($row->request_template_main) . "',
+ request_order_by = '" . addslashes($row->request_order_by) . "',
+ request_order_by_nat = '" . addslashes($row->request_order_by_nat) . "',
+ request_author_id = '" . (int)$_SESSION['user_id'] . "',
+ request_created = '" . time() . "',
+ request_description = '" . addslashes($row->request_description) . "',
+ request_asc_desc = '" . $row->request_asc_desc . "',
+ request_show_pagination = '" . $row->request_show_pagination . "',
+ request_use_query = '" . $row->request_use_query . "',
+ request_hide_current = '" . $row->request_hide_current . "',
+ request_lang = '" . $row->request_lang . "',
+ request_cache_elements = '" . (isset($row->request_cache_elements) ? $row->request_cache_elements : 0) . "'
");
- }
- // Выполянем переход к списку запросов
- header('Location:index.php?do=request&cp=' . SESSION);
- exit;
- }
+ // Получаем id добавленной записи
+ $iid = $AVE_DB->InsertId();
- /**
- * Метод, предназначенный для удаления запроса
- *
- * @param int $request_id идентификатор запроса
- */
- function requestDelete($request_id)
- {
- global $AVE_DB, $AVE_Template;
-
- $request_name = $this->get_request_by_id($request_id)->request_title;
-
- // Выполняем запрос к БД на удаление общей информации о запросе
- $AVE_DB->Query("
- DELETE
- FROM " . PREFIX . "_request
- WHERE Id = '" . $request_id . "'
- ");
-
- // Выполняем запрос к БД на удаление условий запроса
- $AVE_DB->Query("
- DELETE
- FROM " . PREFIX . "_request_conditions
- WHERE request_id = '" . $request_id . "'
- ");
-
- // Сохраняем системное сообщение в журнал
- reportLog($AVE_Template->get_config_vars('REQUEST_DELETE_SUC') . ' (' . stripslashes(htmlspecialchars($request_name, ENT_QUOTES)) . ') ( Id:' . $request_id . ' )');
-
- // Выполянем переход к списку запросов
- header('Location:index.php?do=request&cp=' . SESSION);
- exit;
- }
+ // Сохраняем системное сообщение в журнал
+ reportLog($AVE_Template->get_config_vars('REQUEST_COPY_SUC') . ' (' . stripslashes(htmlspecialchars($this->get_request_by_id($request_id)->request_title, ENT_QUOTES)) . ') ( Id:'.$iid.' )');
- /**
- * Метод, предназначенный для редактирования условий Запроса
- *
- * @param int $request_id идентификатор запроса
- */
- function requestConditionEdit($request_id)
- {
- global $AVE_DB, $AVE_Template;
+ // Выполняем запрос к БД и получаем все условия запроса для копируемого запроса
+ $sql = $AVE_DB->Query("
+ SELECT *
+ FROM " . PREFIX . "_request_conditions
+ WHERE request_id = '" . $request_id . "'
+ ");
- // Определяем действие пользователя
- switch ($_REQUEST['sub'])
- {
- // Если действие не определено
- case '':
- $fields = array();
-
- // Выполняем запрос к БД и получаем список полей у той рубрики, к которой относится данный запрос
- $sql = $AVE_DB->Query("
- SELECT *
- FROM " . PREFIX . "_rubric_fields
- WHERE rubric_id = '" . $_REQUEST['rubric_id'] . "'
- ORDER BY rubric_field_position ASC
+ // Обрабатываем полученные данные и
+ while ($row_cond = $sql->FetchRow())
+ {
+ // Выполняем запрос к БД на добавление условий для нового, скопированного запроса
+ $AVE_DB->Query("
+ INSERT " . PREFIX . "_request_conditions
+ SET
+ request_id = '" . $iid . "',
+ condition_compare = '" . $row_cond->condition_compare . "',
+ condition_field_id = '" . $row_cond->condition_field_id . "',
+ condition_value = '" . $row_cond->condition_value . "',
+ condition_join = '" . $row_cond->condition_join . "'
");
+ }
- // Обрабатываем полученные данные и формируем массив
- while ($row = $sql->FetchRow())
- {
- array_push($fields, $row);
- }
+ // Выполянем переход к списку запросов
+ header('Location:index.php?do=request&cp=' . SESSION);
+ exit;
+ }
- $conditions = array();
+ /**
+ * Метод, предназначенный для удаления запроса
+ *
+ * @param int $request_id идентификатор запроса
+ */
+ function requestDelete($request_id)
+ {
+ global $AVE_DB, $AVE_Template;
- // Выполняем запрос к БД и получаем условия запроса
- $sql = $AVE_DB->Query("
- SELECT *
- FROM " . PREFIX . "_request_conditions
- WHERE request_id = '" . $request_id . "'
- ORDER BY condition_position ASC
- ");
+ $request_name = $this->get_request_by_id($request_id)->request_title;
- // Обрабатываем полученные данные и формируем массив
- while ($row = $sql->FetchRow())
- {
- array_push($conditions, $row);
- }
+ // Выполняем запрос к БД на удаление общей информации о запросе
+ $AVE_DB->Query("
+ DELETE
+ FROM " . PREFIX . "_request
+ WHERE Id = '" . $request_id . "'
+ ");
+
+ // Выполняем запрос к БД на удаление условий запроса
+ $AVE_DB->Query("
+ DELETE
+ FROM " . PREFIX . "_request_conditions
+ WHERE request_id = '" . $request_id . "'
+ ");
- // Передаем данные в шаблон и отображаем страницу с редактированием условий
- $AVE_Template->assign('request_title', $this->get_request_by_id($request_id)->request_title);
- $AVE_Template->assign('fields', $fields);
- $AVE_Template->assign('conditions', $conditions);
+ // Сохраняем системное сообщение в журнал
+ reportLog($AVE_Template->get_config_vars('REQUEST_DELETE_SUC') . ' (' . stripslashes(htmlspecialchars($request_name, ENT_QUOTES)) . ') ( Id:' . $request_id . ' )');
- if (isAjax() && (isset($_REQUEST['ajax']) && $_REQUEST['ajax'] == 1)){
- $AVE_Template->assign('content', $AVE_Template->fetch('request/cond_list.tpl'));
- } else {
- $AVE_Template->assign('content', $AVE_Template->fetch('request/conditions.tpl'));
- }
- break;
+ // Выполянем переход к списку запросов
+ header('Location:index.php?do=request&cp=' . SESSION);
+ exit;
+ }
- case 'sort':
+ /**
+ * Метод, предназначенный для редактирования условий Запроса
+ *
+ * @param int $request_id идентификатор запроса
+ */
+ function requestConditionEdit($request_id)
+ {
+ global $AVE_DB, $AVE_Template;
- foreach ($_REQUEST['sort'] as $position => $cond_id)
- {
- $AVE_DB->Query("
- UPDATE " . PREFIX . "_request_conditions
- SET
- condition_position = '" . (int)$position . "'
- WHERE
- Id = '" . (int)$cond_id . "'
+ // Определяем действие пользователя
+ switch ($_REQUEST['sub'])
+ {
+ // Если действие не определено
+ case '':
+ $fields = array();
+
+ // Выполняем запрос к БД и получаем список полей у той рубрики, к которой относится данный запрос
+ $sql = $AVE_DB->Query("
+ SELECT *
+ FROM " . PREFIX . "_rubric_fields
+ WHERE rubric_id = '" . $_REQUEST['rubric_id'] . "'
+ ORDER BY rubric_field_position ASC
");
- }
- if (isAjax()){
- $message = $AVE_Template->get_config_vars('REQUEST_SORTED');
- $header = $AVE_Template->get_config_vars('REQUEST_SUCCESS');
- $theme = 'accept';
- echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme));
- }
+ // Обрабатываем полученные данные и формируем массив
+ while ($row = $sql->FetchRow())
+ {
+ array_push($fields, $row);
+ }
- exit;
+ $conditions = array();
+ // Выполняем запрос к БД и получаем условия запроса
+ $sql = $AVE_DB->Query("
+ SELECT *
+ FROM " . PREFIX . "_request_conditions
+ WHERE request_id = '" . $request_id . "'
+ ORDER BY condition_position ASC
+ ");
- // Если пользователь нажал кнопку Сохранить изменения
- case 'save':
- // Если существует хотя бы одно условие, тогда
+ // Обрабатываем полученные данные и формируем массив
+ while ($row = $sql->FetchRow())
+ {
+ array_push($conditions, $row);
+ }
- if (isset($_REQUEST['conditions']) && is_array($_POST['conditions']))
- {
- $condition_edited = false;
+ // Передаем данные в шаблон и отображаем страницу с редактированием условий
+ $AVE_Template->assign('request_title', $this->get_request_by_id($request_id)->request_title);
+ $AVE_Template->assign('fields', $fields);
+ $AVE_Template->assign('conditions', $conditions);
+
+ if (isAjax() && (isset($_REQUEST['ajax']) && $_REQUEST['ajax'] == 1)){
+ $AVE_Template->assign('content', $AVE_Template->fetch('request/cond_list.tpl'));
+ } else {
+ $AVE_Template->assign('content', $AVE_Template->fetch('request/conditions.tpl'));
+ }
+ break;
+
+ case 'sort':
- // Обрабатываем данные полей
- foreach ($_REQUEST['conditions'] as $condition_id => $val)
+ foreach ($_REQUEST['sort'] as $position => $cond_id)
{
- // Выполняем запрос к БД на обновление информации об условиях
$AVE_DB->Query("
- UPDATE
- " . PREFIX . "_request_conditions
+ UPDATE " . PREFIX . "_request_conditions
SET
- request_id = '" . $request_id . "',
- condition_compare = '" . $val['condition_compare'] . "',
- condition_field_id = '" . $val['condition_field_id'] . "',
- condition_value = '" . (! empty($val['condition_value']) ? $val['condition_value'] : '') . "',
- condition_join = '" . $val['condition_join'] . "',
- condition_status = '" . ((! empty($val['condition_value'])) ? (($val['condition_status'] == '1') ? '1' : '0') : ''). "'
+ condition_position = '" . (int)$position . "'
WHERE
- Id = '" . $condition_id . "'
+ Id = '" . (int)$cond_id . "'
");
+ }
- $condition_edited = true;
+ if (isAjax()){
+ $message = $AVE_Template->get_config_vars('REQUEST_SORTED');
+ $header = $AVE_Template->get_config_vars('REQUEST_SUCCESS');
+ $theme = 'accept';
+ echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme));
}
- // Если изменения были, сохраняем системное сообщение в журнал
- if ($condition_edited)
+ exit;
+
+
+ // Если пользователь нажал кнопку Сохранить изменения
+ case 'save':
+ // Если существует хотя бы одно условие, тогда
+
+ if (isset($_REQUEST['conditions']) && is_array($_POST['conditions']))
{
- reportLog('' . $AVE_Template->get_config_vars('REQUEST_COND_CHA_SUC') . ' (' . stripslashes(htmlspecialchars($this->get_request_by_id($request_id)->request_title, ENT_QUOTES)) . ') - ( Id: '.$request_id.' )');
+ $condition_edited = false;
+
+ // Обрабатываем данные полей
+ foreach ($_REQUEST['conditions'] as $condition_id => $val)
+ {
+ // Выполняем запрос к БД на обновление информации об условиях
+ $AVE_DB->Query("
+ UPDATE
+ " . PREFIX . "_request_conditions
+ SET
+ request_id = '" . $request_id . "',
+ condition_compare = '" . $val['condition_compare'] . "',
+ condition_field_id = '" . $val['condition_field_id'] . "',
+ condition_value = '" . (! empty($val['condition_value']) ? $val['condition_value'] : '') . "',
+ condition_join = '" . $val['condition_join'] . "',
+ condition_status = '" . ((! empty($val['condition_value'])) ? (($val['condition_status'] == '1') ? '1' : '0') : ''). "'
+ WHERE
+ Id = '" . $condition_id . "'
+ ");
+
+ $condition_edited = true;
+ }
- $message = $AVE_Template->get_config_vars('REQUEST_COND_POST_OK');
- $header = $AVE_Template->get_config_vars('REQUEST_SUCCESS');
- $theme = 'accept';
+ // Если изменения были, сохраняем системное сообщение в журнал
+ if ($condition_edited)
+ {
+ reportLog('' . $AVE_Template->get_config_vars('REQUEST_COND_CHA_SUC') . ' (' . stripslashes(htmlspecialchars($this->get_request_by_id($request_id)->request_title, ENT_QUOTES)) . ') - ( Id: '.$request_id.' )');
+
+ $message = $AVE_Template->get_config_vars('REQUEST_COND_POST_OK');
+ $header = $AVE_Template->get_config_vars('REQUEST_SUCCESS');
+ $theme = 'accept';
+ }
+ else
+ {
+
+ $message = $AVE_Template->get_config_vars('REQUEST_COND_POST_ERR');
+ $header = $AVE_Template->get_config_vars('REQUEST_ERROR');
+ $theme = 'error';
+ }
}
else
{
-
- $message = $AVE_Template->get_config_vars('REQUEST_COND_POST_ERR');
+ $message = $AVE_Template->get_config_vars('REQUEST_COND_NO_POST');
$header = $AVE_Template->get_config_vars('REQUEST_ERROR');
$theme = 'error';
}
- }
- else
- {
- $message = $AVE_Template->get_config_vars('REQUEST_COND_NO_POST');
- $header = $AVE_Template->get_config_vars('REQUEST_ERROR');
- $theme = 'error';
- }
- // Если некоторые из условий были помечены на удаление
- if (isset($_POST['del']) && is_array($_POST['del']))
- {
- // Обрабатываем все поля помеченные на удаление
- foreach ($_POST['del'] as $condition_id => $val)
+ // Если некоторые из условий были помечены на удаление
+ if (isset($_POST['del']) && is_array($_POST['del']))
{
- // Выполняем запрос к БД на удаление условий
- $AVE_DB->Query("
- DELETE
- FROM " . PREFIX . "_request_conditions
- WHERE Id = '" . $condition_id . "'
- ");
+ // Обрабатываем все поля помеченные на удаление
+ foreach ($_POST['del'] as $condition_id => $val)
+ {
+ // Выполняем запрос к БД на удаление условий
+ $AVE_DB->Query("
+ DELETE
+ FROM " . PREFIX . "_request_conditions
+ WHERE Id = '" . $condition_id . "'
+ ");
+ }
+
+ // Сохраняем системное сообщение в журнал
+ reportLog('' . $AVE_Template->get_config_vars('REQUEST_COND_DEL_SUC') . ' (' . stripslashes(htmlspecialchars($this->get_request_by_id($request_id)->request_title, ENT_QUOTES)) . ') - ( Id: '.$request_id.' )');
}
- // Сохраняем системное сообщение в журнал
- reportLog('' . $AVE_Template->get_config_vars('REQUEST_COND_DEL_SUC') . ' (' . stripslashes(htmlspecialchars($this->get_request_by_id($request_id)->request_title, ENT_QUOTES)) . ') - ( Id: '.$request_id.' )');
- }
+ // Нет смысла каждый раз формировать SQL-запрос с условиями Запроса
+ // поэтому формируем SQL-запрос только при изменении условий
+ // require(BASE_DIR . '/functions/func.parserequest.php');
+ request_get_condition_sql_string($request_id, true);
- // Нет смысла каждый раз формировать SQL-запрос с условиями Запроса
- // поэтому формируем SQL-запрос только при изменении условий
- // require(BASE_DIR . '/functions/func.parserequest.php');
- request_get_condition_sql_string($request_id, true);
+ if (!isAjax() && $_REQUEST['ajax'] != '1'){
+ // Выполняем обновление страницы
+ header('Location:index.php?do=request&action=conditions&rubric_id=' . $_REQUEST['rubric_id'] . '&Id=' . $request_id . '&cp=' . SESSION . ($_REQUEST['pop'] ? '&pop=1' : ''));
+ exit;
+ } else {
+ echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme));
+ exit;
+ }
+ break;
- if (!isAjax() && $_REQUEST['ajax'] != '1'){
- // Выполняем обновление страницы
- header('Location:index.php?do=request&action=conditions&rubric_id=' . $_REQUEST['rubric_id'] . '&Id=' . $request_id . '&cp=' . SESSION . ($_REQUEST['pop'] ? '&pop=1' : ''));
- exit;
- } else {
- echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme));
- exit;
- }
- break;
+ // Если пользователь добавил новое условие
+ case 'new':
+ if ($_POST['new_value'] !== '')
+ {
+ // Выполняем запрос к БД на добавление нового условия
+ $sql = $AVE_DB->Query("
+ INSERT " . PREFIX . "_request_conditions
+ SET
+ request_id = '" . $request_id . "',
+ condition_compare = '" . $_POST['new_operator'] . "',
+ condition_field_id = '" . $_POST['field_new'] . "',
+ condition_value = '" . $_POST['new_value'] . "',
+ condition_join = '" . $_POST['oper_new'] . "'
+ ");
+ if ($sql->_result === false) {
+ $message = $AVE_Template->get_config_vars('REQUEST_COND_NEW_ERR');
+ $header = $AVE_Template->get_config_vars('REQUEST_ERROR');
+ $theme = 'error';
+ } else {
+ // Сохраняем системное сообщение в журнал
+ reportLog('' . $AVE_Template->get_config_vars('REQUEST_COND_ADD_SUC') . ' (' . stripslashes(htmlspecialchars($this->get_request_by_id($request_id)->request_title, ENT_QUOTES)) . ') - ( Id: '.$request_id.' )');
+ }
- // Если пользователь добавил новое условие
- case 'new':
- if ($_POST['new_value'] !== '')
- {
- // Выполняем запрос к БД на добавление нового условия
- $sql = $AVE_DB->Query("
- INSERT " . PREFIX . "_request_conditions
- SET
- request_id = '" . $request_id . "',
- condition_compare = '" . $_POST['new_operator'] . "',
- condition_field_id = '" . $_POST['field_new'] . "',
- condition_value = '" . $_POST['new_value'] . "',
- condition_join = '" . $_POST['oper_new'] . "'
- ");
- if ($sql->_result === false) {
- $message = $AVE_Template->get_config_vars('REQUEST_COND_NEW_ERR');
+ } else {
+ $message = $AVE_Template->get_config_vars('REQUEST_COND_VALUE_ERR');
$header = $AVE_Template->get_config_vars('REQUEST_ERROR');
$theme = 'error';
- } else {
- // Сохраняем системное сообщение в журнал
- reportLog('' . $AVE_Template->get_config_vars('REQUEST_COND_ADD_SUC') . ' (' . stripslashes(htmlspecialchars($this->get_request_by_id($request_id)->request_title, ENT_QUOTES)) . ') - ( Id: '.$request_id.' )');
}
- } else {
- $message = $AVE_Template->get_config_vars('REQUEST_COND_VALUE_ERR');
- $header = $AVE_Template->get_config_vars('REQUEST_ERROR');
- $theme = 'error';
- }
-
- // Нет смысла каждый раз формировать SQL-запрос с условиями Запроса
- // поэтому формируем SQL-запрос только при изменении условий
- // require(BASE_DIR . '/functions/func.parserequest.php');
- request_get_condition_sql_string($request_id, true);
+ // Нет смысла каждый раз формировать SQL-запрос с условиями Запроса
+ // поэтому формируем SQL-запрос только при изменении условий
+ // require(BASE_DIR . '/functions/func.parserequest.php');
+ request_get_condition_sql_string($request_id, true);
- if (! isAjax())
- {
- header('Location:index.php?do=request&action=conditions&rubric_id=' . $_REQUEST['rubric_id'] . '&Id=' . $request_id . '&cp=' . SESSION);
- exit;
- }
- else
- {
- if (! $message)
+ if (! isAjax())
{
- $message = $AVE_Template->get_config_vars('REQUEST_COND_NEW_SUC');
- $header = $AVE_Template->get_config_vars('REQUEST_SUCCESS');
- $theme = 'accept';
+ header('Location:index.php?do=request&action=conditions&rubric_id=' . $_REQUEST['rubric_id'] . '&Id=' . $request_id . '&cp=' . SESSION);
+ exit;
}
- echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme));
- exit;
- }
- break;
+ else
+ {
+ if (! $message)
+ {
+ $message = $AVE_Template->get_config_vars('REQUEST_COND_NEW_SUC');
+ $header = $AVE_Template->get_config_vars('REQUEST_SUCCESS');
+ $theme = 'accept';
+ }
+ echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme));
+ exit;
+ }
+ break;
+ }
}
- }
- function conditionFieldChange($field_id, $cond_id)
- {
- global $AVE_DB, $AVE_Template;
+ function conditionFieldChange($field_id, $cond_id)
+ {
+ global $AVE_DB, $AVE_Template;
- // Передаем данные в шаблон и отображаем страницу с редактированием условий
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('cond_id', $cond_id);
- $AVE_Template->assign('content', $AVE_Template->fetch('request/change.tpl'));
- }
+ // Передаем данные в шаблон и отображаем страницу с редактированием условий
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('cond_id', $cond_id);
+ $AVE_Template->assign('content', $AVE_Template->fetch('request/change.tpl'));
+ }
- function conditionFieldChangeSave($field_id, $cond_id)
- {
- global $AVE_DB, $AVE_Template;
-
- $sql = $AVE_DB->Query("
- UPDATE " . PREFIX . "_request_conditions
- SET
- condition_field_id = '" . $field_id . "'
- WHERE
- Id = '" . $cond_id . "'
- ");
-
- request_get_condition_sql_string((int)$_REQUEST['req_id'], true);
-
- // Передаем данные в шаблон и отображаем страницу с редактированием условий
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('cond_id', $cond_id);
- $AVE_Template->assign('content', $AVE_Template->fetch('request/change.tpl'));
- }
-}
+ function conditionFieldChangeSave($field_id, $cond_id)
+ {
+ global $AVE_DB, $AVE_Template;
+
+ $sql = $AVE_DB->Query("
+ UPDATE " . PREFIX . "_request_conditions
+ SET
+ condition_field_id = '" . $field_id . "'
+ WHERE
+ Id = '" . $cond_id . "'
+ ");
+
+ request_get_condition_sql_string((int)$_REQUEST['req_id'], true);
-?>
+ // Передаем данные в шаблон и отображаем страницу с редактированием условий
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('cond_id', $cond_id);
+ $AVE_Template->assign('content', $AVE_Template->fetch('request/change.tpl'));
+ }
+ }
+?>
\ No newline at end of file
diff --git a/class/class.rubs.php b/class/class.rubs.php
index 56d3e3d..44ac4b2 100755
--- a/class/class.rubs.php
+++ b/class/class.rubs.php
@@ -15,11 +15,6 @@
*/
class AVE_Rubric
{
-
- /**
- * СВОЙСТВА
- */
-
/**
* Количество рубрик на странице
*
@@ -27,9 +22,6 @@
*/
public $_limit = 30;
- /**
- * ВНУТРЕННИЕ МЕТОДЫ
- */
function get_rubric_fields_group($rubric_id)
{
@@ -58,10 +50,6 @@
}
- /**
- * ВНЕШНИЕ МЕТОДЫ
- */
-
/**
* Вывод списка рубрик
*
@@ -219,6 +207,7 @@
}
}
+
/**
* Запись настроек рубрики
*
@@ -308,6 +297,7 @@
}
}
+
/**
* Копирование рубрики
*
@@ -440,6 +430,7 @@
}
}
+
/**
* Удаление рубрики
*
@@ -495,6 +486,7 @@
exit;
}
+
/**
* Вывод списка полей рубрики
*
@@ -504,12 +496,15 @@
{
global $AVE_DB, $AVE_Template;
- if(check_permission_acp('rubric_edit'))
+ if (check_permission_acp('rubric_edit'))
{
// Поля
$sql = $AVE_DB->Query("
SELECT
- a.*, b.group_title, b.group_description, b.group_position
+ a.*,
+ b.group_title,
+ b.group_description,
+ b.group_position
FROM
" . PREFIX . "_rubric_fields AS a
LEFT JOIN
@@ -551,19 +546,19 @@
$sql = $AVE_DB->Query("
SELECT *
- FROM " . PREFIX . "_rubric_fields_group
- WHERE rubric_id = '" . $rubric_id . "'
- ORDER BY group_position ASC
+ FROM
+ " . PREFIX . "_rubric_fields_group
+ WHERE
+ rubric_id = '" . $rubric_id . "'
+ ORDER BY
+ group_position ASC
");
while ($row = $sql->FetchRow())
- {
array_push($fields_groups, $row);
- }
$AVE_Template->assign('fields_groups', $fields_groups);
-
// Права
$groups = array();
@@ -575,10 +570,14 @@
$row->doall_h = ($row->user_group == 1) ? 1 : '';
$rubric_permission = $AVE_DB->Query("
- SELECT rubric_permission
- FROM " . PREFIX . "_rubric_permissions
- WHERE user_group_id = '" . $row->user_group . "'
- AND rubric_id = '" . $rubric_id . "'
+ SELECT
+ rubric_permission
+ FROM
+ " . PREFIX . "_rubric_permissions
+ WHERE
+ user_group_id = '" . $row->user_group . "'
+ AND
+ rubric_id = '" . $rubric_id . "'
")->GetCell();
$row->permissions = @explode('|', $rubric_permission);
@@ -587,15 +586,22 @@
}
$sql = $AVE_DB->Query("
- SELECT rubric_title, rubric_linked_rubric, rubric_description
- FROM " . PREFIX . "_rubrics
- WHERE id = '" . $rubric_id . "'
+ SELECT
+ rubric_title,
+ rubric_linked_rubric,
+ rubric_description
+ FROM
+ " . PREFIX . "_rubrics
+ WHERE
+ id = '" . $rubric_id . "'
LIMIT 1
");
$rubrik = $sql->FetchRow();
- $rubrik->rubric_linked_rubric = ($rubrik->rubric_linked_rubric != '0') ? unserialize($rubrik->rubric_linked_rubric) : array();
+ $rubrik->rubric_linked_rubric = ($rubrik->rubric_linked_rubric != '0')
+ ? unserialize($rubrik->rubric_linked_rubric)
+ : array();
$AVE_Template->assign('rubric', $rubrik);
$AVE_Template->assign('groups', $groups);
@@ -691,14 +697,17 @@
{
global $AVE_DB;
- if ($RubLink!==null) {
+ if ($RubLink !== null)
+ {
$AVE_DB->Query("
- UPDATE " . PREFIX . "_rubrics
+ UPDATE
+ " . PREFIX . "_rubrics
SET
rubric_linked_rubric = '" . serialize($_REQUEST['rubric_linked']) . "'
WHERE
Id = '" . (int)$_REQUEST['Id'] . "'
");
+
header('Location:index.php?do=rubs&action=edit&Id=' . (int)$_REQUEST['Id'] . '&cp=' . SESSION);
exit;
}
@@ -706,15 +715,18 @@
{
$rubs = array();
$sql = $AVE_DB->Query("
- SELECT rubric_title, Id
- FROM " . PREFIX . "_rubrics
- ORDER BY rubric_position ASC
+ SELECT
+ rubric_title,
+ Id
+ FROM
+ " . PREFIX . "_rubrics
+ ORDER BY
+ rubric_position ASC
");
while ($row = $sql->FetchRow())
- {
- array_push($rubs,$row);
- }
+ array_push($rubs, $row);
+
return $rubs;
}
}
diff --git a/class/class.thumbnail.php b/class/class.thumbnail.php
index 297fbc2..3558b68 100644
--- a/class/class.thumbnail.php
+++ b/class/class.thumbnail.php
@@ -180,7 +180,8 @@ class Image_Toolbox {
}
$this->_gd_ttf = $gd_info['FreeType Support'];
- $this->_gd_ps = $gd_info['T1Lib Support'];
+ $this->_gd_ps = isset($gd_info['T1Lib Support']) ? $gd_info['T1Lib Support'] : false;
+
if ($gd_info['GIF Read Support']) {
$this->_types[1]['supported'] = 1;
if ($gd_info['GIF Create Support']) {
diff --git a/fields/checkbox/field.php b/fields/checkbox/field.php
index f4e2b3c..99bc427 100644
--- a/fields/checkbox/field.php
+++ b/fields/checkbox/field.php
@@ -1,97 +1,100 @@
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
+ /**
+ * AVE.cms
+ *
+ * @package AVE.cms
+ * @version 3.x
+ * @filesource
+ * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
+ *
+ * @license GPL v.2
+ */
+
+ // Чекбокс (Checkbox)
+ function get_field_checkbox($field_value, $action, $field_id = 0, $tpl = '', $tpl_empty = 0, &$maxlength = null, $document_fields = array(), $rubric_id = 0, $default = null, $_tpl = null)
+ {
+ global $AVE_Template;
-// Чекбокс (Checkbox)
-function get_field_checkbox($field_value, $action, $field_id = 0, $tpl = '', $tpl_empty = 0, &$maxlength = null, $document_fields = array(), $rubric_id = 0, $default = null)
-{
+ $fld_dir = dirname(__FILE__) . '/';
+ $tpl_dir = $fld_dir . 'tpl/';
- global $AVE_Template;
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP')
+ ? $_SESSION['admin_language']
+ : $_SESSION['user_language']) . '.txt';
- $fld_dir = dirname(__FILE__) . '/';
- $tpl_dir = $fld_dir . 'tpl/';
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
- $lang_file = $fld_dir . 'lang/' . (defined('ACP')
- ? $_SESSION['admin_language']
- : $_SESSION['user_language']) . '.txt';
+ $res = '';
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
+ switch ($action)
+ {
+ case 'edit':
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', (int)$field_value);
+ $AVE_Template->assign('doc_id', (isset($_REQUEST['Id']) ? (int)$_REQUEST['Id'] : 0));
- $res = '';
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
- switch ($action)
- {
- case 'edit':
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', (int)$field_value);
- $AVE_Template->assign('doc_id', (isset($_REQUEST['Id']) ? (int)$_REQUEST['Id'] : 0));
+ return $AVE_Template->fetch($tpl_file);
+ break;
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
+ case 'doc':
+ $field_value = clean_php($field_value);
- return $AVE_Template->fetch($tpl_file);
- break;
+ $res = ((int)$field_value === 1)
+ ? (int)$field_value
+ : null;
- case 'doc':
- $field_value = clean_php($field_value);
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
- $res = ((int)$field_value === 1)
- ? (int)$field_value
- : 0;
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_default', $default);
+ $AVE_Template->assign('field_value', $field_value);
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
+ return $AVE_Template->fetch($tpl_file);
+ }
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $field_value);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $res;
+ break;
- return $res;
- break;
+ case 'req':
+ $field_value = clean_php($field_value);
- case 'req':
- $field_value = clean_php($field_value);
+ $res = ((int)$field_value === 1)
+ ? (int)$field_value
+ : null;
- $res = ((int)$field_value === 1)
- ? (int)$field_value
- : 0;
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_default', $default);
+ $AVE_Template->assign('field_value', $field_value);
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $field_value);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- return $res;
- break;
+ return $res;
+ break;
- case 'save':
- $field_value = clean_php($field_value);
- $res = ((int)$field_value === 1)
- ? $field_value
- : '0';
- break;
+ case 'save':
+ $field_value = clean_php($field_value);
+ $res = ((int)$field_value === 1)
+ ? $field_value
+ : null;
+ break;
- case 'name':
- return $AVE_Template->get_config_vars('name');
- break;
- }
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+ break;
+ }
- return ($res ? $res : $field_value);
-}
-?>
+ return ($res ? $res : $field_value);
+ }
+?>
\ No newline at end of file
diff --git a/fields/checkbox/tpl/field-doc.tpl b/fields/checkbox/tpl/field-doc.tpl
index 20c861d..40b1e17 100644
--- a/fields/checkbox/tpl/field-doc.tpl
+++ b/fields/checkbox/tpl/field-doc.tpl
@@ -1 +1,6 @@
+{*
+ $field_id
+ $field_default
+ $field_value
+*}
{$field_value}
\ No newline at end of file
diff --git a/fields/checkbox/tpl/field-req.tpl b/fields/checkbox/tpl/field-req.tpl
index 20c861d..40b1e17 100644
--- a/fields/checkbox/tpl/field-req.tpl
+++ b/fields/checkbox/tpl/field-req.tpl
@@ -1 +1,6 @@
+{*
+ $field_id
+ $field_default
+ $field_value
+*}
{$field_value}
\ No newline at end of file
diff --git a/fields/checkbox/tpl/field.tpl b/fields/checkbox/tpl/field.tpl
index cfbe265..ababcf7 100644
--- a/fields/checkbox/tpl/field.tpl
+++ b/fields/checkbox/tpl/field.tpl
@@ -1,2 +1,2 @@
-
+
\ No newline at end of file
diff --git a/fields/checkbox_multi/field.php b/fields/checkbox_multi/field.php
new file mode 100644
index 0000000..5aa886d
--- /dev/null
+++ b/fields/checkbox_multi/field.php
@@ -0,0 +1,163 @@
+config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
+
+ $res = array();
+
+ switch ($action)
+ {
+ case 'edit':
+ $default_items = explode(',', $default);
+ $default_items = array_diff($default_items, array(''));
+
+ $field_value_array = explode('|', $field_value);
+ $field_value_array = array_values(array_diff($field_value_array, array('')));
+
+ $AVE_Template->assign('items', $default_items);
+ $AVE_Template->assign('used', $field_value_array);
+ $AVE_Template->assign('doc_id', (isset($_REQUEST['Id']) ? (int)$_REQUEST['Id'] : 0));
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $field_value);
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
+
+ return $AVE_Template->fetch($tpl_file);
+ break;
+
+ case 'doc':
+ $default_items = explode(',', $default);
+
+ $items = explode('|', $field_value);
+ $items = array_diff($items, array(''));
+
+ if (! empty($items))
+ {
+ foreach($items as $item)
+ {
+ if ($item)
+ {
+ if ($tpl_empty)
+ {
+ $item = $default_items[(int)$item-1];
+ }
+ else
+ {
+ $field_param = explode('|', $item);
+
+ $item = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param, $default_items)
+ {
+ return $default_items[$field_param[(int)$data[1]]-1];
+ },
+ $tpl
+ );
+ }
+ }
+
+ $res[] = $item;
+ }
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('rubric_id', $rubric_id);
+ $AVE_Template->assign('default', $default_items);
+
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return (! empty($res))
+ ? implode(PHP_EOL, $res)
+ : $tpl;
+
+ break;
+
+ case 'req':
+ $default_items = explode(',', $default);
+
+ $items = explode('|', $field_value);
+ $items = array_diff($items, array(''));
+
+ if (! empty($items))
+ {
+ foreach($items as $item)
+ {
+ if ($item)
+ {
+ if ($tpl_empty)
+ {
+ $item = $default_items[(int)$item-1];
+ }
+ else
+ {
+ $field_param = explode('|', $item);
+
+ $item = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param, $default_items)
+ {
+ return $default_items[$field_param[(int)$data[1]]-1];
+ },
+ $tpl
+ );
+ }
+ }
+
+ $res[] = $item;
+ }
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('rubric_id', $rubric_id);
+ $AVE_Template->assign('default', $default_items);
+
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return (! empty($res))
+ ? implode(PHP_EOL, $res)
+ : $tpl;
+
+ break;
+
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+ break;
+
+ }
+ return ($res ? $res : $field_value);
+ }
+?>
\ No newline at end of file
diff --git a/fields/multi_checkbox/lang/bg.txt b/fields/checkbox_multi/lang/bg.txt
similarity index 100%
rename from fields/multi_checkbox/lang/bg.txt
rename to fields/checkbox_multi/lang/bg.txt
diff --git a/fields/multi_checkbox/lang/cz.txt b/fields/checkbox_multi/lang/cz.txt
similarity index 100%
rename from fields/multi_checkbox/lang/cz.txt
rename to fields/checkbox_multi/lang/cz.txt
diff --git a/fields/multi_checkbox/lang/en.txt b/fields/checkbox_multi/lang/en.txt
similarity index 100%
rename from fields/multi_checkbox/lang/en.txt
rename to fields/checkbox_multi/lang/en.txt
diff --git a/fields/multi_checkbox/lang/pl.txt b/fields/checkbox_multi/lang/pl.txt
similarity index 100%
rename from fields/multi_checkbox/lang/pl.txt
rename to fields/checkbox_multi/lang/pl.txt
diff --git a/fields/multi_checkbox/lang/ru.txt b/fields/checkbox_multi/lang/ru.txt
similarity index 100%
rename from fields/multi_checkbox/lang/ru.txt
rename to fields/checkbox_multi/lang/ru.txt
diff --git a/fields/multi_checkbox/lang/ua.txt b/fields/checkbox_multi/lang/ua.txt
similarity index 100%
rename from fields/multi_checkbox/lang/ua.txt
rename to fields/checkbox_multi/lang/ua.txt
diff --git a/fields/multi_checkbox/tpl/field-doc.tpl b/fields/checkbox_multi/tpl/field-doc.tpl
similarity index 100%
rename from fields/multi_checkbox/tpl/field-doc.tpl
rename to fields/checkbox_multi/tpl/field-doc.tpl
diff --git a/fields/multi_checkbox/tpl/field-req.tpl b/fields/checkbox_multi/tpl/field-req.tpl
similarity index 100%
rename from fields/multi_checkbox/tpl/field-req.tpl
rename to fields/checkbox_multi/tpl/field-req.tpl
diff --git a/fields/multi_checkbox/tpl/field.tpl b/fields/checkbox_multi/tpl/field.tpl
similarity index 100%
rename from fields/multi_checkbox/tpl/field.tpl
rename to fields/checkbox_multi/tpl/field.tpl
diff --git a/fields/code/field.php b/fields/code/field.php
index 21fc304..acafcf7 100644
--- a/fields/code/field.php
+++ b/fields/code/field.php
@@ -1,54 +1,112 @@
config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
-
- switch ($action)
+ /**
+ * AVE.cms
+ *
+ * @package AVE.cms
+ * @version 3.x
+ * @filesource
+ * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
+ *
+ * @license GPL v.2
+ */
+
+ // Код (Codemirror)
+ function get_field_code ($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength='', $document_fields=array(), $rubric_id=0, $default='', $_tpl=null)
{
- case 'edit':
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $field_value);
- $AVE_Template->assign('doc_id', (int)$_REQUEST['Id']);
- $AVE_Template->assign('rubric_id', $rubric_id);
- $AVE_Template->assign('f_id', $field_id.'_'.$_REQUEST['Id']);
+ global $AVE_Template;
+
+ $fld_dir = dirname(__FILE__) . '/';
+ $tpl_dir = $fld_dir . 'tpl/';
+
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
+
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
+
+ switch ($action)
+ {
+ case 'edit':
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $field_value);
+ $AVE_Template->assign('doc_id', (int)$_REQUEST['Id']);
+ $AVE_Template->assign('rubric_id', $rubric_id);
+ $AVE_Template->assign('f_id', $field_id.'_'.(int)$_REQUEST['Id']);
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
+
+ return $AVE_Template->fetch($tpl_file);
+ break;
+
+ case 'doc':
+ $AVE_Template->config_load($lang_file, 'public');
+
+ if (! $tpl_empty)
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function ($data) use ($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_default', $default);
+ $AVE_Template->assign('field_value', $field_value);
+ $AVE_Template->assign('rubric_id', $rubric_id);
+
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return $field_value;
+ break;
+
+ case 'req':
+
+ $AVE_Template->config_load($lang_file, 'public');
+
+ if (! $tpl_empty)
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_default', $default);
+ $AVE_Template->assign('field_value', $field_value);
+ $AVE_Template->assign('rubric_id', $rubric_id);
- return $AVE_Template->fetch($tpl_file);
- break;
+ return $AVE_Template->fetch($tpl_file);
+ }
- case 'doc':
- case 'req':
- return get_field_default($field_value, $action, $field_id, $tpl, $tpl_empty);
- break;
+ return $field_value;
+ break;
- case 'name':
- return $AVE_Template->get_config_vars('name');
- break;
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+ break;
- default: return $field_value;
+ default: return $field_value;
+ }
}
-}
?>
\ No newline at end of file
diff --git a/fields/code/tpl/field-doc.tpl b/fields/code/tpl/field-doc.tpl
new file mode 100644
index 0000000..40b1e17
--- /dev/null
+++ b/fields/code/tpl/field-doc.tpl
@@ -0,0 +1,6 @@
+{*
+ $field_id
+ $field_default
+ $field_value
+*}
+{$field_value}
\ No newline at end of file
diff --git a/fields/code/tpl/field-req.tpl b/fields/code/tpl/field-req.tpl
new file mode 100644
index 0000000..40b1e17
--- /dev/null
+++ b/fields/code/tpl/field-req.tpl
@@ -0,0 +1,6 @@
+{*
+ $field_id
+ $field_default
+ $field_value
+*}
+{$field_value}
\ No newline at end of file
diff --git a/fields/date/field.php b/fields/date/field.php
index 19cb6b9..064bf24 100644
--- a/fields/date/field.php
+++ b/fields/date/field.php
@@ -1,117 +1,126 @@
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
-
-// Дата (TimeStamp)
-function get_field_date($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null){
+ /**
+ * AVE.cms
+ *
+ * @package AVE.cms
+ * @version 3.x
+ * @filesource
+ * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
+ *
+ * @license GPL v.2
+ */
+
+ // Дата (TimeStamp)
+ function get_field_date($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null, $_tpl=null)
+ {
+ global $AVE_Template;
- global $AVE_Template;
+ $fld_dir = dirname(__FILE__) . '/';
+ $tpl_dir = $fld_dir . 'tpl/';
- $fld_dir = dirname(__FILE__) . '/';
- $tpl_dir = $fld_dir . 'tpl/';
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
- $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
+ $res=0;
- $res=0;
+ switch ($action)
+ {
+ case 'edit':
+ $field_value = ($field_value != 0) ? $field_value : '';
- switch ($action)
- {
- case 'edit':
- $field_value = ($field_value != 0) ? $field_value : '';
-
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $field_value);
- $AVE_Template->assign('doc_id', (int)$_REQUEST['Id']);
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
-
- return $AVE_Template->fetch($tpl_file);
- break;
-
- case 'doc':
- $field_value = clean_php($field_value);
- if ($tpl_empty)
- {
- $value = pretty_date(strftime(TIME_FORMAT, $field_value));
- }
- else
- {
- $value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_value)
- {
- return $field_value;
- },
- $tpl
- );
-
- return $res = $value;
- }
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
-
- if($tpl_empty && $tpl_file){
- $AVE_Template->assign('field_value', $field_value);
- return $AVE_Template->fetch($tpl_file);
- }
-
- $res = $field_value;
- break;
-
- case 'req':
-
- $field_value = clean_php($field_value);
- if ($tpl_empty)
- {
- $value = pretty_date(strftime(TIME_FORMAT, $field_value));
- }
- else
- {
- $value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_value)
- {
- return $field_value;
- },
- $tpl
- );
-
- return $res = $value;
- }
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
-
- if($tpl_empty && $tpl_file){
+ $AVE_Template->assign('field_id', $field_id);
$AVE_Template->assign('field_value', $field_value);
- return $AVE_Template->fetch($tpl_file);
- }
-
- $res = $field_value;
- break;
-
- case 'save':
- $res = $field_value;
- break;
+ $AVE_Template->assign('doc_id', (int)$_REQUEST['Id']);
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
- case 'name':
- return $AVE_Template->get_config_vars('name');
- break;
-
+ return $AVE_Template->fetch($tpl_file);
+ break;
+
+ case 'doc':
+ $field_value = clean_php($field_value);
+
+ if ($tpl_empty)
+ {
+ $value = pretty_date(strftime(TIME_FORMAT, $field_value));
+ }
+ else
+ {
+ $value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_value)
+ {
+ return $field_value;
+ },
+ $tpl
+ );
+
+ return $res = $value;
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $field_value);
+ $AVE_Template->assign('field_default', $default);
+
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ $res = $field_value;
+ break;
+
+ case 'req':
+ $field_value = clean_php($field_value);
+
+ if ($tpl_empty)
+ {
+ $value = pretty_date(strftime(TIME_FORMAT, $field_value));
+ }
+ else
+ {
+ $value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_value)
+ {
+ return $field_value;
+ },
+ $tpl
+ );
+
+ return $res = $value;
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $field_value);
+ $AVE_Template->assign('field_default', $default);
+
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ $res = $field_value;
+ break;
+
+ case 'save':
+ $res = $field_value;
+ break;
+
+
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+ break;
+
+ }
+ return ($res ? $res : $field_value);
}
- return ($res ? $res : $field_value);
-}
-?>
+?>
\ No newline at end of file
diff --git a/fields/doc_from_rub/field.php b/fields/doc_from_rub/field.php
index 8ce7215..3dcd5c0 100644
--- a/fields/doc_from_rub/field.php
+++ b/fields/doc_from_rub/field.php
@@ -1,170 +1,180 @@
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2015 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
-
-// Документ из рубрики
-function get_field_doc_from_rub($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null){
-
- global $AVE_DB, $AVE_Template;
+ /**
+ * AVE.cms
+ *
+ * @package AVE.cms
+ * @version 3.x
+ * @filesource
+ * @copyright © 2007-2015 AVE.cms, http://www.ave-cms.ru
+ *
+ * @license GPL v.2
+ */
+
+ // Документ из рубрики
+ function get_field_doc_from_rub($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null, $_tpl=null)
+ {
+ global $AVE_DB, $AVE_Template;
- $fld_dir = dirname(__FILE__) . '/';
- $tpl_dir = $fld_dir . 'tpl/';
+ $fld_dir = dirname(__FILE__) . '/';
+ $tpl_dir = $fld_dir . 'tpl/';
- $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
- $res = 0;
+ $res = 0;
- switch ($action)
- {
- case 'edit':
- if (isset($default))
- {
- $parent = $AVE_DB->Query("
- SELECT
- MIN(document_parent) AS min
- FROM
- ". PREFIX ."_documents
- WHERE
- rubric_id IN (" . $default . ")
- ")->GetCell();
-
- $sql = $AVE_DB->Query("
- SELECT
- Id, document_parent, document_title
- FROM
- ". PREFIX ."_documents
- WHERE
- rubric_id IN (" . $default . ")
- ");
-
- $cats = array();
-
- while($cat = $sql->FetchAssocArray())
+ switch ($action)
+ {
+ case 'edit':
+ if (isset($default))
{
- $cats_ID[$cat['Id']][] = $cat;
- $cats[$cat['document_parent']][$cat['Id']] = $cat;
+ $parent = $AVE_DB->Query("
+ SELECT
+ MIN(document_parent) AS min
+ FROM
+ ". PREFIX ."_documents
+ WHERE
+ rubric_id IN (" . $default . ")
+ ")->GetCell();
+
+ $sql = $AVE_DB->Query("
+ SELECT
+ Id, document_parent, document_title
+ FROM
+ ". PREFIX ."_documents
+ WHERE
+ rubric_id IN (" . $default . ")
+ ");
+
+ $cats = array();
+
+ while ($cat = $sql->FetchAssocArray())
+ {
+ $cats_ID[$cat['Id']][] = $cat;
+ $cats[$cat['document_parent']][$cat['Id']] = $cat;
+ }
+
+ $AVE_Template->assign('subtpl', $tpl_dir . "list.tpl");
+ $AVE_Template->assign('fields', doc_from_rub_tree($cats, $parent));
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('doc_id', (isset($_REQUEST['Id']) ? (int)$_REQUEST['Id'] : 0));
+ $AVE_Template->assign('field_value', $field_value);
+ }
+ else
+ {
+ $AVE_Template->assign('error', $AVE_Template->get_config_vars('error'));
}
- $AVE_Template->assign('subtpl', $tpl_dir . "list.tpl");
- $AVE_Template->assign('fields', doc_from_rub_tree($cats, $parent));
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('doc_id', (isset($_REQUEST['Id']) ? (int)$_REQUEST['Id'] : 0));
- $AVE_Template->assign('field_value', $field_value);
- }
- else
- {
- $AVE_Template->assign('error', $AVE_Template->get_config_vars('error'));
- }
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
- return $AVE_Template->fetch($tpl_file);
- break;
+ return $AVE_Template->fetch($tpl_file);
+ break;
- case 'doc':
- $document = get_document($field_value);
+ case 'doc':
+ $document = get_document($field_value);
- if ($tpl_empty)
- {
- $field_value = $document['document_title'];
- $field_value = clean_php($field_value);
- $field_value = stripcslashes($field_value);
- $field_value = htmlspecialchars_decode($field_value);
- }
- else
+ if ($tpl_empty)
{
- $field_param = explode('|', $field_value);
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
+ $field_value = $document['document_title'];
+ $field_value = clean_php($field_value);
+ $field_value = stripcslashes($field_value);
+ $field_value = htmlspecialchars_decode($field_value);
}
+ else
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $field_value);
+ $AVE_Template->assign('document', $document);
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
-
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('document', $document);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- $res = $field_value;
- break;
+ $res = $field_value;
+ break;
- case 'req':
- $document = get_document($field_value);
+ case 'req':
+ $document = get_document($field_value);
- if ($tpl_empty)
- {
- $field_value = $document['document_title'];
- $field_value = clean_php($field_value);
- $field_value = stripcslashes($field_value);
- $field_value = htmlspecialchars_decode($field_value);
- }
- else
+ if ($tpl_empty)
{
- $field_param = explode('|', $field_value);
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
+ $field_value = $document['document_title'];
+ $field_value = clean_php($field_value);
+ $field_value = stripcslashes($field_value);
+ $field_value = htmlspecialchars_decode($field_value);
}
+ else
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $field_value);
+ $AVE_Template->assign('document', $document);
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
-
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('document', $document);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- $res = $field_value;
- break;
+ $res = $field_value;
+ break;
- case 'name':
- return $AVE_Template->get_config_vars('name');
- break;
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+ break;
+ }
+ return ($res ? $res : $field_value);
}
- return ($res ? $res : $field_value);
-}
-function doc_from_rub_tree($cats, $parent)
-{
- if (is_array($cats) and isset($cats[$parent]))
+
+ if (! function_exists('doc_from_rub_tree'))
{
- foreach($cats[$parent] as $cat)
+ function doc_from_rub_tree($cats, $parent)
{
- $array[$cat['Id']]['Id'] = $cat['Id'];
- $array[$cat['Id']]['document_title'] = $cat['document_title'];
- $array[$cat['Id']]['child'] = doc_from_rub_tree($cats, $cat['Id']);
+ if (is_array($cats) and isset($cats[$parent]))
+ {
+ foreach($cats[$parent] as $cat)
+ {
+ $array[$cat['Id']]['Id'] = $cat['Id'];
+ $array[$cat['Id']]['document_title'] = $cat['document_title'];
+ $array[$cat['Id']]['child'] = doc_from_rub_tree($cats, $cat['Id']);
+ }
+ }
+ else
+ {
+ return null;
+ }
+
+ return $array;
}
}
- else
- {
- return null;
- }
-
- return $array;
-}
?>
\ No newline at end of file
diff --git a/fields/doc_from_rub_check/field.php b/fields/doc_from_rub_check/field.php
index c3cb44e..7f821ea 100644
--- a/fields/doc_from_rub_check/field.php
+++ b/fields/doc_from_rub_check/field.php
@@ -1,201 +1,204 @@
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2015 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
-
-// Документ из рубрики (Checkbox)
-function get_field_doc_from_rub_check($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null){
-
- global $AVE_DB, $AVE_Template;
+ /**
+ * AVE.cms
+ *
+ * @package AVE.cms
+ * @version 3.x
+ * @filesource
+ * @copyright © 2007-2015 AVE.cms, http://www.ave-cms.ru
+ *
+ * @license GPL v.2
+ */
+
+ // Документ из рубрики (Checkbox)
+ function get_field_doc_from_rub_check($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null, $_tpl=null)
+ {
+ global $AVE_DB, $AVE_Template;
- $fld_dir = dirname(__FILE__) . '/';
- $tpl_dir = $fld_dir . 'tpl/';
- $fld_name = basename($fld_dir);
+ $fld_dir = dirname(__FILE__) . '/';
+ $tpl_dir = $fld_dir . 'tpl/';
+ $fld_name = basename($fld_dir);
- $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
- $res = array();
+ $res = array();
- switch ($action)
- {
- case 'edit':
- if (isset($default))
- {
- $parent = $AVE_DB->Query("
+ switch ($action)
+ {
+ case 'edit':
+ if (isset($default))
+ {
+ $parent = $AVE_DB->Query("
+ SELECT
+ MIN(document_parent) AS min
+ FROM
+ ". PREFIX ."_documents
+ WHERE
+ rubric_id IN (" . $default . ")
+ ")->GetCell();
+
+ $sql = $AVE_DB->Query("
SELECT
- MIN(document_parent) AS min
+ Id, document_parent, document_title
FROM
". PREFIX ."_documents
WHERE
rubric_id IN (" . $default . ")
- ")->GetCell();
+ ");
- $sql = $AVE_DB->Query("
- SELECT
- Id, document_parent, document_title
- FROM
- ". PREFIX ."_documents
- WHERE
- rubric_id IN (" . $default . ")
- ");
+ $field_value_array = explode('|', $field_value);
+ $field_value_array = array_values(array_diff($field_value_array, array('')));
- $field_value_array = explode('|', $field_value);
- $field_value_array = array_values(array_diff($field_value_array, array('')));
+ $cats = array();
- $cats = array();
+ while($cat = $sql->FetchAssocArray())
+ {
+ $cat['checked'] = ((in_array($cat['Id'], $field_value_array) == false) ? "0" : "1");
+ $cats_ID[$cat['Id']][] = $cat;
+ $cats[$cat['document_parent']][$cat['Id']] = $cat;
+ }
- while($cat = $sql->FetchAssocArray())
+ $AVE_Template->assign('subtpl', $tpl_dir."list.tpl");
+ $AVE_Template->assign('fields', doc_from_rub_check_tree($cats, $parent));
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('doc_id', (isset($_REQUEST['Id']) ? (int)$_REQUEST['Id'] : 0));
+ $AVE_Template->assign('field_value', $field_value);
+ }
+ else
{
- $cat['checked'] = ((in_array($cat['Id'], $field_value_array) == false) ? "0" : "1");
- $cats_ID[$cat['Id']][] = $cat;
- $cats[$cat['document_parent']][$cat['Id']] = $cat;
+ $AVE_Template->assign('error', $AVE_Template->get_config_vars('error'));
}
- $AVE_Template->assign('subtpl', $tpl_dir."list.tpl");
- $AVE_Template->assign('fields', doc_from_rub_check_tree($cats, $parent));
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('doc_id', (isset($_REQUEST['Id']) ? (int)$_REQUEST['Id'] : 0));
- $AVE_Template->assign('field_value', $field_value);
- }
- else
- {
- $AVE_Template->assign('error', $AVE_Template->get_config_vars('error'));
- }
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
- $AVE_Template->assign('subtpl', $tpl_dir."list.tpl");
+ $AVE_Template->assign('subtpl', $tpl_dir."list.tpl");
- return $AVE_Template->fetch($tpl_file);
- break;
+ return $AVE_Template->fetch($tpl_file);
+ break;
- case 'doc':
- $field_value_array = explode('|', $field_value);
- $field_value_array = array_values(array_diff($field_value_array, array('')));
+ case 'doc':
+ $field_value_array = explode('|', $field_value);
+ $field_value_array = array_values(array_diff($field_value_array, array('')));
- if ($field_value_array != false)
- {
- foreach ($field_value_array as $list_item)
+ if ($field_value_array != false)
{
- if ($list_item)
+ foreach ($field_value_array as $list_item)
{
- if ($tpl_empty)
+ if ($list_item)
{
- $list_item = $AVE_DB->Query("
- SELECT
- Id,
- document_title,
- document_alias,
- document_breadcrum_title
- FROM
- ".PREFIX."_documents
- WHERE
- Id = '" . $list_item . "'
- ")->FetchAssocArray();
+ if ($tpl_empty)
+ {
+ $list_item = $AVE_DB->Query("
+ SELECT
+ Id,
+ document_title,
+ document_alias,
+ document_breadcrum_title
+ FROM
+ ".PREFIX."_documents
+ WHERE
+ Id = '" . $list_item . "'
+ ")->FetchAssocArray();
+ }
}
+ $res[] = $list_item;
}
- $res[] = $list_item;
}
- }
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
- if ($tpl_empty && $tpl_file)
- {
+ if ($tpl_empty && $tpl_file)
+ {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('field_count', count($res));
- $AVE_Template->assign('default', $default);
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('field_count', count($res));
+ $AVE_Template->assign('default', $default);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- return (!empty($res)) ? implode(PHP_EOL, $res) : $tpl;
- break;
+ return (!empty($res)) ? implode(PHP_EOL, $res) : $tpl;
+ break;
- case 'req':
- $field_value_array = explode('|', $field_value);
- $field_value_array = array_values(array_diff($field_value_array, array('')));
+ case 'req':
+ $field_value_array = explode('|', $field_value);
+ $field_value_array = array_values(array_diff($field_value_array, array('')));
- if ($field_value_array != false)
- {
- foreach ($field_value_array as $list_item)
+ if ($field_value_array != false)
{
- if ($list_item)
+ foreach ($field_value_array as $list_item)
{
- if ($tpl_empty)
+ if ($list_item)
{
- $list_item = $AVE_DB->Query("
- SELECT
- Id,
- document_title,
- document_alias,
- document_breadcrum_title
- FROM
- ".PREFIX."_documents
- WHERE
- Id = '" . $list_item . "'
- ")->FetchAssocArray();
+ if ($tpl_empty)
+ {
+ $list_item = $AVE_DB->Query("
+ SELECT
+ Id,
+ document_title,
+ document_alias,
+ document_breadcrum_title
+ FROM
+ ".PREFIX."_documents
+ WHERE
+ Id = '" . $list_item . "'
+ ")->FetchAssocArray();
+ }
}
+ $res[] = $list_item;
}
- $res[] = $list_item;
}
- }
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('field_count', count($res));
- $AVE_Template->assign('default', $default);
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('field_count', count($res));
+ $AVE_Template->assign('default', $default);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- return (!empty($res)) ? implode(PHP_EOL, $res) : $tpl;
- break;
+ return (!empty($res)) ? implode(PHP_EOL, $res) : $tpl;
+ break;
- case 'name' :
- return $AVE_Template->get_config_vars('name');
- break;
+ case 'name' :
+ return $AVE_Template->get_config_vars('name');
+ break;
- }
+ }
- return ($res ? $res : $field_value);
-}
+ return ($res ? $res : $field_value);
+ }
-function doc_from_rub_check_tree($cats, $parent)
-{
- if (is_array($cats) and isset($cats[$parent]))
+ if (! function_exists('doc_from_rub_check_tree'))
{
- foreach ($cats[$parent] as $cat)
+ function doc_from_rub_check_tree($cats, $parent)
{
- $array[$cat['Id']]['Id'] = $cat['Id'];
- $array[$cat['Id']]['checked'] = $cat['checked'];
- $array[$cat['Id']]['document_title'] = $cat['document_title'];
- $array[$cat['Id']]['child'] = doc_from_rub_check_tree($cats, $cat['Id']);
+ if (is_array($cats) and isset($cats[$parent]))
+ {
+ foreach ($cats[$parent] as $cat)
+ {
+ $array[$cat['Id']]['Id'] = $cat['Id'];
+ $array[$cat['Id']]['checked'] = $cat['checked'];
+ $array[$cat['Id']]['document_title'] = $cat['document_title'];
+ $array[$cat['Id']]['child'] = doc_from_rub_check_tree($cats, $cat['Id']);
+ }
+ }
+ else
+ {
+ return null;
+ }
+
+ return $array;
}
}
- else
- {
- return null;
- }
-
- return $array;
-}
?>
\ No newline at end of file
diff --git a/fields/doc_from_rub_search/field.php b/fields/doc_from_rub_search/field.php
index c595350..362c298 100644
--- a/fields/doc_from_rub_search/field.php
+++ b/fields/doc_from_rub_search/field.php
@@ -1,224 +1,224 @@
config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
-
- $res = array();
-
- switch ($action)
+ /**
+ * AVE.cms
+ *
+ * @package AVE.cms
+ * @version 3.x
+ * @filesource
+ * @copyright © 2007-2015 AVE.cms, http://www.ave-cms.ru
+ *
+ * @license GPL v.2
+ */
+
+ // Документы из рубрик (Поиск)
+ function get_field_doc_from_rub_search($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength = '', $doc_fields=array(), $rubric_id=0, $default=null, $_tpl=null)
{
- case 'edit':
+ global $AVE_DB, $AVE_Template;
- $items = array();
+ $fld_dir = dirname(__FILE__) . '/';
+ $tpl_dir = $fld_dir . 'tpl/';
+ $fld_name = basename($fld_dir);
- if ($field_value != '' && $field_value != $default)
- {
- $items = explode('|', $field_value);
- $items = array_values(array_diff($items, array('')));
- }
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
- if(! empty($items))
- {
- foreach($items as $k => $v)
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
+
+ $res = array();
+
+ switch ($action)
+ {
+ case 'edit':
+
+ $items = array();
+
+ if ($field_value != '' && $field_value != $default)
{
- $list[$k]['param'] = htmlspecialchars(get_document($v, 'document_title'), ENT_QUOTES);
- $list[$k]['value'] = $v;
+ $items = explode('|', $field_value);
+ $items = array_values(array_diff($items, array('')));
}
- $items = $list;
- }
- else
+ if(! empty($items))
{
- $items[0]['param'] = '';
- $items[0]['value'] = '';
+ foreach($items as $k => $v)
+ {
+ $list[$k]['param'] = htmlspecialchars(get_document($v, 'document_title'), ENT_QUOTES);
+ $list[$k]['value'] = $v;
+ }
+
+ $items = $list;
}
+ else
+ {
+ $items[0]['param'] = '';
+ $items[0]['value'] = '';
+ }
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
- $AVE_Template->assign('doc_id', $_REQUEST['Id']);
- $AVE_Template->assign('items', $items);
- $AVE_Template->assign('field_dir', $fld_name);
- $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('doc_id', $_REQUEST['Id']);
+ $AVE_Template->assign('items', $items);
+ $AVE_Template->assign('field_dir', $fld_name);
+ $AVE_Template->assign('field_id', $field_id);
- return $AVE_Template->fetch($tpl_file);
+ return $AVE_Template->fetch($tpl_file);
- case 'save':
- foreach ($field_value as $v)
- {
- if (! empty($v['value']))
+ case 'save':
+ foreach ($field_value as $v)
{
- $field_value_new[] = $v['value'];
+ if (! empty($v['value']))
+ {
+ $field_value_new[] = $v['value'];
+ }
}
- }
- if (isset($field_value_new))
- {
- return '|' . implode('|', $field_value_new) . '|';
- }
- else
+ if (isset($field_value_new))
{
- return $field_value_new = '';
+ return '|' . implode('|', $field_value_new) . '|';
}
- break;
+ else
+ {
+ return $field_value_new = '';
+ }
+ break;
- case 'doc':
- $field_value_array = explode('|', $field_value);
- $field_value_array = array_values(array_diff($field_value_array, array('')));
+ case 'doc':
+ $field_value_array = explode('|', $field_value);
+ $field_value_array = array_values(array_diff($field_value_array, array('')));
- if ($field_value_array != false)
- {
- foreach ($field_value_array as $list_item)
+ if ($field_value_array != false)
{
- if ($list_item)
+ foreach ($field_value_array as $list_item)
{
- if ($tpl_empty)
+ if ($list_item)
{
- $list_item = $AVE_DB->Query("
- SELECT
- Id,
- document_title,
- document_alias,
- document_breadcrum_title
- FROM
- ".PREFIX."_documents
- WHERE
- Id = '" . $list_item . "'
- ")->FetchAssocArray();
+ if ($tpl_empty)
+ {
+ $list_item = $AVE_DB->Query("
+ SELECT
+ Id,
+ document_title,
+ document_alias,
+ document_breadcrum_title
+ FROM
+ ".PREFIX."_documents
+ WHERE
+ Id = '" . $list_item . "'
+ ")->FetchAssocArray();
+ }
}
+ $res[] = $list_item;
}
- $res[] = $list_item;
}
- }
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('field_count', count($res));
- $AVE_Template->assign('default', $default);
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('field_count', count($res));
+ $AVE_Template->assign('default', $default);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- return (! empty($res)) ? implode(PHP_EOL, $res) : $tpl;
- break;
+ return (! empty($res)) ? implode(PHP_EOL, $res) : $tpl;
+ break;
- case 'req':
- $field_value_array = explode('|', $field_value);
- $field_value_array = array_values(array_diff($field_value_array, array('')));
+ case 'req':
+ $field_value_array = explode('|', $field_value);
+ $field_value_array = array_values(array_diff($field_value_array, array('')));
- if ($field_value_array != false)
- {
- foreach ($field_value_array as $list_item)
+ if ($field_value_array != false)
{
- if ($list_item)
+ foreach ($field_value_array as $list_item)
{
- if ($tpl_empty)
+ if ($list_item)
{
- $list_item = $AVE_DB->Query("
- SELECT
- Id,
- document_title,
- document_alias,
- document_breadcrum_title
- FROM
- ".PREFIX."_documents
- WHERE
- Id = '" . $list_item . "'
- ")->FetchAssocArray();
+ if ($tpl_empty)
+ {
+ $list_item = $AVE_DB->Query("
+ SELECT
+ Id,
+ document_title,
+ document_alias,
+ document_breadcrum_title
+ FROM
+ ".PREFIX."_documents
+ WHERE
+ Id = '" . $list_item . "'
+ ")->FetchAssocArray();
+ }
}
+ $res[] = $list_item;
}
- $res[] = $list_item;
}
- }
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('field_count', count($res));
- $AVE_Template->assign('default', $default);
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('field_count', count($res));
+ $AVE_Template->assign('default', $default);
- return $AVE_Template->fetch($tpl_file);
- }
-
- return (! empty($res)) ? implode(PHP_EOL, $res) : $tpl;
- break;
-
- case 'name' :
- return $AVE_Template->get_config_vars('name');
- break;
-
- case 'search':
- $default = get_field_default_value($_REQUEST['field_id']);
-
- $sql = $AVE_DB->Query("
- SELECT
- doc.Id,
- doc.document_title,
- rub.rubric_title
- FROM
- " . PREFIX . "_documents AS doc
- JOIN
- " . PREFIX . "_rubrics AS rub
- ON doc.rubric_id = rub.Id
- WHERE
- doc.rubric_id IN (" . $default . ")
- AND
- doc.document_status = 1
- AND
- UPPER (doc.document_title) LIKE UPPER('%" . $_REQUEST['q'] . "%')
- GROUP BY
- doc.Id
- LIMIT
- 0,5
- ");
-
- $doc_finded = array();
-
- while ($row = $sql->FetchRow())
- {
- $doc_finded[] = array(
- 'doc_id' => $row->Id,
- 'doc_title' => $row->document_title,
- 'doc_rubric' => $row->rubric_title
- );
- }
-
- echo json_encode($doc_finded);
- exit;
-
- default:
- return $field_value;
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return (! empty($res)) ? implode(PHP_EOL, $res) : $tpl;
+ break;
+
+ case 'name' :
+ return $AVE_Template->get_config_vars('name');
+ break;
+
+ case 'search':
+ $default = get_field_default_value($_REQUEST['field_id']);
+
+ $sql = $AVE_DB->Query("
+ SELECT
+ doc.Id,
+ doc.document_title,
+ rub.rubric_title
+ FROM
+ " . PREFIX . "_documents AS doc
+ JOIN
+ " . PREFIX . "_rubrics AS rub
+ ON doc.rubric_id = rub.Id
+ WHERE
+ doc.rubric_id IN (" . $default . ")
+ AND
+ doc.document_status = 1
+ AND
+ UPPER (doc.document_title) LIKE UPPER('%" . $_REQUEST['q'] . "%')
+ GROUP BY
+ doc.Id
+ LIMIT
+ 0,5
+ ");
+
+ $doc_finded = array();
+
+ while ($row = $sql->FetchRow())
+ {
+ $doc_finded[] = array(
+ 'doc_id' => $row->Id,
+ 'doc_title' => $row->document_title,
+ 'doc_rubric' => $row->rubric_title
+ );
+ }
- return ($res ? $res : $field_value);
-}
+ echo json_encode($doc_finded);
+ exit;
+
+ default:
+ return $field_value;
+ }
+
+ return ($res ? $res : $field_value);
+ }
?>
\ No newline at end of file
diff --git a/fields/doc_from_rub_search/js/outside.js b/fields/doc_from_rub_search/js/outside.js
deleted file mode 100644
index 7c01cd8..0000000
--- a/fields/doc_from_rub_search/js/outside.js
+++ /dev/null
@@ -1,127 +0,0 @@
-var DocSearch = {
-
- init: false,
-
- init: function() {
- if (this.initialized) return;
- this.initialized = true;
-
- this.DocSearch_items();
- },
-
- DocSearch_items: function() {
- this.DocSearch_sortable();
- this.DocSearch_del_item();
- this.DocSearch_add();
- this.DocSearch_search();
- },
-
- DocSearch_update: function() {
- this.DocSearch_maxid();
- this.DocSearch_del_item();
- this.DocSearch_search();
- AveAdmin.tooltip();
- },
-
- DocSearch_maxid: function(id) {
- var maxid = 1;
- $('#docsearch_lists_' + id).children('.docsearch_list').each(function() {
- maxid = Math.max(maxid, parseInt($(this).attr("data-id")) + 1);
- });
- return maxid;
- },
-
- DocSearch_del_item: function() {
- $('.docsearch_list .DelButton').on('click', function(event) {
- event.preventDefault();
- var id = $(this).attr('data-id');
- jConfirm(
- docsearch_del_conf,
- docsearch_del_head,
- function(b) {
- if (b) {
- $('#docsearch_list_' + id).remove();
- }
- }
- );
- });
- },
-
- DocSearch_add: function() {
- $('.AddButton').on('click', function() {
- c_id = $(this).parent().parent('.docsearch_lists').attr("data-id");
- d_id = $(this).parent().parent('.docsearch_lists').attr("data-docid");
- i_id = DocSearch.DocSearch_maxid(d_id + '_' + c_id);
- $('#docsearch_lists_' + d_id + '_' + c_id + ':last').append(
- ' '
- );
-
- DocSearch.DocSearch_update();
- });
- },
-
- DocSearch_sortable: function() {
- $('.docsearch_lists').sortable({
- handle: ".handle",
- placeholder: "ui-state-highlight grey_bg"
- });
- },
-
- /**
- * @return {boolean}
- */
- DocSearch_search: function() {
-
- $(document).on('input', '.search_docsearch', function(event)
- {
- event.preventDefault();
-
- var query = $(this);
-
- var did = query.attr('data-docid');
- var fid = query.attr('data-fieldid');
- var kid = query.attr('data-id');
- var field_id_input = $('.field_' + did + '_' + fid + '_' + kid);
-
- query.autocomplete("index.php?do=fields&field=doc_from_rub_search&type=search&doc_id=" + did + "&field_id=" + fid, {
- width: query.outerWidth(),
- max: 5,
- dataType: "json",
- matchContains: "word",
- scroll: true,
- scrollHeight: 200,
- parse: function(data) {
- return $.map(data, function(row) {
- return {
- data: row,
- value: row.doc_title,
- result: query.val()
- }
- });
- },
- formatItem: function(item) {
- return ' (' + item.doc_rubric + ') ' + item.doc_title + ' ';
- }
- }).result(function(event, item) {
-
- query.val(item.doc_title);
-
- field_id_input.val(item.doc_id);
-
- query.unautocomplete();
- });
-
- return false;
- });
-
- return false;
- }
-}
-
-$(document).ready(function()
-{
- DocSearch.init();
-});
\ No newline at end of file
diff --git a/fields/download/field.php b/fields/download/field.php
deleted file mode 100644
index 0b2973b..0000000
--- a/fields/download/field.php
+++ /dev/null
@@ -1,76 +0,0 @@
-
-
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
-
-// Загрузить файл
-function get_field_download($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null){
-
- global $AVE_Template;
-
- $fld_dir = dirname(__FILE__) . '/';
- $tpl_dir = $fld_dir . 'tpl/';
-
- $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
-
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
-
- $res=0;
-
- switch ($action)
- {
- case 'edit':
- $field_value = !empty($field_value) ? htmlspecialchars($field_value, ENT_QUOTES) : '';
-
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $field_value);
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
-
- return $AVE_Template->fetch($tpl_file);
- break;
-
- case 'doc':
- $field_value = clean_php($field_value);
- $field_param = explode('|', $field_value);
- if ($tpl_empty)
- {
- $field_value = (!empty($field_param[1]) ? $field_param[1] . ' ' : '')
- . ' ';
- }
- else
- {
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
- }
- $res = $field_value;
- break;
-
- case 'req':
- $res=get_field_default($field_value,$action,$field_id,$tpl,$tpl_empty,$maxlength,$document_fields,$rubric_id);
- break;
-
- case 'name' :
- return $AVE_Template->get_config_vars('name');
- break;
- }
- return ($res ? $res : $field_value);
-}
-?>
\ No newline at end of file
diff --git a/fields/download/lang/bg.txt b/fields/download/lang/bg.txt
deleted file mode 100644
index 568adeb..0000000
--- a/fields/download/lang/bg.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-[admin]
-
-name = "Линк към файл"
diff --git a/fields/download/lang/cz.txt b/fields/download/lang/cz.txt
deleted file mode 100644
index b7dcd65..0000000
--- a/fields/download/lang/cz.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-[admin]
-name = "Soubor ke stažení"
diff --git a/fields/download/lang/en.txt b/fields/download/lang/en.txt
deleted file mode 100644
index 4936e36..0000000
--- a/fields/download/lang/en.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-[admin]
-name = "Download file"
diff --git a/fields/download/lang/pl.txt b/fields/download/lang/pl.txt
deleted file mode 100644
index 7d0ef7d..0000000
--- a/fields/download/lang/pl.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-[admin]
-name = "Pobierz plik"
diff --git a/fields/download/lang/ru.txt b/fields/download/lang/ru.txt
deleted file mode 100644
index 91e422e..0000000
--- a/fields/download/lang/ru.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-[admin]
-name = "Загрузить файл"
diff --git a/fields/download/lang/ua.txt b/fields/download/lang/ua.txt
deleted file mode 100644
index eef181e..0000000
--- a/fields/download/lang/ua.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-[admin]
-name = "Завантажити файл"
diff --git a/fields/download/tpl/field.tpl b/fields/download/tpl/field.tpl
deleted file mode 100644
index b0f38cc..0000000
--- a/fields/download/tpl/field.tpl
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
- ?
\ No newline at end of file
diff --git a/fields/drop_down/field.php b/fields/drop_down/field.php
index 18f2007..8324c4c 100644
--- a/fields/drop_down/field.php
+++ b/fields/drop_down/field.php
@@ -1,87 +1,91 @@
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
-
-// Выпадающий список
-function get_field_drop_down($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null)
-{
- global $AVE_Template;
-
- $fld_dir = dirname(__FILE__) . '/';
- $tpl_dir = $fld_dir . 'tpl/';
-
- $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
-
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
-
- $res = 0;
-
- switch ($action)
+ /**
+ * AVE.cms
+ *
+ * @package AVE.cms
+ * @version 3.x
+ * @filesource
+ * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
+ *
+ * @license GPL v.2
+ */
+
+ // Выпадающий список
+ function get_field_drop_down($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null, $_tpl=null)
{
- case 'edit':
- $items = array();
- $items = explode(',', $default);
- $items = array_diff($items, array(''));
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
-
- $AVE_Template->assign('items', $items);
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', trim($field_value));
-
- return $AVE_Template->fetch($tpl_file);
- break;
-
- case 'doc':
- @$field_value = clean_php($field_value);
- if (!$tpl_empty)
- {
- $field_param = explode('|', $field_value);
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
- }
- $res = $field_value;
- break;
-
- case 'req':
- @$field_value = clean_php($field_value);
- if (!$tpl_empty)
- {
- $field_param = explode('|', $field_value);
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
- }
- $res = $field_value;
- break;
-
- case 'name':
- return $AVE_Template->get_config_vars('name');
- break;
+ global $AVE_Template;
+
+ $fld_dir = dirname(__FILE__) . '/';
+ $tpl_dir = $fld_dir . 'tpl/';
+
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
+
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
+
+ $res = 0;
+
+ switch ($action)
+ {
+ case 'edit':
+ $items = array();
+ $items = explode(',', $default);
+ $items = array_diff($items, array(''));
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
+
+ $AVE_Template->assign('items', $items);
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', trim($field_value));
+
+ return $AVE_Template->fetch($tpl_file);
+ break;
+
+ case 'doc':
+ @$field_value = clean_php($field_value);
+
+ if (! $tpl_empty)
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $res = $field_value;
+ break;
+
+ case 'req':
+ @$field_value = clean_php($field_value);
+
+ if (! $tpl_empty)
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $res = $field_value;
+ break;
+
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+ break;
+ }
+ return ($res ? $res : $field_value);
}
- return ($res ? $res : $field_value);
-}
-?>
+?>
\ No newline at end of file
diff --git a/fields/drop_down_key/field.php b/fields/drop_down_key/field.php
index 8697e03..ce06a23 100644
--- a/fields/drop_down_key/field.php
+++ b/fields/drop_down_key/field.php
@@ -1,78 +1,78 @@
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
+ /**
+ * AVE.cms
+ *
+ * @package AVE.cms
+ * @version 3.x
+ * @filesource
+ * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
+ *
+ * @license GPL v.2
+ */
-// Выпадающий список (Ключ)
-function get_field_drop_down_key($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null)
-{
- global $AVE_Template;
+ // Выпадающий список (Ключ)
+ function get_field_drop_down_key($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null, $_tpl=null)
+ {
+ global $AVE_Template;
- $fld_dir = dirname(__FILE__) . '/';
- $tpl_dir = $fld_dir . 'tpl/';
+ $fld_dir = dirname(__FILE__) . '/';
+ $tpl_dir = $fld_dir . 'tpl/';
- $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
- $res = 0;
+ $res = 0;
- switch ($action)
- {
- case 'edit':
- $items = explode(',', $default);
- $items = array_diff($items, array(''));
+ switch ($action)
+ {
+ case 'edit':
+ $items = explode(',', $default);
+ $items = array_diff($items, array(''));
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
- $AVE_Template->assign('items', $items);
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', trim($field_value));
+ $AVE_Template->assign('items', $items);
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', trim($field_value));
- return $AVE_Template->fetch($tpl_file);
- break;
+ return $AVE_Template->fetch($tpl_file);
+ break;
- case 'doc':
- case 'req':
- @$field_value = clean_php($field_value);
+ case 'doc':
+ case 'req':
+ @$field_value = clean_php($field_value);
- if (!$tpl_empty)
- {
- $field_param = explode('|', $field_value);
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
- }
- else
- {
- $items = explode(',', $default);
- $items = array_diff($items, array(''));
- $field_value = $items[$field_value];
- }
+ if (!$tpl_empty)
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+ else
+ {
+ $items = explode(',', $default);
+ $items = array_diff($items, array(''));
+ $field_value = $items[$field_value];
+ }
- return $field_value = ($field_value != '') ? $field_value : '';
- break;
+ return $field_value = ($field_value != '') ? $field_value : '';
+ break;
- case 'name':
- return $AVE_Template->get_config_vars('name');
- break;
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+ break;
+ }
+ return ($res ? $res : $field_value);
}
- return ($res ? $res : $field_value);
-}
-?>
+?>
\ No newline at end of file
diff --git a/fields/flash/field.php b/fields/flash/field.php
deleted file mode 100644
index 56453af..0000000
--- a/fields/flash/field.php
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
-
-//Flash-ролик
-function get_field_flash($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null){
- global $AVE_Template;
-
-
- $fld_dir = dirname(__FILE__) . '/';
- $tpl_dir = $fld_dir . 'tpl/';
-
- $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
-
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
-
- $res = 0;
-
- switch ($action)
- {
- case 'edit':
- $field_value = !empty($field_value) ? htmlspecialchars($field_value, ENT_QUOTES) : '';
-
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $field_value);
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
-
- return $AVE_Template->fetch($tpl_file);
- break;
-
- case 'doc':
- $field_value = clean_php($field_value);
- $field_param = explode('|', $field_value);
- $field_param[1] = (!empty($field_param[1]) && is_numeric($field_param[1])) ? $field_param[1] : 470;
- $field_param[2] = (!empty($field_param[2]) && is_numeric($field_param[2])) ? $field_param[2] : 320;
- if ($tpl_empty)
- {
- $field_value = ' ';
- }
- else
- {
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
- }
- $res=$field_value;
- break;
-
- case 'req':
- $res=get_field_default($field_value,$action,$field_id,$tpl,$tpl_empty,$maxlength,$document_fields,$rubric_id);
- break;
-
- case 'name' :
- return $AVE_Template->get_config_vars('name');
- break;
-
- }
- return ($res ? $res : $field_value);
-}
-?>
\ No newline at end of file
diff --git a/fields/flash/lang/bg.txt b/fields/flash/lang/bg.txt
deleted file mode 100644
index 851a564..0000000
--- a/fields/flash/lang/bg.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-[admin]
-name = "Flash"
\ No newline at end of file
diff --git a/fields/flash/lang/cz.txt b/fields/flash/lang/cz.txt
deleted file mode 100644
index a9c35ea..0000000
--- a/fields/flash/lang/cz.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-[admin]
-name = "Flash video (Flash)"
\ No newline at end of file
diff --git a/fields/flash/lang/pl.txt b/fields/flash/lang/pl.txt
deleted file mode 100644
index 016f1fc..0000000
--- a/fields/flash/lang/pl.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-[admin]
-name = "Wideo w formacie Flash"
\ No newline at end of file
diff --git a/fields/flash/lang/ru.txt b/fields/flash/lang/ru.txt
deleted file mode 100644
index 790af0f..0000000
--- a/fields/flash/lang/ru.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-[admin]
-name = "Флеш ролик (Flash)"
\ No newline at end of file
diff --git a/fields/flash/lang/ua.txt b/fields/flash/lang/ua.txt
deleted file mode 100644
index 790af0f..0000000
--- a/fields/flash/lang/ua.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-[admin]
-name = "Флеш ролик (Flash)"
\ No newline at end of file
diff --git a/fields/flash/tpl/field.tpl b/fields/flash/tpl/field.tpl
deleted file mode 100644
index d3d4215..0000000
--- a/fields/flash/tpl/field.tpl
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
- ?
diff --git a/fields/image_mega/field.php b/fields/image_mega/field.php
index 6cb7c27..32f6762 100755
--- a/fields/image_mega/field.php
+++ b/fields/image_mega/field.php
@@ -24,7 +24,7 @@
// Изображение (Каскад)
- function get_field_image_mega($field_value, $action, $field_id = 0, $tpl = '', $tpl_empty = 0, &$maxlength = null, $document_fields = array(), $rubric_id = 0, $default = null)
+ function get_field_image_mega($field_value, $action, $field_id = 0, $tpl = '', $tpl_empty = 0, &$maxlength = null, $document_fields = array(), $rubric_id = 0, $default = null, $_tpl=null)
{
global $AVE_Template, $img_pixel;
@@ -91,9 +91,9 @@
$default = explode('|', $default);
- list($path, $watermark, $position, $transparency) = $default;
+ list ($path, $watermark, $position, $transparency) = $default;
- if(preg_match("/%id/i", $path))
+ if (preg_match("/%id/i", $path))
{
if ($_REQUEST['action'] != 'new')
{
@@ -122,7 +122,7 @@
? $path_upload . '/'
: '');
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
$AVE_Template->assign('max_files', $AVE_Template->get_config_vars('max_f_f') . $iniset_count);
$AVE_Template->assign('dir_upload', $AVE_Template->get_config_vars('upl_dir') . $dir_upload);
@@ -194,7 +194,7 @@
}
}
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
if ($tpl_empty && $tpl_file)
{
@@ -268,7 +268,7 @@
}
}
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
if ($tpl_empty && $tpl_file)
{
@@ -301,13 +301,9 @@
}
if (isset($field_value_new))
- {
return serialize($field_value_new);
- }
else
- {
- return $field_value_new = '';
- }
+ return $field_value_new = '';
break;
@@ -365,6 +361,9 @@
if (! is_dir($dir_abs))
mkdir($dir_abs, 0777, true);
+ $new_files = array();
+ $thumbs = array();
+
foreach ($_FILES[$files_unput]['name'] as $name => $value)
{
$filename = strtolower(stripslashes(prepare_url($_FILES[$files_unput]['name'][$name])));
@@ -383,6 +382,8 @@
{
$new_files[] = $filename;
+ $thumbs[] = make_thumbnail(array('link' => $dir . $filename, 'size' => 'f128x128'));
+
if ((bool)$watermark)
{
$position = ($position != '') ? $position : 'center';
@@ -409,6 +410,7 @@
{
echo json_encode(array(
'files' => $new_files,
+ 'thumbs' => $thumbs,
'dir' => $dir,
'respons' => 'succes',
'message' => $AVE_Template->get_config_vars('resp_s_m'),
@@ -433,3 +435,4 @@
return ($res ? $res : $field_value);
}
+?>
\ No newline at end of file
diff --git a/fields/image_mega/js/field.js b/fields/image_mega/js/field.js
index 936c475..965dc57 100755
--- a/fields/image_mega/js/field.js
+++ b/fields/image_mega/js/field.js
@@ -117,7 +117,7 @@ var Mega = {
iid = Mega.mega_maxid(c_id, d_id);
var field_value = data['dir'] + data.files[p];
- var img_path = '../index.php?thumb=' + field_value + '&mode=f&width=128&height=128';
+ var img_path = data.thumbs[p];
$('#mega_' + d_id + '_' + c_id + ' > .mega_sortable:last').prepend(
' ' +
diff --git a/fields/image_multi/field.php b/fields/image_multi/field.php
index a1d5d80..0d44a6b 100755
--- a/fields/image_multi/field.php
+++ b/fields/image_multi/field.php
@@ -1,395 +1,396 @@
config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP')
+ ? $_SESSION['admin_language']
+ : $_SESSION['user_language']) . '.txt';
- $res = 0;
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
- $iniset_count = ini_get('max_file_uploads');
+ $res = 0;
- switch ($action)
- {
- case 'edit':
+ $iniset_count = ini_get('max_file_uploads');
- $items = array();
- $image_items = array();
+ switch ($action)
+ {
+ case 'edit':
- if ($_REQUEST['action'] != 'new')
- {
- $items = unserialize($field_value);
+ $items = array();
+ $image_items = array();
- if($items != false)
+ if ($_REQUEST['action'] != 'new')
{
- foreach($items as $k => $v)
+ $items = unserialize($field_value);
+
+ if($items != false)
{
- $image_item = explode('|', $v);
+ foreach($items as $k => $v)
+ {
+ $image_item = explode('|', $v);
- $img = $image_item[0];
- unset($image_item[0]);
- $image_item = array($img, implode('|', $image_item));
+ $img = $image_item[0];
+ unset($image_item[0]);
+ $image_item = array($img, implode('|', $image_item));
- $image[$k]['url'] = $image_item[0];
- $image[$k]['thumb'] = ($image_item[0] != '')
- ? make_thumbnail(array('size' => 'f100x100', 'link' => $image_item[0]))
- : $img_pixel;
+ $image[$k]['url'] = $image_item[0];
+ $image[$k]['thumb'] = ($image_item[0] != '')
+ ? make_thumbnail(array('size' => 'f100x100', 'link' => $image_item[0]))
+ : $img_pixel;
- $image[$k]['desc'] = (isset($image_item[1]))
- ? htmlspecialchars($image_item[1], ENT_QUOTES)
- : '';
- }
+ $image[$k]['desc'] = (isset($image_item[1]))
+ ? htmlspecialchars($image_item[1], ENT_QUOTES)
+ : '';
+ }
- if (! empty($image))
- {
- $image_items = $image;
+ if (! empty($image))
+ {
+ $image_items = $image;
+ }
}
}
- }
- $show_upload = true;
+ $show_upload = true;
- $default = explode('|', $default);
+ $default = explode('|', $default);
- list($path, $watermark, $position, $transparency) = $default;
+ list($path, $watermark, $position, $transparency) = $default;
- if(preg_match("/%id/i", $path))
- {
- if ($_REQUEST['action'] != 'new')
+ if(preg_match("/%id/i", $path))
{
- $path_upload = trim(@str_replace('%id', $_REQUEST['Id'], $path), '/');
- $show_upload = true;
+ if ($_REQUEST['action'] != 'new')
+ {
+ $path_upload = trim(@str_replace('%id', $_REQUEST['Id'], $path), '/');
+ $show_upload = true;
+ }
+ else
+ {
+ $path_upload = (! empty($path))
+ ? trim($path, '/')
+ : '';
+
+ $show_upload = false;
+ }
}
else
{
$path_upload = (! empty($path))
- ? trim($path, '/')
+ ? $path
: '';
- $show_upload = false;
+ $show_upload = true;
}
- }
- else
- {
- $path_upload = (! empty($path))
- ? $path
- : '';
-
- $show_upload = true;
- }
- $dir_upload = '/' . UPLOAD_DIR . '/' . ((!empty($path_upload))
- ? $path_upload . '/'
- : '');
+ $dir_upload = '/' . UPLOAD_DIR . '/' . ((!empty($path_upload))
+ ? $path_upload . '/'
+ : '');
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
- $AVE_Template->assign('max_files', $AVE_Template->get_config_vars('max_f_f') . $iniset_count);
- $AVE_Template->assign('dir_upload', $AVE_Template->get_config_vars('upl_dir') . $dir_upload);
- $AVE_Template->assign('show_upload', $show_upload);
+ $AVE_Template->assign('max_files', $AVE_Template->get_config_vars('max_f_f') . $iniset_count);
+ $AVE_Template->assign('dir_upload', $AVE_Template->get_config_vars('upl_dir') . $dir_upload);
+ $AVE_Template->assign('show_upload', $show_upload);
- $AVE_Template->assign('field_dir', $fld_name);
- $AVE_Template->assign('images', $image_items);
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('doc_id', (isset($_REQUEST['Id']) ? (int)$_REQUEST['Id'] : 0));
- return $AVE_Template->fetch($tpl_file);
- break;
+ $AVE_Template->assign('field_dir', $fld_name);
+ $AVE_Template->assign('images', $image_items);
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('doc_id', (isset($_REQUEST['Id']) ? (int)$_REQUEST['Id'] : 0));
+ return $AVE_Template->fetch($tpl_file);
+ break;
- case 'doc':
+ case 'doc':
- $items = (isset($field_value))
- ? unserialize($field_value)
- : array();
+ $items = (isset($field_value))
+ ? unserialize($field_value)
+ : array();
- $res = array();
+ $res = array();
- if ($items != false)
- {
- foreach ($items as $image_item)
+ if ($items != false)
{
- $image_item = clean_php($image_item);
- $field_param = explode('|', $image_item);
-
- if ($image_item)
+ foreach ($items as $image_item)
{
- if ($tpl_empty)
+ $image_item = clean_php($image_item);
+ $field_param = explode('|', $image_item);
+
+ if ($image_item)
{
- $image_item = $field_param;
- }
- else
+ if ($tpl_empty)
{
- $image_item = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
-
- $image_item = preg_replace_callback(
- '/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/',
- create_function(
- '$m',
- 'return watermarks(\'$m[1]\', \'$m[2]\', $m[3]);'
- ),
- $image_item
- );
-
- $image_item = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $image_item);
+ $image_item = $field_param;
}
- }
+ else
+ {
+ $image_item = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+
+ $image_item = preg_replace_callback(
+ '/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/',
+ create_function(
+ '$m',
+ 'return watermarks(\'$m[1]\', \'$m[2]\', $m[3]);'
+ ),
+ $image_item
+ );
+
+ $image_item = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $image_item);
+ }
+ }
- $res[] = $image_item;
+ $res[] = $image_item;
+ }
}
- }
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('field_count', count($res));
- $AVE_Template->assign('rubric_id', $rubric_id);
- $AVE_Template->assign('default', $default);
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('field_count', count($res));
+ $AVE_Template->assign('rubric_id', $rubric_id);
+ $AVE_Template->assign('default', $default);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- return (! empty($res))
- ? implode(PHP_EOL, $res)
- : $tpl;
+ return (! empty($res))
+ ? implode(PHP_EOL, $res)
+ : $tpl;
- break;
+ break;
- case 'req':
- $items = unserialize($field_value);
+ case 'req':
+ $items = unserialize($field_value);
- $res = array();
+ $res = array();
- if ($items != false)
- {
- foreach ($items as $image_item)
+ if ($items != false)
{
- $image_item = clean_php($image_item);
- $field_param = explode('|', $image_item);
-
- if ($image_item)
+ foreach ($items as $image_item)
{
- if ($tpl_empty)
+ $image_item = clean_php($image_item);
+ $field_param = explode('|', $image_item);
+
+ if ($image_item)
{
- $image_item = $field_param;
- }
- else
+ if ($tpl_empty)
{
- $image_item = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
-
- $image_item = preg_replace_callback(
- '/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/',
- create_function(
- '$m',
- 'return watermarks(\'$m[1]\', \'$m[2]\', $m[3]);'
- ),
- $image_item
- );
-
- $image_item = preg_replace_callback('/\[tag:([r|c|f]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $image_item);
+ $image_item = $field_param;
}
- }
+ else
+ {
+ $image_item = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+
+ $image_item = preg_replace_callback(
+ '/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/',
+ create_function(
+ '$m',
+ 'return watermarks(\'$m[1]\', \'$m[2]\', $m[3]);'
+ ),
+ $image_item
+ );
+
+ $image_item = preg_replace_callback('/\[tag:([r|c|f]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $image_item);
+ }
+ }
- $res[] = $image_item;
+ $res[] = $image_item;
+ }
}
- }
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('field_count', count($res));
- $AVE_Template->assign('rubric_id', $rubric_id);
- $AVE_Template->assign('default', $default);
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('field_count', count($res));
+ $AVE_Template->assign('rubric_id', $rubric_id);
+ $AVE_Template->assign('default', $default);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- return (! empty($res))
- ? implode(PHP_EOL, $res)
- : $tpl;
+ return (! empty($res))
+ ? implode(PHP_EOL, $res)
+ : $tpl;
- break;
+ break;
- case 'save':
- foreach ($field_value as $v)
- {
- if (! empty($v['url']))
+ case 'save':
+ foreach ($field_value as $v)
{
- $field_value_new[] = $v['url'] . ($v['descr'] ? '|' . $v['descr'] : '');
+ if (! empty($v['url']))
+ {
+ $field_value_new[] = $v['url'] . ($v['descr'] ? '|' . $v['descr'] : '');
+ }
}
- }
- if (isset($field_value_new))
- {
- return @serialize($field_value_new);
- }
- else
+ if (isset($field_value_new))
{
- return $field_value_new = '';
+ return @serialize($field_value_new);
}
+ else
+ {
+ return $field_value_new = '';
+ }
- break;
+ break;
- case 'name' :
- return $AVE_Template->get_config_vars('name');
- break;
+ case 'name' :
+ return $AVE_Template->get_config_vars('name');
+ break;
- case 'upload':
- $error = false;
+ case 'upload':
+ $error = false;
- $search = array();
- $replace = array();
+ $search = array();
+ $replace = array();
- $files_unput = 'cascade_files'.'_'.$_REQUEST['field_id'].'_'.$_REQUEST['doc_id'];
+ $files_unput = 'cascade_files'.'_'.$_REQUEST['field_id'].'_'.$_REQUEST['doc_id'];
- $search[] = '%d';
- $replace[] = date('d');
- $search[] = '%m';
- $replace[] = date('m');
- $search[] = '%Y';
- $replace[] = date('Y');
+ $search[] = '%d';
+ $replace[] = date('d');
+ $search[] = '%m';
+ $replace[] = date('m');
+ $search[] = '%Y';
+ $replace[] = date('Y');
- $default = explode('|', $default);
+ $default = explode('|', $default);
- list($path_upload, $watermark, $position, $transparency) = $default;
+ list($path_upload, $watermark, $position, $transparency) = $default;
- if (! empty($path_upload))
- $path_upload = str_replace($search, $replace, $path_upload);
+ if (! empty($path_upload))
+ $path_upload = str_replace($search, $replace, $path_upload);
- if(preg_match("/%id/i", $path_upload))
- {
- $path = trim(@str_replace('%id', $_REQUEST['doc_id'], $path_upload), '/');
- }
- else
+ if(preg_match("/%id/i", $path_upload))
{
- $path = (! empty($path_upload))
- ? $path_upload
- : '';
+ $path = trim(@str_replace('%id', $_REQUEST['doc_id'], $path_upload), '/');
}
+ else
+ {
+ $path = (! empty($path_upload))
+ ? $path_upload
+ : '';
+ }
- function getExtension($file)
- {
- $file = pathinfo($file);
- return $file['extension'];
- }
-
- $valid_formats = array("jpg", "png", "gif", "bmp","jpeg");
-
- $dir = '/' . UPLOAD_DIR . '/' . ((! empty($path))
- ? trim($path, '/') . '/'
- : '');
+ function getExtension($file)
+ {
+ $file = pathinfo($file);
+ return $file['extension'];
+ }
- $dir_abs = BASE_DIR . $dir;
+ $valid_formats = array("jpg", "png", "gif", "bmp","jpeg");
- if (! is_dir($dir_abs))
- @mkdir($dir_abs, 0777, true);
+ $dir = '/' . UPLOAD_DIR . '/' . ((! empty($path))
+ ? trim($path, '/') . '/'
+ : '');
- foreach ($_FILES[$files_unput]['name'] as $name => $value)
- {
- $filename = strtolower(stripslashes(prepare_url($_FILES[$files_unput]['name'][$name])));
+ $dir_abs = BASE_DIR . $dir;
- $ext = getExtension($filename);
- $ext = strtolower($ext);
+ if (! is_dir($dir_abs))
+ @mkdir($dir_abs, 0777, true);
- if(in_array($ext, $valid_formats))
+ foreach ($_FILES[$files_unput]['name'] as $name => $value)
{
- if (file_exists($dir_abs . $filename))
- {
- $filename = rand(1000, 9999) . '_' . $filename;
- }
+ $filename = strtolower(stripslashes(prepare_url($_FILES[$files_unput]['name'][$name])));
+
+ $ext = getExtension($filename);
+ $ext = strtolower($ext);
- if (@move_uploaded_file($_FILES[$files_unput]['tmp_name'][$name], $dir_abs . $filename))
+ if(in_array($ext, $valid_formats))
{
- $new_files[] = $filename;
- $error = false;
+ if (file_exists($dir_abs . $filename))
+ {
+ $filename = rand(1000, 9999) . '_' . $filename;
+ }
- if ((bool)$watermark)
+ if (@move_uploaded_file($_FILES[$files_unput]['tmp_name'][$name], $dir_abs . $filename))
{
- $position = ($position != '') ? $position : 'center';
- $transparency = ($transparency != '') ? $transparency : '100';
+ $new_files[] = $filename;
+ $error = false;
- watermarks($dir . $filename, $position, $transparency);
+ if ((bool)$watermark)
+ {
+ $position = ($position != '') ? $position : 'center';
+ $transparency = ($transparency != '') ? $transparency : '100';
+
+ watermarks($dir . $filename, $position, $transparency);
+ }
}
+ else
+ {
+ $error = true;
+ }
}
else
{
$error = true;
+ @unlink($_FILES[$files_unput]['tmp_name'][$name]);
}
}
- else
- {
- $error = true;
- @unlink($_FILES[$files_unput]['tmp_name'][$name]);
- }
- }
-
- if ($error !== true)
- {
- echo json_encode(array(
- 'files' => $new_files,
- 'dir' => $dir,
- 'respons' => 'succes',
- 'message' => $AVE_Template->get_config_vars('resp_s_m'),
- 'header' => $AVE_Template->get_config_vars('resp_s_h'),
- 'theme' => 'accept'
- )
- );
- }
- else
+
+ if ($error !== true)
{
echo json_encode(array(
- 'respons' => 'error',
- 'message' => $AVE_Template->get_config_vars('resp_e_m'),
- 'header' => $AVE_Template->get_config_vars('resp_e_h'),
- 'theme' => 'error'
+ 'files' => $new_files,
+ 'dir' => $dir,
+ 'respons' => 'succes',
+ 'message' => $AVE_Template->get_config_vars('resp_s_m'),
+ 'header' => $AVE_Template->get_config_vars('resp_s_h'),
+ 'theme' => 'accept'
)
);
}
+ else
+ {
+ echo json_encode(array(
+ 'respons' => 'error',
+ 'message' => $AVE_Template->get_config_vars('resp_e_m'),
+ 'header' => $AVE_Template->get_config_vars('resp_e_h'),
+ 'theme' => 'error'
+ )
+ );
+ }
- exit;
- }
+ exit;
+ }
- return ($res ? $res : $field_value);
-}
+ return ($res ? $res : $field_value);
+ }
+?>
\ No newline at end of file
diff --git a/fields/image_multi/js/outside.js b/fields/image_multi/js/outside.js
deleted file mode 100755
index 6a35ba2..0000000
--- a/fields/image_multi/js/outside.js
+++ /dev/null
@@ -1,231 +0,0 @@
-var Cascad = {
-
- init: false,
-
- init: function() {
- if (this.initialized) return;
- this.initialized = true;
-
- this.cascad();
- },
-
- cascad: function() {
- this.cascad_sortable();
- this.cascad_del_item();
- this.cascad_del_all_item();
- this.cascad_add_single();
- this.cascad_add_folder();
- this.cascade_upload_files();
- this.cascad_click_upload();
- },
-
- cascad_update: function() {
- this.cascad_maxid();
- this.cascad_del_item();
- AveAdmin.fancy_box();
- AveAdmin.tooltip();
- },
-
- cascad_maxid: function(id, doc) {
- var maxid = 1;
- $('#cascad_' + doc + '_' + id).children('.cascad_sortable').children('.cascad_item').each(function() {
- maxid = Math.max(maxid, parseInt($(this).attr("data-id")) + 1);
- });
- return maxid;
- },
-
- cascad_del_item: function() {
- $('.cascad_item .delete').on('click', function(event) {
- event.preventDefault();
- var id = $(this).attr('data-id');
- jConfirm(
- del_conf,
- del_head,
- function(b) {
- if (b) {
- $('#cascad_image_' + id).remove();
- }
- }
- );
- });
- },
-
- cascad_del_all_item: function() {
- $('.del_all').on('click', function(event) {
- event.preventDefault();
- var c_id = $(this).parent().parent().parent('.cascad').attr("data-id");
- var d_id = $(this).parent().parent().parent('.cascad').attr("data-doc");
- jConfirm(
- del_all_c,
- del_all_h,
- function(b) {
- if (b) {
- $('#cascad_' + d_id + '_' + c_id).children('.cascad_sortable').children('.cascad_item').each(function() {
- $(this).remove();
- });
- }
- }
- );
- });
- },
-
- cascade_upload_files: function() {
- $('.cascade_upload').on('change', function(event) {
-
- event.preventDefault();
-
- var cascade_input = $(this);
-
- event.preventDefault();
-
- if (cascade_input.val() == '') {
- return false;
- }
-
- var files_input = this.files.length;
- var max_files = cascade_input.attr("data-max-files");
-
- if (files_input > max_files) {
- $.jGrowl(max_f_t, {
- header: max_f_h,
- theme: 'error'
- });
-
- cascade_input.replaceWith(cascade_input.val('').clone(true));
-
- return false;
- }
-
- var cid = $(this).parent('.cascad').attr("data-id");
- var did = $(this).parent('.cascad').attr("data-doc");
- var rid = $(this).parent('.cascad').attr("data-rubric");
-
- $('#docmanager_edit').ajaxSubmit({
- url: 'index.php?do=fields',
- data: {
- "field_id": cid,
- "rubric_id": rid,
- "doc_id": did,
- "field": 'image_multi',
- "type": 'upload'
- },
- beforeSend: function() {
- $.alerts._overlay('show');
- },
- dataType: "json",
- success: function(data) {
- if (data['respons'] == 'succes') {
- for (var p = 0, max = data.files.length; p < max; p++) {
- iid = Cascad.cascad_maxid(cid, did);
- var field_value = data['dir'] + data.files[p];
- var img_path = '../index.php?thumb=' + field_value + '&mode=f&width=128&height=128';
- $('#cascad_' + did + '_' + cid + ' > .cascad_sortable:last').prepend(
- ' ' +
- '' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' '
- );
- $.alerts._overlay('hide');
- Cascad.cascad_update();
- }
- }
- $.jGrowl(data['message'], {
- header: data['header'],
- theme: data['theme']
- });
- cascade_input.replaceWith(cascade_input = cascade_input.clone(true));
- cascade_input.val();
- }
- });
- return false;
- });
- },
-
- cascad_click_upload: function() {
- $('.upload_local').on('click', function(event) {
- event.preventDefault();
- var c_id = $(this).parent().parent().parent('.cascad').attr("data-id");
- var d_id = $(this).parent().parent().parent('.cascad').attr("data-doc");
- $('.cascade_upload_field_' + c_id + '_' + d_id).trigger('click');
- });
- },
-
- cascad_add_single: function() {
- $('.add_single').on('click', function(event) {
- event.preventDefault();
- var c_id = $(this).parent().parent().parent('.cascad').attr("data-id");
- var d_id = $(this).parent().parent().parent('.cascad').attr("data-doc");
- var iid = Cascad.cascad_maxid(c_id, d_id);
- $('#cascad_' + d_id + '_' + c_id + ' > .cascad_sortable:last').prepend(
- ' ' +
- '' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' '
- );
- browse_uploads('image__' + c_id + '_' + d_id + '_' + iid + '');
- Cascad.cascad_update();
- });
- },
-
- cascad_sortable: function() {
- $('.cascad_sortable').sortable({
- handle: ".header",
- placeholder: "ui-state-highlight grey_bg"
- });
- //$(".cascad").disableSelection();
- },
-
- cascad_add_folder: function() {
- $('.add_folder').on('click', function(event) {
- event.preventDefault();
- var c_id = $(this).parent().parent().parent('.cascad').attr("data-id");
- var d_id = $(this).parent().parent().parent('.cascad').attr("data-doc");
- browse_dirs("cascad__" + c_id + '_' + d_id);
- });
- }
-}
-
-$(document).ready(function() {
- Cascad.init();
-
- $.fn.myPlugin = function cascad_add_items(dir, cid, did) {
-
- $.ajax({
- url: ave_path + 'admin/index.php?do=docs&action=image_import&ajax=run',
- data: {
- "path": dir
- },
- dataType: "json",
- success: function(data) {
- $.alerts._overlay('hide');
- for (var p = 0, max = data.respons.length; p < max; p++) {
- var iid = Cascad.cascad_maxid(cid, did);
- var field_value = dir + data.respons[p];
- var img_path = '../index.php?thumb=' + field_value + '&mode=f&width=128&height=128';
- $('#cascad_' + did + '_' + cid + ' > .cascad_sortable:last').prepend(
- ' ' +
- '' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' '
- );
- Cascad.cascad_update();
- }
- }
- });
- }
-
-});
\ No newline at end of file
diff --git a/fields/image_single/field.php b/fields/image_single/field.php
index 9d7ad34..0d46452 100644
--- a/fields/image_single/field.php
+++ b/fields/image_single/field.php
@@ -1,161 +1,161 @@
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
+ /**
+ * AVE.cms
+ *
+ * @package AVE.cms
+ * @version 3.x
+ * @filesource
+ * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
+ *
+ * @license GPL v.2
+ */
+
+ // Изображение
+ function get_field_image_single($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null, $_tpl=null)
+ {
+ global $AVE_Template;
-// Изображение
-function get_field_image_single($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null){
+ $fld_dir = dirname(__FILE__) . '/';
+ $tpl_dir = $fld_dir . 'tpl/';
+ $fld_name = basename($fld_dir);
- global $AVE_Template;
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
- $fld_dir = dirname(__FILE__) . '/';
- $tpl_dir = $fld_dir . 'tpl/';
- $fld_name = basename($fld_dir);
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
- $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
+ $res = 0;
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
+ switch ($action)
+ {
+ case 'edit':
+ $blanc = '/uploads/images/noimage.gif';
+ $image = explode('|', $field_value);
+ $img = $image[0];
+ unset($image[0]);
+ $image = array($img, implode('|', $image));
+ $field = (!empty($image[0]) ? '../' . make_thumbnail(array('link' => $image[0], 'size' => 'f128x128')) : make_thumbnail(array('link' => $blanc, 'size' => 'f128x128')));
- $res = 0;
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
+
+ $AVE_Template->assign('field_dir', $fld_name);
+ $AVE_Template->assign('image', $image);
+ $AVE_Template->assign('doc_id', (int)$_REQUEST['Id']);
+ $AVE_Template->assign('field', $field);
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $field_value);
- switch ($action)
- {
- case 'edit':
- $blanc = '/uploads/images/noimage.gif';
- $image = explode('|', $field_value);
- $img = $image[0];
- unset($image[0]);
- $image = array($img, implode('|', $image));
- $field = (!empty($image[0]) ? '../' . make_thumbnail(array('link' => $image[0], 'size' => 'f128x128')) : make_thumbnail(array('link' => $blanc, 'size' => 'f128x128')));
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
-
- $AVE_Template->assign('field_dir', $fld_name);
- $AVE_Template->assign('image', $image);
- $AVE_Template->assign('doc_id', (int)$_REQUEST['Id']);
- $AVE_Template->assign('field', $field);
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $field_value);
-
- return $AVE_Template->fetch($tpl_file);
- break;
-
- case 'doc':
- $field_value = clean_php($field_value);
-
- $field_param = explode('|', $field_value);
-
- if ($tpl_empty)
- {
- $field_value = ' ';
- }
- else
- {
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
-
- $field_value = preg_replace_callback(
- '/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/',
- create_function(
- '$m',
- 'return watermarks(\'$m[1]\', \'$m[2]\', $m[3]);'
- ),
- $field_value
- );
-
- $field_value = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $field_value);
- }
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
-
- if($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('image', $field_param);
- return $AVE_Template->fetch($tpl_file);
- }
-
- return $field_value;
- break;
-
- case 'req':
- $field_value = clean_php($field_value);
-
- $field_param = explode('|', $field_value);
-
- if ($tpl_empty)
- {
- $field_param[1] = isset($field_param[1]) ? $field_param[1] : '';
- $field_value = ' ';
- }
- else
- {
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
-
- $field_value = preg_replace_callback(
- '/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/',
- create_function(
- '$m',
- 'return watermarks(\'$m[1]\', \'$m[2]\', $m[3]);'
- ),
- $field_value
- );
-
- $field_value = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $field_value);
- }
-
- $maxlength = null;
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
-
- if($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('image', $field_param);
return $AVE_Template->fetch($tpl_file);
- }
-
- return $field_value;
- break;
-
- case 'save':
- if (isset($field_value) && $field_value['img'] != '' )
- {
- $field_value = htmlspecialchars(implode("|", $field_value), ENT_QUOTES);
- }
- else
- {
- $field_value = '';
- }
- break;
-
- case 'name' :
- return $AVE_Template->get_config_vars('name');
- break;
+ break;
+
+ case 'doc':
+ $field_value = clean_php($field_value);
+
+ $field_param = explode('|', $field_value);
+
+ if ($tpl_empty)
+ {
+ $field_value = ' ';
+ }
+ else
+ {
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+
+ $field_value = preg_replace_callback(
+ '/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/',
+ create_function(
+ '$m',
+ 'return watermarks(\'$m[1]\', \'$m[2]\', $m[3]);'
+ ),
+ $field_value
+ );
+
+ $field_value = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $field_value);
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
+
+ if($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('image', $field_param);
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return $field_value;
+ break;
+
+ case 'req':
+ $field_value = clean_php($field_value);
+
+ $field_param = explode('|', $field_value);
+
+ if ($tpl_empty)
+ {
+ $field_param[1] = isset($field_param[1]) ? $field_param[1] : '';
+ $field_value = ' ';
+ }
+ else
+ {
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+
+ $field_value = preg_replace_callback(
+ '/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/',
+ create_function(
+ '$m',
+ 'return watermarks(\'$m[1]\', \'$m[2]\', $m[3]);'
+ ),
+ $field_value
+ );
+
+ $field_value = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $field_value);
+ }
+
+ $maxlength = null;
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
+
+ if($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('image', $field_param);
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return $field_value;
+ break;
+
+ case 'save':
+ if (isset($field_value) && $field_value['img'] != '' )
+ {
+ $field_value = htmlspecialchars(implode("|", $field_value), ENT_QUOTES);
+ }
+ else
+ {
+ $field_value = '';
+ }
+ break;
+
+ case 'name' :
+ return $AVE_Template->get_config_vars('name');
+ break;
+ }
+
+ return ($res ? $res : $field_value);
}
-
- return ($res ? $res : $field_value);
-}
-?>
+?>
\ No newline at end of file
diff --git a/fields/link/field.php b/fields/link/field.php
index 54e1965..ec9d622 100644
--- a/fields/link/field.php
+++ b/fields/link/field.php
@@ -1,100 +1,100 @@
-
-
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
-
-// Ссылка
-function get_field_link($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null){
-
- global $AVE_Template;
-
- $fld_dir = dirname(__FILE__) . '/';
- $tpl_dir = $fld_dir . 'tpl/';
-
- $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
-
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
-
- $res = '';
-
- switch ($action)
+assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $field_value);
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
-
- return $AVE_Template->fetch($tpl_file);
- break;
-
- case 'doc':
- $field_value = clean_php($field_value);
- $field_param = explode('|', $field_value);
- $field_param[1] = empty($field_param[1]) ? $field_param[0] : $field_param[1];
-
- if ($tpl_empty)
- {
- $field_value = ' ' . $field_param[1] . '';
- }
- else
- {
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
- }
-
- $res = $field_value;
- break;
-
- case 'req':
- $field_value = clean_php($field_value);
- $field_param = explode('|', $field_value);
-
- if (empty($field_param[1]))
- $field_param[1] = $field_param[0];
-
- if (isset($document_fields[$rubric_id]['tpl_req_empty']))
- {
- $field_value = " " . $field_param[1] . "";
- }
- else
- {
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
- }
-
- $maxlength = null;
-
- $res = $field_value;
- break;
-
- case 'name' :
- return $AVE_Template->get_config_vars('name');
- break;
-
+ global $AVE_Template;
+
+ $fld_dir = dirname(__FILE__) . '/';
+ $tpl_dir = $fld_dir . 'tpl/';
+
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
+
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
+
+ $res = '';
+
+ switch ($action)
+ {
+ case 'edit':
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $field_value);
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
+
+ return $AVE_Template->fetch($tpl_file);
+ break;
+
+ case 'doc':
+ $field_value = clean_php($field_value);
+ $field_param = explode('|', $field_value);
+ $field_param[1] = empty($field_param[1]) ? $field_param[0] : $field_param[1];
+
+ if ($tpl_empty)
+ {
+ $field_value = ' ' . $field_param[1] . '';
+ }
+ else
+ {
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $res = $field_value;
+ break;
+
+ case 'req':
+ $field_value = clean_php($field_value);
+ $field_param = explode('|', $field_value);
+
+ if (empty($field_param[1]))
+ $field_param[1] = $field_param[0];
+
+ if (isset($document_fields[$rubric_id]['tpl_req_empty']))
+ {
+ $field_value = " " . $field_param[1] . "";
+ }
+ else
+ {
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $maxlength = null;
+
+ $res = $field_value;
+ break;
+
+ case 'name' :
+ return $AVE_Template->get_config_vars('name');
+ break;
+
+ }
+ return ($res ? $res : $field_value);
}
- return ($res ? $res : $field_value);
-}
?>
\ No newline at end of file
diff --git a/fields/link_multi/css/field.css b/fields/link_multi/css/field.css
new file mode 100644
index 0000000..0a676da
--- /dev/null
+++ b/fields/link_multi/css/field.css
@@ -0,0 +1,18 @@
+.multi_lists {
+ position: relative;
+}
+
+.multi_lists > .ui-state-highlight {
+ display: inline-block;
+ margin: 3px;
+ width: 450px;
+ height: 26px;
+ background-color: rgba(255,255,255,0.5); !important;
+ border: solid 1px #eaeaea;
+ border-radius: 5px;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ position: relative;
+ text-align: center;
+ padding: 0 !important;
+}
\ No newline at end of file
diff --git a/fields/link_multi/field.php b/fields/link_multi/field.php
new file mode 100644
index 0000000..f62c7eb
--- /dev/null
+++ b/fields/link_multi/field.php
@@ -0,0 +1,194 @@
+config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
+
+ $res = array();
+
+ switch ($action)
+ {
+ case 'edit':
+
+ $items = array();
+
+ $items = unserialize($field_value);
+
+ if ($items != false)
+ {
+
+ foreach($items as $k => $v){
+ $list_item = explode('|', $v);
+
+ $list[$k]['param'] = (isset($list_item[0])) ? htmlspecialchars($list_item[0], ENT_QUOTES) : '';
+ $list[$k]['value'] = (isset($list_item[1])) ? htmlspecialchars($list_item[1], ENT_QUOTES) : '';
+ }
+
+ $items = $list;
+ }
+ else
+ {
+ $items = explode(',', $default);
+
+ foreach($items as $k => $v){
+ $list_item = explode('|', $v);
+
+ $list[$k]['param'] = (isset($list_item[0])) ? htmlspecialchars($list_item[0], ENT_QUOTES) : '';
+ $list[$k]['value'] = (isset($list_item[1])) ? htmlspecialchars($list_item[1], ENT_QUOTES) : '';
+ }
+ $items = $list;
+ }
+
+ $AVE_Template->assign('doc_id', $_REQUEST['Id']);
+ $AVE_Template->assign('field_dir', $fld_name);
+ $AVE_Template->assign('items', $items);
+ $AVE_Template->assign('field_id', $field_id);
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
+
+ return $AVE_Template->fetch($tpl_file);
+ break;
+
+ case 'doc':
+ $items = unserialize($field_value);
+
+ if ($items != false)
+ {
+ foreach($items as $list_item)
+ {
+ $list_item = clean_php($list_item);
+ $field_param = explode('|', $list_item);
+
+ if ($list_item)
+ {
+ if ($tpl_empty)
+ {
+ $list_item = $field_param;
+ }
+ else
+ {
+ $list_item = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+ }
+ $res[] = $list_item;
+ }
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('field_count', count($res));
+ $AVE_Template->assign('default', $default);
+
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return (! empty($res)) ? implode(PHP_EOL, $res) : $tpl;
+ break;
+
+ case 'req':
+ $items = unserialize($field_value);
+
+ if ($items != false)
+ {
+ foreach($items as $list_item)
+ {
+ $list_item = clean_php($list_item);
+ $field_param = explode('|', $list_item);
+
+ if ($list_item)
+ {
+ if ($tpl_empty)
+ {
+ $list_item = $field_param;
+ }
+ else
+ {
+ $list_item = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+ }
+ $res[] = $list_item;
+ }
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('field_count', count($res));
+ $AVE_Template->assign('default', $default);
+
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return (!empty($res)) ? implode(PHP_EOL, $res) : $tpl;
+ break;
+
+ case 'save':
+ foreach ($field_value as $v)
+ {
+ if (! empty($v['param']))
+ {
+ $field_value_new[] = $v['param'] . ($v['value'] ? '|' . $v['value'] : '');
+ }
+ }
+
+ if (isset($field_value_new))
+ {
+ return @serialize($field_value_new);
+ }
+ else
+ {
+ return $field_value_new = '';
+ }
+ break;
+
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+ break;
+
+ }
+ return ($res ? $res : $field_value);
+ }
+?>
\ No newline at end of file
diff --git a/fields/multi_list/js/outside.js b/fields/link_multi/js/field.js
similarity index 53%
rename from fields/multi_list/js/outside.js
rename to fields/link_multi/js/field.js
index e67fa2f..050438c 100644
--- a/fields/multi_list/js/outside.js
+++ b/fields/link_multi/js/field.js
@@ -1,4 +1,4 @@
-var MultiList = {
+var MultiLinks = {
init: false,
@@ -23,22 +23,22 @@ var MultiList = {
lists_maxid: function(id) {
var maxid = 1;
- $('#multi_lists_' + id).children('.multi_list').each(function() {
+ $('#multi_links_' + id).children('.multi_link').each(function() {
maxid = Math.max(maxid, parseInt($(this).attr("data-id")) + 1);
});
return maxid;
},
lists_del_item: function() {
- $('.multi_list .DelButton').on('click', function(event) {
+ $('.multi_link .DelButton').on('click', function(event) {
event.preventDefault();
var id = $(this).attr('data-id');
jConfirm(
- list_del_conf,
- list_del_head,
+ links_del_conf,
+ links_del_head,
function(b) {
if (b) {
- $('#list_' + id).remove();
+ $('#link_' + id).remove();
}
}
);
@@ -46,30 +46,29 @@ var MultiList = {
},
lists_add: function() {
- $('.AddButton').on('click', function(event) {
+ $('.multi_links .AddButton').on('click', function(event) {
event.preventDefault();
- c_id = $(this).parent().parent('.multi_lists').attr("data-id");
- iid = MultiList.lists_maxid(c_id);
- $('#multi_lists_' + c_id + ':last').append(
- ' ' +
- ' ×' +
+ c_id = $(this).parent().parent('.multi_links').attr("data-id");
+ iid = MultiLinks.lists_maxid(c_id);
+ $('#multi_links_' + c_id + ':last').append(
+ ' '
);
- MultiList.lists_update();
+ MultiLinks.lists_update();
});
},
lists_sortable: function() {
- $('.multi_lists').sortable({
+ $('.multi_links').sortable({
handle: ".handle",
placeholder: "ui-state-highlight grey_bg"
});
- //$(".multi_lists").disableSelection();
}
}
$(document).ready(function() {
- MultiList.init();
+ MultiLinks.init();
});
\ No newline at end of file
diff --git a/fields/link_multi/lang/ru.txt b/fields/link_multi/lang/ru.txt
new file mode 100644
index 0000000..261b752
--- /dev/null
+++ b/fields/link_multi/lang/ru.txt
@@ -0,0 +1,8 @@
+[admin]
+name = "Мульти ссылки"
+delete = "Удалить элемент"
+param = "Наименование"
+value = "Ссылка"
+del_conf = "Вы уверены, что хотите удалить данный элемент?"
+del_head = "Удаление элемента..."
+add = "Добавить"
\ No newline at end of file
diff --git a/fields/link_multi/tpl/field-doc-181.tpl b/fields/link_multi/tpl/field-doc-181.tpl
new file mode 100644
index 0000000..b72bc47
--- /dev/null
+++ b/fields/link_multi/tpl/field-doc-181.tpl
@@ -0,0 +1,33 @@
+{if ! empty($field_value)}
+
+
+
+
+
+{foreach from=$field_value item=list}
+
+
+ {$list[0]}
+ |
+
+{/foreach}
+
+
+{else}
+
+
+
+
+
+
+
+ Нет файлов для скачивания
+
+ |
+
+
+{/if}
\ No newline at end of file
diff --git a/fields/link_multi/tpl/field-doc.tpl b/fields/link_multi/tpl/field-doc.tpl
new file mode 100644
index 0000000..ef6968b
--- /dev/null
+++ b/fields/link_multi/tpl/field-doc.tpl
@@ -0,0 +1,5 @@
+
+{foreach from=$field_value item=list}
+ - {$list[0]}: {$list[1]}
+{/foreach}
+
\ No newline at end of file
diff --git a/fields/link_multi/tpl/field-req.tpl b/fields/link_multi/tpl/field-req.tpl
new file mode 100644
index 0000000..ef6968b
--- /dev/null
+++ b/fields/link_multi/tpl/field-req.tpl
@@ -0,0 +1,5 @@
+
+{foreach from=$field_value item=list}
+ - {$list[0]}: {$list[1]}
+{/foreach}
+
\ No newline at end of file
diff --git a/fields/link_multi/tpl/field.tpl b/fields/link_multi/tpl/field.tpl
new file mode 100644
index 0000000..d858890
--- /dev/null
+++ b/fields/link_multi/tpl/field.tpl
@@ -0,0 +1,29 @@
+{if $multi_list != load}
+ {assign var=multi_list value='' scope="global"}
+ {if $smarty.request.outside}
+
+ {else}
+
+ {/if}
+
+
+ {assign var=multi_list value="load" scope="global"}
+{/if}
+
+
+{foreach from=$items key=key item=item}
+
+
+ PDF {if $key == 0} +{else} ×{/if}
+
+
+
+{/foreach}
+
\ No newline at end of file
diff --git a/fields/multi_checkbox/field.php b/fields/multi_checkbox/field.php
deleted file mode 100644
index f396ccd..0000000
--- a/fields/multi_checkbox/field.php
+++ /dev/null
@@ -1,163 +0,0 @@
-
-
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2015 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
-
-// Мульти чекбокс
-function get_field_multi_checkbox($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null)
-{
- global $AVE_Template;
-
- $fld_dir = dirname(__FILE__) . '/';
- $tpl_dir = $fld_dir . 'tpl/';
-
- $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
-
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
-
- $res = array();
-
- switch ($action)
- {
- case 'edit':
- $default_items = explode(',', $default);
- $default_items = array_diff($default_items, array(''));
-
- $field_value_array = explode('|', $field_value);
- $field_value_array = array_values(array_diff($field_value_array, array('')));
-
- $AVE_Template->assign('items', $default_items);
- $AVE_Template->assign('used', $field_value_array);
- $AVE_Template->assign('doc_id', (isset($_REQUEST['Id']) ? (int)$_REQUEST['Id'] : 0));
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $field_value);
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
-
- return $AVE_Template->fetch($tpl_file);
- break;
-
- case 'doc':
- $default_items = explode(',', $default);
-
- $items = explode('|', $field_value);
- $items = array_diff($items, array(''));
-
- if (! empty($items))
- {
- foreach($items as $item)
- {
- if ($item)
- {
- if ($tpl_empty)
- {
- $item = $default_items[(int)$item-1];
- }
- else
- {
- $field_param = explode('|', $item);
-
- $item = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param, $default_items)
- {
- return $default_items[$field_param[(int)$data[1]]-1];
- },
- $tpl
- );
- }
- }
-
- $res[] = $item;
- }
- }
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
-
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('rubric_id', $rubric_id);
- $AVE_Template->assign('default', $default_items);
-
- return $AVE_Template->fetch($tpl_file);
- }
-
- return (! empty($res))
- ? implode(PHP_EOL, $res)
- : $tpl;
-
- break;
-
- case 'req':
- $default_items = explode(',', $default);
-
- $items = explode('|', $field_value);
- $items = array_diff($items, array(''));
-
- if (! empty($items))
- {
- foreach($items as $item)
- {
- if ($item)
- {
- if ($tpl_empty)
- {
- $item = $default_items[(int)$item-1];
- }
- else
- {
- $field_param = explode('|', $item);
-
- $item = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param, $default_items)
- {
- return $default_items[$field_param[(int)$data[1]]-1];
- },
- $tpl
- );
- }
- }
-
- $res[] = $item;
- }
- }
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
-
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('rubric_id', $rubric_id);
- $AVE_Template->assign('default', $default_items);
-
- return $AVE_Template->fetch($tpl_file);
- }
-
- return (! empty($res))
- ? implode(PHP_EOL, $res)
- : $tpl;
-
- break;
-
- case 'name':
- return $AVE_Template->get_config_vars('name');
- break;
-
- }
- return ($res ? $res : $field_value);
-}
-?>
\ No newline at end of file
diff --git a/fields/multi_line/field.php b/fields/multi_line/field.php
index bc47f0f..eadd249 100644
--- a/fields/multi_line/field.php
+++ b/fields/multi_line/field.php
@@ -1,89 +1,77 @@
-
+config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP')
+ ? $_SESSION['admin_language']
+ : $_SESSION['user_language']) . '.txt';
- $res=0;
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
- switch ($action)
- {
- case 'edit':
- if (isset($_COOKIE['no_wysiwyg']) && $_COOKIE['no_wysiwyg'] == 1)
- {
- $field = ' ';
- $field .= ' ';
- }
- else
- {
- if (isset($_REQUEST['outside']) && ($_REQUEST['outside'] === (bool)true)) {
- switch ($_SESSION['use_editor']) {
- case '0':
- case '1':
- case '2':
- $oCKeditor = new CKeditor();
- $oCKeditor->returnOutput = true;
- $oCKeditor->config['toolbar'] = 'Verysmall';
- $oCKeditor->config['height'] = 250;
- $config = array();
- $field = $oCKeditor->editor('data['.$_REQUEST['Id'].'][feld][' . $field_id . ']', $field_value, $config);
- break;
+ $res = null;
- default:
- $field = $field_value;
- break;
+ switch ($action)
+ {
+ case 'edit':
+ if (isset($_COOKIE['no_wysiwyg']) && $_COOKIE['no_wysiwyg'] == 1)
+ {
+ $field = ' ';
+ $field .= ' ';
+ }
+ else
+ {
+ if (isset($_REQUEST['outside']) && ($_REQUEST['outside'] === true))
+ {
+ $oCKeditor = new CKeditor();
+ $oCKeditor->returnOutput = true;
+ $oCKeditor->config['toolbar'] = 'Verysmall';
+ $oCKeditor->config['height'] = 250;
+ $config = array();
+ $field = $oCKeditor->editor('data['.$_REQUEST['Id'].'][feld][' . $field_id . ']', $field_value, $config);
}
- } else {
- switch ($_SESSION['use_editor']) {
- case '0': // CKEditor
- case '1':
- $oCKeditor = new CKeditor();
- $oCKeditor->returnOutput = true;
- $oCKeditor->config['toolbar'] = 'Big';
- $oCKeditor->config['height'] = 400;
- $config = array();
- $field = $oCKeditor->editor('feld[' . $field_id . ']', $field_value, $config);
- break;
-
- default:
- $field = $field_value;
- break;
+ else
+ {
+ $oCKeditor = new CKeditor();
+ $oCKeditor->returnOutput = true;
+ $oCKeditor->config['toolbar'] = 'Big';
+ $oCKeditor->config['height'] = 400;
+ $config = array();
+ $field = $oCKeditor->editor('feld[' . $field_id . ']', $field_value, $config);
}
}
- }
- $res = $field;
- break;
- case 'doc':
- case 'req':
- $res = get_field_default($field_value, $action, $field_id, $tpl, $tpl_empty, $maxlength, $document_fields, $rubric_id);
- $res = document_pagination($res);
- break;
+ $res = $field;
+ break;
+
+ case 'doc':
+ case 'req':
+ $res = get_field_default($field_value, $action, $field_id, $tpl, $tpl_empty, $maxlength, $document_fields, $rubric_id);
+ $res = document_pagination($res);
+ break;
+
+ case 'name' :
+ return $AVE_Template->get_config_vars('name');
+ break;
+ }
- case 'name' :
- return $AVE_Template->get_config_vars('name');
- break;
+ return ($res ? $res : $field_value);
}
- return ($res ? $res : $field_value);
-}
-?>
+?>
\ No newline at end of file
diff --git a/fields/multi_line_simple/field.php b/fields/multi_line_simple/field.php
index 9010bc6..f6b2990 100644
--- a/fields/multi_line_simple/field.php
+++ b/fields/multi_line_simple/field.php
@@ -1,91 +1,74 @@
-
+config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
- $res=0;
+ $res=0;
- switch ($action)
- {
- case 'edit':
- if (isset($_COOKIE['no_wysiwyg']) && $_COOKIE['no_wysiwyg'] == 1)
- {
- $field = " ";
- $field .= " ";
- }
- else
- {
- if (isset($_REQUEST['outside']) && ($_REQUEST['outside'] === (bool)true)) {
- switch ($_SESSION['use_editor'])
+ switch ($action)
+ {
+ case 'edit':
+ if (isset($_COOKIE['no_wysiwyg']) && $_COOKIE['no_wysiwyg'] == 1)
+ {
+ $field = ' ';
+ $field .= ' ';
+ }
+ else
+ {
+ if (isset($_REQUEST['outside']) && ($_REQUEST['outside'] === true))
{
- case '0':
- case '1':
- case '2':
- $oCKeditor = new CKeditor();
- $oCKeditor->returnOutput = true;
- $oCKeditor->config['toolbar'] = 'Verysmall';
- $oCKeditor->config['height'] = 200;
- $config = array();
- $field = $oCKeditor->editor('data['.$_REQUEST['Id'].'][feld][' . $field_id . ']', $field_value, $config);
- break;
-
- default:
- $field = $field_value;
- break;
+ $oCKeditor = new CKeditor();
+ $oCKeditor->returnOutput = true;
+ $oCKeditor->config['toolbar'] = 'Verysmall';
+ $oCKeditor->config['height'] = 250;
+ $config = array();
+ $field = $oCKeditor->editor('data['.$_REQUEST['Id'].'][feld][' . $field_id . ']', $field_value, $config);
}
- } else {
- switch ($_SESSION['use_editor']) {
- case '0': // CKEditor
- case '1':
- $oCKeditor = new CKeditor();
- $oCKeditor->returnOutput = true;
- $oCKeditor->config['toolbar'] = 'Small';
- $oCKeditor->config['height'] = 300;
- $config = array();
- $field = $oCKeditor->editor('feld[' . $field_id . ']', $field_value, $config);
- break;
-
- default:
- $field = $field_value;
- break;
+ else
+ {
+ $oCKeditor = new CKeditor();
+ $oCKeditor->returnOutput = true;
+ $oCKeditor->config['toolbar'] = 'Small';
+ $oCKeditor->config['height'] = 300;
+ $config = array();
+ $field = $oCKeditor->editor('feld[' . $field_id . ']', $field_value, $config);
}
}
- }
- $res = $field;
- break;
+ $res = $field;
+ break;
- case 'doc':
- case 'req':
- $res = get_field_default($field_value,$action,$field_id,$tpl,$tpl_empty,$maxlength,$document_fields,$rubric_id);
- $res = document_pagination($res);
- break;
+ case 'doc':
+ case 'req':
+ $res = get_field_default($field_value,$action,$field_id,$tpl,$tpl_empty,$maxlength,$document_fields,$rubric_id);
+ $res = document_pagination($res);
+ break;
- case 'name' :
- return $AVE_Template->get_config_vars('name');
- break;
+ case 'name' :
+ return $AVE_Template->get_config_vars('name');
+ break;
+ }
+ return ($res ? $res : $field_value);
}
- return ($res ? $res : $field_value);
-}
-?>
+?>
\ No newline at end of file
diff --git a/fields/multi_line_slim/field.php b/fields/multi_line_slim/field.php
index 5170c43..f9b3695 100644
--- a/fields/multi_line_slim/field.php
+++ b/fields/multi_line_slim/field.php
@@ -1,91 +1,75 @@
-
+config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
- $res=0;
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
- switch ($action)
- {
- case 'edit':
- if (isset($_COOKIE['no_wysiwyg']) && $_COOKIE['no_wysiwyg'] == 1)
- {
- $field = " ";
- $field .= " ";
- }
- else
- {
- if (isset($_REQUEST['outside']) && ($_REQUEST['outside'] === (bool)true)) {
- switch ($_SESSION['use_editor']) {
- case '0':
- case '1':
- case '2':
- $oCKeditor = new CKeditor();
- $oCKeditor->returnOutput = true;
- $oCKeditor->config['toolbar'] = 'Verysmall';
- $oCKeditor->config['height'] = 200;
- $config = array();
- $field = $oCKeditor->editor('data['.$_REQUEST['Id'].'][feld][' . $field_id . ']', $field_value, $config);
- break;
+ $res = 0;
- default:
- $field = $field_value;
- break;
+ switch ($action)
+ {
+ case 'edit':
+ if (isset($_COOKIE['no_wysiwyg']) && $_COOKIE['no_wysiwyg'] == 1)
+ {
+ $field = ' ';
+ $field .= ' ';
+ }
+ else
+ {
+ if (isset($_REQUEST['outside']) && ($_REQUEST['outside'] === true))
+ {
+ $oCKeditor = new CKeditor();
+ $oCKeditor->returnOutput = true;
+ $oCKeditor->config['toolbar'] = 'Verysmall';
+ $oCKeditor->config['height'] = 250;
+ $config = array();
+ $field = $oCKeditor->editor('data['.$_REQUEST['Id'].'][feld][' . $field_id . ']', $field_value, $config);
}
- } else {
- switch ($_SESSION['use_editor']) {
- case '0': // CKEditor
- case '1':
- $oCKeditor = new CKeditor();
- $oCKeditor->returnOutput = true;
- $oCKeditor->config['toolbar'] = 'Verysmall';
- $oCKeditor->config['height'] = 200;
- $config = array();
- $field = $oCKeditor->editor('feld[' . $field_id . ']', $field_value, $config);
- break;
-
- default:
- $field = $field_value;
- break;
+ else
+ {
+ $oCKeditor = new CKeditor();
+ $oCKeditor->returnOutput = true;
+ $oCKeditor->config['toolbar'] = 'Verysmall';
+ $oCKeditor->config['height'] = 200;
+ $config = array();
+ $field = $oCKeditor->editor('feld[' . $field_id . ']', $field_value, $config);
}
}
- }
- $res = $field;
- break;
+ $res = $field;
+ break;
- case 'doc':
- case 'req':
- $res = get_field_default($field_value,$action,$field_id,$tpl,$tpl_empty,$maxlength,$document_fields,$rubric_id);
- $res = document_pagination($res);
- break;
+ case 'doc':
+ case 'req':
+ $res = get_field_default($field_value,$action,$field_id,$tpl,$tpl_empty,$maxlength,$document_fields,$rubric_id);
+ $res = document_pagination($res);
+ break;
- case 'name' :
- return $AVE_Template->get_config_vars('name');
- break;
- }
- return ($res ? $res : $field_value);
+ case 'name' :
+ return $AVE_Template->get_config_vars('name');
+ break;
+ }
+ return ($res ? $res : $field_value);
-}
-?>
+ }
+?>
\ No newline at end of file
diff --git a/fields/multi_list/field.php b/fields/multi_list/field.php
index 2d1e750..6d8442e 100644
--- a/fields/multi_list/field.php
+++ b/fields/multi_list/field.php
@@ -1,194 +1,194 @@
-
-
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
-
-// Мульти лист
-function get_field_multi_list($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null){
+config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
+ $res = array();
- $res = array();
+ switch ($action)
+ {
+ case 'edit':
- switch ($action)
- {
- case 'edit':
+ $items = array();
- $items = array();
+ $items = unserialize($field_value);
- $items = unserialize($field_value);
+ if ($items != false)
+ {
- if ($items != false)
- {
+ foreach($items as $k => $v){
+ $list_item = explode('|', $v);
- foreach($items as $k => $v){
- $list_item = explode('|', $v);
+ $list[$k]['param'] = (isset($list_item[0])) ? htmlspecialchars($list_item[0], ENT_QUOTES) : '';
+ $list[$k]['value'] = (isset($list_item[1])) ? htmlspecialchars($list_item[1], ENT_QUOTES) : '';
+ }
- $list[$k]['param'] = (isset($list_item[0])) ? htmlspecialchars($list_item[0], ENT_QUOTES) : '';
- $list[$k]['value'] = (isset($list_item[1])) ? htmlspecialchars($list_item[1], ENT_QUOTES) : '';
+ $items = $list;
}
+ else
+ {
+ $items = explode(',', $default);
- $items = $list;
- }
- else
- {
- $items = explode(',', $default);
-
- foreach($items as $k => $v){
- $list_item = explode('|', $v);
+ foreach($items as $k => $v){
+ $list_item = explode('|', $v);
- $list[$k]['param'] = (isset($list_item[0])) ? htmlspecialchars($list_item[0], ENT_QUOTES) : '';
- $list[$k]['value'] = (isset($list_item[1])) ? htmlspecialchars($list_item[1], ENT_QUOTES) : '';
+ $list[$k]['param'] = (isset($list_item[0])) ? htmlspecialchars($list_item[0], ENT_QUOTES) : '';
+ $list[$k]['value'] = (isset($list_item[1])) ? htmlspecialchars($list_item[1], ENT_QUOTES) : '';
+ }
+ $items = $list;
}
- $items = $list;
- }
- $AVE_Template->assign('doc_id', $_REQUEST['Id']);
- $AVE_Template->assign('field_dir', $fld_name);
- $AVE_Template->assign('items', $items);
- $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('doc_id', $_REQUEST['Id']);
+ $AVE_Template->assign('field_dir', $fld_name);
+ $AVE_Template->assign('items', $items);
+ $AVE_Template->assign('field_id', $field_id);
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
- return $AVE_Template->fetch($tpl_file);
- break;
+ return $AVE_Template->fetch($tpl_file);
+ break;
- case 'doc':
- $items = unserialize($field_value);
+ case 'doc':
+ $items = unserialize($field_value);
- if ($items != false)
- {
- foreach($items as $list_item)
+ if ($items != false)
{
- $list_item = clean_php($list_item);
- $field_param = explode('|', $list_item);
-
- if ($list_item)
+ foreach($items as $list_item)
{
- if ($tpl_empty)
- {
- $list_item = $field_param;
- }
- else
+ $list_item = clean_php($list_item);
+ $field_param = explode('|', $list_item);
+
+ if ($list_item)
{
- $list_item = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
+ if ($tpl_empty)
+ {
+ $list_item = $field_param;
+ }
+ else
+ {
+ $list_item = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
}
+ $res[] = $list_item;
}
- $res[] = $list_item;
}
- }
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('field_count', count($res));
- $AVE_Template->assign('default', $default);
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('field_count', count($res));
+ $AVE_Template->assign('default', $default);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- return (! empty($res)) ? implode(PHP_EOL, $res) : $tpl;
- break;
+ return (! empty($res)) ? implode(PHP_EOL, $res) : $tpl;
+ break;
- case 'req':
- $items = unserialize($field_value);
+ case 'req':
+ $items = unserialize($field_value);
- if ($items != false)
- {
- foreach($items as $list_item)
+ if ($items != false)
{
- $list_item = clean_php($list_item);
- $field_param = explode('|', $list_item);
-
- if ($list_item)
+ foreach($items as $list_item)
{
- if ($tpl_empty)
- {
- $list_item = $field_param;
- }
- else
+ $list_item = clean_php($list_item);
+ $field_param = explode('|', $list_item);
+
+ if ($list_item)
{
- $list_item = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
+ if ($tpl_empty)
+ {
+ $list_item = $field_param;
+ }
+ else
+ {
+ $list_item = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
}
+ $res[] = $list_item;
}
- $res[] = $list_item;
}
- }
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('field_count', count($res));
- $AVE_Template->assign('default', $default);
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('field_count', count($res));
+ $AVE_Template->assign('default', $default);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- return (!empty($res)) ? implode(PHP_EOL, $res) : $tpl;
- break;
+ return (!empty($res)) ? implode(PHP_EOL, $res) : $tpl;
+ break;
- case 'save':
- foreach ($field_value as $v)
- {
- if(! empty($v['param']))
+ case 'save':
+ foreach ($field_value as $v)
{
- $field_value_new[] = $v['param'] . ($v['value'] ? '|' . $v['value'] : '');
+ if(! empty($v['param']))
+ {
+ $field_value_new[] = $v['param'] . ($v['value'] ? '|' . $v['value'] : '');
+ }
}
- }
- if (isset($field_value_new))
- {
- return @serialize($field_value_new);
- }
- else
+ if (isset($field_value_new))
{
- return $field_value_new = '';
+ return @serialize($field_value_new);
}
- break;
+ else
+ {
+ return $field_value_new = '';
+ }
+ break;
- case 'name':
- return $AVE_Template->get_config_vars('name');
- break;
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+ break;
+ }
+ return ($res ? $res : $field_value);
}
- return ($res ? $res : $field_value);
-}
?>
\ No newline at end of file
diff --git a/fields/multi_list_single/field.php b/fields/multi_list_single/field.php
index c76277e..0718e76 100644
--- a/fields/multi_list_single/field.php
+++ b/fields/multi_list_single/field.php
@@ -1,177 +1,177 @@
-
-
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
- *
- */
-
-// Мульти лист
-function get_field_multi_list_single($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null){
-
- global $AVE_Template;
+config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
- $res = array();
+ $res = array();
- switch ($action)
- {
- case 'edit':
+ switch ($action)
+ {
+ case 'edit':
- $items = array();
+ $items = array();
- $items = unserialize($field_value);
+ $items = unserialize($field_value);
- if ($items != false)
- {
- $items = $items;
- }
- else
+ if ($items != false)
{
- $items = explode(',', $default);
+ $items = $items;
}
+ else
+ {
+ $items = explode(',', $default);
+ }
- $AVE_Template->assign('doc_id', $_REQUEST['Id']);
- $AVE_Template->assign('field_dir', $fld_name);
- $AVE_Template->assign('items', $items);
- $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('doc_id', $_REQUEST['Id']);
+ $AVE_Template->assign('field_dir', $fld_name);
+ $AVE_Template->assign('items', $items);
+ $AVE_Template->assign('field_id', $field_id);
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
- return $AVE_Template->fetch($tpl_file);
- break;
+ return $AVE_Template->fetch($tpl_file);
+ break;
- case 'doc':
- $items = unserialize($field_value);
+ case 'doc':
+ $items = unserialize($field_value);
- if ($items != false)
- {
- foreach($items as $list_item)
+ if ($items != false)
{
- $list_item = clean_php($list_item);
- $field_param = explode('|', $list_item);
-
- if ($list_item)
+ foreach($items as $list_item)
{
- if ($tpl_empty)
- {
- $list_item = $field_param;
- }
- else
+ $list_item = clean_php($list_item);
+ $field_param = explode('|', $list_item);
+
+ if ($list_item)
{
- $list_item = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
+ if ($tpl_empty)
+ {
+ $list_item = $field_param;
+ }
+ else
+ {
+ $list_item = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
}
+ $res[] = $list_item;
}
- $res[] = $list_item;
}
- }
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('field_count', count($res));
- $AVE_Template->assign('default', $default);
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('field_count', count($res));
+ $AVE_Template->assign('default', $default);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- return (! empty($res)) ? implode(PHP_EOL, $res) : $tpl;
- break;
+ return (! empty($res)) ? implode(PHP_EOL, $res) : $tpl;
+ break;
- case 'req':
- $items = unserialize($field_value);
+ case 'req':
+ $items = unserialize($field_value);
- if ($items != false)
- {
- foreach($items as $list_item)
+ if ($items != false)
{
- $list_item = clean_php($list_item);
- $field_param = explode('|', $list_item);
-
- if ($list_item)
+ foreach($items as $list_item)
{
- if ($tpl_empty)
- {
- $list_item = $field_param;
- }
- else
+ $list_item = clean_php($list_item);
+ $field_param = explode('|', $list_item);
+
+ if ($list_item)
{
- $list_item = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
+ if ($tpl_empty)
+ {
+ $list_item = $field_param;
+ }
+ else
+ {
+ $list_item = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
}
+ $res[] = $list_item;
}
- $res[] = $list_item;
}
- }
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('field_count', count($res));
- $AVE_Template->assign('default', $default);
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('field_count', count($res));
+ $AVE_Template->assign('default', $default);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- return (! empty($res)) ? implode(PHP_EOL, $res) : $tpl;
- break;
+ return (! empty($res)) ? implode(PHP_EOL, $res) : $tpl;
+ break;
- case 'save':
- foreach ($field_value as $v)
- {
- if (! empty($v))
+ case 'save':
+ foreach ($field_value as $v)
{
- $field_value_new[] = $v;
+ if (! empty($v))
+ {
+ $field_value_new[] = $v;
+ }
}
- }
- if (isset($field_value_new))
- {
- return @serialize($field_value_new);
- }
- else
+ if (isset($field_value_new))
{
- return $field_value_new = '';
+ return @serialize($field_value_new);
}
- break;
+ else
+ {
+ return $field_value_new = '';
+ }
+ break;
- case 'name':
- return $AVE_Template->get_config_vars('name');
- break;
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+ break;
+ }
+ return ($res ? $res : $field_value);
}
- return ($res ? $res : $field_value);
-}
?>
\ No newline at end of file
diff --git a/fields/multi_list_single/js/outside.js b/fields/multi_list_single/js/outside.js
deleted file mode 100644
index d977cfe..0000000
--- a/fields/multi_list_single/js/outside.js
+++ /dev/null
@@ -1,75 +0,0 @@
-var MultiListSingle = {
-
- init: false,
-
- init: function() {
- if (this.initialized) return;
- this.initialized = true;
-
- this.s_lists();
- },
-
- s_lists: function() {
- this.s_lists_sortable();
- this.s_lists_del_item();
- this.s_lists_add();
- },
-
- s_lists_update: function() {
- this.s_lists_maxid();
- this.s_lists_del_item();
- AveAdmin.tooltip();
- },
-
- s_lists_maxid: function(id) {
- var maxid = 1;
- $('#multi_lists_single_' + id).children('.multi_list_single').each(function() {
- maxid = Math.max(maxid, parseInt($(this).attr("data-id")) + 1);
- });
- return maxid;
- },
-
- s_lists_del_item: function() {
- $('.multi_list_single .DelSingleButton').on('click', function(event) {
- event.preventDefault();
- var id = $(this).attr('data-id');
- jConfirm(
- s_list_del_conf,
- s_list_del_head,
- function(b) {
- if (b) {
- $('#list_' + id).remove();
- }
- }
- );
- });
- },
-
- s_lists_add: function() {
- $('.AddSingleButton').on('click', function(event) {
- event.preventDefault();
- c_id = $(this).parent().parent('.multi_lists_single').attr("data-id");
- iid = MultiListSingle.s_lists_maxid(c_id);
- $('#multi_lists_single_' + c_id + ':last').append(
- ' '
- );
-
- MultiListSingle.s_lists_update();
- });
- },
-
- s_lists_sortable: function() {
- $('.multi_lists_single').sortable({
- handle: ".handle",
- placeholder: "ui-state-highlight grey_bg"
- });
- //$(".multi_lists_single").disableSelection();
- }
-}
-
-$(document).ready(function() {
- MultiListSingle.init();
-});
\ No newline at end of file
diff --git a/fields/multi_list_triple/field.php b/fields/multi_list_triple/field.php
index 138e855..5502b05 100644
--- a/fields/multi_list_triple/field.php
+++ b/fields/multi_list_triple/field.php
@@ -1,200 +1,199 @@
-
-
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
+config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
- $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
+ $res = array();
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
+ switch ($action)
+ {
+ case 'edit':
- $res = array();
+ $items = array();
- switch ($action)
- {
- case 'edit':
+ $items = unserialize($field_value);
- $items = array();
-
- $items = unserialize($field_value);
+ if ($items != false)
+ {
- if ($items != false)
- {
+ foreach($items as $k => $v)
+ {
+ $list_item = explode('|', $v);
- foreach($items as $k => $v)
- {
- $list_item = explode('|', $v);
+ $list[$k]['param'] = (isset($list_item[0])) ? htmlspecialchars($list_item[0], ENT_QUOTES) : '';
+ $list[$k]['value'] = (isset($list_item[1])) ? htmlspecialchars($list_item[1], ENT_QUOTES) : '';
+ $list[$k]['value2'] = (isset($list_item[2])) ? htmlspecialchars($list_item[2], ENT_QUOTES) : '';
+ }
- $list[$k]['param'] = (isset($list_item[0])) ? htmlspecialchars($list_item[0], ENT_QUOTES) : '';
- $list[$k]['value'] = (isset($list_item[1])) ? htmlspecialchars($list_item[1], ENT_QUOTES) : '';
- $list[$k]['value2'] = (isset($list_item[2])) ? htmlspecialchars($list_item[2], ENT_QUOTES) : '';
+ $items = $list;
}
+ else
+ {
- $items = $list;
- }
- else
- {
+ $items = explode(',', $default);
- $items = explode(',', $default);
+ foreach ($items as $k => $v)
+ {
+ $list_item = explode('|', $v);
- foreach ($items as $k => $v)
- {
- $list_item = explode('|', $v);
+ $list[$k]['param'] = (isset($list_item[0])) ? htmlspecialchars($list_item[0], ENT_QUOTES) : '';
+ $list[$k]['value'] = (isset($list_item[1])) ? htmlspecialchars($list_item[1], ENT_QUOTES) : '';
+ $list[$k]['value2'] = (isset($list_item[2])) ? htmlspecialchars($list_item[2], ENT_QUOTES) : '';
+ }
- $list[$k]['param'] = (isset($list_item[0])) ? htmlspecialchars($list_item[0], ENT_QUOTES) : '';
- $list[$k]['value'] = (isset($list_item[1])) ? htmlspecialchars($list_item[1], ENT_QUOTES) : '';
- $list[$k]['value2'] = (isset($list_item[2])) ? htmlspecialchars($list_item[2], ENT_QUOTES) : '';
+ $items = $list;
}
- $items = $list;
- }
-
- $AVE_Template->assign('doc_id', $_REQUEST['Id']);
- $AVE_Template->assign('field_dir', $fld_name);
- $AVE_Template->assign('items', $items);
- $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('doc_id', $_REQUEST['Id']);
+ $AVE_Template->assign('field_dir', $fld_name);
+ $AVE_Template->assign('items', $items);
+ $AVE_Template->assign('field_id', $field_id);
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
- return $AVE_Template->fetch($tpl_file);
- break;
+ return $AVE_Template->fetch($tpl_file);
+ break;
- case 'doc':
- $items = unserialize($field_value);
+ case 'doc':
+ $items = unserialize($field_value);
- if ($items != false)
- {
- foreach ($items as $list_item)
+ if ($items != false)
{
- $list_item = clean_php($list_item);
- $field_param = explode('|', $list_item);
-
- if ($list_item)
+ foreach ($items as $list_item)
{
- if ($tpl_empty)
- {
- $list_item = $field_param;
- }
- else
+ $list_item = clean_php($list_item);
+ $field_param = explode('|', $list_item);
+
+ if ($list_item)
{
- $list_item = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
+ if ($tpl_empty)
+ {
+ $list_item = $field_param;
+ }
+ else
+ {
+ $list_item = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
}
+ $res[] = $list_item;
}
- $res[] = $list_item;
}
- }
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
- if($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('field_count', count($res));
- $AVE_Template->assign('default', $default);
+ if($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('field_count', count($res));
+ $AVE_Template->assign('default', $default);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- return (!empty($res)) ? implode(PHP_EOL, $res) : $tpl;
- break;
+ return (!empty($res)) ? implode(PHP_EOL, $res) : $tpl;
+ break;
- case 'req':
- $items = unserialize($field_value);
+ case 'req':
+ $items = unserialize($field_value);
- if ($items != false)
- {
- foreach ($items as $list_item)
+ if ($items != false)
{
- $list_item = clean_php($list_item);
- $field_param = explode('|', $list_item);
-
- if ($list_item)
+ foreach ($items as $list_item)
{
- if ($tpl_empty)
- {
- $list_item = $field_param;
- }
- else
+ $list_item = clean_php($list_item);
+ $field_param = explode('|', $list_item);
+
+ if ($list_item)
{
- $list_item = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
+ if ($tpl_empty)
+ {
+ $list_item = $field_param;
+ }
+ else
+ {
+ $list_item = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
}
+ $res[] = $list_item;
}
- $res[] = $list_item;
}
- }
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('field_count', count($res));
- $AVE_Template->assign('default', $default);
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('field_count', count($res));
+ $AVE_Template->assign('default', $default);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- return (!empty($res)) ? implode(PHP_EOL, $res) : $tpl;
- break;
+ return (!empty($res)) ? implode(PHP_EOL, $res) : $tpl;
+ break;
- case 'save':
- foreach ($field_value as $v)
- {
- if(!empty($v['param']))
+ case 'save':
+ foreach ($field_value as $v)
{
- $field_value_new[] = $v['param'] . '|' . $v['value'] . '|' . $v['value2'];
+ if(!empty($v['param']))
+ {
+ $field_value_new[] = $v['param'] . '|' . $v['value'] . '|' . $v['value2'];
+ }
}
- }
- if (isset($field_value_new))
- {
- return @serialize($field_value_new);
- }
- else
+ if (isset($field_value_new))
{
- return $field_value_new = '';
+ return @serialize($field_value_new);
}
- break;
+ else
+ {
+ return $field_value_new = '';
+ }
+ break;
- case 'name':
- return $AVE_Template->get_config_vars('name');
- break;
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+ break;
+ }
+ return ($res ? $res : $field_value);
}
- return ($res ? $res : $field_value);
-}
?>
\ No newline at end of file
diff --git a/fields/multi_list_triple/js/outside.js b/fields/multi_list_triple/js/outside.js
deleted file mode 100644
index e4d5ca8..0000000
--- a/fields/multi_list_triple/js/outside.js
+++ /dev/null
@@ -1,75 +0,0 @@
-var MultiListTriple = {
-
- init: false,
-
- init: function() {
- if (this.initialized) return;
- this.initialized = true;
-
- this.lists();
- },
-
- lists: function() {
- this.lists_sortable();
- this.lists_del_item();
- this.lists_add();
- },
-
- lists_update: function() {
- this.lists_maxid();
- this.lists_del_item();
- AveAdmin.tooltip();
- },
-
- lists_maxid: function(id) {
- var maxid = 1;
- $('#multi_lists_triple_' + id).children('.multi_list_triple').each(function() {
- maxid = Math.max(maxid, parseInt($(this).attr("data-id")) + 1);
- });
- return maxid;
- },
-
- lists_del_item: function() {
- $('.multi_list_triple .DelButton').on('click', function(event) {
- event.preventDefault();
- var id = $(this).attr('data-id');
- jConfirm(
- list_del_conf,
- list_del_head,
- function(b) {
- if (b) {
- $('#list_' + id).remove();
- }
- }
- );
- });
- },
-
- lists_add: function() {
- $('.AddButton').on('click', function(event) {
- event.preventDefault();
- c_id = $(this).parent().parent('.multi_lists_triple').attr("data-id");
- iid = MultiListTriple.lists_maxid(c_id);
- $('#multi_lists_triple_' + c_id + ':last').append(
- ' '
- );
-
- MultiListTriple.lists_update();
- });
- },
-
- lists_sortable: function() {
- $('.multi_lists_triple').sortable({
- handle: ".handle",
- placeholder: "ui-state-highlight grey_bg"
- });
- //$(".multi_lists_triple").disableSelection();
- }
-}
-
-$(document).ready(function() {
- MultiListTriple.init();
-});
\ No newline at end of file
diff --git a/fields/multi_select/field.php b/fields/multi_select/field.php
index a999467..d877d66 100644
--- a/fields/multi_select/field.php
+++ b/fields/multi_select/field.php
@@ -1,159 +1,159 @@
-
-
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
-
-// Мульти список
-function get_field_multi_select($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null)
-{
- global $AVE_Template;
+config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
- $res = array();
+ $res = array();
- switch ($action)
- {
- case 'edit':
- $items = array();
+ switch ($action)
+ {
+ case 'edit':
+ $items = array();
- $items = explode(',', $default);
+ $items = explode(',', $default);
- $items = array_diff($items, array(''));
+ $items = array_diff($items, array(''));
- @$field_value = unserialize($field_value);
+ @$field_value = unserialize($field_value);
- $AVE_Template->assign('items', $items);
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $field_value);
+ $AVE_Template->assign('items', $items);
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $field_value);
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
- return $AVE_Template->fetch($tpl_file);
- break;
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
+ return $AVE_Template->fetch($tpl_file);
+ break;
- case 'doc':
- $items = (isset($field_value))
- ? unserialize($field_value)
- : array();
+ case 'doc':
+ $items = (isset($field_value))
+ ? unserialize($field_value)
+ : array();
- if ($items != false)
- {
- foreach($items as $item)
+ if ($items != false)
{
- $item = clean_php($item);
+ foreach($items as $item)
+ {
+ $item = clean_php($item);
- $field_param = explode('|', $item);
+ $field_param = explode('|', $item);
- if ($item)
- {
- if ($tpl_empty)
- {
- $item = $field_param[0];
- }
- else
+ if ($item)
{
- $item = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
+ if ($tpl_empty)
+ {
+ $item = $field_param[0];
+ }
+ else
+ {
+ $item = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
}
+ $res[] = $item;
}
- $res[] = $item;
}
- }
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
- if ($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('rubric_id', $rubric_id);
- $AVE_Template->assign('default', $default);
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('rubric_id', $rubric_id);
+ $AVE_Template->assign('default', $default);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- return (! empty($res))
- ? implode(PHP_EOL, $res)
- : $tpl;
+ return (! empty($res))
+ ? implode(PHP_EOL, $res)
+ : $tpl;
- break;
+ break;
- case 'req':
- $items = (isset($field_value)) ? unserialize($field_value) : array();
+ case 'req':
+ $items = (isset($field_value)) ? unserialize($field_value) : array();
- if ($items != false)
- {
- foreach($items as $item)
+ if ($items != false)
{
- $item = clean_php($item);
+ foreach($items as $item)
+ {
+ $item = clean_php($item);
- $field_param = explode('|', $item);
+ $field_param = explode('|', $item);
- if ($item)
- {
- if ($tpl_empty)
- {
- $item = $field_param[0];
- }
- else
+ if ($item)
{
- $item = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
+ if ($tpl_empty)
+ {
+ $item = $field_param[0];
+ }
+ else
+ {
+ $item = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
}
+ $res[] = $item;
}
- $res[] = $item;
}
- }
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
- if($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $res);
- $AVE_Template->assign('rubric_id', $rubric_id);
- $AVE_Template->assign('default', $default);
+ if($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $res);
+ $AVE_Template->assign('rubric_id', $rubric_id);
+ $AVE_Template->assign('default', $default);
- return $AVE_Template->fetch($tpl_file);
- }
+ return $AVE_Template->fetch($tpl_file);
+ }
- return (!empty($res)) ? implode(PHP_EOL, $res) : $tpl;
- break;
+ return (!empty($res)) ? implode(PHP_EOL, $res) : $tpl;
+ break;
- case 'name':
- return $AVE_Template->get_config_vars('name');
- break;
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+ break;
- }
+ }
- return ($res ? $res : $field_value);
-}
+ return ($res ? $res : $field_value);
+ }
?>
\ No newline at end of file
diff --git a/fields/single_line/field.php b/fields/single_line/field.php
index facabad..e9ef91d 100644
--- a/fields/single_line/field.php
+++ b/fields/single_line/field.php
@@ -1,115 +1,123 @@
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
-
-// Однострочное
-function get_field_single_line ($field_value, $action, $field_id = 0, $tpl = '', $tpl_empty = 0, &$maxlength = null, $document_fields = array(), $rubric_id = 0, $default = null)
-{
- global $AVE_Template;
-
- $fld_dir = dirname(__FILE__) . '/';
- $tpl_dir = $fld_dir . 'tpl/';
- $fld_name = basename($fld_dir);
-
- $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
-
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
-
- switch ($action)
+ /**
+ * AVE.cms
+ *
+ * @package AVE.cms
+ * @version 3.x
+ * @filesource
+ * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
+ *
+ * @license GPL v.2
+ */
+
+ // Однострочное
+ function get_field_single_line ($field_value, $action, $field_id = 0, $tpl = '', $tpl_empty = 0, &$maxlength = null, $document_fields = array(), $rubric_id = 0, $default = null, $_tpl = null)
{
- case 'edit':
- $AVE_Template->assign('field_dir', $fld_name);
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $field_value);
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
-
- return $AVE_Template->fetch($tpl_file);
- break;
-
- case 'doc':
-
- $AVE_Template->config_load($lang_file, 'public');
-
- if ($tpl_empty)
- {
- $field_value = clean_php($field_value);
- }
- else
- {
- $field_param = explode('|', $field_value);
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
- }
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
-
- if($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_value', $field_value);
- return $AVE_Template->fetch($tpl_file);
- }
-
- return $field_value;
- break;
-
- case 'req':
-
- $AVE_Template->config_load($lang_file, 'public');
-
- if ($tpl_empty)
- {
- $field_value = clean_php($field_value);
- }
- else
- {
- $field_param = explode('|', $field_value);
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
- }
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
-
- if($tpl_empty && $tpl_file)
- {
- $AVE_Template->assign('field_value', $field_value);
- return $AVE_Template->fetch($tpl_file);
- }
+ global $AVE_Template;
- return $field_value;
- break;
+ $fld_dir = dirname(__FILE__) . '/';
+ $tpl_dir = $fld_dir . 'tpl/';
+ $fld_name = basename($fld_dir);
- case 'save':
- return $field_value;
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP')
+ ? $_SESSION['admin_language']
+ : $_SESSION['user_language']) . '.txt';
- case 'name':
- return $AVE_Template->get_config_vars('name');
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
- default: return $field_value;
- }
-}
+ switch ($action)
+ {
+ case 'edit':
+ $AVE_Template->assign('field_dir', $fld_name);
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $field_value);
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
-?>
+ return $AVE_Template->fetch($tpl_file);
+ break;
+
+ case 'doc':
+
+ $AVE_Template->config_load($lang_file, 'public');
+
+ if ($tpl_empty)
+ {
+ $field_value = clean_php($field_value);
+ }
+ else
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function ($data) use ($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_default', $default);
+ $AVE_Template->assign('field_value', $field_value);
+
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return $field_value;
+ break;
+
+ case 'req':
+
+ $AVE_Template->config_load($lang_file, 'public');
+
+ if ($tpl_empty)
+ {
+ $field_value = clean_php($field_value);
+ }
+ else
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_default', $default);
+ $AVE_Template->assign('field_value', $field_value);
+
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return $field_value;
+ break;
+
+ case 'save':
+ return $field_value;
+
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+
+ default:
+ return $field_value;
+ }
+ }
+?>
\ No newline at end of file
diff --git a/fields/single_line/tpl/field-doc.tpl b/fields/single_line/tpl/field-doc.tpl
index 20c861d..8166f56 100644
--- a/fields/single_line/tpl/field-doc.tpl
+++ b/fields/single_line/tpl/field-doc.tpl
@@ -1 +1,5 @@
+{*
+ $field_id
+ $field_value
+*}
{$field_value}
\ No newline at end of file
diff --git a/fields/single_line/tpl/field-req.tpl b/fields/single_line/tpl/field-req.tpl
index 20c861d..8166f56 100644
--- a/fields/single_line/tpl/field-req.tpl
+++ b/fields/single_line/tpl/field-req.tpl
@@ -1 +1,5 @@
+{*
+ $field_id
+ $field_value
+*}
{$field_value}
\ No newline at end of file
diff --git a/fields/single_line_numeric/field.php b/fields/single_line_numeric/field.php
index ddd77b1..4be1485 100644
--- a/fields/single_line_numeric/field.php
+++ b/fields/single_line_numeric/field.php
@@ -1,106 +1,115 @@
-
-
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- */
-
-// Однострочное числовое
-function get_field_single_line_numeric ($field_value, $action, $field_id = 0, $tpl = '', $tpl_empty = 0, &$maxlength = null, $document_fields = array(), $rubric_id = 0, $default = null)
-{
- global $AVE_Template;
-
- $fld_dir = dirname(__FILE__) . '/';
- $tpl_dir = $fld_dir . 'tpl/';
- $fld_name = basename($fld_dir);
-
- $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
-
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
-
- switch ($action)
+assign('field_dir', $fld_name);
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $field_value);
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
-
- return $AVE_Template->fetch($tpl_file);
- break;
-
- case 'doc':
- if ($tpl_empty)
- {
- $field_value = clean_php($field_value);
- }
- else
- {
- $field_param = explode('|', $field_value);
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
- }
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
-
- if($tpl_empty && $tpl_file){
- $AVE_Template->assign('field_value', $field_value);
- return $AVE_Template->fetch($tpl_file);
- }
- return $field_value;
- break;
-
- case 'req':
- if ($tpl_empty)
- {
- $field_value = clean_php($field_value);
- }
- else
- {
- $field_param = explode('|', $field_value);
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
- }
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
-
- if($tpl_empty && $tpl_file){
- $AVE_Template->assign('field_value', $field_value);
- return $AVE_Template->fetch($tpl_file);
- }
- return $field_value;
- break;
+ global $AVE_Template;
- case 'save':
- $field_value = preg_replace('/[^\d.]/','',$field_value);
- return $field_value;
+ $fld_dir = dirname(__FILE__) . '/';
+ $tpl_dir = $fld_dir . 'tpl/';
+ $fld_name = basename($fld_dir);
- case 'name':
- return $AVE_Template->get_config_vars('name');
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
- default: return $field_value;
- }
-}
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
-?>
+ switch ($action)
+ {
+ case 'edit':
+ $AVE_Template->assign('field_dir', $fld_name);
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $field_value);
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
+
+ return $AVE_Template->fetch($tpl_file);
+ break;
+
+ case 'doc':
+ if ($tpl_empty)
+ {
+ $field_value = clean_php($field_value);
+ }
+ else
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_default', $default);
+ $AVE_Template->assign('field_value', $field_value);
+
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return $field_value;
+ break;
+
+ case 'req':
+ if ($tpl_empty)
+ {
+ $field_value = clean_php($field_value);
+ }
+ else
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $field_value);
+ $AVE_Template->assign('field_default', $default);
+
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return $field_value;
+ break;
+
+ case 'save':
+ $field_value = preg_replace('/[^\d.]/','',$field_value);
+ return $field_value;
+
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+
+ default: return $field_value;
+ }
+ }
+?>
\ No newline at end of file
diff --git a/fields/single_line_numeric_three/field.php b/fields/single_line_numeric_three/field.php
new file mode 100644
index 0000000..0a6d36b
--- /dev/null
+++ b/fields/single_line_numeric_three/field.php
@@ -0,0 +1,134 @@
+config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
+
+ switch ($action)
+ {
+ case 'edit':
+ if (! empty($field_value))
+ $field_value = explode('|', $field_value);
+
+ $AVE_Template->assign('field_dir', $fld_name);
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $field_value);
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
+
+ return $AVE_Template->fetch($tpl_file);
+ break;
+
+ case 'doc':
+
+ if ($tpl_empty)
+ {
+ $value = array();
+
+ if (! empty($field_value))
+ {
+ $value = array_diff(explode('|', $field_value), array(''));
+ $value = array_map('clean_php', $value);
+ }
+ }
+ else
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_value', $value);
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return $field_value;
+ break;
+
+ case 'req':
+ if ($tpl_empty)
+ {
+ $value = array();
+
+ if (! empty($field_value))
+ {
+ $value = explode('|', $field_value);
+ $value = array_map('clean_php', $value);
+ }
+ }
+ else
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_value', $value);
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return $field_value;
+ break;
+
+ case 'save':
+ $save = array();
+
+ if (is_array($field_value))
+ {
+ foreach ($field_value AS $k => $v)
+ {
+ $save[] = preg_replace('/[^\d.]/', '', $v);
+ }
+ }
+
+ return empty($save) ? '' : implode('|', $save);
+
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+
+ default: return $field_value;
+ }
+ }
+?>
\ No newline at end of file
diff --git a/fields/single_line_numeric_three/js/field.js b/fields/single_line_numeric_three/js/field.js
new file mode 100644
index 0000000..af84e5d
--- /dev/null
+++ b/fields/single_line_numeric_three/js/field.js
@@ -0,0 +1,26 @@
+$(document).ready(function() {
+ $(".field_numeric").on('keydown', function(event) {
+ var num_dot = $(this).attr('data-num-dot');
+ var keyCode = window.event ? event.keyCode : event.which;
+ var foo = 0;
+ // prevent if already dot
+ if (keyCode != 8 && keyCode != 46) {
+ if ((foo == 0) && (keyCode != 190) && (keyCode < 96 || keyCode > 105) && (keyCode < 46 || keyCode > 59)) {
+ event.preventDefault();
+ } // prevent if not number/dot
+ }
+ if ($(this).val().indexOf('.') > -1) {
+ if (keyCode == 190) event.preventDefault();
+ }
+ $(this).keyup(function() {
+ this.value = this.value.replace(/[^0-9.]/i, "");
+ if($(this).val().indexOf('.')!=-1){
+ if($(this).val().split(".")[1].length >= num_dot){
+ if( isNaN( parseFloat( this.value ) ) ) return;
+ this.value = parseFloat(this.value).toFixed(num_dot);
+ }
+ }
+ return this;
+ });
+ });
+});
\ No newline at end of file
diff --git a/fields/single_line_numeric_three/lang/bg.txt b/fields/single_line_numeric_three/lang/bg.txt
new file mode 100644
index 0000000..51dcca4
--- /dev/null
+++ b/fields/single_line_numeric_three/lang/bg.txt
@@ -0,0 +1,3 @@
+[admin]
+
+name = "Едноредово (Числово)"
\ No newline at end of file
diff --git a/fields/single_line_numeric_three/lang/cz.txt b/fields/single_line_numeric_three/lang/cz.txt
new file mode 100644
index 0000000..67162c8
--- /dev/null
+++ b/fields/single_line_numeric_three/lang/cz.txt
@@ -0,0 +1,2 @@
+[admin]
+name = "Jednořádkový (Číselný)"
\ No newline at end of file
diff --git a/fields/single_line_numeric_three/lang/en.txt b/fields/single_line_numeric_three/lang/en.txt
new file mode 100644
index 0000000..fce8b0c
--- /dev/null
+++ b/fields/single_line_numeric_three/lang/en.txt
@@ -0,0 +1,2 @@
+[admin]
+name = "Single line (Numbers)"
\ No newline at end of file
diff --git a/fields/single_line_numeric_three/lang/pl.txt b/fields/single_line_numeric_three/lang/pl.txt
new file mode 100644
index 0000000..74abffa
--- /dev/null
+++ b/fields/single_line_numeric_three/lang/pl.txt
@@ -0,0 +1,2 @@
+[admin]
+name = "Linia pojedyncza (Numeryczne)"
\ No newline at end of file
diff --git a/fields/single_line_numeric_three/lang/ru.txt b/fields/single_line_numeric_three/lang/ru.txt
new file mode 100644
index 0000000..1cba424
--- /dev/null
+++ b/fields/single_line_numeric_three/lang/ru.txt
@@ -0,0 +1,2 @@
+[admin]
+name = "Однострочное (Числовое тройное)"
\ No newline at end of file
diff --git a/fields/single_line_numeric_three/lang/ua.txt b/fields/single_line_numeric_three/lang/ua.txt
new file mode 100644
index 0000000..37bf67d
--- /dev/null
+++ b/fields/single_line_numeric_three/lang/ua.txt
@@ -0,0 +1,2 @@
+[admin]
+name = "Однорядкове (Числове)"
\ No newline at end of file
diff --git a/fields/single_line_numeric_three/tpl/field-doc.tpl b/fields/single_line_numeric_three/tpl/field-doc.tpl
new file mode 100644
index 0000000..e0b3cf7
--- /dev/null
+++ b/fields/single_line_numeric_three/tpl/field-doc.tpl
@@ -0,0 +1 @@
+{$field_value.0} - {$field_value.1} - {$field_value.2}
\ No newline at end of file
diff --git a/fields/single_line_numeric_three/tpl/field-req.tpl b/fields/single_line_numeric_three/tpl/field-req.tpl
new file mode 100644
index 0000000..e0b3cf7
--- /dev/null
+++ b/fields/single_line_numeric_three/tpl/field-req.tpl
@@ -0,0 +1 @@
+{$field_value.0} - {$field_value.1} - {$field_value.2}
\ No newline at end of file
diff --git a/fields/single_line_numeric_three/tpl/field.tpl b/fields/single_line_numeric_three/tpl/field.tpl
new file mode 100644
index 0000000..c0db113
--- /dev/null
+++ b/fields/single_line_numeric_three/tpl/field.tpl
@@ -0,0 +1,8 @@
+{if $single_line_numeric != load}
+ {assign var=single_line_numeric value='' scope="global"}
+
+ {assign var=single_line_numeric value="load" scope="global"}
+{/if}
+
+
+
\ No newline at end of file
diff --git a/fields/single_line_numeric_two/field.php b/fields/single_line_numeric_two/field.php
new file mode 100644
index 0000000..2f90c99
--- /dev/null
+++ b/fields/single_line_numeric_two/field.php
@@ -0,0 +1,134 @@
+config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
+
+ switch ($action)
+ {
+ case 'edit':
+ if (! empty($field_value))
+ $field_value = explode('|', $field_value);
+
+ $AVE_Template->assign('field_dir', $fld_name);
+ $AVE_Template->assign('field_id', $field_id);
+ $AVE_Template->assign('field_value', $field_value);
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
+
+ return $AVE_Template->fetch($tpl_file);
+ break;
+
+ case 'doc':
+
+ if ($tpl_empty)
+ {
+ $value = array();
+
+ if (! empty($field_value))
+ {
+ $value = array_diff(explode('|', $field_value), array(''));
+ $value = array_map('clean_php', $value);
+ }
+ }
+ else
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_value', $value);
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return $field_value;
+ break;
+
+ case 'req':
+ if ($tpl_empty)
+ {
+ $value = array();
+
+ if (! empty($field_value))
+ {
+ $value = explode('|', $field_value);
+ $value = array_map('clean_php', $value);
+ }
+ }
+ else
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
+
+ if ($tpl_empty && $tpl_file)
+ {
+ $AVE_Template->assign('field_value', $value);
+ return $AVE_Template->fetch($tpl_file);
+ }
+
+ return $field_value;
+ break;
+
+ case 'save':
+ $save = array();
+
+ if (is_array($field_value))
+ {
+ foreach ($field_value AS $k => $v)
+ {
+ $save[] = preg_replace('/[^\d.]/', '', $v);
+ }
+ }
+
+ return empty($save) ? '' : implode('|', $save);
+
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+
+ default: return $field_value;
+ }
+ }
+?>
\ No newline at end of file
diff --git a/fields/single_line_numeric_two/js/field.js b/fields/single_line_numeric_two/js/field.js
new file mode 100644
index 0000000..af84e5d
--- /dev/null
+++ b/fields/single_line_numeric_two/js/field.js
@@ -0,0 +1,26 @@
+$(document).ready(function() {
+ $(".field_numeric").on('keydown', function(event) {
+ var num_dot = $(this).attr('data-num-dot');
+ var keyCode = window.event ? event.keyCode : event.which;
+ var foo = 0;
+ // prevent if already dot
+ if (keyCode != 8 && keyCode != 46) {
+ if ((foo == 0) && (keyCode != 190) && (keyCode < 96 || keyCode > 105) && (keyCode < 46 || keyCode > 59)) {
+ event.preventDefault();
+ } // prevent if not number/dot
+ }
+ if ($(this).val().indexOf('.') > -1) {
+ if (keyCode == 190) event.preventDefault();
+ }
+ $(this).keyup(function() {
+ this.value = this.value.replace(/[^0-9.]/i, "");
+ if($(this).val().indexOf('.')!=-1){
+ if($(this).val().split(".")[1].length >= num_dot){
+ if( isNaN( parseFloat( this.value ) ) ) return;
+ this.value = parseFloat(this.value).toFixed(num_dot);
+ }
+ }
+ return this;
+ });
+ });
+});
\ No newline at end of file
diff --git a/fields/single_line_numeric_two/lang/bg.txt b/fields/single_line_numeric_two/lang/bg.txt
new file mode 100644
index 0000000..51dcca4
--- /dev/null
+++ b/fields/single_line_numeric_two/lang/bg.txt
@@ -0,0 +1,3 @@
+[admin]
+
+name = "Едноредово (Числово)"
\ No newline at end of file
diff --git a/fields/single_line_numeric_two/lang/cz.txt b/fields/single_line_numeric_two/lang/cz.txt
new file mode 100644
index 0000000..67162c8
--- /dev/null
+++ b/fields/single_line_numeric_two/lang/cz.txt
@@ -0,0 +1,2 @@
+[admin]
+name = "Jednořádkový (Číselný)"
\ No newline at end of file
diff --git a/fields/single_line_numeric_two/lang/en.txt b/fields/single_line_numeric_two/lang/en.txt
new file mode 100644
index 0000000..fce8b0c
--- /dev/null
+++ b/fields/single_line_numeric_two/lang/en.txt
@@ -0,0 +1,2 @@
+[admin]
+name = "Single line (Numbers)"
\ No newline at end of file
diff --git a/fields/single_line_numeric_two/lang/pl.txt b/fields/single_line_numeric_two/lang/pl.txt
new file mode 100644
index 0000000..74abffa
--- /dev/null
+++ b/fields/single_line_numeric_two/lang/pl.txt
@@ -0,0 +1,2 @@
+[admin]
+name = "Linia pojedyncza (Numeryczne)"
\ No newline at end of file
diff --git a/fields/single_line_numeric_two/lang/ru.txt b/fields/single_line_numeric_two/lang/ru.txt
new file mode 100644
index 0000000..0ce29ac
--- /dev/null
+++ b/fields/single_line_numeric_two/lang/ru.txt
@@ -0,0 +1,2 @@
+[admin]
+name = "Однострочное (Числовое двойное)"
\ No newline at end of file
diff --git a/fields/single_line_numeric_two/lang/ua.txt b/fields/single_line_numeric_two/lang/ua.txt
new file mode 100644
index 0000000..37bf67d
--- /dev/null
+++ b/fields/single_line_numeric_two/lang/ua.txt
@@ -0,0 +1,2 @@
+[admin]
+name = "Однорядкове (Числове)"
\ No newline at end of file
diff --git a/fields/single_line_numeric_two/tpl/field-doc.tpl b/fields/single_line_numeric_two/tpl/field-doc.tpl
new file mode 100644
index 0000000..a992a59
--- /dev/null
+++ b/fields/single_line_numeric_two/tpl/field-doc.tpl
@@ -0,0 +1 @@
+{$field_value.0} - {$field_value.1}
\ No newline at end of file
diff --git a/fields/single_line_numeric_two/tpl/field-req.tpl b/fields/single_line_numeric_two/tpl/field-req.tpl
new file mode 100644
index 0000000..a992a59
--- /dev/null
+++ b/fields/single_line_numeric_two/tpl/field-req.tpl
@@ -0,0 +1 @@
+{$field_value.0} - {$field_value.1}
\ No newline at end of file
diff --git a/fields/single_line_numeric_two/tpl/field.tpl b/fields/single_line_numeric_two/tpl/field.tpl
new file mode 100644
index 0000000..4d7f34c
--- /dev/null
+++ b/fields/single_line_numeric_two/tpl/field.tpl
@@ -0,0 +1,7 @@
+{if $single_line_numeric != load}
+ {assign var=single_line_numeric value='' scope="global"}
+
+ {assign var=single_line_numeric value="load" scope="global"}
+{/if}
+
+
\ No newline at end of file
diff --git a/fields/teasers/field.php b/fields/teasers/field.php
index cddd81a..3429ce7 100644
--- a/fields/teasers/field.php
+++ b/fields/teasers/field.php
@@ -2,7 +2,7 @@
/**
* Teasers
*/
- function get_field_teasers($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength = '', $doc_fields=array(), $rubric_id=0, $default='')
+ function get_field_teasers($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength = '', $doc_fields=array(), $rubric_id=0, $default='', $_tpl=null)
{
global $AVE_DB, $AVE_Template;
@@ -36,7 +36,7 @@
$items = $list;
}
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
$AVE_Template->assign('doc_id', $_REQUEST['Id']);
$AVE_Template->assign('items', $items);
diff --git a/fields/teasers/js/outside.js b/fields/teasers/js/outside.js
deleted file mode 100644
index 89e625d..0000000
--- a/fields/teasers/js/outside.js
+++ /dev/null
@@ -1,120 +0,0 @@
-var Analoque = {
-
- init: false,
-
- init: function() {
- if (this.initialized) return;
- this.initialized = true;
-
- this.Analoque_items();
- },
-
- Analoque_items: function() {
- this.Analoque_sortable();
- this.Analoque_del_item();
- this.Analoque_add();
- this.Analoque_search();
- },
-
- Analoque_update: function() {
- this.Analoque_maxid();
- this.Analoque_del_item();
- this.Analoque_search();
- AveAdmin.tooltip();
- },
-
- Analoque_maxid: function(id) {
- var maxid = 1;
- $('#analoque_lists_' + id).children('.analoque_list').each(function() {
- maxid = Math.max(maxid, parseInt($(this).attr("data-id")) + 1);
- });
- return maxid;
- },
-
- Analoque_del_item: function() {
- $('.analoque_list .DelButton').on('click', function(event) {
- event.preventDefault();
- var id = $(this).attr('data-id');
- jConfirm(
- analoque_del_conf,
- analoque_del_head,
- function(b) {
- if (b) {
- $('#analoque_list_' + id).remove();
- }
- }
- );
- });
- },
-
- Analoque_add: function() {
- $('.AddButton').on('click', function() {
- c_id = $(this).parent().parent('.analoque_lists').attr("data-id");
- d_id = $(this).parent().parent('.analoque_lists').attr("data-docid");
- i_id = Analoque.Analoque_maxid(d_id + '_' + c_id);
- $('#analoque_lists_' + d_id + '_' + c_id + ':last').append(
- ' '
- );
-
- Analoque.Analoque_update();
- });
- },
-
- Analoque_sortable: function() {
- $('.analoque_lists').sortable({
- handle: ".handle",
- placeholder: "ui-state-highlight grey_bg"
- });
- },
-
- Analoque_search: function() {
-
- $('.search_analoque').on('input', function(event) {
-
- var query = $(this);
-
- var did = query.attr('data-docid');
- var fid = query.attr('data-fieldid');
- var kid = query.attr('data-id');
- var field_id_input = $('.field_' + did + '_' + fid + '_' + kid);
-
- query.autocomplete("index.php?do=fields&field=analoque&type=search&doc_id=" + did + "&field_id=" + fid, {
- width: query.outerWidth(),
- max: 10,
- dataType: "json",
- matchContains: "word",
- scroll: true,
- scrollHeight: 200,
- parse: function(data) {
- return $.map(data, function(row) {
- return {
- data: row,
- value: row.doc_title,
- result: query.val()
- }
- });
- },
- formatItem: function(item) {
- return ' ' + item.doc_article + ' ' + item.doc_name + ' ';
- }
- }).result(function(e, item) {
- query.val(item.doc_name);
- field_id_input.val(item.doc_id);
- });
-
- });
-
- }
-
-
-
-
-
-}
-
-$(document).ready(function() {
- Analoque.init();
-});
\ No newline at end of file
diff --git a/fields/text_to_image/field.php b/fields/text_to_image/field.php
index a7d28eb..4905048 100644
--- a/fields/text_to_image/field.php
+++ b/fields/text_to_image/field.php
@@ -1,125 +1,125 @@
-
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @copyright © 2007-2016 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- *
- * @param $field_value
- * @param $action
- * @param int $field_id
- * @param string $tpl
- * @param int $tpl_empty
- * @param null $maxlength
- * @param array $document_fields
- * @param int $rubric_id
- * @param null $default
- * @return array|int|mixed|string
- */
-
-// Текст в изображение
-function get_field_text_to_image ($field_value, $action, $field_id = 0, $tpl = '', $tpl_empty = 0, &$maxlength = null, $document_fields = array(), $rubric_id = 0, $default = null)
-{
- global $AVE_Template;
-
- $fld_dir = dirname(__FILE__) . '/';
- $tpl_dir = $fld_dir . 'tpl/';
- $fld_name = basename($fld_dir);
-
- $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
-
- $AVE_Template->config_load($lang_file, 'lang');
- $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
- $AVE_Template->config_load($lang_file, 'admin');
-
- switch ($action)
+assign('field_dir', $fld_name);
- $AVE_Template->assign('field_id', $field_id);
- $AVE_Template->assign('field_value', $field_value);
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
-
- return $AVE_Template->fetch($tpl_file);
- break;
-
- // Отображение поля в документах
- case 'doc':
-
- $AVE_Template->config_load($lang_file, 'public');
-
- if ($tpl_empty)
- {
- $field_value = clean_php($field_value);
- }
- else
- {
- $field_param = explode('|', $field_value);
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
- }
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
-
- if($tpl_empty && $tpl_file){
- $AVE_Template->assign('field_value', $field_value);
- return $AVE_Template->fetch($tpl_file);
- }
- return $field_value;
- break;
-
- // Отображение поля в запросах
- case 'req':
-
- $AVE_Template->config_load($lang_file, 'public');
-
- if ($tpl_empty)
- {
- $field_value = clean_php($field_value);
- }
- else
- {
- $field_param = explode('|', $field_value);
- $field_value = preg_replace_callback(
- '/\[tag:parametr:(\d+)\]/i',
- function($data) use($field_param)
- {
- return $field_param[(int)$data[1]];
- },
- $tpl
- );
- }
-
- $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
-
- if($tpl_empty && $tpl_file){
+ global $AVE_Template;
+
+ $fld_dir = dirname(__FILE__) . '/';
+ $tpl_dir = $fld_dir . 'tpl/';
+ $fld_name = basename($fld_dir);
+
+ $lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
+
+ $AVE_Template->config_load($lang_file, 'lang');
+ $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
+ $AVE_Template->config_load($lang_file, 'admin');
+
+ switch ($action)
+ {
+ // Отображение поля в административной части
+ case 'edit':
+ $AVE_Template->assign('field_dir', $fld_name);
+ $AVE_Template->assign('field_id', $field_id);
$AVE_Template->assign('field_value', $field_value);
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
+
return $AVE_Template->fetch($tpl_file);
- }
- return $field_value;
- break;
-
- // Сохранение поля в административной части
- case 'save':
- return $field_value;
- // Тип | Имя поля в административной части
- case 'name':
- return $AVE_Template->get_config_vars('name');
-
- default: return $field_value;
+ break;
+
+ // Отображение поля в документах
+ case 'doc':
+
+ $AVE_Template->config_load($lang_file, 'public');
+
+ if ($tpl_empty)
+ {
+ $field_value = clean_php($field_value);
+ }
+ else
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
+
+ if($tpl_empty && $tpl_file){
+ $AVE_Template->assign('field_value', $field_value);
+ return $AVE_Template->fetch($tpl_file);
+ }
+ return $field_value;
+ break;
+
+ // Отображение поля в запросах
+ case 'req':
+
+ $AVE_Template->config_load($lang_file, 'public');
+
+ if ($tpl_empty)
+ {
+ $field_value = clean_php($field_value);
+ }
+ else
+ {
+ $field_param = explode('|', $field_value);
+ $field_value = preg_replace_callback(
+ '/\[tag:parametr:(\d+)\]/i',
+ function($data) use($field_param)
+ {
+ return $field_param[(int)$data[1]];
+ },
+ $tpl
+ );
+ }
+
+ $tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
+
+ if($tpl_empty && $tpl_file){
+ $AVE_Template->assign('field_value', $field_value);
+ return $AVE_Template->fetch($tpl_file);
+ }
+ return $field_value;
+ break;
+
+ // Сохранение поля в административной части
+ case 'save':
+ return $field_value;
+ // Тип | Имя поля в административной части
+ case 'name':
+ return $AVE_Template->get_config_vars('name');
+
+ default: return $field_value;
+ }
}
-}
-
?>
\ No newline at end of file
diff --git a/fields/youtube/field.php b/fields/youtube/field.php
index 425b8e7..afec825 100644
--- a/fields/youtube/field.php
+++ b/fields/youtube/field.php
@@ -1,31 +1,30 @@
-
-
-/**
- * AVE.cms
- *
- * @package AVE.cms
- * @version 3.x
- * @filesource
- * @field YouTube
- * @copyright © 2007-2016 AVE.cms, http://www.ave-cms.ru
- *
- * @license GPL v.2
- *
- * @param $field_value
- * @param $action
- * @param int $field_id
- * @param string $tpl
- * @param int $tpl_empty
- * @param null $maxlength
- * @param array $document_fields
- * @param int $rubric_id
- * @param null $default
- * @return array|int|mixed|string
- */
-
-// YouTube
-
- function get_field_youtube($field_value, $action, $field_id = 0, $tpl = '', $tpl_empty = 0, &$maxlength = null, $document_fields = array(), $rubric_id = 0, $default = null)
+
+?>
\ No newline at end of file
diff --git a/functions/func.block.php b/functions/func.block.php
index 44091da..4a1d1e2 100644
--- a/functions/func.block.php
+++ b/functions/func.block.php
@@ -1,97 +1,101 @@
Query("
- SELECT
- block_text
- FROM
- " . PREFIX . "_blocks
- WHERE
- " . (is_numeric($id) ? 'id' : 'block_alias') . " = '" . $id . "'
- LIMIT 1
- ")->GetCell();
-
- if ($cache_file)
- file_put_contents($cache_file, $return);
- }
+ $cache = md5('block' . $id);
- //-- парсим теги
- $search = array(
- '[tag:mediapath]',
- '[tag:path]',
- '[tag:docid]'
- );
+ $cache_file = BASE_DIR . '/cache/sql/block/' . $cache . '.cache';
- $replace = array(
- ABS_PATH . 'templates/' . ((defined('THEME_FOLDER') === false) ? DEFAULT_THEME_FOLDER : THEME_FOLDER) . '/',
- ABS_PATH,
- get_current_document_id()
- );
+ // Если включен DEV MODE, то отключаем кеширование запросов
+ if (defined('DEV_MODE') AND DEV_MODE)
+ $cache_file = null;
- $return = str_replace($search, $replace, $return);
+ if (! file_exists(dirname($cache_file)))
+ mkdir(dirname($cache_file), 0766, true);
- $return = preg_replace_callback('/\[tag:home]/', 'get_home_link', $return);
- $return = preg_replace_callback('/\[tag:breadcrumb]/', 'get_breadcrumb', $return);
- $return = preg_replace_callback('/\[tag:request:([A-Za-z0-9-_]{1,20}+)\]/', 'request_parse', $return);
-
- if (isset($_REQUEST['id']) && $_REQUEST['id'] != '')
- {
- //-- парсим теги полей документа в шаблоне рубрики
- $return = preg_replace_callback('/\[tag:fld:([a-zA-Z0-9-_]+)\]/', 'document_get_field', $return);
- $return = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $return);
- }
+ if (file_exists($cache_file))
+ {
+ $return = file_get_contents($cache_file);
+ }
+ else
+ {
+ $return = $AVE_DB->Query("
+ SELECT
+ block_text
+ FROM
+ " . PREFIX . "_blocks
+ WHERE
+ " . (is_numeric($id) ? 'id' : 'block_alias') . " = '" . $id . "'
+ LIMIT 1
+ ")->GetCell();
+
+ if ($cache_file)
+ file_put_contents($cache_file, $return);
+ }
+
+ //-- парсим теги
+ $search = array(
+ '[tag:mediapath]',
+ '[tag:path]',
+ '[tag:docid]'
+ );
+
+ $replace = array(
+ ABS_PATH . 'templates/' . ((defined('THEME_FOLDER') === false) ? DEFAULT_THEME_FOLDER : THEME_FOLDER) . '/',
+ ABS_PATH,
+ get_current_document_id()
+ );
+
+ $return = str_replace($search, $replace, $return);
+
+ $return = preg_replace_callback('/\[tag:home]/', 'get_home_link', $return);
+ $return = preg_replace_callback('/\[tag:breadcrumb]/', 'get_breadcrumb', $return);
+ $return = preg_replace_callback('/\[tag:request:([A-Za-z0-9-_]{1,20}+)\]/', 'request_parse', $return);
+
+ if (isset($_REQUEST['id']) && $_REQUEST['id'] != '')
+ {
+ //-- парсим теги полей документа в шаблоне рубрики
+ $return = preg_replace_callback('/\[tag:fld:([a-zA-Z0-9-_]+)\]\[([0-9]+)]\[([0-9]+)]/', 'get_field_element', $return);
+ $return = preg_replace_callback('/\[tag:fld:([a-zA-Z0-9-_]+)(|[:(\d)])+?\]/', 'document_get_field', $return);
+ $return = preg_replace_callback('/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/', 'watermarks', $return);
+ $return = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $return);
+ }
- // Парсим блоки
- $return = preg_replace_callback('/\[tag:block:([A-Za-z0-9-_]{1,20}+)\]/', 'parse_block', $return);
- // Парсим ситемные блоки
- $return = preg_replace_callback('/\[tag:sysblock:([A-Za-z0-9-_]{1,20}+)\]/', 'parse_sysblock', $return);
+ // Парсим блоки
+ $return = preg_replace_callback('/\[tag:block:([A-Za-z0-9-_]{1,20}+)\]/', 'parse_block', $return);
+ // Парсим ситемные блоки
+ $return = preg_replace_callback('/\[tag:sysblock:([A-Za-z0-9-_]{1,20}+)\]/', 'parse_sysblock', $return);
- $gen_time = Debug::endTime('BLOCK_' . $id);
+ $gen_time = Debug::endTime('BLOCK_' . $id);
- $GLOBALS['block_generate']['BLOCKS'][$id] = $gen_time;
+ $GLOBALS['block_generate']['BLOCKS'][$id] = $gen_time;
- return $return;
+ return $return;
+ }
}
-}
?>
\ No newline at end of file
diff --git a/functions/func.common.php b/functions/func.common.php
index 4f7b2b5..26ad985 100755
--- a/functions/func.common.php
+++ b/functions/func.common.php
@@ -605,6 +605,11 @@
$dir = BASE_DIR . "/" . $path;
+ $dir_abs = "/" . $path;
+
+ $files = array();
+ $thumbs = array();
+
if ($handle = opendir($dir))
{
while (false !== ($file = readdir($handle)))
@@ -612,14 +617,23 @@
$nameParts = explode('.', $file);
$ext = strtolower(end($nameParts));
- if ($file != "." && $file != ".." && $ext == "png" || $ext == "jpg" || $ext == "gif")
+ if ($file != "." && $file != ".." && in_array($ext, $images_ext))
{
- if (! is_dir($dir . "/" . $file))
- $files[] = $file;
+ if (! is_dir($dir . "/" . $file))
+ {
+ $files[] = $file;
+ $thumbs[] = make_thumbnail(array('link' => $dir_abs . $file, 'size' => 'f128x128'));
+ }
}
}
closedir($handle);
}
+
+ $return = array(
+ 'files' => $files,
+ 'thumbs' => $thumbs
+ );
+
return $files;
}
@@ -631,7 +645,7 @@
*/
function file_multi_import($path)
{
- $dir = BASE_DIR."/".$path;
+ $dir = BASE_DIR . "/" . $path;
if ($handle = opendir($dir))
{
@@ -642,8 +656,8 @@
if ($file != "." && $file != ".." && $ext == "php" || $ext == "inc")
{
- if (! is_dir($dir . "/" . $file))
- $files[] = $file;
+ if (! is_dir($dir . "/" . $file))
+ $files[] = $file;
}
}
closedir($handle);
diff --git a/functions/func.documents.php b/functions/func.documents.php
index e311cec..5d25c4f 100644
--- a/functions/func.documents.php
+++ b/functions/func.documents.php
@@ -1,108 +1,115 @@
- // Chrome
- // FF
- $pages = preg_split('# #i', $text);
- $total_page = @sizeof($pages);
-
- if ($total_page > 1)
+ /**
+ * AVE.cms
+ *
+ * @package AVE.cms
+ * @version 3.x
+ * @filesource
+ * @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
+ *
+ * @license GPL v.2
+ */
+
+
+ /**
+ * Постраничная навигация документа
+ *
+ * @param string $text текст многострочной части документа
+ * @return string
+ */
+ function document_pagination($text)
{
- $text = @$pages[get_current_page('artpage')-1];
+ global $AVE_Core;
- $page_nav = ' {t} ';
- $page_nav = get_pagination($total_page, 'artpage', $page_nav, get_settings('navi_box'));
+ // IE8
+ // Chrome
+ // FF
+ $pages = preg_split('# #i', $text);
+ $total_page = @sizeof($pages);
- $text .= rewrite_link($page_nav);
+ if ($total_page > 1)
+ {
+ $text = @$pages[get_current_page('artpage')-1];
+
+ $page_nav = ' {t} ';
+ $page_nav = get_pagination($total_page, 'artpage', $page_nav, get_settings('navi_box'));
+
+ $text .= rewrite_link($page_nav);
+ }
+
+ $pages = '';
+
+ return $pages . $text;
}
- $pages = '';
-
- return $pages . $text;
-}
-
-/**
- * Получить идентификатор текущего документа
- *
- * @return int идентификатор текущего документа
- */
-function get_current_document_id()
-{
- $_REQUEST['id'] = (isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) ? $_REQUEST['id'] : 1;
-
- return $_REQUEST['id'];
-}
-
-/**
- * Получить идентификатор родительского документа
- *
- * @return int идентификатор родительского документа
- */
-function get_parent_document_id()
-{
- global $AVE_DB;
- return $AVE_DB->Query("SELECT document_parent FROM " . PREFIX . "_documents WHERE Id = '".get_current_document_id()."' ")->GetCell();
-}
-
-/**
- * Функция отдаёт основные параметры дока
- *
- * @param int $doc_id - номер id документа
- * @param string $key - параметр документа
- *
- * @return string
- */
-function get_document ($doc_id , $key ='')
-{
- global $AVE_DB;
-
- $doc_id = (int)$doc_id;
- if ($doc_id < 1) return array();
-
- static $get_documents_data = array();
-
- if (!isset ($get_documents_data[$doc_id]))
+ /**
+ * Получить идентификатор текущего документа
+ *
+ * @return int идентификатор текущего документа
+ */
+ function get_current_document_id()
{
- $get_documents_data[$doc_id] = $AVE_DB->Query("
- SELECT * FROM " . PREFIX . "_documents
- WHERE Id = '" . $doc_id . "'
- ")->FetchAssocArray();
+ $_REQUEST['id'] = (isset($_REQUEST['id']) && is_numeric($_REQUEST['id']))
+ ? $_REQUEST['id']
+ : 1;
- $get_documents_data[$doc_id]['doc_title'] = $get_documents_data[$doc_id]['document_title'];
- $get_documents_data[$doc_id]['feld'] = array();
+ return $_REQUEST['id'];
}
- if(isset($key) && $key != '') {
- return $get_documents_data[$doc_id][$key];
- }else{
- return $get_documents_data[$doc_id];
+ /**
+ * Получить идентификатор родительского документа
+ *
+ * @return int идентификатор родительского документа
+ */
+ function get_parent_document_id()
+ {
+ global $AVE_DB;
+ return $AVE_DB->Query("SELECT document_parent FROM " . PREFIX . "_documents WHERE Id = '".get_current_document_id()."' ")->GetCell();
+ }
+
+ /**
+ * Функция отдаёт основные параметры дока
+ *
+ * @param int $doc_id - номер id документа
+ * @param string $key - параметр документа
+ *
+ * @return string
+ */
+ function get_document ($doc_id , $key ='')
+ {
+ global $AVE_DB;
+
+ $doc_id = (int)$doc_id;
+
+ if ($doc_id < 1)
+ return array();
+
+ static $get_documents_data = array();
+
+ if (! isset ($get_documents_data[$doc_id]))
+ {
+ $get_documents_data[$doc_id] = $AVE_DB->Query("
+ SELECT
+ *
+ FROM
+ " . PREFIX . "_documents
+ WHERE
+ Id = '" . $doc_id . "'
+ ")->FetchAssocArray();
+
+ $get_documents_data[$doc_id]['doc_title'] = $get_documents_data[$doc_id]['document_title'];
+ $get_documents_data[$doc_id]['feld'] = array();
+ }
+
+ if (isset($key) && $key != '')
+ return $get_documents_data[$doc_id][$key];
+ else
+ return $get_documents_data[$doc_id];
}
-}
?>
\ No newline at end of file
diff --git a/functions/func.fields.php b/functions/func.fields.php
index fec137a..167eda5 100644
--- a/functions/func.fields.php
+++ b/functions/func.fields.php
@@ -15,7 +15,7 @@
/**
* Определяем пустое изображение
*/
- @$img_pixel = 'templates/images/blanc.gif';
+ $img_pixel = 'templates/images/default.png';
/**
@@ -30,7 +30,9 @@
$field_dir = $d->path . '/' . $entry;
if (is_dir($field_dir) && file_exists($field_dir . '/field.php'))
- require_once($field_dir . '/field.php');
+ {
+ require_once ($field_dir . '/field.php');
+ }
}
$d->Close();
@@ -68,12 +70,12 @@
*
* @return string
*/
- function get_field_default($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null)
+ function get_field_default($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null, $_tpl=null)
{
switch ($action)
{
case 'edit':
- return ' ';
+ return ' ';
case 'doc':
case 'req':
if (! $tpl_empty)
@@ -101,7 +103,7 @@
*
* @return mixed
*/
- function get_field_type($type = '')
+ function get_field_type ($type = '')
{
static $fields;
@@ -133,6 +135,8 @@
? $fields_vars[$name]
: $name));
}
+ else
+ continue;
}
$fields = msort($fields, array('name'));
@@ -156,7 +160,7 @@
static $alias_field_id = array();
if (isset($alias_field_id[$id]))
- return $alias_field_id[$id];
+ return $alias_field_id[$id];
$alias_field_id[$id] = $AVE_DB->Query("SELECT rubric_field_alias FROM " . PREFIX . "_rubric_fields WHERE Id=".intval($id))->GetCell();
@@ -183,10 +187,13 @@
$sql = "
SELECT Id
- FROM " . PREFIX . "_rubric_fields
- WHERE (rubric_field_alias = '".addslashes($alias)."'
- OR Id = '".intval($alias)."')
- AND rubric_id = ".intval($rubric_id)
+ FROM
+ " . PREFIX . "_rubric_fields
+ WHERE
+ (rubric_field_alias = '".addslashes($alias)."'
+ OR Id = '".intval($alias)."')
+ AND
+ rubric_id = ".intval($rubric_id)
;
$alias_field_id[$rubric_id][$alias] = $AVE_DB->Query($sql)->GetCell();
@@ -213,9 +220,12 @@
return $alias_field_id[$id];
$sql = "
- SELECT rubric_field_default
- FROM " . PREFIX . "_rubric_fields
- WHERE Id = ".intval($id)
+ SELECT
+ rubric_field_default
+ FROM
+ " . PREFIX . "_rubric_fields
+ WHERE
+ Id = ".intval($id)
;
$alias_field_id[$id] = $AVE_DB->Query($sql)->GetCell();
@@ -227,50 +237,41 @@
/**
* Возвращаем шаблон tpl или пусто
*
- * @param string $dir
+ * @param string $dir папка шаблона
* @param int $field_id идентификатор поля
- * @param string $type
+ * @param string $type тип поля
+ * @param int $_tpl номер шаблона
*
* @return string
*/
- function get_field_tpl($dir='', $field_id=0, $type='admin')
+ function get_field_tpl($dir = '', $field_id = 0, $type = 'admin', $_tpl = null)
{
- $alias_field_id = get_field_alias($field_id);
-
- switch ($type)
- {
- case '':
- case 'admin':
- default:
- $tpl = (file_exists($dir.'field-'.$field_id.'.tpl'))
- ? $dir.'field-'.$field_id.'.tpl'
- : ((file_exists($dir.'field-'.$alias_field_id.'.tpl'))
- ? $dir.'field-'.$alias_field_id.'.tpl'
- : $dir.'field.tpl');
-
- $tpl = (@filesize($tpl)) ? $tpl : '';
- break;
-
- case 'doc':
- $tpl = (file_exists($dir.'field-doc-'.$field_id.'.tpl'))
- ? $dir.'field-doc-'.$field_id.'.tpl'
- : ((file_exists($dir.'field-doc-'.$alias_field_id.'.tpl'))
- ? $dir.'field-doc-'.$alias_field_id.'.tpl'
- : $dir.'field-doc.tpl');
+ if (! $type)
+ return false;
- $tpl = (@filesize($tpl)) ? $tpl : '';
- break;
+ $alias_field_id = get_field_alias($field_id);
- case 'req':
- $tpl = (file_exists($dir.'field-req-'.$field_id.'.tpl'))
- ? $dir.'field-req-'.$field_id.'.tpl'
- : ((file_exists($dir.'field-req-'.$alias_field_id.'.tpl'))
- ? $dir.'field-req-'.$alias_field_id.'.tpl'
- : $dir.'field-req.tpl');
-
- $tpl = (@filesize($tpl)) ? $tpl : '';
- break;
- }
+ // Если существет файл с ID поля и ID шаблона
+ if (file_exists($dir.'field-'.$type.'-'.$field_id.'-'.$_tpl.'.tpl'))
+ $tpl = $dir.'field-'.$type.'-'.$field_id.'-'.$_tpl.'.tpl';
+ // Если существет файл с аласом поля и ID шаблона
+ else if (file_exists($dir.'field-'.$type.'-'.$alias_field_id.'-'.$_tpl.'.tpl'))
+ $tpl = $dir.'field-'.$type.'-'.$alias_field_id.'-'.$_tpl.'.tpl';
+ // Если существет файл с ID поля
+ else if (file_exists($dir.'field-'.$type.'-'.$field_id.'.tpl'))
+ $tpl = $dir.'field-'.$type.'-'.$field_id.'.tpl';
+ // Если существет файл с алиасом поля
+ else if (file_exists($dir.'field-'.$type.'-'.$alias_field_id.'.tpl'))
+ $tpl = $dir.'field-'.$type.'-'.$alias_field_id.'.tpl';
+ // Если существет файл c типом поля
+ else if (file_exists($dir.'field-'.$type.'.tpl'))
+ $tpl = $dir.'field-'.$type.'.tpl';
+ // Если существет файл c ID поля
+ else if (file_exists($dir.'field-'.$field_id.'.tpl'))
+ $tpl = $dir.'field-'.$field_id.'.tpl';
+ // Иначе
+ else
+ $tpl = $dir.'field.tpl';
return $tpl;
}
@@ -284,10 +285,13 @@
*
* @return string
*/
- function document_get_field($field_id, $document_id = null)
+ function document_get_field($field_id, $document_id = null, $_tpl = null)
{
global $AVE_Core;
+ if (! $_tpl && is_array($field_id))
+ $_tpl = $field_id[2];
+
if (is_array($field_id))
$field_id = $field_id[1];
@@ -321,7 +325,7 @@
if (! is_callable($func))
$func = 'get_field_default';
- $field_value = $func($field_value, 'doc', $field_id, $rubric_field_template, $tpl_field_empty, $maxlength, $document_fields, RUB_ID, $rubric_field_default);
+ $field_value = $func($field_value, 'doc', $field_id, $rubric_field_template, $tpl_field_empty, $maxlength, $document_fields, RUB_ID, $rubric_field_default, $_tpl);
return $field_value;
}
@@ -416,7 +420,6 @@
$where = "WHERE doc_field.document_id = '" . $document_id . "'";
$query="
-
SELECT
doc_field.Id,
doc_field.document_id,
@@ -444,7 +447,7 @@
ON doc.Id = doc_field.document_id
" . $where;
- $sql = $AVE_DB->Query($query,-1,'doc_'.$document_id);
+ $sql = $AVE_DB->Query($query, -1, 'doc_'.$document_id);
//Вдруг памяти мало!!!!
if (memory_panic() && (count($document_fields) > 3))
@@ -681,11 +684,20 @@
*
* @return string
*/
- function return_element()
+ function get_field_element()
{
$param = func_get_args();
- $return = get_element($param[0][1], $param[0][2], $param[0][3]);
+ // Field ID
+ $param_1 = isset($param[0]) ? $param[0] : null;
+ // Item ID
+ $param_2 = isset($param[1]) ? $param[1] : null;
+ // Param ID
+ $param_3 = isset($param[2]) ? $param[2] : null;
+ // Document ID
+ $param_4 = isset($param[3]) ? $param[3] : null;
+
+ $return = get_element($param_1, $param_2, $param_3, $param_4);
return $return;
}
diff --git a/functions/func.parserequest.php b/functions/func.parserequest.php
index 3712c4d..7a139d5 100755
--- a/functions/func.parserequest.php
+++ b/functions/func.parserequest.php
@@ -389,6 +389,27 @@
// Парсим теги системных блоков
$item = preg_replace_callback('/\[tag:sysblock:([A-Za-z0-9-_]{1,20}+)\]/', 'parse_sysblock', $item);
+ // Парсим элементы полей
+ $item = preg_replace_callback(
+ '/\[tag:rfld:([a-zA-Z0-9-_]+)\]\[([0-9]+)]\[([0-9]+)]/',
+ create_function(
+ '$m',
+ 'return get_field_element($m[1], $m[2], $m[3], ' . $row->Id . ');'
+ ),
+ $item
+ );
+
+ // Парсим теги полей
+ $item = preg_replace_callback(
+ '/\[tag:rfld:([a-zA-Z0-9-_]+)]\[(more|esc|img|[0-9-]+)]/',
+ create_function(
+ '$m',
+ 'return request_get_document_field($m[1], ' . $row->Id . ', $m[2], ' . (int)$row->rubric_id . ');'
+ ),
+ $item
+ );
+
+ // Повторно парсим теги полей
$item = preg_replace_callback(
'/\[tag:rfld:([a-zA-Z0-9-_]+)]\[(more|esc|img|[0-9-]+)]/',
create_function(
@@ -398,7 +419,7 @@
$item
);
- // Возвращаем поле из БД документа
+ // Возвращаем поле документа из БД (document_***)
$item = preg_replace_callback('/\[tag:doc:([a-zA-Z0-9-_]+)\]/u',
function ($match) use ($row)
{
@@ -421,7 +442,10 @@
$item
);
+ // Абсолютный путь
$item = str_replace('[tag:path]', ABS_PATH, $item);
+
+ // Путь к папке шаблона
$item = str_replace('[tag:mediapath]', ABS_PATH . 'templates/' . ((defined('THEME_FOLDER') === false)
? DEFAULT_THEME_FOLDER
: THEME_FOLDER)
@@ -437,12 +461,14 @@
$item
);
- // Удаляем ошибочные теги полей документа в шаблоне рубрики
+ // Удаляем ошибочные теги полей документа и языковые, в шаблоне рубрики
$item = preg_replace('/\[tag:doc:\d*\]/', '', $item);
$item = preg_replace('/\[tag:langfile:\d*\]/', '', $item);
+ // Делаем линки на миниатюры
$item = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $item);
+ // Если был вызов тизера, ищем параметры
if ($tparams != '')
{
// Заменяем tparam в тизере
@@ -511,7 +537,7 @@
if (isset($use_cache) && $use_cache == 1)
{
// Кеширование элементов запроса
- if(! file_exists(dirname($cachefile_docid)))
+ if (! file_exists(dirname($cachefile_docid)))
@mkdir(dirname($cachefile_docid), 0777, true);
file_put_contents($cachefile_docid, $item);
@@ -522,8 +548,8 @@
$item = file_get_contents($cachefile_docid);
}
+ // Кол-во просмотров
$item = str_replace('[tag:docviews]', $row->document_count_view, $item);
- $item = str_replace('[tag:doccomments]', isset($row->nums) ? $row->nums : '', $item);
unset($row);
@@ -1080,6 +1106,7 @@
return $return;
}
+
/**
* Функция получения содержимого поля для обработки в шаблоне запроса
*
diff --git a/functions/func.sysblock.php b/functions/func.sysblock.php
index 511d579..0ed1808 100644
--- a/functions/func.sysblock.php
+++ b/functions/func.sysblock.php
@@ -1,101 +1,105 @@
Query("
- SELECT
- sysblock_text
- FROM
- " . PREFIX . "_sysblocks
- WHERE
- " . (is_numeric($id) ? 'id' : 'sysblock_alias') . " = '" . $id . "'
- LIMIT 1
- ")->GetCell();
-
- if ($cache_file)
- file_put_contents($cache_file, $return);
- }
+ $eval_sysblock = true;
- //-- парсим теги
- $search = array(
- '[tag:mediapath]',
- '[tag:path]',
- '[tag:docid]'
- );
+ $cache = md5('sysblock' . $id);
- $replace = array(
- ABS_PATH . 'templates/' . ((defined('THEME_FOLDER') === false) ? DEFAULT_THEME_FOLDER : THEME_FOLDER) . '/',
- ABS_PATH,
- get_current_document_id()
- );
+ $cache_file = BASE_DIR . '/cache/sql/sysblock/' . $cache . '.cache';
- $return = str_replace($search, $replace, $return);
+ // Если включен DEV MODE, то отключаем кеширование запросов
+ if (defined('DEV_MODE') AND DEV_MODE)
+ $cache_file = null;
- $return = preg_replace_callback('/\[tag:home]/', 'get_home_link', $return);
- $return = preg_replace_callback('/\[tag:breadcrumb]/', 'get_breadcrumb', $return);
- $return = preg_replace_callback('/\[tag:request:([A-Za-z0-9-_]{1,20}+)\]/', 'request_parse', $return);
+ if (! file_exists(dirname($cache_file)))
+ mkdir(dirname($cache_file), 0766, true);
- if (isset($_REQUEST['id']) && $_REQUEST['id'] != '')
- {
- //-- парсим теги полей документа в шаблоне рубрики
- $return = preg_replace_callback('/\[tag:fld:([a-zA-Z0-9-_]+)\]/', 'document_get_field', $return);
- $return = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $return);
- }
+ if (file_exists($cache_file))
+ {
+ $return = file_get_contents($cache_file);
+ }
+ else
+ {
+ $return = $AVE_DB->Query("
+ SELECT
+ sysblock_text
+ FROM
+ " . PREFIX . "_sysblocks
+ WHERE
+ " . (is_numeric($id) ? 'id' : 'sysblock_alias') . " = '" . $id . "'
+ LIMIT 1
+ ")->GetCell();
+
+ if ($cache_file)
+ file_put_contents($cache_file, $return);
+ }
+
+ //-- парсим теги
+ $search = array(
+ '[tag:mediapath]',
+ '[tag:path]',
+ '[tag:docid]'
+ );
+
+ $replace = array(
+ ABS_PATH . 'templates/' . ((defined('THEME_FOLDER') === false) ? DEFAULT_THEME_FOLDER : THEME_FOLDER) . '/',
+ ABS_PATH,
+ get_current_document_id()
+ );
+
+ $return = str_replace($search, $replace, $return);
+
+ $return = preg_replace_callback('/\[tag:home]/', 'get_home_link', $return);
+ $return = preg_replace_callback('/\[tag:breadcrumb]/', 'get_breadcrumb', $return);
+ $return = preg_replace_callback('/\[tag:request:([A-Za-z0-9-_]{1,20}+)\]/', 'request_parse', $return);
+
+ if (isset($_REQUEST['id']) && $_REQUEST['id'] != '')
+ {
+ //-- парсим теги полей документа в шаблоне рубрики
+ $return = preg_replace_callback('/\[tag:fld:([a-zA-Z0-9-_]+)\]\[([0-9]+)]\[([0-9]+)]/', 'get_field_element', $return);
+ $return = preg_replace_callback('/\[tag:fld:([a-zA-Z0-9-_]+)(|[:(\d)])+?\]/', 'document_get_field', $return);
+ $return = preg_replace_callback('/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/', 'watermarks', $return);
+ $return = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $return);
+ }
- $return = preg_replace_callback('/\[tag:block:([A-Za-z0-9-_]{1,20}+)\]/', 'parse_block', $return);
+ $return = preg_replace_callback('/\[tag:block:([A-Za-z0-9-_]{1,20}+)\]/', 'parse_block', $return);
- if ($eval_sysblock)
- $return = eval2var('?'.'>' . $return . '<'.'?');
+ if ($eval_sysblock)
+ $return = eval2var('?'.'>' . $return . '<'.'?');
- $gen_time = Debug::endTime('SYSBLOCK_' . $id);
+ $gen_time = Debug::endTime('SYSBLOCK_' . $id);
- $GLOBALS['block_generate']['SYSBLOCK'][$id] = $gen_time;
+ $GLOBALS['block_generate']['SYSBLOCK'][$id] = $gen_time;
- return $return;
+ return $return;
+ }
}
-}
?>
\ No newline at end of file
diff --git a/functions/func.thumbnails.php b/functions/func.thumbnails.php
index 9ba5c3e..d53c4eb 100644
--- a/functions/func.thumbnails.php
+++ b/functions/func.thumbnails.php
@@ -15,7 +15,7 @@
/*
|----------------------------------------------------------------------------------
| Формирование ссылки на миниатюру определённого размера,
- | если размер не указан формируется миниатюра шириной 120px
+ | если размер не указан формируется миниатюра шириной 128px
|----------------------------------------------------------------------------------
| @param array $params - параметры
|
@@ -39,7 +39,9 @@
if (! is_dir($path))
{
- if(! is_dir(dirname($path))) mkdir(dirname($path), 0777);
+ if (! is_dir(dirname($path)))
+ mkdir(dirname($path), 0777, true);
+
mkdir($path, 0777);
}
diff --git a/inc/config.php b/inc/config.php
index 92e301c..57f2b77 100755
--- a/inc/config.php
+++ b/inc/config.php
@@ -150,6 +150,7 @@
$GLOBALS['CMS_CONFIG']['REQUEST_STRIP_TAGS'] = array('DESCR' => 'При - у поля, оставляем теги в результате', 'default'=>'', 'TYPE'=>'string', 'VARIANT'=>'');
$GLOBALS['CMS_CONFIG']['DEV_MODE'] = array('DESCR' => 'Режим разработчика (Отключено кеширование SQL)', 'default'=>false, 'TYPE'=>'bool', 'VARIANT'=>'');
+ $GLOBALS['CMS_CONFIG']['SQL_QUERY_SANITIZE'] = array('DESCR' => 'Принудительно проверять SQL запросы', 'default'=>false, 'TYPE'=>'bool', 'VARIANT'=>'');
include_once(dirname(dirname(__FILE__)) . '/inc/config.inc.php');
diff --git a/inc/sitemap.php b/inc/sitemap.php
index 6fee20d..c475486 100644
--- a/inc/sitemap.php
+++ b/inc/sitemap.php
@@ -11,72 +11,48 @@
* @license GPL v.2
*/
- header("Content-type: text/xml");
- @date_default_timezone_set('Europe/Moscow');
+ header ('Content-type: text/xml');
- define('START_MICROTIME', microtime());
+ define ('START_MICROTIME', microtime());
- define('BASE_DIR', str_replace("\\", "/", rtrim($_SERVER['DOCUMENT_ROOT'],'/')));
+ define ('BASE_DIR', str_replace("\\", "/", rtrim($_SERVER['DOCUMENT_ROOT'],'/')));
if (! @filesize(BASE_DIR . '/inc/db.config.php'))
{
- header('Location: Location:install/index.php');
+ header ('Location: Location:install/index.php');
exit;
}
if (substr($_SERVER['REQUEST_URI'], 0, strlen('/index.php?')) != '/index.php?')
{
- $_SERVER['REQUEST_URI'] = str_ireplace('_', '-', $_SERVER['REQUEST_URI']);
+ $_SERVER['REQUEST_URI'] = str_ireplace('_','-',$_SERVER['REQUEST_URI']);
}
require_once (BASE_DIR . '/inc/init.php');
$abs_path = str_ireplace(BASE_DIR, '/', str_replace("\\", "/", dirname(dirname(__FILE__))));
- if (isset ($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
+ if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
{
- $domain = 'https://' . $_SERVER['SERVER_NAME'];
+ $domain = 'https://'.$_SERVER['SERVER_NAME'];
}
else
{
- $domain = 'http://' . $_SERVER['SERVER_NAME'];
+ $domain = 'http://'.$_SERVER['SERVER_NAME'];
}
-echo '';
-?>
-
-
- UNIX_TIMESTAMP()'
+ ? 'AND doc.document_published < UNIX_TIMESTAMP() AND doc.document_expire > UNIX_TIMESTAMP()'
: '';
- $sql = "
- SELECT
- doc.Id,
- doc.document_alias,
- doc.document_changed,
- doc.document_sitemap_freq,
- doc.document_sitemap_pr
- FROM
- " . PREFIX . "_documents doc
- LEFT JOIN
- " . PREFIX . "_rubrics rub
- ON rub.Id = doc.rubric_id
- LEFT JOIN
- " . PREFIX . "_rubric_permissions rubperm
- ON rubperm.rubric_id = doc.rubric_id
- WHERE
- rub.rubric_template NOT LIKE ''
- AND doc.document_status = 1
- AND doc.document_deleted = 1
- $publish
- AND doc.Id != " . PAGE_NOT_FOUND_ID . "
- AND (document_meta_robots NOT LIKE '%noindex%' or document_meta_robots NOT LIKE '%nofollow%')
- AND (rubperm.user_group_id = 2 AND rubperm.rubric_permission LIKE '%docread%')
- ORDER BY
- doc.Id ASC, doc.document_changed DESC
- ";
+ // Начало
+ $_start = 0;
+ // Конец
+ $_end = 2000;
+
+ // Часть
+ $parts = 1;
$changefreq = array(
'0' => 'always',
@@ -88,18 +64,101 @@ echo '';
'6' => 'never'
);
+ // Вытаскиваем кол-во документов
+ $sql = "
+ SELECT STRAIGHT_JOIN SQL_CALC_FOUND_ROWS
+ COUNT(doc.Id)
+ FROM
+ " . PREFIX . "_documents doc
+ LEFT JOIN
+ " . PREFIX . "_rubrics rub
+ ON rub.Id = doc.rubric_id
+ LEFT JOIN
+ " . PREFIX . "_rubric_permissions rubperm
+ ON rubperm.rubric_id = doc.rubric_id
+ WHERE
+ rub.rubric_template NOT LIKE ''
+ AND doc.document_status = 1
+ AND doc.document_deleted = 1
+ $publish
+ AND doc.Id != " . PAGE_NOT_FOUND_ID . "
+ AND (document_meta_robots NOT LIKE '%noindex%' or document_meta_robots NOT LIKE '%nofollow%')
+ AND (rubperm.user_group_id = 2 AND rubperm.rubric_permission LIKE '%docread%')
+ ";
+
+ $num = $AVE_DB->Query($sql)->GetCell();
+
+ if ($num > $_end)
+ $parts = ceil($num/$_end);
+
+ if (! isset($_REQUEST['id'])):
+ echo '' . PHP_EOL;
+ echo '' . PHP_EOL;
+
+ for ($i = 1; $i <= $parts; $i++):
+?>
+
+ = $domain . '/sitemap-' . $i . '.xml'; ?>
+ = date("c"); ?>
+
+ endfor;
+ echo '';
+ else:
+?>
+
+ if ((int)$_REQUEST['id'] > 1)
+ $_start = ((int)$_REQUEST['id']-1) * $_end;
+
+ $sql = "
+ SELECT STRAIGHT_JOIN SQL_CALC_FOUND_ROWS
+ doc.Id,
+ doc.document_alias,
+ doc.document_published,
+ doc.document_changed,
+ doc.document_sitemap_freq,
+ doc.document_sitemap_pr
+ FROM " . PREFIX . "_documents doc
+ LEFT JOIN " . PREFIX . "_rubrics rub
+ ON rub.Id = doc.rubric_id
+ LEFT JOIN " . PREFIX . "_rubric_permissions rubperm
+ ON rubperm.rubric_id = doc.rubric_id
+ WHERE
+ rub.rubric_template NOT LIKE ''
+ AND doc.document_status = 1
+ AND doc.document_deleted = 1
+ $publish
+ AND doc.Id != " . PAGE_NOT_FOUND_ID . "
+ AND (document_meta_robots NOT LIKE '%noindex%' or document_meta_robots NOT LIKE '%nofollow%')
+ AND (rubperm.user_group_id = 2 AND rubperm.rubric_permission LIKE '%docread%')
+ ORDER BY doc.document_published ASC
+ LIMIT ".$_start.",".$_end."
+ ";
+
$res = $AVE_DB->Query($sql);
- while ($row = $res->FetchAssocArray()):
+ echo '' . PHP_EOL;
+ echo '' . PHP_EOL;
+ if ((int)$_REQUEST['id'] == 1):
+?>
+
+ echo $domain . '/'; ?>
+ echo date("c", time()); ?>
+ weekly
+ 0.8
+
+ endif; ?>
+
+ while($row = $res->FetchAssocArray()):
$document_alias = $abs_path . $row['document_alias'] . URL_SUFF;
$document_alias = $domain . str_ireplace($abs_path . '/' . URL_SUFF, '/', $document_alias);
- $date = $row["document_changed"] ? date("Y-m-d", $row["document_changed"]) : date("Y-m-d");
+ $date = $row["document_published"] ? date("c", $row["document_published"]) : date("c");
?>
-
-
-
-
+ echo $document_alias; ?>
+ echo $date; ?>
+ echo $changefreq[$row['document_sitemap_freq']]; ?>
+ echo $row['document_sitemap_pr']; ?>
-
-
\ No newline at end of file
+ endwhile; ?>
+
+ endif; ?>
\ No newline at end of file
diff --git a/inc/thumb.php b/inc/thumb.php
index 04f82fa..6a43f13 100644
--- a/inc/thumb.php
+++ b/inc/thumb.php
@@ -75,14 +75,14 @@
$allowedExt = array('jpg', 'jpeg', 'png', 'gif', 'JPG', 'JPEG', 'PNG', 'GIF');
//-- Разрешенные размеры миниатюр
- $allowedSize = THUMBNAIL_SIZES
+ $allowedSize = (defined(THUMBNAIL_SIZES) && THUMBNAIL_SIZES != '')
? explode(',', trim(THUMBNAIL_SIZES))
: array();
//-- Разрешения для админпанели
$allowedAdmin = array(
't128x128',
- 'f128x128',
+ 'f128x128'
);
//-- Ссылка на файл
@@ -191,7 +191,7 @@
if (! file_exists("$imagePath/$imageName"))
{
- $l= "$imagePath/$imageName";
+ $l = "$imagePath/$imageName";
if (file_exists($l . '.tmp'))
{
@@ -218,21 +218,20 @@
@unlink($l . '.tmp');
}
-
}
if (! file_exists("$imagePath/$imageName"))
{
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
- $imageName = 'noimage.gif';
+ $imageName = 'default.png';
- if (!file_exists("$imagePath/$imageName"))
+ if (! file_exists("$imagePath/$imageName"))
{
$imagePath = $baseDir . '/' . UPLOAD_DIR . '/images';
}
- if (!file_exists("$imagePath/$imageName"))
+ if (! file_exists("$imagePath/$imageName"))
exit(0);
$save = false;
diff --git a/index.php b/index.php
index 4c394e5..f788a98 100755
--- a/index.php
+++ b/index.php
@@ -150,6 +150,16 @@
$render = str_replace('[tag:rubheader]', $rubheader, $render);
+ // Тут заменяем [tag:rubfooter]
+ // на собранный $GLOBALS["user_footer"]
+ $rubfooter = (empty($GLOBALS['user_footer'])
+ ? ''
+ : implode(chr(10), $GLOBALS['user_footer']));
+
+ $render = str_replace('[tag:rubfooter]', $rubfooter, $render);
+
+ unset ($rubheader, $rubfooter);
+
//-- Header Engine
header('X-Engine: AVE.cms');
header('X-Engine-Copyright: 2007-' . date('Y') . ' (c) AVE.cms');
@@ -161,4 +171,8 @@
//Вывод конечного результата
output_compress($render);
+
+ //Debug::_print($GLOBALS['block_generate']);
+
+ //$AVE_DB->showAllQueries();
?>
\ No newline at end of file
diff --git a/robots.txt b/robots.txt
index 19fac62..3117a78 100644
--- a/robots.txt
+++ b/robots.txt
@@ -3,12 +3,14 @@ Disallow: /admin/
Disallow: /backup/
Disallow: /cache/
Disallow: /class/
+Disallow: /fields/
Disallow: /functions/
Disallow: /inc/
Disallow: /lib/
#Disallow: /modules/
Disallow: /session/
Disallow: /*?sysblock
+Disallow: /*?request
Disallow: /*index.php?module
#Disallow: /templates/
#
|