Revision: 46009
Author: ialex
Date: 2009-01-22 10:16:38 +0000 (Thu, 22 Jan 2009)
Log Message:
-----------
* Also show templates used by notices in Central:Notice for users without
centralnotice-admin right
* Removed "Submit" button for users without centralnotice-admin right in
Special:CentralNotice
* Fixed XHTML errors
* Whitespaces fixes
Modified Paths:
--------------
trunk/extensions/CentralNotice/SpecialCentralNotice.php
trunk/extensions/CentralNotice/SpecialNoticeTemplate.php
Modified: trunk/extensions/CentralNotice/SpecialCentralNotice.php
===================================================================
--- trunk/extensions/CentralNotice/SpecialCentralNotice.php 2009-01-22
10:03:31 UTC (rev 46008)
+++ trunk/extensions/CentralNotice/SpecialCentralNotice.php 2009-01-22
10:16:38 UTC (rev 46009)
@@ -92,27 +92,27 @@
}
}
- // Handle setting preferred
- $preferredNotices = $wgRequest->getArray( 'preferred'
);
- if ( isset( $preferredNotices ) ) {
- // Set since this is a single display
- if ( $method == 'listNoticeDetail' ) {
- $notice = $wgRequest->getVal ( 'notice' );
- CentralNoticeDB::updatePreferred( $notice,
'1' );
- }
- else {
- // Build list of notices to unset
- $unsetNotices = array_diff(
$this->getNoticesName(), $preferredNotices );
+ // Handle setting preferred
+ $preferredNotices = $wgRequest->getArray( 'preferred' );
+ if ( isset( $preferredNotices ) ) {
+ // Set since this is a single display
+ if ( $method == 'listNoticeDetail' ) {
+ $notice = $wgRequest->getVal ( 'notice'
);
+ CentralNoticeDB::updatePreferred(
$notice, '1' );
+ }
+ else {
+ // Build list of notices to unset
+ $unsetNotices = array_diff(
$this->getNoticesName(), $preferredNotices );
- // Set flag accordingly
- foreach( $preferredNotices as $notice ) {
- CentralNoticeDB::updatePreferred(
$notice, '1' );
- }
- foreach( $unsetNotices as $notice ) {
- CentralNoticeDB::updatePreferred(
$notice, '0' );
- }
- }
- }
+ // Set flag accordingly
+ foreach( $preferredNotices as $notice )
{
+
CentralNoticeDB::updatePreferred( $notice, '1' );
+ }
+ foreach( $unsetNotices as $notice ) {
+
CentralNoticeDB::updatePreferred( $notice, '0' );
+ }
+ }
+ }
$noticeName = $wgRequest->getVal( 'notice' );
@@ -645,29 +645,33 @@
}
// Catch for no templates so that we dont' double message
- if( $this->editable ) {
- 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' );
- $htmlOut .= $output_templates;
- } else {
- $htmlOut .= $output_assigned;
- $htmlOut .= $output_templates;
+ 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;
}
+ } else {
+ $htmlOut .= $output_assigned;
+ if( $this->editable ) {
+ $htmlOut .= $output_templates;
+ }
}
- $htmlOut .= Xml::tags( 'tr', null,
- Xml::tags( 'td', array( 'collspan' => 2 ),
- Xml::submitButton( wfMsg(
'centralnotice-modify' ) )
- )
- );
-
- $htmlOut .= Xml::closeElement( 'form' );
+
+ if( $this->editable ) {
+ $htmlOut .= Xml::tags( 'tr', null,
+ Xml::tags( 'td', array( 'collspan' => 2 ),
+ Xml::submitButton( wfMsg(
'centralnotice-modify' ) )
+ )
+ );
+ $htmlOut .= Xml::closeElement( 'form' );
+ }
$wgOut->addHTML( $htmlOut );
}
Modified: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php
===================================================================
--- trunk/extensions/CentralNotice/SpecialNoticeTemplate.php 2009-01-22
10:03:31 UTC (rev 46008)
+++ trunk/extensions/CentralNotice/SpecialNoticeTemplate.php 2009-01-22
10:16:38 UTC (rev 46009)
@@ -80,12 +80,12 @@
}
}
- // Handle viewiing of a template in all languages
- if ( $sub == 'view' && $wgRequest->getVal( 'wpUserLanguage' )
== 'all' ) {
- $template = $wgRequest->getVal( 'template' );
- $this->showViewAvailable( $template );
- return;
- }
+ // Handle viewiing of a template in all languages
+ if ( $sub == 'view' && $wgRequest->getVal( 'wpUserLanguage' )
== 'all' ) {
+ $template = $wgRequest->getVal( 'template' );
+ $this->showViewAvailable( $template );
+ return;
+ }
// Handle viewing a specific template
if ( $sub == 'view' && $wgRequest->getText( 'template' ) != ''
) {
@@ -365,7 +365,7 @@
$htmlOut .= Xml::openElement( 'table', array ( 'cellpadding' =>
9 ) );
list( $lsLabel, $lsSelect ) = Xml::languageSelector(
$wpUserLang );
- $newPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view'
);
+ $newPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' );
$htmlOut .= Xml::tags( 'tr', null,
Xml::tags( 'td', null, $lsLabel ) .
@@ -410,62 +410,63 @@
$htmlOut .= Xml::closeElement( 'form' );
}
- /*
- * Show Clone form
- */
- if ( $this->editable ) {
- $htmlOut .= Xml::openElement ( 'form',
- array(
- 'method' => 'post',
- 'action' => SpecialPage::getTitleFor(
'NoticeTemplate', 'clone' )->getLocalUrl()
- )
- );
+ /*
+ * Show Clone form
+ */
+ if ( $this->editable ) {
+ $htmlOut .= Xml::openElement ( 'form',
+ array(
+ 'method' => 'post',
+ 'action' => SpecialPage::getTitleFor(
'NoticeTemplate', 'clone' )->getLocalUrl()
+ )
+ );
- $htmlOut .= Xml::fieldset( wfMsg(
'centralnotice-clone-notice' ) );
- $htmlOut .= Xml::openElement( 'table', array(
'cellpadding' => 9 ) );
- $htmlOut .= Xml::openElement( 'tr' );
- $htmlOut .= Xml::inputLabel( 'Name:', 'newTemplate',
'newTemplate, 25');
- $htmlOut .= Xml::submitButton( wfMsg(
'centralnotice-clone' ), array ( 'id' => 'clone' ) );
- $htmlOut .= Xml::hidden( 'oldTemplate',
$currentTemplate );
+ $htmlOut .= Xml::fieldset( wfMsg(
'centralnotice-clone-notice' ) );
+ $htmlOut .= Xml::openElement( 'table', array(
'cellpadding' => 9 ) );
+ $htmlOut .= Xml::openElement( 'tr' );
+ $htmlOut .= Xml::inputLabel( 'Name:', 'newTemplate',
'newTemplate, 25');
+ $htmlOut .= Xml::submitButton( wfMsg(
'centralnotice-clone' ), array ( 'id' => 'clone' ) );
+ $htmlOut .= Xml::hidden( 'oldTemplate',
$currentTemplate );
- $htmlOut .= Xml::closeElement( 'tr' );
- $htmlOut .= Xml::closeElement( 'table' );
- $htmlOut .= Xml::closeElement( 'form' );
- }
+ $htmlOut .= Xml::closeElement( 'tr' );
+ $htmlOut .= Xml::closeElement( 'table' );
+ $htmlOut .= Xml::closeElement( 'fieldset' );
+ $htmlOut .= Xml::closeElement( 'form' );
+ }
- // Output HTML
- $wgOut->addHTML( $htmlOut );
- }
+ // Output HTML
+ $wgOut->addHTML( $htmlOut );
+ }
- public function showViewAvailable( $template ) {
- global $wgOut, $wgUser;
+ public function showViewAvailable( $template ) {
+ global $wgOut, $wgUser;
- // Testing to see if bumping up the memory limit lets meta preview
- ini_set( 'memory_limit', '120M' );
+ // Testing to see if bumping up the memory limit lets meta
preview
+ ini_set( 'memory_limit', '120M' );
- $sk = $wgUser->getSkin();
+ $sk = $wgUser->getSkin();
- // Pull all available text for a template
- $langs = array_keys( $this->getTranslations( $template ) );
- $htmlOut = '';
+ // Pull all available text for a template
+ $langs = array_keys( $this->getTranslations( $template ) );
+ $htmlOut = '';
- foreach( $langs as $lang ) {
- // Link and Preview all available translations
- $viewPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view'
);
- $render = new SpecialNoticeText();
- $render->project = 'wikipedia';
- $render->language = $lang;
- $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
- $sk->makeLinkObj( $viewPage,
- $lang,
- 'template=' . urlencode( $template ) .
"&wpUserLanguage=$lang") .
- Xml::fieldset( wfMsg( 'centralnotice-preview' ),
- $render->getHtmlNotice( $template )
- )
- );
- }
- return $wgOut->addHtml( $htmlOut );
- }
+ foreach( $langs as $lang ) {
+ // Link and Preview all available translations
+ $viewPage = SpecialPage::getTitleFor( 'NoticeTemplate',
'view' );
+ $render = new SpecialNoticeText();
+ $render->project = 'wikipedia';
+ $render->language = $lang;
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
+ $sk->makeLinkObj( $viewPage,
+ $lang,
+ 'template=' . urlencode( $template ) .
"&wpUserLanguage=$lang") .
+ Xml::fieldset( wfMsg( 'centralnotice-preview' ),
+ $render->getHtmlNotice( $template )
+ )
+ );
+ }
+ return $wgOut->addHtml( $htmlOut );
+ }
private function updateMessage( $text, $translation, $lang, $token =
false ) {
global $wgUser;
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs