Commit bc062c4a authored by Jason Frisvold's avatar Jason Frisvold
Browse files

- Remove feedcreator

- Rename classTodoItem to phpTodoItem
- New templates for RSS/ATOM feeds
- Extensive changes to handle Smarty Template RSS/ATOM feeds
- Add code to mark row as dirty when tags edited using popup editor
- New SQL update file for 0.9 -> 1.0
- SQL updates to support new feed creation system
parent dce9887f
......@@ -9,6 +9,10 @@
New ajax code to handle adding/modifying/deleting feeds
Moved to git, removing old SVN tags
Remove wml files.. Seriously.. It's not happening.. Thankfully.
Switch to a smarty-based RSS generator, removed feedcreator
Remove ATOM 0.3 support, add RSS 0.92 support
Rename classTodoItem to phpTodoItem to be consistent
SQL changes to support new feeds
0.9 Don't include cookies in the redirect URL
Rename the session cookie to avoid naming collisions
......
## 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 ##
# You *should* be able to pipe this through mysql to update your database
# mysql -uroot -p phpTodo < phpTodo-0.9-1.0-update.sql
# If you have altered the tables, this will probably fail. As always, BACK UP
# YOUR DATA before you try this!
DELETE FROM feed_version WHERE name = 'ATOM 0.3';
ALTER TABLE feed_version DROP version;
ALTER TABLE feed_version ADD (template CHAR(25) NOT NULL,
icon CHAR(25) NOT NULL);
INSERT INTO feed_version VALUES (NULL, 'RSS 0.92', 'feed-rss092.tpl', 'rss.gif');
UPDATE feed_version SET template = 'feed-rss091.tpl', icon = 'rss.gif' WHERE name = 'RSS 0.91';
UPDATE feed_version SET template = 'feed-rss10.tpl', icon = 'rss.gif' WHERE name = 'RSS 1.0';
UPDATE feed_version SET template = 'feed-rss20.tpl', icon = 'rss.gif' WHERE name = 'RSS 2.0';
UPDATE feed_version SET template = 'feed-atom10.tpl', icon = 'atom-icon.gif' WHERE name = 'ATOM 1.0';
UPDATE order_by SET field_name = 'l.priority' where id = 2;
UPDATE order_by SET field_name = 'l.status_id' where id = 3;
UPDATE order_by SET field_name = 'l.subject' where id = 4;
UPDATE order_by SET field_name = 'l.due_date' where id = 5;
UPDATE order_by SET field_name = 'l.start_date' where id = 6;
......@@ -123,7 +123,8 @@ CREATE TABLE description (id INTEGER UNSIGNED NOT NULL AUTO_
DROP TABLE IF EXISTS feed_version;
CREATE TABLE feed_version(id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
name CHAR(15) NOT NULL,
version CHAR(8) NOT NULL,
template CHAR(25) NOT NULL,
icon CHAR(25) NOT NULL,
PRIMARY KEY (id));
DROP TABLE IF EXISTS feeds;
......@@ -163,22 +164,22 @@ INSERT INTO status VALUES (98, 'Cancelled');
INSERT INTO status VALUES (99, 'Completed');
INSERT INTO order_by VALUES (NULL, '', 'None');
INSERT INTO order_by VALUES (NULL, 'priority.priority', 'Priority');
INSERT INTO order_by VALUES (NULL, 'status.id', 'Status');
INSERT INTO order_by VALUES (NULL, 'listentries.subject', 'Subject');
INSERT INTO order_by VALUES (NULL, 'listentries.due_date', 'Due Date');
INSERT INTO order_by VALUES (NULL, 'listentries.start_date', 'Start Date');
INSERT INTO order_by VALUES (NULL, 'l.priority', 'Priority');
INSERT INTO order_by VALUES (NULL, 'l.status_id', 'Status');
INSERT INTO order_by VALUES (NULL, 'l.subject', 'Subject');
INSERT INTO order_by VALUES (NULL, 'l.due_date', 'Due Date');
INSERT INTO order_by VALUES (NULL, 'l.start_date', 'Start Date');
INSERT INTO tags VALUES (NULL, 'None', 1);
INSERT INTO tags VALUES (NULL, 'Personal', 1);
INSERT INTO tags VALUES (NULL, 'Work', 1);
INSERT INTO tags VALUES (NULL, 'Other', 1);
INSERT INTO feed_version VALUES (NULL, 'RSS 0.91', 'RSS0.91');
INSERT INTO feed_version VALUES (NULL, 'RSS 1.0', 'RSS1.0');
INSERT INTO feed_version VALUES (NULL, 'RSS 2.0', 'RSS2.0');
INSERT INTO feed_version VALUES (NULL, 'ATOM 0.3', 'ATOM0.3');
INSERT INTO feed_version VALUES (NULL, 'ATOM 1.0', 'ATOM1.0');
INSERT INTO feed_version VALUES (NULL, 'RSS 0.91', 'feed-rss091.tpl', 'rss.gif');
INSERT INTO feed_version VALUES (NULL, 'RSS 0.92', 'feed-rss092.tpl', 'rss.gif');
INSERT INTO feed_version VALUES (NULL, 'RSS 1.0', 'feed-rss10.tpl', 'rss.gif');
INSERT INTO feed_version VALUES (NULL, 'RSS 2.0', 'feed-rss20.tpl', 'rss.gif');
INSERT INTO feed_version VALUES (NULL, 'ATOM 1.0', 'feed-atom10.tpl', 'atom-icon.gif');
INSERT INTO user_prefs VALUES (NULL, 1, 0, 0, 0, 0, 0, 0, 'none', 'asc');
......
......@@ -50,7 +50,8 @@
$feed_output['description'] = 'phpTodo Version ' . $phpTodo_version .
"\n" . 'Auto-generated RSS feed' . "\n" .
$phpTodo_homepage;
$feed_output['lastbuild'] = $builddate->format(DATE_RFC822);
$feed_output['lastbuild'] = $builddate->format(DATE_RFC1123);
$feed_output['lastbuildatom'] = $builddate->format(DATE_RFC3339);
$feed_output['generator'] = 'phpTodo Version ' . $phpTodo_version;
// Check authentication
......@@ -99,15 +100,15 @@
$query = $query . ' GROUP BY l.id';
}
// If specified, order by the specified field
if ($feed->order_by_field() != '') {
$query = $query . sprintf(' ORDER BY %s', $feed->order_by_field());
}
if ($feed->max_limit() > 0) {
$query = $query . sprintf(' LIMIT %d', $feed->max_limit());
}
// If specified, order by the specified field
//if ($feed->order_by() != '') {
// $query = $query . sprintf(' ORDER BY %s', $feed->order_by());
//}
// Execute the query
if ($result = $sqlhdlr->query($query)) {
// Place the results into a two dimensional array
......@@ -133,20 +134,32 @@
$feedDesc .= $todoitem->description();
$entries[$loop]['title'] = $todoitem->subject() . ' (' .
$todoitem->priority_name() . ')';
$entries[$loop]['link'] = $phpTodo_serveruri .
$phpTodo_serverpath .
'taskmodify.php?edit=Edit&' .
'task_id=' .
$todoitem->task_id();
$entries[$loop]['description'] = nl2br("$feedDesc");
$entries[$loop]['title'] = $todoitem->subject() . ' (' .
$todoitem->priority_name() .
')';
$entries[$loop]['link'] = $phpTodo_serveruri .
$phpTodo_serverpath .
'taskmodify.php?edit=Edit&' .
'task_id=' .
$todoitem->task_id();
$entries[$loop]['description'] = nl2br("$feedDesc");
$createdate = DateTime::createFromFormat('m-d-Y',
$todoitem->create_date());
$entries[$loop]['createdate'] = $createdate->format(DATE_RFC822);
$entries[$loop]['source'] = '';
$entries[$loop]['author'] = $user_obj->email() . ' (' .
$user_obj->username() . ')';
$entries[$loop]['createdate'] =
$createdate->format(DATE_RFC1123);
$entries[$loop]['createdateatom'] =
$createdate->format(DATE_RFC3339);
$updateddate = DateTime::createFromFormat('m-d-Y',
$todoitem->last_modified());
$entries[$loop]['updated'] =
$updateddate->format(DATE_RFC1123);
$entries[$loop]['updatedatom'] =
$updateddate->format(DATE_RFC3339);
$entries[$loop]['source'] = '';
$entries[$loop]['author'] = $user_obj->email() . ' (' .
$user_obj->username() . ')';
$entries[$loop]['authorname'] = $user_obj->username();
$entries[$loop]['authoremail'] = $user_obj->email();
$loop++;
}
......@@ -159,10 +172,25 @@
}
// Assign the array to a template variable (if there is an array)
if (! empty($entries)) {
$smarty->assign('entries', $entries);
if (empty($entries)) {
$createdate = new DateTime();
$updateddate = new DateTime();
$entries[0]['title'] = 'No Entries';
$entries[0]['link'] = '';
$entries[0]['description'] = '';
$entries[0]['createdate'] = $createdate->format(DATE_RFC1123);
$entries[0]['createdateatom'] = $createdate->format(DATE_RFC3339);
$entries[0]['updated'] = $updateddate->format(DATE_RFC1123);
$entries[0]['updatedatom'] = $updateddate->format(DATE_RFC3339);
$entries[0]['source'] = '';
$entries[0]['author'] = $user_obj->email() . ' (' .
$user_obj->username() . ')';
$entries[0]['authorname'] = $user_obj->username();
$entries[0]['authoremail'] = $user_obj->email();
}
$smarty->assign('entries', $entries);
$smarty->assign('feed', $feed_output);
// Close the MySQL handler
......@@ -174,5 +202,5 @@
str_replace(' ', '' , $feed->name() . ' - phpTodo RSS Feed.xml'));
// Display the Feed
$smarty->display('feed-rss091.tpl');
$smarty->display($feed->template());
?>
......@@ -71,6 +71,7 @@
// Variable to hold the taglist input element
taglist = $( this ).siblings('input');
tagparent = $( this ).parents('tr');
$.ajax({
url: 'feeds_ajax.php',
......@@ -82,7 +83,10 @@
$( '#popup' ).append(data.output);
$( '#tags' ).val( taglist.val() );
$( '#okbutton' ).bind('click', function() {
taglist.val( $( '#tags' ).val() );
if (taglist.val() != $( '#tags' ).val() ) {
taglist.val( $( '#tags' ).val() );
tagparent.addClass('dirty');
}
$( '#popup' ).remove();
$( '#blanket' ).remove();
});
......
......@@ -42,9 +42,12 @@ class phpTodoFeed {
private $status_id; // Integer
private $tag_filter; // Char(255)
private $order_by; // Integer
private $order_by_field; // Char(30)
private $max_limit; // Integer
private $show_completed; // Boolean
private $version; // Char(8)
private $template; // Char(25)
private $icon; // Char(25)
private $sqlhdlr; // Object
......@@ -89,10 +92,10 @@ class phpTodoFeed {
$this->feed_id = $feed_id;
// Create the necessary sql statement
$query = sprintf('SELECT secret, name, priority_min, priority_max, ' .
'status_id, tag_filter, order_by, max_limit, ' .
'show_completed, version FROM feeds WHERE ' .
'id = %d AND user_id = %d', $this->feed_id,
$query = sprintf('SELECT f.secret, f.name, f.priority_min, f.priority_max, ' .
'f.status_id, f.tag_filter, f.order_by, o.field_name, f.max_limit, ' .
'f.show_completed, f.version, v.template, v.icon FROM feeds AS f, order_by AS o, feed_version AS v WHERE v.id = f.version AND o.id = f.order_by AND ' .
'f.id = %d AND f.user_id = %d', $this->feed_id,
$this->user_id);
if ($result = $this->sqlhdlr->query($query)) {
......@@ -121,9 +124,12 @@ class phpTodoFeed {
$get_tag_name->close();
}
$this->order_by = $line[6];
$this->max_limit = $line[7];
$this->show_completed = $line[8];
$this->version = $line[9];
$this->order_by_field = $line[7];
$this->max_limit = $line[8];
$this->show_completed = $line[9];
$this->version = $line[10];
$this->template = $line[11];
$this->icon = $line[12];
$result->close();
} else {
......@@ -141,9 +147,12 @@ class phpTodoFeed {
$this->status_id = 0;
$this->tag_filter = array();
$this->order_by = 1;
$this->order_by_field = '';
$this->max_limit = 0;
$this->show_completed = 0;
$this->version = 'RSS0.91';
$this->version = 0;
$this->template = '';
$this->icon = '';
$this->dirty_flag = true;
}
......@@ -340,6 +349,13 @@ class phpTodoFeed {
return $this->order_by;
}
/**
* Return the field used to sort entries
*/
public function order_by_field() {
return $this->order_by_field;
}
/**
* Set / Return the max limit
*
......@@ -400,6 +416,20 @@ class phpTodoFeed {
return $this->version;
}
/**
* Return the template filename representing the feed's version
*/
public function template() {
return $this->template;
}
/**
* Return the icon filename representing the feed's version
*/
public function icon() {
return $this->icon;
}
/**
* Set the delete flag value
*/
......
......@@ -136,6 +136,7 @@
$feeds[$loop]['feed_max'] = $feed->max_limit();
$feeds[$loop]['feed_show'] = $feed->show_completed();
$feeds[$loop]['feed_version'] = $feed->version();
$feeds[$loop]['feed_icon'] = $feed->icon();
$loop++;
}
......
......@@ -178,6 +178,6 @@ require_once('libs/sec_check.php');
require_once('libs/phpTodoUser.php');
require_once('libs/phpTodoFeed.php');
require_once('libs/funcs.php');
require_once('libs/classTodoItem.php');
require_once('libs/phpTodoItem.php');
require_once('libs/phpTodoTag.php');
?>
{* 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 *}
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text">{$feed.title|escape:'html'}</title>
<!-- <subtitle type="html">
A &lt;em&gt;lot&lt;/em&gt; of effort
went into making this effortless
</subtitle>
--> <updated>{$feed.lastbuildatom}</updated>
<id>{$feed.link|escape:'html'}</id>
<link rel="self" type="application/atom+xml"
href="{$feed.link|escape:'html'}"/>
<!-- <rights>Copyright (c) 2003, Mark Pilgrim</rights>
<generator uri="http://www.example.com/" version="1.0">
Example Toolkit
</generator>
-->
<generator>{$feed.generator}</generator>
{foreach from=$entries item=entry}
<entry>
<title>{$entry.title|escape:'html'}</title>
<link href="{$entry.link|escape:'html'}"/>
<id>{$entry.link|escape:'html'}</id>
<updated>{$entry.updatedatom}</updated>
<published>{$entry.createdateatom}</published>
<author>
<name>{$entry.authorname|escape:'html'}</name>
<email>{$entry.authoremail|escape:'html'}</email>
</author>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">{$entry.description}</div>
</content>
</entry>
{/foreach}
</feed>
\ No newline at end of file
......@@ -21,13 +21,12 @@
<link>{$feed.link|escape:'html'}</link>
<description>{$feed.description|escape:'html'}</description>
<lastBuildDate>{$feed.lastbuild}</lastBuildDate>
<generator>{$feed.generator}</generator>
<!-- <language>en-us</language>
<copyright>Copyright 2000, WriteTheWeb team.</copyright>
<managingEditor>editor@writetheweb.com</managingEditor>
<webMaster>webmaster@writetheweb.com</webMaster>
-->
<!-- <image>
<image>
<title>WriteTheWeb</title>
<url>http://writetheweb.com/images/mynetscape88.gif</url>
<link>http://writetheweb.com</link>
......
{* 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 *}
<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="0.91">
<channel>
<title>{$feed.title|escape:'html'}</title>
<link>{$feed.link|escape:'html'}</link>
<description>{$feed.description|escape:'html'}</description>
<lastBuildDate>{$feed.lastbuild}</lastBuildDate>
<!-- <language>en-us</language>
<copyright>Copyright 2000, WriteTheWeb team.</copyright>
<managingEditor>editor@writetheweb.com</managingEditor>
<webMaster>webmaster@writetheweb.com</webMaster>
<image>
<title>WriteTheWeb</title>
<url>http://writetheweb.com/images/mynetscape88.gif</url>
<link>http://writetheweb.com</link>
<width>88</width>
<height>31</height>
<description>News for web users that write back</description>
</image>
-->
{foreach from=$entries item=entry}
<item>
<title>{$entry.title|escape:'html'}</title>
<link>{$entry.link|escape:'html'}</link>
<description>{$entry.description|escape:'html'}</description>
<author>{$entry.author|escape:'html'}</author>
<pubDate>{$entry.createdate}</pubDate>
</item>
{/foreach}
</channel>
</rss>
\ No newline at end of file
{* 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 *}
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/"
>
<channel rdf:about="http://www.xml.com/xml/news.rss">
<title>{$feed.title|escape:'html'}</title>
<link>{$feed.link|escape:'html'}</link>
<description>{$feed.description|escape:'html'}</description>
<!-- <image rdf:resource="http://xml.com/universal/images/xml_tiny.gif" />
-->
<items>
<rdf:Seq>
{foreach from=$entries item=entry}
<rdf:li resource="{$entry.link|escape:'html'}" />
{/foreach}
</rdf:Seq>
</items>
<!-- <textinput rdf:resource="http://search.xml.com" />
-->
</channel>
<!-- <image rdf:about="http://xml.com/universal/images/xml_tiny.gif">
<title>XML.com</title>
<link>http://www.xml.com</link>
<url>http://xml.com/universal/images/xml_tiny.gif</url>
</image>
-->
{foreach from=$entries item=entry}
<item rdf:about="{$entry.link|escape:'html'}">
<title>{$entry.title|escape:'html'}</title>
<link>{$entry.link|escape:'html'}</link>
<description>{$entry.description|escape:'html'}</description>
</item>
{/foreach}
<!-- <textinput rdf:about="http://search.xml.com">
<title>Search XML.com</title>
<description>Search XML.com's XML collection</description>
<name>s</name>
<link>http://search.xml.com</link>
</textinput>
-->
</rdf:RDF>
\ No newline at end of file
{* 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 *}
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>{$feed.title|escape:'html'}</title>
<link>{$feed.link|escape:'html'}</link>
<description>{$feed.description|escape:'html'}</description>
<pubDate>{$feed.lastbuild}</pubDate>
<lastBuildDate>{$feed.lastbuild}</lastBuildDate>
<generator>{$feed.generator}</generator>
<!-- <language>en-us</language>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<managingEditor>editor@example.com</managingEditor>
<webMaster>webmaster@example.com</webMaster>
-->
{foreach from=$entries item=entry}
<item>
<title>{$entry.title|escape:'html'}</title>
<link>{$entry.link|escape:'html'}</link>
<description>{$entry.description|escape:'html'}</description>
<author>{$entry.author|escape:'html'}</author>
<pubDate>{$entry.createdate}</pubDate>
<guid>{$entry.link|escape:'html'}</guid>
</item>
{/foreach}
</channel>
</rss>
\ No newline at end of file
......@@ -18,14 +18,10 @@
<td>
{if (isset($row))}
<a href='feed.php?user_id={$user_id}&amp;secret={$row.feed_secret}&amp;feed_id={$row.feed_id}'>
{if (($row.feed_version == 'ATOM0.3') || ($row.feed_version == 'ATOM1.0'))}
<img src='images/atom-icon.gif' alt='ATOM Feed' />
{else}
<img src='images/rss.gif' alt='RSS Feed' />
{/if}
<img src='images/{$row.feed_icon}' alt='Feed Icon' />
</a>
{else}
<img src='images/rss.gif' alt='RSS Feed' />
<img src='images/rss.gif' alt='Feed Icon' />
{/if}
</td><td>
<select name='feed_version'>
......
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