A lot rewrites from double-quote to single-quote, some fixes for extension handling...
[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 - 2008 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')) || (!IS_ADMIN())) {
41         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
42         require($INC);
43 } elseif (!EXT_IS_ACTIVE('theme')) {
44         addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), 'theme');
45         return;
46 }
47
48 // Add description as navigation point
49 ADD_DESCR('admin', __FILE__);
50
51 // Check for selected themes
52 $SEL = 0;
53 if (REQUEST_ISSET_POST('sel')) $SEL = SELECTION_COUNT(REQUEST_POST('sel'));
54 if ($SEL > 0) {
55         $OUT = '';
56         foreach (REQUEST_POST('sel') as $id => $sel) {
57                 $sql = '';
58                 // Shall I de-/activate or delete themes?
59                 if (REQUEST_ISSET_POST(('status'))) {
60                         // Change status
61                         if (REQUEST_POST('active', $id) == 'Y') {
62                                 $sql = "UPDATE `{!_MYSQL_PREFIX!}_themes` SET theme_active='N' WHERE id='".$id."' LIMIT 1";
63                         } else {
64                                 $sql = "UPDATE `{!_MYSQL_PREFIX!}_themes` SET theme_active='Y' WHERE id='".$id."' LIMIT 1";
65                         }
66                         $OUT = getMessage('ADMIN_THEMES_UPDATED');
67                 } elseif (REQUEST_ISSET_POST('del')) {
68                         // Delete themes
69                         $sql = "DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_themes` WHERE id='".$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                         rebuildCacheFiles("themes", "them");
80                 } // END - if
81         }
82
83         // Output generated?
84         if (empty($OUT)) $OUT = getMessage('ADMIN_THEME_NO_OUTPUT');
85 } elseif (REQUEST_ISSET_GET(('default_theme'))) {
86         // Escape string from input
87         $POST['default_theme'] = REQUEST_GET(('default_theme'));
88
89         // Set session
90         set_session('mxchange_theme', $POST['default_theme']);
91
92         // Set it in config and current theme as well
93         $GLOBALS['curr_theme'] = $POST['default_theme'];
94         setConfigEntry('default_theme', $POST['default_theme']);
95
96         // Save theme
97         ADMIN_SAVE_SETTINGS($POST);
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                 LOAD_INC($INC);
113
114                 // Is the loaded theme name != current theme name?
115                 $LINK = $content['theme_path'];
116                 if ($content['theme_path'] != GET_CURR_THEME()) $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'    => TRANSLATE_YESNO($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'  => DEREFERER($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 .= LOAD_TEMPLATE("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     ".LOAD_TEMPLATE('admin_settings_saved', true, getMessage('ADMIN_NO_THEMES_FOUND'))."
144   </td>
145 </tr>\n";
146 }
147
148 define('__THEME_LIST', $OUT);
149
150 // Load template
151 LOAD_TEMPLATE("admin_theme_edit");
152
153 //
154 ?>