Commit 7e395368 authored by mose's avatar mose

[MOD] freetags: added a way for admin to remove tags on objects, would require...

[MOD] freetags: added a way for admin to remove tags on objects, would require an extra perm for that. Also fixed accented chars glitch, and improved display
parent e171cbdf
......@@ -475,7 +475,11 @@ class FreetagLib extends ObjectLib {
$normalized_valid_chars = $this->_normalized_valid_chars;
$tag = preg_replace("/[^$normalized_valid_chars]/", "", $tag);
}
return $this->_normalize_in_lowercase ? strtolower($tag) : $tag;
if (function_exists('mb_strtolower')) {
return $this->_normalize_in_lowercase ? mb_strtolower($tag,'UTF-8') : $tag;
} else {
return $this->_normalize_in_lowercase ? strtolower($tag) : $tag;
}
}
......@@ -493,9 +497,9 @@ class FreetagLib extends ObjectLib {
*
* @return string Returns the tag in normalized form.
*/
function delete_object_tag($user, $itemId, $type, $tag) {
if (!isset($user) || !isset($itemId) || !isset($type) || !isset($tag) ||
empty($user) || empty($itemId) || empty($type) || empty($tag)) {
function delete_object_tag($itemId, $type, $tag, $user=false) {
if (!isset($itemId) || !isset($type) || !isset($tag) ||
empty($itemId) || empty($type) || empty($tag)) {
die("delete_object_tag argument missing");
return false;
}
......@@ -507,16 +511,13 @@ class FreetagLib extends ObjectLib {
} else {
$objectId = $this->get_object_id($type, $itemId);
$query = "DELETE FROM `tiki_freetagged_objects`
WHERE `user` = ?
AND `objectId` = ?
AND `tagId` = ?
LIMIT 1
";
$bindvals = array($user, $objectId, $tagId);
$this->query($query, $bindvals);
$query = "delete from `tiki_freetagged_objects` where `objectId`=? and `tagId`=?";
$bindvars = array($objectId, $tagId);
if ($user) {
$query.= " and `user`=?";
$bindvars[] = $user;
}
$this->query($query, $bindvars);
return true;
......@@ -656,7 +657,7 @@ class FreetagLib extends ObjectLib {
foreach ($oldTags['data'] as $tag) {
if (!in_array($tag['raw_tag'], $tagArray)) {
$this->delete_object_tag($user, $itemId, $type, $tag['raw_tag']);
$this->delete_object_tag($itemId, $type, $tag['raw_tag'],$user);
}
}
......
{* $Header: /cvsroot/tikiwiki/tiki/templates/tiki-browse_freetags.tpl,v 1.25 2006-02-05 16:10:07 amette Exp $ *}
{* $Header: /cvsroot/tikiwiki/tiki/templates/tiki-browse_freetags.tpl,v 1.26 2007-05-15 07:06:11 mose Exp $ *}
{if $feature_ajax eq 'y'}
{include file='tiki-ajax_header.tpl' test=$test}
......@@ -7,12 +7,6 @@
<h1>{tr}Browse related tags{/tr}</h1>
{if $freetags_browse_show_cloud eq 'y'}
{foreach from=$most_popular_tags item=popular_tag}
<a class="freetag_{$popular_tag.size}" href="tiki-browse_freetags.php?tag={$popular_tag.tag}">{$popular_tag.tag}</a>
{/foreach}
{/if}
{if $feature_morcego eq 'y' and $freetags_feature_3d eq 'y'}
<div class="morcego_embedded">
......@@ -51,7 +45,8 @@
</div>
{/if}
<h2>Objects tagged <span id="currentTag2">{$tag}</span></h2>
<br />
<br />
{if $feature_ajax eq 'y'}
<div class="navbar">
......@@ -142,10 +137,21 @@
{if $feature_articles eq 'y'}
<a class="linkbut" href="tiki-browse_freetags.php?tag={$tag}&amp;type=article">{if $type eq 'article'}<span class="highlight">{/if}{tr}Articles{/tr}{if $type eq 'article'}</span>{/if}</a>
{/if}
<br />
<br />
<table width="100%">
<td width="200">
{if $freetags_browse_show_cloud eq 'y'}
{foreach from=$most_popular_tags item=popular_tag}
<a class="freetag_{$popular_tag.size}" href="tiki-browse_freetags.php?tag={$popular_tag.tag}" style="padding:0 2px;{if $tag eq $popular_tag.tag}color:#000;background-color:#eec;{/if}">{$popular_tag.tag}</a>
{/foreach}
{/if}
</td><td>
<h3>{$cantobjects} {tr}results found{/tr}</h3>
{if $cantobjects > 0}
<form action="tiki-browse_freetags.php" method="get">
<form action="tiki-browse_freetags.php" method="get" style="padding:5px 0;">
<b>{tr}Tag{/tr}</b> <div class="simplebox" style="display:inline;padding:2px 5px;">{$tag}</div>
<input type="hidden" name="sort_mode" value="{$sort_mode|escape}" />
<input type="hidden" name="tag" value="{$tag|escape}" />
{tr}Find:{/tr} <input type="text" name="find" />
......@@ -158,25 +164,25 @@
<td>{tr}{$objects[ix].type|replace:"wiki page":"Wiki"|replace:"article":"Article"|regex_replace:"/tracker [0-9]*/":"tracker item"}{/tr}</td>
<td><a href="{$objects[ix].href}" class="catname">{$objects[ix].name}</a></td>
<td>{$objects[ix].description}&nbsp;</td>
<td align="right"><a href="tiki-browse_freetags.php?del=1&amp;tag={$tag}{if $type}&amp;type={$type|escape:'url'}{/if}&amp;typeit={$objects[ix].type|escape:'url'}&amp;itemit={$objects[ix].name|escape:'url'}">del</a></td>
</tr>
{/section}
</table>
<br />
<div align="center">
<div class="mini">
{if $prev_offset >= 0}
[<a class="prevnext" href="tiki-browse_freetags.php?tag={$tag}&find={$find}&amp;type={$type}&amp;offset={$prev_offset}">{tr}prev{/tr}</a>]&nbsp;
[<a class="prevnext" href="tiki-browse_freetags.php?tag={$tag|escape:'url'}&find={$find|escape:'url'}&amp;type={$type|escape:'url'}&amp;offset={$prev_offset}">{tr}prev{/tr}</a>]&nbsp;
{/if}
{tr}Page{/tr}: {$actual_page}/{$cant_pages}
{if $next_offset >= 0}
&nbsp;[<a class="prevnext" href="tiki-browse_freetags.php?tag={$tag}&find={$find}&amp;type={$type}&amp;offset={$next_offset}">{tr}next{/tr}</a>]
&nbsp;[<a class="prevnext" href="tiki-browse_freetags.php?tag={$tag|escape:'url'}&find={$find|escape:'url'}&amp;type={$type|escape:'url'}&amp;offset={$next_offset}">{tr}next{/tr}</a>]
{/if}
{if $direct_pagination eq 'y'}
<br />
{section loop=$cant_pages name=foo}
{assign var=selector_offset value=$smarty.section.foo.index|times:$maxRecords}
<a class="prevnext" href="tiki-browse_freetags.php?tag={$tag}&find={$find}&amp;type={$type}&amp;offset={$selector_offset}">
<a class="prevnext" href="tiki-browse_freetags.php?tag={$tag|escape:'url'}&find={$find|escape:'url'}&amp;type={$type|escape:'url'}&amp;offset={$selector_offset}">
{$smarty.section.foo.index_next}
</a>&nbsp;
{/section}
......@@ -184,4 +190,5 @@
</div>
</div>
{/if}
</td></tr></table>
{/if $feature_ajax}
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-browse_freetags.php,v 1.11 2006-02-11 15:00:24 amette Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-browse_freetags.php,v 1.12 2007-05-15 07:06:10 mose Exp $
// Copyright (c) 2002-2005, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
//
// $Header: /cvsroot/tikiwiki/tiki/tiki-browse_freetags.php,v 1.11 2006-02-11 15:00:24 amette Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-browse_freetags.php,v 1.12 2007-05-15 07:06:10 mose Exp $
//
// Initialization
......@@ -28,6 +28,12 @@ if ($tiki_p_view_freetags != 'y') {
die;
}
if ($tiki_p_admin == 'y') {
if (isset($_REQUEST['del'])) {
$freetaglib->delete_object_tag($_REQUEST['itemit'],$_REQUEST['typeit'],$_REQUEST['tag']);
}
}
if (!isset($_REQUEST['tag'])) {
$tag = $freetaglib->get_tag_suggestion('', 1);
if ($tag) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment