Author: rhari
Date: Wed May  2 11:31:45 2007
New Revision: 396

URL: http://svn.gna.org/viewcvs/phplinker?rev=396&view=rev
Log:
#193
Ajout de l'arbre des categories dans l'edition des liens

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

Modified: trunk/smarty/default/templates/admin/url_edit.tpl
URL: 
http://svn.gna.org/viewcvs/phplinker/trunk/smarty/default/templates/admin/url_edit.tpl?rev=396&r1=395&r2=396&view=diff
==============================================================================
--- trunk/smarty/default/templates/admin/url_edit.tpl (original)
+++ trunk/smarty/default/templates/admin/url_edit.tpl Wed May  2 11:31:45 2007
@@ -1,3 +1,44 @@
+{literal}
+<script type="text/javascript" src="../js/ajax.js"></script>
+<script type="text/javascript" src="../js/context-menu.js"></script><!-- 
IMPORTANT! INCLUDE THE context-menu.js FILE BEFORE drag-drop-folder-tree.js -->
+<script type="text/javascript" src="../js/drag-drop-folder-tree.js">
+
+/*****************************************************************************************************
+(C) www.dhtmlgoodies.com, July 2006
+
+Update log:
+
+
+This is a script from www.dhtmlgoodies.com. You will find this and a lot of 
other scripts at our website.
+
+Terms of use:
+You are free to use this script as long as the copyright message is kept 
intact.
+
+For more detailed license information, see 
http://www.dhtmlgoodies.com/index.html?page=termsOfUse
+
+Thank you!
+
+www.dhtmlgoodies.com
+Alf Magne Kalleland
+
+*****************************************************************************************************/
+</script>
+<link rel="stylesheet" href="css/drag-drop-folder-tree.css" 
type="text/css"></link>
+<link rel="stylesheet" href="css/context-menu.css" type="text/css"></link>
+       <style type="text/css">
+       /* CSS for the demo */
+       img{
+               border:0px;
+       }
+       </style>
+       <script type="text/javascript">
+       //--------------------------------
+       // Save functions
+       //--------------------------------
+       var ajaxObjects = new Array();
+       </script>
+{/literal}
+
 <div align="center">
 {if isset($action) && $action=="update"}
 <div class = "message" align="left">Operation effect&eacute;e</div>
@@ -32,6 +73,14 @@
   <td align="right" valign="top">Description:&nbsp;&nbsp;</td>
   <td><textarea name="description" cols="41" 
rows="6">{$description}</textarea></td>
 </tr>
+<!-- hari 20070502 -->
+<tr>
+      <td  align="right" valign="top">Category:&nbsp;&nbsp;</td>
+  <td>
+      {$categ_ul_li}
+</td></tr>
+<!-- ************* -->
+<!-- hari 20070502
 <tr>
   <td  align="right">Category:&nbsp;&nbsp;</td>
   <td>
@@ -44,9 +93,13 @@
 {/section}
 </select>
 {/section}
+-->
 <input type="hidden" name="id" value="{$id}" >
 <input type="hidden" name="action" value="update" >
+<!--
 </td>
+</tr>
+-->
 <tr>
   <td align="right"><input type="submit" value="UPDATE" 
name="todo_action">&nbsp;&nbsp;&nbsp;</td>
   <td align="left">&nbsp;&nbsp;&nbsp;<input type="button" value="CANCEL" 
onclick="{$bc}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" 
value="DELETE" name="todo_action"></td>
@@ -55,3 +108,13 @@
 </form>
 </td></tr></table>
 </div>
+{literal}
+<script type="text/javascript">
+       treeObj2 = new JSDragDropTree();
+       treeObj2.setTreeId('dhtmlgoodies_tree2');
+       treeObj2.setMaximumDepth(1);
+       treeObj2.setMessageMaximumDepthReached('Maximum depth reached'); // If 
you want to show a message when maximum depth is reached, i.e. on drop.
+       treeObj2.initTree();
+//     treeObj2.expandAll();
+</script>
+{/literal}

Modified: trunk/www/admin/url_edit.php
URL: 
http://svn.gna.org/viewcvs/phplinker/trunk/www/admin/url_edit.php?rev=396&r1=395&r2=396&view=diff
==============================================================================
--- trunk/www/admin/url_edit.php (original)
+++ trunk/www/admin/url_edit.php Wed May  2 11:31:45 2007
@@ -17,92 +17,126 @@
 $bc ="javascript:history.go(-1);";
 if(isset($_GET["action"]) && $_GET["action"]=="update" && 
isset($_GET["todo_action"])){
   if($_GET["todo_action"] =="UPDATE"){
-  $update_desc = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"UPDATE url 
SET description=\"".utf8_decode($_GET["description"])."\" WHERE 
id=".$_GET["id"]);
-  $select_test = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"SELECT 
id_category FROM url2category WHERE id_url =".$_GET["id"]);
-  if(mysql_num_rows($select_test)!=0){
-    $up_cat = mysql_num_rows($select_test);
-       $delete_cat = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"DELETE 
FROM url2category WHERE id_url =".$_GET["id"]);
-    foreach($_GET["cat"] as $value){
-      if($value==""){
-       $update_cat_url =  
sql_query('die',__FILE__,__LINE__,__FUNCTION__,"DELETE FROM url2category WHERE 
id_url =".$_GET["id"]);
-      }else{
-       $update_cat_url =  
sql_query('die',__FILE__,__LINE__,__FUNCTION__,"INSERT INTO url2category 
(id_url, id_category) VALUES (".$_GET["id"].",".$value.")");
 
-      }
+    //***************hari 20070502***
+    foreach ($_GET['categ_checked'] as $cle) {
+      echo 'Valeur : '.$cle.'<br />';
     }
-    for($t=0;$t<$up_cat;$t++){
-      $opd = "categ".$t;
-      //
-    }
-}else{
-     foreach($_GET["cat"] as $value){
-       if($value==""){
-        $update_cat_url =  
sql_query('die',__FILE__,__LINE__,__FUNCTION__,"DELETE FROM url2category WHERE 
id_url =".$_GET["id"]);
-       }else{
+    //*******************************
+
+     $update_desc = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"UPDATE url 
SET description=\"".utf8_decode($_GET["description"])."\" WHERE 
id=".$_GET["id"]);
+
+     $up_cat = mysql_num_rows($select_test);
+     $delete_cat = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"DELETE FROM 
url2category WHERE id_url =".$_GET["id"]);
+     foreach($_GET['categ_checked'] as $value){
        $update_cat_url =  
sql_query('die',__FILE__,__LINE__,__FUNCTION__,"INSERT INTO url2category 
(id_url, id_category) VALUES (".$_GET["id"].",".$value.")");
-       }
      }
-  }
-    linker_log("[".$_SESSION['login'] ."]Update URL url_".$_GET["id"]." 
categorized cat_".$value);
-    echo "<script language='javascript'>history.go(-2);</script>";
+
+     linker_log("[".$_SESSION['login'] ."]Update URL url_".$_GET["id"]." 
categorized cat_".$value);
+     echo "<script language='javascript'>history.go(-2);</script>";
   }elseif($_GET["todo_action"] =="DELETE"){
     echo '<script language="javascript">if(confirm("DO YOU REALY WANT TO 
DELETE THIS URL ??")){';
     $update_cat_url =  sql_query('die',__FILE__,__LINE__,__FUNCTION__,"DELETE 
FROM url2category WHERE id_url =".$_GET["id"]);
     $update_cat_url1 =  sql_query('die',__FILE__,__LINE__,__FUNCTION__,"DELETE 
FROM url WHERE id =".$_GET["id"]);
-        echo " alert('URL DELETED');history.go(-2);";
-        echo'}else{ history.go(-2);}</script>';
- }else{
-     echo "<script language='javascript'>history.go(-2);</script>";
+    echo " alert('URL DELETED');history.go(-2);";
+    echo'}else{ history.go(-2);}</script>';
+  }else{
+    echo "<script language='javascript'>history.go(-2);</script>";
   }
- }
+}
 
 
 $info_url = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"SELECT id, url, 
description, hit, last_update, state FROM url WHERE id =".$_GET["id"]);
 $result_fetch = mysql_fetch_array($info_url);
-$request_update = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"SELECT 
id_category FROM url2category WHERE id_url =".$_GET["id"]);
-if(mysql_num_rows($request_update) !=0){
-  $sel ="<option value=''>Uncategorized</option>";
-  $rang = mysql_num_rows($request_update);
-  for($ps=0;$ps<$rang;$ps++){
-    $id_url_l[$ps] = mysql_result($request_update,$ps,"id_category");
-    $array[] = $id_url_l[$ps];
-  }
-$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;';
+$qryListCateg = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"SELECT 
id_category FROM url2category WHERE id_url =".$_GET["id"]);
 
-  $categ_parents[$i]['name'] = $sp . $categ_parents[$i]['name'];
-  $array_id_cat[] = array('id' => $categ_parents[$i]['id'] , 'name' => 
$categ_parents[$i]['name']);
+if(mysql_num_rows($qryListCateg) !=0){
+  $categstochecked = array();
+  while ($line = mysql_fetch_array($qryListCateg))
+    $categstochecked[] = $line['id_category'];
+ }
 
-  /* printf("<option value='%d' %s
-  >%s</option>",$categ_parents[$i]['id'], ($id_cat == 
$categ_parents[$i]['id'])?"selected='selected'":"" ,$categ_parents[$i]['name']);
-  */}
-
- }else{
-  $sel ="<option value='' selected='selected'>Uncategorized</option>";
-  $array[]="";
-$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'];
-  $array_id_cat[] = array('id' => $categ_parents[$i]['id'] , 'name' => 
$categ_parents[$i]['name']);
-  }
- }
-$categ_parents = linker_get_categories_tree_array();
-$array_children=array();
-$categ_parents = linker_get_category_children(0 , $categ_parents, 
$array_children);
 $url = $result_fetch["url"];
 $description = $result_fetch["description"];
 $id = $result_fetch["id"];
+?>
+<?
+$root=0;
+$bool=false;
+//      $root = 2521;
+//$root = 2207;
+$categ_ul_li = "";
+$all_categs = linker_get_categories_tree_array();
+$tree_categs = array();
+$tree_categs = linker_get_category_children($root, $all_categs, $tree_categs, 
1, true);
+
+$ul_ouverts = 0;
+$li_ouverts = 0;
+$categ_ul_li .=  "<ul id=\"dhtmlgoodies_tree2\" class=\"dhtmlgoodies_tree\">";
+$categ_ul_li .="<li id=\"root\"
+         noDrag=\"true\" noSiblings=\"true\"
+         noDelete=\"true\"
+         noRename=\"true\">
+             <a href=\"#\">Root</a>";
+
+  $categ_ul_li .="<ul>";
+// echo "<pre>";
+// print_r($categstochecked);
+for ($i=0;$i<sizeof($tree_categs);$i++){
+   if (in_array($tree_categs[$i]['id'], $categstochecked))
+    $checked = 'checked';
+  else
+    $checked = '';
+
+  $ul_ouverts++;
+  $li_ouverts++;
+  $categ_ul_li .="  <li id=\"categ_".$tree_categs[$i]['id']."\"
+             is_tag=\"false\"
+             id_ad_tag=\"".$tree_categs[$i]['id_ad_tag']."\"
+              is_new=\"false\"
+              noRename=\"".$bool."\"
+              noDrag=\"".$bool."\"
+              noDelete=\"".$bool."\"
+          >
+                 <a href=\"#\"
+                   title=\"id : ".$tree_categs[$i]['id']."\"
+                 >".$tree_categs[$i]['name']."</a><input type=\"checkbox\" 
name=\"categ_checked[]\" id=\"check".$tree_categs[$i]['id']."\" 
value=\"".$tree_categs[$i]['id']."\" ".$checked.">";
+
+  if (isset($tree_categs[$i+1]) && ($tree_categs[$i+1]['deep'] > 
$tree_categs[$i]['deep'])){
+    $ul_ouverts++;
+    $categ_ul_li .= "<ul>";
+  }
+
+  if (isset($tree_categs[$i+1]) && ($tree_categs[$i+1]['deep'] == 
$tree_categs[$i]['deep'])){
+    $li_ouverts--;
+    $categ_ul_li .="</li>";
+  }
+
+  if (isset($tree_categs[$i+1]) && ($tree_categs[$i+1]['deep'] < 
$tree_categs[$i]['deep'])){
+    $diff = $tree_categs[$i]['deep'] - $tree_categs[$i+1]['deep'];
+    for ($x=0;$x<$diff;$x++){
+      $li_ouverts--;
+      $categ_ul_li .= "</li>";
+      $ul_ouverts--;
+      $categ_ul_li .= "</ul>";
+    }
+    $li_ouverts--;
+    $categ_ul_li .= "</li>";
+  }
+
+  if (!isset($tree_categs[$i+1])){
+    while ($li_ouverts > 0){
+      $li_ouverts--;
+      $categ_ul_li .= "</li>";
+      $ul_ouverts--;
+      $categ_ul_li .= "</ul>";
+    }
+  }
+}
+$categ_ul_li .= "</li></ul>";
+?>
+<?
+linker_tpl("categ_ul_li", $categ_ul_li);
  linker_tpl("id" , $id);
  linker_tpl("url" , $url);
  linker_tpl("description" , $description);
@@ -111,9 +145,6 @@
  linker_tpl("hit" , $result_fetch['hit']);
  linker_tpl("date" , $result_fetch['last_update']);
  linker_tpl("state" , $result_fetch['state']);
- linker_tpl("array_id_cat" , $array_id_cat);
- linker_tpl("array" , $array);
- linker_tpl("sel" , $sel);
 //linker_tpl("select_menu" , $select_menu);
 require("includes/footer.php");
 ?>


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

Reply via email to