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