diff options
author | Christian Weiske <cweiske@cweiske.de> | 2010-10-01 18:21:33 +0200 |
---|---|---|
committer | Christian Weiske <cweiske@cweiske.de> | 2010-10-01 18:21:33 +0200 |
commit | cb1d41054b26c46c75f746a7d8e5bc28f32664f0 (patch) | |
tree | 7e9388cbc002d05973e7fdb7a4d876d3e5adefbb /www/ajax | |
parent | 04d360dadbdcd492d3a1e5b7b6105007ad841987 (diff) | |
download | semanticscuttle-cb1d41054b26c46c75f746a7d8e5bc28f32664f0.tar.gz semanticscuttle-cb1d41054b26c46c75f746a7d8e5bc28f32664f0.tar.bz2 |
make adminlinkedtags (menu2Tags) finally work with jquery
Diffstat (limited to 'www/ajax')
-rw-r--r-- | www/ajax/getadminlinkedtags.php | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/www/ajax/getadminlinkedtags.php b/www/ajax/getadminlinkedtags.php index 6646c50..a08045a 100644 --- a/www/ajax/getadminlinkedtags.php +++ b/www/ajax/getadminlinkedtags.php @@ -21,44 +21,42 @@ /* Return a json file with list of linked tags */ $httpContentType = 'application/json'; +$httpContentType='text/plain'; require_once '../www-header.php'; -/* Service creation: only useful services are created */ -$b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag'); -$bookmarkservice =SemanticScuttle_Service_Factory::get('Tag'); -$tagstatservice =SemanticScuttle_Service_Factory::get('TagStat'); +$tag = isset($_GET['tag']) ? trim($_GET['tag']) : ''; -/* Managing all possible inputs */ -isset($_GET['tag']) ? define('GET_TAG', $_GET['tag']): define('GET_TAG', ''); -isset($_GET['uId']) ? define('GET_UID', $_GET['uId']): define('GET_UID', ''); +function assembleTagData($tag, SemanticScuttle_Service_Tag2Tag $t2t) +{ + if ($tag == '') { + $linkedTags = $GLOBALS['menu2Tags']; + } else { + $linkedTags = $t2t->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: [ -<?php -$json = displayTag(GET_TAG, intval(GET_UID)); -$json = substr($json, 0, -1); // remove final comma avoiding IE6 Dojo bug -echo $json; -?> -] } +$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 |