blob: 5581c43e17a9cb88f3851848f1b8bdd9e36dcda9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<?php
/**
* Returns a list of tags managed by the admins, in json format
* suitable for jsTree consumption.
*
* @param string $tag Tag for which the children tags shall be returned
*
* SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
*
* @category Bookmarking
* @package SemanticScuttle
* @subcategory Templates
* @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
* @author Christian Weiske <cweiske@cweiske.de>
* @author Eric Dane <ericdane@users.sourceforge.net>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
$httpContentType = 'application/json';
require_once '../www-header.php';
function assembleTagData($tag, SemanticScuttle_Service_Tag2Tag $t2t)
{
if ($tag == '') {
$linkedTags = $GLOBALS['menu2Tags'];
} else {
$linkedTags = $t2t->getAdminLinkedTags($tag, '>');
}
$tagData = array();
foreach ($linkedTags as $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, $hasChildren = true)
{
$ar = array(
'data' => $tag,
'attr' => array('rel' => $tag),
);
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')
);
echo json_encode($tagData);
?>
|