Huge rewrite of default parameters, ext-network continued:
[mailer.git] / inc / modules / admin / what-theme_edit.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    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 $SEL = '0';
54 if (isPostRequestElementSet('sel')) $SEL = countPostSelection();
55 if ($SEL > 0) {
56         $OUT = '';
57         foreach (postRequestElement('sel') as $id => $sel) {
58                 $sql = '';
59                 // Shall I de-/activate or delete themes?
60                 if (isPostRequestElementSet(('status'))) {
61                         // Change status
62                         if (postRequestElement('active', $id) == 'Y') {
63                                 $sql = "UPDATE `{?_MYSQL_PREFIX?}_themes` SET theme_active='N' WHERE `id`='".$id."' LIMIT 1";
64                         } else {
65                                 $sql = "UPDATE `{?_MYSQL_PREFIX?}_themes` SET theme_active='Y' WHERE `id`='".$id."' LIMIT 1";
66                         }
67                         $OUT = getMessage('ADMIN_THEMES_UPDATED');
68                 } elseif (isPostRequestElementSet('del')) {
69                         // Delete themes
70                         $sql = "DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_themes` WHERE `id`='".$id."' LIMIT 1";
71                         $OUT = getMessage('ADMIN_THEMES_DELETED');
72                 }
73
74                 // Run SQL command?
75                 if (!empty($sql)) {
76                         // Run it
77                         $result = SQL_QUERY($sql, __FILE__, __LINE__);
78
79                         // Rebuild cache
80                         rebuildCacheFile('themes', 'them');
81                 } // END - if
82         }
83
84         // Output generated?
85         if (empty($OUT)) $OUT = getMessage('ADMIN_THEME_NO_OUTPUT');
86 } elseif (isGetRequestElementSet('default_theme')) {
87         // Escape string from input
88         $postData['default_theme'] = getRequestElement('default_theme');
89
90         // Set session
91         setTheme($postData['default_theme']);
92
93         // Set it in config and current theme as well
94         setConfigEntry('default_theme', $postData['default_theme']);
95
96         // Save theme
97         adminSaveSettings($postData);
98 }
99
100 // Switch to testing mode
101 $GLOBALS['theme_mode'] = 'test';
102
103 // Generate output lines for the template
104 $OUT = ''; $SW = 2;
105 $result = SQL_QUERY("SELECT `id`, `theme_path`, `theme_active`, `theme_ver`, `theme_name` FROM `{?_MYSQL_PREFIX?}_themes` ORDER BY theme_path", __FILE__, __LINE__);
106 if (SQL_NUMROWS($result) > 0) {
107         while ($content = SQL_FETCHARRAY($result)) {
108                 // Construct IFN
109                 $inc = sprintf("theme/%s/theme.php", $content['theme_path']);
110
111                 // Load theme in test mode
112                 loadInclude($inc);
113
114                 // Is the loaded theme name != current theme name?
115                 $LINK = $content['theme_path'];
116                 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>";
117
118                 // Prepare data for the row template
119                 $content = array(
120                         'sw'        => $SW,
121                         'id'        => $content['id'],
122                         'active'    => $content['theme_active'],
123                         'link'      => $LINK,
124                         'name'      => $content['theme_name'],
125                         'is_act'    => translateYesNo($content['theme_active']),
126                         'email'     => "<a href=\"mailto:".$GLOBALS['theme_data']['email']."?Subject=[Theme:] ".$GLOBALS['theme_data']['name']." (".$content['theme_path'].")'.'\">".$GLOBALS['theme_data']['author']."</a>",
127                         'url_link'  => generateDerefererUrl($GLOBALS['theme_data']['url']),
128                         'url_title' => $GLOBALS['theme_data']['url'],
129                         'ver'       => $content['theme_ver'],
130                 );
131
132                 // Load row template and switch color
133                 $OUT .= loadTemplate('admin_theme_edit_row', true, $content);
134                 $SW = 3 - $SW;
135         }
136
137         // Free memory
138         SQL_FREERESULT($result);
139 } else {
140         // No themes found???
141         $OUT .= "<tr>
142   <td colspan=\"7\" class=\"bottom2\" height=\"60\">
143     ".loadTemplate('admin_settings_saved', true, getMessage('ADMIN_NO_THEMES_FOUND'))."
144   </td>
145 </tr>\n";
146 }
147
148 // Load template
149 loadTemplate('admin_theme_edit', false, $OUT);
150
151 // [EOF]
152 ?>