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