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

6
README.md

@ -1,4 +1,4 @@
# AVE.cms v3.27 # AVE.cms v3.28
###### Многофункциональная, система управления сайтом. ###### Многофункциональная, система управления сайтом.
## Оглавление ## Оглавление
@ -33,10 +33,6 @@
6. Следуйте инструкциям. 6. Следуйте инструкциям.
7. После установки системы настоятельно рекомендуем устанавливать права доступа на папку uploads не выше CHMOD 755. 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/) Сайт: [ave-cms.ru](https://ave-cms.ru/)

1
admin/groups.php

@ -20,6 +20,7 @@ if (!defined('ACP'))
global $AVE_Template; global $AVE_Template;
require(BASE_DIR . '/class/class.user.php'); require(BASE_DIR . '/class/class.user.php');
$AVE_User = new AVE_User; $AVE_User = new AVE_User;
$AVE_Template->config_load(BASE_DIR . '/admin/lang/' . $_SESSION['admin_language'] . '/groups.txt', 'groups'); $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; box-sizing:border-box;
border:1px solid #d9dee9; border:1px solid #d9dee9;
color:#177bbb!important; color:#177bbb!important;
padding:0 5px; padding:3px 5px;
border-radius:3px; border-radius:3px;
-moz-border-radius:3px; -moz-border-radius:3px;
-webkit-border-radius:3px; -webkit-border-radius:3px;
@ -899,6 +899,41 @@ div.jGrowl div.accept {
color:#177bbb!important; 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 { .docaction .code {
background-color:#f2f4f8; background-color:#f2f4f8;
color:#7f88b4!important; color:#7f88b4!important;

6
admin/templates/pop.tpl

@ -38,9 +38,7 @@
</script> </script>
</head> </head>
<body> <body>
<!-- Wrapper --> <!-- Wrapper -->
<div class="wrapper"> <div class="wrapper">
@ -52,8 +50,6 @@
<div class="fix"></div> <div class="fix"></div>
</div> </div>
<!-- Footer --> <!-- Footer -->
<div id="footer"> <div id="footer">
<div class="wrapper"> <div class="wrapper">
@ -63,5 +59,7 @@
</div> </div>
</div> </div>
<script type="text/javascript" src="{$ABS_PATH}admin/lang/{$smarty.session.admin_language}/scripts.js"></script>
</body> </body>
</html> </html>

6
class/class.docs.php

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

5
fields/checkbox/field.php

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

4
fields/code/field.php

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

3
fields/date/field.php

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

4
fields/doc_from_rub_all/field.php

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

4
fields/doc_from_rub_check/field.php

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

28
fields/doc_from_rub_search/field.php

@ -172,6 +172,34 @@
return (! empty($res)) ? implode(PHP_EOL, $res) : $tpl; return (! empty($res)) ? implode(PHP_EOL, $res) : $tpl;
break; 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' : case 'name' :
return $AVE_Template->get_config_vars('name'); return $AVE_Template->get_config_vars('name');
break; 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>

12
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; global $AVE_Template;
@ -34,7 +34,7 @@
$items = explode(',', $default); $items = explode(',', $default);
$items = array_diff($items, array('')); $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('items', $items);
$AVE_Template->assign('field_id', $field_id); $AVE_Template->assign('field_id', $field_id);
@ -45,7 +45,6 @@
case 'doc': case 'doc':
@$field_value = clean_php($field_value); @$field_value = clean_php($field_value);
if (!$tpl_empty) if (!$tpl_empty)
{ {
$field_param = explode('|', $field_value); $field_param = explode('|', $field_value);
@ -58,13 +57,11 @@
$tpl $tpl
); );
} }
$res = $field_value; $res = $field_value;
break; break;
case 'req': case 'req':
@$field_value = clean_php($field_value); @$field_value = clean_php($field_value);
if (!$tpl_empty) if (!$tpl_empty)
{ {
$field_param = explode('|', $field_value); $field_param = explode('|', $field_value);
@ -77,10 +74,13 @@
$tpl $tpl
); );
} }
$res = $field_value; $res = $field_value;
break; break;
case 'api':
return $field_value;
break;
case 'name': case 'name':
return $AVE_Template->get_config_vars('name'); return $AVE_Template->get_config_vars('name');
break; break;

70
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; global $AVE_Template;
@ -33,7 +33,7 @@
$items = explode(',', $default); $items = explode(',', $default);
$items = array_diff($items, array('')); $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('items', $items);
$AVE_Template->assign('field_id', $field_id); $AVE_Template->assign('field_id', $field_id);
@ -43,10 +43,16 @@
break; break;
case 'doc': case 'doc':
case 'req': if ($tpl_empty)
@$field_value = clean_php($field_value); {
$key = (int)$field_value;
if (!$tpl_empty) $items = explode(',', $default);
$items = array_diff($items, array(''));
$field_value = isset($items[$key])
? trim($items[$key])
: '';
}
else
{ {
$field_param = explode('|', $field_value); $field_param = explode('|', $field_value);
$field_value = preg_replace_callback( $field_value = preg_replace_callback(
@ -58,14 +64,60 @@
$tpl $tpl
); );
} }
else
$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 = explode(',', $default);
$items = array_diff($items, array('')); $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
);
} }
return $field_value = ($field_value != '') ? $field_value : ''; $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;
case 'api':
return $field_value;
break; break;
case 'name': case 'name':

29
fields/image_mega/field.php

@ -318,6 +318,35 @@
break; 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' : case 'name' :
return $AVE_Template->get_config_vars('name'); return $AVE_Template->get_config_vars('name');
break; break;

27
fields/image_multi/field.php

@ -272,6 +272,33 @@
break; 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' : case 'name' :
return $AVE_Template->get_config_vars('name'); return $AVE_Template->get_config_vars('name');
break; break;

31
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; global $AVE_Template;
@ -71,7 +71,14 @@
$tpl $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); $field_value = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $field_value);
} }
@ -91,6 +98,8 @@
$field_value = clean_php($field_value); $field_value = clean_php($field_value);
$field_param = explode('|', $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) if ($tpl_empty)
{ {
@ -108,7 +117,14 @@
$tpl $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); $field_value = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $field_value);
} }
@ -137,6 +153,15 @@
} }
break; 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' : case 'name' :
return $AVE_Template->get_config_vars('name'); return $AVE_Template->get_config_vars('name');
break; break;

4
fields/link/field.php

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

22
fields/link_multi/field.php

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

5
fields/multi_checkbox/field.php

@ -153,11 +153,16 @@ function get_field_multi_checkbox($field_value, $action, $field_id=0, $tpl='', $
break; break;
case 'api':
return $field_value;
break;
case 'name': case 'name':
return $AVE_Template->get_config_vars('name'); return $AVE_Template->get_config_vars('name');
break; break;
} }
return ($res ? $res : $field_value); 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); $res = get_field_default($field_value, $action, $field_id, $tpl, $tpl_empty, $maxlength, $document_fields, $rubric_id);
break; break;
case 'api':
$res = get_field_default($field_value, $action, $field_id, $tpl, $tpl_empty, $maxlength, $document_fields, $rubric_id);
break;
case 'name' : case 'name' :
return $AVE_Template->get_config_vars('name'); return $AVE_Template->get_config_vars('name');
break; 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); $res = get_field_default($field_value,$action,$field_id,$tpl,$tpl_empty,$maxlength,$document_fields,$rubric_id);
break; break;
case 'api':
$res = get_field_default($field_value, $action, $field_id, $tpl, $tpl_empty, $maxlength, $document_fields, $rubric_id);
break;
case 'name' : case 'name' :
return $AVE_Template->get_config_vars('name'); return $AVE_Template->get_config_vars('name');
break; 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); $res = get_field_default($field_value,$action,$field_id,$tpl,$tpl_empty,$maxlength,$document_fields,$rubric_id);
break; break;
case 'api':
$res = get_field_default($field_value, $action, $field_id, $tpl, $tpl_empty, $maxlength, $document_fields, $rubric_id);
break;
case 'name' : case 'name' :
return $AVE_Template->get_config_vars('name'); return $AVE_Template->get_config_vars('name');
break; 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; 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': case 'name':
return $AVE_Template->get_config_vars('name'); return $AVE_Template->get_config_vars('name');
break; break;

22
fields/multi_list/field.php

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

7
fields/multi_list_single/field.php

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

24
fields/multi_list_triple/field.php

@ -189,6 +189,30 @@
} }
break; 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': case 'name':
return $AVE_Template->get_config_vars('name'); return $AVE_Template->get_config_vars('name');
break; break;

7
fields/multi_select/field.php

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

3
fields/single_line/field.php

@ -113,6 +113,9 @@
case 'save': case 'save':
return $field_value; return $field_value;
case 'api':
return $field_value;
case 'name': case 'name':
return $AVE_Template->get_config_vars('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); $field_value = preg_replace('/[^\d.]/','',$field_value);
return $field_value; return $field_value;
case 'api':
return $field_value;
case 'name': case 'name':
return $AVE_Template->get_config_vars('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); return empty($save) ? '' : implode('|', $save);
case 'api':
if (! empty($field_value))
$field_value = explode('|', $field_value);
return $field_value;
case 'name': case 'name':
return $AVE_Template->get_config_vars('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); return empty($save) ? '' : implode('|', $save);
case 'api':
if (! empty($field_value))
$field_value = explode('|', $field_value);
return $field_value;
case 'name': case 'name':
return $AVE_Template->get_config_vars('name'); return $AVE_Template->get_config_vars('name');

8
fields/tags/field.php

@ -161,6 +161,14 @@
return $field_value; 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': case 'name':
return $AVE_Template->get_config_vars('name'); return $AVE_Template->get_config_vars('name');

7
fields/teasers/field.php

@ -90,6 +90,13 @@
case 'req': case 'req':
return get_field_default($field_value, $action, $field_id, $tpl, $tpl_empty); 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' : case 'name' :
return $AVE_Template->get_config_vars('name'); return $AVE_Template->get_config_vars('name');
break; break;

3
fields/text_to_image/field.php

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

17
fields/youtube/field.php

@ -134,6 +134,23 @@
} }
break; 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' : case 'name' :
return $AVE_Template->get_config_vars('name'); return $AVE_Template->get_config_vars('name');

3
functions/func.common.php

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

42
functions/func.documents.php

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

151
functions/func.fields.php

@ -155,19 +155,16 @@
* @param $id * @param $id
* @return string * @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)) $alias = Registry::get('fields_params', $field_id);
static $fields_data = [];
if (isset($fields_data[$id])) $alias = $alias['rubric_field_alias'] ? $alias['rubric_field_alias'] : $field_id;
return $fields_data[$id]['alias'];
$fields_data[$id]['alias'] = $AVE_DB->Query("SELECT rubric_field_alias FROM " . PREFIX . "_rubric_fields WHERE Id=" . intval($id))->GetCell(); return $alias;
return $fields_data[$id]['alias'];
} }
@ -254,22 +251,22 @@
$alias_field_id = get_field_alias($field_id); $alias_field_id = get_field_alias($field_id);
// Если существет файл с ID поля и ID шаблона // Если существует файл с ID поля и ID шаблона
if (file_exists($dir.'field-'.$type.'-'.$field_id.'-'.$_tpl.'.tpl')) if (file_exists($dir.'field-'.$type.'-'.$field_id.'-'.$_tpl.'.tpl'))
$tpl = $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')) else if (file_exists($dir.'field-'.$type.'-'.$alias_field_id.'-'.$_tpl.'.tpl'))
$tpl = $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')) else if (file_exists($dir.'field-'.$type.'-'.$field_id.'.tpl'))
$tpl = $dir.'field-'.$type.'-'.$field_id.'.tpl'; $tpl = $dir.'field-'.$type.'-'.$field_id.'.tpl';
// Если существет файл с алиасом поля // Если существует файл с алиасом поля
else if (file_exists($dir.'field-'.$type.'-'.$alias_field_id.'.tpl')) else if (file_exists($dir.'field-'.$type.'-'.$alias_field_id.'.tpl'))
$tpl = $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')) else if (file_exists($dir.'field-'.$type.'.tpl'))
$tpl = $dir.'field-'.$type.'.tpl'; $tpl = $dir.'field-'.$type.'.tpl';
// Если существет файл c ID поля // Если существует файл c ID поля
else if (file_exists($dir.'field-'.$field_id.'.tpl')) else if (file_exists($dir.'field-'.$field_id.'.tpl'))
$tpl = $dir.'field-'.$field_id.'.tpl'; $tpl = $dir.'field-'.$field_id.'.tpl';
// Иначе // Иначе
@ -393,6 +390,9 @@
*/ */
function get_document_field ($document_id, $field) function get_document_field ($document_id, $field)
{ {
if (Registry::stored($document_id, $field))
$document_fields = Registry::get($document_id, $field);
else
$document_fields = get_document_fields($document_id); $document_fields = get_document_fields($document_id);
if (! is_array($document_fields[$field])) if (! is_array($document_fields[$field]))
@ -417,25 +417,30 @@
*/ */
function get_document_fields ($document_id, $values = null) function get_document_fields ($document_id, $values = null)
{ {
global $AVE_DB, $AVE_Core, $fields_data; //$request_documents global $AVE_DB, $AVE_Core; //$request_documents
if (defined('USE_STATIC_DATA') && USE_STATIC_DATA)
static $document_fields = [];
else
$document_fields = [];
if (! is_numeric($document_id)) if (! is_numeric($document_id))
return false; 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($AVE_Core) || $AVE_Core->curentdoc->Id != $document_id)
{ {
if (! isset($rubric_changed_fields[$document_id]))
$rubric_id = get_document($document_id, 'rubric_id'); $rubric_id = get_document($document_id, 'rubric_id');
$rubric_changed_fields[$document_id] = get_rubrics_changes($rubric_id, 'rubric_changed_fields');
$cache_time = $rubric_changed_fields[$document_id]; $cache_time = $rubric_changed_fields[$rubric_id]['rubric_changed_fields'];
} }
else else
{ {
@ -459,9 +464,11 @@
doc_field.rubric_field_id, doc_field.rubric_field_id,
doc_field.field_value, doc_field.field_value,
text_field.field_value AS field_value_more, text_field.field_value AS field_value_more,
rub_field.rubric_id,
rub_field.rubric_field_alias, rub_field.rubric_field_alias,
rub_field.rubric_field_type, rub_field.rubric_field_type,
rub_field.rubric_field_default, rub_field.rubric_field_default,
rub_field.rubric_field_numeric,
rub_field.rubric_field_title, rub_field.rubric_field_title,
rub_field.rubric_field_template, rub_field.rubric_field_template,
rub_field.rubric_field_template_request rub_field.rubric_field_template_request
@ -518,7 +525,9 @@
$row['field_value'] = (string)$row['field_value'] . (string)$row['field_value_more']; $row['field_value'] = (string)$row['field_value'] . (string)$row['field_value_more'];
if ($values) 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'] === '') 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'])); $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']; $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);
}
/** /**
* Возвращает поле документа по номеру * Возвращает поле документа по номеру
* *

19
functions/func.parserequest.php

@ -270,6 +270,7 @@
$document_fields = get_document_fields($document_id); $document_fields = get_document_fields($document_id);
// ToDo
if (! is_array($document_fields[$field_id])) if (! is_array($document_fields[$field_id]))
$field_id = intval($document_fields[$field_id]); $field_id = intval($document_fields[$field_id]);
@ -325,7 +326,7 @@
$maxlength = abs($maxlength); $maxlength = abs($maxlength);
} }
// ToDo - сделать настройки окончаний // ToDo - сделать настройки окончаний = Уже есть в Доп настройках
if ($maxlength != 0) if ($maxlength != 0)
{ {
$field_value = truncate($field_value, $maxlength, REQUEST_ETC, REQUEST_BREAK_WORDS); $field_value = truncate($field_value, $maxlength, REQUEST_ETC, REQUEST_BREAK_WORDS);
@ -610,7 +611,11 @@
// Кол-во просмотров // Кол-во просмотров
$item = str_replace('[tag:docviews]', $row->document_count_view, $item); $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; return $item;
} }
@ -862,7 +867,7 @@
$sql = " ?> $sql = " ?>
SELECT STRAIGHT_JOIN SQL_CALC_FOUND_ROWS SELECT STRAIGHT_JOIN SQL_CALC_FOUND_ROWS
#REQUEST = $request->Id #REQUEST = $request->Id
a.* a.Id
" . $request_select_str . " " . $request_select_str . "
FROM FROM
" . $where_cond['from'] . " " . $where_cond['from'] . "
@ -1060,7 +1065,7 @@
Debug::startTime('ELEMENTS_ALL'); Debug::startTime('ELEMENTS_ALL');
foreach ($rows as $row) foreach ($rows AS $row)
{ {
$x++; $x++;
$last_item = ($x == $items_count ? true : false); $last_item = ($x == $items_count ? true : false);
@ -1069,7 +1074,7 @@
Debug::startTime('ELEMENT_' . $item_num); 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); $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]', '<'.'?php } ?>', $item);
$item = str_replace('[tag:if_else]', '<'.'?php }else{ ?>', $item); $item = str_replace('[tag:if_else]', '<'.'?php }else{ ?>', $item);
$items .= $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'); $GLOBALS['block_generate']['REQUESTS'][$id]['ELEMENTS']['ALL'] = Debug::endTime('ELEMENTS_ALL');

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; global $AVE_DB;
if (Registry::stored('rubric_changes'))
return Registry::get('rubric_changes');
$cache_file = BASE_DIR . '/tmp/cache/sql/rubrics/all/rubrics.cahnges'; $cache_file = BASE_DIR . '/tmp/cache/sql/rubrics/all/rubrics.cahnges';
// Если включен DEV MODE, то отключаем кеширование запросов // Если включен DEV MODE, то отключаем кеширование запросов
@ -47,16 +46,8 @@
file_put_contents($cache_file, serialize($rubrics)); file_put_contents($cache_file, serialize($rubrics));
} }
if ($rubric_id > 0) Registry::set('rubric_changes', $rubrics);
{
if (! empty($var)) return Registry::get('rubric_changes');
return $rubrics[$rubric_id][$var];
else
return $rubrics[$rubric_id];
}
else
{
return $rubrics;
}
} }
?> ?>

2
functions/func.sysblock.php

@ -180,7 +180,7 @@
" . (is_numeric($id) ? 'id' : 'sysblock_alias') . " = '" . $id . "' " . (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 == '') if ($param == '')

2
inc/config.php

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

6
inc/init.php

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

9
inc/thumb.php

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

5
index.php

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