[pmwiki-users] Reading $RecentChangesFmt in config.php from page local configs?
Johnny Ernst Nielsen
j_e_n_pub at yahoo.dk
Sat Oct 13 11:28:08 CDT 2007
Greetings.
In config.php I have added a function to do perpage summary logging.
It reads on disk if page config files exists, and reads from existing
page config files if summary logging is already defined (in the
$RecentChangesFmt array).
Now, the function potentially goes to disk three times.
I would like to reduce the disk activity, if possible.
Is there any way to check from config.php if a
$RecentChangesFmt array element has been defined in a page config
file?
This is the code I have added to local/config.php:
---
function PerPageSummaryLog($pagename, &$page, &$new)
{
// No summary logs for log pages.
if (!strpos($pagename, "SummaryLog")
&& !strpos($pagename, "RecentChanges")
&& !strpos($pagename, "Site.AllEdits")
&& !strpos($pagename, "Last100Edits")
&& !strpos($pagename, "Last1000Edits"))
{
// If the page has no configuration file.
if(!file_exists($LocalDir . $pagename . ".php"))
{
// Write configuration file.
$file = fopen($LocalDir . $pagename . ".php", "w");
fwrite($file, $newfileconfig);
fclose($file);
}
// If the page already has a configuration file.
else
{
// Make sure we don't clobber an already existing log setting
for the page.
$file = fopen($LocalDir . $pagename . ".php", "r");
$configfile = fread($file, filesize($LocalDir .
$pagename . ".php"));
fclose($file);
if(!strpos($configfile, "RecentChangesFmt['" .
$pagename . "SummaryLog']"))
{
$file = fopen($LocalDir . $pagename . ".php", "a");
fwrite($file, $appendfileconfig);
fclose($file);
}
}
}
}
array_unshift($EditFunctions, 'PerPageSummaryLog');
Best regards :o)
Johnny :o)
More information about the pmwiki-users
mailing list