Browse Source

Fixed images fields

pull/3/head
MadD3n 2 years ago
parent
commit
86519de6e7
  1. 9
      admin/templates/js/main.js
  2. 8
      fields/image_single/field.php
  3. 14
      fields/image_single/js/field.js
  4. 4
      fields/image_single/tpl/field.tpl
  5. 4
      inc/thumb.php

9
admin/templates/js/main.js

@ -34,9 +34,12 @@ function browse_uploads(target, width, height, scrollbar) {
if (typeof width == 'undefined' || width == '') var width = screen.width * 0.8; if (typeof width == 'undefined' || width == '') var width = screen.width * 0.8;
if (typeof height == 'undefined' || height == '') var height = screen.height * 0.8; if (typeof height == 'undefined' || height == '') var height = screen.height * 0.8;
if (typeof scrollbar == 'undefined') var scrollbar = 0; if (typeof scrollbar == 'undefined') var scrollbar = 0;
var targetVal = document.getElementById(target).value; let targetVal = document.getElementById(target).value;
var left = (screen.width - width) / 2; if ((document.getElementById(target).dataset.default).length) {
var top = (screen.height - height) / 2; targetVal = document.getElementById(target).dataset.default;
}
let left = (screen.width - width) / 2;
let top = (screen.height - height) / 2;
window.open('index.php?do=browser&type=image&target=' + target + '&tval=' + targetVal, 'imgpop', 'left=' + left + ',top=' + top + ',width=' + width + ',height=' + height + ',scrollbars=' + scrollbar + ',resizable=1'); window.open('index.php?do=browser&type=image&target=' + target + '&tval=' + targetVal, 'imgpop', 'left=' + left + ',top=' + top + ',width=' + width + ',height=' + height + ',scrollbars=' + scrollbar + ',resizable=1');
} }

8
fields/image_single/field.php

@ -16,7 +16,7 @@
{ {
global $AVE_Template; global $AVE_Template;
$fld_dir = dirname(__FILE__) . '/'; $fld_dir = __DIR__ . '/';
$tpl_dir = $fld_dir . 'tpl/'; $tpl_dir = $fld_dir . 'tpl/';
$fld_name = basename($fld_dir); $fld_name = basename($fld_dir);
@ -36,10 +36,14 @@
$img = $image[0]; $img = $image[0];
unset($image[0]); unset($image[0]);
$image = array($img, implode('|', $image)); $image = array($img, implode('|', $image));
$field = (!empty($image[0]) ? '../' . make_thumbnail(array('link' => $image[0], 'size' => 'f128x128')) : make_thumbnail(array('link' => $blanc, 'size' => 'f128x128'))); $field = (! empty($image[0])
? make_thumbnail(array('link' => $image[0], 'size' => 't128x128'))
: make_thumbnail(array('link' => $blanc, 'size' => 't128x128'))
);
$tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl); $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
$AVE_Template->assign('default', $default);
$AVE_Template->assign('field_dir', $fld_name); $AVE_Template->assign('field_dir', $fld_name);
$AVE_Template->assign('image', $image); $AVE_Template->assign('image', $image);
$AVE_Template->assign('doc_id', (int)$_REQUEST['Id']); $AVE_Template->assign('doc_id', (int)$_REQUEST['Id']);

14
fields/image_single/js/field.js

@ -11,11 +11,11 @@ var SingleImage = {
single_image: function() { single_image: function() {
$('.single_image').each(function(index, element) { $('.single_image').each(function(index, element) {
var image_id = $(element).attr('data-id'); let image_id = $(element).attr('data-id');
var doc_id = $(element).attr('data-doc'); let doc_id = $(element).attr('data-doc');
var link = $(element).find('a.lnk'); let link = $(element).find('a.lnk');
var look = $(element).find('a.look'); let look = $(element).find('a.look');
var input = $(element).find('input'); let input = $(element).find('input');
link.on('click', function(event) { link.on('click', function(event) {
event.preventDefault(); event.preventDefault();
@ -34,13 +34,13 @@ var SingleImage = {
}); });
$('#preview__' + image_id + '_' + doc_id).attr({ $('#preview__' + image_id + '_' + doc_id).attr({
'src': '../index.php?mode=f&width=128&height=128&thumb=/' + dir + '/' + file_full //'src': '../index.php?mode=t&width=128&height=128&thumb=/' + dir + '/' + file_full
}); });
}); });
if (input.val() == '') { if (input.val() == '') {
$('#preview__' + image_id + '_' + doc_id).attr({ $('#preview__' + image_id + '_' + doc_id).attr({
'src': '/uploads/images/' + thumbdir + '/noimage-f128x128.png' 'src': '/uploads/images/' + thumbdir + '/noimage-t128x128.png'
}); });
$('.preview__' + image_id + '_' + doc_id).attr({ $('.preview__' + image_id + '_' + doc_id).attr({
'href': '/uploads/images/noimage.png' 'href': '/uploads/images/noimage.png'

4
fields/image_single/tpl/field.tpl

@ -3,7 +3,7 @@
<script src="{$ABS_PATH}fields/{$field_dir}/js/field.js" type="text/javascript"></script> <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" /> <link href="{$ABS_PATH}fields/{$field_dir}/css/field.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript"> <script type="text/javascript">
var thumbdir = "{$smarty.const.THUMBNAIL_DIR}"; let thumbdir = "{$smarty.const.THUMBNAIL_DIR}";
</script> </script>
{assign var=single_image value="load" scope="global"} {assign var=single_image value="load" scope="global"}
{/if} {/if}
@ -13,7 +13,7 @@
<div class="header grey_bg"></div> <div class="header grey_bg"></div>
<a class="topDir icon_sprite ico_photo view fancy preview__{$field_id}_{$doc_id}" href="{$image.0|htmlspecialchars}" title="{#look#}"></a> <a class="topDir icon_sprite ico_photo view fancy preview__{$field_id}_{$doc_id}" href="{$image.0|htmlspecialchars}" title="{#look#}"></a>
<a class="topDir icon_sprite ico_edit lnk" href="javascript:void(0);" title="{#link#}"></a> <a class="topDir icon_sprite ico_edit lnk" href="javascript:void(0);" title="{#link#}"></a>
<input style="display: none;" type="text" name="feld[{$field_id}][img]" value="{$image.0|htmlspecialchars}" id="image__{$field_id}_{$doc_id}"> <input style="display: none;" type="text" name="feld[{$field_id}][img]" value="{$image.0|htmlspecialchars}" id="image__{$field_id}_{$doc_id}" data-default="{$default}">
<img id="preview__{$field_id}_{$doc_id}" src="{$field}" alt="" border="0" onclick="browse_uploads('image__{$field_id}_{$doc_id}');" style="max-width: 128px;" class="topDir" title="{#select#}" /> <img id="preview__{$field_id}_{$doc_id}" src="{$field}" alt="" border="0" onclick="browse_uploads('image__{$field_id}_{$doc_id}');" style="max-width: 128px;" class="topDir" title="{#select#}" />
<textarea class="descr mousetrap" name="feld[{$field_id}][descr]" placeholder="{#place#}">{$image.1|htmlspecialchars}</textarea> <textarea class="descr mousetrap" name="feld[{$field_id}][descr]" placeholder="{#place#}">{$image.1|htmlspecialchars}</textarea>
</div> </div>

4
inc/thumb.php

@ -129,7 +129,9 @@
//-- Если пришел прямой вызов файла, то сразу отрубаем его //-- Если пришел прямой вызов файла, то сразу отрубаем его
if ($_SERVER['REQUEST_URI'] == '/inc/thumb.php') if ($_SERVER['REQUEST_URI'] == '/inc/thumb.php')
{
die('No image'); die('No image');
}
//-- Если файл существует, показываем его //-- Если файл существует, показываем его
if (file_exists(BASE_DIR . $imagefile)) if (file_exists(BASE_DIR . $imagefile))
@ -172,7 +174,9 @@
$countParts = count($nameParts); $countParts = count($nameParts);
if ($countParts < 2 || ! in_array(strtolower(end($nameParts)), $allowedExt)) if ($countParts < 2 || ! in_array(strtolower(end($nameParts)), $allowedExt))
{
exit(0); exit(0);
}
$matches = []; $matches = [];

Loading…
Cancel
Save