Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to hide banners #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions action.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']; }
Expand Down Expand Up @@ -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[] = '<span class="approval_latest_draft">';
$strings[] = sprintf($this->getLang('apr_recent_draft'), wl($ID, 'force_rev=1'));
$strings[] = $this->difflink($ID, null, $REV) . '</span>';
}

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 = ''; }
Expand All @@ -162,15 +165,17 @@ function handle_display_banner(&$event, $param) {
$strings[] = $this->difflink($ID, $userrev, $REV) . '</span>';
}

if(!$approver) {
if(!$approver && $this->getConf('apr_draft')) {
$strings_flag = true;
# Draft
$strings[] = '<span class="approval_draft">';
$strings[] = sprintf($this->getLang('apr_draft'),
'<span class="approval_date">' . $longdate . '</span>');
$strings[] = '</span>';
}

if($approver) {
if($approver && $this->getConf('apr_approved')) {
$strings_flag = true;
# Approved
$strings[] = '<span class="approval_approved">';
$strings[] = sprintf($this->getLang('apr_approved'),
Expand All @@ -179,7 +184,8 @@ function handle_display_banner(&$event, $param) {
$strings[] = '</span>';
}

if($previous_approved) {
if($previous_approved && $this->getConf('apr_previous')) {
$strings_flag = true;
$strings[] = '<span class="approval_previous">';
$strings[] = sprintf($this->getLang('apr_previous'),
wl($ID, 'rev=' . $previous_approved),
Expand All @@ -189,7 +195,9 @@ function handle_display_banner(&$event, $param) {

$strings[] = '</div>';

ptln(implode($strings));
# Don't print the banner if no visible banner is to be displayed
if($strings_flag)
ptln(implode($strings));
return true;
}

Expand Down
5 changes: 5 additions & 0 deletions conf/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
5 changes: 5 additions & 0 deletions conf/metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
8 changes: 7 additions & 1 deletion lang/en/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

?>