From bd92516e6fac1970770fbddec612f3d8da30fb3f Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 1 Oct 2010 21:34:11 +0200 Subject: make the admin tag menu behave correctly now and show only arrows on nodes that have children --- www/ajax/getadminlinkedtags.php | 63 +++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 30 deletions(-) (limited to 'www/ajax') diff --git a/www/ajax/getadminlinkedtags.php b/www/ajax/getadminlinkedtags.php index a08045a..5581c43 100644 --- a/www/ajax/getadminlinkedtags.php +++ b/www/ajax/getadminlinkedtags.php @@ -1,31 +1,27 @@ + * @author Christian Weiske + * @author Eric Dane + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ + $httpContentType = 'application/json'; -$httpContentType='text/plain'; require_once '../www-header.php'; -$tag = isset($_GET['tag']) ? trim($_GET['tag']) : ''; - function assembleTagData($tag, SemanticScuttle_Service_Tag2Tag $t2t) { if ($tag == '') { @@ -36,27 +32,34 @@ function assembleTagData($tag, SemanticScuttle_Service_Tag2Tag $t2t) $tagData = array(); foreach ($linkedTags as $tag) { - $tagData[] = createTagArray($tag); + //FIXME: the hasChildren code is nasty, because it causes too many + // queries onto the database + $hasChildren = 0 < count($t2t->getAdminLinkedTags($tag, '>')); + $tagData[] = createTagArray($tag, $hasChildren); } return $tagData; } -function createTagArray($tag) +function createTagArray($tag, $hasChildren = true) { - return array( + $ar = array( 'data' => $tag, 'attr' => array('rel' => $tag), - //'children' => array('foo', 'bar'), - 'state' => 'closed' ); + if ($hasChildren) { + //jstree needs that to show the arrows + $ar['state'] = 'closed'; + } + + return $ar; } +$tag = isset($_GET['tag']) ? trim($_GET['tag']) : ''; $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