Author: lesabotsy
Date: Wed Apr 25 08:40:43 2007
New Revision: 359

URL: http://svn.gna.org/viewcvs/phplinker?rev=359&view=rev
Log:
#195
modification url_search pour une compatibilité avec le bug 195

Modified:
    trunk/smarty/default/templates/admin/url_search.tpl
    trunk/www/admin/url_search.php

Modified: trunk/smarty/default/templates/admin/url_search.tpl
URL: 
http://svn.gna.org/viewcvs/phplinker/trunk/smarty/default/templates/admin/url_search.tpl?rev=359&r1=358&r2=359&view=diff
==============================================================================
--- trunk/smarty/default/templates/admin/url_search.tpl (original)
+++ trunk/smarty/default/templates/admin/url_search.tpl Wed Apr 25 08:40:43 2007
@@ -3,6 +3,7 @@
 #cat{
 display: none;
 }
+
 a.srh:link, a.srh:hover, a.srh:visited{
 color:#FFFFFF;
 font-size: 12px;
@@ -10,9 +11,7 @@
 text-decoration:none;
 }
 
-
 </style>
-
 <script language='javascript'>
 function Show_my_div(f) {
 if(f.categorized.value ==1){
@@ -24,19 +23,21 @@
 </script>
 {/literal}
 
-<form action="url_result"
-      method="get" id="cherche">State :
- <select name="state" >
-<option value="">All</option>
-<option value="moderated">moderated</option>
-<option value="awaiting_update_moderation"  
{php}if($_GET["case"]=="moderator"){echo"selected='selected'";}{/php}>Other</option>
-</select>&nbsp;Keywords : <input type="text"
-      name="key">&nbsp;Category
-      : <select
-      name="categorized" onChange="Show_my_div(this.form)"><option
-      value="none">All</option><option
-      value="1">Categorized</option><option value="0"
-       {php} 
if($_GET["case"]=="top"){echo"selected='selected'";}{/php}>Uncategorized</option></select>
+{if $result_for_all =='Pas de resultat pour cette requette'}
+<form action="url_search"
+      method="get" id="cherche">
+<input type="hidden" name="case" value="all">
+State:
+  <select name="state" >
+<option value="" {php} if  ((isset($_GET['state']))&&($_GET['state']=="")){ 
echo "selected='selected'";}{/php}>All</option>
+<option value="moderated"{php} if  
((isset($_GET['state']))&&($_GET['state']=="moderated")){ echo 
"selected='selected'";}{/php}>moderated</option>
+<option value="awaiting_update_moderation" {php} if  
((isset($_GET['state']))&&($_GET['state']=="awaiting_update_moderation")){ echo 
"selected";}{/php}>Other</option>
+</select>&nbsp; Keywords : <input type="text" name="key" {php} if
+      (isset($_GET['key'])){ echo "value= $key";}{/php}>&nbsp;Category
+      : <select name="categorized" onChange="Show_my_div(this.form)">
+<option value="none" {php} if  
((isset($_GET['categorized']))&&($_GET['categorized']=="none")){ echo 
"selected";}{/php}>All</option>
+<option value="1" {php} if  
((isset($_GET['categorized']))&&($_GET['categorized']=="1")){ echo 
"selected";}{/php}>Categorized</option>
+<option value="0" {php} if  
((isset($_GET['categorized']))&&($_GET['categorized']=="0")){ echo 
"selected";}{/php}>Uncategorized</option></select>
 &nbsp;<div id="cat">Category :
 <select name="cat">
 <option value="all">All</option>
@@ -51,36 +52,65 @@
     $sp .= '&nbsp;&nbsp;&nbsp;';
 
   $categ_parents[$i]['name'] = $sp . $categ_parents[$i]['name'];
-  echo"<option value='".$categ_parents[$i]['id']."'>".  
$categ_parents[$i]['name']."</option>";
+  printf("<option value='%d' %s
+  >%s</option>",$categ_parents[$i]['id'], (isset($_GET['cat']) && 
$_GET['cat']==$categ_parents[$i]['id'])?"selected":"" 
,$categ_parents[$i]['name']);
+}
+{/php}
+</select></div>
+
+
+<input type="submit" value="Chercher">
+<input type="hidden" name="action" value="search"
+</form><br><br><br><br>
+ <div class = "message" align="left"> {$result_for_all}</div>
+{else}
+<form action="url_search"
+      method="get" id="cherche"><input type="hidden" name="case" value="all">
+  State :
+  <select name="state" >
+<option value="" {php} if  ((isset($_GET['state']))&&($_GET['state']=="")){ 
echo "selected='selected'";}{/php}>All</option>
+<option value="moderated"{php} if  
((isset($_GET['state']))&&($_GET['state']=="moderated")){ echo 
"selected='selected'";}{/php}>moderated</option>
+<option value="awaiting_update_moderation" {php} if  
((isset($_GET['state']))&&($_GET['state']=="awaiting_update_moderation")){ echo 
"selected";}{/php}>Other</option>
+</select>&nbsp;Keywords : <input type="text" name="key" {php} if
+      (isset($_GET['key'])){ echo 
"value=\"".$_GET['key']."\"";}{/php}>&nbsp;Category
+      : <select name="categorized" onChange="Show_my_div(this.form)">
+<option value="none" {php} if  
((isset($_GET['categorized']))&&($_GET['categorized']=="none")){ echo 
"selected";}{/php}>All</option>
+<option value="1" {php} if  
((isset($_GET['categorized']))&&($_GET['categorized']=="1")){ echo 
"selected";}{/php}>Categorized</option>
+<option value="0" {php} if  
((isset($_GET['categorized']))&&($_GET['categorized']=="0")){ echo 
"selected";}{/php}>Uncategorized</option></select>
+&nbsp;<div id="cat">Category :
+<select name="cat">
+<option value="all">All</option>
+{php}
+$categ_parents = linker_get_categories_tree_array();
+$array_children=array();
+$categ_parents = linker_get_category_children(0 , $categ_parents, 
$array_children);
+
+for ($i=0;$i<sizeof($categ_parents);$i++) {
+  $sp = '';
+  for ($to=0;$to<$categ_parents[$i]['deep'];$to++)
+    $sp .= '&nbsp;&nbsp;&nbsp;';
+
+  $categ_parents[$i]['name'] = $sp . $categ_parents[$i]['name'];
+  printf("<option value='%d' %s
+  >%s</option>",$categ_parents[$i]['id'], (isset($_GET['cat']) && 
$_GET['cat']==$categ_parents[$i]['id'])?"selected":"" 
,$categ_parents[$i]['name']);
 }
 {/php}
 </select>&nbsp;</div>
-Afficher&nbsp;<select name="setPerPage" >
-<option value="5">5</option>
-<option value="10">10</option>
-<option value="12">15</option>
-<option value="20">20</option>
-<option value="25">25</option>
-<option value="30">30</option>
-<option value="35">35</option>
-<option value="40">40</option>
-<option value="45">45</option>
-<option value="50">50</option>
+Afficher &nbsp;<select name="setPerPage" >
+<option value="5" {php}if($_GET["setPerPage"]=="5 "){echo 
"selected=selected";}{/php}>5</option>
+<option value="10" {php}if($_GET["setPerPage"]=="10"){echo 
"selected=selected";}{/php}>10</option>
+<option value="15" {php}if($_GET["setPerPage"]=="15"){echo 
"selected=selected";}{/php}>15</option>
+<option value="20" {php}if($_GET["setPerPage"]=="20"){echo 
"selected=selected";}{/php}>20</option>
+<option value="25" {php}if($_GET["setPerPage"]=="30"){echo 
"selected=selected";}{/php}>25</option>
+<option value="30" {php}if($_GET["setPerPage"]=="30"){echo 
"selected=selected";}{/php}>30</option>
+<option value="35" {php}if($_GET["setPerPage"]=="35"){echo 
"selected=selected";}{/php}>35</option>
+<option value="40" {php}if($_GET["setPerPage"]=="40"){echo 
"selected=selected";}{/php}>40</option>
+<option value="45" {php}if($_GET["setPerPage"]=="45"){echo 
"selected=selected";}{/php}>45</option>
+<option value="50" {php}if($_GET["setPerPage"]=="50"){echo 
"selected=selected";}{/php}>50</option>
 </select>&nbsp; par page&nbsp;
 <input type="submit" value="Chercher">
 <input type="hidden" name="action" value="search"
-</form>
-{literal}
-<script type="text/javascript">
-f = document.getElementById('cherche');
- Show_my_div(f);
-</script>
-{/literal}
-
-
-{if $result_for_all =='Pas de resultat pour cette requette'}
-   <div class = "message" align="left"> {$result_for_all}</div>
-{else}
+</form><br>
 <table border="0" cellspacing="0" cellpadding="5" width="100%">
 <tr align="left">
   <td colspan="2" width="300" >
@@ -92,6 +122,7 @@
     <td colspan="2" ><b><span style="font-size:12px;">{$nbr} site(s) 
trouvé(s)</span><b></td>
   </tr>
 </table>
+
 <table border="0" cellspacing="0" cellpadding="5" class="framed" width="100%">
   <tr align="left" class="row_header">
     <td colspan="2"><h4><b>#</b></h4></td>
@@ -107,7 +138,8 @@
    {section name=run_increment loop=$myData}
     {$myData[run_increment]}
    {/section}
-  </table>
+  </table><br>
+
 <table border="0" cellspacing="0" cellpadding="5" width="100%">
 <tr align="left">
   <td colspan="2" width="300" >
@@ -119,4 +151,12 @@
     <td colspan="2" ><b><span style="font-size:12px;">{$nbr} site(s) 
trouvé(s)</span><b></td>
   </tr>
 </table>
+
+<br>
 {/if}
+{literal}
+<script type="text/javascript">
+f = document.getElementById('cherche');
+ Show_my_div(f);
+</script>
+{/literal}

Modified: trunk/www/admin/url_search.php
URL: 
http://svn.gna.org/viewcvs/phplinker/trunk/www/admin/url_search.php?rev=359&r1=358&r2=359&view=diff
==============================================================================
--- trunk/www/admin/url_search.php (original)
+++ trunk/www/admin/url_search.php Wed Apr 25 08:40:43 2007
@@ -1,4 +1,21 @@
 <?php
+/*
+    This file is part of PHPLinker.
+
+    PHPLinker is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    PHPLinker 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 General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with PHPLinker; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
 $group="admin";
 $title="Url search";
 $header="<script type='text/javascript' 
src='/js/ask_confirmation.js'></script>";
@@ -6,24 +23,44 @@
 require("includes/auth.php");
 require("includes/header.php");
 require($linker_config['linker_php_pager']);
+if(isset($_GET["state"])){
+  $state = $_GET["state"];
+ }else{
+  $state ="";
+  $_GET["state"]="";
+ }
+if(isset($_GET["key"])){
+  $key = $_GET["key"];
+ }else{
+  $key ="";
+  $_GET["key"]="";
+ }
+if(isset($_GET["categorized"])){
+  $categorized = $_GET["categorized"];
+ }else{
+  $categorized ="";
+  $_GET["categorized"]="";
+ }
+if(isset($_GET["cat"])){
+  $cat = $_GET["cat"];
+ }else{
+  $cat ="";
+  $_GET["cat"]="";
+ }
+
 
 $test = $_SERVER["QUERY_STRING"];
-$state = "";
-$key = "";
-$categorized = "none";
-$cat = "";
 $img_url = "";
 $img_date = "";
 $img_hit = "";
-$rang=1;
-$top_f_request = "";
 $img_desc = "";
 $img_visible = "";
 $category_name="";
 $img_state = "";
 $myData = array();
+$nbr = 0;
 $_SESSION['order'] = "test";
-$nbr = 0;
+
 if(isset($_GET['order'])){
   switch($_GET['order']){
   case "desc1":
@@ -76,104 +113,94 @@
       break;
 }
  }else{
-  $order_by=" ORDER BY  hit DESC, url ASC";
- }
-if(!isset($_GET['case'])){
-  $_GET['case']="";
- }
- switch($_GET['case']){
- default:
-   $all="";
+  $order_by=" ORDER BY hit DESC";
+ }
+ $all="";
    if (isset($_GET['state']))
      $state = $_GET['state'];
 
    if (isset($_GET['key']))
      $key = $_GET['key'];
 
+
    if (isset($_GET['categorized']))
      $categorized = $_GET['categorized'];
-
+     $categorized = "";
    if (isset($_GET['cat']))
      $cat = $_GET['cat'];
-
-   if($state==""){
-     $state_request = " AND 2=2";
-   }elseif($state=="moderated"){
-      $state_request ="  AND state =\"".$state."\"";
-   }else{
-     $state_request ="  AND state !=\"moderated\"";
-   }
-   if($key ==""){
-     $key_request = "";
-   }else{
-     $key_request = " AND (url LIKE '%".$key."%' OR `description` LIKE 
'%".$key."%')";
-   }
-
-
-   if($categorized=="none"){
-     $categorized_request = " AND 1=1";
-   }elseif($categorized==0){
-     $categorized_request =" AND  categorized = '".$categorized."'";
-   }else{
-     $categorized_request="";
-     $cat = $_GET['cat'];
-     $all = "(";
-     $categ_parents = linker_get_categories_tree_array();
-     $array_children=array();
-     $categ_parents = linker_get_category_children($cat , $categ_parents, 
$array_children);
-     for ($i=0;$i<sizeof($categ_parents);$i++) {
-       $req_boucle = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"SELECT 
id_url FROM url2category WHERE id_category=". $categ_parents[$i]['id']);
-       $id_categ = mysql_fetch_array($req_boucle);
-       if($i==0){
-        $all.= $id_categ['id_url'];
-       }else{
-        if(!empty($id_categ['id_url']))
-          $all.= ",".$id_categ['id_url'];
-       }
-     }
-     $all = $all.")";
-
-     if($all =="()"){
-       $all = "";
-     }else{
-       $all = " AND id IN".$all;
-       $categorized_request = $all;
-     }
-   }
+ if($state==""){
+    $state_request = " AND 1=1";
+ }elseif($state=="moderated"){
+      $state_request ="  AND state=\"".$state."\"";
+  }else{
+     $state_request ="  AND state != \"moderated\"";
+}
+ if($key ==""){
+   $key_request = "";
+ }else{
+   $key_request = " AND (url LIKE '%".$_GET['key']."%' OR `description` LIKE 
'%".$_GET['key']."%')";
+ }
+  if($_GET['categorized']=="none"){
+    $categorized_request = " AND 2=2";
+  }elseif($_GET['categorized']==0){
+    $categorized_request =" AND id NOT IN ( SELECT id_url FROM url2category )";
+  }else{
+    $categorized_request="";
+    if($_GET['cat'] == "all"){
+      $categorized_request =" AND id IN ( SELECT id_url FROM url2category )";
+    }else{
+    $cat = $_GET['cat'];
+    $all = "(";
+    $categ_parents = linker_get_categories_tree_array();
+    $array_children=array();
+    $categ_children = linker_get_category_children($cat , $categ_parents, 
$array_children, 1, 1,true);
+    for ($i=0;$i<sizeof($categ_children);$i++) {
+      $req_boucle = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"SELECT 
id_url FROM url2category WHERE id_category=". $categ_children[$i]['id']);
+      $id_categ = mysql_fetch_array($req_boucle);
+      if($i==0){
+       $all.= $id_categ['id_url'];
+      }else{
+       if(!empty($id_categ['id_url']))
+        $all.= ",".$id_categ['id_url'];
+      }
+    }
+    $all = $all.")";
+
+    if($all =="()"){
+      $all = " AND  1=2";
+      $categorized_request = $all;
+    }else{
+      $all = str_replace("(,","(",$all);
+      $all = " AND id IN".$all;
+      $categorized_request = $all;
+    }
+  }
+}
+//echo $all;
    $simple_request = $state_request . $categorized_request . $key_request;
-   break;
- case"moderator":
-   $simple_request = " AND state !=\"moderated\"";
-   break;
- case"top":
-   $simple_request = " AND id NOT IN (SELECT id_url FROM url2category )";
-   $top_f_request = "LIMIT 0, 1000 ";
-   break;
- }
-
-//echo "SELECT count(*) as nb FROM url WHERE  1=1" .$simple_request." 
".$top_f_request;
-
-   $qryCount = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"SELECT id FROM 
url WHERE 1=1 " .$simple_request." ". $top_f_request);
-$nbr = mysql_num_rows($qryCount);
-if(mysql_num_rows($qryCount)!=0){
+//echo "SELECT id FROM url WHERE 1=1 " .$simple_request;
+if(empty($simple_request)){
+     $result_for_all ="Pas de resultat pour cette requette";
+  }elseif(!empty($simple_request) || ($_GET['state']=="" && 
$_GET['categorized']=="none")){
+   $qryCount = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"SELECT id FROM 
url WHERE 1=1 " .$simple_request);
+   $nbr = mysql_num_rows($qryCount);
+   if(mysql_num_rows($qryCount)!=0){
 
      while($id_loop = mysql_fetch_array($qryCount)){
-       $qryChange = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"SELECT 
id_url, id_category FROM url2category  WHERE `id_url`= ".$id_loop['id']) or 
die(mysql_query());
+       $qryChange = mysql_query("SELECT id_url, id_category FROM url2category  
WHERE `id_url`= ".$id_loop['id']) or die(mysql_query());
        $arrayChange = mysql_fetch_array($qryChange);
-       linker_update_categories($arrayChange['id_url']);
-        $qryCount = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"SELECT 
count(*) as nb FROM url WHERE  1=1" .$simple_request);
-        if ($titi = mysql_fetch_array($qryCount))
-          $res = $titi['nb'];
+       $qryCount = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"SELECT 
count(*) as nb FROM url WHERE  1=1" .$simple_request);
+       if ($titi = mysql_fetch_array($qryCount))
+        $res = $titi['nb'];
        $page_next  = (isset($_GET['page_next'])) ? $_GET['page_next'] : 1;     
                       // la valeur 'page' ici doit être eq à la valeur de 
params['urlVar']
        $pPage = (isset($_GET['setPerPage'])) ? $_GET['setPerPage'] : 5;        
       // la valeur 10 ici doit être eq à la valeur de params['perPage']
        $debut = $page_next * $pPage - $pPage;
        $qry =sql_query('die',__FILE__,__LINE__,__FUNCTION__,"SELECT id , url, 
hit , description , state , date_format(last_update,'%d-%m-%Y') as date_new 
FROM url WHERE  1=1 " .$simple_request." ".$order_by."  LIMIT 
".$debut.",".$pPage);
-       //echo "SELECT id , url, hit , description , state , 
date_format(last_update,'%d-%m-%Y') as date_new FROM url WHERE  1=1 " 
.$simple_request." ".$order_by."  LIMIT ".$debut.",".$pPage;
        $toto = 0;
        $Counter = 0;
        $rang=1;
        while ($res != $toto) {
-       if ($toto >= $debut && $toto < ($debut+$pPage) && $Counter < $pPage) {
+        if ($toto >= $debut && $toto < ($debut+$pPage) && $Counter < $pPage) {
           $id = mysql_result ($qry, $Counter, "id");
           $url = mysql_result ($qry, $Counter, "url");
           $hit = mysql_result ($qry, $Counter, "hit");
@@ -194,7 +221,12 @@
             }
           }else{
             $category_name = "------";
-       }
+          }
+          if(isset($_GET['key'])){
+            $description1 = str_replace($_GET['key'], "<b><span 
style='font-size:12px;'>".$_GET['key']."</span></b>", $description1);
+            $url = str_replace($_GET['key'], "<b><span 
style='font-size:12px;'>".$_GET['key']."</span></b>", $url);
+          }
+
           $court = linker_cut_char($description1,"150");
           if($Counter%2==0){
             $tr = "<tr class=\"row_odd\">";
@@ -207,7 +239,7 @@
             $visible="NON";
           }
           $myData[] = "
-    $tr
+       $tr
     <td colspan=\"2\"><span>$rang</span></td>
     <td colspan=\"2\"><span><a href=\"$url\" 
target=\"blank\">$url</a></span></td>
     <td colspan=\"2\"><span>$court</span></td>
@@ -216,15 +248,14 @@
     <td colspan=\"2\"><span>$state</span></td>
     <td colspan=\"2\" align=\"center\"><span>$hit</span></td>
     <td colspan=\"2\"><span>$date</span></td>
-     <td colspan=\"2\"><a href='url_edit?id=$id'><img 
src=\"/imgs/icons/edit.png\" alt=\"Modifier\" /></a></td>
-   </tr>";
+    <td colspan=\"2\"><a href='url_edit?id=$id''><img 
src=\"/imgs/icons/edit.png\" alt=\"Modifier\" /></a></td>
+ </tr>";
           $Counter++;
         } else {
           $myData[] = "";
         }
         $toto++;
         $rang++;
-
        }
 
      }
@@ -232,6 +263,7 @@
    }else{
    $result_for_all = "Pas de resultat pour cette requette";
    }
+  }
 
  // Initialisation de la variable $param avec les valeurs par défaut
    $params = array(
@@ -258,7 +290,6 @@
    $selectBox = $pager->getPerPageSelectBox();
    $link =  $links['all'];
    linker_tpl("nbr" , $nbr);
-   linker_tpl("rang" , $rang);
    linker_tpl("params" , $params);
    linker_tpl("myData" , $myData);
    linker_tpl("selectBox" , $selectBox);
@@ -271,11 +302,12 @@
    linker_tpl("key" , $key);
    linker_tpl("categorized" , $categorized);
    linker_tpl("cat" , $cat);
-   linker_tpl("img_desc" , $img_desc);
    linker_tpl("img_url" , $img_url);
    linker_tpl("img_date" , $img_date);
    linker_tpl("img_hit" , $img_hit);
+   linker_tpl("img_desc" , $img_desc);
+   linker_tpl("state" , $state);
    linker_tpl("img_state" , $img_state);
    linker_tpl("img_visible" , $img_visible);
 require("includes/footer.php");
-?>
+?>


_______________________________________________
PHPLinker-commits mailing list
[email protected]
https://mail.gna.org/listinfo/phplinker-commits

Reply via email to