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 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://www.mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
46 if (!isExtensionActive('theme')) {
47 loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('theme'));
51 // Switch to testing mode
52 $GLOBALS['theme_mode'] = 'test';
54 // Import selected theme if not present
55 if (isPostRequestParameterSet('theme')) {
56 // Check if theme is there
57 if (!ifThemeExists(postRequestParameter('theme'))) {
59 $inc = sprintf("theme/%s/theme.php", SQL_ESCAPE(postRequestParameter('theme')));
61 // Is the theme readable?
62 if (isIncludeReadable($inc)) {
63 // Load the theme header file
66 // Register it ith the exchange
67 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_themes` (`theme_path`,`theme_active`,`theme_ver`,`theme_name`)
68 VALUES ('%s','N','%s','%s')",
70 postRequestParameter('theme'),
71 $GLOBALS['theme_data']['version'],
72 $GLOBALS['theme_data']['name']
73 ), __FILE__, __LINE__);
76 rebuildCache('themes', 'them');
79 $message = getMaskedMessage('ADMIN_THEME_IMPORTED', postRequestParameter('theme'));
81 // Include file not found
82 $message = getMaskedMessage('ADMIN_THEME_INC_404', postRequestParameter('theme'));
85 // Theme already imported
86 $message = getMaskedMessage('ADMIN_THEME_ALREADY_INSTALLED', postRequestParameter('theme'));
90 loadTemplate('admin_settings_saved', false, $message);
95 'theme_unix' => array(), // Unix name from filesystem
96 'theme_name' => array(), // Title
97 'theme_author' => array(), // Theme author's name
98 'theme_email' => array(), // Author's email address
99 'theme_url' => array(), // URL were you can download it from
100 'theme_version' => array(), // Version number of theme
103 // Read directory "themes"
104 $includes = getArrayFromDirectory('theme/', '', false, true, array('css', 'images'));
106 // Walk through all entries and add it
107 foreach ($includes as $inc) {
108 // Get directory from it
109 $dir = basename(dirname($inc));
114 // Add found theme to array
115 $THEMES['theme_unix'][] = $dir;
116 $THEMES['theme_name'][] = $GLOBALS['theme_data']['name'];
117 $THEMES['theme_author'][] = $GLOBALS['theme_data']['author'];
118 $THEMES['theme_email'][] = $GLOBALS['theme_data']['email'];
119 $THEMES['theme_url'][] = $GLOBALS['theme_data']['url'];
120 $THEMES['theme_version'][] = $GLOBALS['theme_data']['version'];
123 // Sort array by Uni* name
124 array_pk_sort($THEMES, array('theme_name'));
126 // Generate output lines for the template
128 foreach ($THEMES['theme_unix'] as $key => $unix) {
129 // Already installed is default
130 $formContent = '<div class="notice">' . getMaskedMessage('ADMIN_THEME_ALREADY_INSTALLED', $unix) . '</div>';
132 // Check if current theme is already imported or not
133 if (!ifThemeExists($unix)) {
134 // Theme not installed
135 $formContent = loadTemplate('admin_import_theme_form', true, $unix);
141 'theme_name' => $THEMES['theme_name'][$key],
142 'theme_email' => $THEMES['theme_email'][$key],
143 'theme_author' => $THEMES['theme_author'][$key],
144 'theme_url' => $THEMES['theme_url'][$key],
145 'theme_version' => $THEMES['theme_version'][$key],
146 'form_content' => $formContent
150 $OUT .= loadTemplate('admin_import_theme_row', true, $content);
154 // No themes found???
155 $OUT .= loadTemplate('admin_import_theme_none', true, loadTemplate('admin_settings_saved', true, '{--ADMIN_NO_THEMES_FOUND--}'));
159 loadTemplate('admin_import_theme', false, $OUT);