From 6d49b0622df0ea44975e99b585781f55fe9ac671 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 25 Mar 2011 19:26:42 +0100 Subject: begin modifying ajax/getcontacttags --- www/ajax/getcontacttags.php | 69 +++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 34 deletions(-) (limited to 'www/ajax') diff --git a/www/ajax/getcontacttags.php b/www/ajax/getcontacttags.php index 5f1edb3..1377fea 100644 --- a/www/ajax/getcontacttags.php +++ b/www/ajax/getcontacttags.php @@ -1,46 +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'); +$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 = $b2tservice->getContactTags( - $userservice->getCurrentUserId(), 1000, $userservice->getCurrentUserId() +$listTags = SemanticScuttle_Service_Factory::get('Bookmark2Tag')->getContactTags( + $currentUserId, $limit, $currentUserId, $beginsWith ); $tags = array(); -foreach($listTags as $t) { - $tags[] = array( - 'caption' => $t['tag'], - 'value' => $t['tag'], - ); +foreach ($listTags as $t) { + $tags[] = $t['tag']; } echo json_encode($tags); ?> - - - - -- cgit v1.2.3