]> git.mxchange.org Git - mailer.git/blob - inc/loader/load_cache-extension.php
API functions renamed:
[mailer.git] / inc / loader / load_cache-extension.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 06/26/2004 *
4  * ===================                          Last change: 07/01/2005 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : load_cache-extensions.php                        *
8  * -------------------------------------------------------------------- *
9  * Short description : Load all extensions                              *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Alle Erweiterungen laden                         *
12  * -------------------------------------------------------------------- *
13  * @TODO Rewrite this whole file to load_cache-extensions.php           *
14  * -------------------------------------------------------------------- *
15  * $Revision::                                                        $ *
16  * $Date::                                                            $ *
17  * $Tag:: 0.2.1-FINAL                                                 $ *
18  * $Author::                                                          $ *
19  * Needs to be in all Files and every File needs "svn propset           *
20  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
21  * -------------------------------------------------------------------- *
22  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
23  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
24  * For more information visit: http://www.mxchange.org                  *
25  *                                                                      *
26  * This program is free software; you can redistribute it and/or modify *
27  * it under the terms of the GNU General Public License as published by *
28  * the Free Software Foundation; either version 2 of the License, or    *
29  * (at your option) any later version.                                  *
30  *                                                                      *
31  * This program is distributed in the hope that it will be useful,      *
32  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
33  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
34  * GNU General Public License for more details.                         *
35  *                                                                      *
36  * You should have received a copy of the GNU General Public License    *
37  * along with this program; if not, write to the Free Software          *
38  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
39  * MA  02110-1301  USA                                                  *
40  ************************************************************************/
41
42 // Some security stuff...
43 if (!defined('__SECURITY')) {
44         die();
45 } // END - if
46
47 // Use this code if you don't want to run this cache loader on installation phase
48 if (isInstallationPhase()) return;
49
50 // Next cached table is the extension
51 if (($GLOBALS['cache_instance']->loadCacheFile('extension')) && ($GLOBALS['cache_instance']->extensionVersionMatches('sql_patches'))) {
52         // Load extension from cache
53         $EXT_DUMMY = $GLOBALS['cache_instance']->getArrayFromCache();
54
55         // Init extension inc-pool
56         $EXT_POOL = array();
57
58         // Do we have entries?
59         if (count($EXT_DUMMY) > 0) {
60                 // Init arrays
61                 $EXT_NAMES = array();
62
63                 // Loop through all
64                 foreach ($EXT_DUMMY['ext_name'] as $k => $name) {
65                         // Load CSS file
66                         if ($EXT_DUMMY['ext_css'][$k] == 'Y') addExtensionCssFile($name . '.css');
67
68                         // Load extension file itself
69                         if (($EXT_DUMMY['ext_active'][$k] == 'Y') || ($EXT_DUMMY['ext_keep'][$k] == 'Y')) {
70                                 $EXT_POOL[] = $name;
71                         } // END - if
72
73                         // Version number
74                         $EXT_DUMMY['ext_version'][$name] = $EXT_DUMMY['ext_version'][$k];
75                         unset($EXT_DUMMY['ext_version'][$k]);
76
77                         // Extension is active
78                         $EXT_DUMMY['ext_active'][$name] = $EXT_DUMMY['ext_active'][$k];
79                         unset($EXT_DUMMY['ext_active'][$k]);
80
81                         // Ext menu
82                         $EXT_DUMMY['ext_menu'][$name] = $EXT_DUMMY['ext_menu'][$k];
83                         unset($EXT_DUMMY['ext_menu'][$k]);
84
85                         // Language file
86                         $EXT_DUMMY['ext_lang'][$name] = $EXT_DUMMY['ext_lang'][$k];
87                         unset($EXT_DUMMY['ext_lang'][$k]);
88
89                         // Functions file
90                         $EXT_DUMMY['ext_func'][$name] = $EXT_DUMMY['ext_func'][$k];
91                         unset($EXT_DUMMY['ext_func'][$k]);
92
93                         // Extension id
94                         $EXT_DUMMY['ext_id'][$name] = $EXT_DUMMY['ext_id'][$k];
95                         $id = $EXT_DUMMY['ext_id'][$name];
96                         unset($EXT_DUMMY['ext_id'][$k]);
97
98                         // Add ext name
99                         $EXT_NAMES[$id] = $name;
100
101                         // Add deprecated flag (defaults to 'not deprecated')
102                         $EXT_DUMMY['ext_deprecated'][$name] = 'N';
103
104                         // Mark it as active extension
105                         $GLOBALS['cache_array']['always_active'][$name] = $EXT_DUMMY['ext_keep'][$k];
106                         unset($EXT_DUMMY['ext_keep'][$k]);
107
108                         // Remove unneccessary data from memory
109                         unset($EXT_DUMMY['ext_css'][$k]);
110                 } // END - foreach
111
112                 // Write dummy array back
113                 $EXT_DUMMY['ext_name'] = $EXT_NAMES;
114                 unset($EXT_NAMES);
115
116                 // Loading cache is done so let's free some memory!
117                 unset($EXT_DUMMY['ext_keep']);
118                 unset($EXT_DUMMY['ext_css']);
119         } // END - if
120
121         // Transfer dummy array
122         $GLOBALS['cache_array']['extension'] = $EXT_DUMMY;
123         unset($EXT_DUMMY);
124
125         // No database load needed
126         $res_ext_crt = false;
127
128         // Load all extension files in test-mode (we initialize them later)
129         foreach ($EXT_POOL as $ext) {
130                 loadExtension($ext, 'test');
131         } // END - foreach
132
133         // Remove array and mark cache as loaded
134         unset($EXT_POOL);
135 } elseif (getScriptOutputMode() != 1) {
136         // Create cache file here
137         $GLOBALS['cache_instance']->init();
138
139         // Add more if sql_patches is recent enougth
140         $add = '';
141         if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) $add = ", `ext_has_css` AS ext_css";
142
143         // Load all modules and their data
144         $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__);
145         while ($content = SQL_FETCHARRAY($result)) {
146                 // Load extension
147                 loadExtension($content['ext_name'], 'test');
148
149                 // Get menu entry
150                 $content['ext_menu'] = 'N';
151                 if (ifModuleHasMenu($content['ext_name'], true)) {
152                         // Extension is a module and has menu... pew!
153                         $content['ext_menu'] = 'Y';
154                 } // END - if
155
156                 // Get language entry
157                 $content['ext_lang'] = 'N';
158                 if (isLanguageIncludeReadable($content['ext_name'])) {
159                         // Readable
160                         $content['ext_lang'] = 'Y';
161                 } // END - if
162
163                 // Get function entry
164                 $content['ext_func'] = 'N';
165                 if (isExtensionFunctionFileReadable($content['ext_name'])) {
166                         // Readable
167                         $content['ext_func'] = 'Y';
168                 } // END - if
169
170                 // Transfer EXT_ALWAYS_ACTIVE flag
171                 $content['ext_keep'] = getExtensionAlwaysActive();
172
173                 // Fix missing ext_css
174                 if (!isset($content['ext_css'])) $content['ext_css'] = 'N';
175
176                 // Add row to cache file
177                 $GLOBALS['cache_instance']->addRow($content);
178         } // END - while
179
180         // Free memory
181         SQL_FREERESULT($result);
182
183         // Close the cache
184         $GLOBALS['cache_instance']->storeExtensionVersion('sql_patches');
185         $GLOBALS['cache_instance']->finalize();
186 }
187
188 // [EOF]
189 ?>