From e9014a66154ac79758ef1466238a55b266ec72f9 Mon Sep 17 00:00:00 2001 From: Marius Orcsik Date: Mon, 1 Jun 2009 16:28:06 +0200 Subject: [PATCH] * various small changes * from making mysqli a valid db backend * to adding some exception handling to paginator and views --- _res/_libs/controllers/tscontroller.class.php | 2 +- _res/_libs/functions.inc.php | 8 +++++--- _res/_libs/helpers/tspaginator.class.php | 4 ++++ _res/_libs/models/sqldrivers/sqlfactory.class.php | 5 +++-- _res/_libs/views/tstemplate.class.php | 9 ++++++++- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/_res/_libs/controllers/tscontroller.class.php b/_res/_libs/controllers/tscontroller.class.php index ef10d1b..e111525 100644 --- a/_res/_libs/controllers/tscontroller.class.php +++ b/_res/_libs/controllers/tscontroller.class.php @@ -125,7 +125,7 @@ abstract class tsController { if (!empty($regex)) self::$instance->addRegex ($regex); } elseif (!class_exists ($to)) { - trigger_error ($to . 'is not in the include path', E_USER_ERROR); + throw new tsExceptionPackageImport ($to . 'is not in the include path', E_USER_ERROR); } } return self::$instance; diff --git a/_res/_libs/functions.inc.php b/_res/_libs/functions.inc.php index 0792f55..da34535 100644 --- a/_res/_libs/functions.inc.php +++ b/_res/_libs/functions.inc.php @@ -109,11 +109,13 @@ function usingClass ($className) { $classNameLow = strtolower($className); - - $fileIncluded = @include ($classNameLow . '.class.php'); + $sFilePath = $classNameLow . '.class.php'; + $fileIncluded = @include ($sFilePath); if ( !$fileIncluded ) { - $fileIncluded = @include ($classNameLow . DIRECTORY_SEPARATOR . $classNameLow . '.class.php'); + $sFilePath = $classNameLow . DIRECTORY_SEPARATOR . $sFilePath; + $fileIncluded = @include ($sFilePath); } + return $fileIncluded; } diff --git a/_res/_libs/helpers/tspaginator.class.php b/_res/_libs/helpers/tspaginator.class.php index dcf3b08..5a6e6b6 100644 --- a/_res/_libs/helpers/tspaginator.class.php +++ b/_res/_libs/helpers/tspaginator.class.php @@ -70,7 +70,11 @@ class tsPaginator extends tsHelperAbstract { $this->template->assign ('url_right', $urlRight); $this->template->assign ('max_pages', $cnt); + try { $this->content = $this->template->fetch ($this->path); + } catch (tsExceptionPackageImport $e) { + // todo + } return $this->content; } diff --git a/_res/_libs/models/sqldrivers/sqlfactory.class.php b/_res/_libs/models/sqldrivers/sqlfactory.class.php index 3a8ec9d..c872304 100644 --- a/_res/_libs/models/sqldrivers/sqlfactory.class.php +++ b/_res/_libs/models/sqldrivers/sqlfactory.class.php @@ -2,9 +2,9 @@ /** * Factory class for data objects */ - +usingPackage ('coreexceptions'); class sqlFactory { - static public $TYPES = array ('postgresql', 'mysql', 'null'); + static public $TYPES = array ('postgresql', 'mysql', 'mysqli', 'null'); static private $instance = false; /** @@ -30,6 +30,7 @@ class sqlFactory { static public function &connect($incString) { if (!sqlFactory::validType ($incString)) { sqlFactory::$instance = new nullSql(); +// throw new tsExceptionUnimplemented ('The database type is invalid'); } if(!(sqlFactory::$instance instanceof fooSqlDriverA)) { diff --git a/_res/_libs/views/tstemplate.class.php b/_res/_libs/views/tstemplate.class.php index d8fe0ec..0f71f6c 100644 --- a/_res/_libs/views/tstemplate.class.php +++ b/_res/_libs/views/tstemplate.class.php @@ -82,7 +82,14 @@ class tsTemplate { public function fetch ($includePath) { ob_start (); - include ($includePath); + if (is_file ($includePath)) { + $bIncluded = @include ($includePath); + } else { + ob_end_clean(); + throw new tsExceptionPackageImport ('Template ' . $includePath . ' could not be located'); + return ''; + } + $this->content = ob_get_contents(); ob_end_clean (); return $this->content; -- 2.11.4.GIT