96f936afc08a59af8262f55023ba900b289fc8f7
[mailer.git] / inc / modules / admin / what-theme_edit.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 02/12/2004 *
4  * ===================                          Last change: 02/12/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-theme_edit.php                              *
8  * -------------------------------------------------------------------- *
9  * Short description :                                                  *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  :                                                  *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
42         die();
43 } // END - if
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 if (!isExtensionActive('theme')) {
49         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('theme'));
50         return;
51 } // END - if
52
53 // Check for selected themes
54 if (ifPostContainsSelections()) {
55         $OUT = '';
56         foreach (postRequestParameter('sel') as $id => $sel) {
57                 $sql = '';
58                 // Shall I de-/activate or delete themes?
59                 if (isPostRequestParameterSet('status')) {
60                         // Change status
61                         if (postRequestParameter('active', $id) == 'Y') {
62                                 $sql = "UPDATE `{?_MYSQL_PREFIX?}_themes` SET `theme_active`='N' WHERE `id`=%s LIMIT 1";
63                         } else {
64                                 $sql = "UPDATE `{?_MYSQL_PREFIX?}_themes` SET `theme_active`='Y' WHERE `id`=%s LIMIT 1";
65                         }
66                         $OUT = '{--ADMIN_THEMES_UPDATED--}';
67                 } elseif (isFormSent('del')) {
68                         // Delete themes
69                         $sql = "DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_themes` WHERE `id`=%s LIMIT 1";
70                         $OUT = '{--ADMIN_THEMES_DELETED--}';
71                 }
72
73                 // Run SQL command?
74                 if (!empty($sql)) {
75                         // Run it
76                         $result = SQL_QUERY_ESC($sql, array(bigintval($id)), __FILE__, __LINE__);
77
78                         // Rebuild cache
79                         rebuildCache('themes', 'them');
80                 } // END - if
81         } // END - foreach
82
83         // Output generated?
84         if (empty($OUT)) $OUT = '{--ADMIN_THEME_NO_OUTPUT--}';
85 } elseif (isGetRequestParameterSet('default_theme')) {
86         // Escape string from input
87         $postData['default_theme'] = getRequestParameter('default_theme');
88
89         // Set session
90         setTheme($postData['default_theme']);
91
92         // Set it in config and current theme as well
93         setConfigEntry('default_theme', $postData['default_theme']);
94
95         // Save theme
96         adminSaveSettings($postData);
97 }
98
99 // Init rows
100 $OUT = ''; 
101
102 // Switch to testing mode
103 $GLOBALS['theme_mode'] = 'test';
104
105 $result = SQL_QUERY("SELECT
106         `id`,
107         `theme_path`,
108         `theme_active`,
109         `theme_ver` AS `theme_version`,
110         `theme_name`
111 FROM
112         `{?_MYSQL_PREFIX?}_themes`
113 ORDER BY
114         `theme_path` ASC", __FILE__, __LINE__);
115
116 if (!SQL_HASZERONUMS($result)) {
117         while ($content = SQL_FETCHARRAY($result)) {
118                 // Construct IFN
119                 $inc = sprintf("theme/%s/theme.php", $content['theme_path']);
120
121                 // Load theme in test mode
122                 loadInclude($inc);
123
124                 // Is the loaded theme name != current theme name?
125                 $content['link'] = $content['theme_path'];
126                 if ($content['theme_path'] != getCurrentTheme()) $content['link'] = '<a href="{%url=modules.php?module=admin&amp;what=theme_edit&amp;default_theme=' . $content['theme_path'] . '%}" title="{--ADMIN_SET_AS_NEW_THEME--}">' . $content['theme_path'] . '</a>';
127
128                 // Prepare data for the row template
129                 $content['email'] = '<a href="mailto:' . $GLOBALS['theme_data']['email'] . '?Subject=[Theme:] ' . $GLOBALS['theme_data']['name'] . ' (' . $content['theme_path'] . ')\>' . $GLOBALS['theme_data']['author'] . '</a>';
130
131                 // Load row template and switch color
132                 $OUT .= loadTemplate('admin_edit_theme_row', true, $content);
133         } // END - while
134
135         // Free memory
136         SQL_FREERESULT($result);
137 } else {
138         // No themes found???
139         $OUT .= '<tr>
140   <td colspan="7" class="bottom" height="60">
141     ' . loadTemplate('admin_settings_saved', true, '{--ADMIN_NO_THEMES_FOUND--}') . '
142   </td>
143 </tr>';
144 }
145
146 // Load template
147 loadTemplate('admin_edit_theme', false, $OUT);
148
149 // [EOF]
150 ?>