maruto 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -1
- data/fixtures/magento_1.0/app/Mage.php +585 -0
- data/fixtures/magento_1.13.0.0/app/Mage.php +42 -0
- data/fixtures/magento_1.3.3.0/app/Mage.php +738 -0
- data/fixtures/magento_1.4.0.0/app/Mage.php +859 -0
- data/fixtures/magento_1.7.0.2/app/Mage.php +989 -0
- data/lib/maruto/magento_instance.rb +4 -0
- data/lib/maruto/magento_version.rb +57 -0
- data/lib/maruto/module_configuration.rb +11 -2
- data/lib/maruto/runner.rb +12 -3
- data/lib/maruto/version.rb +1 -1
- data/maruto.gemspec +1 -1
- data/spec/magento_version_spec.rb +57 -0
- data/spec/module_events_spec.rb +45 -35
- metadata +14 -6
data/README.md
CHANGED
|
@@ -27,7 +27,7 @@ Or install it yourself as:
|
|
|
27
27
|
|
|
28
28
|
1. Fork it
|
|
29
29
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
30
|
-
3. Run the tests (`rake test`)
|
|
30
|
+
3. Run the tests (`bundle exec rake test`)
|
|
31
31
|
4. Commit your changes (`git commit -am 'Add some feature'`)
|
|
32
32
|
5. Push to the branch (`git push origin my-new-feature`)
|
|
33
33
|
6. Create new Pull Request
|
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Magento
|
|
4
|
+
*
|
|
5
|
+
* NOTICE OF LICENSE
|
|
6
|
+
*
|
|
7
|
+
* This source file is subject to the Open Software License (OSL 3.0)
|
|
8
|
+
* that is bundled with this package in the file LICENSE.txt.
|
|
9
|
+
* It is also available through the world-wide-web at this URL:
|
|
10
|
+
* http://opensource.org/licenses/osl-3.0.php
|
|
11
|
+
* If you did not receive a copy of the license and are unable to
|
|
12
|
+
* obtain it through the world-wide-web, please send an email
|
|
13
|
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
|
14
|
+
*
|
|
15
|
+
* @category Mage
|
|
16
|
+
* @package Mage_Core
|
|
17
|
+
* @copyright Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
|
18
|
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
define('DS', DIRECTORY_SEPARATOR);
|
|
22
|
+
define('PS', PATH_SEPARATOR);
|
|
23
|
+
define('BP', dirname(dirname(__FILE__)));
|
|
24
|
+
define('DEVELOPER_MODE', FALSE);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Error reporting
|
|
28
|
+
*/
|
|
29
|
+
error_reporting(E_ALL | E_STRICT);
|
|
30
|
+
|
|
31
|
+
Mage::register('original_include_path', get_include_path());
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Set include path
|
|
35
|
+
*/
|
|
36
|
+
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'local';
|
|
37
|
+
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'community';
|
|
38
|
+
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'core';
|
|
39
|
+
$paths[] = BP . DS . 'lib';
|
|
40
|
+
|
|
41
|
+
$app_path = implode(PS, $paths);
|
|
42
|
+
|
|
43
|
+
set_include_path($app_path . PS . Mage::registry('original_include_path'));
|
|
44
|
+
|
|
45
|
+
include_once "Mage/Core/functions.php";
|
|
46
|
+
include_once "Varien/Profiler.php";
|
|
47
|
+
|
|
48
|
+
Varien_Profiler::enable();
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Check magic quotes settings
|
|
52
|
+
*/
|
|
53
|
+
checkMagicQuotes();
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Main Mage hub class
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
final class Mage {
|
|
60
|
+
/**
|
|
61
|
+
* Registry collection
|
|
62
|
+
*
|
|
63
|
+
* @var array
|
|
64
|
+
*/
|
|
65
|
+
static private $_registry = array();
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Application model
|
|
69
|
+
*
|
|
70
|
+
* @var Mage_Core_Model_App
|
|
71
|
+
*/
|
|
72
|
+
static private $_app;
|
|
73
|
+
|
|
74
|
+
static private $_useCache = array();
|
|
75
|
+
|
|
76
|
+
static private $_objects;
|
|
77
|
+
|
|
78
|
+
static private $_isDownloader = false;
|
|
79
|
+
|
|
80
|
+
public static function getVersion()
|
|
81
|
+
{
|
|
82
|
+
return '1.0';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Register a new variable
|
|
87
|
+
*
|
|
88
|
+
* @param string $key
|
|
89
|
+
* @param mixed $value
|
|
90
|
+
*/
|
|
91
|
+
public static function register($key, $value)
|
|
92
|
+
{
|
|
93
|
+
if(isset(self::$_registry[$key])){
|
|
94
|
+
Mage::throwException('Mage registry key "'.$key.'" already exists');
|
|
95
|
+
}
|
|
96
|
+
self::$_registry[$key] = $value;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public static function unregister($key)
|
|
100
|
+
{
|
|
101
|
+
if (isset(self::$_registry[$key])) {
|
|
102
|
+
if (is_object(self::$_registry[$key]) && (method_exists(self::$_registry[$key],'__destruct'))) {
|
|
103
|
+
self::$_registry[$key]->__destruct();
|
|
104
|
+
}
|
|
105
|
+
unset(self::$_registry[$key]);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Retrieve a value from registry by a key
|
|
111
|
+
*
|
|
112
|
+
* @param string $key
|
|
113
|
+
* @return mixed
|
|
114
|
+
*/
|
|
115
|
+
public static function registry($key)
|
|
116
|
+
{
|
|
117
|
+
if (isset(self::$_registry[$key])) {
|
|
118
|
+
return self::$_registry[$key];
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Set application root absolute path
|
|
125
|
+
*
|
|
126
|
+
* @param string $appRoot
|
|
127
|
+
*/
|
|
128
|
+
public static function setRoot($appRoot='')
|
|
129
|
+
{
|
|
130
|
+
if (''===$appRoot) {
|
|
131
|
+
// automagically find application root by dirname of Mage.php
|
|
132
|
+
$appRoot = dirname(__FILE__);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
$appRoot = realpath($appRoot);
|
|
136
|
+
|
|
137
|
+
if (is_dir($appRoot) and is_readable($appRoot)) {
|
|
138
|
+
Mage::register('appRoot', $appRoot);
|
|
139
|
+
} else {
|
|
140
|
+
Mage::throwException($appRoot.' is not a directory or not readable by this user');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Get application root absolute path
|
|
146
|
+
*
|
|
147
|
+
* @return string
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
public static function getRoot()
|
|
151
|
+
{
|
|
152
|
+
return Mage::registry('appRoot');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Varien Objects Cache
|
|
157
|
+
*
|
|
158
|
+
* @param string $key optional, if specified will load this key
|
|
159
|
+
* @return Varien_Object_Cache
|
|
160
|
+
*/
|
|
161
|
+
public static function objects($key=null)
|
|
162
|
+
{
|
|
163
|
+
if (!self::$_objects) {
|
|
164
|
+
self::$_objects = new Varien_Object_Cache;
|
|
165
|
+
}
|
|
166
|
+
if (is_null($key)) {
|
|
167
|
+
return self::$_objects;
|
|
168
|
+
} else {
|
|
169
|
+
return self::$_objects->load($key);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Retrieve application root absolute path
|
|
175
|
+
*
|
|
176
|
+
* @return string
|
|
177
|
+
*/
|
|
178
|
+
public static function getBaseDir($type='', array $params=array())
|
|
179
|
+
{
|
|
180
|
+
return Mage::getConfig()->getBaseDir($type, $params);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
public static function getModuleDir($type, $moduleName)
|
|
184
|
+
{
|
|
185
|
+
return Mage::getConfig()->getModuleDir($type, $moduleName);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
public static function getStoreConfig($path, $id=null)
|
|
189
|
+
{
|
|
190
|
+
return self::app()->getStore($id)->getConfig($path);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
public static function getStoreConfigFlag($path, $id=null)
|
|
194
|
+
{
|
|
195
|
+
$flag = strtolower(Mage::getStoreConfig($path, $id));
|
|
196
|
+
if (!empty($flag) && 'false'!==$flag && '0'!==$flag) {
|
|
197
|
+
return true;
|
|
198
|
+
} else {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Get base URL path by type
|
|
205
|
+
*
|
|
206
|
+
* @param string $type
|
|
207
|
+
* @return string
|
|
208
|
+
*/
|
|
209
|
+
public static function getBaseUrl($type=Mage_Core_Model_Store::URL_TYPE_LINK, $secure=null)
|
|
210
|
+
{
|
|
211
|
+
return Mage::app()->getStore()->getBaseUrl($type, $secure);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Generate url by route and parameters
|
|
216
|
+
*
|
|
217
|
+
* @param string $route
|
|
218
|
+
* @param array $params
|
|
219
|
+
* @return string
|
|
220
|
+
*/
|
|
221
|
+
public static function getUrl($route='', $params=array())
|
|
222
|
+
{
|
|
223
|
+
return Mage::getModel('core/url')->getUrl($route, $params);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Get design package singleton
|
|
228
|
+
*
|
|
229
|
+
* @return Mage_Core_Model_Design_Package
|
|
230
|
+
*/
|
|
231
|
+
public static function getDesign()
|
|
232
|
+
{
|
|
233
|
+
return Mage::getSingleton('core/design_package');
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Get a config object
|
|
238
|
+
*
|
|
239
|
+
* @return Mage_Core_Model_Config
|
|
240
|
+
*/
|
|
241
|
+
public static function getConfig()
|
|
242
|
+
{
|
|
243
|
+
return Mage::registry('config');
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Add observer to even object
|
|
248
|
+
*
|
|
249
|
+
* @param string $eventName
|
|
250
|
+
* @param callback $callback
|
|
251
|
+
* @param array $arguments
|
|
252
|
+
* @param string $observerName
|
|
253
|
+
*/
|
|
254
|
+
public static function addObserver($eventName, $callback, $data=array(), $observerName='', $observerClass='')
|
|
255
|
+
{
|
|
256
|
+
if ($observerClass=='') {
|
|
257
|
+
$observerClass = 'Varien_Event_Observer';
|
|
258
|
+
}
|
|
259
|
+
$observer = new $observerClass();
|
|
260
|
+
$observer->setName($observerName)->addData($data)->setEventName($eventName)->setCallback($callback);
|
|
261
|
+
return Mage::registry('events')->addObserver($observer);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Dispatch event
|
|
266
|
+
*
|
|
267
|
+
* Calls all observer callbacks registered for this event
|
|
268
|
+
* and multiobservers matching event name pattern
|
|
269
|
+
*
|
|
270
|
+
* @param string $name
|
|
271
|
+
* @param array $args
|
|
272
|
+
*/
|
|
273
|
+
public static function dispatchEvent($name, array $data=array())
|
|
274
|
+
{
|
|
275
|
+
Varien_Profiler::start('DISPATCH EVENT:'.$name);
|
|
276
|
+
$result = Mage::app()->dispatchEvent($name, $data);
|
|
277
|
+
#$result = Mage::registry('events')->dispatch($name, $data);
|
|
278
|
+
Varien_Profiler::stop('DISPATCH EVENT:'.$name);
|
|
279
|
+
return $result;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Retrieve model object
|
|
284
|
+
*
|
|
285
|
+
* @link Mage_Core_Model_Config::getModelInstance
|
|
286
|
+
* @param string $modelClass
|
|
287
|
+
* @param array $arguments
|
|
288
|
+
* @return Mage_Core_Model_Abstract
|
|
289
|
+
*/
|
|
290
|
+
public static function getModel($modelClass='', $arguments=array())
|
|
291
|
+
{
|
|
292
|
+
return Mage::getConfig()->getModelInstance($modelClass, $arguments);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Retrieve model object singleton
|
|
297
|
+
*
|
|
298
|
+
* @param string $modelClass
|
|
299
|
+
* @param array $arguments
|
|
300
|
+
* @return Mage_Core_Model_Abstract
|
|
301
|
+
*/
|
|
302
|
+
public static function getSingleton($modelClass='', array $arguments=array())
|
|
303
|
+
{
|
|
304
|
+
$registryKey = '_singleton/'.$modelClass;
|
|
305
|
+
if (!Mage::registry($registryKey)) {
|
|
306
|
+
Mage::register($registryKey, Mage::getModel($modelClass, $arguments));
|
|
307
|
+
}
|
|
308
|
+
return Mage::registry($registryKey);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Retrieve object of resource model
|
|
313
|
+
*
|
|
314
|
+
* @param string $modelClass
|
|
315
|
+
* @param array $arguments
|
|
316
|
+
* @return Object
|
|
317
|
+
*/
|
|
318
|
+
public static function getResourceModel($modelClass, $arguments=array())
|
|
319
|
+
{
|
|
320
|
+
return Mage::getConfig()->getResourceModelInstance($modelClass, $arguments);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Retrieve resource vodel object singleton
|
|
325
|
+
*
|
|
326
|
+
* @param string $modelClass
|
|
327
|
+
* @param array $arguments
|
|
328
|
+
* @return object
|
|
329
|
+
*/
|
|
330
|
+
public static function getResourceSingleton($modelClass='', array $arguments=array())
|
|
331
|
+
{
|
|
332
|
+
$registryKey = '_resource_singleton/'.$modelClass;
|
|
333
|
+
if (!Mage::registry($registryKey)) {
|
|
334
|
+
Mage::register($registryKey, Mage::getResourceModel($modelClass, $arguments));
|
|
335
|
+
}
|
|
336
|
+
return Mage::registry($registryKey);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Deprecated, use Mage::helper()
|
|
341
|
+
*
|
|
342
|
+
* @param string $type
|
|
343
|
+
* @return object
|
|
344
|
+
*/
|
|
345
|
+
public static function getBlockSingleton($type)
|
|
346
|
+
{
|
|
347
|
+
$action = Mage::app()->getFrontController()->getAction();
|
|
348
|
+
return $action ? $action->getLayout()->getBlockSingleton($type) : false;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Retrieve helper object
|
|
353
|
+
*
|
|
354
|
+
* @param helper name $name
|
|
355
|
+
* @return Mage_Core_Helper_Abstract
|
|
356
|
+
*/
|
|
357
|
+
public static function helper($name)
|
|
358
|
+
{
|
|
359
|
+
return Mage::app()->getHelper($name);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Return new exception by module to be thrown
|
|
364
|
+
*
|
|
365
|
+
* @param string $module
|
|
366
|
+
* @param string $message
|
|
367
|
+
* @param integer $code
|
|
368
|
+
*/
|
|
369
|
+
public static function exception($module='Mage_Core', $message='', $code=0)
|
|
370
|
+
{
|
|
371
|
+
$className = $module.'_Exception';
|
|
372
|
+
return new $className($message, $code);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
public static function throwException($message, $messageStorage=null)
|
|
376
|
+
{
|
|
377
|
+
if ($messageStorage && ($storage = Mage::getSingleton($messageStorage))) {
|
|
378
|
+
$storage->addError($message);
|
|
379
|
+
}
|
|
380
|
+
throw new Mage_Core_Exception($message);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Initialize and retrieve application
|
|
385
|
+
*
|
|
386
|
+
* @param string $code
|
|
387
|
+
* @param string $type
|
|
388
|
+
* @param string $etcDir
|
|
389
|
+
* @return Mage_Core_Model_App
|
|
390
|
+
*/
|
|
391
|
+
public static function app($code = '', $type = 'store', $etcDir=null)
|
|
392
|
+
{
|
|
393
|
+
if (is_null(self::$_app)) {
|
|
394
|
+
Varien_Profiler::start('app/init');
|
|
395
|
+
|
|
396
|
+
self::$_app = new Mage_Core_Model_App();
|
|
397
|
+
|
|
398
|
+
Mage::setRoot();
|
|
399
|
+
Mage::register('events', new Varien_Event_Collection());
|
|
400
|
+
Mage::register('config', new Mage_Core_Model_Config());
|
|
401
|
+
|
|
402
|
+
self::$_app->init($code, $type, $etcDir);
|
|
403
|
+
self::$_app->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS);
|
|
404
|
+
}
|
|
405
|
+
return self::$_app;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Front end main entry point
|
|
410
|
+
*
|
|
411
|
+
* @param string $code
|
|
412
|
+
* @param string $type
|
|
413
|
+
* @param string $etcDir
|
|
414
|
+
*/
|
|
415
|
+
public static function run($code='', $type = 'store', $etcDir=null)
|
|
416
|
+
{
|
|
417
|
+
try {
|
|
418
|
+
Varien_Profiler::start('app');
|
|
419
|
+
|
|
420
|
+
self::loadRequiredExtensions();
|
|
421
|
+
|
|
422
|
+
self::app($code, $type, $etcDir);
|
|
423
|
+
//print self::app()->getStore();
|
|
424
|
+
self::app()->getFrontController()->dispatch();
|
|
425
|
+
|
|
426
|
+
Varien_Profiler::stop('app');
|
|
427
|
+
}
|
|
428
|
+
catch (Exception $e) {
|
|
429
|
+
if (self::app()->isInstalled() || self::$_isDownloader) {
|
|
430
|
+
self::printException($e);
|
|
431
|
+
exit();
|
|
432
|
+
}
|
|
433
|
+
try {
|
|
434
|
+
self::dispatchEvent('mage_run_exception', array('exception'=>$e));
|
|
435
|
+
if (!headers_sent()) {
|
|
436
|
+
//header('Location:'.Mage::getBaseUrl().'install/');
|
|
437
|
+
header('Location:'.self::getUrl('install'));
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
self::printException($e);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
catch (Exception $ne){
|
|
444
|
+
self::printException($e);
|
|
445
|
+
self::printException($ne);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* log facility (??)
|
|
452
|
+
*
|
|
453
|
+
* @param string $message
|
|
454
|
+
* @param integer $level
|
|
455
|
+
* @param string $file
|
|
456
|
+
*/
|
|
457
|
+
public static function log($message, $level=null, $file = '')
|
|
458
|
+
{
|
|
459
|
+
if (!self::getConfig()) {
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
if (!Mage::getStoreConfig('dev/log/active')) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
static $loggers = array();
|
|
467
|
+
|
|
468
|
+
$level = is_null($level) ? Zend_Log::DEBUG : $level;
|
|
469
|
+
if (empty($file)) {
|
|
470
|
+
$file = Mage::getStoreConfig('dev/log/file');
|
|
471
|
+
$file = empty($file) ? 'system.log' : $file;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
try {
|
|
475
|
+
if (!isset($loggers[$file])) {
|
|
476
|
+
$logFile = Mage::getBaseDir('var').DS.'log'.DS.$file;
|
|
477
|
+
$logDir = Mage::getBaseDir('var').DS.'log';
|
|
478
|
+
|
|
479
|
+
if (!is_dir(Mage::getBaseDir('var').DS.'log')) {
|
|
480
|
+
mkdir(Mage::getBaseDir('var').DS.'log', 0777);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
if (!file_exists($logFile)) {
|
|
484
|
+
file_put_contents($logFile,'');
|
|
485
|
+
chmod($logFile, 0777);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
$format = '%timestamp% %priorityName% (%priority%): %message%' . PHP_EOL;
|
|
489
|
+
$formatter = new Zend_Log_Formatter_Simple($format);
|
|
490
|
+
$writer = new Zend_Log_Writer_Stream($logFile);
|
|
491
|
+
$writer->setFormatter($formatter);
|
|
492
|
+
$loggers[$file] = new Zend_Log($writer);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
if (is_array($message) || is_object($message)) {
|
|
496
|
+
$message = print_r($message, true);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
$loggers[$file]->log($message, $level);
|
|
500
|
+
}
|
|
501
|
+
catch (Exception $e){
|
|
502
|
+
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
public static function logException(Exception $e)
|
|
507
|
+
{
|
|
508
|
+
if (!self::getConfig()) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
$file = Mage::getStoreConfig('dev/log/exception_file');
|
|
512
|
+
self::log("\n".$e->getTraceAsString(), Zend_Log::ERR, $file);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Display exception
|
|
517
|
+
*
|
|
518
|
+
* @param Exception $e
|
|
519
|
+
*/
|
|
520
|
+
public static function printException(Exception $e, $extra = '')
|
|
521
|
+
{
|
|
522
|
+
ob_start();
|
|
523
|
+
mageSendErrorHeader();
|
|
524
|
+
if ($extra != '') {
|
|
525
|
+
echo $extra."\n";
|
|
526
|
+
}
|
|
527
|
+
echo $e->getMessage();
|
|
528
|
+
mageSendErrorFooter();
|
|
529
|
+
$trace = ob_get_clean();
|
|
530
|
+
#exit;
|
|
531
|
+
if ( DEVELOPER_MODE ) {
|
|
532
|
+
echo '<pre>'.$trace.'</pre>';
|
|
533
|
+
} else {
|
|
534
|
+
$file = microtime(true)*100;
|
|
535
|
+
$traceFile = Mage::getBaseDir('var').DS.$file;
|
|
536
|
+
file_put_contents($traceFile, $trace);
|
|
537
|
+
chmod($traceFile, 0777);
|
|
538
|
+
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).'report?id='.$file.'&s='.Mage::app()->getStore()->getCode();
|
|
539
|
+
if (!headers_sent()) {
|
|
540
|
+
header('Location: '.$url);
|
|
541
|
+
} else {
|
|
542
|
+
echo "<script type='text/javascript'>location.href='".$url."'</script>";
|
|
543
|
+
}
|
|
544
|
+
die;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Tries to dynamically load an extension if not loaded
|
|
551
|
+
*
|
|
552
|
+
* @param string $ext
|
|
553
|
+
* @return boolean
|
|
554
|
+
*/
|
|
555
|
+
public static function loadExtension($ext)
|
|
556
|
+
{
|
|
557
|
+
if (extension_loaded($ext)) {
|
|
558
|
+
return true;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
if (ini_get('enable_dl') !== 1 || ini_get('safe_mode') === 1) {
|
|
562
|
+
return false;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
$file = (PHP_SHLIB_SUFFIX === 'dll' ? 'php_' : '') . $ext . '.' . PHP_SHLIB_SUFFIX;
|
|
566
|
+
return @dl($file);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
public static function loadRequiredExtensions()
|
|
570
|
+
{
|
|
571
|
+
$result = true;
|
|
572
|
+
foreach (array('mcrypt', 'simplexml', 'pdo_mysql', 'curl', 'iconv') as $ext) {
|
|
573
|
+
if (!self::loadExtension($ext)) {
|
|
574
|
+
$result = false;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
return $result;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
public static function setIsDownloader($flag=true)
|
|
582
|
+
{
|
|
583
|
+
self::$_isDownloader = $flag;
|
|
584
|
+
}
|
|
585
|
+
}
|