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

Last change on this file since 26010 was 25794, checked in by rvelices, 10 years ago
File size: 2.2 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', 'resize_threshold', 'resize_factor');
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        // int/double
29        $my_conf['album_thumb_size'] = max(0, $my_conf['album_thumb_size']);
30  $my_conf['resize_threshold'] = max(1, $my_conf['resize_threshold']);
31  $my_conf['resize_factor'] = max(0, min(1, $my_conf['resize_factor']) );
32  $my_conf = array_intersect_key($my_conf, $default_conf);
33  conf_update_param('modus_theme', addslashes(serialize($my_conf)) );
34
35        global $page;
36        $page['infos'][] = 'options saved !';
37}
38
39
40// *************** template init ********************
41
42
43foreach ($text_values as $k )
44  $template->assign( strtoupper($k), $my_conf[$k] );
45foreach ($bool_values as $k )
46  $template->assign( strtoupper($k), $my_conf[$k] );
47
48$available_derivatives = array( ''=> 'Default');
49foreach(array_keys(ImageStdParams::get_defined_type_map()) as $type)
50        $available_derivatives[$type] = l10n($type);
51
52$available_skins=array();
53$skin_dir = dirname(dirname(__FILE__)).'/skins/';
54$skin_suffix = '.inc.php';
55foreach( glob($skin_dir.'*'.$skin_suffix) as $file)
56{
57        $skin = substr($file, strlen($skin_dir), -strlen($skin_suffix));
58        $available_skins[$skin] = ucwords( str_replace('_', ' ',$skin));
59}
60
61$template->assign( array(
62        'available_derivatives' => $available_derivatives,
63        'available_skins' => $available_skins,
64  'THEMECONF_SRC' => highlight_file( dirname(dirname(__FILE__)).'/themeconf.inc.php', true )
65        ) );
66
67$template->set_filename( 'modus_content', dirname(__FILE__).'/modus_admin.tpl' );
68$template->assign_var_from_handle( 'ADMIN_CONTENT', 'modus_content');
69?>
Note: See TracBrowser for help on using the repository browser.