Browse Source

Fixes

pull/3/head
M@d D3n 4 years ago
parent
commit
144fcec62f
  1. 6
      README.md
  2. 1
      admin/groups.php
  3. 37
      admin/templates/css/color_default.css
  4. 2
      admin/templates/main.tpl
  5. 52
      admin/templates/pop.tpl
  6. 6
      class/class.docs.php
  7. 147
      class/class.registry.php
  8. 2
      class/class.rubs.php
  9. 5
      fields/checkbox/field.php
  10. 4
      fields/code/field.php
  11. 3
      fields/date/field.php
  12. 56
      fields/doc_files/css/field.css
  13. 229
      fields/doc_files/field.php
  14. 83
      fields/doc_files/js/field.js
  15. 9
      fields/doc_files/lang/ru.txt
  16. 5
      fields/doc_files/tpl/field-doc.tpl
  17. 5
      fields/doc_files/tpl/field-req.tpl
  18. 33
      fields/doc_files/tpl/field.tpl
  19. 4
      fields/doc_from_rub/field.php
  20. 4
      fields/doc_from_rub_all/field.php
  21. 4
      fields/doc_from_rub_check/field.php
  22. 28
      fields/doc_from_rub_search/field.php
  23. 81
      fields/download/field.php
  24. 3
      fields/download/lang/bg.txt
  25. 2
      fields/download/lang/cz.txt
  26. 2
      fields/download/lang/en.txt
  27. 2
      fields/download/lang/pl.txt
  28. 2
      fields/download/lang/ru.txt
  29. 2
      fields/download/lang/ua.txt
  30. 7
      fields/download/tpl/field.tpl
  31. 18
      fields/drop_down/field.php
  32. 88
      fields/drop_down_key/field.php
  33. 29
      fields/image_mega/field.php
  34. 27
      fields/image_multi/field.php
  35. 41
      fields/image_single/field.php
  36. 4
      fields/link/field.php
  37. 22
      fields/link_multi/field.php
  38. 5
      fields/multi_checkbox/field.php
  39. 4
      fields/multi_line/field.php
  40. 4
      fields/multi_line_simple/field.php
  41. 4
      fields/multi_line_slim/field.php
  42. 22
      fields/multi_links/field.php
  43. 22
      fields/multi_list/field.php
  44. 7
      fields/multi_list_single/field.php
  45. 24
      fields/multi_list_triple/field.php
  46. 7
      fields/multi_select/field.php
  47. 4
      fields/rubrics/field.php
  48. 3
      fields/single_line/field.php
  49. 3
      fields/single_line_numeric/field.php
  50. 6
      fields/single_line_numeric_three/field.php
  51. 6
      fields/single_line_numeric_two/field.php
  52. 8
      fields/tags/field.php
  53. 7
      fields/teasers/field.php
  54. 3
      fields/text_to_image/field.php
  55. 17
      fields/youtube/field.php
  56. 5
      functions/func.common.php
  57. 42
      functions/func.documents.php
  58. 159
      functions/func.fields.php
  59. 35
      functions/func.parserequest.php
  60. 23
      functions/func.rubrics.php
  61. 2
      functions/func.sysblock.php
  62. 2
      inc/config.php
  63. 6
      inc/init.php
  64. 9
      inc/thumb.php
  65. 5
      index.php

6
README.md

@ -1,4 +1,4 @@
# AVE.cms v3.27
# AVE.cms v3.28
###### Многофункциональная, система управления сайтом.
## Оглавление
@ -33,10 +33,6 @@
6. Следуйте инструкциям.
7. После установки системы настоятельно рекомендуем устанавливать права доступа на папку uploads не выше CHMOD 755.
## MySQL >= 5.7
Cекция [mysqld]
* sql_mode = "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
## Ресурсы
Сайт: [ave-cms.ru](https://ave-cms.ru/)

1
admin/groups.php

@ -20,6 +20,7 @@ if (!defined('ACP'))
global $AVE_Template;
require(BASE_DIR . '/class/class.user.php');
$AVE_User = new AVE_User;
$AVE_Template->config_load(BASE_DIR . '/admin/lang/' . $_SESSION['admin_language'] . '/groups.txt', 'groups');

37
admin/templates/css/color_default.css

@ -889,7 +889,7 @@ div.jGrowl div.accept {
box-sizing:border-box;
border:1px solid #d9dee9;
color:#177bbb!important;
padding:0 5px;
padding:3px 5px;
border-radius:3px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
@ -899,6 +899,41 @@ div.jGrowl div.accept {
color:#177bbb!important;
}
.code.green {
background-color:#1aae88;
border:1px solid #199875;
color:#fff!important;
}
.code.green > a {
color:#fff!important;
}
.code.red {
background-color:#dd1e32;
border:1px solid #ce1e31;
color:#fff!important;
}
.code.red > a {
color:#fff!important;
}
.code.yellow {
background-color: #dda70e;
border:1px solid #db9a01;
color:#fff!important;
}
.code.yellow > a {
color:#fff!important;
}
.docaction .code {
background-color:#f2f4f8;
color:#7f88b4!important;

2
admin/templates/main.tpl

@ -244,7 +244,7 @@
{if check_permission('cache_clear')}
<li class="dropdown"><a href="javascript:void(0);" class="clearCache" title="{#MAIN_STAT_CLEAR_CACHE#}"><img src="{$tpl_dir}/images/icons/subTrash.png" alt="" /><span>{#MAIN_STAT_CLEAR_CACHE#}</span></a>
<ul>
<li><a href="index.php?do=settings&action=showcache&cp={$sess}">{#MAIN_SETTINGS_SHOWCACHE#}</a></li>
<li><a href="index.php?do=settings&action=showcache&cp={$sess}">{#MAIN_SETTINGS_SHOWCACHE#}</a></li>
</ul>
</li>
{/if}

52
admin/templates/pop.tpl

@ -11,7 +11,7 @@
<meta http-equiv="pragma" content="no-cache">
<meta name="generator" content="Notepad" >
<meta name="Expires" content="Mon, 06 Jan 1990 00:00:01 GMT">
<!-- Favicon -->
<link rel="icon" type="image/vnd.microsoft.icon" href="{$ABS_PATH}admin/admin.favicon.ico">
<link rel="SHORTCUT ICON" href="{$ABS_PATH}admin/admin.favicon.ico">
@ -38,30 +38,28 @@
</script>
</head>
<body>
<!-- Wrapper -->
<div class="wrapper">
<!-- Content -->
<div class="content" id="contentPage">
{$content}
</div>
<div class="fix"></div>
</div>
<!-- Footer -->
<div id="footer">
<div class="wrapper">
<span class="floatleft">{#oficial_site#}: {$smarty.const.APP_INFO}</span>
<span class="floatleft ml20">{#support#}: <a href="mailto:support@ave-cms.ru">support@ave-cms.ru</a></span>
<span class="floatright">{$smarty.const.APP_NAME} v{$smarty.const.APP_VERSION}</span>
</div>
</div>
</body>
<body>
<!-- Wrapper -->
<div class="wrapper">
<!-- Content -->
<div class="content" id="contentPage">
{$content}
</div>
<div class="fix"></div>
</div>
<!-- Footer -->
<div id="footer">
<div class="wrapper">
<span class="floatleft">{#oficial_site#}: {$smarty.const.APP_INFO}</span>
<span class="floatleft ml20">{#support#}: <a href="mailto:support@ave-cms.ru">support@ave-cms.ru</a></span>
<span class="floatright">{$smarty.const.APP_NAME} v{$smarty.const.APP_VERSION}</span>
</div>
</div>
<script type="text/javascript" src="{$ABS_PATH}admin/lang/{$smarty.session.admin_language}/scripts.js"></script>
</body>
</html>

6
class/class.docs.php

@ -1268,6 +1268,8 @@
// Запускаем триггер перед сохранением, возвращаем $data для дальнейшего сохранения
$data = Hooks::trigger('DocumentBeforeSave', $data);
$data['rubric_id'] = $rubric_id;
// Выполняем стартовый код рубрики
if ($rubric_code)
eval (' ?'.'>' . $_rubric->rubric_code_start . '<?'.'php ');
@ -1829,7 +1831,6 @@
if ($rubric_code)
eval (' ?'.'>' . $_rubric->rubric_code_end . '<?'.'php ');
// Чистим кеш
$AVE_DB->clearDocument($document_id);
@ -3808,8 +3809,9 @@
exit;
}
$search_query = $_SESSION['search_query'][$document_id] ? true : false;
$search_query = isset($_SESSION['search_query'][$document_id]) ? true : false;
$AVE_Template->assign('rubric_id', $rubric_id);
$AVE_Template->assign('search_query', $search_query);
$AVE_Template->assign($document);
$AVE_Template->assign('content', $AVE_Template->fetch('documents/form_after.tpl'));

147
class/class.registry.php

@ -0,0 +1,147 @@
<?php
class Registry
{
private static $_storage = [];
private static $_instance;
protected function __construct ()
{
//
}
public static function init ()
{
if (self::$_instance == null)
self::$_instance = new self;
return self::$_instance;
}
/*
|--------------------------------------------------------------------------------------
| Установка значения
|--------------------------------------------------------------------------------------
|
*/
public static function set ($key, $value)
{
//if ($key == 'documents')
// Debug::_($value);
return self::$_storage[$key] = $value;
}
/*
|--------------------------------------------------------------------------------------
| Получение значения
|--------------------------------------------------------------------------------------
|
*/
public static function get ($key, $arrkey = null, $default = null)
{
if (empty($arrkey))
return (isset(self::$_storage[$key])) ? self::$_storage[$key] : $default;
else
return (isset(self::$_storage[$key][$arrkey])) ? self::$_storage[$key][$arrkey] : $default;
}
/*
|--------------------------------------------------------------------------------------
| Удаление
|--------------------------------------------------------------------------------------
|
*/
public static function remove ($key, $arrkey = null)
{
if (empty($arrkey))
unset(self::$_storage[$key]);
else
unset(self::$_storage[$key][$arrkey]);
return true;
}
/*
|--------------------------------------------------------------------------------------
| Проверка
|--------------------------------------------------------------------------------------
|
*/
public static function stored ($key, $arrkey = null)
{
if (empty($arrkey))
return isset (self::$_storage[$key]);
else
return isset(self::$_storage[$key][$arrkey]);
}
/*
|--------------------------------------------------------------------------------------
| Очистка
|--------------------------------------------------------------------------------------
|
*/
public static function clean ()
{
self::$_storage = [];
return true;
}
/*
|--------------------------------------------------------------------------------------
| Добавить значение в конец
|--------------------------------------------------------------------------------------
|
*/
public static function addAfter ($key, $value)
{
return self::$_storage[$key] .= $value;
}
/*
|--------------------------------------------------------------------------------------
| Добавить значение в начало
|--------------------------------------------------------------------------------------
|
*/
public static function addBefore ($key, $value)
{
return self::$_storage[$key] = self::$_storage[$key] . $value;
}
/*
|--------------------------------------------------------------------------------------
| Вывод
|--------------------------------------------------------------------------------------
|
*/
public static function output ()
{
return self::$_storage;
}
private function __sleep ()
{
self::$_storage = serialize (self::$_storage);
}
private function __wakeup ()
{
self::$_storage = unserialize (self::$_storage);
}
}
?>

2
class/class.rubs.php

@ -954,7 +954,7 @@
$AVE_DB->clearCache('rub_' . $rubric_id);
$this->clearChanges();
if ($sql->_result === false)
if ($sql !== true)
{
$message = $AVE_Template->get_config_vars('RUBRIK_CODE_SAVED_ERR');
$header = $AVE_Template->get_config_vars('RUBRIK_CODE_ERROR');

5
fields/checkbox/field.php

@ -90,6 +90,11 @@
: null;
break;
case 'api':
$field_value = clean_php($field_value);
$res = ((int)$field_value === 1) ? '1' : '0';
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;

4
fields/code/field.php

@ -102,6 +102,10 @@
return $field_value;
break;
case 'api':
return $field_value;
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;

3
fields/date/field.php

@ -115,6 +115,9 @@
$res = $field_value;
break;
case 'api':
return clean_php($field_value);
break;
case 'name':
return $AVE_Template->get_config_vars('name');

56
fields/doc_files/css/field.css

@ -0,0 +1,56 @@
.doc_files {
position: relative;
}
.doc_files > .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;
}
.doc_files .doc_file {
border: 1px solid #d9dee9;
display: block;
overflow: hidden;
padding: 10px;
width: auto;
border-radius: 5px;
}
.doc_files .doc_file .file_block {
display: block;
float: left;
}
.doc_files .doc_file .handle {
float: left;
display: inline-block;
margin: 4px 7px;
cursor: move;
}
.doc_files .doc_file .file_block .docs_name {
display: block;
width: 400px;
margin-bottom: 5px;
}
.doc_files .doc_file .file_block .docs_desc {
display: block;
width: 400px;
height: 40px;
margin-bottom: 5px;
}
.doc_files .doc_file .file_block .docs_url {
width: 400px;
}

229
fields/doc_files/field.php

@ -0,0 +1,229 @@
<?php
/**
* 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_doc_files($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');
$res = array();
switch ($action)
{
case 'edit':
$items = [];
$items = unserialize($field_value);
if ($items != false)
{
foreach($items as $k => $v)
{
$list_item = explode('|', $v);
$list[$k]['name'] = (isset($list_item[0])) ? htmlspecialchars($list_item[0], ENT_QUOTES) : '';
$list[$k]['descr'] = (isset($list_item[1])) ? htmlspecialchars($list_item[1], ENT_QUOTES) : '';
$list[$k]['url'] = (isset($list_item[2])) ? htmlspecialchars($list_item[2], ENT_QUOTES) : '';
}
$items = $list;
}
else
{
$items = explode(',', $default);
foreach($items as $k => $v)
{
$list_item = explode('|', $v);
$list[$k]['name'] = (isset($list_item[0])) ? htmlspecialchars($list_item[0], ENT_QUOTES) : '';
$list[$k]['descr'] = (isset($list_item[1])) ? htmlspecialchars($list_item[1], ENT_QUOTES) : '';
$list[$k]['url'] = (isset($list_item[2])) ? htmlspecialchars($list_item[2], 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');
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');
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');
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['url']))
{
$field_value_new[] = [
'name' => (isset($v['name']) ? $v['name'] : ''),
'descr' => (isset($v['descr']) ? $v['descr'] : ''),
'url' => $v['url']
];
}
}
if (isset($field_value_new))
{
return @serialize($field_value_new);
}
else
{
return $field_value_new = '';
}
break;
case 'api':
if (empty($field_value))
return $field_value;
$items = unserialize($field_value);
if ($items != false)
{
foreach($items as $k => $v)
{
$list_item = explode('|', $v);
$list[$k]['name'] = (isset($list_item[0])) ? htmlspecialchars($list_item[0], ENT_QUOTES) : '';
$list[$k]['descr'] = (isset($list_item[1])) ? htmlspecialchars($list_item[1], ENT_QUOTES) : '';
$list[$k]['url'] = (isset($list_item[2])) ? htmlspecialchars($list_item[2], ENT_QUOTES) : '';
}
$items = $list;
}
return $items;
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;
}
return ($res ? $res : $field_value);
}
?>

83
fields/doc_files/js/field.js

@ -0,0 +1,83 @@
var DocFiles = {
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;
$('#doc_files_' + id).children('.doc_file').each(function() {
maxid = Math.max(maxid, parseInt($(this).attr("data-id")) + 1);
});
return maxid;
},
lists_del_item: function() {
$('.doc_file .DelButton').on('click', function(event) {
event.preventDefault();
var id = $(this).attr('data-id');
jConfirm(
links_del_conf,
links_del_head,
function(b) {
if (b) {
$('#link_' + id).remove();
}
}
);
});
},
lists_add: function() {
$('.doc_files .AddButton').on('click', function(event) {
event.preventDefault();
c_id = $(this).parent().parent().parent('.doc_files').attr("data-id");
iid = DocFiles.lists_maxid(c_id);
$('#doc_files_' + c_id + ':last').append(
'<div class="doc_file fix mb10" id="link_' + c_id + '_' + iid + '" data-id="' + iid + '">' +
'<div class="handle">' +
'<span class="icon_sprite ico_move"></span>' +
'</div>' +
'<div class="file_block">' +
'<input type="text" class="mousetrap docs_name" value="" name="feld[' + c_id + '][' + iid + '][name]" placeholder="' + links_name + '"/>' +
'<textarea class="mousetrap docs_desc" name="feld[' + c_id + '][' + iid + '][descr]" placeholder="' + links_desc + '"></textarea>' +
'<input type="text" class="mousetrap docs_url" value="" name="feld[' + c_id + '][' + iid + '][url]" id="links_' + c_id + '_' + iid + '" placeholder="' + links_url + '" />&nbsp;' +
'<a class="btn greyishBtn" onclick="openFileWindow(\'links_' + c_id + '_' + iid + '\',\'links_' + c_id + '_' + iid + '\',\'links_' + c_id + '_' + iid + '\');">FILE</a>&nbsp;&nbsp;<a href="javascript:void(0);" data-id="' + c_id + '_' + iid + '" class="button redBtn topDir DelButton" title="' + links_del + '">&times;</a>' +
'</div>' +
'</div>'
);
DocFiles.lists_update();
});
},
lists_sortable: function() {
$('.doc_files').sortable({
handle: ".handle",
placeholder: "ui-state-highlight grey_bg"
});
}
}
$(document).ready(function() {
DocFiles.init();
});

9
fields/doc_files/lang/ru.txt

@ -0,0 +1,9 @@
[admin]
name = "Файлы документов"
delete = "Удалить элемент"
param_name = "Наименование"
param_desc = "Описание"
param_url = "Ссылка"
del_conf = "Вы уверены, что хотите удалить данный элемент?"
del_head = "Удаление элемента..."
add = "Добавить"

5
fields/doc_files/tpl/field-doc.tpl

@ -0,0 +1,5 @@
<ul>
{foreach from=$field_value item=list}
<li>{$list[0]}: {$list[1]}</li>
{/foreach}
</ul>

5
fields/doc_files/tpl/field-req.tpl

@ -0,0 +1,5 @@
<ul>
{foreach from=$field_value item=list}
<li>{$list[0]}: {$list[1]}</li>
{/foreach}
</ul>

33
fields/doc_files/tpl/field.tpl

@ -0,0 +1,33 @@
{if $doc_files != load}
{assign var=doc_files value='' scope="global"}
<script src="{$ABS_PATH}fields/{$field_dir}/js/field.js" type="text/javascript"></script>
<link href="{$ABS_PATH}fields/{$field_dir}/css/field.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript">
var links_name = '{#param_name#}';
var links_desc = '{#param_desc#}';
var links_url = '{#param_url#}';
var links_add = '{#add#}';
var links_del = '{#delete#}';
var links_del_conf = '{#del_conf#}';
var links_del_head = '{#del_head#}';
</script>
{assign var=doc_files value="load" scope="global"}
{/if}
<div class="doc_files mt10" id="doc_files_{$field_id}" data-id="{$field_id}">
{foreach from=$items key=key item=item}
<div class="doc_file fix mb10" id="link_{$field_id}_{$key}" data-id="{$key}">
<div class="handle">
<span class="icon_sprite ico_move"></span>
</div>
<div class="file_block">
<input type="text" class="mousetrap docs_name" value="{$item.name|escape}" name="feld[{$field_id}][{$key}][name]" placeholder="{#param_name#}"/>
<textarea class="mousetrap docs_desc" name="feld[{$field_id}][{$key}][descr]" placeholder="{#param_desc#}">{$item.descr|escape}</textarea>
<input type="text" class="mousetrap docs_url" value="{$item.url|escape}" name="feld[{$field_id}][{$key}][url]" id="links_{$field_id}_{$key}" placeholder="{#param_url#}" />
<a class="btn greyishBtn" onclick="openFileWindow('links_{$field_id}_{$key}','links_{$field_id}_{$key}','links_{$field_id}_{$key}');">FILE</a>&nbsp;&nbsp;{if $key == 0}<a href="javascript:void(0);" class="button basicBtn topDir AddButton" title="{#add#}">+</a>{else}<a href="javascript:void(0);" data-id="{$field_id}_{$key}" class="button redBtn topDir DelButton" title="{#delete#}">&times;</a>{/if}
</div>
</div>
{/foreach}
</div>

4
fields/doc_from_rub/field.php

@ -148,6 +148,10 @@
$res = $field_value;
break;
case 'api':
return $field_value;
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;

4
fields/doc_from_rub_all/field.php

@ -137,6 +137,10 @@
$res = $field_value;
break;
case 'api':
return $field_value;
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;

4
fields/doc_from_rub_check/field.php

@ -170,6 +170,10 @@
return (!empty($res)) ? implode(PHP_EOL, $res) : $tpl;
break;
case 'api':
return $field_value;
break;
case 'name' :
return $AVE_Template->get_config_vars('name');
break;

28
fields/doc_from_rub_search/field.php

@ -172,6 +172,34 @@
return (! empty($res)) ? implode(PHP_EOL, $res) : $tpl;
break;
case 'api' :
$items = [];
if ($field_value != '' && $field_value != $default)
{
$items = explode('|', $field_value);
$items = array_values(array_diff($items, array('')));
}
if (! empty($items))
{
foreach($items as $k => $v)
{
$list[$k]['param'] = htmlspecialchars_decode(get_document($v, 'document_title'), ENT_QUOTES);
$list[$k]['value'] = $v;
}
$items = $list;
}
else
{
$items[0]['param'] = '';
$items[0]['value'] = '';
}
return $items;
break;
case 'name' :
return $AVE_Template->get_config_vars('name');
break;

81
fields/download/field.php

@ -0,0 +1,81 @@
<?php
/**
* 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] . '<br />' : '')
. '<form method="get" target="_blank" action="' . $field_param[0]
. '"><input class="basicBtn" type="submit" value="Скачать" /></form>';
}
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 'api' :
return htmlspecialchars_decode($field_value, ENT_QUOTES);
break;
case 'name' :
return $AVE_Template->get_config_vars('name');
break;
}
return ($res ? $res : $field_value);
}
?>

3
fields/download/lang/bg.txt

@ -0,0 +1,3 @@
[admin]
name = "Линк към файл"

2
fields/download/lang/cz.txt

@ -0,0 +1,2 @@
[admin]
name = "Soubor ke stažení"

2
fields/download/lang/en.txt

@ -0,0 +1,2 @@
[admin]
name = "Download file"

2
fields/download/lang/pl.txt

@ -0,0 +1,2 @@
[admin]
name = "Pobierz plik"

2
fields/download/lang/ru.txt

@ -0,0 +1,2 @@
[admin]
name = "Загрузить файл"

2
fields/download/lang/ua.txt

@ -0,0 +1,2 @@
[admin]
name = "Завантажити файл"

7
fields/download/tpl/field.tpl

@ -0,0 +1,7 @@
<div style="" id="feld_{$field_id}"><a name="{$field_id}"></a>
<div style="display:none" id="feld_{$field_id}">
<img style="display:none" id="_img_feld__{$field_id}" src="{$field_value}" alt="" border="0" /></div>
<div style="display:none" id="span_feld__{$field_id}"></div>
<input class="mousetrap" type="text" style="width: 400px;" name="feld[{$field_id}]" value="{$field_value|escape}" id="img_feld__{$field_id}" />&nbsp;
<input value="{#MAIN_OPEN_MEDIAPATH#}"" class="basicBtn" type="button" onclick="browse_uploads('img_feld__{$field_id}', '', '', '0');" />&nbsp;
<a class="button blackBtn topDir" title="{#DOC_FILE_TYPE_HELP#}" href="#">?</a>

18
fields/drop_down/field.php

@ -12,7 +12,7 @@
*/
// Выпадающий список
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)
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;
@ -34,7 +34,7 @@
$items = explode(',', $default);
$items = array_diff($items, array(''));
$tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
$tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
$AVE_Template->assign('items', $items);
$AVE_Template->assign('field_id', $field_id);
@ -45,8 +45,7 @@
case 'doc':
@$field_value = clean_php($field_value);
if (! $tpl_empty)
if (!$tpl_empty)
{
$field_param = explode('|', $field_value);
$field_value = preg_replace_callback(
@ -58,14 +57,12 @@
$tpl
);
}
$res = $field_value;
break;
case 'req':
@$field_value = clean_php($field_value);
if (! $tpl_empty)
if (!$tpl_empty)
{
$field_param = explode('|', $field_value);
$field_value = preg_replace_callback(
@ -77,10 +74,13 @@
$tpl
);
}
$res = $field_value;
break;
case 'api':
return $field_value;
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;
@ -88,4 +88,4 @@
}
return ($res ? $res : $field_value);
}
?>
?>

88
fields/drop_down_key/field.php

@ -12,7 +12,7 @@
*/
// Выпадающий список (Ключ)
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)
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;
@ -33,7 +33,7 @@
$items = explode(',', $default);
$items = array_diff($items, array(''));
$tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
$tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
$AVE_Template->assign('items', $items);
$AVE_Template->assign('field_id', $field_id);
@ -43,29 +43,81 @@
break;
case 'doc':
case 'req':
@$field_value = clean_php($field_value);
if (!$tpl_empty)
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
);
$key = (int)$field_value;
$items = explode(',', $default);
$items = array_diff($items, array(''));
$field_value = isset($items[$key])
? trim($items[$key])
: '';
}
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);
$AVE_Template->assign('key', $key);
$AVE_Template->assign('default', $default);
$AVE_Template->assign('field_value', $field_value);
return $AVE_Template->fetch($tpl_file);
}
$res = $field_value;
break;
case 'req':
if ($tpl_empty)
{
$key = (int)$field_value;
$items = explode(',', $default);
$items = array_diff($items, array(''));
$field_value = $items[$field_value];
$field_value = isset($items[$key])
? trim($items[$key])
: '';
}
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);
$AVE_Template->assign('key', $key);
$AVE_Template->assign('default', $default);
$AVE_Template->assign('field_value', $field_value);
return $AVE_Template->fetch($tpl_file);
}
$res = $field_value;
break;
return $field_value = ($field_value != '') ? $field_value : '';
case 'api':
return $field_value;
break;
case 'name':
@ -75,4 +127,4 @@
}
return ($res ? $res : $field_value);
}
?>
?>

29
fields/image_mega/field.php

@ -318,6 +318,35 @@
break;
case 'api':
if (empty($field_value))
return $field_value;
$items = [];
if (! empty($field_value))
{
$images = unserialize($field_value);
if (! $images)
return false;
foreach ($images AS $k => $v)
{
$_item = explode('|', $v);
$items[$k] = [
'url' => $_item[0],
'title' => (isset($_item[1]) ? $_item[1] : ''),
'description' => (isset($_item[2]) ? $_item[2] : ''),
'link' => (isset($_item[3]) ? $_item[3] : '')
];
}
}
return $items;
break;
case 'name' :
return $AVE_Template->get_config_vars('name');
break;

27
fields/image_multi/field.php

@ -272,6 +272,33 @@
break;
case 'api':
if (empty($field_value))
return $field_value;
$items = [];
if (! empty($field_value))
{
$images = unserialize($field_value);
if (! $images)
return false;
foreach ($images AS $k => $v)
{
$_item = explode('|', $v);
$items[$k] = [
'url' => $_item[0],
'descr' => (isset($_item[1]) ? $_item[2] : ''),
];
}
}
return $items;
break;
case 'name' :
return $AVE_Template->get_config_vars('name');
break;

41
fields/image_single/field.php

@ -12,7 +12,7 @@
*/
// Изображение
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)
function get_field_image_single($field_value, $action, $field_id = 0, $tpl = '', $tpl_empty = false, &$maxlength = null, $document_fields = array(), $rubric_id = 0, $default = null, $_tpl = null)
{
global $AVE_Template;
@ -64,21 +64,28 @@
{
$field_value = preg_replace_callback(
'/\[tag:parametr:(\d+)\]/i',
function($data) use ($field_param)
function($data) use($field_param)
{
return $field_param[(int)$data[1]];
},
$tpl
);
$field_value = preg_replace_callback('/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/', 'watermarks', $field_value);
$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);
$tpl_file = get_field_tpl ($tpl_dir, $field_id, 'doc', $_tpl);
if($tpl_empty && $tpl_file)
if ($tpl_empty && $tpl_file)
{
$AVE_Template->assign('image', $field_param);
return $AVE_Template->fetch($tpl_file);
@ -91,6 +98,8 @@
$field_value = clean_php($field_value);
$field_param = explode('|', $field_value);
$field_param['name'] = preg_replace('/\\.[^.\\s]{3,4}$/', '', $field_param[0]);
$field_param['ext'] = getExtension($field_param[0]);
if ($tpl_empty)
{
@ -101,14 +110,21 @@
{
$field_value = preg_replace_callback(
'/\[tag:parametr:(\d+)\]/i',
function($data) use ($field_param)
function($data) use($field_param)
{
return $field_param[(int)$data[1]];
},
$tpl
);
$field_value = preg_replace_callback('/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/', 'watermarks', $field_value);
$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);
}
@ -117,7 +133,7 @@
$tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
if($tpl_empty && $tpl_file)
if ($tpl_empty && $tpl_file)
{
$AVE_Template->assign('image', $field_param);
return $AVE_Template->fetch($tpl_file);
@ -137,6 +153,15 @@
}
break;
case 'api':
if (empty($field_value))
return $field_value;
$image = explode('|', $field_value);
return ['img' => $image[0], 'descr' => isset($image[1]) ? $image[1] : ''];
break;
case 'name' :
return $AVE_Template->get_config_vars('name');
break;

4
fields/link/field.php

@ -90,6 +90,10 @@
$res = $field_value;
break;
case 'api' :
return clean_php($field_value);
break;
case 'name' :
return $AVE_Template->get_config_vars('name');
break;

22
fields/link_multi/field.php

@ -184,6 +184,28 @@
}
break;
case 'api':
if (empty($field_value))
return $field_value;
$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;
}
return $items;
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;

5
fields/multi_checkbox/field.php

@ -153,11 +153,16 @@ function get_field_multi_checkbox($field_value, $action, $field_id=0, $tpl='', $
break;
case 'api':
return $field_value;
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;
}
return ($res ? $res : $field_value);
}
?>

4
fields/multi_line/field.php

@ -62,6 +62,10 @@
$res = get_field_default($field_value, $action, $field_id, $tpl, $tpl_empty, $maxlength, $document_fields, $rubric_id);
break;
case 'api':
$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;

4
fields/multi_line_simple/field.php

@ -62,6 +62,10 @@
$res = get_field_default($field_value,$action,$field_id,$tpl,$tpl_empty,$maxlength,$document_fields,$rubric_id);
break;
case 'api':
$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;

4
fields/multi_line_slim/field.php

@ -62,6 +62,10 @@
$res = get_field_default($field_value,$action,$field_id,$tpl,$tpl_empty,$maxlength,$document_fields,$rubric_id);
break;
case 'api':
$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;

22
fields/multi_links/field.php

@ -184,6 +184,28 @@ function get_field_multi_links($field_value, $action, $field_id=0, $tpl='', $tpl
}
break;
case 'api':
if (empty($field_value))
return $field_value;
$items = unserialize($field_value);
if ($items != false)
{
foreach($items as $k => $v){
$list_item = explode('|', $v);
$list[$k]['param'] = (isset($list_item[0])) ? htmlspecialchars_decode($list_item[0], ENT_QUOTES) : '';
$list[$k]['value'] = (isset($list_item[1])) ? htmlspecialchars_decode($list_item[1], ENT_QUOTES) : '';
}
$items = $list;
}
return $items;
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;

22
fields/multi_list/field.php

@ -184,6 +184,28 @@
}
break;
case 'api':
if (empty($field_value))
return $field_value;
$items = unserialize($field_value);
if ($items != false)
{
foreach($items as $k => $v)
{
$list_item = explode('|', $v);
$list[$k]['param'] = (isset($list_item[0])) ? htmlspecialchars_decode($list_item[0], ENT_QUOTES) : '';
$list[$k]['value'] = (isset($list_item[1])) ? htmlspecialchars_decode($list_item[1], ENT_QUOTES) : '';
}
$items = $list;
}
return $items;
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;

7
fields/multi_list_single/field.php

@ -167,6 +167,13 @@
}
break;
case 'api':
if (empty($field_value))
return $field_value;
return unserialize($field_value);
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;

24
fields/multi_list_triple/field.php

@ -189,6 +189,30 @@
}
break;
case 'api':
if (empty($field_value))
return $field_value;
$items = unserialize($field_value);
if ($items != false)
{
foreach($items as $k => $v)
{
$list_item = explode('|', $v);
$list[$k]['param'] = (isset($list_item[0])) ? htmlspecialchars_decode($list_item[0], ENT_QUOTES) : '';
$list[$k]['value'] = (isset($list_item[1])) ? htmlspecialchars_decode($list_item[1], ENT_QUOTES) : '';
$list[$k]['value2'] = (isset($list_item[2])) ? htmlspecialchars_decode($list_item[2], ENT_QUOTES) : '';
}
$items = $list;
}
return $items;
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;

7
fields/multi_select/field.php

@ -148,6 +148,13 @@
return (!empty($res)) ? implode(PHP_EOL, $res) : $tpl;
break;
case 'api':
if (empty($field_value))
return $field_value;
return unserialize($field_value);
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;

4
fields/rubrics/field.php

@ -73,6 +73,10 @@ function get_field_rubrics($field_value, $action, $field_id = 0, $tpl = '', $tpl
$res = $field_value;
break;
case 'api':
return $field_value;
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;

3
fields/single_line/field.php

@ -113,6 +113,9 @@
case 'save':
return $field_value;
case 'api':
return $field_value;
case 'name':
return $AVE_Template->get_config_vars('name');

3
fields/single_line_numeric/field.php

@ -106,6 +106,9 @@
$field_value = preg_replace('/[^\d.]/','',$field_value);
return $field_value;
case 'api':
return $field_value;
case 'name':
return $AVE_Template->get_config_vars('name');

6
fields/single_line_numeric_three/field.php

@ -125,6 +125,12 @@
return empty($save) ? '' : implode('|', $save);
case 'api':
if (! empty($field_value))
$field_value = explode('|', $field_value);
return $field_value;
case 'name':
return $AVE_Template->get_config_vars('name');

6
fields/single_line_numeric_two/field.php

@ -125,6 +125,12 @@
return empty($save) ? '' : implode('|', $save);
case 'api':
if (! empty($field_value))
$field_value = explode('|', $field_value);
return $field_value;
case 'name':
return $AVE_Template->get_config_vars('name');

8
fields/tags/field.php

@ -161,6 +161,14 @@
return $field_value;
case 'api':
if (! empty($field_value))
{
$field_value = explode('|', $field_value);
$field_value = array_diff($field_value, ['']);
}
return $field_value;
case 'name':
return $AVE_Template->get_config_vars('name');

7
fields/teasers/field.php

@ -90,6 +90,13 @@
case 'req':
return get_field_default($field_value, $action, $field_id, $tpl, $tpl_empty);
case 'api' :
if (! empty($field_value))
return unserialize($field_value);
return $field_value;
break;
case 'name' :
return $AVE_Template->get_config_vars('name');
break;

3
fields/text_to_image/field.php

@ -119,6 +119,9 @@
case 'name':
return $AVE_Template->get_config_vars('name');
case 'api':
return $field_value;
default: return $field_value;
}
}

17
fields/youtube/field.php

@ -134,6 +134,23 @@
}
break;
case 'api':
if (empty($field_value))
return $field_value;
$_video = explode('|', $field_value);
$video = [
'url' => (isset($_video[0]) ? $_video[0] : ''),
'width' => (isset($_video[1]) ? $_video[1] : ''),
'height' => (isset($_video[2]) ? $_video[2] : ''),
'fullscreen' => (isset($_video[3]) ? $_video[3] : ''),
'source' => (isset($_video[4]) ? $_video[4] : '')
];
return $video;
break;
// Тип/Имя поля в административной части
case 'name' :
return $AVE_Template->get_config_vars('name');

5
functions/func.common.php

@ -1116,6 +1116,9 @@
if (defined('HTML_COMPRESSION') && HTML_COMPRESSION)
$data = compress_htlm($data);
if (isset($_REQUEST['sysblock']))
define('ONLYCONTENT', true);
//-- Вывод статистики загрузки и запросов SQL (только для администраторов)
if (! defined('ONLYCONTENT') && UGROUP == 1)
{
@ -1380,7 +1383,7 @@
return false;
}
if (!function_exists('getExtension'))
if (! function_exists('getExtension'))
{
function getExtension($path)
{

42
functions/func.documents.php

@ -87,26 +87,32 @@
if ($doc_id < 1)
return [];
/*
if (defined('USE_STATIC_DATA') && USE_STATIC_DATA)
static $get_documents_data = [];
else
$get_documents_data = [];
*/
if (! isset ($get_documents_data[$doc_id]))
{
$get_documents_data[$doc_id] = getDocument($doc_id);
$get_documents_data[$doc_id] = object2array($get_documents_data[$doc_id]);
if (! (Registry::stored('documents', $doc_id)))
$documents_data = getDocument($doc_id);
else
$documents_data = Registry::get('documents', $doc_id);
$get_documents_data[$doc_id]['doc_title'] = $get_documents_data[$doc_id]['document_title'] = htmlspecialchars_decode($get_documents_data[$doc_id]['document_title'], ENT_QUOTES);
$get_documents_data[$doc_id]['feld'] = [];
}
if (! is_object($documents_data))
return false;
$documents_data = object2array($documents_data);
$documents_data['doc_title'] = $documents_data['document_title'] = htmlspecialchars_decode($documents_data['document_title'], ENT_QUOTES);
$documents_data['feld'] = [];
if (isset($key) && $key != '')
return $get_documents_data[$doc_id][$key];
return $documents_data[$key];
else
return $get_documents_data[$doc_id];
return $documents_data;
}
@ -121,11 +127,16 @@
{
global $AVE_DB;
if (! defined('USE_STATIC_DATA') || ! USE_STATIC_DATA)
Registry::clean();
$doc_id = (int)$doc_id;
if ($doc_id < 1)
return false;
$documents = Registry::get('documents');
$sql = "
SELECT
# DOCUMENT = $doc_id
@ -145,7 +156,16 @@
$data = $AVE_DB->Query($sql, $cache_time, 'dat_' . $doc_id, true, '.data')->FetchRow();
return $data;
if (! is_object($data))
return false;
$documents[$data->Id] = $data;
Registry::set('documents', $documents);
unset ($documents);
return Registry::get('documents', $doc_id);
}

159
functions/func.fields.php

@ -155,19 +155,16 @@
* @param $id
* @return string
*/
function get_field_alias ($id)
function get_field_alias ($field_id)
{
global $AVE_DB, $fields_data;
if (! Registry::stored('fields_params', $field_id))
_get_field_params($field_id);
if (! isset($fields_data))
static $fields_data = [];
$alias = Registry::get('fields_params', $field_id);
if (isset($fields_data[$id]))
return $fields_data[$id]['alias'];
$alias = $alias['rubric_field_alias'] ? $alias['rubric_field_alias'] : $field_id;
$fields_data[$id]['alias'] = $AVE_DB->Query("SELECT rubric_field_alias FROM " . PREFIX . "_rubric_fields WHERE Id=" . intval($id))->GetCell();
return $fields_data[$id]['alias'];
return $alias;
}
@ -247,29 +244,29 @@
*
* @return string
*/
function get_field_tpl($dir = '', $field_id = 0, $type = 'admin', $_tpl = null)
function get_field_tpl ($dir = '', $field_id = 0, $type = 'admin', $_tpl = null)
{
if (! $type)
return false;
$alias_field_id = get_field_alias($field_id);
// Если существет файл с ID поля и ID шаблона
// Если существует файл с ID поля и ID шаблона
if (file_exists($dir.'field-'.$type.'-'.$field_id.'-'.$_tpl.'.tpl'))
$tpl = $dir.'field-'.$type.'-'.$field_id.'-'.$_tpl.'.tpl';
// Если существет файл с аласом поля и ID шаблона
// Если существует файл с аласом поля и ID шаблона
else if (file_exists($dir.'field-'.$type.'-'.$alias_field_id.'-'.$_tpl.'.tpl'))
$tpl = $dir.'field-'.$type.'-'.$alias_field_id.'-'.$_tpl.'.tpl';
// Если существет файл с ID поля
// Если существует файл с 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 типом поля
// Если существует файл c типом поля
else if (file_exists($dir.'field-'.$type.'.tpl'))
$tpl = $dir.'field-'.$type.'.tpl';
// Если существет файл c ID поля
// Если существует файл c ID поля
else if (file_exists($dir.'field-'.$field_id.'.tpl'))
$tpl = $dir.'field-'.$field_id.'.tpl';
// Иначе
@ -393,7 +390,10 @@
*/
function get_document_field ($document_id, $field)
{
$document_fields = get_document_fields($document_id);
if (Registry::stored($document_id, $field))
$document_fields = Registry::get($document_id, $field);
else
$document_fields = get_document_fields($document_id);
if (! is_array($document_fields[$field]))
$field = intval($document_fields[$field]);
@ -417,25 +417,30 @@
*/
function get_document_fields ($document_id, $values = null)
{
global $AVE_DB, $AVE_Core, $fields_data; //$request_documents
if (defined('USE_STATIC_DATA') && USE_STATIC_DATA)
static $document_fields = [];
else
$document_fields = [];
global $AVE_DB, $AVE_Core; //$request_documents
if (! is_numeric($document_id))
return false;
static $rubric_changed_fields = [];
if (! defined('USE_STATIC_DATA') || ! USE_STATIC_DATA)
Registry::clean();
if (Registry::stored('fields', $document_id))
return Registry::get('fields', $document_id);
$document_fields = Registry::get('fields');
$fields_param = Registry::get('fields_param');
if (Registry::stored('rubric_changeds'))
$rubric_changed_fields = Registry::get('rubric_changeds');
else
$rubric_changed_fields = get_rubrics_changes();
if (! isset($AVE_Core) || $AVE_Core->curentdoc->Id != $document_id)
{
if (! isset($rubric_changed_fields[$document_id]))
$rubric_id = get_document($document_id, 'rubric_id');
$rubric_changed_fields[$document_id] = get_rubrics_changes($rubric_id, 'rubric_changed_fields');
$rubric_id = get_document($document_id, 'rubric_id');
$cache_time = $rubric_changed_fields[$document_id];
$cache_time = $rubric_changed_fields[$rubric_id]['rubric_changed_fields'];
}
else
{
@ -459,9 +464,11 @@
doc_field.rubric_field_id,
doc_field.field_value,
text_field.field_value AS field_value_more,
rub_field.rubric_id,
rub_field.rubric_field_alias,
rub_field.rubric_field_type,
rub_field.rubric_field_default,
rub_field.rubric_field_numeric,
rub_field.rubric_field_title,
rub_field.rubric_field_template,
rub_field.rubric_field_template_request
@ -518,7 +525,9 @@
$row['field_value'] = (string)$row['field_value'] . (string)$row['field_value_more'];
if ($values)
$row['field_value'] = (isset($values[$row['rubric_field_id']]) ? $values[$row['rubric_field_id']] : $row['field_value']);
$row['field_value'] = (isset($values[$row['rubric_field_id']])
? $values[$row['rubric_field_id']]
: $row['field_value']);
if ($row['field_value'] === '')
{
@ -537,14 +546,49 @@
$row['rubric_field_template'] = trim(str_replace(['[tag:if_notempty]','[/tag:if_notempty]'], '', $row['rubric_field_template']));
}
$document_fields[$row['document_id']][$row['rubric_field_id']] = $row;
//$document_fields[$row['document_id']][$row['rubric_field_id']] = $row;
$document_fields[$row['document_id']][$row['rubric_field_alias']] = $row['rubric_field_id'];
$fields_data[$row['rubric_field_id']]['alias'] = $row['rubric_field_alias'];
$document_fields[$document_id][$row['rubric_field_id']] = [
'Id' => $row['Id'],
'document_id' => $row['document_id'],
'document_author_id' => $row['document_author_id'],
'rubric_field_id' => $row['rubric_field_id'],
'field_value' => $row['field_value'],
'field_value_more' => $row['field_value_more'],
'tpl_req_empty' => $row['tpl_req_empty'],
'tpl_field_empty' => $row['tpl_field_empty'],
'rubric_id' => $row['rubric_id'],
'rubric_field_alias' => $row['rubric_field_alias'],
'rubric_field_type' => $row['rubric_field_type'],
'rubric_field_default' => $row['rubric_field_default'],
'rubric_field_numeric' => $row['rubric_field_numeric'],
'rubric_field_title' => $row['rubric_field_title'],
'rubric_field_template' => $row['rubric_field_template'],
'rubric_field_template_request' => $row['rubric_field_template_request'],
];
$fields_param[$row['rubric_field_id']] = [
'rubric_id' => $row['rubric_id'],
'rubric_field_alias' => $row['rubric_field_alias'],
'rubric_field_type' => $row['rubric_field_type'],
'rubric_field_default' => $row['rubric_field_default'],
'rubric_field_numeric' => $row['rubric_field_numeric'],
'rubric_field_title' => $row['rubric_field_title'],
];
}
}
return $document_fields[$document_id];
Registry::set('fields', $document_fields);
if (! Registry::stored('fields_param', $row['rubric_field_id']))
Registry::set('fields_param', $fields_param);
unset ($document_fields, $rubric_changed_fields, $fields_param);
return Registry::get('fields', $document_id);
}
@ -791,6 +835,55 @@
}
/**
* Возвращает параметры поля
*
* @param int $field_id ([tag:fld:X]) - номер поля
*
* @return void
*/
function _get_field_params ($field_id)
{
global $AVE_DB;
if (Registry::stored('fields_params', $field_id))
return Registry::get('fields_params', $field_id);
$fields_param = Registry::get('fields_params');
$query = "
SELECT
rubric_id,
rubric_field_alias,
rubric_field_type,
rubric_field_default,
rubric_field_numeric,
rubric_field_title
FROM
" . PREFIX . "_rubric_fields
WHERE
Id = '" . $field_id . "'
LIMIT 0,1
# FIELDS PARAMS = $field_id
";
$row = $AVE_DB->Query($query)->FetchAssocArray();
$fields_param[$field_id] = [
'rubric_id' => $row['rubric_id'],
'rubric_field_alias' => $row['rubric_field_alias'],
'rubric_field_type' => $row['rubric_field_type'],
'rubric_field_default' => $row['rubric_field_default'],
'rubric_field_numeric' => $row['rubric_field_numeric'],
'rubric_field_title' => $row['rubric_field_title'],
];
Registry::set('fields_params', $fields_param);
unset ($query, $row, $fields_param);
}
/**
* Возвращает поле документа по номеру
*

35
functions/func.parserequest.php

@ -19,7 +19,7 @@
*
* @return string
*/
function request_get_settings($id)
function request_get_settings ($id)
{
global $AVE_DB;
@ -53,7 +53,7 @@
*
* @return array
*/
function request_get_condition_sql_string($id, $update_db = false)
function request_get_condition_sql_string ($id, $update_db = false)
{
global $AVE_DB, $AVE_Core;
@ -270,6 +270,7 @@
$document_fields = get_document_fields($document_id);
// ToDo
if (! is_array($document_fields[$field_id]))
$field_id = intval($document_fields[$field_id]);
@ -325,7 +326,7 @@
$maxlength = abs($maxlength);
}
// ToDo - сделать настройки окончаний
// ToDo - сделать настройки окончаний = Уже есть в Доп настройках
if ($maxlength != 0)
{
$field_value = truncate($field_value, $maxlength, REQUEST_ETC, REQUEST_BREAK_WORDS);
@ -339,7 +340,7 @@
return $field_value;
}
function showteaser($id, $tparams = '')
function showteaser ($id, $tparams = '')
{
$item = showrequestelement($id, '', $tparams);
$item = str_replace('[tag:path]', ABS_PATH, $item);
@ -350,7 +351,7 @@
// Функция получения уникальных параметров для каждого тизера
function f_params_of_teaser($id_param_array,$num)
function f_params_of_teaser ($id_param_array,$num)
{
global $params_of_teaser;
return $params_of_teaser[$id_param_array][$num];
@ -358,7 +359,7 @@
// Функция получения элемента запроса
function showrequestelement($mixed, $template = '', $tparams = '')
function showrequestelement ($mixed, $template = '', $tparams = '')
{
global
$AVE_DB,
@ -388,7 +389,7 @@
if ($tparams != '')
{
$tparams_id = $row->Id . md5($tparams); // Создаем уникальный id для каждого набора параметров
$params_of_teaser[$tparams_id] = []; // Для отмены лишних ворнингов
$params_of_teaser[$tparams_id] = []; // Для отмены лишних ворнингов
$tparams = trim($tparams,'[]:'); // Удаляем: слева ':[', справа ']'
$params_of_teaser[$tparams_id] = explode('|',$tparams); // Заносим параметры в массив уникального id
}
@ -610,7 +611,11 @@
// Кол-во просмотров
$item = str_replace('[tag:docviews]', $row->document_count_view, $item);
unset($row);
Registry::remove('documents', $row->Id);
Registry::remove('fields', $row->Id);
Registry::remove('fields_param', $row->Id);
unset($row, $template);
return $item;
}
@ -625,7 +630,7 @@
*
* @return string
*/
function request_parse($id, $params = [])
function request_parse ($id, $params = [])
{
global $AVE_Core, $AVE_DB, $request_documents;
@ -862,7 +867,7 @@
$sql = " ?>
SELECT STRAIGHT_JOIN SQL_CALC_FOUND_ROWS
#REQUEST = $request->Id
a.*
a.Id
" . $request_select_str . "
FROM
" . $where_cond['from'] . "
@ -1060,7 +1065,7 @@
Debug::startTime('ELEMENTS_ALL');
foreach ($rows as $row)
foreach ($rows AS $row)
{
$x++;
$last_item = ($x == $items_count ? true : false);
@ -1069,7 +1074,7 @@
Debug::startTime('ELEMENT_' . $item_num);
$item = showrequestelement($row, $request->request_template_item);
$item = showrequestelement($row->Id, $request->request_template_item);
$GLOBALS['block_generate']['REQUESTS'][$id]['ELEMENTS'][$item_num] = Debug::endTime('ELEMENT_' . $item_num);
@ -1085,6 +1090,10 @@
$item = str_replace('[tag:/if]', '<'.'?php } ?>', $item);
$item = str_replace('[tag:if_else]', '<'.'?php }else{ ?>', $item);
$items .= $item;
Registry::remove('documents', $row->Id);
Registry::remove('fields', $row->Id);
Registry::remove('fields_param', $row->Id);
}
$GLOBALS['block_generate']['REQUESTS'][$id]['ELEMENTS']['ALL'] = Debug::endTime('ELEMENTS_ALL');
@ -1208,7 +1217,7 @@
* содержимое поля будет очищено от HTML-тегов.
* @return string
*/
function request_get_document_field_value($rubric_id, $document_id, $maxlength = 0)
function request_get_document_field_value ($rubric_id, $document_id, $maxlength = 0)
{
if (! is_numeric($rubric_id) || $rubric_id < 1 || ! is_numeric($document_id) || $document_id < 1)
return '';

23
functions/func.rubrics.php

@ -3,15 +3,14 @@
/**
* Функция отдает время когда менялась рубрика или ее поля
*
* @param int $rubric_id
* @param int $var
*
* @return mixed
*/
function get_rubrics_changes ($rubric_id = null, $var = '')
function get_rubrics_changes ()
{
global $AVE_DB;
if (Registry::stored('rubric_changes'))
return Registry::get('rubric_changes');
$cache_file = BASE_DIR . '/tmp/cache/sql/rubrics/all/rubrics.cahnges';
// Если включен DEV MODE, то отключаем кеширование запросов
@ -47,16 +46,8 @@
file_put_contents($cache_file, serialize($rubrics));
}
if ($rubric_id > 0)
{
if (! empty($var))
return $rubrics[$rubric_id][$var];
else
return $rubrics[$rubric_id];
}
else
{
return $rubrics;
}
Registry::set('rubric_changes', $rubrics);
return Registry::get('rubric_changes');
}
?>

2
functions/func.sysblock.php

@ -180,7 +180,7 @@
" . (is_numeric($id) ? 'id' : 'sysblock_alias') . " = '" . $id . "'
";
$sys_block = $AVE_DB->Query($sql, -1, 'sysblocks/' . $id . '/')->FetchAssocArray();
$sys_block = $AVE_DB->Query($sql, -1, 'sysblocks/' . $id)->FetchAssocArray();
}
if ($param == '')

2
inc/config.php

@ -12,7 +12,7 @@
*/
define('APP_NAME', 'AVE.cms');
define('APP_VERSION', '3.27');
define('APP_VERSION', '3.28');
define('APP_INFO', '<a target="_blank" href="https://ave-cms.ru/">Ave-Cms.Ru</a> '.'&copy; 2007-' . date('Y'));
$themes = [];

6
inc/init.php

@ -24,6 +24,10 @@
if (PHP_DEBUGGING_FILE && ! defined('ACP'))
include_once BASE_DIR . '/inc/errors.php';
//-- Registry
require(BASE_DIR . '/class/class.registry.php');
Registry::init();
//-- Debug Class
require(BASE_DIR . '/class/class.debug.php');
new Debug;
@ -230,7 +234,7 @@
//-- Шаблоны
write_htaccess_deny(BASE_DIR . '/templates/' . DEFAULT_THEME_FOLDER . '/include/');
global $AVE_DB, $fields_data;
global $AVE_DB;
//-- Класс для работы с MySQL (Global $AVE_DB)
require_once (BASE_DIR . '/class/class.database.php');

9
inc/thumb.php

@ -131,9 +131,6 @@
if ($_SERVER['REQUEST_URI'] == '/inc/thumb.php')
die('No image');
//-- Базовая папка
$baseDir = str_replace('\\', '/', dirname(dirname(__FILE__)));
//-- Если файл существует, показываем его
if (file_exists(BASE_DIR . $imagefile))
{
@ -167,7 +164,7 @@
exit(0);
}
$thumbPath = $baseDir . '/' . UPLOAD_DIR . '/' . $thumbPath;
$thumbPath = BASE_DIR . '/' . UPLOAD_DIR . '/' . $thumbPath;
$imagePath = $lenThumbDir ? dirname($thumbPath) : $thumbPath;
$thumbName = basename($imagefile);
@ -254,7 +251,7 @@
$imageName = 'noimage.png';
if (! file_exists("$imagePath/$imageName"))
$imagePath = $baseDir . '/' . UPLOAD_DIR . '/images';
$imagePath = BASE_DIR . '/' . UPLOAD_DIR . '/images';
if (! file_exists("$imagePath/$imageName"))
exit(0);
@ -264,7 +261,7 @@
define('IMAGE_TOOLBOX_DEFAULT_JPEG_QUALITY', JPG_QUALITY);
require $baseDir . '/class/class.thumbnail.php';
require BASE_DIR . '/class/class.thumbnail.php';
$thumb = new Image_Toolbox("$imagePath/$imageName");

5
index.php

@ -6,7 +6,7 @@
* @package AVE.cms
* @version 3.x
* @filesource
* @copyright © 2007-2016 AVE.cms, http://www.ave-cms.ru
* @copyright © 2007-2020 AVE.cms, https://ave-cms.ru
*
* @license GPL v.2
*/
@ -114,6 +114,8 @@
unset ($content);
Registry::clean();
//-- Ловим 404 ошибку
if (isset($_REQUEST['id']) AND ($_REQUEST['id']) == PAGE_NOT_FOUND_ID)
{
@ -172,4 +174,3 @@
//-- Вывод конечного результата
output_compress($render);
?>
Loading…
Cancel
Save