From 1ba341b06441dbb7364d0fe2a756992819cc63de Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Mon, 2 Jun 2014 18:58:49 +0400 Subject: [PATCH] Add namespace. --- {app => App}/Action.php | 10 ++--- {app => App}/AjaxAction.php | 2 +- {app => App}/CliController.php | 2 +- {app => App}/ErrorAction.php | 14 +++---- {app => App}/FrontController.php | 42 ++++++++++----------- {app => App}/PagerAction.php | 2 +- {app/router => App/Router}/Route.php | 4 +- {app/router => App/Router}/Router.php | 10 ++--- {app => App}/StaticAction.php | 2 +- {app => App}/iCli.php | 2 +- {cache => Cache}/Cache.php | 0 {cache => Cache}/CacheKey.php | 0 {cache => Cache}/Cacher.php | 0 {cache => Cache}/MemcacheCache.php | 0 {captcha => Captcha}/Captcha.php | 0 {captcha => Captcha}/CaptchaImageAction.php | 0 {captcha => Captcha}/CaptchaValidator.php | 0 {captcha => Captcha}/poh.ttf | Bin Config.php | 8 ++-- classes/Env.class.php => Env.php | 4 +- {classes => Env}/Format.class.php | 0 {classes => Env}/User.class.php | 0 {exception => Exception}/Error404Exception.php | 4 +- {exception => Exception}/ErrorHTTPException.php | 2 +- {exception => Exception}/ErrorHandler.php | 32 ++++++++-------- {exception => Exception}/GeneralException.php | 4 +- .../InitializationException.php | 4 +- {form => Form}/Form.php | 12 +++--- {form => Form}/FormField.php | 16 ++++---- {form => Form}/FormViewHelper.php | 8 ++-- layout/Error.layout.php => Layout/ErrorLayout.php | 8 ++-- {layout => Layout}/Layout.php | 14 +++---- Load.php | 17 ++++++++- {logger => Logger}/CliLogger.php | 2 +- {logger => Logger}/FileLogger.php | 6 +-- {logger => Logger}/Logger.php | 6 +-- {mail => Mail}/Mailer.php | 0 {model => Model}/Db.php | 16 ++++---- {model => Model}/DbDriver.php | 4 +- {model => Model}/DbExpr.php | 2 +- {model => Model}/DbStatement.php | 10 ++--- {model => Model}/Model.php | 10 ++--- {model => Model}/MongoDbCommand.php | 4 +- {model => Model}/MongoDriver.php | 0 {model => Model}/MongoModel.php | 8 ++-- {model => Model}/MongoStatement.php | 0 {model => Model}/MySQLiDriver.php | 6 +-- {model => Model}/MySQLiStatement.php | 34 ++++++++--------- {model => Model}/NoSqlDbDriver.php | 2 +- {model => Model}/SqlCriteria.php | 2 +- {model => Model}/SqlDbDriver.php | 8 ++-- {model => Model}/SqlModel.php | 4 +- {model => Model}/SqlResultCollection.php | 4 +- {model => Model}/SqlResultProvider.php | 8 ++-- {model => Model}/iSqlResultItems.php | 2 +- {redis => Redis}/RedisDebug.php | 2 +- {redis => Redis}/RedisManager.php | 16 ++++---- {redis => Redis}/redis.php | 2 +- Registry.php | 6 +-- {session => Session}/Session.model.php | 2 +- {session => Session}/Session.php | 4 +- {session => Session}/session.sql | 0 {tests => Tests}/ConfigTest.php | 0 {tests => Tests}/LoadTest.php | 0 {tests => Tests}/MySQLTestsSuite.php | 0 {tests => Tests}/RedisTestsSuite.php | 0 {tests => Tests}/RegistryTest.php | 0 {tests => Tests}/app/ActionTest.php | 0 {tests => Tests}/app/Action_TestCase.php | 0 {tests => Tests}/app/AjaxActionTest.php | 0 {tests => Tests}/app/CliControllerTest.php | 0 {tests => Tests}/app/ErrorActionTest.php | 0 {tests => Tests}/app/FrontControllerTest.php | 0 {tests => Tests}/app/PagerActionTest.php | 0 {tests => Tests}/app/StaticActionTest.php | 0 {tests => Tests}/app/router/RouteTest.php | 0 {tests => Tests}/app/router/RouterTest.php | 0 {tests => Tests}/bootstrap.php | 0 {tests => Tests}/cache/CacheKeyTest.php | 0 {tests => Tests}/cache/CacherTest.php | 0 {tests => Tests}/cache/MemcacheCacheTest.php | 0 {tests => Tests}/captcha/CaptchaTest.php | 0 {tests => Tests}/captcha/CaptchaValidatorTest.php | 0 {tests => Tests}/classes/EnvTest.php | 0 {tests => Tests}/classes/FormatTest.php | 0 .../exception/Error404ExceptionTest.php | 0 .../exception/ErrorHTTPExceptionTest.php | 0 {tests => Tests}/exception/ErrorHandlerTest.php | 0 .../exception/GeneralExceptionTest.php | 0 .../exception/InitializationExceptionTest.php | 0 {tests => Tests}/form/FormFieldTest.php | 0 {tests => Tests}/form/FormTest.php | 0 {tests => Tests}/form/FormViewHelperTest.php | 0 {tests => Tests}/i18n/I18NTest.php | 0 {tests => Tests}/layout/ErrorLayoutTest.php | 0 {tests => Tests}/layout/LayoutTest.php | 0 {tests => Tests}/logger/CliLoggerTest.php | 0 {tests => Tests}/logger/FileLoggerTest.php | 0 {tests => Tests}/model/DbExprTest.php | 0 {tests => Tests}/model/DbStatementTest.php | 0 {tests => Tests}/model/DbTest.php | 0 {tests => Tests}/model/MongoDbCommandTest.php | 0 {tests => Tests}/model/MongoDriverTest.php | 0 {tests => Tests}/model/MongoModelTest.php | 0 {tests => Tests}/model/MongoStatementTest.php | 0 {tests => Tests}/model/MyDbDriver.php | 0 {tests => Tests}/model/MySQLiDriverTest.php | 0 {tests => Tests}/model/MySQLiStatementTest.php | 0 {tests => Tests}/model/SqlDbDriverTest.php | 0 {tests => Tests}/model/SqlModelTest.php | 0 {tests => Tests}/model/testData.xml | 0 {tests => Tests}/model/testDataAfterCommit.xml | 0 {tests => Tests}/model/testdb.sql | 0 {tests => Tests}/phpunit.xml | 0 {tests => Tests}/redis/RedisDebugTest.php | 0 {tests => Tests}/redis/RedisManagerTest.php | 0 {tests => Tests}/session/SessionModelTest.php | 0 {tests => Tests}/session/SessionTest.php | 0 {tests => Tests}/util/AutoloadBuilderTest.php | 0 {tests => Tests}/util/AutoloadBuilderTestVFS.php | 0 .../util/profiler/CommandProfilerTest.php | 0 {tests => Tests}/util/profiler/ProfilerTest.php | 0 {tests => Tests}/validator/EmailValidatorTest.php | 0 {tests => Tests}/validator/EqualValidatorTest.php | 0 .../validator/NotEmptyValidatorTest.php | 0 {tests => Tests}/validator/RegexValidatorTest.php | 0 {tests => Tests}/view/PHPViewTest.php | 0 .../view/helpers/BreadcrumbVeiwHelperTest.php | 0 .../view/helpers/GetViewHelperTest.php | 0 .../view/helpers/HeadViewHelperTest.php | 0 .../view/helpers/MsgViewHelperTest.php | 0 .../view/helpers/TitleViewHelperTest.php | 0 {util => Util}/AsciiSortedIterator.php | 0 {util => Util}/AutoloadBuilder.php | 10 ++--- {util => Util}/FirePHPCore-0.3.2/CHANGELOG | 0 {util => Util}/FirePHPCore-0.3.2/CREDITS | 0 {util => Util}/FirePHPCore-0.3.2/README | 0 .../lib/FirePHPCore/FirePHP.class.php | 0 .../FirePHPCore-0.3.2/lib/FirePHPCore/LICENSE | 0 .../FirePHPCore-0.3.2/lib/FirePHPCore/fb.php | 0 .../profiler => Util/Profiler}/CommandProfiler.php | 2 +- {util/profiler => Util/Profiler}/Profiler.php | 4 +- {validator => Validator}/EmailValidator.php | 2 +- {validator => Validator}/EqualValidator.php | 2 +- {validator => Validator}/MbStrlenValidator.php | 2 +- {validator => Validator}/NotEmptyValidator.php | 2 +- {validator => Validator}/RegexValidator.php | 6 +-- {validator => Validator}/StrlenValidator.php | 2 +- {validator => Validator}/Validator.php | 4 +- {validator => Validator}/iValidator.php | 4 +- .../Helpers}/BreadcrumbViewHelper.php | 8 ++-- {view/helpers => View/Helpers}/GetViewHelper.php | 4 +- {view/helpers => View/Helpers}/HeadViewHelper.php | 8 ++-- {view/helpers => View/Helpers}/MsgViewHelper.php | 12 +++--- {view/helpers => View/Helpers}/TitleViewHelper.php | 8 ++-- {view/helpers => View/Helpers}/ViewHelper.php | 4 +- {view => View}/PHPView.php | 41 ++++++++++---------- {view => View}/iView.php | 2 +- composer.json | 9 ++--- 159 files changed, 265 insertions(+), 264 deletions(-) rename {app => App}/Action.php (81%) rename {app => App}/AjaxAction.php (97%) rename {app => App}/CliController.php (98%) rename {app => App}/ErrorAction.php (74%) rename {app => App}/FrontController.php (69%) rename {app => App}/PagerAction.php (97%) rename {app/router => App/Router}/Route.php (98%) rename {app/router => App/Router}/Router.php (89%) rename {app => App}/StaticAction.php (94%) rename {app => App}/iCli.php (89%) rename {cache => Cache}/Cache.php (100%) rename {cache => Cache}/CacheKey.php (100%) rename {cache => Cache}/Cacher.php (100%) rename {cache => Cache}/MemcacheCache.php (100%) rename {captcha => Captcha}/Captcha.php (100%) rename {captcha => Captcha}/CaptchaImageAction.php (100%) rename {captcha => Captcha}/CaptchaValidator.php (100%) rename {captcha => Captcha}/poh.ttf (100%) rename classes/Env.class.php => Env.php (96%) rename {classes => Env}/Format.class.php (100%) rename {classes => Env}/User.class.php (100%) rename {exception => Exception}/Error404Exception.php (69%) rename {exception => Exception}/ErrorHTTPException.php (97%) rename {exception => Exception}/ErrorHandler.php (88%) rename {exception => Exception}/GeneralException.php (65%) rename {exception => Exception}/InitializationException.php (69%) rename {form => Form}/Form.php (92%) rename {form => Form}/FormField.php (86%) rename {form => Form}/FormViewHelper.php (77%) rename layout/Error.layout.php => Layout/ErrorLayout.php (66%) rename {layout => Layout}/Layout.php (81%) rename {logger => Logger}/CliLogger.php (95%) rename {logger => Logger}/FileLogger.php (82%) rename {logger => Logger}/Logger.php (89%) rename {mail => Mail}/Mailer.php (100%) rename {model => Model}/Db.php (71%) rename {model => Model}/DbDriver.php (93%) rename {model => Model}/DbExpr.php (93%) rename {model => Model}/DbStatement.php (89%) rename {model => Model}/Model.php (94%) rename {model => Model}/MongoDbCommand.php (98%) rename {model => Model}/MongoDriver.php (100%) rename {model => Model}/MongoModel.php (95%) rename {model => Model}/MongoStatement.php (100%) rename {model => Model}/MySQLiDriver.php (96%) rename {model => Model}/MySQLiStatement.php (80%) rename {model => Model}/NoSqlDbDriver.php (89%) rename {model => Model}/SqlCriteria.php (99%) rename {model => Model}/SqlDbDriver.php (96%) rename {model => Model}/SqlModel.php (99%) rename {model => Model}/SqlResultCollection.php (84%) rename {model => Model}/SqlResultProvider.php (91%) rename {model => Model}/iSqlResultItems.php (80%) rename {redis => Redis}/RedisDebug.php (96%) rename {redis => Redis}/RedisManager.php (70%) rename {redis => Redis}/redis.php (99%) rename {session => Session}/Session.model.php (98%) rename {session => Session}/Session.php (99%) rename {session => Session}/session.sql (100%) rename {tests => Tests}/ConfigTest.php (100%) rename {tests => Tests}/LoadTest.php (100%) rename {tests => Tests}/MySQLTestsSuite.php (100%) rename {tests => Tests}/RedisTestsSuite.php (100%) rename {tests => Tests}/RegistryTest.php (100%) rename {tests => Tests}/app/ActionTest.php (100%) rename {tests => Tests}/app/Action_TestCase.php (100%) rename {tests => Tests}/app/AjaxActionTest.php (100%) rename {tests => Tests}/app/CliControllerTest.php (100%) rename {tests => Tests}/app/ErrorActionTest.php (100%) rename {tests => Tests}/app/FrontControllerTest.php (100%) rename {tests => Tests}/app/PagerActionTest.php (100%) rename {tests => Tests}/app/StaticActionTest.php (100%) rename {tests => Tests}/app/router/RouteTest.php (100%) rename {tests => Tests}/app/router/RouterTest.php (100%) rename {tests => Tests}/bootstrap.php (100%) rename {tests => Tests}/cache/CacheKeyTest.php (100%) rename {tests => Tests}/cache/CacherTest.php (100%) rename {tests => Tests}/cache/MemcacheCacheTest.php (100%) rename {tests => Tests}/captcha/CaptchaTest.php (100%) rename {tests => Tests}/captcha/CaptchaValidatorTest.php (100%) rename {tests => Tests}/classes/EnvTest.php (100%) rename {tests => Tests}/classes/FormatTest.php (100%) rename {tests => Tests}/exception/Error404ExceptionTest.php (100%) rename {tests => Tests}/exception/ErrorHTTPExceptionTest.php (100%) rename {tests => Tests}/exception/ErrorHandlerTest.php (100%) rename {tests => Tests}/exception/GeneralExceptionTest.php (100%) rename {tests => Tests}/exception/InitializationExceptionTest.php (100%) rename {tests => Tests}/form/FormFieldTest.php (100%) rename {tests => Tests}/form/FormTest.php (100%) rename {tests => Tests}/form/FormViewHelperTest.php (100%) rename {tests => Tests}/i18n/I18NTest.php (100%) rename {tests => Tests}/layout/ErrorLayoutTest.php (100%) rename {tests => Tests}/layout/LayoutTest.php (100%) rename {tests => Tests}/logger/CliLoggerTest.php (100%) rename {tests => Tests}/logger/FileLoggerTest.php (100%) rename {tests => Tests}/model/DbExprTest.php (100%) rename {tests => Tests}/model/DbStatementTest.php (100%) rename {tests => Tests}/model/DbTest.php (100%) rename {tests => Tests}/model/MongoDbCommandTest.php (100%) rename {tests => Tests}/model/MongoDriverTest.php (100%) rename {tests => Tests}/model/MongoModelTest.php (100%) rename {tests => Tests}/model/MongoStatementTest.php (100%) rename {tests => Tests}/model/MyDbDriver.php (100%) rename {tests => Tests}/model/MySQLiDriverTest.php (100%) rename {tests => Tests}/model/MySQLiStatementTest.php (100%) rename {tests => Tests}/model/SqlDbDriverTest.php (100%) rename {tests => Tests}/model/SqlModelTest.php (100%) rename {tests => Tests}/model/testData.xml (100%) rename {tests => Tests}/model/testDataAfterCommit.xml (100%) rename {tests => Tests}/model/testdb.sql (100%) rename {tests => Tests}/phpunit.xml (100%) rename {tests => Tests}/redis/RedisDebugTest.php (100%) rename {tests => Tests}/redis/RedisManagerTest.php (100%) rename {tests => Tests}/session/SessionModelTest.php (100%) rename {tests => Tests}/session/SessionTest.php (100%) rename {tests => Tests}/util/AutoloadBuilderTest.php (100%) rename {tests => Tests}/util/AutoloadBuilderTestVFS.php (100%) rename {tests => Tests}/util/profiler/CommandProfilerTest.php (100%) rename {tests => Tests}/util/profiler/ProfilerTest.php (100%) rename {tests => Tests}/validator/EmailValidatorTest.php (100%) rename {tests => Tests}/validator/EqualValidatorTest.php (100%) rename {tests => Tests}/validator/NotEmptyValidatorTest.php (100%) rename {tests => Tests}/validator/RegexValidatorTest.php (100%) rename {tests => Tests}/view/PHPViewTest.php (100%) rename {tests => Tests}/view/helpers/BreadcrumbVeiwHelperTest.php (100%) rename {tests => Tests}/view/helpers/GetViewHelperTest.php (100%) rename {tests => Tests}/view/helpers/HeadViewHelperTest.php (100%) rename {tests => Tests}/view/helpers/MsgViewHelperTest.php (100%) rename {tests => Tests}/view/helpers/TitleViewHelperTest.php (100%) rename {util => Util}/AsciiSortedIterator.php (100%) rename {util => Util}/AutoloadBuilder.php (91%) rename {util => Util}/FirePHPCore-0.3.2/CHANGELOG (100%) rename {util => Util}/FirePHPCore-0.3.2/CREDITS (100%) rename {util => Util}/FirePHPCore-0.3.2/README (100%) rename {util => Util}/FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php (100%) rename {util => Util}/FirePHPCore-0.3.2/lib/FirePHPCore/LICENSE (100%) rename {util => Util}/FirePHPCore-0.3.2/lib/FirePHPCore/fb.php (100%) rename {util/profiler => Util/Profiler}/CommandProfiler.php (95%) rename {util/profiler => Util/Profiler}/Profiler.php (97%) rename {validator => Validator}/EmailValidator.php (92%) rename {validator => Validator}/EqualValidator.php (95%) rename {validator => Validator}/MbStrlenValidator.php (95%) rename {validator => Validator}/NotEmptyValidator.php (94%) rename {validator => Validator}/RegexValidator.php (77%) rename {validator => Validator}/StrlenValidator.php (95%) rename {validator => Validator}/Validator.php (97%) rename {validator => Validator}/iValidator.php (87%) rename {view/helpers => View/Helpers}/BreadcrumbViewHelper.php (73%) rename {view/helpers => View/Helpers}/GetViewHelper.php (93%) rename {view/helpers => View/Helpers}/HeadViewHelper.php (60%) rename {view/helpers => View/Helpers}/MsgViewHelper.php (81%) rename {view/helpers => View/Helpers}/TitleViewHelper.php (67%) rename {view/helpers => View/Helpers}/ViewHelper.php (80%) rename {view => View}/PHPView.php (55%) rename {view => View}/iView.php (91%) diff --git a/app/Action.php b/App/Action.php similarity index 81% rename from app/Action.php rename to App/Action.php index 36fd258..e6ed81f 100644 --- a/app/Action.php +++ b/App/Action.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -13,7 +13,7 @@ abstract class Action protected $template; /** - * @var PHPView + * @var \Majestic\View\PHPView */ protected $view; @@ -26,7 +26,7 @@ abstract class Action protected function extractParams() { - foreach (Env::getParam() as $name => $value) { + foreach (\Majestic\Env::getParam() as $name => $value) { if (is_string($name)) { $this->$name = $value; } @@ -46,7 +46,7 @@ abstract class Action if ($permanently) { header('HTTP/1.1 301 Moved Permanently'); } - header('Location: ' . (($url) ? $url : Env::getRequestUri())); + header('Location: ' . (($url) ? $url : \Majestic\Env::getRequestUri())); exit(); } @@ -54,7 +54,7 @@ abstract class Action { $class = get_class($this); $template = ($this->template) ? $this->template : substr($class, 0, -6 /*strlen('Action')*/); - $dir = array_slice(explode('/', Load::getFilePath($class)), -2, 1); + $dir = array_slice(explode('/', \Majestic\Load::getFilePath($class)), -2, 1); return '/actions/' . array_pop($dir) . '/' . $template; } diff --git a/app/AjaxAction.php b/App/AjaxAction.php similarity index 97% rename from app/AjaxAction.php rename to App/AjaxAction.php index f007350..2585e93 100644 --- a/app/AjaxAction.php +++ b/App/AjaxAction.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/app/ErrorAction.php b/App/ErrorAction.php similarity index 74% rename from app/ErrorAction.php rename to App/ErrorAction.php index 057a272..43ca076 100644 --- a/app/ErrorAction.php +++ b/App/ErrorAction.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -11,7 +11,7 @@ class ErrorAction extends Action { /** - * @var ErrorException|ErrorHTTPException + * @var \ErrorException|\Majestic\Exception\ErrorHTTPException */ public $exception; @@ -25,9 +25,9 @@ class ErrorAction extends Action protected function execute() { - if ($this->exception instanceof Error404Exception) { + if ($this->exception instanceof \Majestic\Exception\Error404Exception) { $this->template = 404; - } elseif ($this->exception instanceof ErrorHTTPException) { + } elseif ($this->exception instanceof \Majestic\Exception\ErrorHTTPException) { $this->template = 'HTTP'; } else { $this->template = 500; @@ -51,7 +51,7 @@ class ErrorAction extends Action protected function sendHttpCode() { - if ($this->exception instanceof ErrorHTTPException) { + if ($this->exception instanceof \Majestic\Exception\ErrorHTTPException) { header($this->exception->getHTTPHeader()); } else { header('HTTP/1.0 500 Internal Server Error'); @@ -60,8 +60,8 @@ class ErrorAction extends Action protected function logError() { - if (!$this->exception instanceof Error404Exception) { - ErrorHandler::logError($this->exception); + if (!$this->exception instanceof \Majestic\Exception\Error404Exception) { + \Majestic\Exception\ErrorHandler::logError($this->exception); } } diff --git a/app/FrontController.php b/App/FrontController.php similarity index 69% rename from app/FrontController.php rename to App/FrontController.php index 1b03064..4d05bb6 100644 --- a/app/FrontController.php +++ b/App/FrontController.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -10,14 +10,14 @@ class FrontController { /** - * @var Router + * @var Router\Router */ protected $router; /** * @var string */ - protected $view = 'PHPView'; + protected $view = '\Majestic\View\PHPView'; protected $base_url = ''; @@ -30,7 +30,7 @@ class FrontController private function __construct() { // ErrorHandler::init(); - $this->router = new Router(); + $this->router = new Router\Router(); } /** @@ -69,12 +69,12 @@ class FrontController /** * * @param null $view - * @return PHPView + * @return ..\View\PHPView */ public function getView($view = null) { $view = ($view) ? $view : $this->view; - return new $view(Config::get($view)); + return new $view(\Majestic\Config::get($view)); } /** @@ -93,7 +93,7 @@ class FrontController } /** - * @return Router + * @return Router\Router */ public function getRouter() { @@ -103,53 +103,53 @@ class FrontController public function execute() { try { - $request = Env::getRequestUri(true); + $request = \Majestic\Env::getRequestUri(true); $route = $this->getRouter()->route($request); if (!$route) { - throw new Error404Exception('Route for "' . $request . '" not found'); + throw new \Majestic\Exception\Error404Exception('Route for "' . $request . '" not found'); } $action_class = $route->getAction(); if (!class_exists($action_class)) { - throw new GeneralException('Action class "' . $action_class . '" not found.'); + throw new \Majestic\Exception\GeneralException('Action class "' . $action_class . '" not found.'); } $action = new $action_class(); $layout_class = $route->getLayout(); if (!class_exists($layout_class)) { - throw new GeneralException('Layout class "' . $layout_class . '" not found.'); + throw new \Majestic\Exception\GeneralException('Layout class "' . $layout_class . '" not found.'); } /** - * @var Layout $layout + * @var \Majestic\Layout\Layout $layout */ $layout = new $layout_class(); $html = $layout->fetch($action); - if (Config::get('PROFILER')) { + if (\Majestic\Config::get('PROFILER')) { if (is_subclass_of($action, 'AjaxAction')) { - Profiler::getInstance()->getJson(); + \Majestic\Util\Profiler\Profiler::getInstance()->getJson(); } else { - $html = Profiler::getInstance()->end($html); + $html = \Majestic\Util\Profiler\Profiler::getInstance()->end($html); } } return $html; } - catch (Exception $e) { - if (Config::get('DEBUG')) { + catch (\Exception $e) { + if (\Majestic\Config::get('DEBUG')) { if (!headers_sent()) { - if ($e instanceof ErrorHTTPException) { + if ($e instanceof \Majestic\Exception\ErrorHTTPException) { header($e->getHTTPHeader()); } else { header('HTTP/1.0 500 Internal Server Error'); } } - ErrorHandler::logError($e); - return ErrorHandler::showDebug($e); + \Majestic\Exception\ErrorHandler::logError($e); + return \Majestic\Exception\ErrorHandler::showDebug($e); } $layout_class = $this->getRouter()->getErrorLayout(); /** - * @var ErrorLayout $layout + * @var \Majestic\Layout\ErrorLayout $layout */ $layout = new $layout_class(); $layout->setException($e); diff --git a/app/PagerAction.php b/App/PagerAction.php similarity index 97% rename from app/PagerAction.php rename to App/PagerAction.php index a277882..fe7f28c 100644 --- a/app/PagerAction.php +++ b/App/PagerAction.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/app/router/Route.php b/App/Router/Route.php similarity index 98% rename from app/router/Route.php rename to App/Router/Route.php index 5f8b456..d66e51d 100644 --- a/app/router/Route.php +++ b/App/Router/Route.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -7,8 +7,6 @@ * @since 2010-02-25 */ -namespace Majestic; - class Route { diff --git a/app/router/Router.php b/App/Router/Router.php similarity index 89% rename from app/router/Router.php rename to App/Router/Router.php index ec09a2a..ac6bbc6 100644 --- a/app/router/Router.php +++ b/App/Router/Router.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -33,7 +33,7 @@ class Router if (!$layout) { $layout = $this->default_layout; } - $this->routes[$name] = new \Majestic\Route($route, $action, $params, $layout); + $this->routes[$name] = new Route($route, $action, $params, $layout); } /** @@ -48,7 +48,7 @@ class Router if ($route->match($req)) { $this->route_name = $name; $this->route = $route; - Env::setParams($route->getParams()); + \Majestic\Env::setParams($route->getParams()); return $this->route; } } @@ -94,7 +94,7 @@ class Router /** * @param null|string $name * @return Route - * @throws ErrorException + * @throws \ErrorException */ public function getRoute($name = null) { @@ -104,7 +104,7 @@ class Router if ($this->routeIsExists($name)) { return $this->getRouteByName($name); } else { - throw new ErrorException('Unknown route name: "' . $name . '".'); + throw new \ErrorException('Unknown route name: "' . $name . '".'); } } } diff --git a/app/StaticAction.php b/App/StaticAction.php similarity index 94% rename from app/StaticAction.php rename to App/StaticAction.php index b1bfa96..1ef4296 100644 --- a/app/StaticAction.php +++ b/App/StaticAction.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/app/iCli.php b/App/iCli.php similarity index 89% rename from app/iCli.php rename to App/iCli.php index 82b9644..6a7aa7c 100644 --- a/app/iCli.php +++ b/App/iCli.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/cache/Cache.php b/Cache/Cache.php similarity index 100% rename from cache/Cache.php rename to Cache/Cache.php diff --git a/cache/CacheKey.php b/Cache/CacheKey.php similarity index 100% rename from cache/CacheKey.php rename to Cache/CacheKey.php diff --git a/cache/Cacher.php b/Cache/Cacher.php similarity index 100% rename from cache/Cacher.php rename to Cache/Cacher.php diff --git a/cache/MemcacheCache.php b/Cache/MemcacheCache.php similarity index 100% rename from cache/MemcacheCache.php rename to Cache/MemcacheCache.php diff --git a/captcha/Captcha.php b/Captcha/Captcha.php similarity index 100% rename from captcha/Captcha.php rename to Captcha/Captcha.php diff --git a/captcha/CaptchaImageAction.php b/Captcha/CaptchaImageAction.php similarity index 100% rename from captcha/CaptchaImageAction.php rename to Captcha/CaptchaImageAction.php diff --git a/captcha/CaptchaValidator.php b/Captcha/CaptchaValidator.php similarity index 100% rename from captcha/CaptchaValidator.php rename to Captcha/CaptchaValidator.php diff --git a/captcha/poh.ttf b/Captcha/poh.ttf similarity index 100% rename from captcha/poh.ttf rename to Captcha/poh.ttf diff --git a/Config.php b/Config.php index 223fc81..675546e 100644 --- a/Config.php +++ b/Config.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -7,9 +7,9 @@ * @since 2010-02-17 */ -namespace Majestic; -class Config extends \Registry + +class Config extends Registry { private static $_class_name = 'Config'; @@ -33,7 +33,7 @@ class ConfigArray extends \ArrayObject public function offsetGet($index) { if (!$this->offsetExists($index)) { - throw new \GeneralException('Configuration variable "' . $index . '" undefined'); + throw new Exception\GeneralException('Configuration variable "' . $index . '" undefined'); } return parent::offsetGet($index); } diff --git a/classes/Env.class.php b/Env.php similarity index 96% rename from classes/Env.class.php rename to Env.php index 2adb9f6..c3cd4d7 100644 --- a/classes/Env.class.php +++ b/Env.php @@ -1,4 +1,4 @@ -getBaseUrl(); + $base = \Majestic\App\FrontController::getInstance()->getBaseUrl(); if (($length = strlen($base)) > 0 && strpos(self::$request[$trim_base], $base) === 0) { self::$request[$trim_base] = (string) substr(self::$request[$trim_base], $length); } diff --git a/classes/Format.class.php b/Env/Format.class.php similarity index 100% rename from classes/Format.class.php rename to Env/Format.class.php diff --git a/classes/User.class.php b/Env/User.class.php similarity index 100% rename from classes/User.class.php rename to Env/User.class.php diff --git a/exception/Error404Exception.php b/Exception/Error404Exception.php similarity index 69% rename from exception/Error404Exception.php rename to Exception/Error404Exception.php index 454b500..3cded9d 100644 --- a/exception/Error404Exception.php +++ b/Exception/Error404Exception.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -8,7 +8,7 @@ */ class Error404Exception extends ErrorHTTPException { - function __construct($message = '', $code = null, Exception $previous = NULL ) + function __construct($message = '', $code = null, \Exception $previous = NULL ) { parent::__construct($message, 404, $previous); } diff --git a/exception/ErrorHTTPException.php b/Exception/ErrorHTTPException.php similarity index 97% rename from exception/ErrorHTTPException.php rename to Exception/ErrorHTTPException.php index c104092..185c1e2 100644 --- a/exception/ErrorHTTPException.php +++ b/Exception/ErrorHTTPException.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/exception/ErrorHandler.php b/Exception/ErrorHandler.php similarity index 88% rename from exception/ErrorHandler.php rename to Exception/ErrorHandler.php index 0773a4a..9c9f0dc 100644 --- a/exception/ErrorHandler.php +++ b/Exception/ErrorHandler.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -22,7 +22,7 @@ class ErrorHandler ob_end_clean(); } if (error_reporting() !== 0) { - throw new ErrorException($errstr, 0, $errno, $errfile, $errline); + throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); } return true; } @@ -31,7 +31,7 @@ class ErrorHandler { $error = 0; $exception_name = ''; - if ($exception instanceof ErrorException) { + if ($exception instanceof \ErrorException) { $error = $exception->getSeverity(); } else { $exception_name = get_class($exception) . ': '; @@ -59,9 +59,9 @@ class ErrorHandler static public function getHTTPErrorConditions() { $text = null; - if (!is_null(Env::Server('REQUEST_METHOD')) && !is_null(Env::Server('REQUEST_URI'))) { - $text = ', URL: ' . Env::Server('REQUEST_METHOD') . ' ' . Env::Server('REQUEST_URI'); - $text .= ', referrer: ' . Env::Server('HTTP_REFERER'); + if (!is_null(\Majestic\Env::Server('REQUEST_METHOD')) && !is_null(\Majestic\Env::Server('REQUEST_URI'))) { + $text = ', URL: ' . \Majestic\Env::Server('REQUEST_METHOD') . ' ' . \Majestic\Env::Server('REQUEST_URI'); + $text .= ', referrer: ' . \Majestic\Env::Server('HTTP_REFERER'); } return $text; } @@ -109,7 +109,7 @@ class ErrorHandler } /** - * @param Exception $exception + * @param \Exception $exception * @return string */ static public function showDebug($exception) @@ -120,19 +120,19 @@ class ErrorHandler } $class = get_class($exception); - $method = Env::Server('REQUEST_METHOD', ''); - $uri = Env::getRequestUri(); + $method = \Majestic\Env::Server('REQUEST_METHOD', ''); + $uri = \Majestic\Env::getRequestUri(); $source = self::getSource($exception->getFile(), $exception->getLine()); - $time = date('r', Env::Server('REQUEST_TIME', time())); + $time = date('r', \Majestic\Env::Server('REQUEST_TIME', time())); $trace = nl2br($exception->getTraceAsString()); - $get = self::wrapArray(Env::Get(), 'GET'); - $post = self::wrapArray(Env::Post(), 'POST'); - $session = self::wrapArray(Session::get(), 'SESSION'); - $files = self::wrapArray(Env::Files(), 'FILES'); - $cookies = self::wrapArray(Env::Cookie(), 'COOKIE'); - $server = self::wrapArray(Env::Server(), 'SERVER'); + $get = self::wrapArray(\Majestic\Env::Get(), 'GET'); + $post = self::wrapArray(\Majestic\Env::Post(), 'POST'); + $session = self::wrapArray(\Majestic\Session\Session::get(), 'SESSION'); + $files = self::wrapArray(\Majestic\Env::Files(), 'FILES'); + $cookies = self::wrapArray(\Majestic\Env::Cookie(), 'COOKIE'); + $server = self::wrapArray(\Majestic\Env::Server(), 'SERVER'); $message = << diff --git a/exception/GeneralException.php b/Exception/GeneralException.php similarity index 65% rename from exception/GeneralException.php rename to Exception/GeneralException.php index 07faa1b..d399bd4 100644 --- a/exception/GeneralException.php +++ b/Exception/GeneralException.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -7,4 +7,4 @@ * @since 2010-02-26 */ -class GeneralException extends Exception {} \ No newline at end of file +class GeneralException extends \Exception {} \ No newline at end of file diff --git a/exception/InitializationException.php b/Exception/InitializationException.php similarity index 69% rename from exception/InitializationException.php rename to Exception/InitializationException.php index 65d6935..a6e696c 100644 --- a/exception/InitializationException.php +++ b/Exception/InitializationException.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -9,4 +9,4 @@ * Exception from initializtion object */ -class InitializationException extends Exception {} \ No newline at end of file +class InitializationException extends \Exception {} \ No newline at end of file diff --git a/form/Form.php b/Form/Form.php similarity index 92% rename from form/Form.php rename to Form/Form.php index 093ac5c..2961fee 100644 --- a/form/Form.php +++ b/Form/Form.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -7,8 +7,6 @@ * @since 2010-04-24 */ -namespace Majestic; - abstract class Form { @@ -17,7 +15,7 @@ abstract class Form const ERROR = 'error'; /** - * @var \FormField[] + * @var FormField[] */ protected $fields = array(); @@ -38,18 +36,18 @@ abstract class Form /** * @param string $name * @param bool|string $message - * @return \FormField + * @return FormField */ protected function addField($name, $message = false) { - $this->fields[$name] = new \FormField($message); + $this->fields[$name] = new FormField($message); return $this->fields[$name]; } public function isValid($data) { if (!is_array($data)) { - throw new \InitializationException(__CLASS__ . '::' . __METHOD__ . ' expects an array'); + throw new \Majestic\Exception\InitializationException(__CLASS__ . '::' . __METHOD__ . ' expects an array'); } foreach ($this->fields as $field_name => $field) { diff --git a/form/FormField.php b/Form/FormField.php similarity index 86% rename from form/FormField.php rename to Form/FormField.php index 99683b6..680c232 100644 --- a/form/FormField.php +++ b/Form/FormField.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -93,7 +93,7 @@ class FormField } /** - * @param string[]|iValidator[] $validators + * @param string[]|\Majestic\Validator\iValidator[] $validators * @return FormField */ public function addValidators($validators) @@ -105,19 +105,19 @@ class FormField } /** - * @param string|iValidator $validator + * @param string|\Majestic\Validator\iValidator $validator * @return FormField - * @throws InitializationException + * @throws \Majestic\Exception\InitializationException */ public function addValidator($validator) { - if ($validator instanceof iValidator) { + if ($validator instanceof \Majestic\Validator\iValidator) { $name = get_class($validator); } elseif (is_string($validator)) { $name = $validator . 'Validator'; $validator = new $name(); } else { - throw new InitializationException('Invalid validator provided to addValidator; must be string or iValidator'); + throw new \Majestic\Exception\InitializationException('Invalid validator provided to addValidator; must be string or iValidator'); } $this->validators[$name] = $validator; return $this; @@ -139,7 +139,7 @@ class FormField $name = $filter . 'Filter'; $filter = new $name(); } else { - throw new InitializationException('Invalid filter provided to addFilter; must be string or iFilter'); + throw new \Majestic\Exception\InitializationException('Invalid filter provided to addFilter; must be string or iFilter'); } $this->filters[$name] = $filter; return $this; @@ -192,7 +192,7 @@ class FormField if (!$validator->isValid($val, $context)) { $valid = false; if (!$this->default_message) { - throw new InitializationException('Define default message for array fields'); + throw new \Majestic\Validator\InitializationException('Define default message for array fields'); } $this->message = $this->default_message; } diff --git a/form/FormViewHelper.php b/Form/FormViewHelper.php similarity index 77% rename from form/FormViewHelper.php rename to Form/FormViewHelper.php index f55b515..c4d64cb 100644 --- a/form/FormViewHelper.php +++ b/Form/FormViewHelper.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -16,10 +16,10 @@ class FormViewHelper extends ViewHelper { if ($this->data === null) { if ($form == null) { - throw new InitializationException('Form name required for helper init'); + throw new \Majestic\ExceptionInitializationException('Form name required for helper init'); } - $this->data = Session::get($form, array()); - Session::del($form); + $this->data = \Majestic\Session\Session::get($form, array()); + \Majestic\Session\Session::del($form); } return $this; } diff --git a/layout/Error.layout.php b/Layout/ErrorLayout.php similarity index 66% rename from layout/Error.layout.php rename to Layout/ErrorLayout.php index f773cfb..6893865 100644 --- a/layout/Error.layout.php +++ b/Layout/ErrorLayout.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -10,7 +10,7 @@ class ErrorLayout extends Layout { /** - * @var GeneralException + * @var \Majestic\ExceptionGeneralException */ protected $exception; @@ -19,9 +19,9 @@ class ErrorLayout extends Layout } /** - * @param Exception $exception + * @param \Exception $exception */ - public function setException(Exception $exception) + public function setException(\Exception $exception) { $this->exception = $exception; } diff --git a/layout/Layout.php b/Layout/Layout.php similarity index 81% rename from layout/Layout.php rename to Layout/Layout.php index a85dd10..47bf199 100644 --- a/layout/Layout.php +++ b/Layout/Layout.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -13,18 +13,18 @@ abstract class Layout protected $template; /** - * @var PHPView + * @var \Majestic\View\PHPView */ protected $view; public function __construct() { - $this->view = FrontController::getInstance()->getView(); + $this->view = \Majestic\App\FrontController::getInstance()->getView(); } /** * @param string $name - * @param Action $action + * @param \Majestic\App\Action $action */ protected function assign($name, $action) { @@ -34,7 +34,7 @@ abstract class Layout /** * @param string $name - * @param Action $action + * @param \Majestic\App\Action $action */ protected function append($name, $action) { @@ -44,7 +44,7 @@ abstract class Layout /** * @param string $name - * @param Action $action + * @param \Majestic\App\Action $action */ protected function prepend($name, $action) { @@ -55,7 +55,7 @@ abstract class Layout /** * Execute Action, insert action's result html into layout template and return Layout html - * @param Action $action + * @param \Majestic\App\Action $action * @return string */ public function fetch($action) diff --git a/Load.php b/Load.php index 4039810..1743315 100644 --- a/Load.php +++ b/Load.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -18,6 +18,15 @@ class Load static protected $builder = null; + /** + * @var \Composer\Autoload\ClassLoader + */ + static protected $class_loader; + + static public function setClassLoader($class_loader) { + self::$class_loader = $class_loader; + } + /** * Add exclude path for autoload. Should be called before setAutoloadFrom * @static @@ -62,7 +71,11 @@ class Load static public function getFilePath($class) { - return self::$autoload[$class]; + if (self::$class_loader) { + return self::$class_loader->findFile($class); + } else { + return self::$autoload[$class]; + } } static protected function buildAutoload() diff --git a/logger/CliLogger.php b/Logger/CliLogger.php similarity index 95% rename from logger/CliLogger.php rename to Logger/CliLogger.php index ddbc5cc..0151605 100644 --- a/logger/CliLogger.php +++ b/Logger/CliLogger.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/logger/FileLogger.php b/Logger/FileLogger.php similarity index 82% rename from logger/FileLogger.php rename to Logger/FileLogger.php index f92a965..7770e65 100644 --- a/logger/FileLogger.php +++ b/Logger/FileLogger.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -20,7 +20,7 @@ class FileLogger extends Logger protected function __construct() { - $this->file_path = Config::get('Logger')->filepath; + $this->file_path = \Majestic\Config::get('Logger')->filepath; } protected function generateOutString($message) @@ -35,7 +35,7 @@ class FileLogger extends Logger if (!$this->handler) { $this->handler = @fopen($this->file_path, "a"); if (!$this->handler) { - throw new GeneralException('Could not open file ' . $this->file_path); + throw new \Majestic\Exception\GeneralException('Could not open file ' . $this->file_path); } } fwrite($this->handler, $out); diff --git a/logger/Logger.php b/Logger/Logger.php similarity index 89% rename from logger/Logger.php rename to Logger/Logger.php index 53be1de..66588b9 100644 --- a/logger/Logger.php +++ b/Logger/Logger.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -31,7 +31,7 @@ abstract class Logger { if (static::$_instance === null) { //$class = get_called_class(); - $class = Config::get('Logger')->logger; + $class = \Majestic\Config::get('Logger')->logger; static::$_instance = new $class(); } return static::$_instance; @@ -43,7 +43,7 @@ abstract class Logger */ public function log($message) { - if (Config::get('LOGGING')) { + if (\Majestic\Config::get('LOGGING')) { $this->concreteLog($message); } } diff --git a/mail/Mailer.php b/Mail/Mailer.php similarity index 100% rename from mail/Mailer.php rename to Mail/Mailer.php diff --git a/model/Db.php b/Model/Db.php similarity index 71% rename from model/Db.php rename to Model/Db.php index 66f11cc..d60a6e3 100644 --- a/model/Db.php +++ b/Model/Db.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -7,8 +7,6 @@ * @since 2010-02-16 */ -namespace Majestic; - class Db { @@ -31,23 +29,23 @@ class Db * @param array $config Configuration array. * * @return DbDriver - * @throws InitializationException + * @throws \Majestic\Exception\InitializationException */ static public function connect($name = 'default', $config = null) { if (!isset(self::$connections[$name])) { if (!$config) { if (!is_object(\Majestic\Config::get(__CLASS__))) { - throw new \InitializationException('Trying to get property of non-object'); + throw new \Majestic\Exception\InitializationException('Trying to get property of non-object'); } $config = \Majestic\Config::get(__CLASS__)->$name; } if (!is_array($config)) { - throw new \InitializationException('Connection parameters must be an array'); + throw new \Majestic\Exception\InitializationException('Connection parameters must be an array'); } - $driver = 'MySQLiDriver'; + $driver = '\Majestic\Model\MySQLiDriver'; if (isset($config['driver'])) { $driver = $config['driver']; unset($config['driver']); @@ -55,8 +53,8 @@ class Db $connection = new $driver($config); - if (!$connection instanceof \DbDriver) { - throw new \InitializationException('Database driver must extends DbDriver'); + if (!$connection instanceof DbDriver) { + throw new \Majestic\Exception\InitializationException('Database driver must extends DbDriver'); } self::$connections[$name] = $connection; } diff --git a/model/DbDriver.php b/Model/DbDriver.php similarity index 93% rename from model/DbDriver.php rename to Model/DbDriver.php index 8042b0f..c3face2 100644 --- a/model/DbDriver.php +++ b/Model/DbDriver.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -36,7 +36,7 @@ abstract class DbDriver $required = array('database', 'username', 'password', 'hostname'); foreach ($required as $option) { if (!isset($config[$option])) { - throw new GeneralException('Configuration must have a "' . $option . '".'); + throw new \GeneralException('Configuration must have a "' . $option . '".'); } } } diff --git a/model/DbExpr.php b/Model/DbExpr.php similarity index 93% rename from model/DbExpr.php rename to Model/DbExpr.php index 1d5e84f..c3c94ee 100644 --- a/model/DbExpr.php +++ b/Model/DbExpr.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/model/DbStatement.php b/Model/DbStatement.php similarity index 89% rename from model/DbStatement.php rename to Model/DbStatement.php index 40a2ad7..5d0a82b 100644 --- a/model/DbStatement.php +++ b/Model/DbStatement.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -53,7 +53,7 @@ abstract class DbStatement * @param mixed $style * @return array */ - public function fetchAll($style = \Majestic\Db::FETCH_OBJ) + public function fetchAll($style = Db::FETCH_OBJ) { $data = array(); while ($row = $this->fetch($style)) { @@ -69,7 +69,7 @@ abstract class DbStatement public function fetchColumn($field) { $data = array(); - while ($row = $this->fetch(\Majestic\Db::FETCH_ASSOC)) { + while ($row = $this->fetch(Db::FETCH_ASSOC)) { $data[] = $row[$field]; } return $data; @@ -81,7 +81,7 @@ abstract class DbStatement */ public function fetchField($field) { - $row = $this->fetch(\Majestic\Db::FETCH_ASSOC); + $row = $this->fetch(Db::FETCH_ASSOC); if (isset($row[$field])) { return $row[$field]; } @@ -94,7 +94,7 @@ abstract class DbStatement abstract protected function assemble(); - abstract public function fetch($style = \Majestic\Db::FETCH_OBJ); + abstract public function fetch($style = Db::FETCH_OBJ); abstract public function fetchObject($class = 'stdClass'); diff --git a/model/Model.php b/Model/Model.php similarity index 94% rename from model/Model.php rename to Model/Model.php index 30fba75..d27c852 100644 --- a/model/Model.php +++ b/Model/Model.php @@ -1,4 +1,4 @@ -db = \Majestic\Db::connect($connection); + $this->db = Db::connect($connection); } /** @@ -101,7 +99,7 @@ abstract class Model public function getCache() { if (!$this->cache) { - $this->cache = \Cacher::get(Config::get(__CLASS__, 'MemcacheCache')); + $this->cache = \Cacher::get(\Majestic\Config::get(__CLASS__, 'MemcacheCache')); } return $this->cache; } diff --git a/model/MongoDbCommand.php b/Model/MongoDbCommand.php similarity index 98% rename from model/MongoDbCommand.php rename to Model/MongoDbCommand.php index 18bc7ee..b67c247 100644 --- a/model/MongoDbCommand.php +++ b/Model/MongoDbCommand.php @@ -49,14 +49,14 @@ abstract class MongoDbCommand * Execute Mongo command/query * * @return mixed - * @throws GeneralException + * @throws \Majestic\Exception\GeneralException */ public function execute() { if ($this->checkParams()) { return $this->concreteExecute(); } else { - throw new GeneralException(get_called_class() . ' error. Bind all required params first.'); + throw new \Majestic\Exception\GeneralException(get_called_class() . ' error. Bind all required params first.'); } } diff --git a/model/MongoDriver.php b/Model/MongoDriver.php similarity index 100% rename from model/MongoDriver.php rename to Model/MongoDriver.php diff --git a/model/MongoModel.php b/Model/MongoModel.php similarity index 95% rename from model/MongoModel.php rename to Model/MongoModel.php index 9a5c672..07a4d21 100644 --- a/model/MongoModel.php +++ b/Model/MongoModel.php @@ -159,7 +159,7 @@ abstract class MongoModel extends Model /** * @param array $params Parameters for find query * @return array Query result sort rules - * @throws GeneralException + * @throws \Majestic\Exception\GeneralException * */ private function getOrder($params = array()) { @@ -170,7 +170,7 @@ abstract class MongoModel extends Model } elseif (is_array($params['order'])) { $order = $params['order']; } else { - throw new GeneralException('Wrong order parameter given to query.'); + throw new \Majestic\Exception\GeneralException('Wrong order parameter given to query.'); } } return $order; @@ -179,7 +179,7 @@ abstract class MongoModel extends Model /** * @param array $params Parameters for find query * @return array Query result sort rules - * @throws GeneralException + * @throws \Majestic\Exception\GeneralException * */ private function getFields($params) { @@ -196,7 +196,7 @@ abstract class MongoModel extends Model $fields = $params['fields']; } } else { - throw new GeneralException('Wrong fields parameter given to query.'); + throw new \Majestic\Exception\GeneralException('Wrong fields parameter given to query.'); } } return $fields; diff --git a/model/MongoStatement.php b/Model/MongoStatement.php similarity index 100% rename from model/MongoStatement.php rename to Model/MongoStatement.php diff --git a/model/MySQLiDriver.php b/Model/MySQLiDriver.php similarity index 96% rename from model/MySQLiDriver.php rename to Model/MySQLiDriver.php index dc44478..629fa99 100644 --- a/model/MySQLiDriver.php +++ b/Model/MySQLiDriver.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -8,7 +8,7 @@ */ /** - * @property MySQLi $connection + * @property \MySQLi $connection */ class MySQLiDriver extends SqlDbDriver { @@ -51,7 +51,7 @@ class MySQLiDriver extends SqlDbDriver public function isConnected() { - return ($this->connection instanceof MySQLi); + return ($this->connection instanceof \MySQLi); } public function disconnect() diff --git a/model/MySQLiStatement.php b/Model/MySQLiStatement.php similarity index 80% rename from model/MySQLiStatement.php rename to Model/MySQLiStatement.php index 9da6219..87cdaf6 100644 --- a/model/MySQLiStatement.php +++ b/Model/MySQLiStatement.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -9,7 +9,7 @@ /** * @property MySQLiDriver $driver - * @property MySQLi_Result $result + * @property \MySQLi_Result $result */ class MySQLiStatement extends DbStatement { @@ -23,10 +23,10 @@ class MySQLiStatement extends DbStatement } if (count($this->map) > 0) { if (!is_string($param) && !is_int($param)) { - throw new GeneralException('Placeholder must be an integer or string'); + throw new \Majestic\Exception\GeneralException('Placeholder must be an integer or string'); } if (is_object($value) && ! ($value instanceof DbExpr)) { - throw new GeneralException('Objects excepts DbExpr not allowed.'); + throw new \Majestic\Exception\GeneralException('Objects excepts DbExpr not allowed.'); } if (isset($this->map[$param])) { $this->params[$param] = &$value; @@ -81,29 +81,29 @@ class MySQLiStatement extends DbStatement * * @param mixed $style * @return mixed - * @throws GeneralException + * @throws \Majestic\Exception\GeneralException */ - public function fetch($style = \Majestic\Db::FETCH_OBJ) + public function fetch($style = Db::FETCH_OBJ) { if (!$this->result) { return false; } switch ($style) { - case \Majestic\Db::FETCH_OBJ: + case Db::FETCH_OBJ: $row = $this->result->fetch_object(); break; - case \Majestic\Db::FETCH_NUM: + case Db::FETCH_NUM: $row = $this->result->fetch_array(MYSQLI_NUM); break; - case \Majestic\Db::FETCH_ASSOC: + case Db::FETCH_ASSOC: $row = $this->result->fetch_assoc(); break; - case \Majestic\Db::FETCH_BOTH: + case Db::FETCH_BOTH: $row = $this->result->fetch_array(MYSQLI_BOTH); break; default: - throw new GeneralException('Invalid fetch mode "' . $style . '" specified'); + throw new \Majestic\Exception\GeneralException('Invalid fetch mode "' . $style . '" specified'); } return $row; } @@ -123,7 +123,7 @@ class MySQLiStatement extends DbStatement public function fetchPairs() { $data = array(); - while ($row = $this->fetch(\Majestic\Db::FETCH_NUM)) { + while ($row = $this->fetch(Db::FETCH_NUM)) { $data[$row[0]] = $row[1]; } return $data; @@ -158,11 +158,11 @@ class MySQLiStatement extends DbStatement protected function driverExecute($request) { /** - * @var MySQLi + * @var \MySQLi */ $mysqli = $this->driver->getConnection(); - if (Config::get('PROFILER_DETAILS')) { - $profiler = Profiler::getInstance()->profilerCommand('MySQL', $request); + if (\Majestic\Config::get('PROFILER_DETAILS')) { + $profiler = \Majestic\Util\Profiler\Profiler::getInstance()->profilerCommand('MySQL', $request); $result = $mysqli->query($request); $profiler->end(); } else { @@ -170,9 +170,9 @@ class MySQLiStatement extends DbStatement } if ($result === false) { $message = $mysqli->error . "\nQuery: \"" . $request . '"'; - throw new GeneralException($message, $mysqli->errno); + throw new \Majestic\Exception\GeneralException($message, $mysqli->errno); } - if ($result instanceof MySQLi_Result) { + if ($result instanceof \MySQLi_Result) { $this->result = $result; } return true; diff --git a/model/NoSqlDbDriver.php b/Model/NoSqlDbDriver.php similarity index 89% rename from model/NoSqlDbDriver.php rename to Model/NoSqlDbDriver.php index 19a7020..02e3cd7 100644 --- a/model/NoSqlDbDriver.php +++ b/Model/NoSqlDbDriver.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/model/SqlCriteria.php b/Model/SqlCriteria.php similarity index 99% rename from model/SqlCriteria.php rename to Model/SqlCriteria.php index 72c8b23..00a9206 100644 --- a/model/SqlCriteria.php +++ b/Model/SqlCriteria.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -129,7 +129,7 @@ abstract class SqlDbDriver extends DbDriver /** * @param mixed $where * @return string - * @throws ErrorException + * @throws \ErrorException */ public function whereExpr($where) { @@ -143,7 +143,7 @@ abstract class SqlDbDriver extends DbDriver foreach ($where as $cond => &$term) { if (is_int($cond)) { if (is_int($term)) { - throw new ErrorException('Condition in where expression as integer. ' . $term); + throw new \ErrorException('Condition in where expression as integer. ' . $term); } if ($term instanceof DbExpr) { $term = (string) $term; @@ -164,7 +164,7 @@ abstract class SqlDbDriver extends DbDriver /** * @param mixed $group_by * @return string - * @throws ErrorException + * @throws \ErrorException */ public function groupByExpr($group_by) { diff --git a/model/SqlModel.php b/Model/SqlModel.php similarity index 99% rename from model/SqlModel.php rename to Model/SqlModel.php index 4a0dfef..3e9c919 100644 --- a/model/SqlModel.php +++ b/Model/SqlModel.php @@ -1,4 +1,4 @@ -result_items_base as $item) { if (!isset($item->{$field})) { - throw new ErrorException('Undefined field. ' . $field); + throw new \ErrorException('Undefined field. ' . $field); } if ($assoc_as_array) { if (!isset($result_items_assoc[$item->{$field}])) { @@ -55,7 +55,7 @@ class SqlResultProvider implements iSqlResultItems $result_items_assoc[$item->{$field}][] = $item; } else { if (isset($result_items_assoc[$item->{$field}])) { - throw new ErrorException('Field not unique. May be use assoc_as_array. ' . $field); + throw new \ErrorException('Field not unique. May be use assoc_as_array. ' . $field); } $result_items_assoc[$item->{$field}] = $item; } diff --git a/model/iSqlResultItems.php b/Model/iSqlResultItems.php similarity index 80% rename from model/iSqlResultItems.php rename to Model/iSqlResultItems.php index 4e0ef72..fec922f 100644 --- a/model/iSqlResultItems.php +++ b/Model/iSqlResultItems.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/redis/RedisManager.php b/Redis/RedisManager.php similarity index 70% rename from redis/RedisManager.php rename to Redis/RedisManager.php index 29b17d4..0c71f52 100644 --- a/redis/RedisManager.php +++ b/Redis/RedisManager.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -23,7 +23,7 @@ class RedisManager * @param string $name connection name. If not set 'default' will be used. * @param array $config Configuration array. * - * @throws GeneralException + * @throws \Majestic\Exception\GeneralException * @return Redis */ static public function connect($name = 'default', $config = null) @@ -31,13 +31,13 @@ class RedisManager if (!isset(self::$connections[$name])) { if (!$config) { if (!is_object(\Majestic\Config::get('Redis'))) { - throw new GeneralException('Redis config no existence'); + throw new \Majestic\Exception\GeneralException('Redis config no existence'); } $config = \Majestic\Config::get('Redis')->$name; } if (!is_array($config)) { - throw new GeneralException('Connection parameters must be an array'); + throw new \Majestic\Exception\GeneralException('Connection parameters must be an array'); } $host = isset($config['host']) ? $config['host'] : 'localhost'; @@ -47,16 +47,16 @@ class RedisManager /** * @var Redis */ - $connection = new Redis(); - if (Config::get('PROFILER_DETAILS')) { + $connection = new \Redis(); + if (\Majestic\Config::get('PROFILER_DETAILS')) { $connection = new RedisDebug($connection); } if (!$connection->connect($host, $port)) { - throw new GeneralException('Failed to connect to Redis server at ' . $host . ':' . $port); + throw new \Majestic\Exception\GeneralException('Failed to connect to Redis server at ' . $host . ':' . $port); } if ($database) { if (!$connection->select($database)) { - throw new GeneralException('Failed to select Redis database with index ' . $database); + throw new \Majestic\Exception\GeneralException('Failed to select Redis database with index ' . $database); } } self::$connections[$name] = $connection; diff --git a/redis/redis.php b/Redis/redis.php similarity index 99% rename from redis/redis.php rename to Redis/redis.php index 3514a5f..d011ef2 100644 --- a/redis/redis.php +++ b/Redis/redis.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -7,7 +7,7 @@ * @since 2010-02-17 */ -class Registry extends ArrayObject +class Registry extends \ArrayObject { /** * Class name of the singleton registry object. @@ -53,7 +53,7 @@ class Registry extends ArrayObject public static function getInstance() { if (self::$_registry === null) { - self::$_registry = new self::$_class_name(); + self::$_registry = new \Majestic\Registry(); } return self::$_registry; } diff --git a/session/Session.model.php b/Session/Session.model.php similarity index 98% rename from session/Session.model.php rename to Session/Session.model.php index 72e1f73..d9b52d6 100644 --- a/session/Session.model.php +++ b/Session/Session.model.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/session/Session.php b/Session/Session.php similarity index 99% rename from session/Session.php rename to Session/Session.php index c6bb514..b09c37e 100644 --- a/session/Session.php +++ b/Session/Session.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -7,8 +7,6 @@ * @since 2010-03-14 */ -namespace Majestic; - class Session { /** diff --git a/session/session.sql b/Session/session.sql similarity index 100% rename from session/session.sql rename to Session/session.sql diff --git a/tests/ConfigTest.php b/Tests/ConfigTest.php similarity index 100% rename from tests/ConfigTest.php rename to Tests/ConfigTest.php diff --git a/tests/LoadTest.php b/Tests/LoadTest.php similarity index 100% rename from tests/LoadTest.php rename to Tests/LoadTest.php diff --git a/tests/MySQLTestsSuite.php b/Tests/MySQLTestsSuite.php similarity index 100% rename from tests/MySQLTestsSuite.php rename to Tests/MySQLTestsSuite.php diff --git a/tests/RedisTestsSuite.php b/Tests/RedisTestsSuite.php similarity index 100% rename from tests/RedisTestsSuite.php rename to Tests/RedisTestsSuite.php diff --git a/tests/RegistryTest.php b/Tests/RegistryTest.php similarity index 100% rename from tests/RegistryTest.php rename to Tests/RegistryTest.php diff --git a/tests/app/ActionTest.php b/Tests/app/ActionTest.php similarity index 100% rename from tests/app/ActionTest.php rename to Tests/app/ActionTest.php diff --git a/tests/app/Action_TestCase.php b/Tests/app/Action_TestCase.php similarity index 100% rename from tests/app/Action_TestCase.php rename to Tests/app/Action_TestCase.php diff --git a/tests/app/AjaxActionTest.php b/Tests/app/AjaxActionTest.php similarity index 100% rename from tests/app/AjaxActionTest.php rename to Tests/app/AjaxActionTest.php diff --git a/tests/app/CliControllerTest.php b/Tests/app/CliControllerTest.php similarity index 100% rename from tests/app/CliControllerTest.php rename to Tests/app/CliControllerTest.php diff --git a/tests/app/ErrorActionTest.php b/Tests/app/ErrorActionTest.php similarity index 100% rename from tests/app/ErrorActionTest.php rename to Tests/app/ErrorActionTest.php diff --git a/tests/app/FrontControllerTest.php b/Tests/app/FrontControllerTest.php similarity index 100% rename from tests/app/FrontControllerTest.php rename to Tests/app/FrontControllerTest.php diff --git a/tests/app/PagerActionTest.php b/Tests/app/PagerActionTest.php similarity index 100% rename from tests/app/PagerActionTest.php rename to Tests/app/PagerActionTest.php diff --git a/tests/app/StaticActionTest.php b/Tests/app/StaticActionTest.php similarity index 100% rename from tests/app/StaticActionTest.php rename to Tests/app/StaticActionTest.php diff --git a/tests/app/router/RouteTest.php b/Tests/app/router/RouteTest.php similarity index 100% rename from tests/app/router/RouteTest.php rename to Tests/app/router/RouteTest.php diff --git a/tests/app/router/RouterTest.php b/Tests/app/router/RouterTest.php similarity index 100% rename from tests/app/router/RouterTest.php rename to Tests/app/router/RouterTest.php diff --git a/tests/bootstrap.php b/Tests/bootstrap.php similarity index 100% rename from tests/bootstrap.php rename to Tests/bootstrap.php diff --git a/tests/cache/CacheKeyTest.php b/Tests/cache/CacheKeyTest.php similarity index 100% rename from tests/cache/CacheKeyTest.php rename to Tests/cache/CacheKeyTest.php diff --git a/tests/cache/CacherTest.php b/Tests/cache/CacherTest.php similarity index 100% rename from tests/cache/CacherTest.php rename to Tests/cache/CacherTest.php diff --git a/tests/cache/MemcacheCacheTest.php b/Tests/cache/MemcacheCacheTest.php similarity index 100% rename from tests/cache/MemcacheCacheTest.php rename to Tests/cache/MemcacheCacheTest.php diff --git a/tests/captcha/CaptchaTest.php b/Tests/captcha/CaptchaTest.php similarity index 100% rename from tests/captcha/CaptchaTest.php rename to Tests/captcha/CaptchaTest.php diff --git a/tests/captcha/CaptchaValidatorTest.php b/Tests/captcha/CaptchaValidatorTest.php similarity index 100% rename from tests/captcha/CaptchaValidatorTest.php rename to Tests/captcha/CaptchaValidatorTest.php diff --git a/tests/classes/EnvTest.php b/Tests/classes/EnvTest.php similarity index 100% rename from tests/classes/EnvTest.php rename to Tests/classes/EnvTest.php diff --git a/tests/classes/FormatTest.php b/Tests/classes/FormatTest.php similarity index 100% rename from tests/classes/FormatTest.php rename to Tests/classes/FormatTest.php diff --git a/tests/exception/Error404ExceptionTest.php b/Tests/exception/Error404ExceptionTest.php similarity index 100% rename from tests/exception/Error404ExceptionTest.php rename to Tests/exception/Error404ExceptionTest.php diff --git a/tests/exception/ErrorHTTPExceptionTest.php b/Tests/exception/ErrorHTTPExceptionTest.php similarity index 100% rename from tests/exception/ErrorHTTPExceptionTest.php rename to Tests/exception/ErrorHTTPExceptionTest.php diff --git a/tests/exception/ErrorHandlerTest.php b/Tests/exception/ErrorHandlerTest.php similarity index 100% rename from tests/exception/ErrorHandlerTest.php rename to Tests/exception/ErrorHandlerTest.php diff --git a/tests/exception/GeneralExceptionTest.php b/Tests/exception/GeneralExceptionTest.php similarity index 100% rename from tests/exception/GeneralExceptionTest.php rename to Tests/exception/GeneralExceptionTest.php diff --git a/tests/exception/InitializationExceptionTest.php b/Tests/exception/InitializationExceptionTest.php similarity index 100% rename from tests/exception/InitializationExceptionTest.php rename to Tests/exception/InitializationExceptionTest.php diff --git a/tests/form/FormFieldTest.php b/Tests/form/FormFieldTest.php similarity index 100% rename from tests/form/FormFieldTest.php rename to Tests/form/FormFieldTest.php diff --git a/tests/form/FormTest.php b/Tests/form/FormTest.php similarity index 100% rename from tests/form/FormTest.php rename to Tests/form/FormTest.php diff --git a/tests/form/FormViewHelperTest.php b/Tests/form/FormViewHelperTest.php similarity index 100% rename from tests/form/FormViewHelperTest.php rename to Tests/form/FormViewHelperTest.php diff --git a/tests/i18n/I18NTest.php b/Tests/i18n/I18NTest.php similarity index 100% rename from tests/i18n/I18NTest.php rename to Tests/i18n/I18NTest.php diff --git a/tests/layout/ErrorLayoutTest.php b/Tests/layout/ErrorLayoutTest.php similarity index 100% rename from tests/layout/ErrorLayoutTest.php rename to Tests/layout/ErrorLayoutTest.php diff --git a/tests/layout/LayoutTest.php b/Tests/layout/LayoutTest.php similarity index 100% rename from tests/layout/LayoutTest.php rename to Tests/layout/LayoutTest.php diff --git a/tests/logger/CliLoggerTest.php b/Tests/logger/CliLoggerTest.php similarity index 100% rename from tests/logger/CliLoggerTest.php rename to Tests/logger/CliLoggerTest.php diff --git a/tests/logger/FileLoggerTest.php b/Tests/logger/FileLoggerTest.php similarity index 100% rename from tests/logger/FileLoggerTest.php rename to Tests/logger/FileLoggerTest.php diff --git a/tests/model/DbExprTest.php b/Tests/model/DbExprTest.php similarity index 100% rename from tests/model/DbExprTest.php rename to Tests/model/DbExprTest.php diff --git a/tests/model/DbStatementTest.php b/Tests/model/DbStatementTest.php similarity index 100% rename from tests/model/DbStatementTest.php rename to Tests/model/DbStatementTest.php diff --git a/tests/model/DbTest.php b/Tests/model/DbTest.php similarity index 100% rename from tests/model/DbTest.php rename to Tests/model/DbTest.php diff --git a/tests/model/MongoDbCommandTest.php b/Tests/model/MongoDbCommandTest.php similarity index 100% rename from tests/model/MongoDbCommandTest.php rename to Tests/model/MongoDbCommandTest.php diff --git a/tests/model/MongoDriverTest.php b/Tests/model/MongoDriverTest.php similarity index 100% rename from tests/model/MongoDriverTest.php rename to Tests/model/MongoDriverTest.php diff --git a/tests/model/MongoModelTest.php b/Tests/model/MongoModelTest.php similarity index 100% rename from tests/model/MongoModelTest.php rename to Tests/model/MongoModelTest.php diff --git a/tests/model/MongoStatementTest.php b/Tests/model/MongoStatementTest.php similarity index 100% rename from tests/model/MongoStatementTest.php rename to Tests/model/MongoStatementTest.php diff --git a/tests/model/MyDbDriver.php b/Tests/model/MyDbDriver.php similarity index 100% rename from tests/model/MyDbDriver.php rename to Tests/model/MyDbDriver.php diff --git a/tests/model/MySQLiDriverTest.php b/Tests/model/MySQLiDriverTest.php similarity index 100% rename from tests/model/MySQLiDriverTest.php rename to Tests/model/MySQLiDriverTest.php diff --git a/tests/model/MySQLiStatementTest.php b/Tests/model/MySQLiStatementTest.php similarity index 100% rename from tests/model/MySQLiStatementTest.php rename to Tests/model/MySQLiStatementTest.php diff --git a/tests/model/SqlDbDriverTest.php b/Tests/model/SqlDbDriverTest.php similarity index 100% rename from tests/model/SqlDbDriverTest.php rename to Tests/model/SqlDbDriverTest.php diff --git a/tests/model/SqlModelTest.php b/Tests/model/SqlModelTest.php similarity index 100% rename from tests/model/SqlModelTest.php rename to Tests/model/SqlModelTest.php diff --git a/tests/model/testData.xml b/Tests/model/testData.xml similarity index 100% rename from tests/model/testData.xml rename to Tests/model/testData.xml diff --git a/tests/model/testDataAfterCommit.xml b/Tests/model/testDataAfterCommit.xml similarity index 100% rename from tests/model/testDataAfterCommit.xml rename to Tests/model/testDataAfterCommit.xml diff --git a/tests/model/testdb.sql b/Tests/model/testdb.sql similarity index 100% rename from tests/model/testdb.sql rename to Tests/model/testdb.sql diff --git a/tests/phpunit.xml b/Tests/phpunit.xml similarity index 100% rename from tests/phpunit.xml rename to Tests/phpunit.xml diff --git a/tests/redis/RedisDebugTest.php b/Tests/redis/RedisDebugTest.php similarity index 100% rename from tests/redis/RedisDebugTest.php rename to Tests/redis/RedisDebugTest.php diff --git a/tests/redis/RedisManagerTest.php b/Tests/redis/RedisManagerTest.php similarity index 100% rename from tests/redis/RedisManagerTest.php rename to Tests/redis/RedisManagerTest.php diff --git a/tests/session/SessionModelTest.php b/Tests/session/SessionModelTest.php similarity index 100% rename from tests/session/SessionModelTest.php rename to Tests/session/SessionModelTest.php diff --git a/tests/session/SessionTest.php b/Tests/session/SessionTest.php similarity index 100% rename from tests/session/SessionTest.php rename to Tests/session/SessionTest.php diff --git a/tests/util/AutoloadBuilderTest.php b/Tests/util/AutoloadBuilderTest.php similarity index 100% rename from tests/util/AutoloadBuilderTest.php rename to Tests/util/AutoloadBuilderTest.php diff --git a/tests/util/AutoloadBuilderTestVFS.php b/Tests/util/AutoloadBuilderTestVFS.php similarity index 100% rename from tests/util/AutoloadBuilderTestVFS.php rename to Tests/util/AutoloadBuilderTestVFS.php diff --git a/tests/util/profiler/CommandProfilerTest.php b/Tests/util/profiler/CommandProfilerTest.php similarity index 100% rename from tests/util/profiler/CommandProfilerTest.php rename to Tests/util/profiler/CommandProfilerTest.php diff --git a/tests/util/profiler/ProfilerTest.php b/Tests/util/profiler/ProfilerTest.php similarity index 100% rename from tests/util/profiler/ProfilerTest.php rename to Tests/util/profiler/ProfilerTest.php diff --git a/tests/validator/EmailValidatorTest.php b/Tests/validator/EmailValidatorTest.php similarity index 100% rename from tests/validator/EmailValidatorTest.php rename to Tests/validator/EmailValidatorTest.php diff --git a/tests/validator/EqualValidatorTest.php b/Tests/validator/EqualValidatorTest.php similarity index 100% rename from tests/validator/EqualValidatorTest.php rename to Tests/validator/EqualValidatorTest.php diff --git a/tests/validator/NotEmptyValidatorTest.php b/Tests/validator/NotEmptyValidatorTest.php similarity index 100% rename from tests/validator/NotEmptyValidatorTest.php rename to Tests/validator/NotEmptyValidatorTest.php diff --git a/tests/validator/RegexValidatorTest.php b/Tests/validator/RegexValidatorTest.php similarity index 100% rename from tests/validator/RegexValidatorTest.php rename to Tests/validator/RegexValidatorTest.php diff --git a/tests/view/PHPViewTest.php b/Tests/view/PHPViewTest.php similarity index 100% rename from tests/view/PHPViewTest.php rename to Tests/view/PHPViewTest.php diff --git a/tests/view/helpers/BreadcrumbVeiwHelperTest.php b/Tests/view/helpers/BreadcrumbVeiwHelperTest.php similarity index 100% rename from tests/view/helpers/BreadcrumbVeiwHelperTest.php rename to Tests/view/helpers/BreadcrumbVeiwHelperTest.php diff --git a/tests/view/helpers/GetViewHelperTest.php b/Tests/view/helpers/GetViewHelperTest.php similarity index 100% rename from tests/view/helpers/GetViewHelperTest.php rename to Tests/view/helpers/GetViewHelperTest.php diff --git a/tests/view/helpers/HeadViewHelperTest.php b/Tests/view/helpers/HeadViewHelperTest.php similarity index 100% rename from tests/view/helpers/HeadViewHelperTest.php rename to Tests/view/helpers/HeadViewHelperTest.php diff --git a/tests/view/helpers/MsgViewHelperTest.php b/Tests/view/helpers/MsgViewHelperTest.php similarity index 100% rename from tests/view/helpers/MsgViewHelperTest.php rename to Tests/view/helpers/MsgViewHelperTest.php diff --git a/tests/view/helpers/TitleViewHelperTest.php b/Tests/view/helpers/TitleViewHelperTest.php similarity index 100% rename from tests/view/helpers/TitleViewHelperTest.php rename to Tests/view/helpers/TitleViewHelperTest.php diff --git a/util/AsciiSortedIterator.php b/Util/AsciiSortedIterator.php similarity index 100% rename from util/AsciiSortedIterator.php rename to Util/AsciiSortedIterator.php diff --git a/util/AutoloadBuilder.php b/Util/AutoloadBuilder.php similarity index 91% rename from util/AutoloadBuilder.php rename to Util/AutoloadBuilder.php index 4f27ece..470cf8d 100644 --- a/util/AutoloadBuilder.php +++ b/Util/AutoloadBuilder.php @@ -1,4 +1,4 @@ -dirs as $dir) { - $iterator = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($dir, FilesystemIterator::FOLLOW_SYMLINKS | FilesystemIterator::SKIP_DOTS), - RecursiveIteratorIterator::LEAVES_ONLY + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($dir, \FilesystemIterator::FOLLOW_SYMLINKS | \FilesystemIterator::SKIP_DOTS), + \RecursiveIteratorIterator::LEAVES_ONLY ); - $iterator = new AsciiSortedIterator($iterator); + $iterator = new \AsciiSortedIterator($iterator); foreach ($iterator as $file) { /** * @var SplFileInfo $file diff --git a/util/FirePHPCore-0.3.2/CHANGELOG b/Util/FirePHPCore-0.3.2/CHANGELOG similarity index 100% rename from util/FirePHPCore-0.3.2/CHANGELOG rename to Util/FirePHPCore-0.3.2/CHANGELOG diff --git a/util/FirePHPCore-0.3.2/CREDITS b/Util/FirePHPCore-0.3.2/CREDITS similarity index 100% rename from util/FirePHPCore-0.3.2/CREDITS rename to Util/FirePHPCore-0.3.2/CREDITS diff --git a/util/FirePHPCore-0.3.2/README b/Util/FirePHPCore-0.3.2/README similarity index 100% rename from util/FirePHPCore-0.3.2/README rename to Util/FirePHPCore-0.3.2/README diff --git a/util/FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php b/Util/FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php similarity index 100% rename from util/FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php rename to Util/FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php diff --git a/util/FirePHPCore-0.3.2/lib/FirePHPCore/LICENSE b/Util/FirePHPCore-0.3.2/lib/FirePHPCore/LICENSE similarity index 100% rename from util/FirePHPCore-0.3.2/lib/FirePHPCore/LICENSE rename to Util/FirePHPCore-0.3.2/lib/FirePHPCore/LICENSE diff --git a/util/FirePHPCore-0.3.2/lib/FirePHPCore/fb.php b/Util/FirePHPCore-0.3.2/lib/FirePHPCore/fb.php similarity index 100% rename from util/FirePHPCore-0.3.2/lib/FirePHPCore/fb.php rename to Util/FirePHPCore-0.3.2/lib/FirePHPCore/fb.php diff --git a/util/profiler/CommandProfiler.php b/Util/Profiler/CommandProfiler.php similarity index 95% rename from util/profiler/CommandProfiler.php rename to Util/Profiler/CommandProfiler.php index 21f97be..ffce4ed 100644 --- a/util/profiler/CommandProfiler.php +++ b/Util/Profiler/CommandProfiler.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/util/profiler/Profiler.php b/Util/Profiler/Profiler.php similarity index 97% rename from util/profiler/Profiler.php rename to Util/Profiler/Profiler.php index 37db682..a7b91b8 100644 --- a/util/profiler/Profiler.php +++ b/Util/Profiler/Profiler.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -29,7 +29,7 @@ class Profiler private function __construct() { - if (Config::get('PROFILER') == false) { + if (\Majestic\Config::get('PROFILER') == false) { throw new GeneralException('Need turn PROFILER before use.'); } } diff --git a/validator/EmailValidator.php b/Validator/EmailValidator.php similarity index 92% rename from validator/EmailValidator.php rename to Validator/EmailValidator.php index 7c7c565..6fb82b9 100644 --- a/validator/EmailValidator.php +++ b/Validator/EmailValidator.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/validator/EqualValidator.php b/Validator/EqualValidator.php similarity index 95% rename from validator/EqualValidator.php rename to Validator/EqualValidator.php index dadb28c..e4c6745 100644 --- a/validator/EqualValidator.php +++ b/Validator/EqualValidator.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/validator/MbStrlenValidator.php b/Validator/MbStrlenValidator.php similarity index 95% rename from validator/MbStrlenValidator.php rename to Validator/MbStrlenValidator.php index 4539fe9..2506107 100644 --- a/validator/MbStrlenValidator.php +++ b/Validator/MbStrlenValidator.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/validator/NotEmptyValidator.php b/Validator/NotEmptyValidator.php similarity index 94% rename from validator/NotEmptyValidator.php rename to Validator/NotEmptyValidator.php index cf4b418..f4b0281 100644 --- a/validator/NotEmptyValidator.php +++ b/Validator/NotEmptyValidator.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/validator/RegexValidator.php b/Validator/RegexValidator.php similarity index 77% rename from validator/RegexValidator.php rename to Validator/RegexValidator.php index 9f419cf..d2bc79b 100644 --- a/validator/RegexValidator.php +++ b/Validator/RegexValidator.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -7,7 +7,7 @@ * @since 2010-04-26 */ -class RegexValidator extends \Majestic\Validator +class RegexValidator extends Validator { const NOT_MATCH = 'regex_not_match'; @@ -28,7 +28,7 @@ class RegexValidator extends \Majestic\Validator $status = preg_match($this->regex, $value); if ($status === false) { - throw new GeneralException('Internal error matching regex "' . $this->regex . ' against value "' . $value . '"'); + throw new \Majestic\Exception\GeneralException('Internal error matching regex "' . $this->regex . ' against value "' . $value . '"'); } if (!$status) { $this->error(); diff --git a/validator/StrlenValidator.php b/Validator/StrlenValidator.php similarity index 95% rename from validator/StrlenValidator.php rename to Validator/StrlenValidator.php index 12fd41e..2d7021a 100644 --- a/validator/StrlenValidator.php +++ b/Validator/StrlenValidator.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/validator/Validator.php b/Validator/Validator.php similarity index 97% rename from validator/Validator.php rename to Validator/Validator.php index d2ad29a..04c8264 100644 --- a/validator/Validator.php +++ b/Validator/Validator.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -7,8 +7,6 @@ * @since 2010-04-24 */ -namespace Majestic; - abstract class Validator implements iValidator { diff --git a/validator/iValidator.php b/Validator/iValidator.php similarity index 87% rename from validator/iValidator.php rename to Validator/iValidator.php index c2b2b77..ebfe7b9 100644 --- a/validator/iValidator.php +++ b/Validator/iValidator.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -7,8 +7,6 @@ * @since 2010-04-25 */ -namespace Majestic; - interface iValidator { public function isValid($value, $context = null); diff --git a/view/helpers/BreadcrumbViewHelper.php b/View/Helpers/BreadcrumbViewHelper.php similarity index 73% rename from view/helpers/BreadcrumbViewHelper.php rename to View/Helpers/BreadcrumbViewHelper.php index defa0ba..0b8a340 100644 --- a/view/helpers/BreadcrumbViewHelper.php +++ b/View/Helpers/BreadcrumbViewHelper.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -22,12 +22,12 @@ class BreadcrumbViewHelper extends ViewHelper public function prepend($text, $href) { - Registry::set(__CLASS__, array($text => $href) + Registry::get(__CLASS__, array())); + \Majestic\Registry::set(__CLASS__, array($text => $href) + \Majestic\Registry::get(__CLASS__, array())); } public function append($text, $href) { - Registry::set(__CLASS__, Registry::get(__CLASS__, array()) + array($text => $href)); + \Majestic\Registry::set(__CLASS__, \Majestic\Registry::get(__CLASS__, array()) + array($text => $href)); } public function setSeparator($sep) @@ -38,7 +38,7 @@ class BreadcrumbViewHelper extends ViewHelper public function __toString() { $data = array(); - foreach (Registry::get(__CLASS__, array()) as $text => $href) { + foreach (\Majestic\Registry::get(__CLASS__, array()) as $text => $href) { if ($href) { $data[] = '' . $this->view->escape($text) . ''; } else { diff --git a/view/helpers/GetViewHelper.php b/View/Helpers/GetViewHelper.php similarity index 93% rename from view/helpers/GetViewHelper.php rename to View/Helpers/GetViewHelper.php index 430d342..7fb7b1e 100644 --- a/view/helpers/GetViewHelper.php +++ b/View/Helpers/GetViewHelper.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -31,7 +31,7 @@ class GetViewHelper extends ViewHelper protected function getSanitizedRequest() { if ($this->get === null) { - $get = Env::Get(); + $get = \Majestic\Env\Env::Get(); foreach ($get as $key => $value) { $this->get[$key] = $this->impl($key, $value); } diff --git a/view/helpers/HeadViewHelper.php b/View/Helpers/HeadViewHelper.php similarity index 60% rename from view/helpers/HeadViewHelper.php rename to View/Helpers/HeadViewHelper.php index 761383d..04fca8c 100644 --- a/view/helpers/HeadViewHelper.php +++ b/View/Helpers/HeadViewHelper.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -13,15 +13,15 @@ class HeadViewHelper extends ViewHelper public function head($string = false) { if ($string) { - $data = Registry::get(__CLASS__, array()); + $data = \Majestic\Registry::get(__CLASS__, array()); $data[] = $string; - Registry::set(__CLASS__, $data); + \Majestic\Registry::set(__CLASS__, $data); } return $this; } public function __toString() { - return implode("\n ", Registry::get(__CLASS__, array())) . "\n"; + return implode("\n ", \Majestic\Registry::get(__CLASS__, array())) . "\n"; } } \ No newline at end of file diff --git a/view/helpers/MsgViewHelper.php b/View/Helpers/MsgViewHelper.php similarity index 81% rename from view/helpers/MsgViewHelper.php rename to View/Helpers/MsgViewHelper.php index 5b0f90f..b310567 100644 --- a/view/helpers/MsgViewHelper.php +++ b/View/Helpers/MsgViewHelper.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -33,7 +33,7 @@ class MsgViewHelper extends ViewHelper { if ($msg && $type) { if (!in_array($type, array(self::SUCCESS, self::ERROR, self::INFO, self::WARNING))) { - throw new GeneralException('Unknown message type: "' . $type . '"'); + throw new \Majestic\Exception\GeneralException('Unknown message type: "' . $type . '"'); } $this->set($msg, $type); } @@ -62,12 +62,12 @@ class MsgViewHelper extends ViewHelper protected function set($msg, $type) { - Session::set(__CLASS__, array('message' => $msg, 'type' => $type)); + \Majestic\Session\Session::set(__CLASS__, array('message' => $msg, 'type' => $type)); } public static function getType() { - $msg = Session::get(__CLASS__, false); + $msg = \Majestic\Session\Session::get(__CLASS__, false); return $msg ? $msg['type'] : ''; } @@ -79,9 +79,9 @@ class MsgViewHelper extends ViewHelper public function __toString() { - $msg = Session::get(__CLASS__, false); + $msg = \Majestic\Session\Session::get(__CLASS__, false); if ($msg) { - Session::del(__CLASS__); + \Majestic\Session\Session::del(__CLASS__); $type_to_class = static::getTypeToClass(); return '
' . (($this->use_as_html)?$msg['message']:$this->view->escape($msg['message'])) . '
'; } diff --git a/view/helpers/TitleViewHelper.php b/View/Helpers/TitleViewHelper.php similarity index 67% rename from view/helpers/TitleViewHelper.php rename to View/Helpers/TitleViewHelper.php index d69dca2..fc600bb 100644 --- a/view/helpers/TitleViewHelper.php +++ b/View/Helpers/TitleViewHelper.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -15,9 +15,9 @@ class TitleViewHelper extends ViewHelper public function title($string = false) { if ($string) { - $data = Registry::get(__CLASS__, array()); + $data = \Majestic\Registry::get(__CLASS__, array()); $data[] = $string; - Registry::set(__CLASS__, $data); + \Majestic\Registry::set(__CLASS__, $data); } return $this; } @@ -29,6 +29,6 @@ class TitleViewHelper extends ViewHelper public function __toString() { - return implode($this->separator, Registry::get(__CLASS__, array())); + return implode($this->separator, \Majestic\Registry::get(__CLASS__, array())); } } \ No newline at end of file diff --git a/view/helpers/ViewHelper.php b/View/Helpers/ViewHelper.php similarity index 80% rename from view/helpers/ViewHelper.php rename to View/Helpers/ViewHelper.php index a092228..84a4807 100644 --- a/view/helpers/ViewHelper.php +++ b/View/Helpers/ViewHelper.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -11,7 +11,7 @@ abstract class ViewHelper { /** - * @var PHPView + * @var \Majestic\View\PHPView */ protected $view = null; diff --git a/view/PHPView.php b/View/PHPView.php similarity index 55% rename from view/PHPView.php rename to View/PHPView.php index 539a5df..375533b 100644 --- a/view/PHPView.php +++ b/View/PHPView.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru @@ -8,18 +8,18 @@ */ /** - * @method BreadcrumbViewHelper breadcrumb() breadcrumb(string $text = false, string $href = false) Append next link to breadcrumb - * @method GetViewHelper get() get(array $replace) Replace some HTTP GET parameters with $replace - * @method HeadViewHelper head() head(string $string = false) Append another string to HEAD section of Layout - * @method MsgViewHelper msg() msg(string $msg = null, string $type = null) Set a message to display for user in Layout - * @method TitleViewHelper title() title(string $string = false) Append another section for TITLE of Layout - * @method FormViewHelper form() form(string $form = null) Get form values from session - * @method LinkHeadViewHelper linkHead() linkHead($href = false, $rel = 'stylesheet', $type = 'text/css', $media = 'screen,projection,print') Append link tag (css file or other) into head section - * @method ScriptFooterViewHelper scriptFooter() scriptFooter($src = false, $type = 'text/javascript') Append script src (javascript or other) into footer section - * @method GroupedCssViewHelper groupedCss() groupedCss($relative_file_path = false) Append css into one file - * @method GroupedJsViewHelper groupedJs() groupedJs($relative_file_path = false) Append js into one file - * @method DescriptionViewHelper description() description(string $string = false) Set value of meta-tag description - * @method KeywordsViewHelper keywords() keywords(string $string = false) Set value of meta-tag keywords + * @method Helpers\BreadcrumbViewHelper breadcrumb() breadcrumb(string $text = false, string $href = false) Append next link to breadcrumb + * @method Helpers\GetViewHelper get() get(array $replace) Replace some HTTP GET parameters with $replace + * @method Helpers\HeadViewHelper head() head(string $string = false) Append another string to HEAD section of Layout + * @method Helpers\MsgViewHelper msg() msg(string $msg = null, string $type = null) Set a message to display for user in Layout + * @method Helpers\TitleViewHelper title() title(string $string = false) Append another section for TITLE of Layout + * @method Helpers\FormViewHelper form() form(string $form = null) Get form values from session + * @method Helpers\LinkHeadViewHelper linkHead() linkHead($href = false, $rel = 'stylesheet', $type = 'text/css', $media = 'screen,projection,print') Append link tag (css file or other) into head section + * @method Helpers\ScriptFooterViewHelper scriptFooter() scriptFooter($src = false, $type = 'text/javascript') Append script src (javascript or other) into footer section + * @method Helpers\GroupedCssViewHelper groupedCss() groupedCss($relative_file_path = false) Append css into one file + * @method Helpers\GroupedJsViewHelper groupedJs() groupedJs($relative_file_path = false) Append js into one file + * @method Helpers\DescriptionViewHelper description() description(string $string = false) Set value of meta-tag description + * @method Helpers\KeywordsViewHelper keywords() keywords(string $string = false) Set value of meta-tag keywords * */ class PHPView implements iView @@ -38,7 +38,7 @@ class PHPView implements iView public function __construct($config) { if (!isset($config['path'])) { - throw new InitializationException('Configuration must have a "path" set.'); + throw new \Majestic\Exception\InitializationException('Configuration must have a "path" set.'); } $this->setPath($config['path']); } @@ -54,7 +54,7 @@ class PHPView implements iView } /** - * @param Action $object + * @param \Majestic\App\Action $object */ public function assignObject($object) { @@ -106,7 +106,7 @@ class PHPView implements iView ob_start(); if (!is_readable($this->template)) { ob_clean(); - throw new GeneralException('Template "' . $this->template . '" not found.'); + throw new \Majestic\Exception\GeneralException('Template "' . $this->template . '" not found.'); } include($this->template); return ob_get_clean(); @@ -122,7 +122,7 @@ class PHPView implements iView * * @param mixed $name * @param mixed $args - * @return ViewHelper + * @return Helpers\ViewHelper */ public function __call($name, $args) { @@ -133,9 +133,12 @@ class PHPView implements iView protected function getHelper($name) { if (!isset($this->helpers[$name])) { - $class = ucfirst($name) . 'ViewHelper'; + $class = '\\' . ucfirst($name) . 'ViewHelper'; if (!class_exists($class)) { - throw new GeneralException('View helper "' . $class . '" not found.'); + $class = '\Majestic\View\Helpers\\' . ucfirst($name) . 'ViewHelper'; + if (!class_exists($class)) { + throw new \Majestic\Exception\GeneralException( 'View helper "' . $class . '" not found.' ); + } } $this->helpers[$name] = new $class($this); } diff --git a/view/iView.php b/View/iView.php similarity index 91% rename from view/iView.php rename to View/iView.php index 82c9733..e9f7ed7 100644 --- a/view/iView.php +++ b/View/iView.php @@ -1,4 +1,4 @@ - * @link http://netmonsters.ru diff --git a/composer.json b/composer.json index 9179706..2c15f0a 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,7 @@ { "name": "majestic/core", - "version": "0.1.0", - "dist": { - "type": "git", - "url": "git@dimti.ru:majestic.git" + "version": "0.1.1", + "autoload": { + "psr-4": {"Majestic\\": ""} } -} \ No newline at end of file +}