Even more rewrites/fixes from EL branch (please report any broken part after you...
[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 (countPostSelection() > 0) {
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`=" . bigintval($id) . " LIMIT 1";
63                         } else {
64                                 $sql = "UPDATE `{?_MYSQL_PREFIX?}_themes` SET theme_active='Y' WHERE `id`=" . bigintval($id) . " LIMIT 1";
65                         }
66                         $OUT = getMessage('ADMIN_THEMES_UPDATED');
67                 } elseif (isFormSent('del')) {
68                         // Delete themes
69                         $sql = "DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_themes` WHERE `id`=" . bigintval($id) . " LIMIT 1";
70                         $OUT = getMessage('ADMIN_THEMES_DELETED');
71                 }
72
73                 // Run SQL command?
74                 if (!empty($sql)) {
75                         // Run it
76                         $result = SQL_QUERY($sql, __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 = getMessage('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`,
110         `theme_name`
111 FROM
112         `{?_MYSQL_PREFIX?}_themes`
113 ORDER BY
114         `theme_path` ASC", __FILE__, __LINE__);
115
116 if (SQL_NUMROWS($result) > 0) {
117         // Init color
118         $SW = 2;
119         while ($content = SQL_FETCHARRAY($result)) {
120                 // Construct IFN
121                 $inc = sprintf("theme/%s/theme.php", $content['theme_path']);
122
123                 // Load theme in test mode
124                 loadInclude($inc);
125
126                 // Is the loaded theme name != current theme name?
127                 $LINK = $content['theme_path'];
128                 if ($content['theme_path'] != getCurrentTheme()) $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>';
129
130                 // Prepare data for the row template
131                 $content = array(
132                         'sw'        => $SW,
133                         'id'        => $content['id'],
134                         'active'    => $content['theme_active'],
135                         'link'      => $LINK,
136                         'name'      => $content['theme_name'],
137                         'is_act'    => translateYesNo($content['theme_active']),
138                         'email'     => '<a href="mailto:' . $GLOBALS['theme_data']['email'] . '?Subject=[Theme:] ' . $GLOBALS['theme_data']['name'] . ' (' . $content['theme_path'] . ')\>' . $GLOBALS['theme_data']['author'] . '</a>',
139                         'url_link'  => generateDerefererUrl($GLOBALS['theme_data']['url']),
140                         'url_title' => $GLOBALS['theme_data']['url'],
141                         'ver'       => $content['theme_ver'],
142                 );
143
144                 // Load row template and switch color
145                 $OUT .= loadTemplate('admin_theme_edit_row', true, $content);
146                 $SW = 3 - $SW;
147         } // END - while
148
149         // Free memory
150         SQL_FREERESULT($result);
151 } else {
152         // No themes found???
153         $OUT .= "<tr>
154   <td colspan=\"7\" class=\"bottom\" height=\"60\">
155     ".loadTemplate('admin_settings_saved', true, getMessage('ADMIN_NO_THEMES_FOUND'))."
156   </td>
157 </tr>\n";
158 }
159
160 // Load template
161 loadTemplate('admin_theme_edit', false, $OUT);
162
163 // [EOF]
164 ?>