[19486] | 1 | <?php |
---|
| 2 | load_language('theme.lang', PHPWG_THEMES_PATH.'cuise/'); |
---|
| 3 | $params = array_merge(unserialize($conf['cuise'])); |
---|
| 4 | |
---|
| 5 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 6 | { |
---|
| 7 | die ("Hacking attempt!"); |
---|
| 8 | } |
---|
| 9 | |
---|
| 10 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 11 | include_once(PHPWG_ROOT_PATH.'include/template.class.php'); |
---|
| 12 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 16 | global $themeconf,$parent,$user; |
---|
| 17 | global $nb_template; |
---|
| 18 | $nb_template=5 ; |
---|
| 19 | global $id; |
---|
| 20 | |
---|
| 21 | include_once(PHPWG_ROOT_PATH.'themes/cuise/themeconf.inc.php'); |
---|
| 22 | $save_options=false ; |
---|
| 23 | |
---|
| 24 | define ('PHPWG_THEME_PATH',PHPWG_THEMES_PATH.$themeconf['name']."/" ); |
---|
| 25 | |
---|
| 26 | $my_base_url="admin.php?page=theme&theme=".$themeconf['name']; |
---|
| 27 | $tabsheet = new tabsheet(); |
---|
| 28 | $tabsheet->add( 'admin', |
---|
| 29 | l10n('admin'), |
---|
| 30 | $my_base_url.'&tab=admin' |
---|
| 31 | ); |
---|
| 32 | |
---|
| 33 | $tabsheet->add( 'texture', |
---|
| 34 | l10n('texture'), |
---|
| 35 | $my_base_url.'&tab=texture' |
---|
| 36 | ); |
---|
| 37 | |
---|
[19990] | 38 | $tabsheet->add( 'test', |
---|
| 39 | l10n('test'), |
---|
| 40 | $my_base_url.'&tab=test' |
---|
| 41 | ); |
---|
[19486] | 42 | |
---|
| 43 | if (!isset($_GET['tab'])) |
---|
| 44 | $page['tab'] = 'admin'; |
---|
| 45 | else |
---|
| 46 | $page['tab'] = $_GET['tab']; |
---|
| 47 | |
---|
| 48 | $tabsheet->select($page['tab']); |
---|
| 49 | $tabsheet->assign(); |
---|
| 50 | /************************* |
---|
| 51 | * |
---|
| 52 | *************************/ |
---|
| 53 | if(!function_exists("cl_print_var")){ |
---|
| 54 | function cl_print_var($variables){ |
---|
| 55 | ob_start(); |
---|
| 56 | echo '<pre>'; |
---|
| 57 | print_r($variables); |
---|
| 58 | echo '</pre>'; |
---|
| 59 | $m= ob_get_contents(); |
---|
| 60 | ob_end_clean(); |
---|
| 61 | return $m; |
---|
| 62 | } |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | if (isset($_POST['submit'])){ |
---|
| 67 | $val_id=$_POST['submit']; |
---|
| 68 | $save_options=true ; |
---|
| 69 | } |
---|
| 70 | if (isset($_POST['compiled-templates']) ){ |
---|
| 71 | $template->delete_compiled_templates(); |
---|
| 72 | $FileCombiner = new FileCombiner("tpl") ; |
---|
| 73 | $FileCombiner::clear_combined_files(); |
---|
[19990] | 74 | array_push($page['infos'],l10n('parent') . ":" . $_POST['compiled-templates']); |
---|
| 75 | // array_push($page['infos'], l10n('delete_compiled')); |
---|
[19486] | 76 | $parent=$_POST['compiled-templates']; |
---|
| 77 | $save_options=true ; |
---|
| 78 | } |
---|
| 79 | for($id=0;$id<$nb_template;$id++){ |
---|
| 80 | if (!isset($params["chk_cuise_$id"])){ |
---|
| 81 | $_POST['default']=true ; |
---|
| 82 | } |
---|
| 83 | } |
---|
| 84 | $id=0; |
---|
[19990] | 85 | $name_tpl = array("fondBG","fondBp","Menu_bar","thumbnail","Header" ); |
---|
| 86 | $params = array_merge(unserialize($conf['cuise'])); |
---|
[19486] | 87 | if (isset($_POST['default']) || !isset($params['chk_cuise_0']) ){ |
---|
| 88 | |
---|
| 89 | $params['parent']= $parent ; |
---|
| 90 | $params['theme']= 'cuise' ; |
---|
[19990] | 91 | $name_img=array("cbmt.gif","bpv.png","bp3.jpg","bph.png","header.png"); |
---|
[19486] | 92 | for($id=0;$id<$nb_template;$id++){ |
---|
[19990] | 93 | $params = array_merge($params,array( |
---|
| 94 | "bg_cuise_$id" => '#d4d4d4', |
---|
| 95 | "bgho_cuise_$id" => '#A0A0A0', |
---|
| 96 | "bd_cuise_$id" => '#4F4F4F', |
---|
| 97 | "bdho_cuise_$id" => '#4F4F4F', |
---|
| 98 | "bd_width_cuise_$id" => '0px', |
---|
| 99 | "co_cuise_$id" => '#4F4F4F', |
---|
| 100 | "coho_cuise_$id" => '#5f5f5f', |
---|
| 101 | "img_cuise_$id" => $name_img[$id], |
---|
| 102 | "chk_cuise_x_$id" => 'checked', |
---|
| 103 | "chk_cuise_y_$id" => '', |
---|
| 104 | "rayon_cuise_$id" => '8px', |
---|
| 105 | "chk_cuise_$id" => '' |
---|
[19486] | 106 | |
---|
| 107 | )); |
---|
| 108 | } |
---|
| 109 | $id=0; |
---|
[19990] | 110 | // array_push($page['warnings'], cl_print_var($params)); |
---|
[19486] | 111 | $save_options=true ; |
---|
| 112 | |
---|
| 113 | } |
---|
| 114 | if ($save_options==true) { |
---|
[19990] | 115 | // array_push($page['warnings'], print_r($_POST,true)); |
---|
[19486] | 116 | $i="0"; |
---|
| 117 | $New_params=array(); |
---|
| 118 | $j=$i; |
---|
| 119 | for($i=0;$i<$nb_template;$i++){ |
---|
| 120 | if( isset($_POST["bg_cuise_$i"]) ) { |
---|
| 121 | |
---|
| 122 | $img_src= (isset($_POST["img_cuise_$i"])&&$_POST["img_cuise_$i"]!="")?$_POST["img_cuise_$i"]:$params["img_cuise_$i"] ; |
---|
| 123 | |
---|
| 124 | $New_params = array( |
---|
| 125 | "bg_cuise_$i" => isset($_POST["bg_cuise_$i"])?$_POST["bg_cuise_$i"]:$params["bg_cuise_$i"], |
---|
| 126 | "bgho_cuise_$i" => isset($_POST["bgho_cuise_$i"])?$_POST["bgho_cuise_$i"]:$params["bgho_cuise_$i"], |
---|
| 127 | "bd_cuise_$i" => isset($_POST["bd_cuise_$i"])?$_POST["bd_cuise_$i"]:$params["bd_cuise_$i"], |
---|
[19990] | 128 | "bdho_cuise_$id" => isset($_POST["bdho_cuise_$i"])?$_POST["bdho_cuise_$i"]:$params["bdho_cuise_$i"], |
---|
| 129 | "bd_width_cuise_$id" => isset($_POST["bd_width_cuise_$i"])?$_POST["bd_width_cuise_$i"]:$params["bd_width_cuise_$i"], |
---|
[19486] | 130 | "co_cuise_$i" => isset($_POST["co_cuise_$i"])?$_POST["co_cuise_$i"]:$params["co_cuise_$i"], |
---|
| 131 | "coho_cuise_$i" => isset($_POST["coho_cuise_$i"])?$_POST["coho_cuise_$i"]:$params["coho_cuise_$i"], |
---|
| 132 | "img_cuise_$i" =>$img_src, |
---|
| 133 | "rayon_cuise_$i" => isset($_POST["rayon_cuise_$i"])?$_POST["rayon_cuise_$i"]:$params["rayon_cuise_$i"], |
---|
[19990] | 134 | "chk_cuise_$i" => isset($_POST["chk_cuise_$i"])?"checked":"no", |
---|
[19486] | 135 | "chk_cuise_x_$i" => isset($_POST["chk_cuise_x_$i"])?"checked":"no", |
---|
| 136 | "chk_cuise_y_$i" => isset($_POST["chk_cuise_y_$i"])?"checked":"no", |
---|
| 137 | ); |
---|
| 138 | $id=$i; |
---|
| 139 | break; |
---|
| 140 | } |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | $i=$j; |
---|
| 144 | $params = array_merge($params,$New_params ,array('parent' => $parent, |
---|
| 145 | "theme" => PHPWG_THEMES_PATH.$themeconf['name']."/" |
---|
| 146 | )); |
---|
| 147 | |
---|
[19990] | 148 | // |
---|
[19486] | 149 | conf_update_param('cuise', pwg_db_real_escape_string(serialize($params))); |
---|
| 150 | array_push($page['infos'], l10n('Your configuration settings are saved')); |
---|
| 151 | load_conf_from_db(); |
---|
| 152 | $params = array_merge(unserialize($conf['cuise'])); |
---|
| 153 | $keys=$params; |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | // array_push($page['warnings'], print_r($parent,true) ); |
---|
| 157 | // array_push($page['warnings'], print_r($params,true)); |
---|
| 158 | |
---|
| 159 | $params = array_merge(unserialize($conf['cuise'])); |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | |
---|
[19990] | 163 | |
---|
[19486] | 164 | if(isset($val_id)){ |
---|
| 165 | $ids = explode("_",$val_id) ; |
---|
| 166 | $id= ( isset($ids[1]) ) ? $ids[1] :0; |
---|
| 167 | |
---|
| 168 | } |
---|
| 169 | $id= isset( $_POST["sel_tab"] ) ? $_POST["sel_tab"]: $id; |
---|
| 170 | |
---|
| 171 | if(!isset($id)) $id=0; |
---|
| 172 | //============================================== |
---|
| 173 | // $list_themes = get_list_dirs("themes"); |
---|
| 174 | |
---|
| 175 | get_list_theme(); |
---|
[19990] | 176 | $arguments=""; |
---|
| 177 | foreach ($params as $key => $value) { |
---|
| 178 | $value = str_replace("#", "_", $value); |
---|
| 179 | |
---|
| 180 | $arguments .= "$key=$value&"; |
---|
| 181 | } |
---|
| 182 | $arguments .="redraw=ok"; |
---|
[19486] | 183 | $template->assign(array( |
---|
[19990] | 184 | 'THEME_CUISE_ABS' => realpath(PHPWG_THEMES_PATH.'cuise/admin/'), |
---|
| 185 | 'root' => PHPWG_ROOT_PATH, |
---|
| 186 | 'theme' => PHPWG_THEME_PATH, |
---|
| 187 | "classeRoot" => PHPWG_THEMES_PATH.'cuise/admin/classes/' , |
---|
| 188 | 'parent' => $parent, |
---|
[19486] | 189 | |
---|
[19990] | 190 | 'nb_template' => $nb_template, |
---|
| 191 | 'ind' => $id, |
---|
| 192 | 'name_tpl' => $name_tpl, |
---|
[19486] | 193 | 'selected_bg_cuise' => $params['bg_cuise_'.$id], |
---|
[19990] | 194 | 'selected_bgho_cuise' => $params['bgho_cuise_'.$id], |
---|
[19486] | 195 | 'selected_bd_cuise' => $params['bd_cuise_'.$id], |
---|
[19990] | 196 | 'selected_bdho_cuise' => $params['bdho_cuise_'.$id], |
---|
| 197 | 'selected_bd_width_cuise' => $params['bd_width_cuise_'.$id], |
---|
| 198 | |
---|
| 199 | 'selected_co_cuise' => $params['co_cuise_'.$id], |
---|
[19486] | 200 | 'selected_coho_cuise' => $params['coho_cuise_'.$id], |
---|
| 201 | 'selected_img_cuise' => $params['img_cuise_'.$id], |
---|
[19990] | 202 | 'selected_rayon_cuise' => $params['rayon_cuise_'.$id], |
---|
[19486] | 203 | |
---|
[19990] | 204 | 'selected_chk_x_cuise' => ($params['chk_cuise_x_'.$id]=="checked")?"checked":"", |
---|
| 205 | 'selected_chk_y_cuise' => ($params['chk_cuise_y_'.$id]=="checked")?"checked":"", |
---|
[19486] | 206 | 'selected_chk_cuise' => ($params['chk_cuise_'.$id]=="checked")?"checked":"", |
---|
[19990] | 207 | 'params' => $arguments |
---|
[19486] | 208 | |
---|
| 209 | )); |
---|
| 210 | //=============================================== |
---|
| 211 | if (isset($_GET['hlp'])){ |
---|
| 212 | global $BGIMGcss, $BGcolcss; |
---|
| 213 | if ($_GET['hlp']=="1") |
---|
| 214 | $theme_css= "themes/".$themeconf['name']."/theme.css.css"; |
---|
| 215 | else if ($_GET['hlp']=="2") |
---|
| 216 | $theme_css= "themes/".$themeconf['parent']."/theme.css"; |
---|
| 217 | else if ($_GET['hlp']=="3") |
---|
| 218 | $theme_css= "themes/".$themeconf['name']."/theme.css.php"; |
---|
| 219 | else { |
---|
| 220 | $path="themes/".$themeconf['name']."/"; |
---|
| 221 | $theme_css=$path."theme.css.php"; |
---|
| 222 | if(!file_exists($theme_css)){ |
---|
| 223 | $theme_css=$path."css/style.css"; |
---|
| 224 | if(!file_exists($theme_css)){ |
---|
| 225 | $theme_css=$path."css/theme.css"; |
---|
| 226 | if(!file_exists($theme_css)){ |
---|
| 227 | $theme_css=$path."style.css"; |
---|
| 228 | if(!file_exists($theme_css)){ |
---|
| 229 | $theme_css=$path."theme.css"; |
---|
| 230 | } |
---|
| 231 | } |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | |
---|
| 235 | } |
---|
| 236 | } |
---|
| 237 | $arguments = $conf['cuise']; |
---|
[19990] | 238 | |
---|
[19486] | 239 | $Css =css($theme_css); |
---|
[19990] | 240 | |
---|
[19486] | 241 | $message =$theme_css."<br>"; |
---|
[19990] | 242 | $message .= cl_print_var($Css)."<br>"; |
---|
[19486] | 243 | //$message .= cl_print_var($BGIMGcss)."<br>"; |
---|
[19990] | 244 | //$message .= cl_print_var($BGcolcss)."<br>"; |
---|
[19486] | 245 | |
---|
| 246 | array_push($page['infos'], $message); |
---|
| 247 | } |
---|
| 248 | //=============================================== |
---|
| 249 | |
---|
| 250 | $template->assign('options', unserialize($conf['cuise'])); |
---|
| 251 | switch ($page['tab']) { |
---|
| 252 | case 'admin': |
---|
| 253 | $template->set_filenames(array('theme_admin_content' => dirname(__FILE__) . '/cuise_admin.tpl')); |
---|
| 254 | $template->assign_var_from_handle('ADMIN_CONTENT', 'theme_admin_content'); |
---|
| 255 | break; |
---|
| 256 | case 'texture': |
---|
| 257 | $template->set_filenames(array('theme_admin_content' => dirname(__FILE__) . '/cuise_texture.tpl')); |
---|
| 258 | $template->assign_var_from_handle('ADMIN_CONTENT', 'theme_admin_content'); |
---|
| 259 | break ; |
---|
[19990] | 260 | case 'test': |
---|
| 261 | $template->set_filenames(array('theme_admin_content' => dirname(__FILE__) . '/cuise_test.tpl')); |
---|
| 262 | $template->assign_var_from_handle('ADMIN_CONTENT', 'theme_admin_content'); |
---|
| 263 | break ; |
---|
[19486] | 264 | } |
---|
| 265 | |
---|
| 266 | //================================================ |
---|
| 267 | function css($theme_local) { |
---|
| 268 | global $BGIMGcss, $BGcolcss; |
---|
| 269 | $BGIMGcss=Array(); |
---|
| 270 | $BGcolcss=Array(); |
---|
| 271 | |
---|
| 272 | $path = $_SERVER['DOCUMENT_ROOT']; |
---|
| 273 | if (substr($path,-1)=='/'){ |
---|
| 274 | $path = substr($path,0,-1); |
---|
| 275 | } |
---|
| 276 | if(isset($_GET['path'])) |
---|
| 277 | $path=$_GET['path']; |
---|
| 278 | else |
---|
| 279 | $path=PHPWG_ROOT_PATH."local/css/"; |
---|
| 280 | |
---|
| 281 | $path=""; |
---|
| 282 | $mycssfile=$path.$theme_local; |
---|
| 283 | |
---|
| 284 | if(!file_exists($theme_local)) |
---|
| 285 | |
---|
| 286 | $mycssfile=$path."default-rules.css"; |
---|
| 287 | |
---|
| 288 | if(!file_exists($mycssfile)){ |
---|
| 289 | return Array(); |
---|
| 290 | } |
---|
| 291 | |
---|
| 292 | |
---|
| 293 | |
---|
| 294 | function remove_comments( & $string ) { |
---|
| 295 | $order = array("/}/","/\r\n/",'#/\*.*?\*/#s','/\n/','/\r/','/\s[\s]+/'); |
---|
| 296 | $replace = array('}|' ,'' ,'' ,'' ,'' ,'' ); |
---|
| 297 | $string = preg_replace($order, $replace,$string); |
---|
[19990] | 298 | |
---|
[19486] | 299 | // $string = preg_replace('#/\*.*?\*/#s',"",$string); |
---|
| 300 | return $string; |
---|
| 301 | } |
---|
| 302 | |
---|
| 303 | $ret = file_get_contents ($mycssfile); |
---|
[19990] | 304 | // echo $ret; |
---|
[19486] | 305 | |
---|
| 306 | $string= remove_comments( $ret); |
---|
[19990] | 307 | // echo ($string); |
---|
[19486] | 308 | |
---|
| 309 | $newstr = explode('|',$ret); |
---|
| 310 | $css=Array(); |
---|
| 311 | $BGIMGcss=Array(); |
---|
| 312 | $BGcolcss=Array(); |
---|
| 313 | $order = array('/[\s]+/','/}/'); |
---|
| 314 | $replace = array(' ',""); |
---|
| 315 | |
---|
| 316 | |
---|
| 317 | foreach ($newstr as $key => $value) { |
---|
| 318 | |
---|
| 319 | $value = preg_replace($order, $replace, $value); |
---|
| 320 | $value = trim($value); |
---|
| 321 | |
---|
| 322 | |
---|
| 323 | if($value){ |
---|
[19990] | 324 | |
---|
[19486] | 325 | $css2=Array(); |
---|
| 326 | $key = explode("{",$value); |
---|
| 327 | $key_id= $key[0]; |
---|
| 328 | if(isset($key[1])) |
---|
| 329 | $value = $key[1] ; |
---|
| 330 | |
---|
| 331 | $value=explode(";",$value); |
---|
| 332 | foreach ($value as $key2 => $value2) { |
---|
| 333 | if($value2){ |
---|
| 334 | |
---|
| 335 | $value2 = str_replace(" ", '', $value2); |
---|
| 336 | |
---|
| 337 | |
---|
| 338 | $key2=explode(":",$value2); |
---|
| 339 | if(isset($key2[1])) { |
---|
| 340 | $key2[0]=trim($key2[0]); |
---|
| 341 | $css2[$key2[0]] = trim($key2[1]) ; |
---|
| 342 | |
---|
| 343 | |
---|
| 344 | if(preg_match("/url/",$key2[1])){ |
---|
| 345 | $head = preg_replace("#(.*)url.(.*?)\)(.*)#is", '$2', $key2[1]); |
---|
[19990] | 346 | |
---|
[19486] | 347 | $BGIMGcss[$head]=array_merge(array( |
---|
| 348 | "head" => $head, |
---|
| 349 | "clef" => $key_id, |
---|
| 350 | "val" => $key2[0], |
---|
| 351 | )); |
---|
| 352 | |
---|
| 353 | }elseif(preg_match("/(color)/",$key2[0])){ |
---|
| 354 | $head = preg_replace("#(.*)color.(.*?);(.*)#is", '$2', $key2[1]); |
---|
[19990] | 355 | |
---|
[19486] | 356 | |
---|
| 357 | $BGcolcss[$head]=array_merge(array( |
---|
| 358 | "head" => $head, |
---|
| 359 | "clef" => $key_id, |
---|
| 360 | "val" => $key2[0], |
---|
| 361 | )); |
---|
| 362 | |
---|
| 363 | }else{ |
---|
| 364 | // echo " no " . $key_id . "{" . $key2[0] . " : " . $key2[1] ."}<br>"; |
---|
| 365 | } |
---|
| 366 | } |
---|
| 367 | } |
---|
| 368 | } |
---|
| 369 | |
---|
| 370 | |
---|
| 371 | $css[$key_id]=$css2 ; |
---|
| 372 | } |
---|
| 373 | } |
---|
[19990] | 374 | |
---|
[19486] | 375 | return $css; |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | |
---|
| 379 | function get_list_theme() |
---|
| 380 | { |
---|
| 381 | global $user, $template, $conf,$parent; |
---|
| 382 | foreach (get_pwg_themes() as $id => $name) { |
---|
| 383 | $img = PHPWG_THEMES_PATH.$id.'/screenshot.png'; |
---|
| 384 | if (file_exists($img)) { |
---|
| 385 | $theme = array( |
---|
| 386 | 'id' => $id, |
---|
| 387 | 'name' => $name, |
---|
| 388 | 'url' => add_url_params( duplicate_index_url(), array('theme'=>$id) ), |
---|
| 389 | 'img' => $img, |
---|
| 390 | ); |
---|
| 391 | if ($id==$parent){ |
---|
| 392 | $template->assign('list_themes_active', $theme); |
---|
| 393 | } |
---|
| 394 | |
---|
| 395 | $template->append('list_themes', $theme); |
---|
| 396 | } |
---|
| 397 | } |
---|
| 398 | } |
---|
| 399 | |
---|
| 400 | function get_list_dirs($path='') |
---|
| 401 | { |
---|
| 402 | $options = array(); |
---|
| 403 | global $parent ; |
---|
| 404 | $options= array(); |
---|
| 405 | if (is_dir($path)) { |
---|
| 406 | $fh = opendir($path); |
---|
| 407 | while ($file = readdir($fh)) |
---|
| 408 | { |
---|
| 409 | $pathfile = $path . '/' . $file; |
---|
| 410 | if ($file != '.' and $file != '..' and $file != '.svn' and is_dir($pathfile)) |
---|
| 411 | { |
---|
| 412 | |
---|
| 413 | |
---|
| 414 | $options[$file] = array( |
---|
| 415 | 'name' => $file, |
---|
| 416 | 'url' => $pathfile, |
---|
| 417 | 'select' => ($file==$parent) ? 'selected="selected"' : "false", |
---|
| 418 | ); |
---|
| 419 | |
---|
| 420 | } |
---|
| 421 | } |
---|
| 422 | closedir($fh); |
---|
| 423 | } |
---|
| 424 | return $options; |
---|
| 425 | } |
---|
| 426 | |
---|
| 427 | |
---|
| 428 | ?> |
---|