diff --git a/config/config.inc.php b/config/config.inc.php
index 9f30512a6..93de44263 100644
--- a/config/config.inc.php
+++ b/config/config.inc.php
@@ -62,9 +62,10 @@ require_once(dirname(__FILE__).'/autoload.php');
if (_PS_DEBUG_PROFILING_)
{
- include_once(_PS_ROOT_DIR_.'/override/classes/_Controller.php');
+ include_once(_PS_ROOT_DIR_.'/override/classes/controller/_Controller.php');
include_once(_PS_ROOT_DIR_.'/override/classes/_Module.php');
include_once(_PS_ROOT_DIR_.'/override/classes/_ObjectModel.php');
+ include_once(_PS_ROOT_DIR_.'/override/classes/_Hook.php');
include_once(_PS_ROOT_DIR_.'/override/classes/db/_Db.php');
}
diff --git a/override/classes/_Controller.php b/override/classes/_Controller.php
deleted file mode 100644
index fa810e712..000000000
--- a/override/classes/_Controller.php
+++ /dev/null
@@ -1,420 +0,0 @@
-
-* @copyright 2007-2011 PrestaShop SA
-* @version Release: $Revision$
-* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-//
-// IMPORTANT : don't forget to delete the underscore _ in the file name if you want to use it !
-//
-
-function developpementErrorHandler($errno, $errstr, $errfile, $errline)
-{
- if (!(error_reporting() & $errno))
- return;
- switch($errno)
- {
- case E_ERROR:
- echo '[PHP Error #'.$errno.'] '.$errstr.' ('.$errfile.', line '.$errline.')';
- break;
- case E_WARNING:
- echo '[PHP Warning #'.$errno.'] '.$errstr.' ('.$errfile.', line '.$errline.')';
- break;
- case E_PARSE:
- echo '[PHP Parse #'.$errno.'] '.$errstr.' ('.$errfile.', line '.$errline.')';
- break;
- case E_NOTICE:
- echo '[PHP Notice #'.$errno.'] '.$errstr.' ('.$errfile.', line '.$errline.')';
- break;
- case E_CORE_ERROR:
- echo '[PHP Core #'.$errno.'] '.$errstr.' ('.$errfile.', line '.$errline.')';
- break;
- case E_CORE_WARNING:
- echo '[PHP Core warning #'.$errno.'] '.$errstr.' ('.$errfile.', line '.$errline.')';
- break;
- case E_COMPILE_ERROR:
- echo '[PHP Compile #'.$errno.'] '.$errstr.' ('.$errfile.', line '.$errline.')';
- break;
- case E_COMPILE_WARNING:
- echo '[PHP Compile warning #'.$errno.'] '.$errstr.' ('.$errfile.', line '.$errline.')';
- break;
- case E_USER_ERROR:
- echo '[PHP Error #'.$errno.'] '.$errstr.' ('.$errfile.', line '.$errline.')';
- break;
- case E_USER_WARNING:
- echo '[PHP User warning #'.$errno.'] '.$errstr.' ('.$errfile.', line '.$errline.')';
- break;
- case E_USER_NOTICE:
- echo '[PHP User notice #'.$errno.'] '.$errstr.' ('.$errfile.', line '.$errline.')';
- break;
- case E_STRICT:
- echo '[PHP Strict #'.$errno.'] '.$errstr.' ('.$errfile.', line '.$errline.')';
- break;
- case E_RECOVERABLE_ERROR:
- echo '[PHP Recoverable error #'.$errno.'] '.$errstr.' ('.$errfile.', line '.$errline.')';
- break;
- default:
- echo '[PHP Unknown error #'.$errno.'] '.$errstr.' ('.$errfile.', line '.$errline.')';
- }
- die;
- return true;
-}
-
-abstract class Controller extends ControllerCore
-{
- public $_memory = array();
- public $_time = array();
- private static $_footer = true;
-
- public static function disableParentCalls()
- {
- self::$_footer = false;
- }
-
- private function displayMemoryColor($n)
- {
- $n /= 1048576;
- if ($n > 3)
- return ''.round($n, 2).' Mb';
- if ($n > 1)
- return ''.round($n, 2).' Mb';
- return ''.round($n, 2).' Mb';
- }
-
- private function displaySQLQueries($n)
- {
- if ($n > 150)
- return ''.$n.' queries';
- if ($n > 100)
- return ''.$n.' queries';
- return ''.$n.' quer'.($n == 1 ? 'y' : 'ies').'';
- }
-
- private function displayLoadTimeColor($n, $kikoo = false)
- {
- if ($n > 1)
- return ''.round($n, 3).'s'.($kikoo ? '
You\'d better run your shop on a toaster' : '');
- if ($n > 0.5)
- return ''.round($n * 1000).'ms'.($kikoo ? '
I hope it is a shared hosting' : '');
- return ''.round($n * 1000).'ms'.($kikoo ? '
Good boy! That\'s what I call a webserver!' : '');
- }
-
- private function getTimeColor($n)
- {
- if ($n > 4)
- return 'style="color:red"';
- if ($n > 2)
- return 'style="color:orange"';
- return 'style="color:green"';
- }
-
- private function getQueryColor($n)
- {
- if ($n > 5)
- return 'style="color:red"';
- if ($n > 2)
- return 'style="color:orange"';
- return 'style="color:green"';
- }
-
- private function getTableColor($n)
- {
- if ($n > 30)
- return 'style="color:red"';
- if ($n > 20)
- return 'style="color:orange"';
- return 'style="color:green"';
- }
-
- private function getObjectModelColor($n)
- {
- if ($n > 50)
- return 'style="color:red"';
- if ($n > 10)
- return 'style="color:orange"';
- return 'style="color:green"';
- }
-
- public function __construct()
- {
- parent::__construct();
-
- // error management
- set_error_handler('developpementErrorHandler');
- ini_set('html_errors', 'on');
- ini_set('display_errors', 'on');
- error_reporting(E_ALL | E_STRICT);
-
- if (!self::$_footer)
- return;
-
- $this->_memory['config'] = memory_get_usage();
- $this->_time['config'] = microtime(true);
-
- parent::__construct();
- $this->_memory['constructor'] = memory_get_usage();
- $this->_time['constructor'] = microtime(true);
- }
-
- public function run()
- {
- $this->init();
- $this->_memory['init'] = memory_get_usage();
- $this->_time['init'] = microtime(true);
-
- if ($this->checkAccess())
- {
- $this->_memory['checkAccess'] = memory_get_usage();
- $this->_time['checkAccess'] = microtime(true);
-
- if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className)))
- $this->setMedia();
- $this->_memory['setMedia'] = memory_get_usage();
- $this->_time['setMedia'] = microtime(true);
-
- // postProcess handles ajaxProcess
- $this->postProcess();
- $this->_memory['postProcess'] = memory_get_usage();
- $this->_time['postProcess'] = microtime(true);
-
- if (!empty($this->redirect_after))
- $this->redirect();
-
- if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className)))
- $this->initHeader();
- $this->_memory['initHeader'] = memory_get_usage();
- $this->_time['initHeader'] = microtime(true);
-
- $this->initContent();
- $this->_memory['initContent'] = memory_get_usage();
- $this->_time['initContent'] = microtime(true);
-
- if (!$this->content_only && ($this->display_footer || (isset($this->className) && $this->className)))
- $this->initFooter();
- $this->_memory['initFooter'] = memory_get_usage();
- $this->_time['initFooter'] = microtime(true);
-
- // default behavior for ajax process is to use $_POST[action] or $_GET[action]
- // then using displayAjax[action]
- if ($this->ajax)
- {
- $action = Tools::getValue('action');
- if (!empty($action) && method_exists($this, 'displayAjax'.Tools::toCamelCase($action)))
- $this->{'displayAjax'.$action}();
- elseif (method_exists($this, 'displayAjax'))
- $this->displayAjax();
- }
- else
- $this->displayDebug();
- }
- else
- {
- $this->initCursedPage();
- $this->displayDebug();
- }
- }
-
- function ini_get_display_errors()
- {
- $a = 'display_errors';
- $b = ini_get($a);
- switch (strtolower($b))
- {
- case 'on':
- case 'yes':
- case 'true':
- return 'assert.active' !== $a;
- case 'stdout':
- case 'stderr':
- return 'display_errors' === $a;
- default:
- return (bool)(int)$b;
- }
- }
-
- private function sizeofvar($var)
- {
- $start_memory = memory_get_usage();
- $tmp = unserialize(serialize($var));
- $size = memory_get_usage() - $start_memory;
- return $size;
- }
-
- public function displayDebug()
- {
- global $start_time;
-
- $this->display();
- $this->_memory['display'] = memory_get_usage();
- $this->_time['display'] = microtime(true);
-
- if (!$this->ini_get_display_errors())
- return;
-
- $hr = '