source: extensions/modus/admin/admin.inc.php @ 28443

Last change on this file since 28443 was 28443, checked in by plg, 10 years ago

simpler configuration for square thumbnails (default = 250px)

File size: 2.3 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4global $template;
5
6include_once( dirname(dirname(__FILE__)).'/functions.inc.php');
7$default_conf = modus_get_default_config();
8
9$my_conf = @$conf['modus_theme'];
10if (!isset($my_conf))
11  $my_conf = $default_conf;
12elseif (!is_array($my_conf))
13{
14  $my_conf = unserialize($my_conf);
15        $my_conf = array_merge($default_conf, $my_conf);
16}
17
18$text_values = array('skin', 'album_thumb_size', 'index_photo_deriv','index_photo_deriv_hdpi');
19$bool_values = array();
20
21// *************** POST management ********************
22if (isset($_POST[$text_values[0]]))
23{
24        foreach ($text_values as $k )
25                $my_conf[$k] = stripslashes($_POST[$k]);
26        foreach ($bool_values as $k )
27                $my_conf[$k] = isset($_POST[$k]) ? true:false;
28 
29  if (!isset($_POST['use_album_square_thumbs']))
30  {
31    $my_conf['album_thumb_size'] = 0;
32  }
33 
34        // int/double
35        $my_conf['album_thumb_size'] = max(0, $my_conf['album_thumb_size']);
36  $my_conf = array_intersect_key($my_conf, $default_conf);
37  conf_update_param('modus_theme', addslashes(serialize($my_conf)) );
38
39        global $page;
40  $page['infos'][] = l10n('Information data registered in database');
41}
42
43
44// *************** template init ********************
45
46
47foreach ($text_values as $k )
48  $template->assign( strtoupper($k), $my_conf[$k] );
49foreach ($bool_values as $k )
50  $template->assign( strtoupper($k), $my_conf[$k] );
51
52// we don't use square thumbs if the thumb size is 0
53$template->assign('use_album_square_thumbs', 0 != $my_conf['album_thumb_size']);
54
55if (0 == $my_conf['album_thumb_size'])
56{
57  $template->assign('ALBUM_THUMB_SIZE', 250);
58}
59
60$available_derivatives = array( ''=> 'Default');
61foreach(array_keys(ImageStdParams::get_defined_type_map()) as $type)
62        $available_derivatives[$type] = l10n($type);
63
64$available_skins=array();
65$skin_dir = dirname(dirname(__FILE__)).'/skins/';
66$skin_suffix = '.inc.php';
67foreach( glob($skin_dir.'*'.$skin_suffix) as $file)
68{
69        $skin = substr($file, strlen($skin_dir), -strlen($skin_suffix));
70        $available_skins[$skin] = ucwords( str_replace('_', ' ',$skin));
71}
72
73$template->assign( array(
74        'available_derivatives' => $available_derivatives,
75        'available_skins' => $available_skins,
76        ) );
77
78$template->set_filename( 'modus_content', dirname(__FILE__).'/modus_admin.tpl' );
79$template->assign_var_from_handle( 'ADMIN_CONTENT', 'modus_content');
80?>
Note: See TracBrowser for help on using the repository browser.