http://www.mediawiki.org/wiki/Special:Code/MediaWiki/70212

Revision: 70212
Author:   kaldari
Date:     2010-07-31 00:58:47 +0000 (Sat, 31 Jul 2010)

Log Message:
-----------
Updating and cleaning up CentralNotice user interface (prior to adding new 
features)

Modified Paths:
--------------
    trunk/extensions/CentralNotice/CentralNotice.i18n.php
    trunk/extensions/CentralNotice/SpecialCentralNotice.php
    trunk/extensions/CentralNotice/SpecialNoticeTemplate.php

Modified: trunk/extensions/CentralNotice/CentralNotice.i18n.php
===================================================================
--- trunk/extensions/CentralNotice/CentralNotice.i18n.php       2010-07-30 
22:35:02 UTC (rev 70211)
+++ trunk/extensions/CentralNotice/CentralNotice.i18n.php       2010-07-31 
00:58:47 UTC (rev 70212)
@@ -23,6 +23,7 @@
        'centralnotice-remove' => 'Remove',
        'centralnotice-translate-heading' => 'Translation for $1',
        'centralnotice-manage' => 'Manage campaigns',
+       'centralnotice-manage-templates' => 'Manage banners',
        'centralnotice-add' => 'Add',
        'centralnotice-add-notice' => 'Add a campaign',
        'centralnotice-edit-notice' => 'Edit campaign',
@@ -34,9 +35,11 @@
        'centralnotice-translate' => 'Translate',
        'centralnotice-english' => 'English',
        'centralnotice-template-name' => 'Banner name',
+       'centralnotice-template' => 'Banner',
        'centralnotice-templates' => 'Banners',
        'centralnotice-weight' => 'Weight',
        'centralnotice-locked' => 'Locked',
+       'centralnotice-notice' => 'Campaign',
        'centralnotice-notices' => 'Campaigns',
        'centralnotice-notice-exists' => 'Campaign already exists.
 Not adding.',
@@ -89,6 +92,7 @@
        'centralnotice-message-not-set' => 'Message not set',
        'centralnotice-clone' => 'Clone',
        'centralnotice-clone-notice' => 'Create a copy of the banner',
+       'centralnotice-clone-name' => 'Name',
        'centralnotice-preview-all-template-translations' => 'Preview all 
available translations of banner',
 
        'right-centralnotice-admin' => 'Manage central notices',

Modified: trunk/extensions/CentralNotice/SpecialCentralNotice.php
===================================================================
--- trunk/extensions/CentralNotice/SpecialCentralNotice.php     2010-07-30 
22:35:02 UTC (rev 70211)
+++ trunk/extensions/CentralNotice/SpecialCentralNotice.php     2010-07-31 
00:58:47 UTC (rev 70212)
@@ -20,11 +20,14 @@
        }
 
        function execute( $sub ) {
-               global $wgOut, $wgUser, $wgRequest;
+               global $wgOut, $wgUser, $wgRequest, $wgScriptPath;
 
                // Begin output
                $this->setHeaders();
-
+               
+               // Add style file to the output headers
+               $wgOut->addExtensionStyle( 
"$wgScriptPath/extensions/CentralNotice/centralnotice.css" );
+               
                // Check permissions
                $this->editable = $wgUser->isAllowed( 'centralnotice-admin' );
 
@@ -33,7 +36,10 @@
 
                // Show header
                $this->printHeader( $sub );
-
+               
+               // Begin Campaigns tab content
+               $wgOut->addHTML( Xml::openElement( 'div', array( 'id' => 
'preferences' ) ) );
+               
                $method = $wgRequest->getVal( 'method' );
                // Handle form sumissions
                if ( $this->editable && $wgRequest->wasPosted() ) {
@@ -185,7 +191,8 @@
                        $project_name      = $wgRequest->getVal( 'project_name' 
);
                        $project_languages = $wgRequest->getArray( 
'project_languages' );
                        if ( $noticeName == '' ) {
-                               $wgOut->addWikiMsg ( 
'centralnotice-null-string' );
+                               //$wgOut->addWikiMsg ( 
'centralnotice-null-string' );
+                               $wgOut->addHTML( Xml::element( 'div', array( 
'class' => 'cn-error' ), wfMsg( 'centralnotice-null-string' ) ) );
                        }
                        else {
                                $this->addNotice( $noticeName, '0', $start, 
$project_name, $project_languages );
@@ -205,6 +212,7 @@
                        $templateWeight = $wgRequest->getVal ( 'weight' );
                        $this->addTemplateTo( $noticeName, $templateName, 
$weight );
                        $this->listNoticeDetail( $noticeName );
+                       $wgOut->addHTML( Xml::closeElement( 'div' ) );
                        return;
                }
 
@@ -219,11 +227,15 @@
                if ( $method == 'listNoticeDetail' ) {
                        $notice = $wgRequest->getVal ( 'notice' );
                        $this->listNoticeDetail( $notice );
+                       $wgOut->addHTML( Xml::closeElement( 'div' ) );
                        return;
                }
 
                // Show list of notices
                $this->listNotices();
+               
+               // End Campaigns tab content
+               $wgOut->addHTML( Xml::closeElement( 'div' ) );
        }
 
        // Update the enabled/disabled state of notice
@@ -245,22 +257,18 @@
                        'CentralNotice' => wfMsg( 'centralnotice-notices' ),
                        'NoticeTemplate' => wfMsg ( 'centralnotice-templates' )
                );
-               $htmlOut = Xml::openElement( 'table', array( 'cellpadding' => 9 
) );
-               $htmlOut .= Xml::openElement( 'tr' );
+               $htmlOut = Xml::openElement( 'ul', array( 'id' => 'preftoc' ) );
                foreach ( $pages as $page => $msg ) {
                        $title = SpecialPage::getTitleFor( $page );
-
-                       $style = array( 'style' => 'border-bottom:solid 1px 
silver;' );
-                       if ( $page == $wgTitle->getText() ) {
-                               $style = array( 'style' => 'border-bottom:solid 
1px black;' );
+                       $attribs = array();
+                       if ( $wgTitle == $title ) {
+                               $attribs['class'] = 'selected';
                        }
-
-                       $htmlOut .= Xml::tags( 'td', $style,
+                       $htmlOut .= Xml::tags( 'li', $attribs,
                                $sk->makeLinkObj( $title, htmlspecialchars( 
$msg ) )
                        );
                }
-               $htmlOut .= Xml::closeElement( 'tr' );
-               $htmlOut .= Xml::closeElement( 'table' );
+               $htmlOut .= Xml::closeElement( 'ul' );
 
                $wgOut->addHTML( $htmlOut );
        }
@@ -400,43 +408,50 @@
                                array( 'ORDER BY' => 'not_id' )
                        );
                }
-
-               // Build HTML
+               
+               // Begin building HTML
                $htmlOut = '';
-               if ( $this->editable ) {
-                       $htmlOut .= Xml::openElement( 'form',
+               
+               // Begin Manage campaigns fieldset
+               $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 
'prefsection' ) );
+               
+               // If there are notices to show...
+               if ( $dbr->numRows( $res ) >= 1 ) {
+                       if ( $this->editable ) {
+                               $htmlOut .= Xml::openElement( 'form',
+                                       array(
+                                               'method' => 'post',
+                                               'action' => 
SpecialPage::getTitleFor( 'CentralNotice' )->getFullUrl()
+                                        )
+                               );
+                       }
+                       $htmlOut .= Xml::element( 'h2', null, wfMsg( 
'centralnotice-manage' ) );
+                       
+                       $htmlOut .= Xml::openElement( 'table',
                                array(
-                                       'method' => 'post',
-                                       'action' => SpecialPage::getTitleFor( 
'CentralNotice' )->getFullUrl()
-                                )
+                                       'cellpadding' => 9,
+                                       'width' => '100%',
+                                       'class' => 'wikitable sortable'
+                               )
                        );
-               }
-               $htmlOut .= Xml::fieldset( wfMsg( "centralnotice-manage" ) );
-               $htmlOut .= Xml::openElement( 'table',
-                       array(
-                               'cellpadding' => 9,
-                               'width' => '100%'
-                       )
-               );
-
-               // Headers
-               $headers = array(
-                       wfMsgHtml( 'centralnotice-notice-name' ),
-                       wfMsgHtml( 'centralnotice-project-name' ),
-                       wfMsgHtml( 'centralnotice-project-lang' ),
-                       wfMsgHtml( 'centralnotice-start-date' ),
-                       wfMsgHtml( 'centralnotice-end-date' ),
-                       wfMsgHtml( 'centralnotice-enabled' ),
-                       wfMsgHtml( 'centralnotice-preferred' ),
-                       wfMsgHtml( 'centralnotice-locked' ),
-               );
-               if ( $this->editable ) {
-                       $headers[] = wfMsgHtml( 'centralnotice-remove' );
-               }
-               $htmlOut .= $this->tableRow( $headers, 'th' );
-
-               // Rows
-               if ( $dbr->numRows( $res ) >= 1 ) {
+       
+                       // Headers
+                       $headers = array(
+                               wfMsgHtml( 'centralnotice-notice-name' ),
+                               wfMsgHtml( 'centralnotice-project-name' ),
+                               wfMsgHtml( 'centralnotice-project-lang' ),
+                               wfMsgHtml( 'centralnotice-start-date' ),
+                               wfMsgHtml( 'centralnotice-end-date' ),
+                               wfMsgHtml( 'centralnotice-enabled' ),
+                               wfMsgHtml( 'centralnotice-preferred' ),
+                               wfMsgHtml( 'centralnotice-locked' ),
+                       );
+                       if ( $this->editable ) {
+                               $headers[] = wfMsgHtml( 'centralnotice-remove' 
);
+                       }
+                       $htmlOut .= $this->tableRow( $headers, 'th' );
+       
+                       // Rows
                        while ( $row = $dbr->fetchObject( $res ) ) {
                                $fields = array();
 
@@ -504,32 +519,32 @@
 
                                $htmlOut .= $this->tableRow( $fields );
                        }
+                       $htmlOut .= Xml::closeElement( 'table' );
                        if ( $this->editable ) {
-                               $htmlOut .= $this->tableRow(
+                               $htmlOut .= Xml::openElement( 'div', array( 
'class' => 'cn-buttons' ) );
+                               $htmlOut .= Xml::submitButton( wfMsg( 
'centralnotice-modify' ),
                                        array(
-                                               Xml::submitButton( wfMsg( 
'centralnotice-modify' ),
-                                                       array(
-                                                               'id' => 
'centralnoticesubmit',
-                                                               'name' => 
'centralnoticesubmit'
-                                                       )
-                                               )
+                                               'id' => 'centralnoticesubmit',
+                                               'name' => 'centralnoticesubmit'
                                        )
                                );
-                       }
-
-                       $htmlOut .= Xml::closeElement( 'table' );
-                       $htmlOut .= Xml::closeElement( 'fieldset' );
-                       if ( $this->editable ) {
+                               $htmlOut .= Xml::closeElement( 'div' );
                                $htmlOut .= Xml::closeElement( 'form' );
                        }
 
-
                // No notices to show
                } else {
-                       $htmlOut = wfMsg( 'centralnotice-no-notices-exist' );
+                       $htmlOut .= wfMsg( 'centralnotice-no-notices-exist' );
                }
+               
+               // End Manage Campaigns fieldset
+               $htmlOut .= Xml::closeElement( 'fieldset' );
 
                if ( $this->editable ) {
+               
+                       // Begin Add a campaign fieldset
+                       $htmlOut .= Xml::openElement( 'fieldset', array( 
'class' => 'prefsection' ) );
+               
                        // Notice Adding
                        $htmlOut .= Xml::openElement( 'form',
                                array(
@@ -537,8 +552,7 @@
                                        'action' =>  SpecialPage::getTitleFor( 
'CentralNotice' )->getLocalUrl()
                                )
                        );
-                       $htmlOut .= Xml::openElement( 'fieldset' );
-                       $htmlOut .= Xml::element( 'legend', null, wfMsg( 
'centralnotice-add-notice' ) );
+                       $htmlOut .= Xml::element( 'h2', null, wfMsg( 
'centralnotice-add-notice' ) );
                        $htmlOut .= Xml::hidden( 'title', 
$this->getTitle()->getPrefixedText() );
                        $htmlOut .= Xml::hidden( 'method', 'addNotice' );
        
@@ -569,15 +583,19 @@
                        $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' 
), wfMsgHtml( 'yourlanguage' ) );
                        $htmlOut .= Xml::tags( 'td', array(), 
$this->languageMultiSelector() );
                        $htmlOut .= Xml::closeElement( 'tr' );
-                       // Submit
-                       $htmlOut .= Xml::openElement( 'tr' );
-                       $htmlOut .= Xml::tags( 'td', array( 'colspan' => '2' ), 
Xml::submitButton( wfMsg( 'centralnotice-modify' ) ) );
-                       $htmlOut .= Xml::closeElement( 'tr' );
-       
                        $htmlOut .= Xml::closeElement( 'table' );
                        $htmlOut .= Xml::hidden( 'change', 'weight' );
+                       
+                       // Submit button
+                       $htmlOut .= Xml::tags( 'div', 
+                               array( 'class' => 'cn-buttons' ), 
+                               Xml::submitButton( wfMsg( 
'centralnotice-modify' ) ) 
+                       );
+                       
+                       $htmlOut .= Xml::closeElement( 'form' );
+                       
+                       // End Add a campaign fieldset
                        $htmlOut .= Xml::closeElement( 'fieldset' );
-                       $htmlOut .= Xml::closeElement( 'form' );
                }
                
                // Output HTML
@@ -620,6 +638,10 @@
                }
 
                $htmlOut = '';
+               
+               // Begin Campaign detail fieldset
+               $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 
'prefsection' ) );
+               
                if ( $this->editable ) {
                        $htmlOut .= Xml::openElement( 'form',
                                array(
@@ -638,41 +660,46 @@
                $output_assigned = $this->assignedTemplatesForm( $notice );
                $output_templates = $this->addTemplatesForm( $notice );
 
-               // No notices returned
                if ( $output_detail == '' ) {
-                       $htmlOut .= wfMsg( 'centralnotice-no-notices-exist' );
+                       // Notice not found
+                       $htmlOut .= Xml::element( 'div', array( 'class' => 
'cn-error' ), wfMsg( 'centralnotice-notice-doesnt-exist' ) );
                } else {
                        $htmlOut .= $output_detail;
-               }
-
-               // Catch for no templates so that we dont' double message
-               if ( $output_assigned == '' && $output_templates == '' ) {
-                       $htmlOut .= wfMsg( 'centralnotice-no-templates' );
-                       $htmlOut .= Xml::element( 'p' );
-                       $newPage = SpecialPage::getTitleFor( 'NoticeTemplate', 
'add' );
-                       $sk = $wgUser->getSkin();
-                       $htmlOut .= $sk->makeLinkObj( $newPage, wfMsgHtml( 
'centralnotice-add-template' ) );
-                       $htmlOut .= Xml::element( 'p' );
-               } elseif ( $output_assigned == '' ) {
-                       $htmlOut .= wfMsg( 
'centralnotice-no-templates-assigned' );
-                       if ( $this->editable ) {
-                               $htmlOut .= $output_templates;
+               
+                       // Catch for no templates so that we don't double 
message
+                       if ( $output_assigned == '' && $output_templates == '' 
) {
+                               $htmlOut .= wfMsg( 'centralnotice-no-templates' 
);
+                               $htmlOut .= Xml::element( 'p' );
+                               $newPage = SpecialPage::getTitleFor( 
'NoticeTemplate', 'add' );
+                               $sk = $wgUser->getSkin();
+                               $htmlOut .= $sk->makeLinkObj( $newPage, 
wfMsgHtml( 'centralnotice-add-template' ) );
+                               $htmlOut .= Xml::element( 'p' );
+                       } elseif ( $output_assigned == '' ) {
+                               $htmlOut .= Xml::fieldset( wfMsg( 
'centralnotice-assigned-templates' ) );
+                               $htmlOut .= wfMsg( 
'centralnotice-no-templates-assigned' );
+                               $htmlOut .= Xml::closeElement( 'fieldset' );
+                               if ( $this->editable ) {
+                                       $htmlOut .= $output_templates;
+                               }
+                       } else {
+                               $htmlOut .= $output_assigned;
+                               if ( $this->editable ) {
+                                       $htmlOut .= $output_templates;
+                               }
                        }
-               } else {
-                       $htmlOut .= $output_assigned;
                        if ( $this->editable ) {
-                               $htmlOut .= $output_templates;
+                               // Submit button
+                               $htmlOut .= Xml::tags( 'div', 
+                                       array( 'class' => 'cn-buttons' ), 
+                                       Xml::submitButton( wfMsg( 
'centralnotice-modify' ) ) 
+                               );
                        }
                }
 
                if ( $this->editable ) {
-                       $htmlOut .= Xml::tags( 'tr', null,
-                               Xml::tags( 'td', array( 'collspan' => 2 ),
-                                       Xml::submitButton( wfMsg( 
'centralnotice-modify' ) )
-                               )
-                       );
                        $htmlOut .= Xml::closeElement( 'form' );
                }
+               $htmlOut .= Xml::closeElement( 'fieldset' );
                $wgOut->addHTML( $htmlOut );
        }
 
@@ -710,7 +737,7 @@
 
                if ( $row ) {
                        // Build Html
-                       $htmlOut  = Xml::fieldset( $notice );
+                       $htmlOut .= Xml::tags( 'h2', null, wfMsg( 
'centralnotice-notice' ) . ': ' . $notice );
                        $htmlOut .= Xml::openElement( 'table', array( 
'cellpadding' => 9 ) );
 
                        // Rows
@@ -762,7 +789,6 @@
                                $htmlOut .= Xml::closeElement( 'tr' );
                        }
                        $htmlOut .= Xml::closeElement( 'table' );
-                       $htmlOut .= Xml::closeElement( 'fieldset' ) ;
                        return $htmlOut;
                } else {
                        return '';
@@ -844,7 +870,8 @@
                                        htmlspecialchars( $row->tmp_name ),
                                        'template=' . urlencode( $row->tmp_name 
) ) .
                                Xml::fieldset( wfMsg( 'centralnotice-preview' ),
-                                       $render->getHtmlNotice( $row->tmp_name )
+                                       $render->getHtmlNotice( $row->tmp_name 
),
+                                       array( 'class' => 'cn-bannerpreview')
                                )
                        );
 
@@ -941,7 +968,8 @@
                                                        htmlspecialchars( 
$row->tmp_name ),
                                                        'template=' . 
urlencode( $row->tmp_name ) ) .
                                                Xml::fieldset( wfMsg( 
'centralnotice-preview' ),
-                                                       $render->getHtmlNotice( 
$row->tmp_name )
+                                                       $render->getHtmlNotice( 
$row->tmp_name ),
+                                                       array( 'class' => 
'cn-bannerpreview')
                                                )
                                        );
 
@@ -1033,7 +1061,7 @@
                $dbr = wfGetDB( DB_SLAVE );
                $res = $dbr->select( 'cn_notices', 'not_name', array( 
'not_name' => $noticeName ) );
                if ( $dbr->numRows( $res ) > 0 ) {
-                       $wgOut->addWikiMsg( 'centralnotice-notice-exists' );
+                       $wgOut->addHTML( Xml::element( 'div', array( 'class' => 
'cn-error' ), wfMsg( 'centralnotice-notice-exists' ) ) );
                        return;
                } else {
                        $dbw = wfGetDB( DB_MASTER );
@@ -1082,12 +1110,12 @@
                        array( 'not_name' => $noticeName )
                );
                if ( $dbr->numRows( $res ) < 1 ) {
-                        $wgOut->addWikiMsg( 
'centralnotice-notice-doesnt-exist' );
+                        $wgOut->addHTML( Xml::element( 'div', array( 'class' 
=> 'cn-error' ), wfMsg( 'centralnotice-remove-notice-doesnt-exist' ) ) );
                         return;
                }
                $row = $dbr->fetchObject( $res );
                if ( $row->not_locked == '1' ) {
-                        $wgOut->addWikiMsg( 'centralnotice-notice-is-locked' );
+                        $wgOut->addHTML( Xml::element( 'div', array( 'class' 
=> 'cn-error' ), wfMsg( 'centralnotice-notice-is-locked' ) ) );
                         return;
                } else {
                         $dbw = wfGetDB( DB_MASTER );
@@ -1116,7 +1144,7 @@
                        )
                );
                if ( $dbr->numRows( $res ) > 0 ) {
-                       $wgOut->addWikiMsg( 
'centralnotice-template-already-exists' );
+                       $wgOut->addHTML( Xml::element( 'div', array( 'class' => 
'cn-error' ), wfMsg( 'centralnotice-template-already-exists' ) ) );
                } else {
                        $dbw = wfGetDB( DB_MASTER );
                        $dbw->begin();
@@ -1184,14 +1212,14 @@
 
                // Start / end dont line up
                if ( $start > $end || $end < $start ) {
-                        $wgOut->addWikiMsg( 
'centralnotice-invalid-date-range3' );
+                        $wgOut->addHTML( Xml::element( 'div', array( 'class' 
=> 'cn-error' ), wfMsg( 'centralnotice-invalid-date-range3' ) ) );
                         return;
                }
 
                // Invalid notice name
                $res = $dbr->select( 'cn_notices', 'not_name', array( 
'not_name' => $noticeName ) );
                if ( $dbr->numRows( $res ) < 1 ) {
-                       $wgOut->addWikiMsg( 'centralnotice-doesnt-exist' );
+                       $wgOut->addHTML( Xml::element( 'div', array( 'class' => 
'cn-error' ), wfMsg( 'centralnotice-notice-doesnt-exist' ) ) );
                }
 
                // Overlap over a date within the same project and language
@@ -1218,7 +1246,7 @@
                        array( 'not_name' => $noticeName )
                );
                if ( $dbr->numRows( $res ) < 1 ) {
-                       $wgOut->addWikiMsg( 'centralnotice-doesnt-exist' );
+                       $wgOut->addHTML( Xml::element( 'div', array( 'class' => 
'cn-error' ), wfMsg( 'centralnotice-doesnt-exist' ) ) );
                } else {
                        $dbw = wfGetDB( DB_MASTER );
                        $dbw->begin();
@@ -1309,15 +1337,21 @@
        }
 }
 </script>";
-               $htmlOut .=
-                       Xml::tags( 'select',
+               if ( $this->editable ) {
+                       $htmlOut .= Xml::tags( 'select',
                                array( 'multiple' => 'multiple', 'size' => 4, 
'id' => 'project_languages[]', 'name' => 'project_languages[]' ),
                                $options
-                       ).
-                       Xml::tags( 'div',
+                       );
+                       $htmlOut .= Xml::tags( 'div',
                                array( 'style' => 'margin-top: 0.2em;' ),
                                '<img src="'.$scriptPath.'/arrow.png" 
style="vertical-align:baseline;"/>Select: <a href="#" 
onclick="selectLanguages(true);return false;">All</a>, <a href="#" 
onclick="selectLanguages(false);return false;">None</a>, <a href="#" 
onclick="top10Languages();return false;">Top 10 Languages</a>'
                        );
+               } else {
+                       $htmlOut .= Xml::tags( 'select',
+                               array( 'multiple' => 'multiple', 'size' => 4, 
'id' => 'project_languages[]', 'name' => 'project_languages[]', 'disabled' => 
'disabled' ),
+                               $options
+                       );
+               }
                return $htmlOut;
        }
        

Modified: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php
===================================================================
--- trunk/extensions/CentralNotice/SpecialNoticeTemplate.php    2010-07-30 
22:35:02 UTC (rev 70211)
+++ trunk/extensions/CentralNotice/SpecialNoticeTemplate.php    2010-07-31 
00:58:47 UTC (rev 70212)
@@ -19,10 +19,13 @@
         * Handle different types of page requests.
         */
        function execute( $sub ) {
-               global $wgOut, $wgUser, $wgRequest;
+               global $wgOut, $wgUser, $wgRequest, $wgScriptPath;
 
                // Begin output
                $this->setHeaders();
+               
+               // Add style file to the output headers
+               $wgOut->addExtensionStyle( 
"$wgScriptPath/extensions/CentralNotice/centralnotice.css" );
 
                // Check permissions
                $this->editable = $wgUser->isAllowed( 'centralnotice-admin' );
@@ -33,6 +36,9 @@
                // Show header
                CentralNotice::printHeader();
 
+               // Begin Banners tab content
+               $wgOut->addHTML( Xml::openElement( 'div', array( 'id' => 
'preferences' ) ) );
+               
                if ( $this->editable ) {
                        // Handle forms
                        if ( $wgRequest->wasPosted() ) {
@@ -79,38 +85,45 @@
                        }
                }
 
-               // Handle viewing of a template in all languages
-               if ( $sub == 'view' && $wgRequest->getVal( 'wpUserLanguage' ) 
== 'all' ) {
-                       $template =  $wgRequest->getVal( 'template' );
-                       $this->showViewAvailable( $template );
-                       return;
+               switch ( $sub ) {
+               
+                       // Handle viewing or editing a specific banner
+                       case 'view':
+                               if ( $wgRequest->getVal( 'wpUserLanguage' ) == 
'all' ) {
+                                       // Handle viewing a banner in all 
languages
+                                       $template =  $wgRequest->getVal( 
'template' );
+                                       $this->showViewAvailable( $template );
+                               } elseif ( $wgRequest->getText( 'template' ) != 
'' ) {
+                                       $this->showView();
+                               }
+                               break;
+                               
+                       // Handle adding a banner
+                       case 'add':
+                               if ( $this->editable ) {
+                                       $this->showAdd();
+                               }
+                               break;
+                               
+                       // Handle cloning a banner
+                       case 'clone':
+                               if ( $this->editable ) {
+                                       $oldTemplate = $wgRequest->getVal( 
'oldTemplate' );
+                                       $newTemplate =  $wgRequest->getVal( 
'newTemplate' );
+                                       // We use the returned name in case any 
special characters had to be removed
+                                       $template = $this->cloneTemplate( 
$oldTemplate, $newTemplate );
+                                       $wgOut->redirect( 
SpecialPage::getTitleFor( 'NoticeTemplate', 'view' )->getLocalUrl( 
"template=$template" ) );
+                               }
+                               break;
+                               
+                       // Show list of banners by default
+                       default:
+                               $this->showList();
+                               
                }
-
-               // Handle viewing a specific template
-               if ( $sub == 'view' && $wgRequest->getText( 'template' ) != '' 
) {
-                       $this->showView();
-                       return;
-               }
-
-               if ( $this->editable ) {
-                       // Handle viewing a specific template
-                       if ( $sub == 'add' ) {
-                               $this->showAdd();
-                               return;
-                       }
-
-                       if ( $sub == 'clone' ) {
-                               $oldTemplate = $wgRequest->getVal( 
'oldTemplate' );
-                               $newTemplate =  $wgRequest->getVal( 
'newTemplate' );
-                               // We use the returned name in case any special 
characters had to be removed
-                               $template = $this->cloneTemplate( $oldTemplate, 
$newTemplate );
-                               $wgOut->redirect( SpecialPage::getTitleFor( 
'NoticeTemplate', 'view' )->getLocalUrl( "template=$template" ) );
-                               return;
-                       }
-               }
-
-               // Show list by default
-               $this->showList();
+               
+               // End Banners tab content
+               $wgOut->addHTML( Xml::closeElement( 'div' ) );
        }
        
        /*
@@ -121,10 +134,16 @@
 
                $sk = $wgUser->getSkin();
                $pager = new NoticeTemplatePager( $this );
+               
+               // Begin building HTML
+               $htmlOut = '';
+               
+               // Begin Manage Banners fieldset
+               $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 
'prefsection' ) );
+               
                if ( !$pager->getNumRows() ) {
-                       $htmlOut = Xml::element( 'p', null, wfMsg( 
'centralnotice-no-templates' ) );
+                       $htmlOut .= Xml::element( 'p', null, wfMsg( 
'centralnotice-no-templates' ) );
                } else {
-                       $htmlOut = '';          
                        if ( $this->editable ) {
                                $htmlOut .= Xml::openElement( 'form',
                                        array(
@@ -133,13 +152,11 @@
                                         )
                                );
                        }
-
-                       $htmlOut .= Xml::fieldset( wfMsg( 
'centralnotice-available-templates' ) );
+                       $htmlOut .= Xml::element( 'h2', null, wfMsg( 
'centralnotice-manage-templates' ) );
                        $htmlOut .= $pager->getNavigationBar() .
                                $pager->getBody() .
                                $pager->getNavigationBar();
-
-                       $htmlOut .= Xml::closeElement( 'fieldset' );            
+               
                        if ( $this->editable ) {
                                $htmlOut .= Xml::closeElement( 'form' );
                        }
@@ -149,7 +166,10 @@
                        $htmlOut .= Xml::element( 'p' );
                        $newPage = SpecialPage::getTitleFor( 'NoticeTemplate', 
'add' );
                        $htmlOut .= $sk->makeLinkObj( $newPage, wfMsgHtml( 
'centralnotice-add-template' ) );
-               }               
+               }
+               
+               // End Manage Banners fieldset
+               $htmlOut .= Xml::closeElement( 'fieldset' );
 
                $wgOut->addHTML( $htmlOut );
        }
@@ -158,9 +178,10 @@
                global $wgOut;
 
                // Build HTML
-               $htmlOut = Xml::openElement( 'form', array( 'method' => 'post' 
) );
-               $htmlOut .= Xml::openElement( 'fieldset' );
-               $htmlOut .= Xml::element( 'legend', null, wfMsg( 
'centralnotice-add-template' ) );
+               $htmlOut = '';
+               $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 
'prefsection' ) );
+               $htmlOut .= Xml::openElement( 'form', array( 'method' => 'post' 
) );
+               $htmlOut .= Xml::element( 'h2', null, wfMsg( 
'centralnotice-add-template' ) );
                $htmlOut .= Xml::hidden( 'wpMethod', 'addTemplate' );
                $htmlOut .= Xml::tags( 'p', null,
                        Xml::inputLabel(
@@ -173,11 +194,15 @@
                $htmlOut .= Xml::tags( 'p', null,
                        Xml::textarea( 'templateBody', '', 60, 20 )
                );
-               $htmlOut .= Xml::tags( 'p', null,
-                       Xml::submitButton( wfMsg( 'centralnotice-modify' ) )
+               
+               // Submit button
+               $htmlOut .= Xml::tags( 'div', 
+                       array( 'class' => 'cn-buttons' ), 
+                       Xml::submitButton( wfMsg( 'centralnotice-modify' ) ) 
                );
+               
+               $htmlOut .= Xml::closeElement( 'form' );
                $htmlOut .= Xml::closeElement( 'fieldset' );
-               $htmlOut .= Xml::closeElement( 'form' );
 
                // Output HTML
                $wgOut->addHTML( $htmlOut );
@@ -201,17 +226,29 @@
 
                // Get current template
                $currentTemplate = $wgRequest->getText( 'template' );
+               
+               // Begin building HTML
+               $htmlOut = '';
+               
+               // Begin View Banner fieldset
+               $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 
'prefsection' ) );
+               
+               $htmlOut .= Xml::element( 'h2', null, wfMsg( 
'centralnotice-template' ) . ': ' . $currentTemplate );
 
                // Show preview
                $render = new SpecialNoticeText();
                $render->project = 'wikipedia';
                $render->language = $wgRequest->getVal( 'wpUserLanguage' );
-               $htmlOut = Xml::fieldset( wfMsg( 'centralnotice-preview' ),
-                       $render->getHtmlNotice( $wgRequest->getText( 'template' 
) )
-               );
+               if ( $render->language != '' ) {
+                       $htmlOut .= Xml::fieldset( wfMsg( 
'centralnotice-preview' ) . " ($render->language)",
+                               $render->getHtmlNotice( $wgRequest->getText( 
'template' ) )
+                       );
+               } else {
+                       $htmlOut .= Xml::fieldset( wfMsg( 
'centralnotice-preview' ),
+                               $render->getHtmlNotice( $wgRequest->getText( 
'template' ) )
+                       );
+               }
 
-               // Build HTML
-               
                // Pull text and respect any inc: markup
                $bodyPage = Title::newFromText( 
"Centralnotice-template-{$currentTemplate}", NS_MEDIAWIKI );
                $curRev = Revision::newFromTitle( $bodyPage );
@@ -381,8 +418,7 @@
                        $htmlOut .= Xml::fieldset( wfMsg( 
'centralnotice-clone-notice' ) );
                        $htmlOut .= Xml::openElement( 'table', array( 
'cellpadding' => 9 ) );
                        $htmlOut .= Xml::openElement( 'tr' );
-                       // FIXME: hardcoded text?
-                       $htmlOut .= Xml::inputLabel( 'Name:', 'newTemplate', 
'newTemplate, 25' );
+                       $htmlOut .= Xml::inputLabel( wfMsg( 
'centralnotice-clone-name' ) . ':', 'newTemplate', 'newTemplate', '25' );
                        $htmlOut .= Xml::submitButton( wfMsg( 
'centralnotice-clone' ), array ( 'id' => 'clone' ) );
                        $htmlOut .= Xml::hidden( 'oldTemplate', 
$currentTemplate );
 
@@ -391,6 +427,9 @@
                        $htmlOut .= Xml::closeElement( 'fieldset' );
                        $htmlOut .= Xml::closeElement( 'form' );
                }
+               
+               // End View Banner fieldset
+               $htmlOut .= Xml::closeElement( 'fieldset' );
 
                // Output HTML
                $wgOut->addHTML( $htmlOut );
@@ -407,6 +446,11 @@
                // Pull all available text for a template
                $langs = array_keys( $this->getTranslations( $template ) );
                $htmlOut = '';
+               
+               // Begin View Banner fieldset
+               $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 
'prefsection' ) );
+               
+               $htmlOut .= Xml::element( 'h2', null, wfMsg( 
'centralnotice-template' ) . ': ' . $template );
 
                foreach ( $langs as $lang ) {
                        // Link and Preview all available translations
@@ -419,10 +463,15 @@
                                        $lang,
                                        'template=' . urlencode( $template ) . 
"&wpUserLanguage=$lang" ) .
                                Xml::fieldset( wfMsg( 'centralnotice-preview' ),
-                                       $render->getHtmlNotice( $template )
+                                       $render->getHtmlNotice( $template ),
+                                       array( 'class' => 'cn-bannerpreview')
                                )
                        );
                }
+               
+               // End View Banner fieldset
+               $htmlOut .= Xml::closeElement( 'fieldset' );
+               
                return $wgOut->addHtml( $htmlOut );
        }
 
@@ -631,7 +680,7 @@
 
 class NoticeTemplatePager extends ReverseChronologicalPager {
        var $onRemoveChange, $viewPage, $special;
-       var $editable, $msgPreview;
+       var $editable;
 
        function __construct( $special ) {
                $this->special = $special;
@@ -645,7 +694,6 @@
                $msg = Xml::encodeJsVar( wfMsg( 'centralnotice-confirm-delete' 
) );
                $this->onRemoveChange = "if( this.checked ) { this.checked = 
confirm( $msg ) }";
                $this->viewPage = SpecialPage::getTitleFor( 'NoticeTemplate', 
'view' );
-               $this->msgPreview = wfMsg( 'centralnotice-preview' );
        }
 
        function getQueryInfo() {
@@ -682,8 +730,9 @@
                        $this->getSkin()->makeLinkObj( $this->viewPage,
                                htmlspecialchars( $row->tmp_name ),
                                'template=' . urlencode( $row->tmp_name ) ) .
-                       Xml::fieldset( $this->msgPreview,
-                               $render->getHtmlNotice( $row->tmp_name )
+                       Xml::fieldset( wfMsg( 'centralnotice-preview' ),
+                               $render->getHtmlNotice( $row->tmp_name ),
+                               array( 'class' => 'cn-bannerpreview')
                        )
                );
 



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to