From cb1d41054b26c46c75f746a7d8e5bc28f32664f0 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 1 Oct 2010 18:21:33 +0200 Subject: make adminlinkedtags (menu2Tags) finally work with jquery --- data/templates/sidebar.block.menu2.php | 17 +++++++++- www/ajax/getadminlinkedtags.php | 62 ++++++++++++++++------------------ 2 files changed, 46 insertions(+), 33 deletions(-) diff --git a/data/templates/sidebar.block.menu2.php b/data/templates/sidebar.block.menu2.php index 81ee121..dec520a 100644 --- a/data/templates/sidebar.block.menu2.php +++ b/data/templates/sidebar.block.menu2.php @@ -61,7 +61,22 @@ jQuery("#maintagsmenu") "icons": true, "url": 'js/themes/default/style.css' }, - plugins : [ "themes", "html_data"], + "json_data" : { + "ajax" : { + "url": function(node) { + //-1 is root + if (node == -1 ) { + node = ""; + } else if (node.attr('rel')) { + node = node.attr('rel'); + } else { + return; + } + return "ajax/getadminlinkedtags.php?tag=" + node; + } + } + }, + plugins : [ "themes", "json_data"] }); getAdminLinkedTags($tag, '>'); + } + $tagData = array(); + foreach ($linkedTags as $tag) { + $tagData[] = createTagArray($tag); + } -function displayTag($tag, $uId) { - $uId = ($uId==0)?NULL:$uId; // if user is nobody, NULL allows to look for every public tags - - $tag2tagservice =SemanticScuttle_Service_Factory::get('Tag2Tag'); - $output = '{ id:'.rand().', name:\''.$tag.'\''; - - $linkedTags = $tag2tagservice->getAdminLinkedTags($tag, '>'); - if(count($linkedTags) > 0) { - $output.= ', children: ['; - foreach($linkedTags as $linkedTag) { - $output.= displayTag($linkedTag, $uId); - } - $output = substr($output, 0, -1); // remove final comma avoiding IE6 Dojo bug - $output.= "]"; - } + return $tagData; +} - $output.= '},'; - return $output; +function createTagArray($tag) +{ + return array( + 'data' => $tag, + 'attr' => array('rel' => $tag), + //'children' => array('foo', 'bar'), + 'state' => 'closed' + ); } -?> -{ label: 'name', identifier: 'id', items: [ - -] } +$tagData = assembleTagData( + $tag, + SemanticScuttle_Service_Factory::get('Tag2Tag') +); +//$json = substr($json, 0, -1); // remove final comma avoiding IE6 Dojo bug +echo json_encode($tagData); +?> \ No newline at end of file -- cgit v1.2.3-54-g00ecf