Browse Source

Rewrite standart Exception for just return error. Old functionality of showing statical pages was splitted for two new exceptions: StaticPageException for showing static templates and DynamicPageException for invoking Actions classes

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@30 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
master
aterekhov 16 years ago
parent
commit
b0094984e5
  1. 16
      classes/DynamicPageException.class.php
  2. 12
      classes/PageController.class.php
  3. 18
      classes/StaticPageException.class.php
  4. 2
      init/sys.inc.php

16
classes/DynamicPageException.class.php

@ -0,0 +1,16 @@
<?php
/**
* Эксепшен для выводя результата работы класса
*
* @copyright
* @link
* @package Majestic
* @subpackage Core
* @since
* @version SVN: $Id$
* @filesource $URL$
*/
class DynamicPageException extends Exception
{}
?>

12
classes/PageController.class.php

@ -26,12 +26,18 @@ final class PageController
return $decorator->display($action);
} catch (MJException $e) {
return $e->terminate();
} catch (Exception $e) {
} catch (DynamicPageException $e) {
$decorator_name = DEFAULT_DECORATOR;
$action_name = DEFAULT_ACTION;
$decorator = new $decorator_name;
$action_name = $e->getMessage();
return $decorator->display(new $action_name);
} catch (StaticPageException $e) {
$decorator_name = DEFAULT_DECORATOR;
$decorator = new $decorator_name;
$action_name = DEFAULT_ACTION;
return $decorator->display(new $action_name($e->getMessage()));
} catch (Exception $e) {
return $e->getMessage();
}
}
}

18
classes/StaticPageException.class.php

@ -0,0 +1,18 @@
<?php
/**
* Эксепшен для вывода статических шаблонов
*
* @copyright
* @link
* @package Majestic
* @subpackage Core
* @since
* @version SVN: $Id$
* @filesource $URL$
*/
class StaticPageException extends Exception
{
}
?>

2
init/sys.inc.php

@ -42,6 +42,7 @@ define('STATIC_TPL_PATH', TPL_PATH.'/static');
define('DECORATOR_POSTFIX', 'Decorator');
define('MODEL_POSTFIX', 'Model');
define('ACTION_POSTFIX', 'Action');
define('EXCEPTION_POSTFIX', 'Exception');
define('TIME_NOW', time());
@ -77,6 +78,7 @@ function __autoload($name)
switch ($type) {
case $name:
case EXCEPTION_POSTFIX:
require(CORE_PATH.'/'.$name.'.class.php');
break;
case ACTION_POSTFIX:

Loading…
Cancel
Save