1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based photo gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org | |
---|
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 | |
---|
39 | if (isset($_GET['action']) and isset($_GET['theme'])) |
---|
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 | { |
---|
65 | array_push($db_theme_ids, $db_theme['id']); |
---|
66 | } |
---|
67 | |
---|
68 | $active_themes = array(); |
---|
69 | $inactive_themes = array(); |
---|
70 | |
---|
71 | foreach ($themes->fs_themes as $theme_id => $fs_theme) |
---|
72 | { |
---|
73 | if ($theme_id == 'default') |
---|
74 | { |
---|
75 | continue; |
---|
76 | } |
---|
77 | |
---|
78 | if (in_array($theme_id, $db_theme_ids)) |
---|
79 | { |
---|
80 | $fs_theme['deactivable'] = true; |
---|
81 | |
---|
82 | if (count($db_theme_ids) <= 1) |
---|
83 | { |
---|
84 | $fs_theme['deactivable'] = false; |
---|
85 | $fs_theme['deactivate_tooltip'] = l10n('Impossible to deactivate this theme, you need at least one theme.'); |
---|
86 | } |
---|
87 | |
---|
88 | if ($theme_id == $default_theme) |
---|
89 | { |
---|
90 | $fs_theme['is_default'] = true; |
---|
91 | array_unshift($active_themes, $fs_theme); |
---|
92 | } |
---|
93 | else |
---|
94 | { |
---|
95 | $fs_theme['is_default'] = false; |
---|
96 | array_push($active_themes, $fs_theme); |
---|
97 | } |
---|
98 | } |
---|
99 | else |
---|
100 | { |
---|
101 | // is the theme "activable" ? |
---|
102 | if (isset($fs_theme['activable']) and !$fs_theme['activable']) |
---|
103 | { |
---|
104 | $fs_theme['activate_tooltip'] = l10n('This theme was not designed to be directly activated'); |
---|
105 | } |
---|
106 | else |
---|
107 | { |
---|
108 | $fs_theme['activable'] = true; |
---|
109 | } |
---|
110 | |
---|
111 | $missing_parent = $themes->missing_parent_theme($theme_id); |
---|
112 | if (isset($missing_parent)) |
---|
113 | { |
---|
114 | $fs_theme['activable'] = false; |
---|
115 | |
---|
116 | $fs_theme['activate_tooltip'] = sprintf( |
---|
117 | l10n('Impossible to activate this theme, the parent theme is missing: %s'), |
---|
118 | $missing_parent |
---|
119 | ); |
---|
120 | } |
---|
121 | |
---|
122 | // is the theme "deletable" ? |
---|
123 | $children = $themes->get_children_themes($theme_id); |
---|
124 | |
---|
125 | $fs_theme['deletable'] = true; |
---|
126 | |
---|
127 | if (count($children) > 0) |
---|
128 | { |
---|
129 | $fs_theme['deletable'] = false; |
---|
130 | |
---|
131 | $fs_theme['delete_tooltip'] = sprintf( |
---|
132 | l10n('Impossible to delete this theme. Other themes depends on it: %s'), |
---|
133 | implode(', ', $children) |
---|
134 | ); |
---|
135 | } |
---|
136 | |
---|
137 | array_push($inactive_themes, $fs_theme); |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | $template->assign( |
---|
142 | array( |
---|
143 | 'activate_baseurl' => $base_url.'&action=activate&theme=', |
---|
144 | 'deactivate_baseurl' => $base_url.'&action=deactivate&theme=', |
---|
145 | 'set_default_baseurl' => $base_url.'&action=set_default&theme=', |
---|
146 | 'delete_baseurl' => $base_url.'&action=delete&theme=', |
---|
147 | |
---|
148 | 'active_themes' => $active_themes, |
---|
149 | 'inactive_themes' => $inactive_themes, |
---|
150 | ) |
---|
151 | ); |
---|
152 | |
---|
153 | |
---|
154 | $template->set_filenames(array('themes' => 'themes_installed.tpl')); |
---|
155 | $template->assign_var_from_handle('ADMIN_CONTENT', 'themes'); |
---|
156 | ?> |
---|