Author: rhari
Date: Tue May 29 10:11:57 2007
New Revision: 453

URL: http://svn.gna.org/viewcvs/phplinker?rev=453&view=rev
Log:
#220
Ajout de l'arbre des catégories dans url_add

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

Modified: trunk/smarty/default/templates/admin/url_add.tpl
URL: 
http://svn.gna.org/viewcvs/phplinker/trunk/smarty/default/templates/admin/url_add.tpl?rev=453&r1=452&r2=453&view=diff
==============================================================================
--- trunk/smarty/default/templates/admin/url_add.tpl (original)
+++ trunk/smarty/default/templates/admin/url_add.tpl Tue May 29 10:11:57 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 $sms !=""}
 <div class = "error" align="left">{$sms}</div>
@@ -29,18 +70,12 @@
   <td><textarea name="description" cols="41" rows="6"></textarea></td>
 </tr>
 <tr>
-  <td  align="right">Category:&nbsp;&nbsp;</td>
+  <td  align="right" valign="top">Category:&nbsp;&nbsp;</td>
   <td>
-{section name=cat_loop loop=$array}
-<select name="categ_id">
-{$sel}
-{section name=customer loop=$array_id_cat}
-<option 
value="{$array_id_cat[customer].id}">{$array_id_cat[customer].name}</optiion>
-{/section}
-</select>
-{/section}
+    {$categ_ul_li}
+  </td>
+</tr>
 <input type="hidden" name="action" value="insert" >
-</td>
 <tr>
   <td align="right"><input type="submit" value="ADD" 
name="todo_action">&nbsp;&nbsp;&nbsp;</td>
   <td align="left">&nbsp;&nbsp;&nbsp;<input type="reset" value="CANCEL"></td>
@@ -49,3 +84,11 @@
 </form>
 </td></tr></table>
 </div>
+{literal}
+<script type="text/javascript">
+       treeObj2 = new JSDragDropTree();
+       treeObj2.setTreeId('dhtmlgoodies_tree2');
+       treeObj2.initTree();
+       treeObj2.expandThis('root');
+</script>
+{/literal}

Modified: trunk/www/admin/url_add.php
URL: 
http://svn.gna.org/viewcvs/phplinker/trunk/www/admin/url_add.php?rev=453&r1=452&r2=453&view=diff
==============================================================================
--- trunk/www/admin/url_add.php (original)
+++ trunk/www/admin/url_add.php Tue May 29 10:11:57 2007
@@ -1,5 +1,4 @@
 <?php
-  //echo date("Y-m-d h:i:s");
 $group="admin";
 $title="Url edit";
 $header="<script type='text/javascript' 
src='/js/ask_confirmation.js'></script>";
@@ -44,35 +43,98 @@
       $sms = "Ce liens existe d&eacute;j&agrave;";
     }else{
       $insert_db = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"INSERT INTO 
url (id, url, description, state, categorized, hit , last_update) VALUES ('', 
'".$url."', '".$description."', '".$state."', 0 , 0 , '".date("Y-m-d 
h:i:s")."')");
-      if($categ_id !="none"){
-       $know_first = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"SELECT id 
FROM  url ORDER BY id DESC LIMIT 1");
-       $id_url = mysql_result($know_first,0,"id");
-       $insert_2_cat =  sql_query('die',__FILE__,__LINE__,__FUNCTION__,"INSERT 
INTO url2category (id_url, id_category) VALUES (".$id_url.", ".$categ_id.")");
-      }
+     if (isset($_GET['categ_checked'])){
+       $know_first = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"SELECT id 
FROM  url ORDER BY id DESC LIMIT 1");
+       $id_url = mysql_result($know_first,0,"id");
+       foreach($_GET['categ_checked'] as $value){
+        $update_cat_url =  
sql_query('die',__FILE__,__LINE__,__FUNCTION__,"INSERT INTO url2category 
(id_url, id_category) VALUES (".$id_url.",".$value.")");
+       }
+       $qry = "UPDATE url SET categorized = '1' WHERE id = ".$id_url;
+       sql_query('die',__FILE__,__LINE__,__FUNCTION__,$qry);
+     }
+     linker_log("[".$_SESSION['login'] ."]Insert URL url_".$id_url);
+
       echo "<script language ='javascript'>window.location='url_add'</script>";
     }
   }
  }
-  $sel ="<option value='none' 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;';
+?>
+<?
+$root=0;
+$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);
 
-  $categ_parents[$i]['name'] = $sp . $categ_parents[$i]['name'];
-  $array_id_cat[] = array('id' => $categ_parents[$i]['id'] , 'name' => 
$categ_parents[$i]['name']);
+$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>";
+$categstoexpand = array();
+$categstoexpand[] = "root";
+for ($i=0;$i<sizeof($tree_categs);$i++){
+  if (isset($categstochecked) && in_array($tree_categs[$i]['id'], 
$categstochecked)){
+    addthistocategstoexpand($i, $tree_categs, &$categstoexpand);
+    $checked = 'checked';
   }
-$categ_parents = linker_get_categories_tree_array();
-$array_children=array();
-$categ_parents = linker_get_category_children(0 , $categ_parents, 
$array_children);
- linker_tpl("array" , $array);
- linker_tpl("array_id_cat" , $array_id_cat);
- linker_tpl("sel" , $sel);
+  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=\"true\"
+              noDrag=\"true\"
+              noDelete=\"true\"
+          >
+                 <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("sms" , $sms);
-//linker_tpl("select_menu" , $select_menu);
+linker_tpl("categ_ul_li", $categ_ul_li);
 require("includes/footer.php");
 ?>


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

Reply via email to