Batch tagging (first pass but working).
Search will now look in bookmarks addresses too. Some bugfixes.
This commit is contained in:
parent
e567e30ce0
commit
4b5059bfc4
@ -162,6 +162,14 @@ default:
|
||||
<a href="?sort=<?php echo $votingSort ?>"><?php echo T_("Voting").$votingArrow; ?></a>
|
||||
<span>/</span>
|
||||
<?php } ?>
|
||||
<?php
|
||||
if ($userservice->isLoggedOn() && $_SERVER['PHP_SELF'] !== "/index.php") {
|
||||
echo '<form method="get" action="'. $_SERVER['REQUEST_URI'] .'">';
|
||||
echo '<input type="hidden" name="batch" value="1"/>';
|
||||
echo '<input type="submit" value="Batch tagging"/>';
|
||||
echo "</form>";
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ($currenttag!= '') {
|
||||
@ -178,7 +186,6 @@ if ($currenttag!= '') {
|
||||
}
|
||||
}
|
||||
?></p>
|
||||
|
||||
<?php
|
||||
// PAGINATION
|
||||
|
||||
|
@ -47,7 +47,7 @@ $ajaxUrl = ROOT . 'ajax/'
|
||||
: 'getcontacttags'
|
||||
) . '.php';
|
||||
?>
|
||||
<form onsubmit="var ind = 0; var cb = document.getElementById('checkbox'+ind); while (cb !== undefined) {var title = document.getElementById('titleField'+ind); var address = document.getElementById('address'+ind); if(cb.checked) {cb.parentNode.removeChild(cb);} else {cb.parentNode.removeChild(cb); title.parentNode.removeChild(title); address.parentNode.removeChild(address);} ind++; cb = document.getElementById('checkbox'+ind);}" action="<?php echo $formaction; ?>" method="post">
|
||||
<form onsubmit="var ind = 0; var cb = document.getElementById('checkbox'+ind); while (cb !== null) {var title = document.getElementById('titleField'+ind); var address = document.getElementById('address'+ind); if(cb.checked) {cb.parentNode.removeChild(cb);} else {cb.parentNode.removeChild(cb); title.parentNode.removeChild(title); address.parentNode.removeChild(address);} ind++; cb = document.getElementById('checkbox'+ind);}" action="<?php echo $formaction; ?>" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<th align="left">
|
||||
@ -75,13 +75,44 @@ $ajaxUrl = ROOT . 'ajax/'
|
||||
<td>← <?php echo T_('Just visible by you and your contacts.'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if(! isset($batch)): ?>
|
||||
<tr>
|
||||
<th align="left"><?php echo T_('Tags'); ?></th>
|
||||
<td class="scuttletheme">
|
||||
<input type="text" id="tags" name="tags" size="75" value="<?php echo filter($row['tags'], 'xml'); ?>"/>
|
||||
<input type="text" id="tags" class="tags" name="tags" size="75" value="<?php echo filter($row['tags'], 'xml'); ?>"/>
|
||||
</td>
|
||||
<td>← <?php echo T_('Comma-separated'); ?></td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<th align="left"><?php echo 'Common tags'; ?></th>
|
||||
<td class="scuttletheme">
|
||||
<span><?php echo filter($commontags, 'xml'); ?></span>
|
||||
</td>
|
||||
<td>← <?php echo 'Tags common to all those bookmarks'; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left"><?php echo 'Associated tags'; ?></th>
|
||||
<td class="scuttletheme">
|
||||
<span><?php echo filter($alltags, 'xml'); ?></span>
|
||||
</td>
|
||||
<td>← <?php echo 'All tags associated to those bookmarks'; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left"><?php echo 'Add those tags'; ?></th>
|
||||
<td class="scuttletheme">
|
||||
<input type="text" id="tags" class="tags" name="tags" size="75" value="<?php echo filter($row['tags'], 'xml'); ?>"/>
|
||||
</td>
|
||||
<td>← <?php echo T_('Comma-separated'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left"><?php echo 'Remove those tags'; ?></th>
|
||||
<td class="scuttletheme">
|
||||
<input type="text" id="removetags" class="tags" name="removetags" size="75" value="<?php echo filter($row['tags'], 'xml'); ?>"/>
|
||||
</td>
|
||||
<td>← <?php echo T_('Comma-separated'); ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td align="right"><small><?php echo htmlspecialchars(T_('Note: use ">" to include one tag in another. e.g.: europe>france>paris'))?></small></td>
|
||||
@ -112,6 +143,9 @@ $ajaxUrl = ROOT . 'ajax/'
|
||||
<input type="submit" name="delete" value="<?php echo T_('Delete Bookmark'); ?>" />
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<button type="button" id="button" title="Invert selection" onclick="var ind = 0; var cb = document.getElementById('checkbox'+ind); while (cb !== null) {var title = document.getElementById('titleField'+ind); var address = document.getElementById('address'+ind); if(cb.checked) {cb.checked=false;} else {cb.checked=true;} ind++; cb = document.getElementById('checkbox'+ind);}">Invert selection</button>
|
||||
<?php
|
||||
if (isset($showdelete) && $showdelete) {
|
||||
echo ' (<a href="'.createURL('bookmarkcommondescriptionedit', $row['bHash']).'">';
|
||||
echo T_('edit common description').'</a>)';
|
||||
@ -131,21 +165,22 @@ $ajaxUrl = ROOT . 'ajax/'
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php
|
||||
$ind = 0;
|
||||
foreach($row['bAddress'] as $index => $address) {
|
||||
?>
|
||||
<tr>
|
||||
<td height="20px"></td>
|
||||
<td><input type="checkbox" id="checkbox<?php echo $index; ?>" checked /></td>
|
||||
<td><input type="checkbox" id="checkbox<?php echo $ind; ?>" checked="checked" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left"><?php echo T_('Address'); ?></th>
|
||||
<td><input type="text" id="address<?php echo $index; ?>" name="address[<?php echo $index; ?>]" size="75" maxlength="65535" value="<?php echo filter($address, 'xml'); ?>" onblur="useAddress(this)" /></td>
|
||||
<td><input type="text" id="address<?php echo $ind; ?>" name="address[<?php echo $index; ?>]" size="75" maxlength="65535" value="<?php echo filter($address, 'xml'); ?>" onblur="useAddress(this)" /></td>
|
||||
<td>← <?php echo T_('Required'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left"><?php echo T_('Title'); ?></th>
|
||||
<td><input type="text" id="titleField<?php echo $index; ?>" name="title[<?php echo $index; ?>]" size="75" maxlength="255" value="<?php echo filter($row['bTitle'][$index], 'xml'); ?>" onkeypress="this.style.backgroundImage = 'none';" /></td>
|
||||
<td><input type="text" id="titleField<?php echo $ind; ?>" name="title[<?php echo $index; ?>]" size="75" maxlength="255" value="<?php echo filter($row['bTitle'][$index], 'xml'); ?>" onkeypress="this.style.backgroundImage = 'none';" /></td>
|
||||
<td>← <?php echo T_('Required'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -154,6 +189,7 @@ foreach($row['bAddress'] as $index => $address) {
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php
|
||||
$ind++;
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
@ -179,7 +215,8 @@ jQuery(document).ready(function() {
|
||||
}
|
||||
//var availableTags = ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"];
|
||||
|
||||
jQuery("input#tags").autocomplete({
|
||||
//jQuery("input#tags").autocomplete({
|
||||
jQuery("input.tags").autocomplete({
|
||||
autoFocus: true,
|
||||
minLength: 1,
|
||||
|
||||
|
@ -26,9 +26,9 @@ if ($userservice->isLoggedOn() && is_object($currentUser)) {
|
||||
<?php if (isset($loadjs)) :?>
|
||||
<div id="password-form" style="background:white; z-index: 2; position:absolute; top:55px; right:10px; visibility:hidden;">
|
||||
<form id="noshoulderSurfingProtectionPassword">
|
||||
<input type="password" name="password" id="password" size="40" placeholder="Type your password then press Enter to unprotect.">
|
||||
<input type="password" name="password" id="password" size="40" placeholder="Type your password then press Enter to unprotect."/>
|
||||
<!-- Allow form submission with keyboard without duplicating the dialog button -->
|
||||
<input type="submit" tabindex="-1" style="position:absolute; top:-1000px">
|
||||
<input type="submit" tabindex="-1" style="position:absolute; top:-1000px"/>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
|
@ -892,6 +892,9 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
|
||||
$query_4 .= ' OR U.username = "'
|
||||
. $this->db->sql_escape($aTerms[$i])
|
||||
. '"'; //exact match for username
|
||||
$query_4 .= ' OR B.bAddress LIKE "%'
|
||||
. $this->db->sql_escape($aTerms[$i])
|
||||
. '%"';
|
||||
if ($dotags) {
|
||||
$query_4 .= ' OR T.tag LIKE "'
|
||||
. $this->db->sql_escape($aTerms[$i])
|
||||
@ -940,10 +943,10 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
|
||||
'', __LINE__, __FILE__, $query, $this->db
|
||||
);
|
||||
}
|
||||
|
||||
if (SQL_LAYER == 'mysql4') {
|
||||
$totalquery = 'SELECT FOUND_ROWS() AS total';
|
||||
} else {
|
||||
// Disabled because breaks when in debug mode…
|
||||
//if (SQL_LAYER == 'mysql4') {
|
||||
// $totalquery = 'SELECT FOUND_ROWS() AS total';
|
||||
//} else {
|
||||
if ($hash) {
|
||||
$totalquery = 'SELECT COUNT(*) AS total'. $query_2
|
||||
. $query_3 . $query_4;
|
||||
@ -951,7 +954,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
|
||||
$totalquery = 'SELECT COUNT(DISTINCT bAddress) AS total'
|
||||
. $query_2 . $query_3 . $query_4;
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
if (!($totalresult = $this->db->sql_query($totalquery))
|
||||
|| (!($row = $this->db->sql_fetchrow($totalresult)))
|
||||
@ -980,7 +983,6 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
|
||||
|
||||
$this->db->sql_freeresult($dbresult);
|
||||
$output = array ('bookmarks' => $bookmarks, 'total' => $total);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
|
||||
foreach ($tags as $key => $tag) {
|
||||
if (strpos($tag, '=')) {
|
||||
// case "="
|
||||
$pieces = explode('=', $tag);
|
||||
$pieces = $tagservice->normalize(explode('=', $tag));
|
||||
$nbPieces = count($pieces);
|
||||
if ($nbPieces <= 1) {
|
||||
continue;
|
||||
@ -163,7 +163,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
|
||||
$tags[$key] = $pieces[0];
|
||||
} else {
|
||||
// case ">"
|
||||
$pieces = explode('>', $tag);
|
||||
$pieces = $tagservice->normalize(explode('>', $tag));
|
||||
$nbPieces = count($pieces);
|
||||
if ($nbPieces <= 1) {
|
||||
continue;
|
||||
@ -374,6 +374,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
|
||||
}
|
||||
|
||||
$output = $this->db->sql_fetchrowset($dbresult);
|
||||
|
||||
$this->db->sql_freeresult($dbresult);
|
||||
return $this->filterShoulderSurfingProtectedTags($output);
|
||||
}
|
||||
|
@ -281,13 +281,14 @@ class sql_db
|
||||
|
||||
if ($query_id)
|
||||
{
|
||||
unset($this->rowset[$query_id]);
|
||||
unset($this->row[$query_id]);
|
||||
$id = (int) $query_id;
|
||||
unset($this->rowset[$id]);
|
||||
unset($this->row[$id]);
|
||||
|
||||
$result = array();
|
||||
while ($this->rowset[$query_id] = $this->sql_fetchrow($query_id))
|
||||
while ($this->rowset[$id] = $this->sql_fetchrow($query_id))
|
||||
{
|
||||
$result[] = $this->rowset[$query_id];
|
||||
$result[] = $this->rowset[$id];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ require_once 'SemanticScuttle/constants.php';
|
||||
|
||||
// Debug Management using constants
|
||||
if (DEBUG_MODE) {
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('display_errors', '0');
|
||||
ini_set('mysql.trace_mode', '1');
|
||||
error_reporting(E_ALL);
|
||||
} else {
|
||||
|
@ -72,7 +72,6 @@ if (isset($userid)) {
|
||||
} else {
|
||||
$tplVars['cat_url'] = createURL('tags', '%2$s');
|
||||
}
|
||||
|
||||
$tplVars['sidebar_blocks'] = array('linked');
|
||||
$tplVars['userid'] = $userid;
|
||||
$tplVars['loadjs'] = true;
|
||||
|
@ -54,10 +54,14 @@ 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', '');
|
||||
isset($_GET['batch']) ? define('GET_BATCH', $_GET['batch']): define('GET_BATCH', 0);
|
||||
|
||||
if (!isset($_POST['tags'])) {
|
||||
$_POST['tags'] = array();
|
||||
}
|
||||
if (!isset($_POST['removetags'])) {
|
||||
$_POST['removetags'] = array();
|
||||
}
|
||||
//echo '<p>' . var_export($_POST, true) . '</p>';die();
|
||||
if (! is_array($ADDRESS)) {
|
||||
$ADDRESS = array($ADDRESS);
|
||||
@ -162,7 +166,8 @@ if ($userservice->isLoggedOn() && POST_SUBMITTED != '') {
|
||||
$description = trim(POST_DESCRIPTION);
|
||||
$privateNote = trim(POST_PRIVATENOTE);
|
||||
$status = intval(POST_STATUS);
|
||||
$categories = explode(',', $_POST['tags']);
|
||||
$categories = array_map('trim', explode(',', trim($_POST['tags'])));
|
||||
$removecategories = array_map('trim', explode(',', trim($_POST['removetags'])));
|
||||
$saved = true;
|
||||
foreach($address as $index => $value) {
|
||||
if ($bookmarkservice->bookmarkExists($value, $currentUserID)) {
|
||||
@ -171,6 +176,8 @@ if ($userservice->isLoggedOn() && POST_SUBMITTED != '') {
|
||||
$bId = intval($bookmark['bId']);
|
||||
$row = $bookmarkservice->getBookmark($bId, true);
|
||||
$categories = array_unique(array_merge($row['tags'], $categories));
|
||||
// remove tags
|
||||
$categories = array_diff($categories, $removecategories);
|
||||
if (!$bookmarkservice->updateBookmark($bId, $value, $title[$index], $description, $privateNote, $status, $categories)) {
|
||||
$tplvars['error'] = T_('Error while saving this bookmark : ' + $value);
|
||||
$templatename = 'editbookmark.tpl';
|
||||
@ -199,7 +206,7 @@ if ($userservice->isLoggedOn() && POST_SUBMITTED != '') {
|
||||
}
|
||||
}
|
||||
|
||||
if (GET_ACTION == "add") {
|
||||
if (GET_ACTION == "add" || GET_BATCH) {
|
||||
// If the bookmark exists already, edit the original
|
||||
if (count($ADDRESS) === 1) {
|
||||
if ($bookmarkservice->bookmarkExists(stripslashes($ADDRESS[0]), $currentUserID)) {
|
||||
@ -212,7 +219,7 @@ if (GET_ACTION == "add") {
|
||||
$templatename = 'editbookmark.tpl';
|
||||
}
|
||||
|
||||
if ($templatename == 'editbookmark.tpl') {
|
||||
if ($templatename == 'editbookmark.tpl') { // Prepare to display the edit bookmark page.
|
||||
if ($userservice->isLoggedOn()) {
|
||||
$tplVars['formaction'] = createURL('bookmarks', $currentUsername);
|
||||
if (POST_SUBMITTED != '') {
|
||||
@ -225,7 +232,33 @@ if ($templatename == 'editbookmark.tpl') {
|
||||
'bStatus' => $GLOBALS['defaults']['privacy'],
|
||||
);
|
||||
$tplVars['tags'] = $_POST['tags'];
|
||||
} else {
|
||||
}
|
||||
elseif (GET_BATCH) {
|
||||
$completebookmarks = $bookmarkservice->getBookmarks(0, null, $userid, $cat, null, getSortOrder());
|
||||
$addresses2 = array();
|
||||
$titles2 = array();
|
||||
$tags2 = array();
|
||||
foreach ($completebookmarks['bookmarks'] as $key => &$row) {
|
||||
$addresses2[$row['bId']] = $row['bAddress'];
|
||||
$titles2[$row['bId']] = $row['bTitle'];
|
||||
$row = $bookmarkservice->getBookmark($row['bId'], true);
|
||||
$tags2[] = $row['tags'];
|
||||
}
|
||||
$alltags2 = array_unique(call_user_func_array('array_merge', $tags2));
|
||||
$commontags2 = call_user_func_array('array_intersect', $tags2);
|
||||
$tplVars['row'] = array(
|
||||
'bTitle' => $titles2,
|
||||
'bAddress' => $addresses2,
|
||||
'bDescription' => '',
|
||||
'bPrivateNote' => '',
|
||||
'tags' => array(),
|
||||
'bStatus' => $GLOBALS['defaults']['privacy']
|
||||
);
|
||||
$tplVars['batch'] = '1';
|
||||
$tplVars['alltags'] = implode(', ', $alltags2);
|
||||
$tplVars['commontags'] = implode(', ', $commontags2);
|
||||
}
|
||||
else {
|
||||
if(GET_COPYOF != '') { //copy from bookmarks page
|
||||
$tplVars['row'] = $bookmarkservice->getBookmark(intval(GET_COPYOF), true);
|
||||
if(!$currentUser->isAdmin()) {
|
||||
@ -234,9 +267,7 @@ if ($templatename == 'editbookmark.tpl') {
|
||||
}else { //copy from pop-up bookmarklet
|
||||
$tplVars['row'] = array(
|
||||
'bTitle' => array_map('stripslashes', $TITLE),
|
||||
//'bTitle' => stripslashes(GET_TITLE),
|
||||
'bAddress' => array_map('stripslashes', $ADDRESS),
|
||||
//'bAddress' => stripslashes(GET_ADDRESS),
|
||||
'bDescription' => stripslashes(GET_DESCRIPTION),
|
||||
'bPrivateNote' => stripslashes(GET_PRIVATENOTE),
|
||||
'tags' => (GET_TAGS ? explode(',', stripslashes(GET_TAGS)) : array()),
|
||||
|
@ -26,7 +26,7 @@ isset($_POST['terms']) ? define('POST_TERMS', $_POST['terms']): define('POST_TER
|
||||
isset($_POST['range']) ? define('POST_RANGE', $_POST['range']): define('POST_RANGE', '');
|
||||
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
|
||||
isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '');
|
||||
|
||||
isset($_GET['batch']) ? define('GET_BATCH', $_GET['batch']): define('GET_BATCH', 0);
|
||||
|
||||
// POST
|
||||
if (POST_TERMS != '') {
|
||||
@ -115,6 +115,41 @@ if (is_null($terms)) {
|
||||
|
||||
}
|
||||
}
|
||||
if ($userservice->isLoggedOn() && GET_BATCH) {
|
||||
$currentUsername = $currentUser->getUsername();
|
||||
$completebookmarks = $bookmarkservice->getBookmarks(0, null, $s_user, null, $terms, getSortOrder(),
|
||||
$s_watchlist, $s_start, $s_end);
|
||||
$templatename = 'editbookmark.tpl';
|
||||
$addresses2 = array();
|
||||
$titles2 = array();
|
||||
$tags2 = array();
|
||||
foreach ($completebookmarks['bookmarks'] as $key => &$row) {
|
||||
$addresses2[$row['bId']] = $row['bAddress'];
|
||||
$titles2[$row['bId']] = $row['bTitle'];
|
||||
$row = $bookmarkservice->getBookmark($row['bId'], true);
|
||||
$tags2[] = $row['tags'];
|
||||
}
|
||||
$alltags2 = array_unique(call_user_func_array('array_merge', $tags2));
|
||||
$commontags2 = call_user_func_array('array_intersect', $tags2);
|
||||
$tplVars['row'] = array(
|
||||
'bTitle' => $titles2,
|
||||
'bAddress' => $addresses2,
|
||||
'bDescription' => '',
|
||||
'bPrivateNote' => '',
|
||||
'tags' => array(),
|
||||
'bStatus' => $GLOBALS['defaults']['privacy']
|
||||
);
|
||||
$tplVars['pagetitle'] = T_('Add a Bookmark');
|
||||
$tplVars['subtitle'] = T_('Add a Bookmark');
|
||||
$tplVars['btnsubmit'] = T_('Add Bookmark');
|
||||
$tplVars['popup'] = null;
|
||||
$tplVars['batch'] = '1';
|
||||
$tplVars['alltags'] = implode(', ', $alltags2);
|
||||
$tplVars['commontags'] = implode(', ', $commontags2);
|
||||
$tplVars['formaction'] = createURL('bookmarks', $currentUsername);
|
||||
$templateservice->loadTemplate($templatename, $tplVars);
|
||||
}
|
||||
else {
|
||||
$bookmarks = $bookmarkservice->getBookmarks(
|
||||
$start, $perpage, $s_user, NULL, $terms, getSortOrder(),
|
||||
$s_watchlist, $s_start, $s_end
|
||||
@ -152,4 +187,5 @@ $tplVars['cat_url'] = createURL('tags', '%2$s');
|
||||
$tplVars['nav_url'] = createURL('search', $range .'/'. $terms .'/%3$s');
|
||||
|
||||
$templateservice->loadTemplate('bookmarks.tpl', $tplVars);
|
||||
}
|
||||
?>
|
||||
|
74
www/tags.php
74
www/tags.php
@ -20,7 +20,6 @@
|
||||
***************************************************************************/
|
||||
|
||||
require_once 'www-header.php';
|
||||
|
||||
/* Service creation: only useful services are created */
|
||||
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
|
||||
$cacheservice =SemanticScuttle_Service_Factory::get('Cache');
|
||||
@ -28,6 +27,7 @@ $cacheservice =SemanticScuttle_Service_Factory::get('Cache');
|
||||
/* Managing all possible inputs */
|
||||
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
|
||||
isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '');
|
||||
isset($_GET['batch']) ? define('GET_BATCH', $_GET['batch']): define('GET_BATCH', 0);
|
||||
|
||||
/* Managing current logged user */
|
||||
$currentUser = $userservice->getCurrentObjectUser();
|
||||
@ -63,6 +63,43 @@ if ($usecache) {
|
||||
$cacheservice->Start($hash, 1800);
|
||||
}
|
||||
|
||||
// We need all bookmarks (without paging) for batch tagging.
|
||||
if ($userservice->isLoggedOn() && GET_BATCH) {
|
||||
$currentUsername = $currentUser->getUsername();
|
||||
$completebookmarks = $bookmarkservice->getBookmarks(0, null, null, $cat, null, getSortOrder());
|
||||
$templatename = 'editbookmark.tpl';
|
||||
$addresses2 = array();
|
||||
$titles2 = array();
|
||||
$tags2 = array();
|
||||
foreach ($completebookmarks['bookmarks'] as $key => &$row) {
|
||||
$addresses2[$row['bId']] = $row['bAddress'];
|
||||
$titles2[$row['bId']] = $row['bTitle'];
|
||||
$row = $bookmarkservice->getBookmark($row['bId'], true);
|
||||
$tags2[] = $row['tags'];
|
||||
}
|
||||
$alltags2 = array_unique(call_user_func_array('array_merge', $tags2));
|
||||
$commontags2 = call_user_func_array('array_intersect', $tags2);
|
||||
$tplVars['row'] = array(
|
||||
'bTitle' => $titles2,
|
||||
'bAddress' => $addresses2,
|
||||
'bDescription' => '',
|
||||
'bPrivateNote' => '',
|
||||
'tags' => array(),
|
||||
'bStatus' => $GLOBALS['defaults']['privacy']
|
||||
);
|
||||
$tplVars['pagetitle'] = T_('Add a Bookmark');
|
||||
$tplVars['subtitle'] = T_('Add a Bookmark');
|
||||
$tplVars['btnsubmit'] = T_('Add Bookmark');
|
||||
$tplVars['popup'] = null;
|
||||
$tplVars['batch'] = '1';
|
||||
$tplVars['alltags'] = implode(', ', $alltags2);
|
||||
$tplVars['commontags'] = implode(', ', $commontags2);
|
||||
$tplVars['formaction'] = createURL('bookmarks', $currentUsername);
|
||||
$tplVars['loadjs'] = true;
|
||||
$templateservice->loadTemplate($templatename, $tplVars);
|
||||
}
|
||||
else {
|
||||
|
||||
// Header variables
|
||||
$tplVars['pagetitle'] = T_('Tags') .': '. $cat;
|
||||
$tplVars['loadjs'] = true;
|
||||
@ -106,7 +143,38 @@ $tplVars['page'] = $page;
|
||||
$tplVars['start'] = $start;
|
||||
$tplVars['popCount'] = 25;
|
||||
$tplVars['currenttag'] = $cat;
|
||||
$tplVars['sidebar_blocks'] = array('linked', 'related', 'menu2');//array('linked', 'related', 'popular');
|
||||
|
||||
if ($userservice->isLoggedOn() && ! empty($GLOBALS['shoulderSurfingProtectedTag']) && ! isset($_COOKIE["noshoulderSurfingProtection"])) {
|
||||
$tag2tagservice = SemanticScuttle_Service_Factory::get('Tag2Tag');
|
||||
$b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
|
||||
$currentUserID = $currentUser->getId();
|
||||
$alltags = $b2tservice->getTags($currentUserID);
|
||||
$shoulderSurfingProtectedTags = $tag2tagservice->getAllLinkedTags($GLOBALS['shoulderSurfingProtectedTag'], '>', $currentUserID, array());
|
||||
$shoulderSurfingProtectedTags[] = $GLOBALS['shoulderSurfingProtectedTag'];
|
||||
$flag = 0;
|
||||
if (! in_array($cat, $shoulderSurfingProtectedTags, true)) {
|
||||
foreach ($alltags as $tag) {
|
||||
if ($tag['tag'] === $cat) {
|
||||
$flag = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if ($flag) {
|
||||
$tplVars['sidebar_blocks'][] = 'tagactions';
|
||||
$tplVars['sidebar_blocks'][] = 'linked';
|
||||
$tplVars['sidebar_blocks'][] = 'related';
|
||||
$tplVars['sidebar_blocks'][] = 'menu2';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$tplVars['sidebar_blocks'][] = 'tagactions';
|
||||
$tplVars['sidebar_blocks'][] = 'linked';
|
||||
$tplVars['sidebar_blocks'][] = 'related';
|
||||
$tplVars['sidebar_blocks'][] = 'menu2';
|
||||
}
|
||||
|
||||
$tplVars['subtitlehtml'] = $pagetitle;
|
||||
$tplVars['bookmarkCount'] = $start + 1;
|
||||
$bookmarks = $bookmarkservice->getBookmarks($start, $perpage, NULL, $cat, NULL, getSortOrder());
|
||||
@ -116,7 +184,7 @@ $tplVars['cat_url'] = createURL('bookmarks', '%1$s/%2$s');
|
||||
$tplVars['nav_url'] = createURL('tags', '%2$s%3$s');
|
||||
|
||||
$templateservice->loadTemplate('bookmarks.tpl', $tplVars);
|
||||
|
||||
}
|
||||
if ($usecache) {
|
||||
// Cache output if existing copy has expired
|
||||
$cacheservice->End($hash);
|
||||
|
Loading…
Reference in New Issue
Block a user