3 /***************************************************************************
\r
6 * copyright : (C) 2003 - 2005 CyberAlien
\r
7 * support : http://www.phpbbstyles.com
\r
11 * file revision : 78
\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 $template->assign_block_vars('nav_left',array('ITEM' => '» <a href="' . append_sid('xs_edit_data.'.$phpEx) . '">' . $lang['xs_edit_styles_data'] . '</a>'));
\r
43 $lang['xs_edittpl_back_list'] = str_replace('{URL}', append_sid('xs_edit_data.'.$phpEx), $lang['xs_edittpl_back_list']);
\r
45 function xs_empty_name()
\r
48 $sql = "SELECT * FROM " . THEMES_NAME_TABLE . " LIMIT 0, 1";
\r
49 if(!$result = $db->sql_query($sql))
\r
53 $data = $db->sql_fetchrow($result);
\r
54 if($data === false || !@count($data))
\r
58 'tr_color1_name' => '',
\r
59 'tr_color2_name' => '',
\r
60 'tr_color3_name' => '',
\r
61 'tr_class1_name' => '',
\r
62 'tr_class2_name' => '',
\r
63 'tr_class3_name' => '',
\r
64 'th_color1_name' => '',
\r
65 'th_color2_name' => '',
\r
66 'th_color3_name' => '',
\r
67 'th_class1_name' => '',
\r
68 'th_class2_name' => '',
\r
69 'th_class3_name' => '',
\r
70 'td_color1_name' => '',
\r
71 'td_color2_name' => '',
\r
72 'td_color3_name' => '',
\r
73 'td_class1_name' => '',
\r
74 'td_class2_name' => '',
\r
75 'td_class3_name' => '',
\r
76 'fontface1_name' => '',
\r
77 'fontface2_name' => '',
\r
78 'fontface3_name' => '',
\r
79 'fontsize1_name' => '',
\r
80 'fontsize2_name' => '',
\r
81 'fontsize3_name' => '',
\r
82 'fontcolor1_name' => '',
\r
83 'fontcolor2_name' => '',
\r
84 'fontcolor3_name' => '',
\r
85 'span_class1_name' => '',
\r
86 'span_class2_name' => '',
\r
87 'span_class3_name' => ''
\r
92 foreach($data as $var => $value)
\r
94 if($var !== 'themes_id')
\r
102 function xs_get_vars($theme)
\r
106 $vars_100 = array('head_stylesheet', 'body_background');
\r
107 $vars_50 = array('fontface');
\r
108 $vars_30 = array('style_name');
\r
109 $vars_25 = array('tr_class', 'th_class', 'td_class', 'span_class');
\r
110 $vars_6 = array('body_bgcolor', 'body_text', 'body_link', 'body_vlink', 'body_alink', 'body_hlink', 'tr_color', 'th_color', 'td_color', 'fontcolor');
\r
111 $vars_5 = array('img_size_poll', 'img_size_privmsg');
\r
112 $vars_4 = array('fontsize', 'theme_public');
\r
113 foreach($theme as $var => $value)
\r
115 if(!is_integer($var) && $var !== 'themes_id' && $var !== 'template_name')
\r
117 // editable variable
\r
119 $sub = substr($var, 0, strlen($var) - 1);
\r
120 if(xs_in_array($var, $vars_100) || xs_in_array($sub, $vars_100))
\r
124 elseif(xs_in_array($var, $vars_50) || xs_in_array($sub, $vars_50))
\r
128 elseif(xs_in_array($var, $vars_30) || xs_in_array($sub, $vars_30))
\r
132 elseif(xs_in_array($var, $vars_25) || xs_in_array($sub, $vars_25))
\r
136 elseif(xs_in_array($var, $vars_6) || xs_in_array($sub, $vars_6))
\r
140 elseif(xs_in_array($var, $vars_5) || xs_in_array($sub, $vars_5))
\r
144 elseif(xs_in_array($var, $vrs_4) || xs_in_array($sub, $vars_4))
\r
148 elseif(strpos($var, 'class'))
\r
152 elseif(strpos($var, 'color'))
\r
161 'color' => $len == 6 ? true : false,
\r
162 'font' => $len == 25 ? true : false,
\r
164 if($var === 'style_name' || $var === 'head_stylesheet' || $var === 'body_background')
\r
166 $arr1[$var] = $item;
\r
170 $arr2[$var] = $item;
\r
177 if(defined('XS_MODS_CATEGORY_HIERARCHY210'))
\r
179 // force sort for the added fields
\r
181 'style_name' => array(),
\r
182 'images_pack' => array('var' => $item['images_pack'], 'len' => 100, 'color' => false, 'font' => false),
\r
183 'custom_tpls' => array('var' => $item['custom_tpls'], 'len' => 100, 'color' => false, 'font' => false),
\r
184 'head_stylesheet' => array(),
\r
186 $arr1 = array_merge($added, $arr1);
\r
187 // we need to add lang entries
\r
189 $lang['xs_data_images_pack'] = $lang['Images_pack'];
\r
190 $lang['xs_data_images_pack_explain'] = $lang['Images_pack_explain'];
\r
191 $lang['xs_data_custom_tpls'] = $lang['Custom_tpls'];
\r
192 $lang['xs_data_custom_tpls_explain'] = $lang['Custom_tpls_explain'];
\r
194 return array_merge($arr1, $arr2);
\r
200 if(!empty($HTTP_POST_VARS['edit']) && !defined('DEMO_MODE'))
\r
202 $id = intval($HTTP_POST_VARS['edit']);
\r
203 $lang['xs_edittpl_back_edit'] = str_replace('{URL}', append_sid('xs_edit_data.'.$phpEx.'?edit='.$id), $lang['xs_edittpl_back_edit']);
\r
204 $data_item = array();
\r
205 $data_item_update = array();
\r
206 $data_name = array();
\r
207 $data_name_insert_vars = array('themes_id');
\r
208 $data_name_insert_values = array($id);
\r
209 $data_name_update = array();
\r
210 foreach($HTTP_POST_VARS as $var => $value)
\r
212 if(substr($var, 0, 5) === 'edit_')
\r
214 $var = substr($var, 5);
\r
215 $value = stripslashes($value);
\r
216 $data_item[$var] = $value;
\r
217 $data_item_update[] = $var . "='" . xs_sql($value) . "'";
\r
219 elseif(substr($var, 0, 5) === 'name_')
\r
221 $var = substr($var, 5).'_name';
\r
222 $value = stripslashes($value);
\r
223 $data_name[$var] = $value;
\r
224 $data_name_update[] = $var . "='" . xs_sql($value) . "'";
\r
225 $data_name_insert_vars[] = $var;
\r
226 $data_name_insert_values[] = xs_sql($value);
\r
230 $sql = "UPDATE " . THEMES_TABLE . " SET " . implode(',', $data_item_update) . " WHERE themes_id='{$id}'";
\r
231 if(!$result = $db->sql_query($sql))
\r
233 xs_error($lang['xs_edittpl_error_updating'] . '<br /><br />' . $lang['xs_edittpl_back_edit'] . '<br /><br />' . $lang['xs_edittpl_back_list'], __LINE__, __FILE__);
\r
235 // check if there is name
\r
236 $sql = "SELECT themes_id FROM " . THEMES_NAME_TABLE . " WHERE themes_id='{$id}'";
\r
237 if(!$result = $db->sql_query($sql))
\r
239 $sql = "INSERT INTO " . THEMES_NAME_TABLE . " (" . implode(',', $data_name_insert_vars) . ") VALUES ('" . implode("', '", $data_name_insert_values) . "')";
\r
241 $item = $db->sql_fetchrow($result);
\r
242 if(!is_array($item))
\r
244 $sql = "INSERT INTO " . THEMES_NAME_TABLE . " (" . implode(',', $data_name_insert_vars) . ") VALUES ('" . implode("', '", $data_name_insert_values) . "')";
\r
248 $sql = "UPDATE " . THEMES_NAME_TABLE . " SET " . implode(',', $data_name_update) . " WHERE themes_id='{$id}'";
\r
250 $db->sql_query($sql);
\r
251 // regen themes cache
\r
252 if(defined('XS_MODS_CATEGORY_HIERARCHY210'))
\r
254 if ( empty($themes) )
\r
256 $themes = new themes();
\r
258 if ( !empty($themes) )
\r
260 $themes->read(true);
\r
263 xs_message($lang['Information'], $lang['xs_edittpl_style_updated'] . '<br /><br />' . $lang['xs_edittpl_back_edit'] . '<br /><br />' . $lang['xs_edittpl_back_list']);
\r
269 if(!empty($HTTP_GET_VARS['edit']))
\r
271 $id = intval($HTTP_GET_VARS['edit']);
\r
272 $sql = "SELECT * FROM " . THEMES_TABLE . " WHERE themes_id='{$id}'";
\r
273 if(!$result = $db->sql_query($sql))
\r
275 xs_error($lang['xs_no_style_info'], __LINE__, __FILE__);
\r
277 $item = $db->sql_fetchrow($result);
\r
278 if(empty($item['themes_id']))
\r
280 xs_error($lang['xs_invalid_style_id'] . '<br /><br />' . $lang['xs_edittpl_back_list']);
\r
282 $sql = "SELECT * FROM " . THEMES_NAME_TABLE . " WHERE themes_id='{$id}'";
\r
283 if(!$result = $db->sql_query($sql))
\r
285 $item_name = array();
\r
287 $item_name = $db->sql_fetchrow($result);
\r
288 if($item_name === false || !@count($item_name))
\r
290 $item_name = xs_empty_name();
\r
292 $vars = xs_get_vars($item);
\r
294 $template->assign_vars(array(
\r
295 'U_ACTION' => append_sid('xs_edit_data.'.$phpEx),
\r
296 'TPL' => htmlspecialchars($item['template-name']),
\r
297 'STYLE' => htmlspecialchars($item['style_name']),
\r
303 foreach($vars as $var => $value)
\r
305 $row_class = $xs_row_class[$i % 2];
\r
307 if(isset($lang['xs_data_'.$var]))
\r
309 $text = $lang['xs_data_'.$var];
\r
313 $str = substr($var, 0, strlen($var) - 1);
\r
314 $str_fc = substr($var, 0, strlen($var) - 2);
\r
315 if(isset($lang['xs_data_'.$str_fc]))
\r
317 $str1 = substr($var, strlen($var) - 2);
\r
318 $text = sprintf($lang['xs_data_'.$str_fc], $str1);
\r
320 else if(isset($lang['xs_data_'.$str]))
\r
322 $str1 = substr($var, strlen($var) - 1);
\r
323 $text = sprintf($lang['xs_data_'.$str], $str1);
\r
327 $text = sprintf($lang['xs_data_unknown'], $var);
\r
330 $template->assign_block_vars('row', array(
\r
331 'ROW_CLASS' => $row_class,
\r
333 'VALUE' => isset($item[$var]) ? htmlspecialchars($item[$var]) : '',
\r
334 'LEN' => $value['len'],
\r
335 'SIZE' => $value['len'] < 10 ? 10 : 30,
\r
336 'TEXT' => htmlspecialchars($text),
\r
337 'EXPLAIN' => isset($lang['xs_data_' . $var . '_explain']) ? $lang['xs_data_' . $var . '_explain'] : '',
\r
340 if($value['color'])
\r
342 $template->assign_block_vars('row.color', array());
\r
346 $template->assign_block_vars('row.font', array());
\r
348 if(isset($item_name[$var.'_name']))
\r
350 $template->assign_block_vars('row.name', array(
\r
351 'DATA' => $item_name[$var.'_name']
\r
357 $template->assign_block_vars('row.noname', array());
\r
360 $template->set_filenames(array('body' => XS_TPL_PATH . 'edit_data.tpl'));
\r
361 $template->pparse('body');
\r
367 // show list of installed styles
\r
369 $sql = 'SELECT themes_id, template_name, style_name FROM ' . THEMES_TABLE . ' ORDER BY style_name';
\r
370 if(!$result = $db->sql_query($sql))
\r
372 xs_error($lang['xs_no_style_info'], __LINE__, __FILE__);
\r
374 $style_rowset = $db->sql_fetchrowset($result);
\r
376 $template->set_filenames(array('body' => XS_TPL_PATH . 'edit_data_list.tpl'));
\r
377 for($i=0; $i<count($style_rowset); $i++)
\r
379 $item = $style_rowset[$i];
\r
380 $row_class = $xs_row_class[$i % 2];
\r
381 $template->assign_block_vars('styles', array(
\r
382 'ROW_CLASS' => $row_class,
\r
383 'TPL' => htmlspecialchars($item['template_name']),
\r
384 'STYLE' => htmlspecialchars($item['style_name']),
\r
385 'U_EDIT' => append_sid('xs_edit_data.'.$phpEx.'?edit='.$item['themes_id'])
\r
390 $template->pparse('body');
\r