Browse Source

- Modification du README pour adaptation a mysql
- Ajout d'un prefix pour les noms de tables

git-svn-id: http://projet.idleman.fr/leed.svn@62 cbb609ad-8cd9-463b-aa97-3ec7c4f0f680

Valentin CARRUESCO 8 years ago
parent
commit
465f577451
9 changed files with 38 additions and 43 deletions
  1. 1 1
      Event.class.php
  2. 3 3
      Feed.class.php
  3. 2 2
      Folder.class.php
  4. 12 11
      MysqlEntity.class.php
  5. 2 13
      README
  6. 1 1
      action.php
  7. 7 7
      index.php
  8. 4 1
      install.php
  9. 6 4
      todo.txt

+ 1 - 1
Event.class.php

@@ -43,7 +43,7 @@ class Event extends MysqlEntity{
 
 	function getEventCountPerFolder(){
 		$events = array();
-		$results = $this->customQuery('SELECT COUNT('.$this->TABLE_NAME.'.id),folder.id FROM '.$this->TABLE_NAME.' INNER JOIN feed ON (event.feed = feed.id) INNER JOIN folder ON (folder.id = feed.folder) WHERE '.$this->TABLE_NAME.'.unread=1 GROUP BY folder.id');
+		$results = $this->customQuery('SELECT COUNT('.MYSQL_PREFIX.$this->TABLE_NAME.'.id),'.MYSQL_PREFIX.'folder.id FROM '.MYSQL_PREFIX.$this->TABLE_NAME.' INNER JOIN '.MYSQL_PREFIX.'feed ON ('.MYSQL_PREFIX.'event.feed = '.MYSQL_PREFIX.'feed.id) INNER JOIN '.MYSQL_PREFIX.'folder ON ('.MYSQL_PREFIX.'folder.id = '.MYSQL_PREFIX.'feed.folder) WHERE '.MYSQL_PREFIX.$this->TABLE_NAME.'.unread=1 GROUP BY '.MYSQL_PREFIX.'folder.id');
 		
 		while($item = mysql_fetch_array($results)){
 			$events[$item[1]] = $item[0];

+ 3 - 3
Feed.class.php

@@ -101,7 +101,7 @@ class Feed extends MysqlEntity{
 	function removeOldEvents($maxEvent){
 		$eventManager = new Event();
 		$limit = $eventManager->rowCount(array('feed'=>$this->id))-$maxEvent;
-		if ($limit>0) $this->customExecute("DELETE FROM Event WHERE id in(SELECT id FROM Event WHERE feed=".$this->id."  AND favorite!=1 ORDER BY pubDate ASC LIMIT ".($limit>0?$limit:0).");");
+		if ($limit>0) $this->customExecute("DELETE FROM ".MYSQL_PREFIX."event WHERE id in(SELECT id FROM ".MYSQL_PREFIX."event WHERE feed=".$this->id."  AND favorite!=1 ORDER BY pubDate ASC LIMIT ".($limit>0?$limit:0).");");
 	}
 	
 	function setId($id){
@@ -152,7 +152,7 @@ class Feed extends MysqlEntity{
 
 	function countUnreadEvents(){
 		$unreads = array();
-		$results = Feed::customQuery("SELECT COUNT(event.id), feed.id FROM event INNER JOIN feed ON (event.feed = feed.id) WHERE event.unread = '1' GROUP BY feed.id") ;
+		$results = Feed::customQuery("SELECT COUNT(".MYSQL_PREFIX."event.id), ".MYSQL_PREFIX."feed.id FROM ".MYSQL_PREFIX."event INNER JOIN ".MYSQL_PREFIX."feed ON (".MYSQL_PREFIX."event.feed = ".MYSQL_PREFIX."feed.id) WHERE ".MYSQL_PREFIX."event.unread = '1' GROUP BY ".MYSQL_PREFIX."feed.id") ;
 		while($item = mysql_fetch_array($results)){
 			$unreads[$item[1]] = $item[0];
 		}
@@ -161,7 +161,7 @@ class Feed extends MysqlEntity{
 
 	function getFeedsPerFolder(){
 		$feeds = array();
-		$results = Feed::customQuery("SELECT feed.name AS name, feed.id   AS id, feed.url  AS url, folder.id AS folder FROM feed INNER JOIN folder ON ( feed.folder = folder.id ) ORDER BY feed.name ;");
+		$results = Feed::customQuery("SELECT ".MYSQL_PREFIX."feed.name AS name, ".MYSQL_PREFIX."feed.id   AS id, ".MYSQL_PREFIX."feed.url  AS url, ".MYSQL_PREFIX."folder.id AS folder FROM ".MYSQL_PREFIX."feed INNER JOIN ".MYSQL_PREFIX."folder ON ( ".MYSQL_PREFIX."feed.folder = ".MYSQL_PREFIX."folder.id ) ORDER BY ".MYSQL_PREFIX."feed.name ;");
 		while($item = mysql_fetch_array($results)){
 			$feeds[$item['folder']][$item['id']]['id'] = $item['id'];
 			$feeds[$item['folder']][$item['id']]['name'] = html_entity_decode($item['name']);

+ 2 - 2
Folder.class.php

@@ -20,7 +20,7 @@ class Folder extends MysqlEntity{
 	);
 
 	function unreadCount(){
-		$results = $this->customQuery('SELECT COUNT(event.id) FROM event INNER JOIN feed ON (event.feed = feed.id) WHERE event.unread=1 AND feed.folder = '.$this->getId());
+		$results = $this->customQuery('SELECT COUNT('.MYSQL_PREFIX.'event.id) FROM '.MYSQL_PREFIX.'event INNER JOIN '.MYSQL_PREFIX.'feed ON ('.MYSQL_PREFIX.'event.feed = '.MYSQL_PREFIX.'feed.id) WHERE '.MYSQL_PREFIX.'event.unread=1 AND '.MYSQL_PREFIX.'feed.folder = '.$this->getId());
 		$number = mysql_fetch_array($results);
 		return $number[0];
 	}
@@ -29,7 +29,7 @@ class Folder extends MysqlEntity{
 	function getEvents($start=0,$limit=10000,$order,$columns='*'){
 		$eventManager = new Event();
 		$objects = array();
-		$results = $this->customQuery('SELECT '.$columns.' FROM event INNER JOIN feed ON (event.feed = feed.id) WHERE event.unread=1 AND feed.folder = '.$this->getId().' ORDER BY '.$order.' LIMIT '.$start.','.$limit);
+		$results = $this->customQuery('SELECT '.$columns.' FROM '.MYSQL_PREFIX.'event INNER JOIN '.MYSQL_PREFIX.'feed ON ('.MYSQL_PREFIX.'event.feed = '.MYSQL_PREFIX.'feed.id) WHERE '.MYSQL_PREFIX.'event.unread=1 AND '.MYSQL_PREFIX.'feed.folder = '.$this->getId().' ORDER BY '.$order.' LIMIT '.$start.','.$limit);
 		
 		while($item = mysql_fetch_array($results)){
 			$object = new Event();

+ 12 - 11
MysqlEntity.class.php

@@ -1,4 +1,5 @@
 <?php
+require_once('constant.php');
 require_once('MysqlConnector.class.php');
 /*
 	@nom: MysqlEntity
@@ -62,7 +63,7 @@ class MysqlEntity
 	*/
 	public function destroy($debug='false')
 	{
-		$query = 'DROP TABLE IF EXISTS '.$this->TABLE_NAME.';';
+		$query = 'DROP TABLE IF EXISTS '.MYSQL_PREFIX.$this->TABLE_NAME.';';
 		if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.mysql_error();
 		$myQuery = mysql_query($query) or die(mysql_error());
 	}
@@ -76,7 +77,7 @@ class MysqlEntity
 	*/
 	public function truncate($debug='false')
 	{
-			$query = 'TRUNCATE TABLE '.$this->TABLE_NAME.';';
+			$query = 'TRUNCATE TABLE '.MYSQL_PREFIX.$this->TABLE_NAME.';';
 			if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.mysql_error();
 			$myQuery = mysql_query($query) or die(mysql_error());
 	}
@@ -89,7 +90,7 @@ class MysqlEntity
 	* @return Aucun retour
 	*/
 	public function create($debug='false'){
-		$query = 'CREATE TABLE IF NOT EXISTS `'.$this->TABLE_NAME.'` (';
+		$query = 'CREATE TABLE IF NOT EXISTS `'.MYSQL_PREFIX.$this->TABLE_NAME.'` (';
 
 		$i=false;
 		foreach($this->object_fields as $field=>$type){
@@ -106,7 +107,7 @@ class MysqlEntity
 
 
 	public function massiveInsert($events){
-		$query = 'INSERT INTO `'.$this->TABLE_NAME.'`(';
+		$query = 'INSERT INTO `'.MYSQL_PREFIX.$this->TABLE_NAME.'`(';
 			$i=false;
 			foreach($this->object_fields as $field=>$type){
 				if($type!='key'){
@@ -144,7 +145,7 @@ class MysqlEntity
 	*/
 	public function save(){
 		if(isset($this->id)){
-			$query = 'UPDATE `'.$this->TABLE_NAME.'`';
+			$query = 'UPDATE `'.MYSQL_PREFIX.$this->TABLE_NAME.'`';
 			$query .= ' SET ';
 
 			$i=false;
@@ -156,7 +157,7 @@ class MysqlEntity
 
 			$query .= ' WHERE `id`="'.$this->id.'";';
 		}else{
-			$query = 'INSERT INTO `'.$this->TABLE_NAME.'`(';
+			$query = 'INSERT INTO `'.MYSQL_PREFIX.$this->TABLE_NAME.'`(';
 			$i=false;
 			foreach($this->object_fields as $field=>$type){
 				if($i){$query .=',';}else{$i=true;}
@@ -187,7 +188,7 @@ class MysqlEntity
 	* @return Aucun retour
 	*/
 	public function change($columns,$columns2,$operation='=',$debug='false'){
-		$query = 'UPDATE `'.$this->TABLE_NAME.'` SET ';
+		$query = 'UPDATE `'.MYSQL_PREFIX.$this->TABLE_NAME.'` SET ';
 		$i=false;
 		foreach ($columns as $column=>$value){
 			if($i){$query .=',';}else{$i=true;}
@@ -201,7 +202,7 @@ class MysqlEntity
 			$query .= '`'.$column.'`'.$operation.'"'.$value.'" ';
 			
 		}
-		echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.mysql_error();
+		//echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.mysql_error();
 		mysql_query($query)or die(mysql_error());
 	}
 
@@ -244,7 +245,7 @@ class MysqlEntity
 					$whereClause .= '`'.$column.'`'.$operation.'"'.$value.'"';
 				}
 			}
-			$query = 'SELECT '.$selColumn.' FROM `'.$this->TABLE_NAME.'` '.$whereClause.' ';
+			$query = 'SELECT '.$selColumn.' FROM `'.MYSQL_PREFIX.$this->TABLE_NAME.'` '.$whereClause.' ';
 			if($order!=null) $query .='ORDER BY '.$order.' ';
 			if($limit!=null) $query .='LIMIT '.$limit.' ';
 			$query .=';';
@@ -318,7 +319,7 @@ class MysqlEntity
 					$whereClause .= '`'.$column.'`="'.$value.'"';
 			}
 		}
-		$query = 'SELECT COUNT(id) FROM '.$this->TABLE_NAME.$whereClause;
+		$query = 'SELECT COUNT(id) FROM '.MYSQL_PREFIX.$this->TABLE_NAME.$whereClause;
 		if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.mysql_error();
 		$myQuery = mysql_query($query) or die(mysql_error());
 		$number = mysql_fetch_array($myQuery);
@@ -343,7 +344,7 @@ class MysqlEntity
 				if($i){$whereClause .=' AND ';}else{$i=true;}
 				$whereClause .= '`'.$column.'`'.$operation.'"'.$value.'"';
 			}
-			$query = 'DELETE FROM `'.$this->TABLE_NAME.'` WHERE '.$whereClause.' ;';
+			$query = 'DELETE FROM `'.MYSQL_PREFIX.$this->TABLE_NAME.'` WHERE '.$whereClause.' ;';
 			if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.mysql_error();
 			mysql_query($query);
 		

+ 2 - 13
README

@@ -21,9 +21,8 @@ Licence : CC by-nc-nd (http://creativecommons.org/licenses/by-nc-nd/2.0/fr/) Nb
 ================
 
 	- Serveur Apache conseillé (Non testé sur les autres serveurs types Nginx ...)
-	- PHP 5.3 minimum
-	- Extension SQLite 3 pour PHP5
-	- SQLite 3
+	- PHP 5.3 minimum (facultatif, conseillé)
+	- MySQL
 
 ==================
 == INSTALLATION ==
@@ -41,16 +40,6 @@ Licence : CC by-nc-nd (http://creativecommons.org/licenses/by-nc-nd/2.0/fr/) Nb
 
 Le script est installé, merci d'avoir choisis Leed, l'agrégatteur RSS libre et svelte :p.
 
-=================
-== MISE A JOUR ==
-=================
-
-	Pour faire une mise à jour d'une version de Leed sur une autre, copiez le fichier database.db de votre ancienne installation vers votre nouvelle installation.
-
-	Vous ne devez pas relancer l'installation (install.php).
-
-	Dans certain cas, il est possible que les mises a jours concernent également la structure de la base de donnée, vous ne pourrez donc pas utiliser la technique ci dessous et devrez utiliser le module d'export/import puis rééfectuer l'installation.
-
 ================
 == LIBRAIRIES ==
 ================

+ 1 - 1
action.php

@@ -301,7 +301,7 @@ switch ($_['action']){
 	case 'removeFolder':
 		if($myUser==false) exit('Vous devez vous connecter pour cette action.');
 		if(isset($_['id'])){
-			$eventManager->customExecute('DELETE FROM event WHERE event.feed in (SELECT feed.id FROM feed WHERE feed.folder ='.$_['id'].') ;');
+			$eventManager->customExecute('DELETE FROM '.MYSQL_PREFIX.'event WHERE '.MYSQL_PREFIX.'event.feed in (SELECT '.MYSQL_PREFIX.'feed.id FROM '.MYSQL_PREFIX.'feed WHERE '.MYSQL_PREFIX.'feed.folder ='.$_['id'].') ;');
 			$feedManager->delete(array('folder'=>$_['id']));
 			$folderManager->delete(array('id'=>$_['id']));
 		}

+ 7 - 7
index.php

@@ -78,13 +78,13 @@ $allEvents = $eventManager->getEventCountPerFolder();
 				$articleDisplayDate = $configurationManager->get('articleDisplayDate');
 				$articleDisplayAuthor = $configurationManager->get('articleDisplayAuthor');
 
-				$target = 'event.title,event.unread,event.favorite,';
-				if($articleDisplayContent && $articleView=='partial') $target .= 'event.description,';
-				if($articleDisplayContent && $articleView!='partial') $target .= 'event.content,';
-				if($articleDisplayLink) $target .= 'event.link,';
-				if($articleDisplayDate) $target .= 'event.pubdate,';
-				if($articleDisplayAuthor) $target .= 'event.creator,';
-				$target .= 'event.id';
+				$target = MYSQL_PREFIX.'event.title,'.MYSQL_PREFIX.'event.unread,'.MYSQL_PREFIX.'event.favorite,';
+				if($articleDisplayContent && $articleView=='partial') $target .= MYSQL_PREFIX.'event.description,';
+				if($articleDisplayContent && $articleView!='partial') $target .= MYSQL_PREFIX.'event.content,';
+				if($articleDisplayLink) $target .= MYSQL_PREFIX.'event.link,';
+				if($articleDisplayDate) $target .= MYSQL_PREFIX.'event.pubdate,';
+				if($articleDisplayAuthor) $target .= MYSQL_PREFIX.'event.creator,';
+				$target .= MYSQL_PREFIX.'event.id';
 				
 
 				switch($action){

+ 4 - 1
install.php

@@ -64,7 +64,7 @@ if(isset($_['installButton'])){
 
 	$constant = "<?php
 	define('VERSION_NUMBER','1');
-	define('VERSION_NAME','Beta (rev 61)');
+	define('VERSION_NAME','Beta (rev 62)');
 
 	//Host de Mysql, le plus souvent localhost ou 127.0.0.1
 	define('MYSQL_HOST','".$_['mysqlHost']."'); 
@@ -74,6 +74,8 @@ if(isset($_['installButton'])){
 	define('MYSQL_MDP','".$_['mysqlMdp']."');
 	//Nom de la base MySQL ou se trouvera leed
 	define('MYSQL_BDD','".$_['mysqlBase']."');
+	//Prefix des noms des tables leed pour les bases de données uniques
+	define('MYSQL_PREFIX','".$_['mysqlPrefix']."');
 	?>";
 
 	file_put_contents('constant.php', $constant);
@@ -235,6 +237,7 @@ if(isset($_['installButton'])){
 					<p>Mot de passe MySQL : <input type="text" name="mysqlMdp" value=""></p>
 					<p>Nom de base MySQL : <input type="text" name="mysqlBase" value=""></p>
 					<h3>Nom de la base de donn&eacute;es vou&eacute;e &agrave; Leed (&agrave; cr&eacute;er avant d'installer leed)</h3>
+					<p>Prefixe des tables : <input type="text" name="mysqlPrefix" value="leed_"></p>
 				</section>
 
 				

+ 6 - 4
todo.txt

@@ -5,8 +5,8 @@ Cette feuille existe dans l'unique but d'organiser ma petite tête sur le projet
 ==== DERNIER COMMIT ====
 ========================
 
-- Résolution du bug sur le "tout marquer comme lu"
-- ajout dans le to-do
+- Modification du README pour adaptation a mysql
+- Ajout d'un prefix pour les noms de tables
 
 =======================
 ==== BUGS VALIDES  ====
@@ -45,8 +45,10 @@ Pouvoir plier/déplier un article (contenu masqué/démasqué)
 
 
 
-
-
+- cliquer sur le titre d'un item lu l'ouvre (logique) et le marque non-lu (me semble pas logique).
+- il y a un petit tiret qui se balade après "favoriser" (relique de quand lu/non lu se trouvait juste après).
+- il me semble que le cache est un peut agressif parfois (du genre quand on fait 2 synchronisation trop proches).
+- Une petite suggestion, ce serait sympa d'avoir un fond alterné pour les articles (genre gris très claire).