"Recent Changes", "version" => "0.2.0", "author" => "Starbeamrainbowlabs", "description" => "Adds recent changes. Access through the 'recent-changes' action.", "id" => "feature-recent-changes", "code" => function() { global $settings, $env, $paths; // Add the recent changes json file to $paths for convenience. $paths->recentchanges = $env->storage_prefix . "recent-changes.json"; // Create the recent changes json file if it doesn't exist if(!file_exists($paths->recentchanges)) file_put_contents($paths->recentchanges, "[]"); /* * ██████ ███████ ██████ ███████ ███ ██ ████████ * ██ ██ ██ ██ ██ ████ ██ ██ * ██████ █████ ██ █████ ██ ██ ██ ██ * ██ ██ ██ ██ ██ ██ ██ ██ ██ * ██ ██ ███████ ██████ ███████ ██ ████ ██ * * ██████ ██ ██ █████ ███ ██ ██████ ███████ ███████ * ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ * ██ ███████ ███████ ██ ██ ██ ██ ███ █████ ███████ * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ * ██████ ██ ██ ██ ██ ██ ████ ██████ ███████ ███████ */ add_action("recent-changes", function() { global $settings, $paths, $pageindex; $content = "\t\t

Recent Changes

\n"; $recentchanges = json_decode(file_get_contents($paths->recentchanges)); if(count($recentchanges) > 0) { $content .= ""; } else { // No changes yet :( $content .= "

None yet! Try making a few changes and then check back here.

\n"; } echo(page_renderer::render("Recent Changes - $settings->sitename", $content)); }); register_save_preprocessor(function(&$pageinfo, &$newsource, &$oldsource) { global $env, $settings, $paths; // Work out the old and new page lengths $oldsize = strlen($oldsource); $newsize = strlen($newsource); // Calculate the page length difference $size_diff = $newsize - $oldsize; $recentchanges = json_decode(file_get_contents($paths->recentchanges), true); array_unshift($recentchanges, [ "timestamp" => time(), "page" => $env->page, "user" => $env->user, "newsize" => $newsize, "sizediff" => $size_diff ]); // Limit the number of entries in the recent changes file if we've // been asked to. if(isset($settings->max_recent_changes)) $recentchanges = array_slice($recentchanges, -$settings->max_recent_changes); // Save the recent changes file back to disk file_put_contents($paths->recentchanges, json_encode($recentchanges, JSON_PRETTY_PRINT)); }); add_help_section("800-raw-page-content", "Recent Changes", "

The recent changes page displays a list of all the most recent changes that have happened around $settings->sitename, arranged in chronological order. It can be found in the \"More...\" menu in the top right by default.

Each entry displays the name of the page in question, who edited it, how long ago they did so, and the number of characters added or removed. Pages that currently redirect to another page are shown in italics, and hovering over the time since the edit wil show the exact time that the edit was made.

"); } ]); ?>