Commit 48a976c2 authored by Jason Frisvold's avatar Jason Frisvold
Browse files

- Started fleshing out code to handle merge/split/delete for tags

- Moved tag table to template file (for ajax)
- New tags_ajax file to handle ajax functions
- Stop using old math function in Smarty template
parent 06118de0
......@@ -14,6 +14,7 @@
Rename classTodoItem to phpTodoItem to be consistent
SQL changes to support new feeds
Add Smarty whitespace pre-filter (http://blog.rodneyrehm.de/archives/16-Smarty-Whitespace-Control.html)
New tag handling code for preferences (merge, split, delete)
0.9 Don't include cookies in the redirect URL
Rename the session cookie to avoid naming collisions
......
......@@ -63,7 +63,39 @@
// Bind the submit button for tag managment
$( '#tagSubmit' ).bind('click', function() {
alert('Do something here');
action = $( this ).prev('select').val();
taglist = new Array();
$( '#tagList tbody input' ).each(function() {
if ($( this ).is(':checked') == true) {
taglist.push($( this ).attr('name').substr(4));
}
})
// TODO: If we're merging or splitting, we need to pop up a box to get
// the new tags
$.ajax({
url: 'tags_ajax.php',
dataType: 'json',
type: 'POST',
data: {action: action,
taglist: taglist,
newtags: newtags},
success: function(data) {
if (data.success == 'true') {
$( '#tagList' ).remove();
$( '#tagTable' ).append(data.output);
} else {
ajax_error(data.output);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
ajax_error(errorThrown);
}
});
});
// Bind the edit tags function to each edit link
......
......@@ -81,7 +81,7 @@ function assign_status(&$smarty, $useall = false) {
}
function assign_tags(&$smarty, &$user_obj, $usefilter = false) {
global $sqlhdlr;
global $sqlhdlr, $phpTodo_tag_columns;
$query = sprintf('SELECT t.id, t.name, count(t.id) as total FROM tags ' .
'AS t LEFT JOIN tag2entry AS te ON te.tag_id = t.id ' .
......@@ -125,6 +125,8 @@ function assign_tags(&$smarty, &$user_obj, $usefilter = false) {
die( 'Error: ' . $sqlhdlr->error );
}
$smarty->assign('columns', $phpTodo_tag_columns);
// Completed, return true
return true;
}
......
......@@ -105,8 +105,6 @@
$smarty->assign('cur_sort_type', $user_obj->sort_stabilizer());
$smarty->assign('cur_sort_order', $user_obj->sort_order());
$smarty->assign('columns', $phpTodo_tag_columns);
// Get all of the feed info from the database
$query = sprintf('SELECT id FROM feeds WHERE user_id = %d',
$user_obj->user_id());
......@@ -161,12 +159,6 @@
assign_feed_types($smarty);
assign_tags($smarty, $user_obj);
//// Assign the tags
//foreach ($user_obj->tags() as $tag) {
// $taglist[$tag->id()] = $tag->name();
//}
//$smarty->assign('tags', $taglist);
// Close the MySQL handler
$sqlhdlr->close();
......
......@@ -76,42 +76,16 @@
<hr class='onethird' />
<div id='tag_management_list'>
<h3>Tag Management</h3>
{math equation="ceil(count / columns)"
count=$taglist|@count
columns=$columns
assign="columnHeight"}
<form id='tags'>
<div class='centered'>
{section name=tr loop=$columnHeight}
{if $smarty.section.tr.first == true}
<table>
<tbody>
{/if}
<tr>
{section name=td start=$smarty.section.tr.index step=$columnHeight loop=$columnHeight*$columns}
<td>
{if isset($taglist[td])}
<input type='checkbox' name='tag_{$taglist[td].id}' /><span>{$taglist[td].tag}</span>
{else}
{/if}
</td>
{/section}
</tr>
{if $smarty.section.tr.last == true}
</tbody>
</table>
{/if}
{/section}
<div id='tagTable'>
{include file='tag_table.tpl'}
</div>
<br />
<select name='tagAction'>
<option>Merge / Rename</option>
<option>Split</option>
<option>Delete</option>
<option value='merge'>Merge / Rename</option>
<option value='split'>Split</option>
<option value='delete'>Delete</option>
</select>
<input type='button' id='tagSubmit' value='Go' />
</div>
......
{--* phpTodo - Web based todo lists *}
{--* Copyright (C) 2005-12 Jason Frisvold <friz@godshell.com> *}
{--* *}
{--* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA*}
{assign var='count' value=$taglist|@count}
{assign var='columnHeight' value=ceil($count / $columns)}
{section name=tr loop=$columnHeight}
{if $smarty.section.tr.first == true}
<table id='tagList'>
<tbody>
{/if}
<tr>
{section name=td start=$smarty.section.tr.index step=$columnHeight loop=$columnHeight*$columns}
<td>
{if isset($taglist[td])}
<input type='checkbox' name='tag_{$taglist[td].id}' /><span>{$taglist[td].tag}</span>
{else}
{/if}
</td>
{/section}
</tr>
{if $smarty.section.tr.last == true}
</tbody>
</table>
{/if}
{/section}
\ No newline at end of file
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