diff --git a/class/class.template.php b/class/class.template.php index d22dfb5..85a3dc2 100644 --- a/class/class.template.php +++ b/class/class.template.php @@ -175,6 +175,11 @@ $this->registerPlugin('modifier', 'stripcslashes', 'stripcslashes'); } + if (function_exists('html_entity_decode')) { + // Регистрируем как модификатор, если функция существует + $this->registerPlugin('modifier', 'html_entity_decode', 'html_entity_decode'); + } + // плагин позволяющий поставить метки шаблонов // для быстрого поиска шаблона отвечающего за вывод diff --git a/fields/image_mega/field.php b/fields/image_mega/field.php index c26cd30..4ae75d6 100644 --- a/fields/image_mega/field.php +++ b/fields/image_mega/field.php @@ -52,9 +52,9 @@ $items = array(); $image_items = array(); - if ($_REQUEST['action'] != 'new') + if ($_REQUEST['action'] != 'new' && trim($field_value) !== '') { - $items = unserialize($field_value); + $items = @unserialize($field_value); if ($items != false) { @@ -143,8 +143,8 @@ case 'doc': - $items = (isset($field_value)) - ? unserialize($field_value) + $items = (isset($field_value) && trim($field_value) !== '') + ? @unserialize($field_value) : []; $res = []; @@ -177,18 +177,18 @@ '/\[tag:parametr:(\d+)\]/i', function($data) use($field_data) { - return $field_data[(int)$data[1]]; + return isset($field_data[(int)$data[1]]) ? $field_data[(int)$data[1]] : ''; }, $tpl ); - $image_item = preg_replace_callback( - '/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/', - function($m) { - return watermarks($m[1], $m[2], $m[3]); - }, - $image_item - ); + $image_item = preg_replace_callback( + '/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/', + function($m) { + return watermarks($m[1], $m[2], $m[3]); + }, + $image_item + ); $image_item = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $image_item); } @@ -218,7 +218,10 @@ break; case 'req': - $items = unserialize($field_value); + + $items = (trim($field_value) !== '') + ? @unserialize($field_value) + : []; $res = array(); @@ -235,9 +238,9 @@ $image_item = array(); $image_item['url'] = $field_data[0]; - $image_item['title'] = $field_data[1] ? $field_data[1] : ''; - $image_item['description'] = $field_data[2] ? $field_data[2] : ''; - $image_item['link'] = $field_data[3] ? $field_data[3] : ''; + $image_item['title'] = isset($field_data[1]) ? $field_data[1] : ''; + $image_item['description'] = isset($field_data[2]) ? $field_data[2] : ''; + $image_item['link'] = isset($field_data[3]) ? $field_data[3] : ''; if (! empty($image_item['link'])) $image_item['http'] = (preg_match('/^(http|https)/', $image_item['link']) ? true : false); @@ -250,17 +253,17 @@ '/\[tag:parametr:(\d+)\]/i', static function($data) use($field_data) { - return $field_data[(int)$data[1]]; + return isset($field_data[(int)$data[1]]) ? $field_data[(int)$data[1]] : ''; }, $tpl ); - $image_item = preg_replace_callback( - '/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/', - function($m) { - return watermarks($m[1], $m[2], $m[3]); - }, - $image_item - ); + $image_item = preg_replace_callback( + '/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/', + function($m) { + return watermarks($m[1], $m[2], $m[3]); + }, + $image_item + ); $image_item = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $image_item); } @@ -320,7 +323,7 @@ if (! empty($field_value)) { - $images = unserialize($field_value); + $images = @unserialize($field_value); // Добавлено @ if (! $images) return false; @@ -362,7 +365,11 @@ $default = explode('|', $default); - list($path_upload, $watermark, $position, $transparency) = $default; + // извлечение элементов массива $default + $path_upload = $default[0] ?? ''; + $watermark = $default[1] ?? false; + $position = $default[2] ?? null; + $transparency = $default[3] ?? null; if (! empty($path_upload)) $path_upload = str_replace($search, $replace, $path_upload); @@ -472,5 +479,4 @@ } return $res ?: $field_value; - } -?> \ No newline at end of file + } \ No newline at end of file diff --git a/fields/image_mega/tpl/field.tpl b/fields/image_mega/tpl/field.tpl index 04717b3..243f19e 100644 --- a/fields/image_mega/tpl/field.tpl +++ b/fields/image_mega/tpl/field.tpl @@ -1,6 +1,6 @@ {if $mega_new != 'load'} {assign var=mega_new value='' scope="global"} - {if $smarty.request.outside} + {if isset($smarty.request.outside) && $smarty.request.outside} {else}