add( 'admin', l10n('admin'), $my_base_url.'&tab=admin' ); $tabsheet->add( 'texture', l10n('texture'), $my_base_url.'&tab=texture' ); $tabsheet->add( 'test', l10n('test'), $my_base_url.'&tab=test' ); if (!isset($_GET['tab'])) $page['tab'] = 'admin'; else $page['tab'] = $_GET['tab']; $tabsheet->select($page['tab']); $tabsheet->assign(); /************************* * *************************/ if(!function_exists("cl_print_var")){ function cl_print_var($variables){ ob_start(); echo '
';
    print_r($variables);
    echo '
'; $m= ob_get_contents(); ob_end_clean(); return $m; } } if (isset($_POST['submit'])){ $val_id=$_POST['submit']; $save_options=true ; } if (isset($_POST['compiled-templates']) ){ $template->delete_compiled_templates(); $FileCombiner = new FileCombiner("tpl") ; $FileCombiner::clear_combined_files(); array_push($page['infos'],l10n('parent') . ":" . $_POST['compiled-templates']); // array_push($page['infos'], l10n('delete_compiled')); $parent=$_POST['compiled-templates']; $save_options=true ; } for($id=0;$id<$nb_template;$id++){ if (!isset($params["chk_cuise_$id"])){ $_POST['default']=true ; } } $id=0; $name_tpl = array("fondBG","fondBp","Menu_bar","thumbnail","Header" ); $params = array_merge(unserialize($conf['cuise'])); if (isset($_POST['default']) || !isset($params['chk_cuise_0']) ){ $params['parent']= $parent ; $params['theme']= 'cuise' ; $name_img=array("cbmt.gif","bpv.png","bp3.jpg","bph.png","header.png"); for($id=0;$id<$nb_template;$id++){ $params = array_merge($params,array( "bg_cuise_$id" => '#d4d4d4', "bgho_cuise_$id" => '#A0A0A0', "bd_cuise_$id" => '#4F4F4F', "bdho_cuise_$id" => '#4F4F4F', "bd_width_cuise_$id" => '0px', "co_cuise_$id" => '#4F4F4F', "coho_cuise_$id" => '#5f5f5f', "img_cuise_$id" => $name_img[$id], "chk_cuise_x_$id" => 'checked', "chk_cuise_y_$id" => '', "rayon_cuise_$id" => '8px', "chk_cuise_$id" => '' )); } $id=0; // array_push($page['warnings'], cl_print_var($params)); $save_options=true ; } if ($save_options==true) { // array_push($page['warnings'], print_r($_POST,true)); $i="0"; $New_params=array(); $j=$i; for($i=0;$i<$nb_template;$i++){ if( isset($_POST["bg_cuise_$i"]) ) { $img_src= (isset($_POST["img_cuise_$i"])&&$_POST["img_cuise_$i"]!="")?$_POST["img_cuise_$i"]:$params["img_cuise_$i"] ; $New_params = array( "bg_cuise_$i" => isset($_POST["bg_cuise_$i"])?$_POST["bg_cuise_$i"]:$params["bg_cuise_$i"], "bgho_cuise_$i" => isset($_POST["bgho_cuise_$i"])?$_POST["bgho_cuise_$i"]:$params["bgho_cuise_$i"], "bd_cuise_$i" => isset($_POST["bd_cuise_$i"])?$_POST["bd_cuise_$i"]:$params["bd_cuise_$i"], "bdho_cuise_$id" => isset($_POST["bdho_cuise_$i"])?$_POST["bdho_cuise_$i"]:$params["bdho_cuise_$i"], "bd_width_cuise_$id" => isset($_POST["bd_width_cuise_$i"])?$_POST["bd_width_cuise_$i"]:$params["bd_width_cuise_$i"], "co_cuise_$i" => isset($_POST["co_cuise_$i"])?$_POST["co_cuise_$i"]:$params["co_cuise_$i"], "coho_cuise_$i" => isset($_POST["coho_cuise_$i"])?$_POST["coho_cuise_$i"]:$params["coho_cuise_$i"], "img_cuise_$i" =>$img_src, "rayon_cuise_$i" => isset($_POST["rayon_cuise_$i"])?$_POST["rayon_cuise_$i"]:$params["rayon_cuise_$i"], "chk_cuise_$i" => isset($_POST["chk_cuise_$i"])?"checked":"no", "chk_cuise_x_$i" => isset($_POST["chk_cuise_x_$i"])?"checked":"no", "chk_cuise_y_$i" => isset($_POST["chk_cuise_y_$i"])?"checked":"no", ); $id=$i; break; } } $i=$j; $params = array_merge($params,$New_params ,array('parent' => $parent, "theme" => PHPWG_THEMES_PATH.$themeconf['name']."/" )); // conf_update_param('cuise', pwg_db_real_escape_string(serialize($params))); array_push($page['infos'], l10n('Your configuration settings are saved')); load_conf_from_db(); $params = array_merge(unserialize($conf['cuise'])); $keys=$params; } // array_push($page['warnings'], print_r($parent,true) ); // array_push($page['warnings'], print_r($params,true)); $params = array_merge(unserialize($conf['cuise'])); if(isset($val_id)){ $ids = explode("_",$val_id) ; $id= ( isset($ids[1]) ) ? $ids[1] :0; } $id= isset( $_POST["sel_tab"] ) ? $_POST["sel_tab"]: $id; if(!isset($id)) $id=0; //============================================== // $list_themes = get_list_dirs("themes"); get_list_theme(); $arguments=""; foreach ($params as $key => $value) { $value = str_replace("#", "_", $value); $arguments .= "$key=$value&"; } $arguments .="redraw=ok"; $template->assign(array( 'THEME_CUISE_ABS' => realpath(PHPWG_THEMES_PATH.'cuise/admin/'), 'root' => PHPWG_ROOT_PATH, 'theme' => PHPWG_THEME_PATH, "classeRoot" => PHPWG_THEMES_PATH.'cuise/admin/classes/' , 'parent' => $parent, 'nb_template' => $nb_template, 'ind' => $id, 'name_tpl' => $name_tpl, 'selected_bg_cuise' => $params['bg_cuise_'.$id], 'selected_bgho_cuise' => $params['bgho_cuise_'.$id], 'selected_bd_cuise' => $params['bd_cuise_'.$id], 'selected_bdho_cuise' => $params['bdho_cuise_'.$id], 'selected_bd_width_cuise' => $params['bd_width_cuise_'.$id], 'selected_co_cuise' => $params['co_cuise_'.$id], 'selected_coho_cuise' => $params['coho_cuise_'.$id], 'selected_img_cuise' => $params['img_cuise_'.$id], 'selected_rayon_cuise' => $params['rayon_cuise_'.$id], 'selected_chk_x_cuise' => ($params['chk_cuise_x_'.$id]=="checked")?"checked":"", 'selected_chk_y_cuise' => ($params['chk_cuise_y_'.$id]=="checked")?"checked":"", 'selected_chk_cuise' => ($params['chk_cuise_'.$id]=="checked")?"checked":"", 'params' => $arguments )); //=============================================== if (isset($_GET['hlp'])){ global $BGIMGcss, $BGcolcss; if ($_GET['hlp']=="1") $theme_css= "themes/".$themeconf['name']."/theme.css.css"; else if ($_GET['hlp']=="2") $theme_css= "themes/".$themeconf['parent']."/theme.css"; else if ($_GET['hlp']=="3") $theme_css= "themes/".$themeconf['name']."/theme.css.php"; else { $path="themes/".$themeconf['name']."/"; $theme_css=$path."theme.css.php"; if(!file_exists($theme_css)){ $theme_css=$path."css/style.css"; if(!file_exists($theme_css)){ $theme_css=$path."css/theme.css"; if(!file_exists($theme_css)){ $theme_css=$path."style.css"; if(!file_exists($theme_css)){ $theme_css=$path."theme.css"; } } } } } $arguments = $conf['cuise']; $Css =css($theme_css); $message =$theme_css."
"; $message .= cl_print_var($Css)."
"; //$message .= cl_print_var($BGIMGcss)."
"; //$message .= cl_print_var($BGcolcss)."
"; array_push($page['infos'], $message); } //=============================================== $template->assign('options', unserialize($conf['cuise'])); switch ($page['tab']) { case 'admin': $template->set_filenames(array('theme_admin_content' => dirname(__FILE__) . '/cuise_admin.tpl')); $template->assign_var_from_handle('ADMIN_CONTENT', 'theme_admin_content'); break; case 'texture': $template->set_filenames(array('theme_admin_content' => dirname(__FILE__) . '/cuise_texture.tpl')); $template->assign_var_from_handle('ADMIN_CONTENT', 'theme_admin_content'); break ; case 'test': $template->set_filenames(array('theme_admin_content' => dirname(__FILE__) . '/cuise_test.tpl')); $template->assign_var_from_handle('ADMIN_CONTENT', 'theme_admin_content'); break ; } //================================================ function css($theme_local) { global $BGIMGcss, $BGcolcss; $BGIMGcss=Array(); $BGcolcss=Array(); $path = $_SERVER['DOCUMENT_ROOT']; if (substr($path,-1)=='/'){ $path = substr($path,0,-1); } if(isset($_GET['path'])) $path=$_GET['path']; else $path=PHPWG_ROOT_PATH."local/css/"; $path=""; $mycssfile=$path.$theme_local; if(!file_exists($theme_local)) $mycssfile=$path."default-rules.css"; if(!file_exists($mycssfile)){ return Array(); } function remove_comments( & $string ) { $order = array("/}/","/\r\n/",'#/\*.*?\*/#s','/\n/','/\r/','/\s[\s]+/'); $replace = array('}|' ,'' ,'' ,'' ,'' ,'' ); $string = preg_replace($order, $replace,$string); // $string = preg_replace('#/\*.*?\*/#s',"",$string); return $string; } $ret = file_get_contents ($mycssfile); // echo $ret; $string= remove_comments( $ret); // echo ($string); $newstr = explode('|',$ret); $css=Array(); $BGIMGcss=Array(); $BGcolcss=Array(); $order = array('/[\s]+/','/}/'); $replace = array(' ',""); foreach ($newstr as $key => $value) { $value = preg_replace($order, $replace, $value); $value = trim($value); if($value){ $css2=Array(); $key = explode("{",$value); $key_id= $key[0]; if(isset($key[1])) $value = $key[1] ; $value=explode(";",$value); foreach ($value as $key2 => $value2) { if($value2){ $value2 = str_replace(" ", '', $value2); $key2=explode(":",$value2); if(isset($key2[1])) { $key2[0]=trim($key2[0]); $css2[$key2[0]] = trim($key2[1]) ; if(preg_match("/url/",$key2[1])){ $head = preg_replace("#(.*)url.(.*?)\)(.*)#is", '$2', $key2[1]); $BGIMGcss[$head]=array_merge(array( "head" => $head, "clef" => $key_id, "val" => $key2[0], )); }elseif(preg_match("/(color)/",$key2[0])){ $head = preg_replace("#(.*)color.(.*?);(.*)#is", '$2', $key2[1]); $BGcolcss[$head]=array_merge(array( "head" => $head, "clef" => $key_id, "val" => $key2[0], )); }else{ // echo " no " . $key_id . "{" . $key2[0] . " : " . $key2[1] ."}
"; } } } } $css[$key_id]=$css2 ; } } return $css; } function get_list_theme() { global $user, $template, $conf,$parent; foreach (get_pwg_themes() as $id => $name) { $img = PHPWG_THEMES_PATH.$id.'/screenshot.png'; if (file_exists($img)) { $theme = array( 'id' => $id, 'name' => $name, 'url' => add_url_params( duplicate_index_url(), array('theme'=>$id) ), 'img' => $img, ); if ($id==$parent){ $template->assign('list_themes_active', $theme); } $template->append('list_themes', $theme); } } } function get_list_dirs($path='') { $options = array(); global $parent ; $options= array(); if (is_dir($path)) { $fh = opendir($path); while ($file = readdir($fh)) { $pathfile = $path . '/' . $file; if ($file != '.' and $file != '..' and $file != '.svn' and is_dir($pathfile)) { $options[$file] = array( 'name' => $file, 'url' => $pathfile, 'select' => ($file==$parent) ? 'selected="selected"' : "false", ); } } closedir($fh); } return $options; } ?>