2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 06/26/2004 *
4 * =================== Last change: 07/01/2005 *
6 * -------------------------------------------------------------------- *
7 * File : load-extension.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Load all extensions *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Alle Erweiterungen laden *
12 * -------------------------------------------------------------------- *
13 * @TODO Rewrite this whole file *
14 * -------------------------------------------------------------------- *
17 * $Tag:: 0.2.1-FINAL $ *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
22 * For more information visit: http://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')) {
43 } elseif (isInstallationPhase()) {
44 // Use this code if you don't want to run this cache loader on installation phase
48 // Next cached table is the extension
49 if (($GLOBALS['cache_instance']->loadCacheFile('extension')) && ($GLOBALS['cache_instance']->extensionVersionMatches('sql_patches'))) {
50 // Load extension from cache
51 $EXT_DUMMY = $GLOBALS['cache_instance']->getArrayFromCache();
53 // Init extension inc-pool
56 // Do we have entries?
57 if (count($EXT_DUMMY) > 0) {
62 foreach ($EXT_DUMMY['ext_name'] as $k => $ext_name) {
64 if ($EXT_DUMMY['ext_css'][$k] == 'Y') {
65 addExtensionCssFile($ext_name . '.css');
68 // Load extension file itself
69 if (($EXT_DUMMY['ext_active'][$k] == 'Y') || ($EXT_DUMMY['ext_keep'][$k] == 'Y')) {
70 $EXT_POOL[] = $ext_name;
74 $EXT_DUMMY['ext_version'][$ext_name] = $EXT_DUMMY['ext_version'][$k];
75 unset($EXT_DUMMY['ext_version'][$k]);
77 // Extension is active
78 $EXT_DUMMY['ext_active'][$ext_name] = $EXT_DUMMY['ext_active'][$k];
79 unset($EXT_DUMMY['ext_active'][$k]);
82 $EXT_DUMMY['ext_menu'][$ext_name] = $EXT_DUMMY['ext_menu'][$k];
83 unset($EXT_DUMMY['ext_menu'][$k]);
86 $EXT_DUMMY['ext_lang'][$ext_name] = $EXT_DUMMY['ext_lang'][$k];
87 unset($EXT_DUMMY['ext_lang'][$k]);
90 $EXT_DUMMY['ext_func'][$ext_name] = $EXT_DUMMY['ext_func'][$k];
91 unset($EXT_DUMMY['ext_func'][$k]);
94 $EXT_DUMMY['ext_id'][$ext_name] = $EXT_DUMMY['ext_id'][$k];
95 $id = $EXT_DUMMY['ext_id'][$ext_name];
96 unset($EXT_DUMMY['ext_id'][$k]);
99 $EXT_NAMES[$id] = $ext_name;
101 // Add deprecated flag (defaults to 'not deprecated')
102 $EXT_DUMMY['ext_deprecated'][$ext_name] = 'N';
104 // Mark it as active extension
105 $GLOBALS['cache_array']['always_active'][$ext_name] = $EXT_DUMMY['ext_keep'][$k];
106 unset($EXT_DUMMY['ext_keep'][$k]);
108 // Remove unneccessary data from memory
109 unset($EXT_DUMMY['ext_css'][$k]);
112 // Write dummy array back
113 $EXT_DUMMY['ext_name'] = $EXT_NAMES;
116 // Loading cache is done so let's free some memory!
117 unset($EXT_DUMMY['ext_keep']);
118 unset($EXT_DUMMY['ext_css']);
121 // Transfer dummy array
122 $GLOBALS['cache_array']['extension'] = $EXT_DUMMY;
125 // No database load needed
126 $res_ext_crt = false;
128 // Load all extension files in test-mode (we initialize them later)
129 foreach ($EXT_POOL as $ext) {
130 loadExtension($ext, 'test');
133 // Remove array and mark cache as loaded
135 } elseif (isHtmlOutputMode()) {
136 // Create cache file here
137 $GLOBALS['cache_instance']->init();
139 // Add more if sql_patches is recent enougth
141 if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) {
142 $add = ', `ext_has_css` AS `ext_css`';
145 // Load all modules and their data
146 $result = SQL_QUERY('SELECT `id` AS `ext_id`,`ext_name`,`ext_active`,`ext_version`' . $add . ' FROM `{?_MYSQL_PREFIX?}_extensions` ORDER BY `ext_name` ASC', __FILE__, __LINE__);
147 while ($content = SQL_FETCHARRAY($result)) {
149 loadExtension($content['ext_name'], 'test');
152 $content['ext_menu'] = convertBooleanToYesNo(ifModuleHasMenu($content['ext_name'], true));
154 // Get language entry
155 $content['ext_lang'] = convertBooleanToYesNo(isLanguageIncludeReadable($content['ext_name']));
157 // Get function entry
158 $content['ext_func'] = convertBooleanToYesNo(isExtensionFunctionFileReadable($content['ext_name']));
160 // Transfer EXT_ALWAYS_ACTIVE flag
161 $content['ext_keep'] = getThisExtensionAlwaysActive();
163 // Fix missing ext_css
164 if (!isset($content['ext_css'])) {
165 $content['ext_css'] = 'N';
168 // Add row to cache file
169 $GLOBALS['cache_instance']->addRow($content);
173 SQL_FREERESULT($result);
176 $GLOBALS['cache_instance']->storeExtensionVersion('sql_patches');
177 $GLOBALS['cache_instance']->finalize();