mirror of https://github.com/avecms/AVE.cms.git
M@d D3n
4 years ago
65 changed files with 1342 additions and 157 deletions
@ -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); |
||||
} |
||||
} |
||||
?> |
@ -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; |
||||
} |
@ -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); |
||||
} |
||||
?> |
@ -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 + '" /> ' + |
||||
'<a class="btn greyishBtn" onclick="openFileWindow(\'links_' + c_id + '_' + iid + '\',\'links_' + c_id + '_' + iid + '\',\'links_' + c_id + '_' + iid + '\');">FILE</a> <a href="javascript:void(0);" data-id="' + c_id + '_' + iid + '" class="button redBtn topDir DelButton" title="' + links_del + '">×</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(); |
||||
}); |
@ -0,0 +1,9 @@
|
||||
[admin] |
||||
name = "Файлы документов" |
||||
delete = "Удалить элемент" |
||||
param_name = "Наименование" |
||||
param_desc = "Описание" |
||||
param_url = "Ссылка" |
||||
del_conf = "Вы уверены, что хотите удалить данный элемент?" |
||||
del_head = "Удаление элемента..." |
||||
add = "Добавить" |
@ -0,0 +1,5 @@
|
||||
<ul> |
||||
{foreach from=$field_value item=list} |
||||
<li>{$list[0]}: {$list[1]}</li> |
||||
{/foreach} |
||||
</ul> |
@ -0,0 +1,5 @@
|
||||
<ul> |
||||
{foreach from=$field_value item=list} |
||||
<li>{$list[0]}: {$list[1]}</li> |
||||
{/foreach} |
||||
</ul> |
@ -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> {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#}">×</a>{/if} |
||||
</div> |
||||
</div> |
||||
|
||||
{/foreach} |
||||
</div> |
@ -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); |
||||
} |
||||
?> |
@ -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}" /> |
||||
<input value="{#MAIN_OPEN_MEDIAPATH#}"" class="basicBtn" type="button" onclick="browse_uploads('img_feld__{$field_id}', '', '', '0');" /> |
||||
<a class="button blackBtn topDir" title="{#DOC_FILE_TYPE_HELP#}" href="#">?</a> |
Loading…
Reference in new issue