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 // Switch to testing mode
47 $GLOBALS['theme_mode'] = 'test';
49 // Import selected theme if not present
50 if (isPostRequestParameterSet('theme')) {
51 // Check if theme is there
52 if (!ifThemeExists(postRequestParameter('theme'))) {
54 $inc = sprintf("theme/%s/theme.php", SQL_ESCAPE(postRequestParameter('theme')));
56 // Is the theme readable?
57 if (isIncludeReadable($inc)) {
58 // Load the theme header file
61 // Register it ith the exchange
62 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_themes` (`theme_path`, `theme_active`, `theme_ver`, `theme_name`)
63 VALUES ('%s','N','%s','%s')",
65 postRequestParameter('theme'),
66 $GLOBALS['theme_data']['version'],
67 $GLOBALS['theme_data']['name']
68 ), __FILE__, __LINE__);
71 rebuildCache('themes', 'them');
74 $message = '{%message,ADMIN_THEME_IMPORTED=' . postRequestParameter('theme') . '%}';
76 // Include file not found
77 $message = '{%message,ADMIN_THEME_INC_404=' . postRequestParameter('theme') . '%}';
80 // Theme already imported
81 $message = '{%message,ADMIN_THEME_ALREADY_INSTALLED=' . postRequestParameter('theme') . '%}';
85 displayMessage($message);
90 'theme_unix' => array(), // Unix name from filesystem
91 'theme_name' => array(), // Title
92 'theme_author' => array(), // Theme author's name
93 'theme_email' => array(), // Author's email address
94 'theme_url' => array(), // URL were you can download it from
95 'theme_version' => array(), // Version number of theme
98 // Read directory "themes"
99 $includes = getArrayFromDirectory('theme/', '', false, true, array('css', 'images'));
101 // Walk through all entries and add it
102 foreach ($includes as $inc) {
103 // Get directory from it
104 $dir = basename(dirname($inc));
109 // Add found theme to array
110 $themes['theme_unix'][] = $dir;
111 $themes['theme_name'][] = $GLOBALS['theme_data']['name'];
112 $themes['theme_author'][] = $GLOBALS['theme_data']['author'];
113 $themes['theme_email'][] = $GLOBALS['theme_data']['email'];
114 $themes['theme_url'][] = $GLOBALS['theme_data']['url'];
115 $themes['theme_version'][] = $GLOBALS['theme_data']['version'];
118 // Sort array by Uni* name
119 array_pk_sort($themes, array('theme_name'));
121 // Generate output lines for the template
123 foreach ($themes['theme_unix'] as $key => $unix) {
124 // Already installed is default
125 $formContent = '<div class="notice">{%message,ADMIN_THEME_ALREADY_INSTALLED=' . $unix . '%}</div>';
127 // Check if current theme is already imported or not
128 if (!ifThemeExists($unix)) {
129 // Theme not installed
130 $formContent = loadTemplate('admin_import_theme_form', true, $unix);
136 'theme_name' => $themes['theme_name'][$key],
137 'theme_email' => $themes['theme_email'][$key],
138 'theme_author' => $themes['theme_author'][$key],
139 'theme_url' => $themes['theme_url'][$key],
140 'theme_version' => $themes['theme_version'][$key],
141 'form_content' => $formContent
145 $OUT .= loadTemplate('admin_import_theme_row', true, $content);
149 // No themes found???
150 $OUT .= loadTemplate('admin_import_theme_none', true, displayMessage('{--ADMIN_NO_THEMES_FOUND--}', true));
154 loadTemplate('admin_import_theme', false, $OUT);