$tag>";
}
function addDate($date,$day)//add days
{
$sum = strtotime(date("Y-m-d", strtotime("$date")) . " +$day days");
$dateTo=date('Y-m-d',$sum);
return $dateTo;
}
function convertdate($date) {
return preg_replace("/(\d+)\/(\d+)\/(\d+)/",'$3-$2-$1',$date);
}
## Create feed from page history
function Memorization($pagename, $auth = 'read') {
global $FarmD, $WikiTitle, $ScriptUrl;
$feedfile = $FarmD."/pub/memorizationfeed.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='startrecall';
$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) {
$daterecall = PageTextVar($page,$varname);
if ( isset($daterecall) ) {
foreach ($datestorecall as $day) {
# print $page . " ";
$checkdate = addDate(convertdate($daterecall),$day);
# print $daterecall . " + " . $day . " (" . $checkdate . ") == " . date("d/m/Y");
if ($checkdate==convertdate(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
$cleaned_page_name = str_replace(".","/",$page);
// function FeedText($pagename, &$page, $tag) {
//"manually" add the cover by simulating the GroupHeadre (read page ISBN + if exist display image)
$feed_newitem = " -
Day $day recall for page $page started at $daterecall
$ScriptUrl/$cleaned_page_name#MemorizationDay$day"
.FeedText($page,$page,"description").
"$item_GUID
$feed_newitemdate
";
# bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
# appending the item
$feed_newcontent .= $feed_newitem;
}
break; #we can't have 2 days at the same time
}
# print "
";
} # 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 = "
Memorization feed for $WikiTitle .
$ScriptUrl
Receive links to the page you tagged in order to have optimal memorization.
Generated by http://fabien.benetou.fr/Wiki/MemoryRecipe for PmWiki
$feed_newdate";
$feed_footer = "
";
# 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"
'"' => '"',
#'&' => '&',
#'<' => '<',
#'>' => '>',
''' => ''',
'Œ' => 'Œ',
'œ' => 'œ',
'Š' => 'Š',
'š' => 'š',
'Ÿ' => 'Ÿ',
'ˆ' => 'ˆ',
'˜' => '˜',
' ' => ' ',
' ' => ' ',
' ' => ' ',
'' => '',
'' => '',
'' => '',
'' => '',
'–' => '–',
'—' => '—',
'‘' => '‘',
'’' => '’',
'‚' => '‚',
'“' => '“',
'”' => '”',
'„' => '„',
'†' => '†',
'‡' => '‡',
'‰' => '‰',
'‹' => '‹',
'›' => '›',
'€' => '€',
# entities defined in "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent"
'ƒ' => 'ƒ',
'Α' => 'Α',
'Β' => 'Β',
'Γ' => 'Γ',
'Δ' => 'Δ',
'Ε' => 'Ε',
'Ζ' => 'Ζ',
'Η' => 'Η',
'Θ' => 'Θ',
'Ι' => 'Ι',
'Κ' => 'Κ',
'Λ' => 'Λ',
'Μ' => 'Μ',
'Ν' => 'Ν',
'Ξ' => 'Ξ',
'Ο' => 'Ο',
'Π' => 'Π',
'Ρ' => 'Ρ',
'Σ' => 'Σ',
'Τ' => 'Τ',
'Υ' => 'Υ',
'Φ' => 'Φ',
'Χ' => 'Χ',
'Ψ' => 'Ψ',
'Ω' => 'Ω',
'α' => 'α',
'β' => 'β',
'γ' => 'γ',
'δ' => 'δ',
'ε' => 'ε',
'ζ' => 'ζ',
'η' => 'η',
'θ' => 'θ',
'ι' => 'ι',
'κ' => 'κ',
'λ' => 'λ',
'μ' => 'μ',
'ν' => 'ν',
'ξ' => 'ξ',
'ο' => 'ο',
'π' => 'π',
'ρ' => 'ρ',
'ς' => 'ς',
'σ' => 'σ',
'τ' => 'τ',
'υ' => 'υ',
'φ' => 'φ',
'χ' => 'χ',
'ψ' => 'ψ',
'ω' => 'ω',
'ϑ' => 'ϑ',
'ϒ' => 'ϒ',
'ϖ' => 'ϖ',
'•' => '•',
'…' => '…',
'′' => '′',
'″' => '″',
'‾' => '‾',
'⁄' => '⁄',
'℘' => '℘',
'ℑ' => 'ℑ',
'ℜ' => 'ℜ',
'™' => '™',
'ℵ' => 'ℵ',
'←' => '←',
'↑' => '↑',
'→' => '→',
'↓' => '↓',
'↔' => '↔',
'↵' => '↵',
'⇐' => '⇐',
'⇑' => '⇑',
'⇒' => '⇒',
'⇓' => '⇓',
'⇔' => '⇔',
'∀' => '∀',
'∂' => '∂',
'∃' => '∃',
'∅' => '∅',
'∇' => '∇',
'∈' => '∈',
'∉' => '∉',
'∋' => '∋',
'∏' => '∏',
'∑' => '∑',
'−' => '−',
'∗' => '∗',
'√' => '√',
'∝' => '∝',
'∞' => '∞',
'∠' => '∠',
'∧' => '∧',
'∨' => '∨',
'∩' => '∩',
'∪' => '∪',
'∫' => '∫',
'∴' => '∴',
'∼' => '∼',
'≅' => '≅',
'≈' => '≈',
'≠' => '≠',
'≡' => '≡',
'≤' => '≤',
'≥' => '≥',
'⊂' => '⊂',
'⊃' => '⊃',
'⊄' => '⊄',
'⊆' => '⊆',
'⊇' => '⊇',
'⊕' => '⊕',
'⊗' => '⊗',
'⊥' => '⊥',
'⋅' => '⋅',
'⌈' => '⌈',
'⌉' => '⌉',
'⌊' => '⌊',
'⌋' => '⌋',
'〈' => '〈',
'〉' => '〉',
'◊' => '◊',
'♠' => '♠',
'♣' => '♣',
'♥' => '♥',
'♦' => '♦'));