3 /***************************************************************************
\r
4 * xs_style_config.php
\r
5 * -------------------
\r
6 * copyright : (C) 2003 - 2005 CyberAlien
\r
7 * support : http://www.phpbbstyles.com
\r
11 * file revision : 72
\r
12 * project revision : 78
\r
13 * last modified : 05 Dec 2005 13:54:54
\r
15 ***************************************************************************/
\r
17 /***************************************************************************
\r
19 * This program is free software; you can redistribute it and/or modify
\r
20 * it under the terms of the GNU General Public License as published by
\r
21 * the Free Software Foundation; either version 2 of the License, or
\r
22 * (at your option) any later version.
\r
24 ***************************************************************************/
\r
26 define('IN_PHPBB', 1);
\r
27 $phpbb_root_path = "./../";
\r
28 $no_page_header = true;
\r
29 require($phpbb_root_path . 'extension.inc');
\r
30 require('./pagestart.' . $phpEx);
\r
32 // check if mod is installed
\r
33 if(empty($template->xs_version) || $template->xs_version !== 8)
\r
35 message_die(GENERAL_ERROR, isset($lang['xs_error_not_installed']) ? $lang['xs_error_not_installed'] : 'eXtreme Styles mod is not installed. You forgot to upload includes/template.php');
\r
38 define('IN_XS', true);
\r
39 include_once('xs_include.' . $phpEx);
\r
41 $tpl = isset($HTTP_POST_VARS['tpl']) ? $HTTP_POST_VARS['tpl'] : (isset($HTTP_GET_VARS['tpl']) ? $HTTP_GET_VARS['tpl'] : '');
\r
42 $filename = $phpbb_root_path . 'templates/' . $tpl . '/xs_config.cfg';
\r
46 xs_error($lang['xs_invalid_style_name']);
\r
48 if(!@file_exists($filename))
\r
50 // remove from config
\r
51 $config_name = 'xs_style_' . $tpl;
\r
52 $sql = "DELETE FROM " . CONFIG_TABLE . " WHERE config_name='" . addslashes($config_name) . "'";
\r
53 $db->sql_query($sql);
\r
54 // recache config table for cat_hierarchy 2.1.0
\r
55 if(isset($GLOBALS['config']) && is_object($GLOBALS['config']))
\r
58 $config->read(true);
\r
60 $template->assign_block_vars('left_refresh', array(
\r
61 'ACTION' => append_sid('index.' . $phpEx . '?pane=left')
\r
63 xs_error($lang['xs_invalid_style_name']);
\r
66 // get configuration
\r
67 $style_config = array();
\r
69 $data = $template->get_config($tpl, false);
\r
70 for($i=0; $i<count($style_config); $i++)
\r
72 if(!isset($data[$style_config[$i]['var']]))
\r
74 $data[$style_config[$i]['var']] = $style_config[$i]['default'];
\r
79 // check submitted form
\r
80 if(isset($HTTP_POST_VARS['tpl']) && !defined('DEMO_MODE'))
\r
82 for($i=0; $i<count($style_config); $i++)
\r
84 $item = &$style_config[$i];
\r
85 $var = $style_config[$i]['var'];
\r
86 if($item['type'] === 'list')
\r
88 $value = isset($HTTP_POST_VARS['cfg_' . $var]) && is_array($HTTP_POST_VARS['cfg_' . $var]) ? $HTTP_POST_VARS['cfg_' . $var] : array();
\r
90 foreach($value as $var1 => $value1)
\r
94 $value = implode(',', $list);
\r
98 $value = isset($HTTP_POST_VARS['cfg_' . $var]) ? stripslashes($HTTP_POST_VARS['cfg_' . $var]) : 0;
\r
100 $data[$var] = $value;
\r
103 $str = $template->_serialize($data);
\r
104 $config_name = 'xs_style_' . $tpl;
\r
105 if(isset($board_config[$config_name]))
\r
107 $sql = "UPDATE " . CONFIG_TABLE . " SET config_value='" . addslashes($str) . "' WHERE config_name='" . addslashes($config_name) . "'";
\r
111 $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) VALUES ('" . addslashes($config_name) . "', '" . addslashes($str) . "')";
\r
113 $db->sql_query($sql);
\r
114 $board_config[$config_name] = $str;
\r
115 // recache config table for cat_hierarchy 2.1.0
\r
116 if(isset($config) && is_object($config))
\r
118 $config->read(true);
\r
125 for($i=0; $i<count($style_config); $i++)
\r
127 $item = &$style_config[$i];
\r
128 $var = $style_config[$i]['var'];
\r
129 $template->assign_block_vars('item', array(
\r
130 'VAR' => 'cfg_' . $var,
\r
131 'VALUE' => htmlspecialchars($data[$var]),
\r
132 'DEF' => $item['default'],
\r
133 'TYPE' => $item['type'],
\r
134 'TEXT' => htmlspecialchars($item['text']),
\r
135 'EXPLAIN' => isset($item['explain']) ? $item['explain'] : '',
\r
137 if($item['type'] === 'select')
\r
139 foreach($item['selection'] as $var1 => $value1)
\r
141 $template->assign_block_vars('item.select', array(
\r
142 'VALUE' => htmlspecialchars($var1),
\r
143 'TEXT' => htmlspecialchars($value1),
\r
144 'SELECTED' => $data[$var] === $var1 ? 1 : 0,
\r
148 if($item['type'] === 'list')
\r
150 $values = explode(',', $data[$var]);
\r
151 foreach($item['selection'] as $var => $value)
\r
154 for($j=0; $j<count($values); $j++)
\r
156 if($values[$j] === $var)
\r
161 $template->assign_block_vars('item.list', array(
\r
162 'VALUE' => htmlspecialchars($var),
\r
163 'TEXT' => htmlspecialchars($value),
\r
164 'SELECTED' => $selected,
\r
169 if(!empty($item['cat']) && $item['cat'] !== $last_cat)
\r
171 $template->assign_block_vars('item.cat', array(
\r
172 'TEXT' => htmlspecialchars($item['cat'])
\r
174 $last_cat = $item['cat'];
\r
178 $template->assign_vars(array(
\r
179 'TPL' => htmlspecialchars($tpl),
\r
180 'U_FORM' => 'xs_style_config.'.$phpEx.'?sid='.$userdata['session_id'],
\r
183 $template->assign_block_vars('nav_left',array('ITEM' => '» <a href="' . append_sid('xs_style_config.'.$phpEx.'?tpl='.urlencode($tpl)) . '">' . $lang['xs_style_configuration'] . ': ' . $tpl . '</a>'));
\r
185 $template->set_filenames(array('body' => XS_TPL_PATH . 'style_config.tpl'));
\r
186 $template->pparse('body');
\r