quote text 1
quote author 1
quote text 2
quote author 2
...
To use this script, simply copy it into the cookbook/ directory
and add the following line to config.php or a per-page/per-group
customization file.
include_once('cookbook/RandomQuoteWiki.php');
Then add something like
|| '''(:RandomQuoteWiki_quote:)''' ||
|| (:RandomQuoteWiki_author:) ||
in you wiki page.
*/
################################################################################
SDV($RandomQuoteWikiPage, "$WorkDir/SiteData.RandomQuoteWiki");
# this should be $WikiDir instead of $WorkDir, but this "PageStore object"
# certainly desserves some more documentation.
# Anyway, by default they point to the same directory.
################################################################################
################################################################################
################################################################################
define(RANDOM_QUOTE_WIKI, '1.1');
$RandomQuoteWiki_quote = '';
$RandomQuoteWiki_author = '';
$FileHandle = @fopen($RandomQuoteWikiPage, "rb");
if ($FileHandle != FALSE)
{
$FileContent = fread($FileHandle, filesize($RandomQuoteWikiPage));
fclose($FileHandle);
if (preg_match('|text=(.*)|', $FileContent, $matches) == 1)
{
$FileContent = preg_replace("'%([0-9A-Fa-f]{2})'e", "chr(hexdec('\\1'))", $matches[1]);
if (preg_match("|(.*?)|s", $FileContent, $matches) == 1)
{
$QuotesData = $matches[1];
$MatchesCount = preg_match_all("|(.*?)
|s", $FileContent, $matches, PREG_PATTERN_ORDER);
$QuoteData = $matches[1][rand(0, $MatchesCount - 1)];
if (preg_match("|\s*(.+?)\s*|s", $QuoteData, $matches) == 1)
{
$RandomQuoteWiki_quote = $matches[1];
if (preg_match("|\s*(.+?)\s*|s", $QuoteData, $matches) == 1)
{
$RandomQuoteWiki_author = $matches[1];
}
}
}
}
}
Markup('RandomQuoteWiki_quote', 'fulltext', '/\(:RandomQuoteWiki_quote:\)/', $RandomQuoteWiki_quote);
Markup('RandomQuoteWiki_author', 'fulltext', '/\(:RandomQuoteWiki_author:\)/', $RandomQuoteWiki_author);
?>