2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 02/12/2004 *
4 * =================== Last change: 11/12/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-theme_import.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Import of new themes *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Importieren von neuen Themes *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
38 ************************************************************************/
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
48 if (!isExtensionActive('theme')) {
49 loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('theme'));
53 // Switch to testing mode
54 $GLOBALS['theme_mode'] = 'test';
56 // Import selected theme if not present
57 if (isPostRequestParameterSet('theme')) {
58 // Check if theme is there
59 if (!ifThemeExists(postRequestParameter('theme'))) {
61 $inc = sprintf("theme/%s/theme.php", SQL_ESCAPE(postRequestParameter('theme')));
63 // Is the theme readable?
64 if (isIncludeReadable($inc)) {
65 // Load the theme header file
68 // Register it ith the exchange
69 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_themes` (`theme_path`,`theme_active`,`theme_ver`,`theme_name`)
70 VALUES ('%s','N','%s','%s')",
72 postRequestParameter('theme'),
73 $GLOBALS['theme_data']['version'],
74 $GLOBALS['theme_data']['name']
75 ), __FILE__, __LINE__);
78 rebuildCache('themes', 'them');
81 $message = getMaskedMessage('ADMIN_THEME_IMPORTED', postRequestParameter('theme'));
83 // Include file not found!
84 $message = getMaskedMessage('ADMIN_THEME_INC_404', postRequestParameter('theme'));
87 // Theme already imported
88 $message = getMaskedMessage('ADMIN_THEME_ALREADY_INSTALLED', postRequestParameter('theme'));
92 loadTemplate('admin_settings_saved', false, $message);
97 'theme_unix' => array(), // Unix name from filesystem
98 'theme_name' => array(), // Title
99 'theme_author' => array(), // Theme author's name
100 'theme_email' => array(), // Author's email address
101 'theme_url' => array(), // URL were you can download it from
102 'theme_version' => array(), // Version number of theme
105 // Read directory "themes"
106 $includes = getArrayFromDirectory('theme/', '', false, true, array('css', 'images'));
108 // Walk through all entries and add it
109 foreach ($includes as $inc) {
110 // Get directory from it
111 $dir = basename(dirname($inc));
116 // Add found theme to array
117 $THEMES['theme_unix'][] = $dir;
118 $THEMES['theme_name'][] = $GLOBALS['theme_data']['name'];
119 $THEMES['theme_author'][] = $GLOBALS['theme_data']['author'];
120 $THEMES['theme_email'][] = $GLOBALS['theme_data']['email'];
121 $THEMES['theme_url'][] = $GLOBALS['theme_data']['url'];
122 $THEMES['theme_version'][] = $GLOBALS['theme_data']['version'];
125 // Sort array by Uni* name
126 array_pk_sort($THEMES, array('theme_name'));
128 // Generate output lines for the template
130 foreach ($THEMES['theme_unix'] as $key => $unix) {
131 // Already installed is default
132 $formContent = '<div class="notice">' . getMaskedMessage('ADMIN_THEME_ALREADY_INSTALLED', $unix) . '</div>';
134 // Check if current theme is already imported or not
135 if (!ifThemeExists($unix)) {
136 // Theme not installed
137 $formContent = loadTemplate('admin_import_theme_form', true, $unix);
143 'theme_name' => $THEMES['theme_name'][$key],
144 'theme_email' => $THEMES['theme_email'][$key],
145 'theme_author' => $THEMES['theme_author'][$key],
146 'theme_url' => $THEMES['theme_url'][$key],
147 'theme_version' => $THEMES['theme_version'][$key],
148 'form_content' => $formContent
152 $OUT .= loadTemplate('admin_import_theme_row', true, $content);
156 // No themes found???
157 $OUT .= loadTemplate('admin_import_theme_none', true, loadTemplate('admin_settings_saved', true, '{--ADMIN_NO_THEMES_FOUND--}'));
161 loadTemplate('admin_import_theme', false, $OUT);