mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-26 05:32:59 +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,7 +1647,24 @@ register_module([
|
||||||
];
|
];
|
||||||
if($oldsize == 0)
|
if($oldsize == 0)
|
||||||
$newchange["newpage"] = true;
|
$newchange["newpage"] = true;
|
||||||
array_unshift($recentchanges, $newchange);
|
|
||||||
|
add_recent_change($newchange);
|
||||||
|
});
|
||||||
|
|
||||||
|
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>
|
||||||
|
<p>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 <em>currently</em> 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.</p>");
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
// Limit the number of entries in the recent changes file if we've
|
||||||
// been asked to.
|
// been asked to.
|
||||||
|
@ -1657,12 +1673,7 @@ register_module([
|
||||||
|
|
||||||
// Save the recent changes file back to disk
|
// Save the recent changes file back to disk
|
||||||
file_put_contents($paths->recentchanges, json_encode($recentchanges, JSON_PRETTY_PRINT));
|
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>
|
|
||||||
<p>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 <em>currently</em> 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.</p>");
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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,7 +83,24 @@ register_module([
|
||||||
];
|
];
|
||||||
if($oldsize == 0)
|
if($oldsize == 0)
|
||||||
$newchange["newpage"] = true;
|
$newchange["newpage"] = true;
|
||||||
array_unshift($recentchanges, $newchange);
|
|
||||||
|
add_recent_change($newchange);
|
||||||
|
});
|
||||||
|
|
||||||
|
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>
|
||||||
|
<p>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 <em>currently</em> 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.</p>");
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
// Limit the number of entries in the recent changes file if we've
|
||||||
// been asked to.
|
// been asked to.
|
||||||
|
@ -93,11 +109,6 @@ register_module([
|
||||||
|
|
||||||
// Save the recent changes file back to disk
|
// Save the recent changes file back to disk
|
||||||
file_put_contents($paths->recentchanges, json_encode($recentchanges, JSON_PRETTY_PRINT));
|
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>
|
|
||||||
<p>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 <em>currently</em> 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.</p>");
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue