(no commit message)
[mailer.git] / 0.2.1 / inc / modules / admin / what-theme_edit.php
1 <?php\r
2 /************************************************************************\r
3  * MXChange v0.2.1                                    Start: 02/12/2004 *\r
4  * ================                             Last change: 02/12/2004 *\r
5  *                                                                      *\r
6  * -------------------------------------------------------------------- *\r
7  * File              : what-theme_edit.php                              *\r
8  * -------------------------------------------------------------------- *\r
9  * Short description :                                                  *\r
10  * -------------------------------------------------------------------- *\r
11  * Kurzbeschreibung  :                                                  *\r
12  * -------------------------------------------------------------------- *\r
13  *                                                                      *\r
14  * -------------------------------------------------------------------- *\r
15  * Copyright (c) 2003 - 2007 by Roland Haeder                           *\r
16  * For more information visit: http://www.mxchange.org                  *\r
17  *                                                                      *\r
18  * This program is free software; you can redistribute it and/or modify *\r
19  * it under the terms of the GNU General Public License as published by *\r
20  * the Free Software Foundation; either version 2 of the License, or    *\r
21  * (at your option) any later version.                                  *\r
22  *                                                                      *\r
23  * This program is distributed in the hope that it will be useful,      *\r
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *\r
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *\r
26  * GNU General Public License for more details.                         *\r
27  *                                                                      *\r
28  * You should have received a copy of the GNU General Public License    *\r
29  * along with this program; if not, write to the Free Software          *\r
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *\r
31  * MA  02110-1301  USA                                                  *\r
32  ************************************************************************/\r
33 \r
34 // Some security stuff...\r
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!is_admin()))\r
36 {\r
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";\r
38         require($INC);\r
39 }\r
40 // Add description as navigation point\r
41 ADD_DESCR("admin", basename(__FILE__));\r
42 \r
43 global $CurrTheme;\r
44 \r
45 // Check for selected themes\r
46 $SEL = 0;\r
47 if (!empty($_POST['sel'])) $SEL = SELECTION_COUNT($_POST['sel']);\r
48 if ($SEL > 0)\r
49 {\r
50         $OUT = "";\r
51         foreach ($_POST['sel'] as $id=>$sel)\r
52         {\r
53                 $SQL = "";\r
54                 // Shall I de-/activate or delete themes?\r
55                 if (isset($_POST['status']))\r
56                 {\r
57                         // Change status\r
58                         if ($_POST['active'][$id] == "Y")\r
59                         {\r
60                                 $SQL = "UPDATE "._MYSQL_PREFIX."_themes SET theme_active='N' WHERE id='".$id."' LIMIT 1";\r
61                         }\r
62                          else\r
63                         {\r
64                                 $SQL = "UPDATE "._MYSQL_PREFIX."_themes SET theme_active='Y' WHERE id='".$id."' LIMIT 1";\r
65                         }\r
66                         $OUT = ADMIN_THEMES_UPDATED;\r
67                 }\r
68                  elseif (isset($_POST['del']))\r
69                 {\r
70                         // Delete themes\r
71                         $SQL = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_themes WHERE id='".$id."' LIMIT 1";\r
72                         $OUT = ADMIN_THEMES_DELETED;\r
73                 }\r
74 \r
75                 // Run SQL command?\r
76                 if (!empty($SQL)) $result = SQL_QUERY($SQL, __FILE__, __LINE__);\r
77         }\r
78 \r
79         // Output generated?\r
80         if (empty($OUT)) ADMIN_THEME_NO_OUTPUT;\r
81 }\r
82  elseif (!empty($_GET['default_theme']))\r
83 {\r
84         // Save theme\r
85         $POST['default_theme'] = $_GET['default_theme'];\r
86         @setcookie("mxchange_theme", $POST['default_theme'], (time() + 60*60*24*365), COOKIE_PATH);\r
87         $_COOKIE['mxchange_theme'] = $POST['default_theme'];\r
88         ADMIN_SAVE_SETTINGS($POST, "_config", "config='0'");\r
89 }\r
90 \r
91 // Switch to testing mode\r
92 $THEME_MODE = "test";\r
93 \r
94 // Generate output lines for the template\r
95 $OUT = ""; $SW = 2;\r
96 $result = SQL_QUERY("SELECT id, theme_path, theme_active, theme_ver FROM "._MYSQL_PREFIX."_themes ORDER BY theme_path", __FILE__, __LINE__);\r
97 if (SQL_NUMROWS($result) > 0)\r
98 {\r
99         while(list($id, $unix, $active, $ver) = SQL_FETCHROW($result))\r
100         {\r
101                 // Load theme in test mode\r
102                 require(PATH."theme/".$unix."/theme.php");\r
103 \r
104                 // Is the loaded theme name != current theme name?\r
105                 $LINK = $unix;\r
106                 if ($unix != $CurrTheme) $LINK = "<A href=\"".URL."/modules.php?module=admin&amp;what=theme_edit&amp;default_theme=".$unix."\" title=\"".ADMIN_SET_AS_NEW_THEME."\">".$unix."</A>";\r
107 \r
108                 // Prepare data for the row template\r
109                 $content = array(\r
110                         'sw'        => $SW,\r
111                         'id'        => $id,\r
112                         'active'    => $active,\r
113                         'link'      => $LINK,\r
114                         'name'      => $THEME_NAME,\r
115                         'is_act'    => TRANSLATE_YESNO($active),\r
116                         'email'     => "<A href=\"mailto:".$THEME_EMAIL."?Subject=[Theme:] ".$THEME_NAME." (".$unix.")"."\">".$THEME_AUTHOR."</A>",\r
117                         'url_link'  => DEREFERER($THEME_URL),\r
118                         'url_title' => $THEME_URL,\r
119                         'ver'       => $ver,\r
120                 );\r
121 \r
122                 // Load row template and switch color\r
123                 $OUT .= LOAD_TEMPLATE("admin_theme_edit_row", true, $content);\r
124                 $SW = 3 - $SW;\r
125         }\r
126 \r
127         // Free memory\r
128         SQL_FREERESULT($result);\r
129 }\r
130  else\r
131 {\r
132                 // No themes found???\r
133         $OUT .= "<TR>\r
134   <TD colspan=\"7\" class=\"bottom2\" height=\"60\">\r
135     ".LOAD_TEMPLATE("admin_settings_saved", true, ADMIN_NO_THEMES_FOUND)."\r
136   </TD>\r
137 </TR>\n";\r
138 }\r
139 \r
140 define('__THEME_LIST', $OUT);\r
141 \r
142 // Load template\r
143 LOAD_TEMPLATE("admin_theme_edit");\r
144 \r
145 //\r
146 ?>\r