summaryrefslogtreecommitdiff
path: root/www/ajax
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2011-03-26 17:04:21 +0100
committerChristian Weiske <cweiske@cweiske.de>2011-03-26 17:04:21 +0100
commita1545004f2a96597165e4d9b970229137dd156e3 (patch)
tree4f34de85409f53c68a93b85412ece7fb9fb30acf /www/ajax
parenta756799ef4df0449244d41c2ecc7133c3fb8ce70 (diff)
downloadsemanticscuttle-a1545004f2a96597165e4d9b970229137dd156e3.tar.gz
semanticscuttle-a1545004f2a96597165e4d9b970229137dd156e3.tar.bz2
rewrite ajax/getadmintags.php
Diffstat (limited to 'www/ajax')
-rw-r--r--www/ajax/getadmintags.php81
1 files changed, 42 insertions, 39 deletions
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 @@
<?php
-/***************************************************************************
-Copyright (C) 2004 - 2006 Scuttle project
-http://sourceforge.net/projects/scuttle/
-http://scuttle.org/
+/**
+ * Return a json file with list of public tags used by admins and sorted
+ * by popularity.
+ *
+ * The following GET parameters are accepted:
+ * @param string $beginsWith The tag name shall start with that string.
+ * No default.
+ * @param integer $limit Number of tags to return. Defaults to 1000
+ *
+ * Part of SemanticScuttle - your social bookmark manager.
+ *
+ * PHP version 5.
+ *
+ * @category Bookmarking
+ * @package SemanticScuttle
+ * @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 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: [
-<?php
- $listTags = $b2tservice->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