From 6fd51d2301ad50022a4f2b46a7b22581ec3da4ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Lamelas?= Date: Thu, 18 Apr 2013 16:28:14 +0200 Subject: [PATCH] Added options to display only selected banners. --- action.php | 20 ++++++++++++++------ conf/default.php | 5 +++++ conf/metadata.php | 5 +++++ lang/en/settings.php | 8 +++++++- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/action.php b/action.php index 86fd7d5..4efa0ee 100644 --- a/action.php +++ b/action.php @@ -96,6 +96,7 @@ function handle_display_banner(&$event, $param) { if(!$INFO['exists']) return true; $strings = array(); + $strings_flag = false; $meta = p_get_metadata($ID); $rev = $REV; if(!$rev) { $rev = $meta['last_change']['date']; } @@ -147,13 +148,15 @@ function handle_display_banner(&$event, $param) { if($approver && !$most_recent_approved) { $strings[] = 'yes'; } else { $strings[] = 'no'; } $strings[] = '">'; - if($most_recent_draft) { + if($most_recent_draft && $this->getConf('apr_recent_draft')) { + $strings_flag = true; $strings[] = ''; $strings[] = sprintf($this->getLang('apr_recent_draft'), wl($ID, 'force_rev=1')); $strings[] = $this->difflink($ID, null, $REV) . ''; } - if($most_recent_approved) { + if($most_recent_approved && $this->getConf('apr_outdated')) { + $strings_flag = true; # Approved, but there is a more recent version $userrev = $most_recent_approved; if($userrev == $latest_rev) { $userrev = ''; } @@ -162,7 +165,8 @@ function handle_display_banner(&$event, $param) { $strings[] = $this->difflink($ID, $userrev, $REV) . ''; } - if(!$approver) { + if(!$approver && $this->getConf('apr_draft')) { + $strings_flag = true; # Draft $strings[] = ''; $strings[] = sprintf($this->getLang('apr_draft'), @@ -170,7 +174,8 @@ function handle_display_banner(&$event, $param) { $strings[] = ''; } - if($approver) { + if($approver && $this->getConf('apr_approved')) { + $strings_flag = true; # Approved $strings[] = ''; $strings[] = sprintf($this->getLang('apr_approved'), @@ -179,7 +184,8 @@ function handle_display_banner(&$event, $param) { $strings[] = ''; } - if($previous_approved) { + if($previous_approved && $this->getConf('apr_previous')) { + $strings_flag = true; $strings[] = ''; $strings[] = sprintf($this->getLang('apr_previous'), wl($ID, 'rev=' . $previous_approved), @@ -189,7 +195,9 @@ function handle_display_banner(&$event, $param) { $strings[] = ''; - ptln(implode($strings)); + # Don't print the banner if no visible banner is to be displayed + if($strings_flag) + ptln(implode($strings)); return true; } diff --git a/conf/default.php b/conf/default.php index 4076ae5..6878840 100644 --- a/conf/default.php +++ b/conf/default.php @@ -3,3 +3,8 @@ $conf['apr_namespaces'] = ''; $conf['apr_approved_text'] = 'Approved'; +$conf['apr_recent_draft'] = 1; +$conf['apr_outdated'] = 1; +$conf['apr_draft'] = 1; +$conf['apr_approved'] = 1; +$conf['apr_previous'] = 1; \ No newline at end of file diff --git a/conf/metadata.php b/conf/metadata.php index 2098038..dccd6b0 100644 --- a/conf/metadata.php +++ b/conf/metadata.php @@ -3,3 +3,8 @@ $meta['apr_namespaces'] = array('string'); $meta['apr_approved_text'] = array('string'); +$meta['apr_recent_draft'] = array('onoff'); +$meta['apr_outdated'] = array('onoff'); +$meta['apr_draft'] = array('onoff'); +$meta['apr_approved'] = array('onoff'); +$meta['apr_previous'] = array('onoff'); \ No newline at end of file diff --git a/lang/en/settings.php b/lang/en/settings.php index 7b22fa1..4fd7a0f 100644 --- a/lang/en/settings.php +++ b/lang/en/settings.php @@ -3,4 +3,10 @@ $lang['apr_namespaces'] = 'Namespaces this plugin applies to'; $lang['apr_approved_text'] = 'Automatic Approval Comment'; -?> +$lang['apr_recent_draft'] = 'Show banner if most recent version is a draft.'; +$lang['apr_outdated'] = 'Show banner if version is outdated'; +$lang['apr_draft'] = 'Show banner if version is a draft'; +$lang['apr_approved'] = 'Show banner if version is approved'; +$lang['apr_previous'] = 'Show banner if a previously approved version is available'; + +?> \ No newline at end of file