mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 16:33:00 +00:00
Refactor code to add a recent change into own method
This commit is contained in:
parent
d5a1fb1a15
commit
8b55263a44
3 changed files with 44 additions and 22 deletions
|
@ -1565,7 +1565,7 @@ function render_sidebar($pageindex, $root_pagename = "")
|
||||||
|
|
||||||
register_module([
|
register_module([
|
||||||
"name" => "Recent Changes",
|
"name" => "Recent Changes",
|
||||||
"version" => "0.2.1",
|
"version" => "0.3",
|
||||||
"author" => "Starbeamrainbowlabs",
|
"author" => "Starbeamrainbowlabs",
|
||||||
"description" => "Adds recent changes. Access through the 'recent-changes' action.",
|
"description" => "Adds recent changes. Access through the 'recent-changes' action.",
|
||||||
"id" => "feature-recent-changes",
|
"id" => "feature-recent-changes",
|
||||||
|
@ -1637,7 +1637,6 @@ register_module([
|
||||||
// Calculate the page length difference
|
// Calculate the page length difference
|
||||||
$size_diff = $newsize - $oldsize;
|
$size_diff = $newsize - $oldsize;
|
||||||
|
|
||||||
$recentchanges = json_decode(file_get_contents($paths->recentchanges), true);
|
|
||||||
$newchange = [
|
$newchange = [
|
||||||
"type" => "edit",
|
"type" => "edit",
|
||||||
"timestamp" => time(),
|
"timestamp" => time(),
|
||||||
|
@ -1648,15 +1647,8 @@ register_module([
|
||||||
];
|
];
|
||||||
if($oldsize == 0)
|
if($oldsize == 0)
|
||||||
$newchange["newpage"] = true;
|
$newchange["newpage"] = true;
|
||||||
array_unshift($recentchanges, $newchange);
|
|
||||||
|
|
||||||
// Limit the number of entries in the recent changes file if we've
|
add_recent_change($newchange);
|
||||||
// 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", "<p>The <a href='?action=recent-changes'>recent changes</a> 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.</p>
|
add_help_section("800-raw-page-content", "Recent Changes", "<p>The <a href='?action=recent-changes'>recent changes</a> 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.</p>
|
||||||
|
@ -1664,6 +1656,25 @@ register_module([
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new recent change to the recent changes file.
|
||||||
|
* @param array $rchange The new change to add.
|
||||||
|
*/
|
||||||
|
function add_recent_change($rchange)
|
||||||
|
{
|
||||||
|
global $settings, $paths;
|
||||||
|
$recentchanges = json_decode(file_get_contents($paths->recentchanges), true);
|
||||||
|
array_unshift($recentchanges, $rchange);
|
||||||
|
|
||||||
|
// 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,11 +37,11 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Recent Changes",
|
"name": "Recent Changes",
|
||||||
"version": "0.2.1",
|
"version": "0.3",
|
||||||
"author": "Starbeamrainbowlabs",
|
"author": "Starbeamrainbowlabs",
|
||||||
"description": "Adds recent changes. Access through the 'recent-changes' action.",
|
"description": "Adds recent changes. Access through the 'recent-changes' action.",
|
||||||
"id": "feature-recent-changes",
|
"id": "feature-recent-changes",
|
||||||
"lastupdate": 1459693632,
|
"lastupdate": 1459693836,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
register_module([
|
register_module([
|
||||||
"name" => "Recent Changes",
|
"name" => "Recent Changes",
|
||||||
"version" => "0.2.1",
|
"version" => "0.3",
|
||||||
"author" => "Starbeamrainbowlabs",
|
"author" => "Starbeamrainbowlabs",
|
||||||
"description" => "Adds recent changes. Access through the 'recent-changes' action.",
|
"description" => "Adds recent changes. Access through the 'recent-changes' action.",
|
||||||
"id" => "feature-recent-changes",
|
"id" => "feature-recent-changes",
|
||||||
|
@ -73,7 +73,6 @@ register_module([
|
||||||
// Calculate the page length difference
|
// Calculate the page length difference
|
||||||
$size_diff = $newsize - $oldsize;
|
$size_diff = $newsize - $oldsize;
|
||||||
|
|
||||||
$recentchanges = json_decode(file_get_contents($paths->recentchanges), true);
|
|
||||||
$newchange = [
|
$newchange = [
|
||||||
"type" => "edit",
|
"type" => "edit",
|
||||||
"timestamp" => time(),
|
"timestamp" => time(),
|
||||||
|
@ -84,15 +83,8 @@ register_module([
|
||||||
];
|
];
|
||||||
if($oldsize == 0)
|
if($oldsize == 0)
|
||||||
$newchange["newpage"] = true;
|
$newchange["newpage"] = true;
|
||||||
array_unshift($recentchanges, $newchange);
|
|
||||||
|
|
||||||
// Limit the number of entries in the recent changes file if we've
|
add_recent_change($newchange);
|
||||||
// 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", "<p>The <a href='?action=recent-changes'>recent changes</a> 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.</p>
|
add_help_section("800-raw-page-content", "Recent Changes", "<p>The <a href='?action=recent-changes'>recent changes</a> 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.</p>
|
||||||
|
@ -100,4 +92,23 @@ register_module([
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new recent change to the recent changes file.
|
||||||
|
* @param array $rchange The new change to add.
|
||||||
|
*/
|
||||||
|
function add_recent_change($rchange)
|
||||||
|
{
|
||||||
|
global $settings, $paths;
|
||||||
|
$recentchanges = json_decode(file_get_contents($paths->recentchanges), true);
|
||||||
|
array_unshift($recentchanges, $rchange);
|
||||||
|
|
||||||
|
// 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));
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue