Index: trunk/extensions/QPoll/qp_user.php |
— | — | @@ -66,6 +66,20 @@ |
67 | 67 | 'descriptionmsg' => 'qp_desc-sp', |
68 | 68 | ); |
69 | 69 | |
| 70 | +if ( isset( $wgResourceModules ) ) { |
| 71 | + $wgResourceModules['ext.qpoll'] = array( |
| 72 | + 'scripts' => 'qp_user.js', |
| 73 | + 'styles' => 'qp_user.css', |
| 74 | + 'localBasePath' => dirname( __FILE__ ), |
| 75 | + 'remoteExtPath' => 'QPoll' |
| 76 | + ); |
| 77 | + $wgResourceModules['ext.qpoll.special.pollresults'] = array( |
| 78 | + 'styles' => 'qp_results.css', |
| 79 | + 'localBasePath' => dirname( __FILE__ ), |
| 80 | + 'remoteExtPath' => 'QPoll' |
| 81 | + ); |
| 82 | +} |
| 83 | + |
70 | 84 | /** |
71 | 85 | * Extension's global settings and initializiers |
72 | 86 | * should be purely static and preferrably have no constructor |
— | — | @@ -151,12 +165,10 @@ |
152 | 166 | $wgSpecialPages['PollResults'] = array('PollResults'); |
153 | 167 | // TODO: Use the new technique for i18n of magic words |
154 | 168 | // instantiating fake instance for PHP < 5.2.3, which does not support 'Class::method' type of callbacks |
155 | | - $qp_Setup = new qp_Setup; |
156 | 169 | $wgHooks['LanguageGetMagic'][] = |
157 | 170 | $wgHooks['MediaWikiPerformAction'][] = |
158 | 171 | $wgHooks['ParserFirstCallInit'][] = |
159 | | - $wgHooks['LoadAllMessages'][] = |
160 | | - $wgHooks['ResourceLoaderRegisterModules'][] = $qp_Setup; |
| 172 | + $wgHooks['LoadAllMessages'][] = new qp_Setup; |
161 | 173 | } |
162 | 174 | |
163 | 175 | static function onLoadAllMessages() { |
— | — | @@ -273,35 +285,6 @@ |
274 | 286 | } |
275 | 287 | |
276 | 288 | /** |
277 | | - * MW 1.17+ ResourceLoader module hook (JS,CSS) |
278 | | - */ |
279 | | - static function onResourceLoaderRegisterModules( $resourceLoader ) { |
280 | | - global $wgExtensionAssetsPath; |
281 | | - $localpath = dirname( __FILE__ ); |
282 | | - $remotepath = "$wgExtensionAssetsPath/QPoll"; |
283 | | - $resourceLoader->register( |
284 | | - array( |
285 | | - 'ext.qpoll' => new ResourceLoaderFileModule( |
286 | | - array( |
287 | | - 'scripts' => 'qp_user.js', |
288 | | - 'styles' => 'qp_user.css' |
289 | | - ), |
290 | | - $localpath, |
291 | | - $remotepath |
292 | | - ), |
293 | | - 'ext.qpoll.special.pollresults' => new ResourceLoaderFileModule( |
294 | | - array( |
295 | | - 'styles' => 'qp_results.css' |
296 | | - ), |
297 | | - $localpath, |
298 | | - $remotepath |
299 | | - ) |
300 | | - ) |
301 | | - ); |
302 | | - return true; |
303 | | - } |
304 | | - |
305 | | - /** |
306 | 289 | * Call the poll parser on an input text. |
307 | 290 | * |
308 | 291 | * @param $input Text between <qpoll> and </qpoll> tags, in QPoll syntax. |
Index: trunk/extensions/QPoll/qp_question.php |
— | — | @@ -562,10 +562,11 @@ |
563 | 563 | # |
564 | 564 | function parseBodyHeader( $input ) { |
565 | 565 | $this->raws = preg_split( '`\n`su', $input, -1, PREG_SPLIT_NO_EMPTY ); |
566 | | - if ( array_key_exists( 1, $this->raws ) ) { |
| 566 | + $categorySpans = false; |
| 567 | + if ( isset( $this->raws[1] ) ) { |
567 | 568 | $categorySpans = preg_match( $this->mCategoryPattern, $this->raws[1]."\n", $matches ); |
568 | 569 | } |
569 | | - if ( !$categorySpans && array_key_exists( 0, $this->raws ) ) { |
| 570 | + if ( !$categorySpans && isset( $this->raws[0] ) ) { |
570 | 571 | preg_match( $this->mCategoryPattern, $this->raws[0]."\n", $matches ); |
571 | 572 | } |
572 | 573 | # parse the header - spans and categories |
— | — | @@ -582,6 +583,12 @@ |
583 | 584 | } |
584 | 585 | $this->addRow( $spansRow, array( 'class'=>'spans' ), 'th', array( 'count'=>$this->spanType, 'name'=>0 ) ); |
585 | 586 | } |
| 587 | + # do not render single empty category at all (on user's request) |
| 588 | + if ( count( $this->mCategories ) == 1 && |
| 589 | + $this->mCategories[0]['name'] == ' ' ) { |
| 590 | + return; |
| 591 | + } |
| 592 | + # render category table row |
586 | 593 | if ( $this->categoriesStyle != '' ) { |
587 | 594 | qp_Renderer::applyAttrsToRow( $catRow, array( 'style'=>$this->categoriesStyle ) ); |
588 | 595 | } |