Ver Fonte

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 há 12 anos atrás
pai
commit
f6d730f9d1

+ 1 - 1
app/controllers/configureController.php

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

+ 5 - 5
app/controllers/feedController.php

@@ -86,14 +86,14 @@ class feedController extends ActionController {
 					$params['id'] = $feed->id ();
 				}
 			} catch (BadUrlException $e) {
-				Log::record ($e->getMessage (), Log::ERROR);
+				Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
 				$notif = array (
 					'type' => 'bad',
 					'content' => Translate::t ('invalid_url', $url)
 				);
 				Session::_param ('notification', $notif);
 			} catch (FeedException $e) {
-				Log::record ($e->getMessage (), Log::ERROR);
+				Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
 				$notif = array (
 					'type' => 'bad',
 					'content' => Translate::t ('internal_problem_feed')
@@ -101,7 +101,7 @@ class feedController extends ActionController {
 				Session::_param ('notification', $notif);
 			} catch (FileNotExistException $e) {
 				// Répertoire de cache n'existe pas
-				Log::record ($e->getMessage (), Log::ERROR);
+				Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
 				$notif = array (
 					'type' => 'bad',
 					'content' => Translate::t ('internal_problem_feed')
@@ -160,7 +160,7 @@ class feedController extends ActionController {
 				$feedDAO->updateLastUpdate ($feed->id ());
 				$flux_update++;
 			} catch (FeedException $e) {
-				Log::record ($e->getMessage (), Log::ERROR);
+				Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
 				$feedDAO->isInError ($feed->id ());
 			}
 
@@ -264,7 +264,7 @@ class feedController extends ActionController {
 				}
 			} catch (FeedException $e) {
 				$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;
 			} catch(EntriesGetterException $e) {
-				Log::record ($e->getMessage (), Log::NOTICE);
+				Minz_Log::record ($e->getMessage (), Minz_Log::NOTICE);
 				Error::error (
 					404,
 					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;
 		} else {
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 		}
 	}
@@ -97,7 +97,7 @@ class CategoryDAO extends Model_pdo {
 			return true;
 		} else {
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 		}
 	}
@@ -112,7 +112,7 @@ class CategoryDAO extends Model_pdo {
 			return true;
 		} else {
 			$info = $stm->errorInfo();
-			Log::record ('SQL error : ' . $info[2], Log::ERROR);
+			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
 			return false;
 		}
 	}

+ 7 - 7
app/models/Entry.php

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

+ 7 - 7
app/models/Feed.php

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

+ 1 - 1
lib/minz/Cache.php

@@ -7,7 +7,7 @@
 /**
  * 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
 	 */

+ 3 - 3
lib/minz/Dispatcher.php

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

+ 3 - 3
lib/minz/FrontController.php

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

+ 7 - 7
lib/minz/Log.php

@@ -7,7 +7,7 @@
 /**
  * La classe Log permet de logger des erreurs
  */
-class Log {
+class Minz_Log {
 	/**
 	 * Les différents niveau de log
 	 * ERROR erreurs bloquantes de l'application
@@ -33,19 +33,19 @@ class Log {
 		
 		if (! ($env == Configuration::SILENT
 		       || ($env == Configuration::PRODUCTION
-		       && ($level == Log::WARNING || $level == Log::NOTICE)))) {
+		       && ($level == Minz_Log::WARNING || $level == Minz_Log::NOTICE)))) {
 			if (is_null ($file_name)) {
 				$file_name = LOG_PATH . '/application.log';
 			}
 			
 			switch ($level) {
-			case Log::ERROR :
+			case Minz_Log::ERROR :
 				$level_label = 'error';
 				break;
-			case Log::WARNING :
+			case Minz_Log::WARNING :
 				$level_label = 'warning';
 				break;
-			case Log::NOTICE :
+			case Minz_Log::NOTICE :
 				$level_label = 'notice';
 				break;
 			default :
@@ -86,7 +86,7 @@ class Log {
 		$msg_get = str_replace("\n", '', '$_GET content : ' . print_r($_GET, 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)) {
 			include ($this->view_filename);
 		} else {
-			Log::record ('File doesn\'t exist : `'
+			Minz_Log::record ('File doesn\'t exist : `'
 			            . $this->view_filename . '`',
-			            Log::NOTICE);
+			            Minz_Log::NOTICE);
 		}
 	}
 
@@ -87,9 +87,9 @@ class View {
 		if (file_exists ($fic_partial)) {
 			include ($fic_partial);
 		} else {
-			Log::record ('File doesn\'t exist : `'
+			Minz_Log::record ('File doesn\'t exist : `'
 			            . $fic_partial . '`',
-			            Log::WARNING);
+			            Minz_Log::WARNING);
 		}
 	}
 
@@ -105,9 +105,9 @@ class View {
 		if (file_exists ($fic_helper)) {
 			include ($fic_helper);
 		} else {
-			Log::record ('File doesn\'t exist : `'
+			Minz_Log::record ('File doesn\'t exist : `'
 			            . $fic_helper . '`',
-			            Log::WARNING);
+			            Minz_Log::WARNING);
 		}
 	}