Browse Source

- Résolus : Quand on click sur le titre du post on on est bien dirigé vers le site du post sans problème mais le tire change en "(lu)"
- Modification des boucles de requettages de SQLITEentity pour gain de perf + fix des strictes sous PHP 5.4
- Modification SQLITEentity appel de requete perssonalisé (portabilité vers MySQL)

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

Valentin CARRUESCO 9 years ago
parent
commit
9014390b79
8 changed files with 40 additions and 36 deletions
  1. 6 6
      404.html
  2. 1 1
      Configuration.class.php
  3. 2 2
      Feed.class.php
  4. 25 18
      SQLiteEntity.class.php
  5. 1 1
      action.php
  6. 1 1
      index.php
  7. 1 5
      js/script.js
  8. 3 2
      todo.txt

+ 6 - 6
404.html

@@ -2,7 +2,7 @@
 <html lang="en">
 <head>
   <meta charset="utf-8">
-  <title>Page Not Found :(</title>
+  <title>Page Non trouv&eacute;e :(</title>
   <style>
     ::-moz-selection { background: #fe57a1; color: #fff; text-shadow: none; }
     ::selection { background: #fe57a1; color: #fff; text-shadow: none; }
@@ -28,12 +28,12 @@
 </head>
 <body>
   <div class="container">
-    <h1>Not found <span>:(</span></h1>
-    <p>Sorry, but the page you were trying to view does not exist.</p>
-    <p>It looks like this was the result of either:</p>
+    <h1>Page Non trouv&eacute;e <span>:(</span></h1>
+    <p>D&eacute;sol&eacute; la page que vous cherchez n'existe pas.</p>
+    <p>C'est certainement:</p>
     <ul>
-      <li>a mistyped address</li>
-      <li>an out-of-date link</li>
+      <li>une adresse mal tap&eacute;e</li>
+      <li>Un lien mort</li>
     </ul>
     <script>
       var GOOG_FIXURL_LANG = (navigator.language || '').slice(0,2),GOOG_FIXURL_SITE = location.host;

+ 1 - 1
Configuration.class.php

@@ -20,7 +20,7 @@ class Configuration extends SQLiteEntity{
 		if(!isset($_SESSION['configuration'])){
 	
 		$configurationManager = new Configuration();
-		$configsQuery = $configurationManager->query('SELECT key,value FROM configuration');
+		$configsQuery = $configurationManager->customQuery('SELECT key,value FROM configuration');
 		$confTab = array();
 
 		while($config = $configsQuery->fetchArray() ){

+ 2 - 2
Feed.class.php

@@ -229,7 +229,7 @@ class Feed extends SQLiteEntity{
 
 	function countUnreadEvents(){
 		$unreads = array();
-		$results = Feed::query("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(event.id), feed.id FROM event INNER JOIN feed ON (event.feed = feed.id) WHERE event.unread = '1' GROUP BY feed.id") ;
 		while($item = $results->fetchArray()){
 			$unreads[$item[1]] = $item[0];
 		}
@@ -238,7 +238,7 @@ class Feed extends SQLiteEntity{
 
 	function getFeedsPerFolder(){
 		$feeds = array();
-		$results = Feed::query("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 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 ;");
 		while($item = $results->fetchArray()){
 			$feeds[$item['folder']][$item['id']]['id'] = $item['id'];
 			$feeds[$item['folder']][$item['id']]['name'] = html_entity_decode($item['name']);

+ 25 - 18
SQLiteEntity.class.php

@@ -74,10 +74,10 @@ class SQLiteEntity extends SQLite3
 	public function create($debug='false'){
 		$query = 'CREATE TABLE IF NOT EXISTS `'.$this->TABLE_NAME.'` (';
 
-		$end = end(array_keys($this->object_fields));
+		$i=false;
 		foreach($this->object_fields as $field=>$type){
+			if($i){$query .=',';}else{$i=true;}
 			$query .='`'.$field.'`  '. $this->sgbdType($type).'  NOT NULL';
-			if($field != $end)$query .=',';
 		}
 
 		$query .= ');';
@@ -98,29 +98,29 @@ class SQLiteEntity extends SQLite3
 			$query = 'UPDATE `'.$this->TABLE_NAME.'`';
 			$query .= ' SET ';
 
-			$end = end(array_keys($this->object_fields));
+			$i = false;
 			foreach($this->object_fields as $field=>$type){
+				if($i){$query .=',';}else{$i=true;}
 				$id = eval('return htmlentities($this->'.$field.');');
 				$query .= '`'.$field.'`="'.$id.'"';
-				if($field != $end)$query .=',';
 			}
 
 			$query .= ' WHERE `id`="'.$this->id.'";';
 		}else{
 			$query = 'INSERT INTO `'.$this->TABLE_NAME.'`(';
-			$end = end(array_keys($this->object_fields));
+			$i=false;
 			foreach($this->object_fields as $field=>$type){
 				if($type!='key'){
+					if($i){$query .=',';}else{$i=true;}
 					$query .='`'.$field.'`';
-					if($field != $end)$query .=',';
 				}
 			}
 			$query .=')VALUES(';
-			$end = end(array_keys($this->object_fields));
+			$i=false;
 			foreach($this->object_fields as $field=>$type){
 				if($type!='key'){
+					if($i){$query .=',';}else{$i=true;}
 					$query .='"'.eval('return htmlentities($this->'.$field.');').'"';
-					if($field != $end)$query .=',';
 				}
 			}
 
@@ -144,18 +144,18 @@ class SQLiteEntity extends SQLite3
 	*/
 	public function change($columns,$columns2=null,$operation='=',$debug='false'){
 		$query = 'UPDATE `'.$this->TABLE_NAME.'` SET ';
-		$end = end(array_keys($columns));
+		$i=false;
 		foreach ($columns as $column=>$value){
+			if($i){$query .=',';}else{$i=true;}
 			$query .= '`'.$column.'`="'.$value.'" ';
-			if($column != $end)$query .=',';
 		}
 
 		if($columns2!=null){
 			$query .=' WHERE '; 
-			$end = end(array_keys($columns2));
+			$i=false;
 			foreach ($columns2 as $column=>$value){
+				if($i){$query .='AND ';}else{$i=true;}
 				$query .= '`'.$column.'`'.$operation.'"'.$value.'" ';
-				if($column != $end)$query .='AND ';
 			}
 		}
 
@@ -196,9 +196,10 @@ class SQLiteEntity extends SQLite3
 	
 			if($columns!=null && sizeof($columns)!=0){
 			$whereClause .= ' WHERE ';
-				$start = reset(array_keys($columns));
+				$i = false;
 				foreach($columns as $column=>$value){
-					if($column != $start)$whereClause .= ' AND ';
+
+					if($i){$whereClause .=' AND ';}else{$i=true;}
 					$whereClause .= '`'.$column.'`'.$operation.'"'.$value.'"';
 				}
 			}
@@ -271,9 +272,9 @@ class SQLiteEntity extends SQLite3
 		$whereClause ='';
 		if($columns!=null){
 			$whereClause = ' WHERE ';
-			$start = reset(array_keys($columns));
+			$i=false;
 			foreach($columns as $column=>$value){
-					if($column != $start)$whereClause .= ' AND ';
+					if($i){$whereClause .=' AND ';}else{$i=true;}
 					$whereClause .= '`'.$column.'`="'.$value.'"';
 			}
 		}
@@ -297,9 +298,9 @@ class SQLiteEntity extends SQLite3
 	public function delete($columns,$operation='=',$debug='false',$limit=null){
 		$whereClause = '';
 
-			$start = reset(array_keys($columns));
+			$i=false;
 			foreach($columns as $column=>$value){
-				if($column != $start)$whereClause .= ' AND ';
+				if($i){$whereClause .=' AND ';}else{$i=true;}
 				$whereClause .= '`'.$column.'`'.$operation.'"'.$value.'"';
 			}
 			$query = 'DELETE FROM `'.$this->TABLE_NAME.'` WHERE '.$whereClause.' '.(isset($limit)?'LIMIT '.$limit:'').';';
@@ -307,6 +308,12 @@ class SQLiteEntity extends SQLite3
 			if(!$this->exec($query)) echo $this->lastErrorMsg();
 	}
 	
+	public function customExecute($request){
+		$this->exec($request);
+	}
+	public function customQuery($request){
+		return $this->query($request);
+	}
 
 	// ACCESSEURS
 		/**

+ 1 - 1
action.php

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

+ 1 - 1
index.php

@@ -138,7 +138,7 @@ $allFeeds = $feedManager->getFeedsPerFolder();
 					<!-- TITRE -->
 					<h2><a onclick="readThis(this,<?php echo $event->getId(); ?>);" target="_blank" href="<?php echo $event->getLink(); ?>" alt="<?php echo $plainDescription; ?>" title="<?php echo $plainDescription; ?>"><?php echo $event->getTitle(); ?></a> </h2>
 					<!-- DETAILS + OPTIONS -->
-					<h3><?php if ($articleDisplayAuthor){ ?>Par <?php echo $event->getCreator(); } if ($articleDisplayDate){ ?> <?php echo $event->getPubdateWithInstant($time); } if ($articleDisplayLink){ ?> - <a href="<?php echo $event->getLink(); ?>" target="_blank">Lien direct vers l'article</a><?php } if($event->getFavorite()!=1){ ?> -  <a class="pointer" onclick="addFavorite(this,<?php echo $event->getId(); ?>);" >Favoriser</a> <?php }else{ ?> <a class="pointer" onclick="removeFavorite(this,<?php echo $event->getId(); ?>);" >D&eacute;favoriser</a> <?php } if($shareOption!=false){ ?> <button  alt="partager sur shaarli" title="partager sur shaarli" onclick="window.location.href='<?php echo $shareOption.'/index.php?post='.rawurlencode($event->getLink()).'&title='.$event->getTitle().'&source=bookmarklet' ?>'">Shaare</button><?php } ?> - <span class="pointer" onclick="readThis(this,<?php echo $event->getId(); ?><?php echo ($action=='unreadEvents' || $action==''?',true':'') ?>);">(non lu)</span></h3>
+					<h3><?php if ($articleDisplayAuthor){ ?>Par <?php echo $event->getCreator(); } if ($articleDisplayDate){ ?> <?php echo $event->getPubdateWithInstant($time); } if ($articleDisplayLink){ ?> - <a href="<?php echo $event->getLink(); ?>" target="_blank">Lien direct vers l'article</a><?php } if($event->getFavorite()!=1){ ?> -  <a class="pointer" onclick="addFavorite(this,<?php echo $event->getId(); ?>);" >Favoriser</a> <?php }else{ ?> <a class="pointer" onclick="removeFavorite(this,<?php echo $event->getId(); ?>);" >D&eacute;favoriser</a> <?php } if($shareOption!=false){ ?> <button  alt="partager sur shaarli" title="partager sur shaarli" onclick="window.location.href='<?php echo $shareOption.'/index.php?post='.rawurlencode($event->getLink()).'&title='.$event->getTitle().'&source=bookmarklet' ?>'">Shaare</button><?php } ?> - <span class="pointer" onclick="readThis(this,<?php echo $event->getId(); ?><?php echo ($action=='unreadEvents' || $action==''?',true':'') ?>);">(lu/non lu)</span></h3>
 					<!-- CONTENU/DESCRIPTION -->
 					<?php if($articleDisplayContent){ ?><p><?php if ($articleView=='partial'){echo $event->getDescription();}else{echo $event->getContent();} ?></p> <?php } ?>
 				</section>

+ 1 - 5
js/script.js

@@ -65,7 +65,6 @@ function readThis(element,id,hide){
 					  url: "./action.php?action=readContent",
 					  data:{id:id},
 					  success:function(){
-					  	$(element).html('(lu)');
 					  	if(hide){ parent.fadeOut(200); 
 					  	}else{ 
 					  		parent.addClass('eventRead');
@@ -76,10 +75,7 @@ function readThis(element,id,hide){
 		parent.removeClass('eventRead');
 	$.ajax({
 				  url: "./action.php?action=unreadContent",
-				  data:{id:id},
-				  success:function(){
-				  	$(element).html('(non lu)');
-				  }
+				  data:{id:id}
 	});
 	}
 }

+ 3 - 2
todo.txt

@@ -6,7 +6,9 @@ Cette feuille existe dans l'unique but d'organiser ma petite tête sur le projet
 ==== DERNIER COMMIT ====
 ========================
 
-
+- Résolus : Quand on click sur le titre du post on on est bien dirigé vers le site du post sans problème mais le tire change en "(lu)" 
+- Modification des boucles de requettages de SQLITEentity pour gain de perf + fix des strictes sous PHP 5.4 
+- Modification SQLITEentity appel de requete perssonalisé (portabilité vers MySQL)
 
 =========================
 ==== BUGS CONSTATES  ====
@@ -15,7 +17,6 @@ Cette feuille existe dans l'unique but d'organiser ma petite tête sur le projet
 - Quand on click sur le titre du post on on est bien dirigé vers le site du post sans problème mais le tire change en "(lu)" 
 
 
-
 =============================
 ==== ECARTS FONCTIONNELS ====
 =============================