aboutsummaryrefslogtreecommitdiff
path: root/www/ajax/getadminlinkedtags.php
blob: a08045a7f88a4821cc01e6390199076726aba9be (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
<?php
/***************************************************************************
 Copyright (C) 2004 - 2006 Scuttle project
 http://sourceforge.net/projects/scuttle/
 http://scuttle.org/

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ***************************************************************************/

/* Return a json file with list of linked tags */
$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 == '') {
        $linkedTags = $GLOBALS['menu2Tags'];
    } else {
        $linkedTags = $t2t->getAdminLinkedTags($tag, '>');
    }

    $tagData = array();
    foreach ($linkedTags as $tag) {
        $tagData[] = createTagArray($tag);
    }

	return $tagData;
}

function createTagArray($tag)
{
    return array(
        'data' => $tag,
        'attr' => array('rel' => $tag),
        //'children' => array('foo', 'bar'),
        'state' => 'closed'
    );
}


$tagData = assembleTagData(
    $tag,
    SemanticScuttle_Service_Factory::get('Tag2Tag')
);
//$json = substr($json, 0, -1); // remove final comma avoiding IE6 Dojo bug
echo json_encode($tagData);
?>