[5153] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[5153] | 4 | // +-----------------------------------------------------------------------+ |
---|
[26461] | 5 | // | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | |
---|
[5153] | 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
| 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
| 23 | |
---|
| 24 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
| 25 | { |
---|
| 26 | die ("Hacking attempt!"); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php'); |
---|
| 30 | |
---|
| 31 | $base_url = get_root_url().'admin.php?page='.$page['page']; |
---|
| 32 | |
---|
| 33 | $themes = new themes(); |
---|
| 34 | |
---|
| 35 | // +-----------------------------------------------------------------------+ |
---|
| 36 | // | perform actions | |
---|
| 37 | // +-----------------------------------------------------------------------+ |
---|
| 38 | |
---|
[8126] | 39 | if (isset($_GET['action']) and isset($_GET['theme'])) |
---|
[5153] | 40 | { |
---|
| 41 | $page['errors'] = $themes->perform_action($_GET['action'], $_GET['theme']); |
---|
| 42 | |
---|
| 43 | if (empty($page['errors'])) |
---|
| 44 | { |
---|
| 45 | if ($_GET['action'] == 'activate' or $_GET['action'] == 'deactivate') |
---|
| 46 | { |
---|
| 47 | $template->delete_compiled_templates(); |
---|
| 48 | } |
---|
| 49 | redirect($base_url); |
---|
| 50 | } |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | // +-----------------------------------------------------------------------+ |
---|
| 54 | // | start template output | |
---|
| 55 | // +-----------------------------------------------------------------------+ |
---|
| 56 | |
---|
| 57 | $themes->sort_fs_themes(); |
---|
| 58 | |
---|
| 59 | $default_theme = get_default_theme(); |
---|
| 60 | |
---|
| 61 | $db_themes = $themes->get_db_themes(); |
---|
| 62 | $db_theme_ids = array(); |
---|
| 63 | foreach ($db_themes as $db_theme) |
---|
| 64 | { |
---|
[25018] | 65 | $db_theme_ids[] = $db_theme['id']; |
---|
[5153] | 66 | } |
---|
| 67 | |
---|
[23259] | 68 | $tpl_themes = array(); |
---|
[5153] | 69 | |
---|
[5258] | 70 | foreach ($themes->fs_themes as $theme_id => $fs_theme) |
---|
[5153] | 71 | { |
---|
| 72 | if ($theme_id == 'default') |
---|
| 73 | { |
---|
| 74 | continue; |
---|
| 75 | } |
---|
[23259] | 76 | |
---|
| 77 | $tpl_theme = array( |
---|
| 78 | 'ID' => $theme_id, |
---|
| 79 | 'NAME' => $fs_theme['name'], |
---|
| 80 | 'VISIT_URL' => $fs_theme['uri'], |
---|
| 81 | 'VERSION' => $fs_theme['version'], |
---|
| 82 | 'DESC' => $fs_theme['description'], |
---|
| 83 | 'AUTHOR' => $fs_theme['author'], |
---|
| 84 | 'AUTHOR_URL' => @$fs_theme['author uri'], |
---|
| 85 | 'PARENT' => @$fs_theme['parent'], |
---|
| 86 | 'SCREENSHOT' => $fs_theme['screenshot'], |
---|
| 87 | 'IS_MOBILE' => $fs_theme['mobile'], |
---|
| 88 | 'ADMIN_URI' => @$fs_theme['admin_uri'], |
---|
| 89 | ); |
---|
[5153] | 90 | |
---|
| 91 | if (in_array($theme_id, $db_theme_ids)) |
---|
| 92 | { |
---|
[23259] | 93 | $tpl_theme['STATE'] = 'active'; |
---|
[28989] | 94 | $tpl_theme['IS_DEFAULT'] = ($theme_id == $default_theme); |
---|
[23259] | 95 | $tpl_theme['DEACTIVABLE'] = true; |
---|
[5642] | 96 | |
---|
[5382] | 97 | if (count($db_theme_ids) <= 1) |
---|
| 98 | { |
---|
[23259] | 99 | $tpl_theme['DEACTIVABLE'] = false; |
---|
| 100 | $tpl_theme['DEACTIVATE_TOOLTIP'] = l10n('Impossible to deactivate this theme, you need at least one theme.'); |
---|
[5382] | 101 | } |
---|
[28989] | 102 | if ($tpl_theme['IS_DEFAULT']) |
---|
| 103 | { |
---|
| 104 | $tpl_theme['DEACTIVABLE'] = false; |
---|
| 105 | $tpl_theme['DEACTIVATE_TOOLTIP'] = l10n('Impossible to deactivate the default theme.'); |
---|
| 106 | } |
---|
[5153] | 107 | } |
---|
| 108 | else |
---|
| 109 | { |
---|
[23259] | 110 | $tpl_theme['STATE'] = 'inactive'; |
---|
| 111 | |
---|
[5259] | 112 | // is the theme "activable" ? |
---|
[5874] | 113 | if (isset($fs_theme['activable']) and !$fs_theme['activable']) |
---|
| 114 | { |
---|
[23259] | 115 | $tpl_theme['ACTIVABLE'] = false; |
---|
| 116 | $tpl_theme['ACTIVABLE_TOOLTIP'] = l10n('This theme was not designed to be directly activated'); |
---|
[5874] | 117 | } |
---|
| 118 | else |
---|
| 119 | { |
---|
[23259] | 120 | $tpl_theme['ACTIVABLE'] = true; |
---|
[5874] | 121 | } |
---|
[5642] | 122 | |
---|
[5259] | 123 | $missing_parent = $themes->missing_parent_theme($theme_id); |
---|
| 124 | if (isset($missing_parent)) |
---|
| 125 | { |
---|
[23259] | 126 | $tpl_theme['ACTIVABLE'] = false; |
---|
[5642] | 127 | |
---|
[25005] | 128 | $tpl_theme['ACTIVABLE_TOOLTIP'] = l10n( |
---|
| 129 | 'Impossible to activate this theme, the parent theme is missing: %s', |
---|
[5259] | 130 | $missing_parent |
---|
| 131 | ); |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | // is the theme "deletable" ? |
---|
[5258] | 135 | $children = $themes->get_children_themes($theme_id); |
---|
[5259] | 136 | |
---|
[23259] | 137 | $tpl_theme['DELETABLE'] = true; |
---|
[5642] | 138 | |
---|
[5258] | 139 | if (count($children) > 0) |
---|
| 140 | { |
---|
[23259] | 141 | $tpl_theme['DELETABLE'] = false; |
---|
[5642] | 142 | |
---|
[25005] | 143 | $tpl_theme['DELETE_TOOLTIP'] = l10n( |
---|
| 144 | 'Impossible to delete this theme. Other themes depends on it: %s', |
---|
[5258] | 145 | implode(', ', $children) |
---|
| 146 | ); |
---|
| 147 | } |
---|
[5153] | 148 | } |
---|
[23259] | 149 | |
---|
[25018] | 150 | $tpl_themes[] = $tpl_theme; |
---|
[5153] | 151 | } |
---|
| 152 | |
---|
[23259] | 153 | // sort themes by state then by name |
---|
| 154 | function cmp($a, $b) |
---|
| 155 | { |
---|
| 156 | $s = array('active' => 0, 'inactive' => 1); |
---|
| 157 | |
---|
| 158 | if (@$a['IS_DEFAULT']) return -1; |
---|
| 159 | if (@$b['IS_DEFAULT']) return 1; |
---|
| 160 | |
---|
| 161 | if($a['STATE'] == $b['STATE']) |
---|
| 162 | return strcasecmp($a['NAME'], $b['NAME']); |
---|
| 163 | else |
---|
| 164 | return $s[$a['STATE']] >= $s[$b['STATE']]; |
---|
| 165 | } |
---|
| 166 | usort($tpl_themes, 'cmp'); |
---|
| 167 | |
---|
[5153] | 168 | $template->assign( |
---|
| 169 | array( |
---|
[5931] | 170 | 'activate_baseurl' => $base_url.'&action=activate&theme=', |
---|
| 171 | 'deactivate_baseurl' => $base_url.'&action=deactivate&theme=', |
---|
| 172 | 'set_default_baseurl' => $base_url.'&action=set_default&theme=', |
---|
| 173 | 'delete_baseurl' => $base_url.'&action=delete&theme=', |
---|
[5153] | 174 | |
---|
[23259] | 175 | 'tpl_themes' => $tpl_themes, |
---|
[5153] | 176 | ) |
---|
| 177 | ); |
---|
| 178 | |
---|
[28587] | 179 | trigger_notify('loc_end_themes_installed'); |
---|
[5153] | 180 | |
---|
| 181 | $template->set_filenames(array('themes' => 'themes_installed.tpl')); |
---|
| 182 | $template->assign_var_from_handle('ADMIN_CONTENT', 'themes'); |
---|
[5642] | 183 | ?> |
---|