mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
+ RSS 2.0 feed
This commit is contained in:
parent
950bff9f6f
commit
285bd80c26
12 changed files with 114 additions and 28 deletions
|
|
@ -76,6 +76,7 @@ class Lang extends DefaultLang
|
|||
'alltags_show' => "Показать все",
|
||||
'alltags_hide' => "Скрыть все",
|
||||
'a_settings' => "Настройки",
|
||||
'rss_feed' => "RSS-лента",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -863,7 +863,6 @@ function editFormResize(startstop, event)
|
|||
|
||||
function mttTabSelected(el, indx)
|
||||
{
|
||||
|
||||
$(el.parentNode.parentNode).children('.mtt-tabs-selected').removeClass('mtt-tabs-selected');
|
||||
$(el.parentNode).addClass('mtt-tabs-selected');
|
||||
if(!tabLists[indx]) return;
|
||||
|
|
@ -874,6 +873,7 @@ function mttTabSelected(el, indx)
|
|||
$('#searchbarkeyword').text('');
|
||||
$('#searchbar').hide();
|
||||
}
|
||||
if(flag.canAllRead) $('#rss_icon').find('a').attr('href', 'feed.php?list='+tabLists[indx].id);
|
||||
}
|
||||
curList = tabLists[indx];
|
||||
flag.tagsChanged = true;
|
||||
|
|
@ -977,12 +977,14 @@ function loadLists(onInit)
|
|||
}
|
||||
curList = tabLists[0];
|
||||
loadTasks();
|
||||
if(flag.canAllRead) $('#rss_icon').show().find('a').attr('href', 'feed.php?list='+curList.id);
|
||||
}
|
||||
else {
|
||||
curList = 0;
|
||||
$('#lists .mtt-htabs').children().addClass('invisible');
|
||||
$('#page_tasks h3').children().addClass('invisible');
|
||||
$('#mylistscontainer .mtt-need-list').addClass('li-disabled');
|
||||
$('#rss_icon').hide();
|
||||
}
|
||||
ti += '<li class="mtt-tabs-button menu-owner"><a href="#" id="mylists" onClick="btnMenu(this);return false;"><img src="images/arrdown.gif"></a></li>';
|
||||
$('#lists>ul').html(ti);
|
||||
|
|
@ -1152,4 +1154,4 @@ function submitFullTask(form)
|
|||
$("#edittags").flushCache();
|
||||
flag.tagsChanged = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
29
src/ajax.php
29
src/ajax.php
|
|
@ -596,15 +596,15 @@ function prepare_duedate($duedate, $tz=null)
|
|||
}
|
||||
$diff = mktime(0,0,0,$ad[1],$ad[2],$ad[0]) - mktime(0,0,0,$at[1],$at[2],$at[0]);
|
||||
|
||||
if($diff < -604800 && $ad[0] == $at[0]) { $a['class'] = 'past'; $a['str'] = formatDate3($config['dateformatshort'], (int)$ad[0], (int)$ad[1], (int)$ad[2]); }
|
||||
elseif($diff < -604800) { $a['class'] = 'past'; $a['str'] = formatDate3($config['dateformat'], (int)$ad[0], (int)$ad[1], (int)$ad[2]); }
|
||||
if($diff < -604800 && $ad[0] == $at[0]) { $a['class'] = 'past'; $a['str'] = formatDate3($config['dateformatshort'], (int)$ad[0], (int)$ad[1], (int)$ad[2], $lang); }
|
||||
elseif($diff < -604800) { $a['class'] = 'past'; $a['str'] = formatDate3($config['dateformat'], (int)$ad[0], (int)$ad[1], (int)$ad[2], $lang); }
|
||||
elseif($diff < -86400) { $a['class'] = 'past'; $a['str'] = sprintf($lang->get('daysago'),ceil(abs($diff)/86400)); }
|
||||
elseif($diff < 0) { $a['class'] = 'past'; $a['str'] = $lang->get('yesterday'); }
|
||||
elseif($diff < 86400) { $a['class'] = 'today'; $a['str'] = $lang->get('today'); }
|
||||
elseif($diff < 172800) { $a['class'] = 'today'; $a['str'] = $lang->get('tomorrow'); }
|
||||
elseif($diff < 691200) { $a['class'] = 'soon'; $a['str'] = sprintf($lang->get('indays'),ceil($diff/86400)); }
|
||||
elseif($ad[0] == $at[0]) { $a['class'] = 'future'; $a['str'] = formatDate3($config['dateformatshort'], (int)$ad[0], (int)$ad[1], (int)$ad[2]); }
|
||||
else { $a['class'] = 'future'; $a['str'] = formatDate3($config['dateformat'], (int)$ad[0], (int)$ad[1], (int)$ad[2]); }
|
||||
elseif($ad[0] == $at[0]) { $a['class'] = 'future'; $a['str'] = formatDate3($config['dateformatshort'], (int)$ad[0], (int)$ad[1], (int)$ad[2], $lang); }
|
||||
else { $a['class'] = 'future'; $a['str'] = formatDate3($config['dateformat'], (int)$ad[0], (int)$ad[1], (int)$ad[2], $lang); }
|
||||
|
||||
if($config['duedateformat'] == 2) $a['formatted'] = (int)$ad[1].'/'.(int)$ad[2].'/'.$ad[0];
|
||||
elseif($config['duedateformat'] == 3) $a['formatted'] = $ad[2].'.'.$ad[1].'.'.$ad[0];
|
||||
|
|
@ -656,25 +656,4 @@ function myExceptionHandler($e)
|
|||
exit;
|
||||
}
|
||||
|
||||
function formatDate3($format, $ay, $am, $ad)
|
||||
{
|
||||
# F - month long, M - month short
|
||||
# m - month 2-digit, n - month 1-digit
|
||||
# d - day 2-digit, j - day 1-digit
|
||||
global $lang;
|
||||
$ml = $lang->get('months_long');
|
||||
$ms = $lang->get('months_short');
|
||||
$Y = $ay;
|
||||
$n = $am;
|
||||
$m = $n < 10 ? '0'.$n : $n;
|
||||
$F = $ml[$am-1];
|
||||
$M = $ms[$am-1];
|
||||
$j = $ad;
|
||||
$d = $j < 10 ? '0'.$j : $j;
|
||||
return str_replace(
|
||||
array('Y','F','M','n','m','d','j'),
|
||||
array($Y, $F, $M, $n, $m, $d, $j),
|
||||
$format);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -109,4 +109,24 @@ class Config
|
|||
}
|
||||
}
|
||||
|
||||
function formatDate3($format, $ay, $am, $ad, $lang)
|
||||
{
|
||||
# F - month long, M - month short
|
||||
# m - month 2-digit, n - month 1-digit
|
||||
# d - day 2-digit, j - day 1-digit
|
||||
$ml = $lang->get('months_long');
|
||||
$ms = $lang->get('months_short');
|
||||
$Y = $ay;
|
||||
$n = $am;
|
||||
$m = $n < 10 ? '0'.$n : $n;
|
||||
$F = $ml[$am-1];
|
||||
$M = $ms[$am-1];
|
||||
$j = $ad;
|
||||
$d = $j < 10 ? '0'.$j : $j;
|
||||
return str_replace(
|
||||
array('Y','F','M','n','m','d','j'),
|
||||
array($Y, $F, $M, $n, $m, $d, $j),
|
||||
$format);
|
||||
}
|
||||
|
||||
?>
|
||||
78
src/feed.php
Normal file
78
src/feed.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
This file is part of myTinyTodo.
|
||||
(C) Copyright 2009 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
Licensed under the GNU GPL v3 license. See file COPYRIGHT for details.
|
||||
*/
|
||||
|
||||
$dontStartSession = 1;
|
||||
require_once('./init.php');
|
||||
require_once('./lang/class.default.php');
|
||||
require_once('./lang/'.$config['lang'].'.php');
|
||||
$lang = new Lang();
|
||||
|
||||
if(!canAllRead()) {
|
||||
die("Access denied!<br> Disable password protection or Grant read access");
|
||||
}
|
||||
|
||||
$listId = (int)_get('list');
|
||||
|
||||
$listData = $db->sqa("SELECT * FROM lists WHERE id=$listId");
|
||||
if(!$listData) {
|
||||
die("No such list");
|
||||
}
|
||||
htmlarray_ref($listData);
|
||||
|
||||
$data = array();
|
||||
$q = $db->dq("SELECT * FROM todolist WHERE list_id=$listId ORDER BY d DESC LIMIT 100");
|
||||
while($r = $q->fetch_assoc($q))
|
||||
{
|
||||
if($r['prio'] > 0) $r['prio'] = '+'.$r['prio'];
|
||||
$a = array();
|
||||
if($r['prio']) $a[] = $lang->get('priority'). ": $r[prio]";
|
||||
if($r['duedate'] != '') {
|
||||
$ad = explode('-', $r['duedate']);
|
||||
$a[] = $lang->get('due'). ": ".formatDate3($config['dateformat'], (int)$ad[0], (int)$ad[1], (int)$ad[2], $lang);
|
||||
}
|
||||
if($r['tags'] != '') $a[] = $lang->get('tags'). ": ". str_replace(',', ', ', $r['tags']);
|
||||
$r['_descr'] = nl2br($r['note']). ($a && $r['note']!='' ? "<br><br>" : ""). implode("<br>", $a);
|
||||
$data[] = htmlarray($r);
|
||||
}
|
||||
|
||||
printRss($listData, $data);
|
||||
|
||||
|
||||
function printRss($listData, $data)
|
||||
{
|
||||
$link = htmlarray('http://'. $_SERVER['HTTP_HOST']. substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/') + 1));
|
||||
$buildDate = gmdate('r');
|
||||
|
||||
$s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n<channel>\n".
|
||||
"<title>$listData[name]</title>\n<link>$link</link>\n<description>New tasks in $listData[name]</description>\n".
|
||||
"<lastBuildDate>$buildDate</lastBuildDate>\n\n";
|
||||
|
||||
foreach($data as $v)
|
||||
{
|
||||
$da = explode(' ', $v['d']);
|
||||
$dDate = explode('-', $da[0]);
|
||||
$dTime = explode(':', $da[1]);
|
||||
$d = gmdate('r', mktime((int)$dTime[0],(int)$dTime[1],(int)$dTime[2], (int)$dDate[1],(int)$dDate[2],(int)$dDate[0]));
|
||||
|
||||
$guid = $listData['id'].'-'.$v['id'].'-'.$da[0].'_'.$da[1];
|
||||
|
||||
$s .= "<item>\n<title>$v[title]</title>\n".
|
||||
"<link>$link</link>\n".
|
||||
"<pubDate>$d</pubDate>\n".
|
||||
"<description>$v[_descr]</description>\n".
|
||||
"<guid isPermaLink=\"false\">$guid</guid>\n".
|
||||
"</item>\n";
|
||||
}
|
||||
|
||||
$s .= "</channel>\n</rss>";
|
||||
|
||||
header("Content-type: text/xml");
|
||||
print $s;
|
||||
}
|
||||
|
||||
?>
|
||||
BIN
src/images/feed.png
Normal file
BIN
src/images/feed.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 691 B |
BIN
src/images/feed_bw.png
Normal file
BIN
src/images/feed_bw.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 714 B |
|
|
@ -124,6 +124,8 @@ $().ajaxStop( function(r,s) {$("#loading").fadeOut();} );
|
|||
| <a href="#" class="htab-toggle" onClick="addsearchToggle(0);this.blur();return false;"><?php __('htab_newtask');?></a>
|
||||
<div id="searchbar"><?php __('searching');?> <span id="searchbarkeyword"></span></div>
|
||||
</span>
|
||||
|
||||
<span id="rss_icon" style="display:none;"><a href="#" title="<?php __('rss_feed');?>"><img src="images/feed_bw.png" style="border:none;" onMouseOver="this.src='images/feed.png'" onMouseOut="this.src='images/feed_bw.png'"></a></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ else
|
|||
|
||||
|
||||
$needAuth = (isset($config['password']) && $config['password'] != '') ? 1 : 0;
|
||||
if($needAuth)
|
||||
if($needAuth && !isset($dontStartSession))
|
||||
{
|
||||
if(isset($config['session']) && $config['session'] == 'files')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ class DefaultLang
|
|||
'alltags_show' => "Show all",
|
||||
'alltags_hide' => "Hide all",
|
||||
'a_settings' => "Settings",
|
||||
'rss_feed' => "RSS Feed",
|
||||
);
|
||||
|
||||
var $js = array();
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ class Lang extends DefaultLang
|
|||
'alltags_show' => "Show all",
|
||||
'alltags_hide' => "Hide all",
|
||||
'a_settings' => "Settings",
|
||||
'rss_feed' => "RSS Feed",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ a { color:#0000ff; }
|
|||
#sortform .li:hover { background-color:#316AC5; color:white; }
|
||||
|
||||
.mtt-notes-showhide { font-size:8pt; font-weight:normal; margin-left:5px; }
|
||||
#rss_icon { float:right;margin-top:4px; }
|
||||
|
||||
.task-left { float:left; }
|
||||
.task-left .mtt-toggle { margin-top:2px; cursor:pointer; width:15px; height:15px; float:left; background:url(images/toggle_plus.gif) left top no-repeat; }
|
||||
|
|
@ -184,6 +185,7 @@ div.task-note-area textarea { color:#999999; width:100%; display:block; height:6
|
|||
.mtt-btnmenu-container .li { margin:1px 0px; padding:2px; cursor:pointer; }
|
||||
.mtt-btnmenu-container .li:hover { background-color:#316AC5; color:white; }
|
||||
.mtt-btnmenu-container .li.mtt-need-list.li-disabled {color:#ACA899; }
|
||||
.mtt-btnmenu-delimiter { height:0px; border-top:1px solid #cccccc; margin:2px -1px 2px -1px }
|
||||
|
||||
.mtt-settings-table { width:100%; border-collapse:collapse; }
|
||||
.mtt-settings-table th, .mtt-settings-table td { border-bottom:1px solid #dedede; padding:8px; vertical-align:top; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue