You can also transfer the "last modified date" directly from PHP $INFO['lastmod']
to Javascript JSINFO['lastmod']
. Go to /dokuwiki/inc/common.php
and look for the comment * Initialize and/or fill global $JSINFO with some basic info to be given to javascript
, then add the following as a new line to the set:
$JSINFO['lastmod'] = isset($INFO) ? (int) $INFO['lastmod']*1000 : ''; // ****** ADDED ******
Note, that the value is multiplied by 1000, because the date (as a Unix timestamp) is needed in Javascript in the unit Milliseconds, but, is provided in PHP in the unit Seconds.
Now, the javascript code in /dokuwiki/conf/userscript.js
boils down to this:
// *********** Old Page Warning Plugin - compare dates and put the warning message into the page header ***********
var $lastmod_warning = 'This page has not been updated for 2 years! Information on this page may not be valid anymore!';
var $lastmod_date_current = Date.now();
var $lastmod_date = JSINFO['lastmod'];
if ( $lastmod_date != '' && $lastmod_date < ($lastmod_date_current - 1000*60*60*24*365*2) ) { // UNIX timestamp in the unit Milliseconds: 2 years
jQuery("#dokuwiki__content").before('<div class="message-box" style="background-color:orange;z-index:10000;padding:2px 5px;"><span>' + $lastmod_warning + '</span></div>');
}
And that's all that's left from the above plugin code, and that's all that's needed!
Cheers!