make the admin tag menu behave correctly now and show only arrows on nodes that have children
This commit is contained in:
parent
cb1d41054b
commit
bd92516e6f
1 changed files with 32 additions and 29 deletions
|
@ -1,31 +1,27 @@
|
|||
<?php
|
||||
/***************************************************************************
|
||||
Copyright (C) 2004 - 2006 Scuttle project
|
||||
http://sourceforge.net/projects/scuttle/
|
||||
http://scuttle.org/
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
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 == '') {
|
||||
|
@ -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);
|
||||
?>
|
Loading…
Reference in a new issue