aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-15 03:30:24 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-15 03:30:24 +0100
commit878e96202e8a22e4857b98e29b0a1fce68eccbc9 (patch)
treef9233c3b48a0cd6e0ac2536ddcc1897201595ad4 /lib
parent4af233e1f736eb2256e5e1696418635165467855 (diff)
Grosse refactorisation pour permettre le chargement automatique des classes
C'est parti de changements pour https://github.com/marienfressinaud/FreshRSS/issues/255 et finalement j'ai continué la refactorisation... Ajout de préfixes FreshRSS_ et Minz_ sur le modèle de SimplePie_. Toutes les classes sont maintenant en chargement automatique (devrait améliorer les performances en évitant de charger plein de classes inutilisées, et faciliter la maintenance). Suppression de set_include_path(). Si souhaité, certaines classes de Minz pourraient être déplacées dans un sous-répertoire, par exemple les exceptions. Tests et relecture nécessaires.
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/ActionException.php9
-rw-r--r--lib/Minz/BadConfigurationException.php9
-rw-r--r--lib/Minz/Cache.php (renamed from lib/minz/Minz_Cache.php)6
-rw-r--r--lib/Minz/ControllerNotActionControllerException.php9
-rw-r--r--lib/Minz/ControllerNotExistException.php9
-rw-r--r--lib/Minz/CurrentPagePaginationException.php8
-rw-r--r--lib/Minz/Exception.php16
-rw-r--r--lib/Minz/FileNotExistException.php8
-rw-r--r--lib/Minz/Log.php (renamed from lib/minz/Minz_Log.php)12
-rw-r--r--[-rwxr-xr-x]lib/Minz/ModelArray.php (renamed from lib/minz/dao/Model_array.php)6
-rw-r--r--[-rwxr-xr-x]lib/Minz/ModelPdo.php (renamed from lib/minz/dao/Model_pdo.php)12
-rw-r--r--[-rwxr-xr-x]lib/Minz/ModelTxt.php (renamed from lib/minz/dao/Model_txt.php)10
-rw-r--r--lib/Minz/PDOConnectionException.php9
-rw-r--r--lib/Minz/PermissionDeniedException.php8
-rw-r--r--lib/Minz/RouteNotFoundException.php16
-rw-r--r--lib/SimplePie_autoloader.php86
-rw-r--r--lib/lib_rss.php45
-rwxr-xr-xlib/minz/ActionController.php4
-rwxr-xr-xlib/minz/Configuration.php60
-rw-r--r--lib/minz/Dispatcher.php54
-rwxr-xr-xlib/minz/Error.php40
-rwxr-xr-xlib/minz/FrontController.php80
-rwxr-xr-xlib/minz/Helper.php2
-rwxr-xr-xlib/minz/Model.php2
-rwxr-xr-xlib/minz/Paginator.php2
-rw-r--r--lib/minz/Request.php16
-rw-r--r--lib/minz/Response.php2
-rwxr-xr-xlib/minz/Router.php34
-rwxr-xr-xlib/minz/Session.php6
-rw-r--r--lib/minz/Translate.php6
-rwxr-xr-xlib/minz/Url.php18
-rwxr-xr-xlib/minz/View.php10
-rw-r--r--lib/minz/exceptions/MinzException.php94
33 files changed, 304 insertions, 404 deletions
diff --git a/lib/Minz/ActionException.php b/lib/Minz/ActionException.php
new file mode 100644
index 000000000..c566a076f
--- /dev/null
+++ b/lib/Minz/ActionException.php
@@ -0,0 +1,9 @@
+<?php
+class Minz_ActionException extends Minz_Exception {
+ public function __construct ($controller_name, $action_name, $code = self::ERROR) {
+ $message = '`' . $action_name . '` cannot be invoked on `'
+ . $controller_name . '`';
+
+ parent::__construct ($message, $code);
+ }
+}
diff --git a/lib/Minz/BadConfigurationException.php b/lib/Minz/BadConfigurationException.php
new file mode 100644
index 000000000..a7b77d687
--- /dev/null
+++ b/lib/Minz/BadConfigurationException.php
@@ -0,0 +1,9 @@
+<?php
+class Minz_BadConfigurationException extends Minz_Exception {
+ public function __construct ($part_missing, $code = self::ERROR) {
+ $message = '`' . $part_missing
+ . '` in the configuration file is missing or is misconfigured';
+
+ parent::__construct ($message, $code);
+ }
+}
diff --git a/lib/minz/Minz_Cache.php b/lib/Minz/Cache.php
index 6848e3350..fcb627eb2 100644
--- a/lib/minz/Minz_Cache.php
+++ b/lib/Minz/Cache.php
@@ -35,7 +35,7 @@ class Minz_Cache {
* Setteurs
*/
public function _fileName () {
- $file = md5 (Request::getURI ());
+ $file = md5 (Minz_Request::getURI ());
$this->file = CACHE_PATH . '/'.$file;
}
@@ -43,7 +43,7 @@ class Minz_Cache {
public function _expire () {
if ($this->exist ()) {
$this->expire = filemtime ($this->file)
- + Configuration::delayCache ();
+ + Minz_Configuration::delayCache ();
}
}
@@ -52,7 +52,7 @@ class Minz_Cache {
* @return true si activé, false sinon
*/
public static function isEnabled () {
- return Configuration::cacheEnabled () && self::$enabled;
+ return Minz_Configuration::cacheEnabled () && self::$enabled;
}
/**
diff --git a/lib/Minz/ControllerNotActionControllerException.php b/lib/Minz/ControllerNotActionControllerException.php
new file mode 100644
index 000000000..535a1377e
--- /dev/null
+++ b/lib/Minz/ControllerNotActionControllerException.php
@@ -0,0 +1,9 @@
+<?php
+class Minz_ControllerNotActionControllerException extends Minz_Exception {
+ public function __construct ($controller_name, $code = self::ERROR) {
+ $message = 'Controller `' . $controller_name
+ . '` isn\'t instance of ActionController';
+
+ parent::__construct ($message, $code);
+ }
+}
diff --git a/lib/Minz/ControllerNotExistException.php b/lib/Minz/ControllerNotExistException.php
new file mode 100644
index 000000000..523867d11
--- /dev/null
+++ b/lib/Minz/ControllerNotExistException.php
@@ -0,0 +1,9 @@
+<?php
+class Minz_ControllerNotExistException extends Minz_Exception {
+ public function __construct ($controller_name, $code = self::ERROR) {
+ $message = 'Controller `' . $controller_name
+ . '` doesn\'t exist';
+
+ parent::__construct ($message, $code);
+ }
+}
diff --git a/lib/Minz/CurrentPagePaginationException.php b/lib/Minz/CurrentPagePaginationException.php
new file mode 100644
index 000000000..74214d879
--- /dev/null
+++ b/lib/Minz/CurrentPagePaginationException.php
@@ -0,0 +1,8 @@
+<?php
+class Minz_CurrentPagePaginationException extends Minz_Exception {
+ public function __construct ($page) {
+ $message = 'Page number `' . $page . '` doesn\'t exist';
+
+ parent::__construct ($message, self::ERROR);
+ }
+}
diff --git a/lib/Minz/Exception.php b/lib/Minz/Exception.php
new file mode 100644
index 000000000..b5e71e0d8
--- /dev/null
+++ b/lib/Minz/Exception.php
@@ -0,0 +1,16 @@
+<?php
+class Minz_Exception extends Exception {
+ const ERROR = 0;
+ const WARNING = 10;
+ const NOTICE = 20;
+
+ public function __construct ($message, $code = self::ERROR) {
+ if ($code != Minz_Exception::ERROR
+ && $code != Minz_Exception::WARNING
+ && $code != Minz_Exception::NOTICE) {
+ $code = Minz_Exception::ERROR;
+ }
+
+ parent::__construct ($message, $code);
+ }
+}
diff --git a/lib/Minz/FileNotExistException.php b/lib/Minz/FileNotExistException.php
new file mode 100644
index 000000000..df2b8ff6c
--- /dev/null
+++ b/lib/Minz/FileNotExistException.php
@@ -0,0 +1,8 @@
+<?php
+class Minz_FileNotExistException extends Minz_Exception {
+ public function __construct ($file_name, $code = self::ERROR) {
+ $message = 'File doesn\'t exist : `' . $file_name.'`';
+
+ parent::__construct ($message, $code);
+ }
+}
diff --git a/lib/minz/Minz_Log.php b/lib/Minz/Log.php
index 12005aa88..a9b657271 100644
--- a/lib/minz/Minz_Log.php
+++ b/lib/Minz/Log.php
@@ -31,10 +31,10 @@ class Minz_Log {
* @param $file_name fichier de log, par défaut LOG_PATH/application.log
*/
public static function record ($information, $level, $file_name = null) {
- $env = Configuration::environment ();
+ $env = Minz_Configuration::environment ();
- if (! ($env === Configuration::SILENT
- || ($env === Configuration::PRODUCTION
+ if (! ($env === Minz_Configuration::SILENT
+ || ($env === Minz_Configuration::PRODUCTION
&& ($level >= Minz_Log::NOTICE)))) {
if (is_null ($file_name)) {
$file_name = LOG_PATH . '/application.log';
@@ -57,7 +57,7 @@ class Minz_Log {
$level_label = 'unknown';
}
- if ($env == Configuration::PRODUCTION) {
+ if ($env == Minz_Configuration::PRODUCTION) {
$file = @fopen ($file_name, 'a');
} else {
$file = fopen ($file_name, 'a');
@@ -70,9 +70,9 @@ class Minz_Log {
fwrite ($file, $log);
fclose ($file);
} else {
- throw new PermissionDeniedException (
+ throw new Minz_PermissionDeniedException (
$file_name,
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
}
diff --git a/lib/minz/dao/Model_array.php b/lib/Minz/ModelArray.php
index 0b9ccf071..4ba022143 100755..100644
--- a/lib/minz/dao/Model_array.php
+++ b/lib/Minz/ModelArray.php
@@ -7,7 +7,7 @@
/**
* La classe Model_array représente le modèle interragissant avec les fichiers de type texte gérant des tableaux php
*/
-class Model_array extends Model_txt {
+class Minz_ModelArray extends Minz_ModelTxt {
/**
* $array Le tableau php contenu dans le fichier $nameFile
*/
@@ -22,7 +22,7 @@ class Model_array extends Model_txt {
parent::__construct ($nameFile);
if (!$this->getLock ('read')) {
- throw new PermissionDeniedException ($this->filename);
+ throw new Minz_PermissionDeniedException ($this->filename);
} else {
$this->array = include ($this->filename);
$this->releaseLock ();
@@ -41,7 +41,7 @@ class Model_array extends Model_txt {
**/
public function writeFile ($array) {
if (!$this->getLock ('write')) {
- throw new PermissionDeniedException ($this->namefile);
+ throw new Minz_PermissionDeniedException ($this->namefile);
} else {
$this->erase ();
diff --git a/lib/minz/dao/Model_pdo.php b/lib/Minz/ModelPdo.php
index a93291fc8..9655539b2 100755..100644
--- a/lib/minz/dao/Model_pdo.php
+++ b/lib/Minz/ModelPdo.php
@@ -8,7 +8,7 @@
* La classe Model_sql représente le modèle interragissant avec les bases de données
* Seul la connexion MySQL est prise en charge pour le moment
*/
-class Model_pdo {
+class Minz_ModelPdo {
/**
* Partage la connexion à la base de données entre toutes les instances.
@@ -35,7 +35,7 @@ class Model_pdo {
return;
}
- $db = Configuration::dataBase ();
+ $db = Minz_Configuration::dataBase ();
$driver_options = null;
try {
@@ -60,13 +60,13 @@ class Model_pdo {
);
self::$sharedBd = $this->bd;
- $userPrefix = Configuration::currentUser ();
+ $userPrefix = Minz_Configuration::currentUser ();
$this->prefix = $db['prefix'] . (empty($userPrefix) ? '' : ($userPrefix . '_'));
self::$sharedPrefix = $this->prefix;
} catch (Exception $e) {
- throw new PDOConnectionException (
+ throw new Minz_PDOConnectionException (
$string,
- $db['user'], MinzException::ERROR
+ $db['user'], Minz_Exception::ERROR
);
}
}
@@ -82,7 +82,7 @@ class Model_pdo {
}
public function size() {
- $db = Configuration::dataBase ();
+ $db = Minz_Configuration::dataBase ();
$sql = 'SELECT SUM(data_length + index_length) FROM information_schema.TABLES WHERE table_schema = ?';
$stm = $this->bd->prepare ($sql);
$values = array ($db['base']);
diff --git a/lib/minz/dao/Model_txt.php b/lib/Minz/ModelTxt.php
index aed653068..8c5973f4d 100755..100644
--- a/lib/minz/dao/Model_txt.php
+++ b/lib/Minz/ModelTxt.php
@@ -7,7 +7,7 @@
/**
* La classe Model_txt représente le modèle interragissant avec les fichiers de type texte
*/
-class Model_txt {
+class Minz_ModelTxt {
/**
* $file représente le fichier à ouvrir
*/
@@ -28,18 +28,18 @@ class Model_txt {
public function __construct ($nameFile, $mode = 'a+') {
$this->filename = $nameFile;
if (!file_exists($this->filename)) {
- throw new FileNotExistException (
+ throw new Minz_FileNotExistException (
$this->filename,
- MinzException::WARNING
+ Minz_Exception::WARNING
);
}
$this->file = @fopen ($this->filename, $mode);
if (!$this->file) {
- throw new PermissionDeniedException (
+ throw new Minz_PermissionDeniedException (
$this->filename,
- MinzException::WARNING
+ Minz_Exception::WARNING
);
}
}
diff --git a/lib/Minz/PDOConnectionException.php b/lib/Minz/PDOConnectionException.php
new file mode 100644
index 000000000..faf2e0fe9
--- /dev/null
+++ b/lib/Minz/PDOConnectionException.php
@@ -0,0 +1,9 @@
+<?php
+class Minz_PDOConnectionException extends Minz_Exception {
+ public function __construct ($string_connection, $user, $code = self::ERROR) {
+ $message = 'Access to database is denied for `' . $user . '`'
+ . ' (`' . $string_connection . '`)';
+
+ parent::__construct ($message, $code);
+ }
+}
diff --git a/lib/Minz/PermissionDeniedException.php b/lib/Minz/PermissionDeniedException.php
new file mode 100644
index 000000000..61be530d3
--- /dev/null
+++ b/lib/Minz/PermissionDeniedException.php
@@ -0,0 +1,8 @@
+<?php
+class Minz_PermissionDeniedException extends Minz_Exception {
+ public function __construct ($file_name, $code = self::ERROR) {
+ $message = 'Permission is denied for `' . $file_name.'`';
+
+ parent::__construct ($message, $code);
+ }
+}
diff --git a/lib/Minz/RouteNotFoundException.php b/lib/Minz/RouteNotFoundException.php
new file mode 100644
index 000000000..dc4f6fbad
--- /dev/null
+++ b/lib/Minz/RouteNotFoundException.php
@@ -0,0 +1,16 @@
+<?php
+class Minz_RouteNotFoundException extends Minz_Exception {
+ private $route;
+
+ public function __construct ($route, $code = self::ERROR) {
+ $this->route = $route;
+
+ $message = 'Route `' . $route . '` not found';
+
+ parent::__construct ($message, $code);
+ }
+
+ public function route () {
+ return $this->route;
+ }
+}
diff --git a/lib/SimplePie_autoloader.php b/lib/SimplePie_autoloader.php
deleted file mode 100644
index 3f67635b0..000000000
--- a/lib/SimplePie_autoloader.php
+++ /dev/null
@@ -1,86 +0,0 @@
-<?php
-/**
- * SimplePie
- *
- * A PHP-Based RSS and Atom Feed Framework.
- * Takes the hard work out of managing a complete RSS/Atom solution.
- *
- * Copyright (c) 2004-2009, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * * Neither the name of the SimplePie Team nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
- * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * @package SimplePie
- * @version 1.3.1
- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
- * @author Ryan Parman
- * @author Geoffrey Sneddon
- * @author Ryan McCue
- * @link http://simplepie.org/ SimplePie
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
- */
-
-
-// autoloader
-spl_autoload_register(array(new SimplePie_Autoloader(), 'autoload'));
-
-if (!class_exists('SimplePie'))
-{
- trigger_error('Autoloader not registered properly', E_USER_ERROR);
-}
-
-/**
- * Autoloader class
- *
- * @package SimplePie
- * @subpackage API
- */
-class SimplePie_Autoloader
-{
- /**
- * Constructor
- */
- public function __construct()
- {
- $this->path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'SimplePie';
- }
-
- /**
- * Autoloader
- *
- * @param string $class The name of the class to attempt to load.
- */
- public function autoload($class)
- {
- // Only load the class if it starts with "SimplePie"
- if (strpos($class, 'SimplePie') !== 0)
- {
- return;
- }
-
- $filename = $this->path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
- include $filename;
- }
-}
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 4f5b90b61..2fdfd4bd8 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -15,6 +15,31 @@ if (!function_exists('json_encode')) {
}
}
+//<Auto-loading>
+function classAutoloader($class) {
+ if (strpos($class, 'FreshRSS') === 0) {
+ $components = explode('_', $class);
+ switch (count($components)) {
+ case 1:
+ include(APP_PATH . '/' . $components[0] . '.php');
+ return;
+ case 2:
+ include(APP_PATH . '/Models/' . $components[1] . '.php');
+ return;
+ case 3: //Controllers, Exceptions
+ include(APP_PATH . '/' . $components[2] . 's/' . $components[1] . $components[2] . '.php');
+ return;
+ }
+ } elseif (strpos($class, 'Minz') === 0) {
+ include(LIB_PATH . '/' . str_replace('_', '/', $class) . '.php');
+ } elseif (strpos($class, 'SimplePie') === 0) {
+ include(LIB_PATH . '/SimplePie/' . str_replace('_', '/', $class) . '.php');
+ }
+}
+
+spl_autoload_register('classAutoloader');
+//</Auto-loading>
+
function checkUrl($url) {
if (empty ($url)) {
return '';
@@ -33,7 +58,7 @@ function checkUrl($url) {
// vérifie qu'on est connecté
function is_logged () {
- return Session::param ('mail') != false;
+ return Minz_Session::param ('mail') != false;
}
// vérifie que le système d'authentification est configuré
@@ -63,11 +88,11 @@ function formatBytes($bytes, $precision = 2, $system = 'IEC') {
}
function timestamptodate ($t, $hour = true) {
- $month = Translate::t (date('M', $t));
+ $month = Minz_Translate::t (date('M', $t));
if ($hour) {
- $date = Translate::t ('format_date_hour', $month);
+ $date = Minz_Translate::t ('format_date_hour', $month);
} else {
- $date = Translate::t ('format_date', $month);
+ $date = Minz_Translate::t ('format_date', $month);
}
return @date ($date, $t);
@@ -123,10 +148,10 @@ function opml_import ($xml) {
$opml = simplexml_import_dom($dom);
if (!$opml) {
- throw new OpmlException ();
+ throw new FreshRSS_Opml_Exception ();
}
- $catDAO = new CategoryDAO();
+ $catDAO = new FreshRSS_CategoryDAO();
$catDAO->checkDefault();
$defCat = $catDAO->getDefault();
@@ -152,10 +177,10 @@ function opml_import ($xml) {
// Y ne sera pas ajouté et le flux non plus vu que l'id
// de sa catégorie n'exisera pas
$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
- $catDAO = new CategoryDAO ();
+ $catDAO = new FreshRSS_CategoryDAO ();
$cat = $catDAO->searchByName ($title);
if ($cat === false) {
- $cat = new Category ($title);
+ $cat = new FreshRSS_Category ($title);
$values = array (
'name' => $cat->name (),
'color' => $cat->color ()
@@ -204,7 +229,7 @@ function getFeed ($outline, $cat_id) {
$title = (string) $outline['title'];
}
$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
- $feed = new Feed ($url);
+ $feed = new FreshRSS_Feed ($url);
$feed->_category ($cat_id);
$feed->_name ($title);
if (isset($outline['htmlUrl'])) {
@@ -250,7 +275,7 @@ function get_content_by_parsing ($url, $path) {
function lazyimg($content) {
return preg_replace(
'/<img([^>]+?)src=[\'"]([^"\']+)[\'"]([^>]*)>/i',
- '<img$1src="' . Url::display('/themes/icons/grey.gif') . '" data-original="$2"$3>',
+ '<img$1src="' . Minz_Url::display('/themes/icons/grey.gif') . '" data-original="$2"$3>',
$content
);
}
diff --git a/lib/minz/ActionController.php b/lib/minz/ActionController.php
index ab9389dbd..409d9611f 100755
--- a/lib/minz/ActionController.php
+++ b/lib/minz/ActionController.php
@@ -7,7 +7,7 @@
/**
* La classe ActionController représente le contrôleur de l'application
*/
-class ActionController {
+class Minz_ActionController {
protected $router;
protected $view;
@@ -18,7 +18,7 @@ class ActionController {
*/
public function __construct ($router) {
$this->router = $router;
- $this->view = new View ();
+ $this->view = new Minz_View ();
$this->view->attributeParams ();
}
diff --git a/lib/minz/Configuration.php b/lib/minz/Configuration.php
index 7d6e3743e..9fc913964 100755
--- a/lib/minz/Configuration.php
+++ b/lib/minz/Configuration.php
@@ -7,7 +7,7 @@
/**
* La classe Configuration permet de gérer la configuration de l'application
*/
-class Configuration {
+class Minz_Configuration {
const CONF_PATH_NAME = '/application.ini';
/**
@@ -43,7 +43,7 @@ class Configuration {
* - base le nom de la base de données
*/
private static $sel_application = '';
- private static $environment = Configuration::PRODUCTION;
+ private static $environment = Minz_Configuration::PRODUCTION;
private static $base_url = '';
private static $use_url_rewriting = false;
private static $title = '';
@@ -99,30 +99,30 @@ class Configuration {
/**
* Initialise les variables de configuration
- * @exception FileNotExistException si le CONF_PATH_NAME n'existe pas
- * @exception BadConfigurationException si CONF_PATH_NAME mal formaté
+ * @exception Minz_FileNotExistException si le CONF_PATH_NAME n'existe pas
+ * @exception Minz_BadConfigurationException si CONF_PATH_NAME mal formaté
*/
public static function init () {
try {
self::parseFile ();
self::setReporting ();
- } catch (FileNotExistException $e) {
+ } catch (Minz_FileNotExistException $e) {
throw $e;
- } catch (BadConfigurationException $e) {
+ } catch (Minz_BadConfigurationException $e) {
throw $e;
}
}
/**
* Parse un fichier de configuration de type ".ini"
- * @exception FileNotExistException si le CONF_PATH_NAME n'existe pas
- * @exception BadConfigurationException si CONF_PATH_NAME mal formaté
+ * @exception Minz_FileNotExistException si le CONF_PATH_NAME n'existe pas
+ * @exception Minz_BadConfigurationException si CONF_PATH_NAME mal formaté
*/
private static function parseFile () {
if (!file_exists (DATA_PATH . self::CONF_PATH_NAME)) {
- throw new FileNotExistException (
+ throw new Minz_FileNotExistException (
DATA_PATH . self::CONF_PATH_NAME,
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
@@ -132,17 +132,17 @@ class Configuration {
);
if (!$ini_array) {
- throw new PermissionDeniedException (
+ throw new Minz_PermissionDeniedException (
DATA_PATH . self::CONF_PATH_NAME,
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
// [general] est obligatoire
if (!isset ($ini_array['general'])) {
- throw new BadConfigurationException (
+ throw new Minz_BadConfigurationException (
'[general]',
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
$general = $ini_array['general'];
@@ -150,9 +150,9 @@ class Configuration {
// sel_application est obligatoire
if (!isset ($general['sel_application'])) {
- throw new BadConfigurationException (
+ throw new Minz_BadConfigurationException (
'sel_application',
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
self::$sel_application = $general['sel_application'];
@@ -160,18 +160,18 @@ class Configuration {
if (isset ($general['environment'])) {
switch ($general['environment']) {
case 'silent':
- self::$environment = Configuration::SILENT;
+ self::$environment = Minz_Configuration::SILENT;
break;
case 'development':
- self::$environment = Configuration::DEVELOPMENT;
+ self::$environment = Minz_Configuration::DEVELOPMENT;
break;
case 'production':
- self::$environment = Configuration::PRODUCTION;
+ self::$environment = Minz_Configuration::PRODUCTION;
break;
default:
- throw new BadConfigurationException (
+ throw new Minz_BadConfigurationException (
'environment',
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
@@ -194,7 +194,7 @@ class Configuration {
if (CACHE_PATH === false && self::$cache_enabled) {
throw new FileNotExistException (
'CACHE_PATH',
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
}
@@ -213,27 +213,27 @@ class Configuration {
}
if ($db) {
if (!isset ($db['host'])) {
- throw new BadConfigurationException (
+ throw new Minz_BadConfigurationException (
'host',
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
if (!isset ($db['user'])) {
- throw new BadConfigurationException (
+ throw new Minz_BadConfigurationException (
'user',
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
if (!isset ($db['password'])) {
- throw new BadConfigurationException (
+ throw new Minz_BadConfigurationException (
'password',
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
if (!isset ($db['base'])) {
- throw new BadConfigurationException (
+ throw new Minz_BadConfigurationException (
'base',
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
diff --git a/lib/minz/Dispatcher.php b/lib/minz/Dispatcher.php
index 0cfdd8e75..2898b5f00 100644
--- a/lib/minz/Dispatcher.php
+++ b/lib/minz/Dispatcher.php
@@ -9,8 +9,8 @@
* déterminée dans la Request
* C'est un singleton
*/
-class Dispatcher {
- const CONTROLLERS_PATH_NAME = '/controllers';
+class Minz_Dispatcher {
+ const CONTROLLERS_PATH_NAME = '/Controllers';
/* singleton */
private static $instance = null;
@@ -23,7 +23,7 @@ class Dispatcher {
*/
public static function getInstance ($router) {
if (is_null (self::$instance)) {
- self::$instance = new Dispatcher ($router);
+ self::$instance = new Minz_Dispatcher ($router);
}
return self::$instance;
}
@@ -38,7 +38,7 @@ class Dispatcher {
/**
* Lance le controller indiqué dans Request
* Remplit le body de Response à partir de la Vue
- * @exception MinzException
+ * @exception Minz_Exception
*/
public function run () {
$cache = new Minz_Cache();
@@ -53,29 +53,25 @@ class Dispatcher {
$cache->render ();
$text = ob_get_clean();
} else {
- while (Request::$reseted) {
- Request::$reseted = false;
+ while (Minz_Request::$reseted) {
+ Minz_Request::$reseted = false;
try {
- $this->createController (
- Request::controllerName ()
- . 'Controller'
- );
-
+ $this->createController ('FreshRSS_' . Minz_Request::controllerName () . '_Controller');
$this->controller->init ();
$this->controller->firstAction ();
$this->launchAction (
- Request::actionName ()
+ Minz_Request::actionName ()
. 'Action'
);
$this->controller->lastAction ();
- if (!Request::$reseted) {
+ if (!Minz_Request::$reseted) {
ob_start ();
$this->controller->view ()->build ();
$text = ob_get_clean();
}
- } catch (MinzException $e) {
+ } catch (Minz_Exception $e) {
throw $e;
}
}
@@ -85,14 +81,12 @@ class Dispatcher {
}
}
- Response::setBody ($text);
+ Minz_Response::setBody ($text);
}
/**
* Instancie le Controller
* @param $controller_name le nom du controller à instancier
- * @exception FileNotExistException le fichier correspondant au
- * > controller n'existe pas
* @exception ControllerNotExistException le controller n'existe pas
* @exception ControllerNotActionControllerException controller n'est
* > pas une instance de ActionController
@@ -101,26 +95,18 @@ class Dispatcher {
$filename = APP_PATH . self::CONTROLLERS_PATH_NAME . '/'
. $controller_name . '.php';
- if (!file_exists ($filename)) {
- throw new FileNotExistException (
- $filename,
- MinzException::ERROR
- );
- }
- require_once ($filename);
-
if (!class_exists ($controller_name)) {
- throw new ControllerNotExistException (
+ throw new Minz_ControllerNotExistException (
$controller_name,
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
$this->controller = new $controller_name ($this->router);
- if (! ($this->controller instanceof ActionController)) {
- throw new ControllerNotActionControllerException (
+ if (! ($this->controller instanceof Minz_ActionController)) {
+ throw new Minz_ControllerNotActionControllerException (
$controller_name,
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
}
@@ -129,18 +115,18 @@ class Dispatcher {
* Lance l'action sur le controller du dispatcher
* @param $action_name le nom de l'action
* @exception ActionException si on ne peut pas exécuter l'action sur
- * > le controller
+ * le controller
*/
private function launchAction ($action_name) {
- if (!Request::$reseted) {
+ if (!Minz_Request::$reseted) {
if (!is_callable (array (
$this->controller,
$action_name
))) {
- throw new ActionException (
+ throw new Minz_ActionException (
get_class ($this->controller),
$action_name,
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
call_user_func (array (
diff --git a/lib/minz/Error.php b/lib/minz/Error.php
index 0e8c2f60b..1ad0d313c 100755
--- a/lib/minz/Error.php
+++ b/lib/minz/Error.php
@@ -1,5 +1,5 @@
<?php
-/**
+/**
* MINZ - Copyright 2011 Marien Fressinaud
* Sous licence AGPL3 <http://www.gnu.org/licenses/>
*/
@@ -7,7 +7,7 @@
/**
* La classe Error permet de lancer des erreurs HTTP
*/
-class Error {
+class Minz_Error {
public function __construct () { }
/**
@@ -21,28 +21,28 @@ class Error {
*/
public static function error ($code = 404, $logs = array (), $redirect = false) {
$logs = self::processLogs ($logs);
- $error_filename = APP_PATH . '/controllers/errorController.php';
-
+ $error_filename = APP_PATH . '/Controllers/ErrorController.php';
+
if (file_exists ($error_filename)) {
$params = array (
'code' => $code,
'logs' => $logs
);
-
- Response::setHeader ($code);
+
+ Minz_Response::setHeader ($code);
if ($redirect) {
- Request::forward (array (
+ Minz_Request::forward (array (
'c' => 'error'
), true);
} else {
- Request::forward (array (
+ Minz_Request::forward (array (
'c' => 'error',
'params' => $params
), false);
}
} else {
$text = '<h1>An error occured</h1>'."\n";
-
+
if (!empty ($logs)) {
$text .= '<ul>'."\n";
foreach ($logs as $log) {
@@ -50,14 +50,14 @@ class Error {
}
$text .= '</ul>'."\n";
}
-
- Response::setHeader ($code);
- Response::setBody ($text);
- Response::send ();
+
+ Minz_Response::setHeader ($code);
+ Minz_Response::setBody ($text);
+ Minz_Response::send ();
exit ();
}
}
-
+
/**
* Permet de retourner les logs de façon à n'avoir que
* ceux que l'on veut réellement
@@ -66,12 +66,12 @@ class Error {
* > en fonction de l'environment
*/
private static function processLogs ($logs) {
- $env = Configuration::environment ();
+ $env = Minz_Configuration::environment ();
$logs_ok = array ();
$error = array ();
$warning = array ();
$notice = array ();
-
+
if (isset ($logs['error'])) {
$error = $logs['error'];
}
@@ -81,14 +81,14 @@ class Error {
if (isset ($logs['notice'])) {
$notice = $logs['notice'];
}
-
- if ($env == Configuration::PRODUCTION) {
+
+ if ($env == Minz_Configuration::PRODUCTION) {
$logs_ok = $error;
}
- if ($env == Configuration::DEVELOPMENT) {
+ if ($env == Minz_Configuration::DEVELOPMENT) {
$logs_ok = array_merge ($error, $warning, $notice);
}
-
+
return $logs_ok;
}
}
diff --git a/lib/minz/FrontController.php b/lib/minz/FrontController.php
index d48d43d04..eb9835fe5 100755
--- a/lib/minz/FrontController.php
+++ b/lib/minz/FrontController.php
@@ -2,109 +2,79 @@
# ***** BEGIN LICENSE BLOCK *****
# MINZ - a free PHP Framework like Zend Framework
# Copyright (C) 2011 Marien Fressinaud
-#
+#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
-#
+#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# ***** END LICENSE BLOCK *****
/**
- * La classe FrontController est le noyau du framework, elle lance l'application
+ * La classe FrontController est le Dispatcher du framework, elle lance l'application
* Elle est appelée en général dans le fichier index.php à la racine du serveur
*/
-class FrontController {
+class Minz_FrontController {
protected $dispatcher;
protected $router;
-
+
/**
* Constructeur
* Initialise le router et le dispatcher
*/
public function __construct () {
- $this->loadLib ();
-
if (LOG_PATH === false) {
$this->killApp ('Path doesn\'t exist : LOG_PATH');
}
-
+
try {
- Configuration::init ();
+ Minz_Configuration::init ();
- Request::init ();
+ Minz_Request::init ();
- $this->router = new Router ();
+ $this->router = new Minz_Router ();
$this->router->init ();
- } catch (RouteNotFoundException $e) {
+ } catch (Minz_RouteNotFoundException $e) {
Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
- Error::error (
+ Minz_Error::error (
404,
array ('error' => array ($e->getMessage ()))
);
- } catch (MinzException $e) {
+ } catch (Minz_Exception $e) {
Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
$this->killApp ($e->getMessage ());
}
-
- $this->dispatcher = Dispatcher::getInstance ($this->router);
- }
-
- /**
- * Inclue les fichiers de la librairie
- */
- private function loadLib () {
- require ('ActionController.php');
- require ('Minz_Cache.php');
- require ('Configuration.php');
- require ('Dispatcher.php');
- require ('Error.php');
- require ('Helper.php');
- require ('Minz_Log.php');
- require ('Model.php');
- require ('Paginator.php');
- require ('Request.php');
- require ('Response.php');
- require ('Router.php');
- require ('Session.php');
- require ('Translate.php');
- require ('Url.php');
- require ('View.php');
-
- require ('dao/Model_pdo.php');
- require ('dao/Model_txt.php');
- require ('dao/Model_array.php');
-
- require ('exceptions/MinzException.php');
+
+ $this->dispatcher = Minz_Dispatcher::getInstance ($this->router);
}
-
+
/**
* Démarre l'application (lance le dispatcher et renvoie la réponse
*/
public function run () {
try {
$this->dispatcher->run ();
- Response::send ();
- } catch (MinzException $e) {
+ Minz_Response::send ();
+ } catch (Minz_Exception $e) {
try {
Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
- } catch (PermissionDeniedException $e) {
+ } catch (Minz_PermissionDeniedException $e) {
$this->killApp ($e->getMessage ());
}
- if ($e instanceof FileNotExistException ||
- $e instanceof ControllerNotExistException ||
- $e instanceof ControllerNotActionControllerException ||
- $e instanceof ActionException) {
- Error::error (
+ if ($e instanceof Minz_FileNotExistException ||
+ $e instanceof Minz_ControllerNotExistException ||
+ $e instanceof Minz_ControllerNotActionControllerException ||
+ $e instanceof Minz_ActionException) {
+ Minz_Error::error (
404,
array ('error' => array ($e->getMessage ())),
true
@@ -114,7 +84,7 @@ class FrontController {
}
}
}
-
+
/**
* Permet d'arrêter le programme en urgence
*/
diff --git a/lib/minz/Helper.php b/lib/minz/Helper.php
index 4f64ba218..b058211d3 100755
--- a/lib/minz/Helper.php
+++ b/lib/minz/Helper.php
@@ -7,7 +7,7 @@
/**
* La classe Helper représente une aide pour des tâches récurrentes
*/
-class Helper {
+class Minz_Helper {
/**
* Annule les effets des magic_quotes pour une variable donnée
* @param $var variable à traiter (tableau ou simple variable)
diff --git a/lib/minz/Model.php b/lib/minz/Model.php
index 37fc19ed1..adbaba942 100755
--- a/lib/minz/Model.php
+++ b/lib/minz/Model.php
@@ -7,6 +7,6 @@
/**
* La classe Model représente un modèle de l'application (représentation MVC)
*/
-class Model {
+class Minz_Model {
}
diff --git a/lib/minz/Paginator.php b/lib/minz/Paginator.php
index 1a8376e75..5858e76a5 100755
--- a/lib/minz/Paginator.php
+++ b/lib/minz/Paginator.php
@@ -7,7 +7,7 @@
/**
* La classe Paginator permet de gérer la pagination de l'application facilement
*/
-class Paginator {
+class Minz_Paginator {
/**
* $items tableau des éléments à afficher/gérer
*/
diff --git a/lib/minz/Request.php b/lib/minz/Request.php
index 3e508d8f1..c8ffa4a42 100644
--- a/lib/minz/Request.php
+++ b/lib/minz/Request.php
@@ -7,7 +7,7 @@
/**
* Request représente la requête http
*/
-class Request {
+class Minz_Request {
private static $controller_name = '';
private static $action_name = '';
private static $params = array ();
@@ -96,7 +96,7 @@ class Request {
* @return la base de l'url
*/
public static function getBaseUrl () {
- return Configuration::baseUrl ();
+ return Minz_Configuration::baseUrl ();
}
/**
@@ -124,10 +124,10 @@ class Request {
* > sinon, le dispatcher recharge en interne
*/
public static function forward ($url = array (), $redirect = false) {
- $url = Url::checkUrl ($url);
+ $url = Minz_Url::checkUrl ($url);
if ($redirect) {
- header ('Location: ' . Url::display ($url, 'php'));
+ header ('Location: ' . Minz_Url::display ($url, 'php'));
exit ();
} else {
self::$reseted = true;
@@ -185,9 +185,9 @@ class Request {
*/
private static function magicQuotesOff () {
if (get_magic_quotes_gpc ()) {
- $_GET = Helper::stripslashes_r ($_GET);
- $_POST = Helper::stripslashes_r ($_POST);
- $_COOKIE = Helper::stripslashes_r ($_COOKIE);
+ $_GET = Minz_Helper::stripslashes_r ($_GET);
+ $_POST = Minz_Helper::stripslashes_r ($_POST);
+ $_COOKIE = Minz_Helper::stripslashes_r ($_COOKIE);
}
}
@@ -195,5 +195,3 @@ class Request {
return !empty ($_POST) || !empty ($_FILES);
}
}
-
-
diff --git a/lib/minz/Response.php b/lib/minz/Response.php
index fcf53c5b1..f8ea3d946 100644
--- a/lib/minz/Response.php
+++ b/lib/minz/Response.php
@@ -7,7 +7,7 @@
/**
* Response représente la requête http renvoyée à l'utilisateur
*/
-class Response {
+class Minz_Response {
private static $header = 'HTTP/1.0 200 OK';
private static $body = '';
diff --git a/lib/minz/Router.php b/lib/minz/Router.php
index c5d6f5baa..1ccd72597 100755
--- a/lib/minz/Router.php
+++ b/lib/minz/Router.php
@@ -8,7 +8,7 @@
* La classe Router gère le routage de l'application
* Les routes sont définies dans APP_PATH.'/configuration/routes.php'
*/
-class Router {
+class Minz_Router {
const ROUTES_PATH_NAME = '/configuration/routes.php';
private $routes = array ();
@@ -19,7 +19,7 @@ class Router {
* et que l'on utilise l'url rewriting
*/
public function __construct () {
- if (Configuration::useUrlRewriting ()) {
+ if (Minz_Configuration::useUrlRewriting ()) {
if (file_exists (APP_PATH . self::ROUTES_PATH_NAME)) {
$routes = include (
APP_PATH . self::ROUTES_PATH_NAME
@@ -34,9 +34,9 @@ class Router {
$routes
);
} else {
- throw new FileNotExistException (
+ throw new Minz_FileNotExistException (
self::ROUTES_PATH_NAME,
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
}
@@ -51,10 +51,10 @@ class Router {
public function init () {
$url = array ();
- if (Configuration::useUrlRewriting ()) {
+ if (Minz_Configuration::useUrlRewriting ()) {
try {
$url = $this->buildWithRewriting ();
- } catch (RouteNotFoundException $e) {
+ } catch (Minz_RouteNotFoundException $e) {
throw $e;
}
} else {
@@ -63,10 +63,10 @@ class Router {
$url['params'] = array_merge (
$url['params'],
- Request::fetchPOST ()
+ Minz_Request::fetchPOST ()
);
- Request::forward ($url);
+ Minz_Request::forward ($url);
}
/**
@@ -77,15 +77,15 @@ class Router {
public function buildWithoutRewriting () {
$url = array ();
- $url['c'] = Request::fetchGET (
+ $url['c'] = Minz_Request::fetchGET (
'c',
- Request::defaultControllerName ()
+ Minz_Request::defaultControllerName ()
);
- $url['a'] = Request::fetchGET (
+ $url['a'] = Minz_Request::fetchGET (
'a',
- Request::defaultActionName ()
+ Minz_Request::defaultActionName ()
);
- $url['params'] = Request::fetchGET ();
+ $url['params'] = Minz_Request::fetchGET ();
// post-traitement
unset ($url['params']['c']);
@@ -103,7 +103,7 @@ class Router {
*/
public function buildWithRewriting () {
$url = array ();
- $uri = Request::getURI ();
+ $uri = Minz_Request::getURI ();
$find = false;
foreach ($this->routes as $route) {
@@ -121,14 +121,14 @@ class Router {
}
if (!$find && $uri != '/') {
- throw new RouteNotFoundException (
+ throw new Minz_RouteNotFoundException (
$uri,
- MinzException::ERROR
+ Minz_Exception::ERROR
);
}
// post-traitement
- $url = Url::checkUrl ($url);
+ $url = Minz_Url::checkUrl ($url);
return $url;
}
diff --git a/lib/minz/Session.php b/lib/minz/Session.php
index f9c9c6754..878caa556 100755
--- a/lib/minz/Session.php
+++ b/lib/minz/Session.php
@@ -4,7 +4,7 @@
* La classe Session gère la session utilisateur
* C'est un singleton
*/
-class Session {
+class Minz_Session {
/**
* $session stocke les variables de session
*/
@@ -15,7 +15,7 @@ class Session {
*/
public static function init () {
// démarre la session
- session_name (md5 (Configuration::selApplication ()));
+ session_name (md5 (Minz_Configuration::selApplication ()));
session_start ();
if (isset ($_SESSION)) {
@@ -55,7 +55,7 @@ class Session {
if($p == 'language') {
// reset pour remettre à jour le fichier de langue à utiliser
- Translate::reset ();
+ Minz_Translate::reset ();
}
}
}
diff --git a/lib/minz/Translate.php b/lib/minz/Translate.php
index e8cbe4852..e14f783f7 100644
--- a/lib/minz/Translate.php
+++ b/lib/minz/Translate.php
@@ -8,7 +8,7 @@
* La classe Translate se charge de la traduction
* Utilise les fichiers du répertoire /app/i18n/
*/
-class Translate {
+class Minz_Translate {
/**
* $language est la langue à afficher
*/
@@ -25,8 +25,8 @@ class Translate {
* l'enregistre dans $translates
*/
public static function init () {
- $l = Configuration::language ();
- self::$language = Session::param ('language', $l);
+ $l = Minz_Configuration::language ();
+ self::$language = Minz_Session::param ('language', $l);
$l_path = APP_PATH . '/i18n/' . self::$language . '.php';
diff --git a/lib/minz/Url.php b/lib/minz/Url.php
index ce051ebd9..30f7f6231 100755
--- a/lib/minz/Url.php
+++ b/lib/minz/Url.php
@@ -3,7 +3,7 @@
/**
* La classe Url permet de gérer les URL à travers MINZ
*/
-class Url {
+class Minz_Url {
/**
* Affiche une Url formatée selon que l'on utilise l'url_rewriting ou non
* si oui, on cherche dans la table de routage la correspondance pour formater
@@ -29,16 +29,16 @@ class Url {
} else {
$protocol = 'http:';
}
- $url_string = $protocol . '//' . Request::getDomainName () . Request::getBaseUrl ();
+ $url_string = $protocol . '//' . Minz_Request::getDomainName () . Minz_Request::getBaseUrl ();
}
else {
$url_string = '.';
}
if (is_array ($url)) {
- $router = new Router ();
+ $router = new Minz_Router ();
- if (Configuration::useUrlRewriting ()) {
+ if (Minz_Configuration::useUrlRewriting ()) {
$url_string .= $router->printUriRewrited ($url);
} else {
$url_string .= self::printUri ($url, $encodage);
@@ -67,13 +67,13 @@ class Url {
}
if (isset ($url['c'])
- && $url['c'] != Request::defaultControllerName ()) {
+ && $url['c'] != Minz_Request::defaultControllerName ()) {
$uri .= $separator . 'c=' . $url['c'];
$separator = $and;
}
if (isset ($url['a'])
- && $url['a'] != Request::defaultActionName ()) {
+ && $url['a'] != Minz_Request::defaultActionName ()) {
$uri .= $separator . 'a=' . $url['a'];
$separator = $and;
}
@@ -98,10 +98,10 @@ class Url {
if (is_array ($url)) {
if (!isset ($url['c'])) {
- $url_checked['c'] = Request::defaultControllerName ();
+ $url_checked['c'] = Minz_Request::defaultControllerName ();
}
if (!isset ($url['a'])) {
- $url_checked['a'] = Request::defaultActionName ();
+ $url_checked['a'] = Minz_Request::defaultActionName ();
}
if (!isset ($url['params'])) {
$url_checked['params'] = array ();
@@ -125,5 +125,5 @@ function _url ($controller, $action) {
$params[$args[$i]] = $args[$i + 1];
}
- return Url::display (array ('c' => $controller, 'a' => $action, 'params' => $params));
+ return Minz_Url::display (array ('c' => $controller, 'a' => $action, 'params' => $params));
}
diff --git a/lib/minz/View.php b/lib/minz/View.php
index 12202542f..c8d0aefed 100755
--- a/lib/minz/View.php
+++ b/lib/minz/View.php
@@ -7,7 +7,7 @@
/**
* La classe View représente la vue de l'application
*/
-class View {
+class Minz_View {
const VIEWS_PATH_NAME = '/views';
const LAYOUT_PATH_NAME = '/layout';
const LAYOUT_FILENAME = '/layout.phtml';
@@ -28,8 +28,8 @@ class View {
public function __construct () {
$this->view_filename = APP_PATH
. self::VIEWS_PATH_NAME . '/'
- . Request::controllerName () . '/'
- . Request::actionName () . '.phtml';
+ . Minz_Request::controllerName () . '/'
+ . Minz_Request::actionName () . '.phtml';
if (file_exists (APP_PATH
. self::LAYOUT_PATH_NAME
@@ -37,7 +37,7 @@ class View {
$this->use_layout = true;
}
- self::$title = Configuration::title ();
+ self::$title = Minz_Configuration::title ();
}
/**
@@ -232,7 +232,7 @@ class View {
self::$params[$key] = $value;
}
public function attributeParams () {
- foreach (View::$params as $key => $value) {
+ foreach (Minz_View::$params as $key => $value) {
$this->$key = $value;
}
}
diff --git a/lib/minz/exceptions/MinzException.php b/lib/minz/exceptions/MinzException.php
deleted file mode 100644
index 4568c4da8..000000000
--- a/lib/minz/exceptions/MinzException.php
+++ /dev/null
@@ -1,94 +0,0 @@
-<?php
-
-class MinzException extends Exception {
- const ERROR = 0;
- const WARNING = 10;
- const NOTICE = 20;
-
- public function __construct ($message, $code = self::ERROR) {
- if ($code != MinzException::ERROR
- && $code != MinzException::WARNING
- && $code != MinzException::NOTICE) {
- $code = MinzException::ERROR;
- }
-
- parent::__construct ($message, $code);
- }
-}
-
-class PermissionDeniedException extends MinzException {
- public function __construct ($file_name, $code = self::ERROR) {
- $message = 'Permission is denied for `' . $file_name.'`';
-
- parent::__construct ($message, $code);
- }
-}
-class FileNotExistException extends MinzException {
- public function __construct ($file_name, $code = self::ERROR) {
- $message = 'File doesn\'t exist : `' . $file_name.'`';
-
- parent::__construct ($message, $code);
- }
-}
-class BadConfigurationException extends MinzException {
- public function __construct ($part_missing, $code = self::ERROR) {
- $message = '`' . $part_missing
- . '` in the configuration file is missing or is misconfigured';
-
- parent::__construct ($message, $code);
- }
-}
-class ControllerNotExistException extends MinzException {
- public function __construct ($controller_name, $code = self::ERROR) {
- $message = 'Controller `' . $controller_name
- . '` doesn\'t exist';
-
- parent::__construct ($message, $code);
- }
-}
-class ControllerNotActionControllerException extends MinzException {
- public function __construct ($controller_name, $code = self::ERROR) {
- $message = 'Controller `' . $controller_name
- . '` isn\'t instance of ActionController';
-
- parent::__construct ($message, $code);
- }
-}
-class ActionException extends MinzException {
- public function __construct ($controller_name, $action_name, $code = self::ERROR) {
- $message = '`' . $action_name . '` cannot be invoked on `'
- . $controller_name . '`';
-
- parent::__construct ($message, $code);
- }
-}
-class RouteNotFoundException extends MinzException {
- private $route;
-
- public function __construct ($route, $code = self::ERROR) {
- $this->route = $route;
-
- $message = 'Route `' . $route . '` not found';
-
- parent::__construct ($message, $code);
- }
-
- public function route () {
- return $this->route;
- }
-}
-class PDOConnectionException extends MinzException {
- public function __construct ($string_connection, $user, $code = self::ERROR) {
- $message = 'Access to database is denied for `' . $user . '`'
- . ' (`' . $string_connection . '`)';
-
- parent::__construct ($message, $code);
- }
-}
-class CurrentPagePaginationException extends MinzException {
- public function __construct ($page) {
- $message = 'Page number `' . $page . '` doesn\'t exist';
-
- parent::__construct ($message, self::ERROR);
- }
-}