Ignore:
Timestamp:
Jul 20, 2015, 1:45:59 AM (9 years ago)
Author:
SergeD
Message:

version 1.0.18 - refer to changelog for more details

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GDThumb/admin.php

    r31060 r31245  
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44
    5 function delete_gdthumb_cache($height) {
    6   $pattern = '#.*-cu_s9999x'.$height.'\.[a-zA-Z0-9]{3,4}$#';
    7   if ($contents = @opendir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR)):
     5function int_delete_gdthumb_cache($pattern) {
     6  if ($contents = @opendir(PHPWG_ROOT_PATH . PWG_DERIVATIVE_DIR)):
    87    while (($node = readdir($contents)) !== false):
    98      if ($node != '.'
    109          and $node != '..'
    11           and is_dir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.$node)):
    12         clear_derivative_cache_rec(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.$node, $pattern);
     10          and is_dir(PHPWG_ROOT_PATH . PWG_DERIVATIVE_DIR . $node)):
     11        clear_derivative_cache_rec(PHPWG_ROOT_PATH . PWG_DERIVATIVE_DIR . $node, $pattern);
    1312      endif;
    1413    endwhile;
     
    1615  endif;
    1716}
     17
     18function delete_gdthumb_cache($height) {
     19  int_delete_gdthumb_cache('#.*-cu_s9999x' . $height . '\.[a-zA-Z0-9]{3,4}$#');
     20  int_delete_gdthumb_cache('#.*-cu_s' . $height . 'x9999\.[a-zA-Z0-9]{3,4}$#');
     21}
     22
     23global $template, $conf, $page;
     24
     25load_language('plugin.lang', GDTHUMB_PATH);
     26include(dirname(__FILE__).'/config_default.inc.php');
     27$params = $conf['gdThumb'];
    1828
    1929if (isset($_GET['getMissingDerivative'])) {
     
    4353      if ($src_image->is_mimetype())
    4454        continue;
    45       $derivative = new DerivativeImage(ImageStdParams::get_custom(9999, $conf['gdThumb']['height']), $src_image);
     55      if (($params['method'] == "slide") || ($params['method'] == "square")):
     56        $derivative = new DerivativeImage(ImageStdParams::get_custom($params['height'], 9999), $src_image);
     57      else:
     58        $derivative = new DerivativeImage(ImageStdParams::get_custom(9999, $params['height']), $src_image);
     59      endif;
    4660      if (@filemtime($derivative->get_path())===false) {
    4761        $urls[] = $derivative->get_url().$uid;
     
    6478}
    6579
    66 global $template, $conf, $page;
    67 
    68 load_language('plugin.lang', GDTHUMB_PATH);
    69 include(dirname(__FILE__).'/config_default.inc.php');
    70 $params = $conf['gdThumb'];
    71 
    7280// Delete cache
    7381if (isset($_POST['cachedelete'])) {
    7482  check_pwg_token();
    75   delete_gdthumb_cache($conf['gdThumb']['height']);
    76   delete_gdthumb_cache($conf['gdThumb']['height'] * 2 + $conf['gdThumb']['margin']);
     83  delete_gdthumb_cache($params['height']);
     84  delete_gdthumb_cache($params['height'] * 2 + $params['margin']);
    7785  redirect('admin.php?page=plugin-GDThumb');
    7886}
     
    92100  endif;
    93101
    94   $big_thumb = !empty($_POST['big_thumb']);
     102  $big_thumb        = !empty($_POST['big_thumb']);
     103  $big_thumb_noinpw = !empty($_POST['big_thumb_noinpw']);
     104  $thumb_animate    = !empty($_POST['thumb_animate']);
     105  $thumb_mode_album = $_POST['thumb_mode_album'];
     106  $thumb_mode_photo = $_POST['thumb_mode_photo'];
     107
     108  if ($method == "slide"):
     109    if ($big_thumb):
     110      $big_thumb = false;
     111      array_push($page['warnings'], l10n('Big thumb cannot be used in Slide mode. Disabled'));
     112    endif;
     113    if ($thumb_animate):
     114      $thumb_animate = false;
     115      array_push($page['warnings'], l10n('Thumb animation cannot be used in Slide mode. Disabled'));
     116    endif;
     117
     118    if (($thumb_mode_album == "overlay-ex") || ($thumb_mode_album == "overlay") || ($thumb_mode_album == "top") || ($thumb_mode_album == "bottom")):
     119      $thumb_mode_album = "bottom_static";
     120      array_push($page['warnings'], l10n('This Thumb mode cannot be used in Slide mode. Changed to default'));
     121    endif;
     122
     123    if (($thumb_mode_photo == "overlay-ex") || ($thumb_mode_photo == "overlay") || ($thumb_mode_photo == "top") || ($thumb_mode_photo == "bottom")):
     124      $thumb_mode_photo = "bottom_static";
     125      array_push($page['warnings'], l10n('This Thumb mode cannot be used in Slide mode. Changed to default'));
     126    endif;
     127  endif;
     128
     129  if (($big_thumb_noinpw) && (!$big_thumb)):
     130    $big_thumb_noinpw = false;
     131  endif;
     132
    95133  $params  = array(
    96134      'height'          => $_POST['height']
     
    98136    , 'nb_image_page'   => $_POST['nb_image_page']
    99137    , 'big_thumb'       => $big_thumb
    100     , 'big_thumb_noinpw'=> !empty($_POST['big_thumb_noinpw'])
     138    , 'big_thumb_noinpw'=> $big_thumb_noinpw
    101139    , 'cache_big_thumb' => !empty($_POST['cache_big_thumb'])
    102140    , 'normalize_title' => $normalize
    103141    , 'method'          => $method
    104     , 'thumb_mode_album'=> $_POST['thumb_mode_album']
    105     , 'thumb_mode_photo'=> $_POST['thumb_mode_photo']
     142    , 'thumb_mode_album'=> $thumb_mode_album
     143    , 'thumb_mode_photo'=> $thumb_mode_photo
    106144    , 'thumb_metamode'  => $_POST['thumb_metamode']
    107145    , 'no_wordwrap'     => !empty($_POST['no_wordwrap'])
    108     , 'thumb_animate'   => !empty($_POST['thumb_animate'])
     146    , 'thumb_animate'   => $thumb_animate
    109147  );
    110148
    111149  if (!is_numeric($params['height'])) {
    112     array_push($page['errors'], 'Thumbnails max height must be an integer.');
     150    array_push($page['errors'], l10n('Thumbnails max height must be an integer'));
    113151  }
    114152  if (!is_numeric($params['margin'])) {
    115     array_push($page['errors'], 'Margin between thumbnails must be an integer.');
     153    array_push($page['errors'], l10n('Margin between thumbnails must be an integer'));
    116154  }
    117155  if (!is_numeric($params['nb_image_page'])) {
    118     array_push($page['errors'], 'Number of photos per page must be an integer.');
     156    array_push($page['errors'], l10n('Number of photos per page must be an integer'));
    119157  }
    120158
     
    127165
    128166  if (empty($page['errors'])) {
    129     $query = '
    130   UPDATE ' . CONFIG_TABLE . '
    131     SET value="' . addslashes(serialize($params)) . '"
    132     WHERE param="gdThumb"
    133     LIMIT 1';
    134     pwg_query($query);
    135    
     167    conf_update_param('gdThumb', $params);
    136168    array_push($page['infos'], l10n('Information data registered in database'));
    137169  }
Note: See TracChangeset for help on using the changeset viewer.