From 8146646a0e1c7535e62aeebab049f7b1740c86ae Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 17 Mar 2011 08:46:15 +0100 Subject: [PATCH] prepare jquery autocomplete (does not work yet) --- data/templates/editbookmark.tpl.php | 19 +++++++------------ www/ajax/getcontacttags.php | 22 ++++++++++++---------- www/bookmarks.php | 11 +++++++---- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/data/templates/editbookmark.tpl.php b/data/templates/editbookmark.tpl.php index 44e3ac3..504249b 100644 --- a/data/templates/editbookmark.tpl.php +++ b/data/templates/editbookmark.tpl.php @@ -26,12 +26,12 @@ function jsEscTitle($title) - ← + ← - ← + ← @@ -39,7 +39,7 @@ function jsEscTitle($title) - ← + ← 0): ?>

@@ -56,19 +56,15 @@ function jsEscTitle($title) style="display:none"> - ← + ← - - ← + ← @@ -104,7 +100,7 @@ function jsEscTitle($title) echo ' ('; echo T_('edit common description').')'; } - + if ($popup) { ?> @@ -135,7 +131,6 @@ jQuery(document).ready(function() { }); - includeTemplate('dynamictags.inc'); @@ -204,5 +199,5 @@ else if (false) includeTemplate($GLOBALS['bottom_include']); +$this->includeTemplate($GLOBALS['bottom_include']); ?> diff --git a/www/ajax/getcontacttags.php b/www/ajax/getcontacttags.php index 89d6a3a..5f1edb3 100644 --- a/www/ajax/getcontacttags.php +++ b/www/ajax/getcontacttags.php @@ -27,18 +27,20 @@ require_once '../www-header.php'; $b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag'); $bookmarkservice =SemanticScuttle_Service_Factory::get('Tag'); +$listTags = $b2tservice->getContactTags( + $userservice->getCurrentUserId(), 1000, $userservice->getCurrentUserId() +); +$tags = array(); +foreach($listTags as $t) { + $tags[] = array( + 'caption' => $t['tag'], + 'value' => $t['tag'], + ); +} + +echo json_encode($tags); ?> -{identifier:"tag", -items: [ -getContactTags($userservice->getCurrentUserId(), 1000, $userservice->getCurrentUserId()); - foreach($listTags as $t) { - echo "{tag: \"".$t['tag']."\"},"; - } -?> -]} - diff --git a/www/bookmarks.php b/www/bookmarks.php index 5241481..0753c16 100644 --- a/www/bookmarks.php +++ b/www/bookmarks.php @@ -41,7 +41,6 @@ isset($_POST['address']) ? define('POST_ADDRESS', $_POST['address']): define('PO isset($_POST['description']) ? define('POST_DESCRIPTION', $_POST['description']): define('POST_DESCRIPTION', ''); isset($_POST['privateNote']) ? define('POST_PRIVATENOTE', $_POST['privateNote']): define('POST_PRIVATENOTE', ''); isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', ''); -isset($_POST['tags']) ? define('POST_TAGS', $_POST['tags']): define('POST_TAGS', ''); isset($_POST['referrer']) ? define('POST_REFERRER', $_POST['referrer']): define('POST_REFERRER', ''); isset($_GET['popup']) ? define('GET_POPUP', $_GET['popup']): define('GET_POPUP', ''); @@ -50,6 +49,10 @@ isset($_POST['popup']) ? define('POST_POPUP', $_POST['popup']): define('POST_POP isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0); isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', ''); +if (!isset($_POST['tags'])) { + $_POST['tags'] = array(); +} +//echo '

' . var_export($_POST, true) . '

';die(); if ((GET_ACTION == "add") && !$userservice->isLoggedOn()) { @@ -143,7 +146,7 @@ if ($userservice->isLoggedOn() && POST_SUBMITTED != '') { $description = trim(POST_DESCRIPTION); $privateNote = trim(POST_PRIVATENOTE); $status = intval(POST_STATUS); - $categories = trim(POST_TAGS); + $categories = trim(implode(',', $_POST['tags'])); $saved = true; if ($bookmarkservice->addBookmark($address, $title, $description, $privateNote, $status, $categories)) { if (POST_POPUP != '') { @@ -184,10 +187,10 @@ if ($templatename == 'editbookmark.tpl') { 'bAddress' => stripslashes(POST_ADDRESS), 'bDescription' => stripslashes(POST_DESCRIPTION), 'bPrivateNote' => stripslashes(POST_PRIVATENOTE), - 'tags' => (POST_TAGS ? explode(',', stripslashes(POST_TAGS)) : array()), + 'tags' => ($_POST['tags'] ? $_POST['tags'] : array()), 'bStatus' => 0, ); - $tplVars['tags'] = POST_TAGS; + $tplVars['tags'] = $_POST['tags']; } else { if(GET_COPYOF != '') { //copy from bookmarks page $tplVars['row'] = $bookmarkservice->getBookmark(intval(GET_COPYOF), true);