From a1545004f2a96597165e4d9b970229137dd156e3 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Sat, 26 Mar 2011 17:04:21 +0100 Subject: rewrite ajax/getadmintags.php --- www/ajax/getadmintags.php | 81 ++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 39 deletions(-) (limited to 'www/ajax/getadmintags.php') diff --git a/www/ajax/getadmintags.php b/www/ajax/getadmintags.php index ffd20bb..2f13060 100644 --- a/www/ajax/getadmintags.php +++ b/www/ajax/getadmintags.php @@ -1,44 +1,47 @@ + * @author Christian Weiske + * @author Eric Dane + * @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 tags according to current user and sort by popularity*/ $httpContentType = 'application/json'; require_once '../www-header.php'; -/* Service creation: only useful services are created */ -$b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag'); -$bookmarkservice =SemanticScuttle_Service_Factory::get('Tag'); - -?> - -{identifier:"tag", -items: [ -getAdminTags(1000, $userservice->getCurrentUserId()); - foreach($listTags as $t) { - echo "{tag: \"".$t['tag']."\"},"; - } -?> -]} - - - - +$limit = 30; +$beginsWith = null; +$currentUserId = $userservice->getCurrentUserId(); + +if (isset($_GET['limit']) && is_numeric($_GET['limit'])) { + $limit = (int)$_GET['limit']; +} +if (isset($_GET['beginsWith']) && strlen(trim($_GET['beginsWith']))) { + $beginsWith = trim($_GET['beginsWith']); +} + +$listTags = SemanticScuttle_Service_Factory::get('Bookmark2Tag')->getAdminTags( + $limit, $currentUserId, null, $beginsWith +); +$tags = array(); +foreach ($listTags as $t) { + $tags[] = $t['tag']; +} + +echo json_encode($tags); +?> \ No newline at end of file -- cgit v1.2.3