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

Last change on this file since 27151 was 27151, checked in by rvelices, 10 years ago

modus prepare code for a future release

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