source: extensions/GThumb/admin.php @ 12691

Revision 12691, 2.3 KB checked in by patdenice, 8 years ago (diff)

Display cache informations on admin page.
Add possibility to clear the cache.
Resize method is now applied on big images.

Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5global $template, $conf;
6
7load_language('plugin.lang', GTHUMB_PATH);
8include_once(GTHUMB_PATH.'functions.inc.php');
9include(dirname(__FILE__).'/config_default.inc.php');
10$params = $conf['GThumb'];
11
12// Delete cache
13if (isset($_GET['deletecache']))
14{
15  check_pwg_token();
16  gtdeltree(GTHUMB_CACHE_DIR);
17  redirect('admin.php?page=plugin-GThumb');
18}
19
20// Save configuration
21if (isset($_POST['submit']))
22{
23  $params  = array(
24    'height'          => $_POST['height'],
25    'margin'          => $_POST['margin'],
26    'nb_image_page'   => $_POST['nb_image_page'],
27    'big_thumb'       => !empty($_POST['big_thumb']),
28    'cache_big_thumb' => !empty($_POST['cache_big_thumb']),
29    'method'          => $_POST['method'],
30  );
31
32  if (!is_numeric($params['height']))
33  {
34    array_push($page['errors'], 'Thumbnails max height must be an integer.');
35  }
36  if (!is_numeric($params['margin']))
37  {
38    array_push($page['errors'], 'Margin between thumbnails must be an integer.');
39  }
40  if (!is_numeric($params['nb_image_page']))
41  {
42    array_push($page['errors'], 'Number of photos per page must be an integer.');
43  }
44
45  if (empty($page['errors']))
46  {
47    $query = '
48  UPDATE ' . CONFIG_TABLE . '
49    SET value="' . addslashes(serialize($params)) . '"
50    WHERE param="GThumb"
51    LIMIT 1';
52    pwg_query($query);
53   
54    array_push($page['infos'], l10n('Information data registered in database'));
55  }
56}
57
58// Configuration du template
59$template->assign(
60  array(
61    'HEIGHT'          => $params['height'],
62    'MARGIN'          => $params['margin'],
63    'NB_IMAGE_PAGE'   => $params['nb_image_page'],
64    'BIG_THUMB'       => $params['big_thumb'],
65    'CACHE_BIG_THUMB' => $params['cache_big_thumb'],
66    'METHOD'          => $params['method'],
67  )
68);
69
70// Informations
71$data = gtdirsize(GTHUMB_CACHE_DIR);
72if ($data['size'] > 1024 * 1024)
73  $data['size'] = round($data['size'] / (1024 * 1024), 2).' MB';
74else
75  $data['size'] = round($data['size'] / 1024, 2).' KB';
76
77$template->assign(
78  array(
79    'NB_ELEMENTS' => l10n_dec('%d photo', '%d photos', $data['nb_files']),
80    'ELEMENTS_SIZE' => $data['size'],
81    'PWG_TOKEN' => get_pwg_token(),
82  )
83);
84
85$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/template/admin.tpl'));
86$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
87
88?>
Note: See TracBrowser for help on using the repository browser.