[10297] | 1 | <?php |
---|
| 2 | |
---|
| 3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 4 | |
---|
| 5 | global $template, $conf, $user; |
---|
| 6 | |
---|
| 7 | load_language('plugin.lang', ICONSET_PATH); |
---|
| 8 | $page['infos'] = array(); |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | if (isset($_POST['envoi_config']) and $_POST['envoi_config']=='iconset') |
---|
| 12 | { |
---|
| 13 | check_pwg_token(); |
---|
[10326] | 14 | $conf_iconset = @unserialize($conf['iconset']);//pwg_db_real_escape_string(serialize($conf_iconset)) |
---|
| 15 | $conf_themes=$conf_iconset['themes']; |
---|
| 16 | $conf_icons=$conf_iconset['icons']; |
---|
| 17 | $conf_icons=$conf_iconset['icons']; |
---|
| 18 | $error_update=''; |
---|
| 19 | $update_ok=''; |
---|
| 20 | foreach ($conf_themes as $theme_id => $iconset) // theme supprimé |
---|
| 21 | { |
---|
| 22 | if (isset($_POST[$theme_id]) and isset($conf_themes[$theme_id]) and $conf_themes[$theme_id]!=$_POST[$theme_id] and in_array($_POST[$theme_id], $conf_icons)) |
---|
| 23 | { |
---|
| 24 | $conf_themes[$theme_id]=$_POST[$theme_id]; |
---|
| 25 | $update_ok.=$theme_id.' / '; |
---|
| 26 | } |
---|
| 27 | elseif (empty($_POST[$theme_id]) and $conf_themes[$theme_id]!=$_POST[$theme_id]) |
---|
| 28 | { |
---|
| 29 | $conf_themes[$theme_id]=''; |
---|
| 30 | $update_ok.=$theme_id.' / '; |
---|
| 31 | } |
---|
| 32 | elseif (!isset($_POST[$theme_id]) or !isset($conf_themes[$theme_id]) or (!in_array($_POST[$theme_id], $conf_icons) and !empty($_POST[$theme_id])) ) |
---|
| 33 | { |
---|
| 34 | $error_update.=$theme_id.' / '; |
---|
| 35 | } |
---|
| 36 | } |
---|
| 37 | $conf['iconset']=array( |
---|
| 38 | 'themes'=>$conf_themes, |
---|
| 39 | 'icons'=>$conf_icons |
---|
| 40 | ); |
---|
| 41 | $query = ' |
---|
| 42 | UPDATE '.CONFIG_TABLE.' |
---|
| 43 | SET value="'.pwg_db_real_escape_string(serialize($conf['iconset'])).'" |
---|
| 44 | WHERE param="iconset" |
---|
| 45 | LIMIT 1'; |
---|
| 46 | pwg_query($query); |
---|
| 47 | if (!empty($error_update)) { array_push($page['infos'], l10n('iconset_error_update').$error_update ); } |
---|
| 48 | if (!empty($update_ok)) { array_push($page['infos'], l10n('iconset_update_ok').$update_ok ); } |
---|
| 49 | load_conf_from_db(); |
---|
[10297] | 50 | } |
---|
| 51 | //////////////////////////////////////////////// |
---|
| 52 | ////////[ liste les icones dispo ] ////////// |
---|
| 53 | // RQ : un set d'icone = chemin vers le *.conf.php ; on associe (ou pas) un fichier *.conf.php par thème |
---|
| 54 | //////////////////////////////////////////////// |
---|
| 55 | function get_list_iconconf_path ($dir) { |
---|
| 56 | static $list_iconconf_path=array(); |
---|
| 57 | $dh = opendir ($dir); |
---|
| 58 | while (($file = readdir ($dh)) !== false ) { |
---|
| 59 | if ($file !== '.' && $file !== '..') { |
---|
| 60 | $path =$dir.'/'.$file; |
---|
| 61 | if (is_dir ($path)) { |
---|
| 62 | get_list_iconconf_path ($path); |
---|
| 63 | } |
---|
| 64 | else |
---|
| 65 | { |
---|
| 66 | $page = explode('.', $file); |
---|
| 67 | $nb = count($page); |
---|
| 68 | $nom_fichier = $page[0]; |
---|
| 69 | for ($i = 1; $i < $nb-1; $i++){ |
---|
| 70 | $nom_fichier .= '.'.$page[$i]; |
---|
| 71 | } |
---|
| 72 | if(isset($page[1])){ |
---|
| 73 | $ext_fichier = $page[$nb-2].'.'.$page[$nb-1]; |
---|
| 74 | } |
---|
| 75 | else { |
---|
| 76 | $ext_fichier = ''; |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | if($ext_fichier == 'conf.php') { //On ne prend que les .conf.php |
---|
[10299] | 80 | $path = str_replace("./plugins/Icons_Set/icons/", "", $path); |
---|
[10297] | 81 | $list_iconconf_path[]=$path; |
---|
| 82 | } |
---|
| 83 | } |
---|
| 84 | } |
---|
| 85 | } |
---|
| 86 | closedir ($dh); |
---|
| 87 | return $list_iconconf_path; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | function check_config() |
---|
| 91 | { |
---|
| 92 | global $conf, $prefixeTable, $page; |
---|
| 93 | $conf_iconset = @unserialize($conf['iconset']);//pwg_db_real_escape_string(serialize($conf_iconset)) |
---|
| 94 | include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php'); |
---|
| 95 | $themes = new themes(); |
---|
| 96 | $all_icons=get_list_iconconf_path ('./plugins/Icons_Set/icons'); |
---|
| 97 | if ( !isset($conf_iconset) or empty($conf_iconset) or !is_array($conf_iconset) ) |
---|
| 98 | { |
---|
| 99 | $conf['iconset']=array( |
---|
| 100 | 'themes'=>array(), |
---|
| 101 | 'icons'=>array() |
---|
| 102 | ); |
---|
| 103 | } |
---|
| 104 | $themes->sort_fs_themes(); |
---|
| 105 | $conf_themes=$conf_iconset['themes']; |
---|
| 106 | $conf_icons=$conf_iconset['icons']; |
---|
| 107 | $list_theme_id=array(); |
---|
| 108 | $info_new_theme=''; |
---|
| 109 | $info_new_icon=''; |
---|
| 110 | $info_deleted_theme=''; |
---|
| 111 | $info_deleted_icon=''; |
---|
| 112 | foreach ($themes->fs_themes as $theme_id => $fs_theme) |
---|
| 113 | { |
---|
| 114 | if ((isset($fs_theme['activable']) and !$fs_theme['activable']) or $theme_id == 'default' ) |
---|
| 115 | { |
---|
| 116 | continue; |
---|
| 117 | } |
---|
| 118 | if (!array_key_exists($fs_theme['id'], $conf_themes)) // theme ajouté |
---|
| 119 | { |
---|
| 120 | $info_new_theme.=$theme_id.'<br>'; |
---|
| 121 | $conf_themes[$theme_id]=''; // RAZ |
---|
| 122 | } |
---|
| 123 | if (!empty($conf_themes[$theme_id]) and !in_array($conf_themes[$theme_id], $all_icons)) // association thème/icon supprimée |
---|
| 124 | { |
---|
| 125 | $info_deleted_icon.=$conf_themes[$theme_id].'<br>'; |
---|
| 126 | $conf_themes[$theme_id]=''; // RAZ |
---|
| 127 | } |
---|
| 128 | $list_theme_id[]=$theme_id; |
---|
| 129 | } |
---|
| 130 | foreach ($conf_themes as $theme_id => $iconset) // theme supprimé |
---|
| 131 | { |
---|
| 132 | if (!in_array($theme_id, $list_theme_id)) |
---|
| 133 | { |
---|
| 134 | $info_deleted_theme.=$theme_id.'<br>'; |
---|
| 135 | unset($conf_themes[$theme_id]);// suppression de sa config |
---|
| 136 | } |
---|
| 137 | } |
---|
| 138 | foreach ($all_icons as $iconset) // icones ajoutées |
---|
| 139 | { |
---|
| 140 | if (!in_array($iconset, $conf_icons)) |
---|
| 141 | { |
---|
| 142 | $info_new_icon.=$iconset.'<br>'; |
---|
| 143 | } |
---|
| 144 | } |
---|
| 145 | $conf['iconset']=array( |
---|
| 146 | 'themes'=>$conf_themes, |
---|
| 147 | 'icons'=>$all_icons |
---|
| 148 | ); |
---|
| 149 | $query = ' |
---|
| 150 | UPDATE '.CONFIG_TABLE.' |
---|
| 151 | SET value="'.pwg_db_real_escape_string(serialize($conf['iconset'])).'" |
---|
| 152 | WHERE param="iconset" |
---|
| 153 | LIMIT 1'; |
---|
| 154 | pwg_query($query); |
---|
[10326] | 155 | load_conf_from_db(); |
---|
[10297] | 156 | if (!empty($info_new_theme)) { array_push($page['infos'], l10n('iconset_info_new_theme').$info_new_theme ); } |
---|
| 157 | if (!empty($info_new_icon)) { array_push($page['infos'], l10n('iconset_info_new_icon').$info_new_icon ); } |
---|
| 158 | if (!empty($info_deleted_theme)) { array_push($page['infos'], l10n('iconset_info_deleted_theme').$info_deleted_theme ); } |
---|
| 159 | if (!empty($info_deleted_icon)) { array_push($page['infos'], l10n('iconset_info_deleted_icon').$info_deleted_icon ); } |
---|
| 160 | } |
---|
| 161 | check_config(); |
---|
| 162 | load_conf_from_db(); |
---|
| 163 | $conf_iconset = @unserialize($conf['iconset']);//pwg_db_real_escape_string(serialize($conf_iconset)) |
---|
| 164 | $conf_themes=$conf_iconset['themes']; |
---|
| 165 | $conf_icons=$conf_iconset['icons']; |
---|
| 166 | include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php'); |
---|
| 167 | $themes = new themes(); |
---|
| 168 | $themes->sort_fs_themes(); |
---|
| 169 | $all_themes=array(); |
---|
[10299] | 170 | foreach ($conf_themes as $theme_id => $iconset) |
---|
[10297] | 171 | { |
---|
| 172 | $all_themes[$theme_id]=array( |
---|
| 173 | 'name'=>$themes->fs_themes[$theme_id]['name'], |
---|
| 174 | 'id'=>$themes->fs_themes[$theme_id]['id'], |
---|
| 175 | 'screenshot'=>$themes->fs_themes[$theme_id]['screenshot'], |
---|
| 176 | 'icon'=>$iconset, |
---|
| 177 | ); |
---|
| 178 | } |
---|
[10299] | 179 | |
---|
| 180 | $all_icons=array(); |
---|
| 181 | $values=array(); |
---|
| 182 | $output=array(); |
---|
[10326] | 183 | $template->func_combine_css(array( |
---|
| 184 | 'path' => 'themes/default/iconset.css', |
---|
| 185 | ), |
---|
| 186 | $smarty |
---|
| 187 | ); |
---|
| 188 | |
---|
[10299] | 189 | foreach ($conf_icons as $iconset) |
---|
| 190 | { |
---|
| 191 | include_once('icons/'.$iconset); |
---|
| 192 | $all_icons[]=array( |
---|
| 193 | 'path'=>$iconset, |
---|
| 194 | 'name' => $iconsetconf['name'], |
---|
| 195 | 'id' => $iconsetconf['id'], |
---|
| 196 | 'icon_file' => $iconsetconf['icon_file'], |
---|
| 197 | 'css_file' => $iconsetconf['css_file'], |
---|
[10326] | 198 | 'css_file_admin' => $iconsetconf['css_file_admin'], |
---|
[10299] | 199 | ); |
---|
| 200 | $values[]=$iconset; |
---|
| 201 | $output[]=$iconsetconf['name']; |
---|
[10326] | 202 | $template->func_combine_css(array( |
---|
| 203 | 'path' => $iconsetconf['css_file_admin'], |
---|
| 204 | ), |
---|
| 205 | $smarty |
---|
| 206 | ); |
---|
[10299] | 207 | } |
---|
[10297] | 208 | $template->assign(array( |
---|
| 209 | 'all_themes' => $all_themes, |
---|
[10299] | 210 | 'all_icons' => $all_icons, |
---|
| 211 | 'values' => $values, |
---|
| 212 | 'output' => $output, |
---|
[10297] | 213 | )); |
---|
| 214 | |
---|
| 215 | $template->assign(array( |
---|
| 216 | 'PWG_TOKEN' => get_pwg_token() |
---|
| 217 | )); |
---|
| 218 | |
---|
| 219 | $template->func_combine_css(array( |
---|
| 220 | 'path' => 'plugins/'.ICONSET_DIR.'/template/admin.css', |
---|
| 221 | ), |
---|
| 222 | $smarty |
---|
| 223 | ); |
---|
[10326] | 224 | |
---|
[10297] | 225 | $template->set_filename('plugin_admin_content', dirname(__FILE__) .'/template/admin.tpl'); |
---|
| 226 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 227 | |
---|
| 228 | ?> |
---|