Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added new replacement pattern for Revision Number (@REVNUM@). #22

  • Loading branch information...
commit 35637ffd0e5effe3d4c22dff6cdbc5b96ef1b79e 1 parent 8857a27
@samwilson authored
Showing with 51 additions and 0 deletions.
  1. +51 −0 action.php
View
51 action.php
@@ -216,6 +216,7 @@ protected function load_template($title){
'@TPLBASE@' => DOKU_BASE.'lib/plugins/dw2pdf/tpl/'.$tpl.'/',
'@TPLBASE@' => DOKU_PLUGIN.'dw2pdf/tpl/'.$tpl.'/',
'@QRCODE@' => $qr_code,
+ '@REVNUM@' => $this->get_revision_count(),
);
// set HTML element
@@ -231,6 +232,56 @@ protected function load_template($title){
}
/**
+ * Get the number of revisions for the current page (including when the
+ * current view is an old revision). Has the option to limit to revisions
+ * of any of the following change types:
+ * DOKU_CHANGE_TYPE_CREATE,
+ * DOKU_CHANGE_TYPE_EDIT,
+ * DOKU_CHANGE_TYPE_MINOR_EDIT,
+ * DOKU_CHANGE_TYPE_DELETE, and
+ * DOKU_CHANGE_TYPE_REVERT.
+ * All except minor revisions are included if the $types parameter is not
+ * used.
+ *
+ * Note: This is public and static because it can be useful in templates,
+ * and should probably not live in this class at all.
+ *
+ * @uses getRevisions()
+ * @uses getRevisionInfo()
+ * @param array $types Revision types to be included in the count.
+ * @return int The total number of revisions.
+ */
+ public static function get_revision_count($types = null) {
+ global $ID, $INFO, $REV;
+ if (empty($types)) {
+ // These types are defined in inc/changelog.php
+ $types = array(
+ DOKU_CHANGE_TYPE_CREATE,
+ DOKU_CHANGE_TYPE_EDIT,
+ //DOKU_CHANGE_TYPE_MINOR_EDIT,
+ DOKU_CHANGE_TYPE_DELETE,
+ DOKU_CHANGE_TYPE_REVERT,
+ );
+ }
+ $count = 0;
+ // Get all revisions, including current
+ $revisions = array_merge(
+ array($INFO['meta']['last_change']['date']),
+ getRevisions($ID, 0, PHP_INT_MAX)
+ );
+ // Get revision timestamp of the currently-viewed page revision
+ $before = (is_int($REV)) ? $REV : $INFO['meta']['last_change']['date'];
+ foreach ($revisions as $revision) {
+ $info = getRevisionInfo($ID, $revision);
+ // Of requred type and earlier than $before
+ if (in_array($info['type'], $types) && $info['date']<=$before) {
+ $count++;
+ }
+ }
+ return $count;
+ }
+
+ /**
* Load all the style sheets and apply the needed replacements
*/
protected function load_css(){
Please sign in to comment.
Something went wrong with that request. Please try again.