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