You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
376 lines
10 KiB
376 lines
10 KiB
14 years ago
|
<?php if (!defined('PmWiki')) exit();
|
||
|
/*
|
||
|
inspired by PageFeed by Daniel Roesler (diafygi)
|
||
|
conversation array imported from it
|
||
|
|
||
|
XXX
|
||
|
warning, this SHOULD be outdated by memory_management.php
|
||
|
*/
|
||
|
|
||
|
## Recipe version information
|
||
|
$RecipeInfo['Preparation']['Version'] = '2010-04-02';
|
||
|
|
||
|
## Add action for pagefeed
|
||
|
SDV($HandleActions['preparation'], 'Preparation');
|
||
|
|
||
|
function subDate($date,$day)//add days
|
||
|
{
|
||
|
$sum = strtotime(date("Y-m-d", strtotime("$date")) . " -$day days");
|
||
|
$dateTo=date('Y-m-d',$sum);
|
||
|
return $dateTo;
|
||
|
}
|
||
|
function reconvertdate($date) {
|
||
|
return preg_replace("/(\d+)\/(\d+)\/(\d+)/",'$3-$2-$1',$date);
|
||
|
}
|
||
|
|
||
|
## Create feed from page history
|
||
|
function Preparation($pagename, $auth = 'read') {
|
||
|
global $FarmD, $WikiTitle, $ScriptUrl;
|
||
|
$feedfile = $FarmD."/pub/preparationfeed.xml"; #change to a pattern when support arguments
|
||
|
$datestorecall = array(1,10,30,60,120,350,700,1500,3000,7000,15000,30000,100000);
|
||
|
// $datestorecall = array(1,10,30,60..,61,62..,80..);
|
||
|
$varname='startprepare';
|
||
|
|
||
|
$pages = ListPages();
|
||
|
# open $feed as read
|
||
|
if (!file_exists($feedfile))
|
||
|
if (!touch($feedfile))
|
||
|
print "Creation of the feed file fails, check write permissions for pmWiki and $feedfile.";
|
||
|
|
||
|
$feed_oldcontent = file_get_contents($feedfile);
|
||
|
|
||
|
$feed_newcontent = '';
|
||
|
|
||
|
# 2 loops can be probably optimized since they are ordered by date
|
||
|
foreach ($pages as $page) {
|
||
|
$dateprepare = PageTextVar($page,$varname);
|
||
|
if ( isset($dateprepare) ) {
|
||
|
foreach ($datestorecall as $day) {
|
||
|
# print $page . " ";
|
||
|
$checkdate = subDate(reconvertdate($dateprepare),$day);
|
||
|
# print $dateprepare . " + " . $day . " (" . $checkdate . ") == " . date("d/m/Y");
|
||
|
if ($checkdate==reconvertdate(date("d/m/Y")))
|
||
|
{
|
||
|
# print " recall time";
|
||
|
# generate GUID
|
||
|
$item_GUID = $page.'_'.$checkdate;
|
||
|
# if not present in file using a regex on the GUID
|
||
|
if (preg_match("/$item_GUID/",$feed_oldcontent) == 0)
|
||
|
{
|
||
|
|
||
|
# generate date
|
||
|
$feed_newitemdate = date(DATE_RSS, time());
|
||
|
# transform line to XML format
|
||
|
$feed_newitem = " <item>
|
||
|
<title>Day $day of preparation for page $page started at $dateprepare</title>
|
||
|
<link>$ScriptUrl/$page#PreparationDay$day</link>
|
||
|
<description>This is to improve preparation of things you will have to produce. Also don't forget to improve those instructions to be more and more efficient!</description>
|
||
|
<guid>$item_GUID</guid>
|
||
|
<pubDate>$feed_newitemdate</pubDate>
|
||
|
</item>";
|
||
|
# appending the item
|
||
|
$feed_newcontent .= $feed_newitem;
|
||
|
}
|
||
|
break; #we can't have 2 days at the same time
|
||
|
}
|
||
|
# print "<br/>";
|
||
|
} # check if the next recall day is today
|
||
|
} # check if the next page is tagged
|
||
|
}
|
||
|
# feed should be properly updated
|
||
|
|
||
|
$feed_newdate = date(DATE_RSS, time());
|
||
|
|
||
|
$feed_header = "<?xml version=\"1.0\"?>
|
||
|
<rss version=\"2.0\">
|
||
|
<channel>
|
||
|
<title>Preparation feed for $WikiTitle .</title>
|
||
|
<link>$ScriptUrl</link>
|
||
|
<description>Receive links to the page you tagged in order to have optimal preparation.</description>
|
||
|
<lastBuildDate>$feed_newdate</lastBuildDate>";
|
||
|
|
||
|
$feed_footer = "
|
||
|
</channel>
|
||
|
</rss>";
|
||
|
|
||
|
|
||
|
# print header
|
||
|
print $feed_header;
|
||
|
|
||
|
# print items
|
||
|
print $feed_oldcontent;
|
||
|
# $feed_newcontent = str_replace(array_keys($EntitiesTable), array_values($EntitiesTable), $feed_newcontent);
|
||
|
print $feed_newcontent;
|
||
|
|
||
|
# print footer
|
||
|
print $feed_footer;
|
||
|
|
||
|
$write_result = file_put_contents($feedfile,$feed_oldcontent.$feed_newcontent);
|
||
|
if (!$write_result)
|
||
|
if (strlen($feed_oldcontent.$feed_newcontent)>0)
|
||
|
print "Creation of the feed file fails, check write permissions for pmWiki and $feedfile.";
|
||
|
else
|
||
|
print "No item to generate, did you correctly tag your pages?";
|
||
|
}
|
||
|
|
||
|
## Since most feeds don't understand html character entities, we
|
||
|
## convert the common ones to their numeric form here.
|
||
|
## Taken from /scripts/feeds.php
|
||
|
SDVA($EntitiesTable, array(
|
||
|
# entities defined in "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent"
|
||
|
' ' => ' ',
|
||
|
'¡' => '¡',
|
||
|
'¢' => '¢',
|
||
|
'£' => '£',
|
||
|
'¤' => '¤',
|
||
|
'¥' => '¥',
|
||
|
'¦' => '¦',
|
||
|
'§' => '§',
|
||
|
'¨' => '¨',
|
||
|
'©' => '©',
|
||
|
'ª' => 'ª',
|
||
|
'«' => '«',
|
||
|
'¬' => '¬',
|
||
|
'­' => '­',
|
||
|
'®' => '®',
|
||
|
'¯' => '¯',
|
||
|
'°' => '°',
|
||
|
'±' => '±',
|
||
|
'²' => '²',
|
||
|
'³' => '³',
|
||
|
'´' => '´',
|
||
|
'µ' => 'µ',
|
||
|
'¶' => '¶',
|
||
|
'·' => '·',
|
||
|
'¸' => '¸',
|
||
|
'¹' => '¹',
|
||
|
'º' => 'º',
|
||
|
'»' => '»',
|
||
|
'¼' => '¼',
|
||
|
'½' => '½',
|
||
|
'¾' => '¾',
|
||
|
'¿' => '¿',
|
||
|
'À' => 'À',
|
||
|
'Á' => 'Á',
|
||
|
'Â' => 'Â',
|
||
|
'Ã' => 'Ã',
|
||
|
'Ä' => 'Ä',
|
||
|
'Å' => 'Å',
|
||
|
'Æ' => 'Æ',
|
||
|
'Ç' => 'Ç',
|
||
|
'È' => 'È',
|
||
|
'É' => 'É',
|
||
|
'Ê' => 'Ê',
|
||
|
'Ë' => 'Ë',
|
||
|
'Ì' => 'Ì',
|
||
|
'Í' => 'Í',
|
||
|
'Î' => 'Î',
|
||
|
'Ï' => 'Ï',
|
||
|
'Ð' => 'Ð',
|
||
|
'Ñ' => 'Ñ',
|
||
|
'Ò' => 'Ò',
|
||
|
'Ó' => 'Ó',
|
||
|
'Ô' => 'Ô',
|
||
|
'Õ' => 'Õ',
|
||
|
'Ö' => 'Ö',
|
||
|
'×' => '×',
|
||
|
'Ø' => 'Ø',
|
||
|
'Ù' => 'Ù',
|
||
|
'Ú' => 'Ú',
|
||
|
'Û' => 'Û',
|
||
|
'Ü' => 'Ü',
|
||
|
'Ý' => 'Ý',
|
||
|
'Þ' => 'Þ',
|
||
|
'ß' => 'ß',
|
||
|
'à' => 'à',
|
||
|
'á' => 'á',
|
||
|
'â' => 'â',
|
||
|
'ã' => 'ã',
|
||
|
'ä' => 'ä',
|
||
|
'å' => 'å',
|
||
|
'æ' => 'æ',
|
||
|
'ç' => 'ç',
|
||
|
'è' => 'è',
|
||
|
'é' => 'é',
|
||
|
'ê' => 'ê',
|
||
|
'ë' => 'ë',
|
||
|
'ì' => 'ì',
|
||
|
'í' => 'í',
|
||
|
'î' => 'î',
|
||
|
'ï' => 'ï',
|
||
|
'ð' => 'ð',
|
||
|
'ñ' => 'ñ',
|
||
|
'ò' => 'ò',
|
||
|
'ó' => 'ó',
|
||
|
'ô' => 'ô',
|
||
|
'õ' => 'õ',
|
||
|
'ö' => 'ö',
|
||
|
'÷' => '÷',
|
||
|
'ø' => 'ø',
|
||
|
'ù' => 'ù',
|
||
|
'ú' => 'ú',
|
||
|
'û' => 'û',
|
||
|
'ü' => 'ü',
|
||
|
'ý' => 'ý',
|
||
|
'þ' => 'þ',
|
||
|
'ÿ' => 'ÿ',
|
||
|
# entities defined in "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent"
|
||
|
'"' => '"',
|
||
|
#'&' => '&#38;',
|
||
|
#'<' => '&#60;',
|
||
|
#'>' => '>',
|
||
|
''' => ''',
|
||
|
'Œ' => 'Œ',
|
||
|
'œ' => 'œ',
|
||
|
'Š' => 'Š',
|
||
|
'š' => 'š',
|
||
|
'Ÿ' => 'Ÿ',
|
||
|
'ˆ' => 'ˆ',
|
||
|
'˜' => '˜',
|
||
|
' ' => ' ',
|
||
|
' ' => ' ',
|
||
|
' ' => ' ',
|
||
|
'‌' => '‌',
|
||
|
'‍' => '‍',
|
||
|
'‎' => '‎',
|
||
|
'‏' => '‏',
|
||
|
'–' => '–',
|
||
|
'—' => '—',
|
||
|
'‘' => '‘',
|
||
|
'’' => '’',
|
||
|
'‚' => '‚',
|
||
|
'“' => '“',
|
||
|
'”' => '”',
|
||
|
'„' => '„',
|
||
|
'†' => '†',
|
||
|
'‡' => '‡',
|
||
|
'‰' => '‰',
|
||
|
'‹' => '‹',
|
||
|
'›' => '›',
|
||
|
'€' => '€',
|
||
|
# entities defined in "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent"
|
||
|
'ƒ' => 'ƒ',
|
||
|
'Α' => 'Α',
|
||
|
'Β' => 'Β',
|
||
|
'Γ' => 'Γ',
|
||
|
'Δ' => 'Δ',
|
||
|
'Ε' => 'Ε',
|
||
|
'Ζ' => 'Ζ',
|
||
|
'Η' => 'Η',
|
||
|
'Θ' => 'Θ',
|
||
|
'Ι' => 'Ι',
|
||
|
'Κ' => 'Κ',
|
||
|
'Λ' => 'Λ',
|
||
|
'Μ' => 'Μ',
|
||
|
'Ν' => 'Ν',
|
||
|
'Ξ' => 'Ξ',
|
||
|
'Ο' => 'Ο',
|
||
|
'Π' => 'Π',
|
||
|
'Ρ' => 'Ρ',
|
||
|
'Σ' => 'Σ',
|
||
|
'Τ' => 'Τ',
|
||
|
'Υ' => 'Υ',
|
||
|
'Φ' => 'Φ',
|
||
|
'Χ' => 'Χ',
|
||
|
'Ψ' => 'Ψ',
|
||
|
'Ω' => 'Ω',
|
||
|
'α' => 'α',
|
||
|
'β' => 'β',
|
||
|
'γ' => 'γ',
|
||
|
'δ' => 'δ',
|
||
|
'ε' => 'ε',
|
||
|
'ζ' => 'ζ',
|
||
|
'η' => 'η',
|
||
|
'θ' => 'θ',
|
||
|
'ι' => 'ι',
|
||
|
'κ' => 'κ',
|
||
|
'λ' => 'λ',
|
||
|
'μ' => 'μ',
|
||
|
'ν' => 'ν',
|
||
|
'ξ' => 'ξ',
|
||
|
'ο' => 'ο',
|
||
|
'π' => 'π',
|
||
|
'ρ' => 'ρ',
|
||
|
'ς' => 'ς',
|
||
|
'σ' => 'σ',
|
||
|
'τ' => 'τ',
|
||
|
'υ' => 'υ',
|
||
|
'φ' => 'φ',
|
||
|
'χ' => 'χ',
|
||
|
'ψ' => 'ψ',
|
||
|
'ω' => 'ω',
|
||
|
'ϑ' => 'ϑ',
|
||
|
'ϒ' => 'ϒ',
|
||
|
'ϖ' => 'ϖ',
|
||
|
'•' => '•',
|
||
|
'…' => '…',
|
||
|
'′' => '′',
|
||
|
'″' => '″',
|
||
|
'‾' => '‾',
|
||
|
'⁄' => '⁄',
|
||
|
'℘' => '℘',
|
||
|
'ℑ' => 'ℑ',
|
||
|
'ℜ' => 'ℜ',
|
||
|
'™' => '™',
|
||
|
'ℵ' => 'ℵ',
|
||
|
'←' => '←',
|
||
|
'↑' => '↑',
|
||
|
'→' => '→',
|
||
|
'↓' => '↓',
|
||
|
'↔' => '↔',
|
||
|
'↵' => '↵',
|
||
|
'⇐' => '⇐',
|
||
|
'⇑' => '⇑',
|
||
|
'⇒' => '⇒',
|
||
|
'⇓' => '⇓',
|
||
|
'⇔' => '⇔',
|
||
|
'∀' => '∀',
|
||
|
'∂' => '∂',
|
||
|
'∃' => '∃',
|
||
|
'∅' => '∅',
|
||
|
'∇' => '∇',
|
||
|
'∈' => '∈',
|
||
|
'∉' => '∉',
|
||
|
'∋' => '∋',
|
||
|
'∏' => '∏',
|
||
|
'∑' => '∑',
|
||
|
'−' => '−',
|
||
|
'∗' => '∗',
|
||
|
'√' => '√',
|
||
|
'∝' => '∝',
|
||
|
'∞' => '∞',
|
||
|
'∠' => '∠',
|
||
|
'∧' => '∧',
|
||
|
'∨' => '∨',
|
||
|
'∩' => '∩',
|
||
|
'∪' => '∪',
|
||
|
'∫' => '∫',
|
||
|
'∴' => '∴',
|
||
|
'∼' => '∼',
|
||
|
'≅' => '≅',
|
||
|
'≈' => '≈',
|
||
|
'≠' => '≠',
|
||
|
'≡' => '≡',
|
||
|
'≤' => '≤',
|
||
|
'≥' => '≥',
|
||
|
'⊂' => '⊂',
|
||
|
'⊃' => '⊃',
|
||
|
'⊄' => '⊄',
|
||
|
'⊆' => '⊆',
|
||
|
'⊇' => '⊇',
|
||
|
'⊕' => '⊕',
|
||
|
'⊗' => '⊗',
|
||
|
'⊥' => '⊥',
|
||
|
'⋅' => '⋅',
|
||
|
'⌈' => '⌈',
|
||
|
'⌉' => '⌉',
|
||
|
'⌊' => '⌊',
|
||
|
'⌋' => '⌋',
|
||
|
'⟨' => '〈',
|
||
|
'⟩' => '〉',
|
||
|
'◊' => '◊',
|
||
|
'♠' => '♠',
|
||
|
'♣' => '♣',
|
||
|
'♥' => '♥',
|
||
|
'♦' => '♦'));
|