Index: trunk/extensions/CentralNotice/arrow.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php |
— | — | @@ -31,6 +31,9 @@ |
32 | 32 | // Add style file to the output headers |
33 | 33 | $wgOut->addExtensionStyle( "$wgScriptPath/extensions/CentralNotice/centralnotice.css" ); |
34 | 34 | |
| 35 | + // Add script file to the output headers |
| 36 | + $wgOut->addScriptFile( "$wgScriptPath/extensions/CentralNotice/centralnotice.js" ); |
| 37 | + |
35 | 38 | // Check permissions |
36 | 39 | $this->editable = $wgUser->isAllowed( 'centralnotice-admin' ); |
37 | 40 | |
— | — | @@ -287,12 +290,15 @@ |
288 | 291 | return $notices; |
289 | 292 | } |
290 | 293 | |
291 | | - function tableRow( $fields, $element = 'td' ) { |
| 294 | + /** |
| 295 | + * Build a table row. Needed since Xml::buildTableRow escapes all HTML. |
| 296 | + */ |
| 297 | + function tableRow( $fields, $element = 'td', $attribs = array() ) { |
292 | 298 | $cells = array(); |
293 | 299 | foreach ( $fields as $field ) { |
294 | 300 | $cells[] = Xml::tags( $element, array(), $field ); |
295 | 301 | } |
296 | | - return Xml::tags( 'tr', array(), implode( "\n", $cells ) ) . "\n"; |
| 302 | + return Xml::tags( 'tr', $attribs, implode( "\n", $cells ) ) . "\n"; |
297 | 303 | } |
298 | 304 | |
299 | 305 | function dateSelector( $prefix, $timestamp = null ) { |
— | — | @@ -516,8 +522,14 @@ |
517 | 523 | $fields[] = Xml::check( 'removeNotices[]', false, |
518 | 524 | array( 'value' => $row->not_name ) ); |
519 | 525 | } |
520 | | - |
521 | | - $htmlOut .= $this->tableRow( $fields ); |
| 526 | + |
| 527 | + // If campaign is currently active, set special class on table row. |
| 528 | + $attribs = array(); |
| 529 | + if ( wfTimestamp() > wfTimestamp( TS_UNIX , $row->not_start ) && wfTimestamp() < wfTimestamp( TS_UNIX , $row->not_end ) && $row->not_enabled == '1' ) { |
| 530 | + $attribs = array( 'class' => 'cn-active-campaign' ); |
| 531 | + } |
| 532 | + |
| 533 | + $htmlOut .= $this->tableRow( $fields, 'td', $attribs ); |
522 | 534 | } |
523 | 535 | // End table of campaigns |
524 | 536 | $htmlOut .= Xml::closeElement( 'table' ); |
— | — | @@ -1328,26 +1340,7 @@ |
1329 | 1341 | foreach( $languages as $code => $name ) { |
1330 | 1342 | $options .= Xml::option( "$code - $name", $code, in_array( $code, $selected ) ) . "\n"; |
1331 | 1343 | } |
1332 | | - $htmlOut = " |
1333 | | -<script type=\"text/javascript\"> |
1334 | | -function selectLanguages(selectAll) { |
1335 | | - var selectBox = document.getElementById(\"project_languages[]\"); |
1336 | | - var firstSelect = selectBox.options.length - 1; |
1337 | | - for (var i = firstSelect; i >= 0; i--) { |
1338 | | - selectBox.options[i].selected = selectAll; |
1339 | | - } |
1340 | | -} |
1341 | | -function top10Languages() { |
1342 | | - var selectBox = document.getElementById(\"project_languages[]\"); |
1343 | | - var top10 = new Array('en','de','fr','it','pt','ja','es','pl','ru','nl'); |
1344 | | - for (var i = 0; i < selectBox.options.length; i++) { |
1345 | | - var lang = selectBox.options[i].value; |
1346 | | - if (top10.toString().indexOf(lang)!==-1) { |
1347 | | - selectBox.options[i].selected = true; |
1348 | | - } |
1349 | | - } |
1350 | | -} |
1351 | | -</script>"; |
| 1344 | + $htmlOut = ''; |
1352 | 1345 | if ( $this->editable ) { |
1353 | 1346 | $htmlOut .= Xml::tags( 'select', |
1354 | 1347 | array( 'multiple' => 'multiple', 'size' => 4, 'id' => 'project_languages[]', 'name' => 'project_languages[]' ), |
— | — | @@ -1355,7 +1348,7 @@ |
1356 | 1349 | ); |
1357 | 1350 | $htmlOut .= Xml::tags( 'div', |
1358 | 1351 | array( 'style' => 'margin-top: 0.2em;' ), |
1359 | | - '<img src="'.$scriptPath.'/arrow.png" style="vertical-align:baseline;"/>' . wfMsg( 'centralnotice-select' ) . ': <a href="#" onclick="selectLanguages(true);return false;">' . wfMsg( 'powersearch-toggleall' ) . '</a>, <a href="#" onclick="selectLanguages(false);return false;">' . wfMsg( 'powersearch-togglenone' ) . '</a>, <a href="#" onclick="top10Languages();return false;">' . wfMsg( 'centralnotice-top-ten-languages' ) . '</a>' |
| 1352 | + '<img src="'.$scriptPath.'/up-arrow.png" style="vertical-align:baseline;"/>' . wfMsg( 'centralnotice-select' ) . ': <a href="#" onclick="selectLanguages(true);return false;">' . wfMsg( 'powersearch-toggleall' ) . '</a>, <a href="#" onclick="selectLanguages(false);return false;">' . wfMsg( 'powersearch-togglenone' ) . '</a>, <a href="#" onclick="top10Languages();return false;">' . wfMsg( 'centralnotice-top-ten-languages' ) . '</a>' |
1360 | 1353 | ); |
1361 | 1354 | } else { |
1362 | 1355 | $htmlOut .= Xml::tags( 'select', |
Index: trunk/extensions/CentralNotice/centralnotice.css |
— | — | @@ -28,6 +28,9 @@ |
29 | 29 | #preferences fieldset.prefsection div.cn-error { |
30 | 30 | margin:0; |
31 | 31 | } |
| 32 | +#preferences table tr.cn-active-campaign { |
| 33 | + background-color: #ddffdd; |
| 34 | +} |
32 | 35 | #preferences div.cn-buttons { |
33 | 36 | padding:1em; |
34 | 37 | } |
Index: trunk/extensions/CentralNotice/down-arrow.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/CentralNotice/down-arrow.png |
___________________________________________________________________ |
Added: svn:mime-type |
35 | 38 | + application/octet-stream |
Index: trunk/extensions/CentralNotice/CentralNotice.i18n.php |
— | — | @@ -105,6 +105,9 @@ |
106 | 106 | 'centralnotice-donate-button' => 'Donate button', |
107 | 107 | 'centralnotice-expanded-banner' => 'Expanded banner', |
108 | 108 | 'centralnotice-collapsed-banner' => 'Collapsed banner', |
| 109 | + 'centralnotice-banner-type' => 'Banner type', |
| 110 | + 'centralnotice-banner-hidable' => 'Static/Hidable', |
| 111 | + 'centralnotice-banner-collapsable' => 'Collapsable', |
109 | 112 | |
110 | 113 | 'right-centralnotice-admin' => 'Manage central notices', |
111 | 114 | 'right-centralnotice-translate' => 'Translate central notices', |
Index: trunk/extensions/CentralNotice/up-arrow.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/CentralNotice/up-arrow.png |
___________________________________________________________________ |
Added: svn:mime-type |
112 | 115 | + application/octet-stream |
Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php |
— | — | @@ -26,6 +26,9 @@ |
27 | 27 | |
28 | 28 | // Add style file to the output headers |
29 | 29 | $wgOut->addExtensionStyle( "$wgScriptPath/extensions/CentralNotice/centralnotice.css" ); |
| 30 | + |
| 31 | + // Add script file to the output headers |
| 32 | + $wgOut->addScriptFile( "$wgScriptPath/extensions/CentralNotice/centralnotice.js" ); |
30 | 33 | |
31 | 34 | // Check permissions |
32 | 35 | $this->editable = $wgUser->isAllowed( 'centralnotice-admin' ); |
— | — | @@ -179,7 +182,8 @@ |
180 | 183 | * Show "Add a banner" interface |
181 | 184 | */ |
182 | 185 | function showAdd() { |
183 | | - global $wgOut, $wgUser; |
| 186 | + global $wgOut, $wgUser, $wgScriptPath; |
| 187 | + $scriptPath = "$wgScriptPath/extensions/CentralNotice"; |
184 | 188 | |
185 | 189 | // Build HTML |
186 | 190 | $htmlOut = ''; |
— | — | @@ -188,17 +192,15 @@ |
189 | 193 | $htmlOut .= Xml::element( 'h2', null, wfMsg( 'centralnotice-add-template' ) ); |
190 | 194 | $htmlOut .= Xml::hidden( 'wpMethod', 'addTemplate' ); |
191 | 195 | $htmlOut .= Xml::tags( 'p', null, |
192 | | - Xml::inputLabel( |
193 | | - wfMsg( 'centralnotice-template-name' ) . ":", |
194 | | - 'templateName', |
195 | | - 'templateName', |
196 | | - 25 |
197 | | - ) |
| 196 | + Xml::inputLabel( wfMsg( 'centralnotice-template-name' ) . ":", 'templateName', 'templateName', 25 ) |
198 | 197 | ); |
199 | 198 | $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-template' ) ); |
200 | | - $htmlOut .= Xml::tags( 'p', null, |
201 | | - Xml::textarea( 'templateBody', '', 60, 20 ) |
| 199 | + $htmlOut .= wfMsg( 'centralnotice-edit-template-summary' ); |
| 200 | + $htmlOut .= Xml::tags( 'div', |
| 201 | + array( 'style' => 'margin-bottom: 0.2em;' ), |
| 202 | + '<img src="'.$scriptPath.'/down-arrow.png" style="vertical-align:baseline;"/>' . wfMsg( 'centralnotice-insert' ) . ': <a href="#" onclick="insertButton(\'hide\');return false;">' . wfMsg( 'centralnotice-hide-button' ) . '</a>, <a href="#" onclick="insertButton(\'translate\');return false;">' . wfMsg( 'centralnotice-translate-button' ) . '</a>' |
202 | 203 | ); |
| 204 | + $htmlOut .= Xml::textarea( 'templateBody', '', 60, 20 ); |
203 | 205 | $htmlOut .= Xml::closeElement( 'fieldset' ); |
204 | 206 | $htmlOut .= Xml::hidden( 'authtoken', $wgUser->editToken() ); |
205 | 207 | |
Index: trunk/extensions/CentralNotice/centralnotice.js |
— | — | @@ -0,0 +1,43 @@ |
| 2 | +function selectLanguages(selectAll) { |
| 3 | + var selectBox = document.getElementById('project_languages[]'); |
| 4 | + var firstSelect = selectBox.options.length - 1; |
| 5 | + for (var i = firstSelect; i >= 0; i--) { |
| 6 | + selectBox.options[i].selected = selectAll; |
| 7 | + } |
| 8 | +} |
| 9 | +function top10Languages() { |
| 10 | + var selectBox = document.getElementById('project_languages[]'); |
| 11 | + var top10 = new Array('en','de','fr','it','pt','ja','es','pl','ru','nl'); |
| 12 | + for (var i = 0; i < selectBox.options.length; i++) { |
| 13 | + var lang = selectBox.options[i].value; |
| 14 | + if (top10.toString().indexOf(lang)!==-1) { |
| 15 | + selectBox.options[i].selected = true; |
| 16 | + } |
| 17 | + } |
| 18 | +} |
| 19 | +function insertButton( buttonType ) { |
| 20 | + var bannerField = document.getElementById('templateBody'); |
| 21 | + switch( buttonType ) { |
| 22 | + case 'translate': |
| 23 | + var buttonValue = '[<a href="http://meta.wikimedia.org/wiki/CentralNotice">{{int:centralnotice-shared-help-translate}}</a>]'; |
| 24 | + break; |
| 25 | + case 'hide': |
| 26 | + var buttonValue = '[<a href="#" onclick="toggleNotice();return false">{{int:centralnotice-shared-hide}}</a>]'; |
| 27 | + break; |
| 28 | + } |
| 29 | + if (document.selection) { |
| 30 | + // IE support |
| 31 | + bannerField.focus(); |
| 32 | + sel = document.selection.createRange(); |
| 33 | + sel.text = buttonValue; |
| 34 | + } else if (bannerField.selectionStart || bannerField.selectionStart == '0') { |
| 35 | + // Mozilla support |
| 36 | + var startPos = bannerField.selectionStart; |
| 37 | + var endPos = bannerField.selectionEnd; |
| 38 | + bannerField.value = bannerField.value.substring(0, startPos) |
| 39 | + + buttonValue |
| 40 | + + bannerField.value.substring(endPos, bannerField.value.length); |
| 41 | + } else { |
| 42 | + bannerField.value += buttonValue; |
| 43 | + } |
| 44 | +} |
\ No newline at end of file |