-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
69 lines (58 loc) · 1.79 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*****************************************************
* Plugin name : recently_changed
* File name : index.php
* Summery : facilitates to display a list of pages that have most recently been changed.
* Only the page headings are listed as links to the respective page.
* Auther : Christoph M. Becker / T.Uchiyama
* License : GPLv3
*****************************************************
* Useage : {{{recently_changed([$count]);}}}
* Example : {{{recently_changed();}}}
******************************************************/
/*
* Prevent direct access.
*/
if (!defined('CMSIMPLE_XH_VERSION')) {
header('HTTP/1.0 403 Forbidden');
exit;
}
if (!function_exists('recently_changed')) {
/**
* @copyright 2016 Christoph M. Becker
* @license GPLv3
* @URL http://cmsimpleforum.com/viewtopic.php?f=12&t=10543
*/
function recently_changed($count = 5)
{
global $pd_router;
$pageData = $pd_router->find_all();
// uasort($pageData, function ($a, $b) { // anonymous function >= PHP5.3
// return $b['last_edit'] - $a['last_edit'];
// });
uasort($pageData, recently_changed_func($a, $b) );
$pages = array();
$i = 0;
foreach (array_keys($pageData) as $page) {
if ($i <= $count) { // Change '<' to '<=' :201608 T.Uchiyama
if (!hide($page)) {
$pages[] = $page;
}
$i++;
} else {
break;
}
}
global $sn, $h, $u;
$html = '<ul class="recently_changed">';
foreach ($pages as $page) {
$html .= '<li><a href="' . "$sn?$u[$page]" . '">' . $h[$page] . '</a></li>';
}
$html .= '</ul>';
return $html;
}
function recently_changed_func($a, $b) {
return $b['last_edit'] - $a['last_edit'];
}
}
?>