Browse Source

Fix issue #106 : modif nom classes Cache et Log

Passage en Minz_Cache et Minz_Log
Permet d'éviter les redondances quand ces classes sont déjà définies
Je n'utilise pas d'espace de nom parce que beaucoup de boulot et
nécessite obligatoirement php 5.3
Si d'autres classes nécessitent cette modification je le ferai au fur et
à mesure qu'on me remontera les soucis
La version de Minz pour FreshRSS n'est plus compatible avec la version
distribuée à part
Marien Fressinaud 12 years ago
parent
commit
f6d730f9d1

+ 1 - 1
app/controllers/configureController.php

@@ -244,7 +244,7 @@ class configureController extends ActionController {
 					Request::_param ('feeds', $feeds);
 					Request::_param ('feeds', $feeds);
 					Request::forward (array ('c' => 'feed', 'a' => 'massiveImport'));
 					Request::forward (array ('c' => 'feed', 'a' => 'massiveImport'));
 				} catch (OpmlException $e) {
 				} catch (OpmlException $e) {
-					Log::record ($e->getMessage (), Log::ERROR);
+					Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
 
 
 					$notif = array (
 					$notif = array (
 						'type' => 'bad',
 						'type' => 'bad',

+ 5 - 5
app/controllers/feedController.php

@@ -86,14 +86,14 @@ class feedController extends ActionController {
 					$params['id'] = $feed->id ();
 					$params['id'] = $feed->id ();
 				}
 				}
 			} catch (BadUrlException $e) {
 			} catch (BadUrlException $e) {
-				Log::record ($e->getMessage (), Log::ERROR);
+				Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
 				$notif = array (
 				$notif = array (
 					'type' => 'bad',
 					'type' => 'bad',
 					'content' => Translate::t ('invalid_url', $url)
 					'content' => Translate::t ('invalid_url', $url)
 				);
 				);
 				Session::_param ('notification', $notif);
 				Session::_param ('notification', $notif);
 			} catch (FeedException $e) {
 			} catch (FeedException $e) {
-				Log::record ($e->getMessage (), Log::ERROR);
+				Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
 				$notif = array (
 				$notif = array (
 					'type' => 'bad',
 					'type' => 'bad',
 					'content' => Translate::t ('internal_problem_feed')
 					'content' => Translate::t ('internal_problem_feed')
@@ -101,7 +101,7 @@ class feedController extends ActionController {
 				Session::_param ('notification', $notif);
 				Session::_param ('notification', $notif);
 			} catch (FileNotExistException $e) {
 			} catch (FileNotExistException $e) {
 				// Répertoire de cache n'existe pas
 				// Répertoire de cache n'existe pas
-				Log::record ($e->getMessage (), Log::ERROR);
+				Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
 				$notif = array (
 				$notif = array (
 					'type' => 'bad',
 					'type' => 'bad',
 					'content' => Translate::t ('internal_problem_feed')
 					'content' => Translate::t ('internal_problem_feed')
@@ -160,7 +160,7 @@ class feedController extends ActionController {
 				$feedDAO->updateLastUpdate ($feed->id ());
 				$feedDAO->updateLastUpdate ($feed->id ());
 				$flux_update++;
 				$flux_update++;
 			} catch (FeedException $e) {
 			} catch (FeedException $e) {
-				Log::record ($e->getMessage (), Log::ERROR);
+				Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
 				$feedDAO->isInError ($feed->id ());
 				$feedDAO->isInError ($feed->id ());
 			}
 			}
 
 
@@ -264,7 +264,7 @@ class feedController extends ActionController {
 				}
 				}
 			} catch (FeedException $e) {
 			} catch (FeedException $e) {
 				$error = true;
 				$error = true;
-				Log::record ($e->getMessage (), Log::ERROR);
+				Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
 			}
 			}
 		}
 		}
 
 

+ 1 - 1
app/controllers/indexController.php

@@ -59,7 +59,7 @@ class indexController extends ActionController {
 
 
 				$this->view->entryPaginator = $entries;
 				$this->view->entryPaginator = $entries;
 			} catch(EntriesGetterException $e) {
 			} catch(EntriesGetterException $e) {
-				Log::record ($e->getMessage (), Log::NOTICE);
+				Minz_Log::record ($e->getMessage (), Minz_Log::NOTICE);
 				Error::error (
 				Error::error (
 					404,
 					404,
 					array ('error' => array (Translate::t ('page_not_found')))
 					array ('error' => array (Translate::t ('page_not_found')))

+ 3 - 3
app/models/Category.php

@@ -78,7 +78,7 @@ class CategoryDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}
@@ -97,7 +97,7 @@ class CategoryDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}
@@ -112,7 +112,7 @@ class CategoryDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}

+ 7 - 7
app/models/Entry.php

@@ -245,7 +245,7 @@ class EntryDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::NOTICE);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::NOTICE);
 			return false;
 			return false;
 		}
 		}
 	}
 	}
@@ -273,7 +273,7 @@ class EntryDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}
@@ -288,7 +288,7 @@ class EntryDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}
@@ -302,7 +302,7 @@ class EntryDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}
@@ -316,7 +316,7 @@ class EntryDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}
@@ -343,7 +343,7 @@ class EntryDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}
@@ -361,7 +361,7 @@ class EntryDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}

+ 7 - 7
app/models/Feed.php

@@ -258,7 +258,7 @@ class FeedDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}
@@ -286,7 +286,7 @@ class FeedDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}
@@ -304,7 +304,7 @@ class FeedDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}
@@ -321,7 +321,7 @@ class FeedDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}
@@ -345,7 +345,7 @@ class FeedDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}
@@ -360,7 +360,7 @@ class FeedDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}
@@ -374,7 +374,7 @@ class FeedDAO extends Model_pdo {
 			return true;
 			return true;
 		} else {
 		} else {
 			$info = $stm->errorInfo();
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 			return false;
 		}
 		}
 	}
 	}

+ 1 - 1
lib/minz/Cache.php

@@ -7,7 +7,7 @@
 /**
 /**
  * La classe Cache permet de gérer facilement les pages en cache
  * La classe Cache permet de gérer facilement les pages en cache
  */
  */
-class Cache {
+class Minz_Cache {
 	/**
 	/**
 	 * $expire timestamp auquel expire le cache de $url
 	 * $expire timestamp auquel expire le cache de $url
 	 */
 	 */

+ 3 - 3
lib/minz/Dispatcher.php

@@ -41,14 +41,14 @@ class Dispatcher {
 	 * @exception MinzException
 	 * @exception MinzException
 	 */
 	 */
 	public function run () {
 	public function run () {
-		$cache = new Cache();
+		$cache = new Minz_Cache();
 		// Le ob_start est dupliqué : sans ça il y a un bug sous Firefox
 		// Le ob_start est dupliqué : sans ça il y a un bug sous Firefox
 		// ici on l'appelle avec 'ob_gzhandler', après sans.
 		// ici on l'appelle avec 'ob_gzhandler', après sans.
 		// Vraisemblablement la compression fonctionne mais c'est sale
 		// Vraisemblablement la compression fonctionne mais c'est sale
 		// J'ignore les effets de bord :(
 		// J'ignore les effets de bord :(
 		ob_start ('ob_gzhandler');
 		ob_start ('ob_gzhandler');
 
 
-		if (Cache::isEnabled () && !$cache->expired ()) {
+		if (Minz_Cache::isEnabled () && !$cache->expired ()) {
 			ob_start ();
 			ob_start ();
 			$cache->render ();
 			$cache->render ();
 			$text = ob_get_clean();
 			$text = ob_get_clean();
@@ -80,7 +80,7 @@ class Dispatcher {
 				}
 				}
 			}
 			}
 
 
-			if (Cache::isEnabled ()) {
+			if (Minz_Cache::isEnabled ()) {
 				$cache->cache ($text);
 				$cache->cache ($text);
 			}
 			}
 		}
 		}

+ 3 - 3
lib/minz/FrontController.php

@@ -45,13 +45,13 @@ class FrontController {
 			$this->router = new Router ();
 			$this->router = new Router ();
 			$this->router->init ();
 			$this->router->init ();
 		} catch (RouteNotFoundException $e) {
 		} catch (RouteNotFoundException $e) {
-			Log::record ($e->getMessage (), Log::ERROR);
+			Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
 			Error::error (
 			Error::error (
 				404,
 				404,
 				array ('error' => array ($e->getMessage ()))
 				array ('error' => array ($e->getMessage ()))
 			);
 			);
 		} catch (MinzException $e) {
 		} catch (MinzException $e) {
-			Log::record ($e->getMessage (), Log::ERROR);
+			Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
 			$this->killApp ();
 			$this->killApp ();
 		}
 		}
 		
 		
@@ -94,7 +94,7 @@ class FrontController {
 			$this->dispatcher->run ();
 			$this->dispatcher->run ();
 			Response::send ();
 			Response::send ();
 		} catch (MinzException $e) {
 		} catch (MinzException $e) {
-			Log::record ($e->getMessage (), Log::ERROR);
+			Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
 
 
 			if ($e instanceof FileNotExistException ||
 			if ($e instanceof FileNotExistException ||
 			    $e instanceof ControllerNotExistException ||
 			    $e instanceof ControllerNotExistException ||

+ 7 - 7
lib/minz/Log.php

@@ -7,7 +7,7 @@
 /**
 /**
  * La classe Log permet de logger des erreurs
  * La classe Log permet de logger des erreurs
  */
  */
-class Log {
+class Minz_Log {
 	/**
 	/**
 	 * Les différents niveau de log
 	 * Les différents niveau de log
 	 * ERROR erreurs bloquantes de l'application
 	 * ERROR erreurs bloquantes de l'application
@@ -33,19 +33,19 @@ class Log {
 		
 		
 		if (! ($env == Configuration::SILENT
 		if (! ($env == Configuration::SILENT
 		       || ($env == Configuration::PRODUCTION
 		       || ($env == Configuration::PRODUCTION
-		       && ($level == Log::WARNING || $level == Log::NOTICE)))) {
+		       && ($level == Minz_Log::WARNING || $level == Minz_Log::NOTICE)))) {
 			if (is_null ($file_name)) {
 			if (is_null ($file_name)) {
 				$file_name = LOG_PATH . '/application.log';
 				$file_name = LOG_PATH . '/application.log';
 			}
 			}
 			
 			
 			switch ($level) {
 			switch ($level) {
-			case Log::ERROR :
+			case Minz_Log::ERROR :
 				$level_label = 'error';
 				$level_label = 'error';
 				break;
 				break;
-			case Log::WARNING :
+			case Minz_Log::WARNING :
 				$level_label = 'warning';
 				$level_label = 'warning';
 				break;
 				break;
-			case Log::NOTICE :
+			case Minz_Log::NOTICE :
 				$level_label = 'notice';
 				$level_label = 'notice';
 				break;
 				break;
 			default :
 			default :
@@ -86,7 +86,7 @@ class Log {
 		$msg_get = str_replace("\n", '', '$_GET content : ' . print_r($_GET, true));
 		$msg_get = str_replace("\n", '', '$_GET content : ' . print_r($_GET, true));
 		$msg_post = str_replace("\n", '', '$_POST content : ' . print_r($_POST, true));
 		$msg_post = str_replace("\n", '', '$_POST content : ' . print_r($_POST, true));
 
 
-		self::record($msg_get, Log::NOTICE, $file_name);
-		self::record($msg_post, Log::NOTICE, $file_name);
+		self::record($msg_get, Minz_Log::NOTICE, $file_name);
+		self::record($msg_post, Minz_Log::NOTICE, $file_name);
 	}
 	}
 }
 }

+ 6 - 6
lib/minz/View.php

@@ -69,9 +69,9 @@ class View {
 		if (file_exists ($this->view_filename)) {
 		if (file_exists ($this->view_filename)) {
 			include ($this->view_filename);
 			include ($this->view_filename);
 		} else {
 		} else {
-			Log::record ('File doesn\'t exist : `'
+			Minz_Log::record ('File doesn\'t exist : `'
 			            . $this->view_filename . '`',
 			            . $this->view_filename . '`',
-			            Log::NOTICE);
+			            Minz_Log::NOTICE);
 		}
 		}
 	}
 	}
 
 
@@ -87,9 +87,9 @@ class View {
 		if (file_exists ($fic_partial)) {
 		if (file_exists ($fic_partial)) {
 			include ($fic_partial);
 			include ($fic_partial);
 		} else {
 		} else {
-			Log::record ('File doesn\'t exist : `'
+			Minz_Log::record ('File doesn\'t exist : `'
 			            . $fic_partial . '`',
 			            . $fic_partial . '`',
-			            Log::WARNING);
+			            Minz_Log::WARNING);
 		}
 		}
 	}
 	}
 
 
@@ -105,9 +105,9 @@ class View {
 		if (file_exists ($fic_helper)) {
 		if (file_exists ($fic_helper)) {
 			include ($fic_helper);
 			include ($fic_helper);
 		} else {
 		} else {
-			Log::record ('File doesn\'t exist : `'
+			Minz_Log::record ('File doesn\'t exist : `'
 			            . $fic_helper . '`',
 			            . $fic_helper . '`',
-			            Log::WARNING);
+			            Minz_Log::WARNING);
 		}
 		}
 	}
 	}