Browse Source

Add namespace.

namespace
Alexander Demidov 10 years ago
parent
commit
1ba341b064
  1. 10
      App/Action.php
  2. 2
      App/AjaxAction.php
  3. 2
      App/CliController.php
  4. 14
      App/ErrorAction.php
  5. 42
      App/FrontController.php
  6. 2
      App/PagerAction.php
  7. 4
      App/Router/Route.php
  8. 10
      App/Router/Router.php
  9. 2
      App/StaticAction.php
  10. 2
      App/iCli.php
  11. 0
      Cache/Cache.php
  12. 0
      Cache/CacheKey.php
  13. 0
      Cache/Cacher.php
  14. 0
      Cache/MemcacheCache.php
  15. 0
      Captcha/Captcha.php
  16. 0
      Captcha/CaptchaImageAction.php
  17. 0
      Captcha/CaptchaValidator.php
  18. 0
      Captcha/poh.ttf
  19. 8
      Config.php
  20. 4
      Env.php
  21. 0
      Env/Format.class.php
  22. 0
      Env/User.class.php
  23. 4
      Exception/Error404Exception.php
  24. 2
      Exception/ErrorHTTPException.php
  25. 32
      Exception/ErrorHandler.php
  26. 4
      Exception/GeneralException.php
  27. 4
      Exception/InitializationException.php
  28. 12
      Form/Form.php
  29. 16
      Form/FormField.php
  30. 8
      Form/FormViewHelper.php
  31. 8
      Layout/ErrorLayout.php
  32. 14
      Layout/Layout.php
  33. 17
      Load.php
  34. 2
      Logger/CliLogger.php
  35. 6
      Logger/FileLogger.php
  36. 6
      Logger/Logger.php
  37. 0
      Mail/Mailer.php
  38. 16
      Model/Db.php
  39. 4
      Model/DbDriver.php
  40. 2
      Model/DbExpr.php
  41. 10
      Model/DbStatement.php
  42. 10
      Model/Model.php
  43. 4
      Model/MongoDbCommand.php
  44. 0
      Model/MongoDriver.php
  45. 8
      Model/MongoModel.php
  46. 0
      Model/MongoStatement.php
  47. 6
      Model/MySQLiDriver.php
  48. 34
      Model/MySQLiStatement.php
  49. 2
      Model/NoSqlDbDriver.php
  50. 2
      Model/SqlCriteria.php
  51. 8
      Model/SqlDbDriver.php
  52. 4
      Model/SqlModel.php
  53. 4
      Model/SqlResultCollection.php
  54. 8
      Model/SqlResultProvider.php
  55. 2
      Model/iSqlResultItems.php
  56. 2
      Redis/RedisDebug.php
  57. 16
      Redis/RedisManager.php
  58. 2
      Redis/redis.php
  59. 6
      Registry.php
  60. 2
      Session/Session.model.php
  61. 4
      Session/Session.php
  62. 0
      Session/session.sql
  63. 0
      Tests/ConfigTest.php
  64. 0
      Tests/LoadTest.php
  65. 0
      Tests/MySQLTestsSuite.php
  66. 0
      Tests/RedisTestsSuite.php
  67. 0
      Tests/RegistryTest.php
  68. 0
      Tests/app/ActionTest.php
  69. 0
      Tests/app/Action_TestCase.php
  70. 0
      Tests/app/AjaxActionTest.php
  71. 0
      Tests/app/CliControllerTest.php
  72. 0
      Tests/app/ErrorActionTest.php
  73. 0
      Tests/app/FrontControllerTest.php
  74. 0
      Tests/app/PagerActionTest.php
  75. 0
      Tests/app/StaticActionTest.php
  76. 0
      Tests/app/router/RouteTest.php
  77. 0
      Tests/app/router/RouterTest.php
  78. 0
      Tests/bootstrap.php
  79. 0
      Tests/cache/CacheKeyTest.php
  80. 0
      Tests/cache/CacherTest.php
  81. 0
      Tests/cache/MemcacheCacheTest.php
  82. 0
      Tests/captcha/CaptchaTest.php
  83. 0
      Tests/captcha/CaptchaValidatorTest.php
  84. 0
      Tests/classes/EnvTest.php
  85. 0
      Tests/classes/FormatTest.php
  86. 0
      Tests/exception/Error404ExceptionTest.php
  87. 0
      Tests/exception/ErrorHTTPExceptionTest.php
  88. 0
      Tests/exception/ErrorHandlerTest.php
  89. 0
      Tests/exception/GeneralExceptionTest.php
  90. 0
      Tests/exception/InitializationExceptionTest.php
  91. 0
      Tests/form/FormFieldTest.php
  92. 0
      Tests/form/FormTest.php
  93. 0
      Tests/form/FormViewHelperTest.php
  94. 0
      Tests/i18n/I18NTest.php
  95. 0
      Tests/layout/ErrorLayoutTest.php
  96. 0
      Tests/layout/LayoutTest.php
  97. 0
      Tests/logger/CliLoggerTest.php
  98. 0
      Tests/logger/FileLoggerTest.php
  99. 0
      Tests/model/DbExprTest.php
  100. 0
      Tests/model/DbStatementTest.php

10
app/Action.php → App/Action.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\App;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -13,7 +13,7 @@ abstract class Action
protected $template; protected $template;
/** /**
* @var PHPView
* @var \Majestic\View\PHPView
*/ */
protected $view; protected $view;
@ -26,7 +26,7 @@ abstract class Action
protected function extractParams() protected function extractParams()
{ {
foreach (Env::getParam() as $name => $value) {
foreach (\Majestic\Env::getParam() as $name => $value) {
if (is_string($name)) { if (is_string($name)) {
$this->$name = $value; $this->$name = $value;
} }
@ -46,7 +46,7 @@ abstract class Action
if ($permanently) { if ($permanently) {
header('HTTP/1.1 301 Moved Permanently'); header('HTTP/1.1 301 Moved Permanently');
} }
header('Location: ' . (($url) ? $url : Env::getRequestUri()));
header('Location: ' . (($url) ? $url : \Majestic\Env::getRequestUri()));
exit(); exit();
} }
@ -54,7 +54,7 @@ abstract class Action
{ {
$class = get_class($this); $class = get_class($this);
$template = ($this->template) ? $this->template : substr($class, 0, -6 /*strlen('Action')*/); $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; return '/actions/' . array_pop($dir) . '/' . $template;
} }

2
app/AjaxAction.php → App/AjaxAction.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\App;
/** /**
* AjaxAction * AjaxAction
* *

2
app/CliController.php → App/CliController.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\App;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

14
app/ErrorAction.php → App/ErrorAction.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\App;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -11,7 +11,7 @@ class ErrorAction extends Action
{ {
/** /**
* @var ErrorException|ErrorHTTPException
* @var \ErrorException|\Majestic\Exception\ErrorHTTPException
*/ */
public $exception; public $exception;
@ -25,9 +25,9 @@ class ErrorAction extends Action
protected function execute() protected function execute()
{ {
if ($this->exception instanceof Error404Exception) {
if ($this->exception instanceof \Majestic\Exception\Error404Exception) {
$this->template = 404; $this->template = 404;
} elseif ($this->exception instanceof ErrorHTTPException) {
} elseif ($this->exception instanceof \Majestic\Exception\ErrorHTTPException) {
$this->template = 'HTTP'; $this->template = 'HTTP';
} else { } else {
$this->template = 500; $this->template = 500;
@ -51,7 +51,7 @@ class ErrorAction extends Action
protected function sendHttpCode() protected function sendHttpCode()
{ {
if ($this->exception instanceof ErrorHTTPException) {
if ($this->exception instanceof \Majestic\Exception\ErrorHTTPException) {
header($this->exception->getHTTPHeader()); header($this->exception->getHTTPHeader());
} else { } else {
header('HTTP/1.0 500 Internal Server Error'); header('HTTP/1.0 500 Internal Server Error');
@ -60,8 +60,8 @@ class ErrorAction extends Action
protected function logError() 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);
} }
} }

42
app/FrontController.php → App/FrontController.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\App;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -10,14 +10,14 @@
class FrontController class FrontController
{ {
/** /**
* @var Router
* @var Router\Router
*/ */
protected $router; protected $router;
/** /**
* @var string * @var string
*/ */
protected $view = 'PHPView';
protected $view = '\Majestic\View\PHPView';
protected $base_url = ''; protected $base_url = '';
@ -30,7 +30,7 @@ class FrontController
private function __construct() private function __construct()
{ {
// ErrorHandler::init(); // ErrorHandler::init();
$this->router = new Router();
$this->router = new Router\Router();
} }
/** /**
@ -69,12 +69,12 @@ class FrontController
/** /**
* *
* @param null $view * @param null $view
* @return PHPView
* @return ..\View\PHPView
*/ */
public function getView($view = null) public function getView($view = null)
{ {
$view = ($view) ? $view : $this->view; $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() public function getRouter()
{ {
@ -103,53 +103,53 @@ class FrontController
public function execute() public function execute()
{ {
try { try {
$request = Env::getRequestUri(true);
$request = \Majestic\Env::getRequestUri(true);
$route = $this->getRouter()->route($request); $route = $this->getRouter()->route($request);
if (!$route) { if (!$route) {
throw new Error404Exception('Route for "' . $request . '" not found');
throw new \Majestic\Exception\Error404Exception('Route for "' . $request . '" not found');
} }
$action_class = $route->getAction(); $action_class = $route->getAction();
if (!class_exists($action_class)) { 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(); $action = new $action_class();
$layout_class = $route->getLayout(); $layout_class = $route->getLayout();
if (!class_exists($layout_class)) { 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(); $layout = new $layout_class();
$html = $layout->fetch($action); $html = $layout->fetch($action);
if (Config::get('PROFILER')) {
if (\Majestic\Config::get('PROFILER')) {
if (is_subclass_of($action, 'AjaxAction')) { if (is_subclass_of($action, 'AjaxAction')) {
Profiler::getInstance()->getJson();
\Majestic\Util\Profiler\Profiler::getInstance()->getJson();
} else { } else {
$html = Profiler::getInstance()->end($html);
$html = \Majestic\Util\Profiler\Profiler::getInstance()->end($html);
} }
} }
return $html; return $html;
} }
catch (Exception $e) {
if (Config::get('DEBUG')) {
catch (\Exception $e) {
if (\Majestic\Config::get('DEBUG')) {
if (!headers_sent()) { if (!headers_sent()) {
if ($e instanceof ErrorHTTPException) {
if ($e instanceof \Majestic\Exception\ErrorHTTPException) {
header($e->getHTTPHeader()); header($e->getHTTPHeader());
} else { } else {
header('HTTP/1.0 500 Internal Server Error'); 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(); $layout_class = $this->getRouter()->getErrorLayout();
/** /**
* @var ErrorLayout $layout
* @var \Majestic\Layout\ErrorLayout $layout
*/ */
$layout = new $layout_class(); $layout = new $layout_class();
$layout->setException($e); $layout->setException($e);

2
app/PagerAction.php → App/PagerAction.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\App;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

4
app/router/Route.php → App/Router/Route.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\App\Router;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -7,8 +7,6 @@
* @since 2010-02-25 * @since 2010-02-25
*/ */
namespace Majestic;
class Route class Route
{ {

10
app/router/Router.php → App/Router/Router.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\App\Router;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -33,7 +33,7 @@ class Router
if (!$layout) { if (!$layout) {
$layout = $this->default_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)) { if ($route->match($req)) {
$this->route_name = $name; $this->route_name = $name;
$this->route = $route; $this->route = $route;
Env::setParams($route->getParams());
\Majestic\Env::setParams($route->getParams());
return $this->route; return $this->route;
} }
} }
@ -94,7 +94,7 @@ class Router
/** /**
* @param null|string $name * @param null|string $name
* @return Route * @return Route
* @throws ErrorException
* @throws \ErrorException
*/ */
public function getRoute($name = null) public function getRoute($name = null)
{ {
@ -104,7 +104,7 @@ class Router
if ($this->routeIsExists($name)) { if ($this->routeIsExists($name)) {
return $this->getRouteByName($name); return $this->getRouteByName($name);
} else { } else {
throw new ErrorException('Unknown route name: "' . $name . '".');
throw new \ErrorException('Unknown route name: "' . $name . '".');
} }
} }
} }

2
app/StaticAction.php → App/StaticAction.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\App;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

2
app/iCli.php → App/iCli.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\App;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

0
cache/Cache.php → Cache/Cache.php

0
cache/CacheKey.php → Cache/CacheKey.php

0
cache/Cacher.php → Cache/Cacher.php

0
cache/MemcacheCache.php → Cache/MemcacheCache.php

0
captcha/Captcha.php → Captcha/Captcha.php

0
captcha/CaptchaImageAction.php → Captcha/CaptchaImageAction.php

0
captcha/CaptchaValidator.php → Captcha/CaptchaValidator.php

0
captcha/poh.ttf → Captcha/poh.ttf

8
Config.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -7,9 +7,9 @@
* @since 2010-02-17 * @since 2010-02-17
*/ */
namespace Majestic;
class Config extends \Registry
class Config extends Registry
{ {
private static $_class_name = 'Config'; private static $_class_name = 'Config';
@ -33,7 +33,7 @@ class ConfigArray extends \ArrayObject
public function offsetGet($index) public function offsetGet($index)
{ {
if (!$this->offsetExists($index)) { if (!$this->offsetExists($index)) {
throw new \GeneralException('Configuration variable "' . $index . '" undefined');
throw new Exception\GeneralException('Configuration variable "' . $index . '" undefined');
} }
return parent::offsetGet($index); return parent::offsetGet($index);
} }

4
classes/Env.class.php → Env.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic;
/** /**
* Класс для работы с переменными окружения. * Класс для работы с переменными окружения.
* *
@ -23,7 +23,7 @@ class Env
list(self::$request[$trim_base], ) = explode('?', Env::Server('REQUEST_URI')); list(self::$request[$trim_base], ) = explode('?', Env::Server('REQUEST_URI'));
if ($trim_base) { if ($trim_base) {
// removes base url // removes base url
$base = FrontController::getInstance()->getBaseUrl();
$base = \Majestic\App\FrontController::getInstance()->getBaseUrl();
if (($length = strlen($base)) > 0 && strpos(self::$request[$trim_base], $base) === 0) { if (($length = strlen($base)) > 0 && strpos(self::$request[$trim_base], $base) === 0) {
self::$request[$trim_base] = (string) substr(self::$request[$trim_base], $length); self::$request[$trim_base] = (string) substr(self::$request[$trim_base], $length);
} }

0
classes/Format.class.php → Env/Format.class.php

0
classes/User.class.php → Env/User.class.php

4
exception/Error404Exception.php → Exception/Error404Exception.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Exception;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -8,7 +8,7 @@
*/ */
class Error404Exception extends ErrorHTTPException { 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); parent::__construct($message, 404, $previous);
} }

2
exception/ErrorHTTPException.php → Exception/ErrorHTTPException.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Exception;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

32
exception/ErrorHandler.php → Exception/ErrorHandler.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Exception;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -22,7 +22,7 @@ class ErrorHandler
ob_end_clean(); ob_end_clean();
} }
if (error_reporting() !== 0) { if (error_reporting() !== 0) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
} }
return true; return true;
} }
@ -31,7 +31,7 @@ class ErrorHandler
{ {
$error = 0; $error = 0;
$exception_name = ''; $exception_name = '';
if ($exception instanceof ErrorException) {
if ($exception instanceof \ErrorException) {
$error = $exception->getSeverity(); $error = $exception->getSeverity();
} else { } else {
$exception_name = get_class($exception) . ': '; $exception_name = get_class($exception) . ': ';
@ -59,9 +59,9 @@ class ErrorHandler
static public function getHTTPErrorConditions() static public function getHTTPErrorConditions()
{ {
$text = null; $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; return $text;
} }
@ -109,7 +109,7 @@ class ErrorHandler
} }
/** /**
* @param Exception $exception
* @param \Exception $exception
* @return string * @return string
*/ */
static public function showDebug($exception) static public function showDebug($exception)
@ -120,19 +120,19 @@ class ErrorHandler
} }
$class = get_class($exception); $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()); $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()); $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 = <<<EOD $message = <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

4
exception/GeneralException.php → Exception/GeneralException.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Exception;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -7,4 +7,4 @@
* @since 2010-02-26 * @since 2010-02-26
*/ */
class GeneralException extends Exception {}
class GeneralException extends \Exception {}

4
exception/InitializationException.php → Exception/InitializationException.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Exception;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -9,4 +9,4 @@
* Exception from initializtion object * Exception from initializtion object
*/ */
class InitializationException extends Exception {}
class InitializationException extends \Exception {}

12
form/Form.php → Form/Form.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Form;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -7,8 +7,6 @@
* @since 2010-04-24 * @since 2010-04-24
*/ */
namespace Majestic;
abstract class Form abstract class Form
{ {
@ -17,7 +15,7 @@ abstract class Form
const ERROR = 'error'; const ERROR = 'error';
/** /**
* @var \FormField[]
* @var FormField[]
*/ */
protected $fields = array(); protected $fields = array();
@ -38,18 +36,18 @@ abstract class Form
/** /**
* @param string $name * @param string $name
* @param bool|string $message * @param bool|string $message
* @return \FormField
* @return FormField
*/ */
protected function addField($name, $message = false) protected function addField($name, $message = false)
{ {
$this->fields[$name] = new \FormField($message);
$this->fields[$name] = new FormField($message);
return $this->fields[$name]; return $this->fields[$name];
} }
public function isValid($data) public function isValid($data)
{ {
if (!is_array($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) { foreach ($this->fields as $field_name => $field) {

16
form/FormField.php → Form/FormField.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Form;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -93,7 +93,7 @@ class FormField
} }
/** /**
* @param string[]|iValidator[] $validators
* @param string[]|\Majestic\Validator\iValidator[] $validators
* @return FormField * @return FormField
*/ */
public function addValidators($validators) public function addValidators($validators)
@ -105,19 +105,19 @@ class FormField
} }
/** /**
* @param string|iValidator $validator
* @param string|\Majestic\Validator\iValidator $validator
* @return FormField * @return FormField
* @throws InitializationException
* @throws \Majestic\Exception\InitializationException
*/ */
public function addValidator($validator) public function addValidator($validator)
{ {
if ($validator instanceof iValidator) {
if ($validator instanceof \Majestic\Validator\iValidator) {
$name = get_class($validator); $name = get_class($validator);
} elseif (is_string($validator)) { } elseif (is_string($validator)) {
$name = $validator . 'Validator'; $name = $validator . 'Validator';
$validator = new $name(); $validator = new $name();
} else { } 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; $this->validators[$name] = $validator;
return $this; return $this;
@ -139,7 +139,7 @@ class FormField
$name = $filter . 'Filter'; $name = $filter . 'Filter';
$filter = new $name(); $filter = new $name();
} else { } 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; $this->filters[$name] = $filter;
return $this; return $this;
@ -192,7 +192,7 @@ class FormField
if (!$validator->isValid($val, $context)) { if (!$validator->isValid($val, $context)) {
$valid = false; $valid = false;
if (!$this->default_message) { 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; $this->message = $this->default_message;
} }

8
form/FormViewHelper.php → Form/FormViewHelper.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Form;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -16,10 +16,10 @@ class FormViewHelper extends ViewHelper
{ {
if ($this->data === null) { if ($this->data === null) {
if ($form == 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; return $this;
} }

8
layout/Error.layout.php → Layout/ErrorLayout.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Layout;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -10,7 +10,7 @@
class ErrorLayout extends Layout class ErrorLayout extends Layout
{ {
/** /**
* @var GeneralException
* @var \Majestic\ExceptionGeneralException
*/ */
protected $exception; 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; $this->exception = $exception;
} }

14
layout/Layout.php → Layout/Layout.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Layout;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -13,18 +13,18 @@ abstract class Layout
protected $template; protected $template;
/** /**
* @var PHPView
* @var \Majestic\View\PHPView
*/ */
protected $view; protected $view;
public function __construct() public function __construct()
{ {
$this->view = FrontController::getInstance()->getView();
$this->view = \Majestic\App\FrontController::getInstance()->getView();
} }
/** /**
* @param string $name * @param string $name
* @param Action $action
* @param \Majestic\App\Action $action
*/ */
protected function assign($name, $action) protected function assign($name, $action)
{ {
@ -34,7 +34,7 @@ abstract class Layout
/** /**
* @param string $name * @param string $name
* @param Action $action
* @param \Majestic\App\Action $action
*/ */
protected function append($name, $action) protected function append($name, $action)
{ {
@ -44,7 +44,7 @@ abstract class Layout
/** /**
* @param string $name * @param string $name
* @param Action $action
* @param \Majestic\App\Action $action
*/ */
protected function prepend($name, $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 * Execute Action, insert action's result html into layout template and return Layout html
* @param Action $action
* @param \Majestic\App\Action $action
* @return string * @return string
*/ */
public function fetch($action) public function fetch($action)

17
Load.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -18,6 +18,15 @@ class Load
static protected $builder = null; 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 * Add exclude path for autoload. Should be called before setAutoloadFrom
* @static * @static
@ -62,7 +71,11 @@ class Load
static public function getFilePath($class) 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() static protected function buildAutoload()

2
logger/CliLogger.php → Logger/CliLogger.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Logger;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

6
logger/FileLogger.php → Logger/FileLogger.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Logger;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -20,7 +20,7 @@ class FileLogger extends Logger
protected function __construct() protected function __construct()
{ {
$this->file_path = Config::get('Logger')->filepath;
$this->file_path = \Majestic\Config::get('Logger')->filepath;
} }
protected function generateOutString($message) protected function generateOutString($message)
@ -35,7 +35,7 @@ class FileLogger extends Logger
if (!$this->handler) { if (!$this->handler) {
$this->handler = @fopen($this->file_path, "a"); $this->handler = @fopen($this->file_path, "a");
if (!$this->handler) { 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); fwrite($this->handler, $out);

6
logger/Logger.php → Logger/Logger.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Logger;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -31,7 +31,7 @@ abstract class Logger
{ {
if (static::$_instance === null) { if (static::$_instance === null) {
//$class = get_called_class(); //$class = get_called_class();
$class = Config::get('Logger')->logger;
$class = \Majestic\Config::get('Logger')->logger;
static::$_instance = new $class(); static::$_instance = new $class();
} }
return static::$_instance; return static::$_instance;
@ -43,7 +43,7 @@ abstract class Logger
*/ */
public function log($message) public function log($message)
{ {
if (Config::get('LOGGING')) {
if (\Majestic\Config::get('LOGGING')) {
$this->concreteLog($message); $this->concreteLog($message);
} }
} }

0
mail/Mailer.php → Mail/Mailer.php

16
model/Db.php → Model/Db.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -7,8 +7,6 @@
* @since 2010-02-16 * @since 2010-02-16
*/ */
namespace Majestic;
class Db class Db
{ {
@ -31,23 +29,23 @@ class Db
* @param array $config Configuration array. * @param array $config Configuration array.
* *
* @return DbDriver * @return DbDriver
* @throws InitializationException
* @throws \Majestic\Exception\InitializationException
*/ */
static public function connect($name = 'default', $config = null) static public function connect($name = 'default', $config = null)
{ {
if (!isset(self::$connections[$name])) { if (!isset(self::$connections[$name])) {
if (!$config) { if (!$config) {
if (!is_object(\Majestic\Config::get(__CLASS__))) { 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; $config = \Majestic\Config::get(__CLASS__)->$name;
} }
if (!is_array($config)) { 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'])) { if (isset($config['driver'])) {
$driver = $config['driver']; $driver = $config['driver'];
unset($config['driver']); unset($config['driver']);
@ -55,8 +53,8 @@ class Db
$connection = new $driver($config); $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; self::$connections[$name] = $connection;
} }

4
model/DbDriver.php → Model/DbDriver.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -36,7 +36,7 @@ abstract class DbDriver
$required = array('database', 'username', 'password', 'hostname'); $required = array('database', 'username', 'password', 'hostname');
foreach ($required as $option) { foreach ($required as $option) {
if (!isset($config[$option])) { if (!isset($config[$option])) {
throw new GeneralException('Configuration must have a "' . $option . '".');
throw new \GeneralException('Configuration must have a "' . $option . '".');
} }
} }
} }

2
model/DbExpr.php → Model/DbExpr.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

10
model/DbStatement.php → Model/DbStatement.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -53,7 +53,7 @@ abstract class DbStatement
* @param mixed $style * @param mixed $style
* @return array * @return array
*/ */
public function fetchAll($style = \Majestic\Db::FETCH_OBJ)
public function fetchAll($style = Db::FETCH_OBJ)
{ {
$data = array(); $data = array();
while ($row = $this->fetch($style)) { while ($row = $this->fetch($style)) {
@ -69,7 +69,7 @@ abstract class DbStatement
public function fetchColumn($field) public function fetchColumn($field)
{ {
$data = array(); $data = array();
while ($row = $this->fetch(\Majestic\Db::FETCH_ASSOC)) {
while ($row = $this->fetch(Db::FETCH_ASSOC)) {
$data[] = $row[$field]; $data[] = $row[$field];
} }
return $data; return $data;
@ -81,7 +81,7 @@ abstract class DbStatement
*/ */
public function fetchField($field) public function fetchField($field)
{ {
$row = $this->fetch(\Majestic\Db::FETCH_ASSOC);
$row = $this->fetch(Db::FETCH_ASSOC);
if (isset($row[$field])) { if (isset($row[$field])) {
return $row[$field]; return $row[$field];
} }
@ -94,7 +94,7 @@ abstract class DbStatement
abstract protected function assemble(); 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'); abstract public function fetchObject($class = 'stdClass');

10
model/Model.php → Model/Model.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Model;
/** /**
* Класс модели данных * Класс модели данных
@ -10,15 +10,13 @@
* @since 2010-02-16 * @since 2010-02-16
*/ */
namespace Majestic;
abstract class Model abstract class Model
{ {
/** /**
* DbDriver instance * DbDriver instance
* *
* @var \DbDriver
* @var DbDriver
*/ */
protected $db; protected $db;
@ -50,7 +48,7 @@ abstract class Model
public function __construct($connection = 'default') public function __construct($connection = 'default')
{ {
$this->db = \Majestic\Db::connect($connection);
$this->db = Db::connect($connection);
} }
/** /**
@ -101,7 +99,7 @@ abstract class Model
public function getCache() public function getCache()
{ {
if (!$this->cache) { if (!$this->cache) {
$this->cache = \Cacher::get(Config::get(__CLASS__, 'MemcacheCache'));
$this->cache = \Cacher::get(\Majestic\Config::get(__CLASS__, 'MemcacheCache'));
} }
return $this->cache; return $this->cache;
} }

4
model/MongoDbCommand.php → Model/MongoDbCommand.php

@ -49,14 +49,14 @@ abstract class MongoDbCommand
* Execute Mongo command/query * Execute Mongo command/query
* *
* @return mixed * @return mixed
* @throws GeneralException
* @throws \Majestic\Exception\GeneralException
*/ */
public function execute() public function execute()
{ {
if ($this->checkParams()) { if ($this->checkParams()) {
return $this->concreteExecute(); return $this->concreteExecute();
} else { } 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.');
} }
} }

0
model/MongoDriver.php → Model/MongoDriver.php

8
model/MongoModel.php → Model/MongoModel.php

@ -159,7 +159,7 @@ abstract class MongoModel extends Model
/** /**
* @param array $params Parameters for find query * @param array $params Parameters for find query
* @return array Query result sort rules * @return array Query result sort rules
* @throws GeneralException
* @throws \Majestic\Exception\GeneralException
* */ * */
private function getOrder($params = array()) private function getOrder($params = array())
{ {
@ -170,7 +170,7 @@ abstract class MongoModel extends Model
} elseif (is_array($params['order'])) { } elseif (is_array($params['order'])) {
$order = $params['order']; $order = $params['order'];
} else { } else {
throw new GeneralException('Wrong order parameter given to query.');
throw new \Majestic\Exception\GeneralException('Wrong order parameter given to query.');
} }
} }
return $order; return $order;
@ -179,7 +179,7 @@ abstract class MongoModel extends Model
/** /**
* @param array $params Parameters for find query * @param array $params Parameters for find query
* @return array Query result sort rules * @return array Query result sort rules
* @throws GeneralException
* @throws \Majestic\Exception\GeneralException
* */ * */
private function getFields($params) private function getFields($params)
{ {
@ -196,7 +196,7 @@ abstract class MongoModel extends Model
$fields = $params['fields']; $fields = $params['fields'];
} }
} else { } else {
throw new GeneralException('Wrong fields parameter given to query.');
throw new \Majestic\Exception\GeneralException('Wrong fields parameter given to query.');
} }
} }
return $fields; return $fields;

0
model/MongoStatement.php → Model/MongoStatement.php

6
model/MySQLiDriver.php → Model/MySQLiDriver.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -8,7 +8,7 @@
*/ */
/** /**
* @property MySQLi $connection
* @property \MySQLi $connection
*/ */
class MySQLiDriver extends SqlDbDriver class MySQLiDriver extends SqlDbDriver
{ {
@ -51,7 +51,7 @@ class MySQLiDriver extends SqlDbDriver
public function isConnected() public function isConnected()
{ {
return ($this->connection instanceof MySQLi);
return ($this->connection instanceof \MySQLi);
} }
public function disconnect() public function disconnect()

34
model/MySQLiStatement.php → Model/MySQLiStatement.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -9,7 +9,7 @@
/** /**
* @property MySQLiDriver $driver * @property MySQLiDriver $driver
* @property MySQLi_Result $result
* @property \MySQLi_Result $result
*/ */
class MySQLiStatement extends DbStatement class MySQLiStatement extends DbStatement
{ {
@ -23,10 +23,10 @@ class MySQLiStatement extends DbStatement
} }
if (count($this->map) > 0) { if (count($this->map) > 0) {
if (!is_string($param) && !is_int($param)) { 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)) { 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])) { if (isset($this->map[$param])) {
$this->params[$param] = &$value; $this->params[$param] = &$value;
@ -81,29 +81,29 @@ class MySQLiStatement extends DbStatement
* *
* @param mixed $style * @param mixed $style
* @return mixed * @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) { if (!$this->result) {
return false; return false;
} }
switch ($style) { switch ($style) {
case \Majestic\Db::FETCH_OBJ:
case Db::FETCH_OBJ:
$row = $this->result->fetch_object(); $row = $this->result->fetch_object();
break; break;
case \Majestic\Db::FETCH_NUM:
case Db::FETCH_NUM:
$row = $this->result->fetch_array(MYSQLI_NUM); $row = $this->result->fetch_array(MYSQLI_NUM);
break; break;
case \Majestic\Db::FETCH_ASSOC:
case Db::FETCH_ASSOC:
$row = $this->result->fetch_assoc(); $row = $this->result->fetch_assoc();
break; break;
case \Majestic\Db::FETCH_BOTH:
case Db::FETCH_BOTH:
$row = $this->result->fetch_array(MYSQLI_BOTH); $row = $this->result->fetch_array(MYSQLI_BOTH);
break; break;
default: default:
throw new GeneralException('Invalid fetch mode "' . $style . '" specified');
throw new \Majestic\Exception\GeneralException('Invalid fetch mode "' . $style . '" specified');
} }
return $row; return $row;
} }
@ -123,7 +123,7 @@ class MySQLiStatement extends DbStatement
public function fetchPairs() public function fetchPairs()
{ {
$data = array(); $data = array();
while ($row = $this->fetch(\Majestic\Db::FETCH_NUM)) {
while ($row = $this->fetch(Db::FETCH_NUM)) {
$data[$row[0]] = $row[1]; $data[$row[0]] = $row[1];
} }
return $data; return $data;
@ -158,11 +158,11 @@ class MySQLiStatement extends DbStatement
protected function driverExecute($request) protected function driverExecute($request)
{ {
/** /**
* @var MySQLi
* @var \MySQLi
*/ */
$mysqli = $this->driver->getConnection(); $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); $result = $mysqli->query($request);
$profiler->end(); $profiler->end();
} else { } else {
@ -170,9 +170,9 @@ class MySQLiStatement extends DbStatement
} }
if ($result === false) { if ($result === false) {
$message = $mysqli->error . "\nQuery: \"" . $request . '"'; $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; $this->result = $result;
} }
return true; return true;

2
model/NoSqlDbDriver.php → Model/NoSqlDbDriver.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

2
model/SqlCriteria.php → Model/SqlCriteria.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Model;
class SqlCriteria class SqlCriteria
{ {

8
model/SqlDbDriver.php → Model/SqlDbDriver.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -129,7 +129,7 @@ abstract class SqlDbDriver extends DbDriver
/** /**
* @param mixed $where * @param mixed $where
* @return string * @return string
* @throws ErrorException
* @throws \ErrorException
*/ */
public function whereExpr($where) public function whereExpr($where)
{ {
@ -143,7 +143,7 @@ abstract class SqlDbDriver extends DbDriver
foreach ($where as $cond => &$term) { foreach ($where as $cond => &$term) {
if (is_int($cond)) { if (is_int($cond)) {
if (is_int($term)) { 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) { if ($term instanceof DbExpr) {
$term = (string) $term; $term = (string) $term;
@ -164,7 +164,7 @@ abstract class SqlDbDriver extends DbDriver
/** /**
* @param mixed $group_by * @param mixed $group_by
* @return string * @return string
* @throws ErrorException
* @throws \ErrorException
*/ */
public function groupByExpr($group_by) public function groupByExpr($group_by)
{ {

4
model/SqlModel.php → Model/SqlModel.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Model;
/** /**
* Класс модели данных * Класс модели данных
@ -13,7 +13,7 @@
/** /**
* @property SqlDbDriver $db * @property SqlDbDriver $db
*/ */
abstract class SqlModel extends \Majestic\Model
abstract class SqlModel extends Model
{ {
/** /**
* @param string $ident * @param string $ident

4
model/SqlResultCollection.php → Model/SqlResultCollection.php

@ -1,6 +1,6 @@
<?php
<?php namespace Majestic\Model;
class SqlResultCollection extends ArrayIterator implements iSqlResultItems
class SqlResultCollection extends \ArrayIterator implements iSqlResultItems
{ {
private $items; private $items;

8
model/SqlResultProvider.php → Model/SqlResultProvider.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Model;
class SqlResultProvider implements iSqlResultItems class SqlResultProvider implements iSqlResultItems
{ {
@ -38,7 +38,7 @@ class SqlResultProvider implements iSqlResultItems
* @param $field string * @param $field string
* @param bool $assoc_as_array * @param bool $assoc_as_array
* @return $this SqlResultProvider * @return $this SqlResultProvider
* @throws ErrorException
* @throws \ErrorException
*/ */
public function assoc($field, $assoc_as_array = false) public function assoc($field, $assoc_as_array = false)
{ {
@ -46,7 +46,7 @@ class SqlResultProvider implements iSqlResultItems
$result_items_assoc = array(); $result_items_assoc = array();
foreach ($this->result_items_base as $item) { foreach ($this->result_items_base as $item) {
if (!isset($item->{$field})) { if (!isset($item->{$field})) {
throw new ErrorException('Undefined field. ' . $field);
throw new \ErrorException('Undefined field. ' . $field);
} }
if ($assoc_as_array) { if ($assoc_as_array) {
if (!isset($result_items_assoc[$item->{$field}])) { if (!isset($result_items_assoc[$item->{$field}])) {
@ -55,7 +55,7 @@ class SqlResultProvider implements iSqlResultItems
$result_items_assoc[$item->{$field}][] = $item; $result_items_assoc[$item->{$field}][] = $item;
} else { } else {
if (isset($result_items_assoc[$item->{$field}])) { 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; $result_items_assoc[$item->{$field}] = $item;
} }

2
model/iSqlResultItems.php → Model/iSqlResultItems.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Model;
interface iSqlResultItems interface iSqlResultItems
{ {

2
redis/RedisDebug.php → Redis/RedisDebug.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Redis;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

16
redis/RedisManager.php → Redis/RedisManager.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Redis;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -23,7 +23,7 @@ class RedisManager
* @param string $name connection name. If not set 'default' will be used. * @param string $name connection name. If not set 'default' will be used.
* @param array $config Configuration array. * @param array $config Configuration array.
* *
* @throws GeneralException
* @throws \Majestic\Exception\GeneralException
* @return Redis * @return Redis
*/ */
static public function connect($name = 'default', $config = null) static public function connect($name = 'default', $config = null)
@ -31,13 +31,13 @@ class RedisManager
if (!isset(self::$connections[$name])) { if (!isset(self::$connections[$name])) {
if (!$config) { if (!$config) {
if (!is_object(\Majestic\Config::get('Redis'))) { 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; $config = \Majestic\Config::get('Redis')->$name;
} }
if (!is_array($config)) { 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'; $host = isset($config['host']) ? $config['host'] : 'localhost';
@ -47,16 +47,16 @@ class RedisManager
/** /**
* @var Redis * @var Redis
*/ */
$connection = new Redis();
if (Config::get('PROFILER_DETAILS')) {
$connection = new \Redis();
if (\Majestic\Config::get('PROFILER_DETAILS')) {
$connection = new RedisDebug($connection); $connection = new RedisDebug($connection);
} }
if (!$connection->connect($host, $port)) { 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 ($database) {
if (!$connection->select($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; self::$connections[$name] = $connection;

2
redis/redis.php → Redis/redis.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Redis;
/** /**
* *
* *

6
Registry.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -7,7 +7,7 @@
* @since 2010-02-17 * @since 2010-02-17
*/ */
class Registry extends ArrayObject
class Registry extends \ArrayObject
{ {
/** /**
* Class name of the singleton registry object. * Class name of the singleton registry object.
@ -53,7 +53,7 @@ class Registry extends ArrayObject
public static function getInstance() public static function getInstance()
{ {
if (self::$_registry === null) { if (self::$_registry === null) {
self::$_registry = new self::$_class_name();
self::$_registry = new \Majestic\Registry();
} }
return self::$_registry; return self::$_registry;
} }

2
session/Session.model.php → Session/Session.model.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

4
session/Session.php → Session/Session.php

@ -1,4 +1,4 @@
<?php
<?php namespace Majestic\Session;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -7,8 +7,6 @@
* @since 2010-03-14 * @since 2010-03-14
*/ */
namespace Majestic;
class Session class Session
{ {
/** /**

0
session/session.sql → Session/session.sql

0
tests/ConfigTest.php → Tests/ConfigTest.php

0
tests/LoadTest.php → Tests/LoadTest.php

0
tests/MySQLTestsSuite.php → Tests/MySQLTestsSuite.php

0
tests/RedisTestsSuite.php → Tests/RedisTestsSuite.php

0
tests/RegistryTest.php → Tests/RegistryTest.php

0
tests/app/ActionTest.php → Tests/app/ActionTest.php

0
tests/app/Action_TestCase.php → Tests/app/Action_TestCase.php

0
tests/app/AjaxActionTest.php → Tests/app/AjaxActionTest.php

0
tests/app/CliControllerTest.php → Tests/app/CliControllerTest.php

0
tests/app/ErrorActionTest.php → Tests/app/ErrorActionTest.php

0
tests/app/FrontControllerTest.php → Tests/app/FrontControllerTest.php

0
tests/app/PagerActionTest.php → Tests/app/PagerActionTest.php

0
tests/app/StaticActionTest.php → Tests/app/StaticActionTest.php

0
tests/app/router/RouteTest.php → Tests/app/router/RouteTest.php

0
tests/app/router/RouterTest.php → Tests/app/router/RouterTest.php

0
tests/bootstrap.php → Tests/bootstrap.php

0
tests/cache/CacheKeyTest.php → Tests/cache/CacheKeyTest.php

0
tests/cache/CacherTest.php → Tests/cache/CacherTest.php

0
tests/cache/MemcacheCacheTest.php → Tests/cache/MemcacheCacheTest.php

0
tests/captcha/CaptchaTest.php → Tests/captcha/CaptchaTest.php

0
tests/captcha/CaptchaValidatorTest.php → Tests/captcha/CaptchaValidatorTest.php

0
tests/classes/EnvTest.php → Tests/classes/EnvTest.php

0
tests/classes/FormatTest.php → Tests/classes/FormatTest.php

0
tests/exception/Error404ExceptionTest.php → Tests/exception/Error404ExceptionTest.php

0
tests/exception/ErrorHTTPExceptionTest.php → Tests/exception/ErrorHTTPExceptionTest.php

0
tests/exception/ErrorHandlerTest.php → Tests/exception/ErrorHandlerTest.php

0
tests/exception/GeneralExceptionTest.php → Tests/exception/GeneralExceptionTest.php

0
tests/exception/InitializationExceptionTest.php → Tests/exception/InitializationExceptionTest.php

0
tests/form/FormFieldTest.php → Tests/form/FormFieldTest.php

0
tests/form/FormTest.php → Tests/form/FormTest.php

0
tests/form/FormViewHelperTest.php → Tests/form/FormViewHelperTest.php

0
tests/i18n/I18NTest.php → Tests/i18n/I18NTest.php

0
tests/layout/ErrorLayoutTest.php → Tests/layout/ErrorLayoutTest.php

0
tests/layout/LayoutTest.php → Tests/layout/LayoutTest.php

0
tests/logger/CliLoggerTest.php → Tests/logger/CliLoggerTest.php

0
tests/logger/FileLoggerTest.php → Tests/logger/FileLoggerTest.php

0
tests/model/DbExprTest.php → Tests/model/DbExprTest.php

0
tests/model/DbStatementTest.php → Tests/model/DbStatementTest.php

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save