Commit 535c5c78 authored by Richard Mansfield's avatar Richard Mansfield

Edit tags page

Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 12778ddc
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'myportfolio');
require('init.php');
require_once('pieforms/pieform.php');
define('TITLE', get_string('edittags'));
$tags = get_my_tags();
if ($tag = param_variable('tag', null)) {
$edittagform = array(
'name' => 'edit_tag',
'elements' => array(
'tagname' => array(
'type' => 'text',
'size' => 30,
'title' => get_string('name'),
'defaultvalue' => $tag,
'rules' => array('required' => true),
),
'submit' => array(
'type' => 'submit',
'value' => get_string('submit'),
),
),
);
$deletetagform = array(
'name' => 'delete_tag',
'renderer' => 'oneline',
'elements' => array(
'submit' => array(
'type' => 'submit',
'value' => get_string('delete'),
'confirm' => get_string('confirmdeletetag'),
),
),
);
}
$smarty = smarty();
$smarty->assign('PAGEHEADING', hsc(TITLE));
$smarty->assign('tags', $tags);
if ($tag) {
$smarty->assign('tag', $tag);
$smarty->assign('edittagform', pieform($edittagform));
$smarty->assign('deletetagform', pieform($deletetagform));
}
$smarty->display('edittags.tpl');
function edit_tag_submit(Pieform $form, $values) {
global $SESSION, $USER, $tag;
if (!$userid = $USER->get('id')) {
redirect(get_config('wwwroot') . 'edittags.php?tag=' . urlencode($tag));
}
if ($values['tagname'] == $tag) {
redirect(get_config('wwwroot') . 'edittags.php?tag=' . urlencode($tag));
}
db_begin();
execute_sql(
"UPDATE {view_tag} SET tag = ? WHERE tag = ? AND view IN (SELECT id FROM {view} WHERE owner = ?)",
array($values['tagname'], $tag, $userid)
);
execute_sql(
"UPDATE {artefact_tag} SET tag = ? WHERE tag = ? AND artefact IN (SELECT id FROM {artefact} WHERE owner = ?)",
array($values['tagname'], $tag, $userid)
);
db_commit();
$SESSION->add_ok_msg(get_string('tagupdatedsuccessfully'));
redirect(get_config('wwwroot') . 'tags.php?tag=' . urlencode($values['tagname']));
}
function delete_tag_submit(Pieform $form, $values) {
global $SESSION, $USER, $tag;
if (!$userid = $USER->get('id')) {
redirect(get_config('wwwroot') . 'edittags.php?tag=' . urlencode($tag));
}
db_begin();
execute_sql(
"DELETE FROM {view_tag} WHERE tag = ? AND view IN (SELECT id FROM {view} WHERE owner = ?)",
array($tag, $userid)
);
execute_sql(
"DELETE FROM {artefact_tag} WHERE tag = ? AND artefact IN (SELECT id FROM {artefact} WHERE owner = ?)",
array($tag, $userid)
);
db_commit();
$SESSION->add_ok_msg(get_string('tagdeletedsuccessfully'));
redirect(get_config('wwwroot') . 'tags.php');
}
?>
......@@ -80,6 +80,7 @@ $string['sendrequest'] = 'Send request';
$string['reason'] = 'Reason';
$string['select'] = 'Select';
// Tags
$string['tags'] = 'Tags';
$string['tagsdesc'] = 'Enter comma separated tags for this item.';
$string['tagsdescprofile'] = 'Enter comma separated tags for this item. Items tagged with \'profile\' are displayed in your sidebar.';
......@@ -99,7 +100,15 @@ $string['tagfilter_file'] = 'Files';
$string['tagfilter_image'] = 'Images';
$string['tagfilter_text'] = 'Text';
$string['tagfilter_view'] = 'Views';
$string['edittags'] = 'Edit Tags';
$string['selectatagtoedit'] = 'Select a tag to edit';
$string['edittag'] = 'Edit Tag "%s"';
$string['edittagdescription'] = 'All items in your portfolio tagged "%s" will be updated';
$string['deletetag'] = 'Delete Tag "%s"';
$string['confirmdeletetag'] = 'Do you really want to delete this tag from everything in your portfolio?';
$string['deletetagdescription'] = 'Remove this tag from all items in your portfolio';
$string['tagupdatedsuccessfully'] = 'Tag updated successfully';
$string['tagdeletedsuccessfully'] = 'Tag deleted successfully';
$string['selfsearch'] = 'Search My Portfolio';
......
......@@ -835,6 +835,14 @@ div.sideblock #friendscontrol label {
.mytags {
padding: .5em 0;
}
.subpage.mytags {
margin-bottom: 2em;
}
.edittags {
border: 1px solid #ddd;
margin: 0;
padding: .25em .5em;
}
a.tag {
text-decoration: none;
}
......
{include file="header.tpl"}
{if $tags}
<div class="edittags mytags">
<div>{str tag=selectatagtoedit}:</div>
{foreach from=$tags item=t}
<a class="tag{if $t->tag == $tag} selected{/if}" href="{$WWWROOT}edittags.php?tag={$t->tag|urlencode}">{$t->tag|str_shorten_text:30|escape}&nbsp;<span class="tagfreq">({$t->count})</span></a>
{/foreach}
</div>
{else}
<div>{str tag=youhavenottaggedanythingyet}</div>
{/if}
{if $tag}
<h3>{str tag=edittag arg1=$tag|escape}</h3>
<p>{str tag=edittagdescription arg1=$tag|escape}</p>
{$edittagform}
<h3>{str tag=deletetag arg1=$tag|escape}</h3>
<p>{str tag=deletetagdescription}</p>
{$deletetagform}
{/if}
{include file="footer.tpl"}
{include file="header.tpl"}
{if $tags}
<div class="rbuttons"><a href="{$WWWROOT}edittags.php">{str tag=edittags}</a></div>
<ul class="in-page-tabs">
{foreach from=$tagsortoptions key=tagsortfield item=selectedsort name=tagsortoptions}
<li><a href="{$WWWROOT}tags.php?ts={$tagsortfield}" class="tag-sort{if $selectedsort} current-tab{/if}">{str tag=sort$tagsortfield}</a></li>
......@@ -16,7 +17,7 @@
{/if}
<div id="results_container" class="tag-results{if !$tag} hidden{/if}">
<h2 id="results_heading">{str tag=searchresultsfor} <a class="tag" href="{$WWWROOT}tags.php?tag={$tag|urlencode}">{$tag|str_shorten_text:50|escape}</a></h4>
<h2 id="results_heading">{str tag=searchresultsfor} <a class="tag" href="{$WWWROOT}tags.php?tag={$tag|urlencode}">{$tag|str_shorten_text:50|escape}</a></h2>
<div id="results_sort">{str tag=sortresultsby}
{foreach from=$results->sortcols item=sortfield name=sortcols}
<a href="{$results->baseurl}&type={$results->filter}&sort={$sortfield}"{if $results->sort == $sortfield} class="selected"{/if}>{str tag=$sortfield}</a>{if !$smarty.foreach.sortcols.last} | {/if}
......
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