Index: trunk/extensions/WikiEditor/WikiEditor.php |
— | — | @@ -16,17 +16,17 @@ |
17 | 17 | /* Configuration */ |
18 | 18 | |
19 | 19 | // Each module may be configured individually to be globally on/off or user preference based |
20 | | -$wgWikiEditorModules = array( |
21 | | - // Order is significant: makes beta prefs appear before labs prefs |
| 20 | +$wgWikiEditorFeatures = array( |
| 21 | + 'addMediaWizard' => array( 'global' => false, 'user' => false ), |
| 22 | + 'dialogs' => array( 'global' => false, 'user' => true ), |
| 23 | + 'highlight' => array( 'global' => false, 'user' => true ), |
22 | 24 | 'toolbar' => array( 'global' => false, 'user' => true ), |
23 | | - 'highlight' => array( 'global' => false, 'user' => true ), |
24 | 25 | 'preview' => array( 'global' => false, 'user' => true ), |
25 | 26 | 'previewDialog' => array( 'global' => false, 'user' => true ), |
26 | 27 | 'publish' => array( 'global' => false, 'user' => true ), |
27 | | - 'toc' => array( 'global' => false, 'user' => true ), |
28 | 28 | 'templateEditor' => array( 'global' => false, 'user' => true ), |
29 | 29 | 'templates' => array( 'global' => false, 'user' => true ), |
30 | | - 'addMediaWizard' => array( 'global' => false, 'user' => false ), |
| 30 | + 'toc' => array( 'global' => false, 'user' => true ), |
31 | 31 | ); |
32 | 32 | |
33 | 33 | // Bump this each time you change an icon without renaming it |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | ); |
46 | 46 | $wgAutoloadClasses['WikiEditorHooks'] = dirname( __FILE__ ) . '/WikiEditor.hooks.php'; |
47 | 47 | $wgExtensionMessagesFiles['WikiEditor'] = dirname( __FILE__ ) . '/WikiEditor.i18n.php'; |
48 | | -$wgHooks['BeforePageDisplay'][] = 'WikiEditorHooks::beforePageDisplay'; |
| 48 | +$wgHooks['EditPage::showEditForm:initial'][] = 'WikiEditorHooks::editPageShowEditFormInitial'; |
49 | 49 | $wgHooks['GetPreferences'][] = 'WikiEditorHooks::getPreferences'; |
50 | 50 | $wgHooks['MakeGlobalVariablesScript'][] = 'WikiEditorHooks::makeGlobalVariablesScript'; |
51 | 51 | $wgHooks['ResourceLoaderRegisterModules'][] = 'WikiEditorHooks::resourceLoaderRegisterModules'; |
Index: trunk/extensions/WikiEditor/WikiEditor.hooks.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | |
12 | 12 | /* Static Members */ |
13 | 13 | |
14 | | - static $resources = array( |
| 14 | + static $modules = array( |
15 | 15 | |
16 | 16 | /* WikiEditor jQuery plugin Resources */ |
17 | 17 | |
— | — | @@ -18,8 +18,12 @@ |
19 | 19 | 'scripts' => 'extensions/WikiEditor/modules/jquery.wikiEditor.js', |
20 | 20 | 'styles' => 'extensions/WikiEditor/modules/jquery.wikiEditor.css', |
21 | 21 | 'dependencies' => array( |
22 | | - 'jquery.client', |
| 22 | + 'jquery.client', 'jquery.textSelection', 'jquery.delayedBind' |
23 | 23 | ), |
| 24 | + 'messages' => array( |
| 25 | + 'wikieditor-wikitext-tab', |
| 26 | + 'wikieditor-loading', |
| 27 | + ), |
24 | 28 | ), |
25 | 29 | 'jquery.wikiEditor.dialogs' => array( |
26 | 30 | 'scripts' => 'extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js', |
— | — | @@ -99,39 +103,42 @@ |
100 | 104 | 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.dialogs.js', |
101 | 105 | 'styles' => 'extensions/WikiEditor/modules/wikiEditor.dialogs.css', |
102 | 106 | 'dependencies' => array( |
103 | | - 'jquery.wikiEditor.dialogs', |
| 107 | + 'wikiEditor', 'jquery.wikiEditor.dialogs', 'jquery.suggestions', |
104 | 108 | ), |
105 | 109 | ), |
106 | 110 | 'wikiEditor.highlight' => array( |
107 | 111 | 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.highlight.js', |
108 | 112 | 'dependencies' => array( |
109 | | - 'jquery.wikiEditor.highlight', |
| 113 | + 'wikiEditor', 'jquery.wikiEditor.highlight', |
110 | 114 | ), |
111 | 115 | ), |
112 | 116 | 'wikiEditor.preview' => array( |
113 | 117 | 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.preview.js', |
| 118 | + 'dependencies' => array( |
| 119 | + 'wikiEditor', 'jquery.wikiEditor.preview', |
| 120 | + ), |
114 | 121 | 'messages' => array( |
115 | 122 | 'wikieditor-preview-tab', |
116 | 123 | 'wikieditor-preview-changes-tab', |
117 | 124 | 'wikieditor-preview-loading', |
118 | 125 | ), |
119 | | - 'dependencies' => array( |
120 | | - 'jquery.wikiEditor.preview', |
121 | | - ), |
122 | 126 | ), |
123 | 127 | 'wikiEditor.previewDialog' => array( |
124 | 128 | 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.previewDialog.js', |
| 129 | + 'dependencies' => array( |
| 130 | + 'wikiEditor', 'jquery.wikiEditor.previewDialog', |
| 131 | + ), |
125 | 132 | 'messages' => array( |
126 | 133 | 'wikieditor-previewDialog-preference', |
127 | 134 | 'wikieditor-previewDialog-tab', |
128 | 135 | 'wikieditor-previewDialog-loading', |
129 | 136 | ), |
130 | | - 'dependencies' => array( |
131 | | - 'jquery.wikiEditor.preivewDialog', |
132 | | - ), |
133 | 137 | ), |
134 | 138 | 'wikiEditor.publish' => array( |
135 | 139 | 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.publish.js', |
| 140 | + 'dependencies' => array( |
| 141 | + 'wikiEditor', 'jquery.wikiEditor.publish', |
| 142 | + ), |
136 | 143 | 'messages' => array( |
137 | 144 | 'wikieditor-publish-button-publish', |
138 | 145 | 'wikieditor-publish-button-cancel', |
— | — | @@ -142,39 +149,39 @@ |
143 | 150 | 'wikieditor-publish-dialog-publish', |
144 | 151 | 'wikieditor-publish-dialog-goback', |
145 | 152 | ), |
146 | | - 'dependencies' => array( |
147 | | - 'jquery.wikiEditor.publish', |
148 | | - ), |
149 | 153 | ), |
150 | 154 | 'wikiEditor.templateEditor' => array( |
151 | 155 | 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.templateEditor.js', |
| 156 | + 'dependencies' => array( |
| 157 | + 'wikiEditor', 'jquery.wikiEditor.templateEditor', |
| 158 | + ), |
152 | 159 | 'messages' => array( |
153 | 160 | 'wikieditor-template-editor-dialog-title', |
154 | 161 | 'wikieditor-template-editor-dialog-submit', |
155 | 162 | 'wikieditor-template-editor-dialog-cancel', |
156 | 163 | ), |
157 | | - 'dependencies' => array( |
158 | | - 'jquery.wikiEditor.templateEditor', |
159 | | - ), |
160 | 164 | ), |
161 | 165 | 'wikiEditor.templates' => array( |
162 | 166 | 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.templates.js', |
163 | 167 | 'dependencies' => array( |
164 | | - 'jquery.wikiEditor.templates', |
| 168 | + 'wikiEditor', 'jquery.wikiEditor.templates', |
165 | 169 | ), |
166 | 170 | ), |
167 | 171 | 'wikiEditor.toc' => array( |
168 | 172 | 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.toc.js', |
| 173 | + 'dependencies' => array( |
| 174 | + 'wikiEditor', 'jquery.wikiEditor.toc', |
| 175 | + ), |
169 | 176 | 'messages' => array( |
170 | 177 | 'wikieditor-toc-show', |
171 | 178 | 'wikieditor-toc-hide', |
172 | 179 | ), |
173 | | - 'dependencies' => array( |
174 | | - 'jquery.wikiEditor.toc', |
175 | | - ), |
176 | 180 | ), |
177 | 181 | 'wikiEditor.toolbar' => array( |
178 | 182 | 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.toolbar.js', |
| 183 | + 'dependencies' => array( |
| 184 | + 'wikiEditor', 'jquery.wikiEditor.toolbar', 'jquery.cookie', 'jquery.async', |
| 185 | + ), |
179 | 186 | 'messages' => array( |
180 | 187 | // This is a mixed bunch that needs to be separated between dialog and toolbar messages, but since the |
181 | 188 | // dialog module depends on the toolbar module, it's not an urgent matter |
— | — | @@ -371,181 +378,227 @@ |
372 | 379 | 'wikieditor-toolbar-help-content-indent-syntax', |
373 | 380 | 'wikieditor-toolbar-help-content-indent-result', |
374 | 381 | ), |
375 | | - 'dependencies' => array( |
376 | | - 'jquery.wikiEditor.toolbar', |
377 | | - ), |
378 | 382 | ), |
379 | 383 | ); |
380 | 384 | |
381 | | - static $modules = array( |
| 385 | + static $features = array( |
| 386 | + |
| 387 | + /* Special features; not listed in $wgWikiEditorFeatures thus always enabled */ |
| 388 | + |
382 | 389 | 'global' => array( |
383 | | - 'variables' => array( |
| 390 | + 'configurations' => array( |
384 | 391 | 'wgWikiEditorIconVersion', |
385 | 392 | ), |
386 | 393 | ), |
| 394 | + |
| 395 | + /* Beta Features */ |
| 396 | + |
| 397 | + 'toolbar' => array( |
| 398 | + 'preferences' => array( |
| 399 | + // Ideally this key would be 'wikieditor-toolbar' |
| 400 | + 'usebetatoolbar' => array( |
| 401 | + 'type' => 'toggle', |
| 402 | + 'label-message' => 'wikieditor-toolbar-preference', |
| 403 | + 'section' => 'editing/beta', |
| 404 | + ), |
| 405 | + ), |
| 406 | + 'requirements' => array( |
| 407 | + 'usebetatoolbar' => true, |
| 408 | + ), |
| 409 | + 'modules' => array( |
| 410 | + 'wikiEditor.toolbar', |
| 411 | + ), |
| 412 | + ), |
| 413 | + 'dialogs' => array( |
| 414 | + 'preferences' => array( |
| 415 | + // Ideally this key would be 'wikieditor-toolbar-dialogs' |
| 416 | + 'usebetatoolbar-cgd' => array( |
| 417 | + 'type' => 'toggle', |
| 418 | + 'label-message' => 'wikieditor-toolbar-dialogs-preference', |
| 419 | + 'section' => 'editing/beta', |
| 420 | + ), |
| 421 | + ), |
| 422 | + 'requirements' => array( |
| 423 | + 'usebetatoolbar-cgd' => true, |
| 424 | + ), |
| 425 | + 'modules' => array( |
| 426 | + 'wikiEditor.dialogs', |
| 427 | + ), |
| 428 | + ), |
| 429 | + |
| 430 | + /* Labs Features */ |
| 431 | + |
387 | 432 | 'highlight' => array( |
388 | | - 'preference' => array( |
389 | | - 'key' => 'wikieditor-highlight', |
390 | | - 'ui' => array( |
| 433 | + 'preferences' => array( |
| 434 | + 'wikieditor-highlight' => array( |
391 | 435 | 'type' => 'toggle', |
392 | 436 | 'label-message' => 'wikieditor-highlight-preference', |
393 | 437 | 'section' => 'editing/labs', |
394 | 438 | ), |
395 | 439 | ), |
| 440 | + 'requirements' => array( |
| 441 | + 'wikieditor-highlight' => true, |
| 442 | + ), |
| 443 | + 'modules' => array( |
| 444 | + 'wikiEditor.highlight', |
| 445 | + ), |
396 | 446 | ), |
397 | 447 | 'templateEditor' => array( |
398 | | - 'preference' => array( |
399 | | - 'key' => 'wikieditor-template-editor', |
400 | | - 'ui' => array( |
| 448 | + 'preferences' => array( |
| 449 | + 'wikieditor-template-editor' => array( |
401 | 450 | 'type' => 'toggle', |
402 | 451 | 'label-message' => 'wikieditor-template-editor-preference', |
403 | 452 | 'section' => 'editing/labs', |
404 | 453 | ), |
405 | 454 | ), |
| 455 | + 'requirements' => array( |
| 456 | + 'wikieditor-template-editor' => true, |
| 457 | + ), |
| 458 | + 'modules' => array( |
| 459 | + 'wikiEditor.templateEditor', |
| 460 | + ), |
406 | 461 | ), |
407 | 462 | 'templates' => array( |
408 | | - 'preference' => array( |
409 | | - 'key' => 'wikieditor-templates', |
410 | | - 'ui' => array( |
| 463 | + 'preferences' => array( |
| 464 | + 'wikieditor-templates' => array( |
411 | 465 | 'type' => 'toggle', |
412 | 466 | 'label-message' => 'wikieditor-templates-preference', |
413 | 467 | 'section' => 'editing/labs', |
414 | 468 | ), |
415 | 469 | ), |
| 470 | + 'requirements' => array( |
| 471 | + 'wikieditor-templates' => true, |
| 472 | + ), |
| 473 | + 'modules' => array( |
| 474 | + 'wikiEditor.templates', |
| 475 | + ), |
416 | 476 | ), |
417 | 477 | 'addMediaWizard' => array( |
418 | | - 'preference' => array( |
419 | | - 'key' => 'addmediawizard-gadget', |
420 | | - 'ui' => array( |
| 478 | + 'preferences' => array( |
| 479 | + 'addmediawizard-gadget' => array( |
421 | 480 | 'type' => 'toggle', |
422 | 481 | 'label-message' => 'wikieditor-addMediaWizard-preference', |
423 | 482 | 'section' => 'editing/labs', |
424 | 483 | ), |
425 | 484 | ), |
| 485 | + 'requirements' => array( |
| 486 | + 'addmediawizard-gadget' => true, |
| 487 | + ), |
| 488 | + 'modules' => array( |
| 489 | + 'wikiEditor.addMediaWizard', |
| 490 | + ), |
426 | 491 | ), |
427 | 492 | 'preview' => array( |
428 | | - 'preference' => array( |
429 | | - 'key' => 'wikieditor-preview', |
430 | | - 'ui' => array( |
| 493 | + 'preferences' => array( |
| 494 | + 'wikieditor-preview' => array( |
431 | 495 | 'type' => 'toggle', |
432 | 496 | 'label-message' => 'wikieditor-preview-preference', |
433 | 497 | 'section' => 'editing/labs', |
434 | 498 | ), |
435 | 499 | ), |
436 | | - 'messages' => array( |
437 | | - 'wikieditor-preview-tab', |
438 | | - 'wikieditor-preview-changes-tab', |
439 | | - 'wikieditor-preview-loading', |
| 500 | + 'requirements' => array( |
| 501 | + 'wikieditor-preview' => true, |
440 | 502 | ), |
| 503 | + 'modules' => array( |
| 504 | + 'wikiEditor.preview', |
| 505 | + ), |
441 | 506 | ), |
442 | 507 | 'previewDialog' => array( |
443 | | - 'preference' => array( |
444 | | - 'key' => 'wikieditor-previewDialog', |
445 | | - 'ui' => array( |
| 508 | + 'preferences' => array( |
| 509 | + 'wikieditor-previewDialog' => array( |
446 | 510 | 'type' => 'toggle', |
447 | 511 | 'label-message' => 'wikieditor-previewDialog-preference', |
448 | 512 | 'section' => 'editing/labs', |
449 | 513 | ), |
450 | 514 | ), |
| 515 | + 'requirements' => array( |
| 516 | + 'wikieditor-previewDialog' => true, |
| 517 | + ), |
| 518 | + 'modules' => array( |
| 519 | + 'wikiEditor.previewDialog', |
| 520 | + ), |
451 | 521 | ), |
452 | 522 | 'publish' => array( |
453 | | - 'preference' => array( |
454 | | - 'key' => 'wikieditor-publish', |
455 | | - 'ui' => array( |
| 523 | + 'preferences' => array( |
| 524 | + 'wikieditor-publish' => array( |
456 | 525 | 'type' => 'toggle', |
457 | 526 | 'label-message' => 'wikieditor-publish-preference', |
458 | 527 | 'section' => 'editing/labs', |
459 | 528 | ), |
460 | 529 | ), |
| 530 | + 'requirements' => array( |
| 531 | + 'wikieditor-publish' => true, |
| 532 | + ), |
| 533 | + 'modules' => array( |
| 534 | + 'wikiEditor.publish', |
| 535 | + ), |
461 | 536 | ), |
462 | 537 | 'toc' => array( |
463 | | - 'preference' => array( |
| 538 | + 'preferences' => array( |
464 | 539 | // Ideally this key would be 'wikieditor-toc' |
465 | | - 'key' => 'usenavigabletoc', |
466 | | - 'ui' => array( |
| 540 | + 'usenavigabletoc' => array( |
467 | 541 | 'type' => 'toggle', |
468 | 542 | 'label-message' => 'wikieditor-toc-preference', |
469 | 543 | 'section' => 'editing/labs', |
470 | 544 | ), |
471 | 545 | ), |
472 | | - 'variables' => array( |
| 546 | + 'requirements' => array( |
| 547 | + 'usenavigabletoc' => true, |
| 548 | + ), |
| 549 | + 'modules' => array( |
| 550 | + 'wikiEditor.toc', |
| 551 | + ), |
| 552 | + 'configurations' => array( |
473 | 553 | // These are probably only for testing purposes? |
474 | 554 | 'wgNavigableTOCCollapseEnable', |
475 | 555 | 'wgNavigableTOCResizable' |
476 | 556 | ), |
477 | 557 | ), |
478 | | - 'toolbar' => array( |
479 | | - 'preference' => array( |
480 | | - // Ideally this key would be 'wikieditor-toolbar' |
481 | | - 'key' => 'usebetatoolbar', |
482 | | - 'ui' => array( |
483 | | - 'type' => 'toggle', |
484 | | - 'label-message' => 'wikieditor-toolbar-preference', |
485 | | - 'section' => 'editing/beta', |
486 | | - ), |
487 | | - ), |
488 | | - ), |
489 | | - 'dialogs' => array( |
490 | | - 'preference' => array( |
491 | | - // Ideally this key would be 'wikieditor-toolbar-dialogs' |
492 | | - 'key' => 'usebetatoolbar-cgd', |
493 | | - 'ui' => array( |
494 | | - 'type' => 'toggle', |
495 | | - 'label-message' => 'wikieditor-toolbar-dialogs-preference', |
496 | | - 'section' => 'editing/beta', |
497 | | - ), |
498 | | - ), |
499 | | - ), |
500 | 558 | ); |
501 | 559 | |
502 | 560 | /* Protected Static Methods */ |
503 | 561 | |
504 | | - protected static function isEnabled( $module ) { |
505 | | - global $wgVectorModules, $wgUser; |
| 562 | + protected static function isEnabled( $name ) { |
| 563 | + global $wgWikiEditorFeatures, $wgUser; |
506 | 564 | |
507 | | - $enabled = |
508 | | - $wgVectorModules[$module]['global'] || |
509 | | - ( |
510 | | - $wgVectorModules[$module]['user'] && |
511 | | - isset( self::$modules[$module]['preferences']['key'] ) && |
512 | | - $wgUser->getOption( self::$modules[$module]['preferences']['key'] ) |
513 | | - ); |
514 | | - if ( !$enabled ) { |
515 | | - return false; |
| 565 | + // Features not being controlled by $wgWikiEditorFeatures are always enabled, features with global set to true are |
| 566 | + // always enabled |
| 567 | + if ( !isset( $wgWikiEditorFeatures[$name] ) || $wgWikiEditorFeatures[$name]['global'] ) { |
| 568 | + return true; |
516 | 569 | } |
517 | | - if ( isset( self::$modules[$module]['preferences']['requirements'] ) ) { |
518 | | - foreach ( self::$modules[$module]['preferences']['requirements'] as $requirement => $value ) { |
519 | | - // Important! We really do want fuzzy evaluation here |
520 | | - if ( $wgUser->getOption( $requirement ) != $value ) { |
521 | | - return false; |
| 570 | + // Features with user preference control can have any number of preferences to be specific values to be enabled |
| 571 | + if ( $wgWikiEditorFeatures[$name]['user'] ) { |
| 572 | + if ( isset( self::$features[$name]['requirements'] ) ) { |
| 573 | + foreach ( self::$features[$name]['requirements'] as $requirement => $value ) { |
| 574 | + // Important! We really do want fuzzy evaluation here |
| 575 | + if ( $wgUser->getOption( $requirement ) != $value ) { |
| 576 | + return false; |
| 577 | + } |
522 | 578 | } |
523 | 579 | } |
| 580 | + return true; |
524 | 581 | } |
525 | | - return true; |
| 582 | + // Features controlled by $wgWikiEditorFeatures with both global and user set to false are awlways disabled |
| 583 | + return false; |
526 | 584 | } |
527 | 585 | |
528 | 586 | /* Static Methods */ |
529 | 587 | |
530 | 588 | /** |
531 | | - * BeforePageDisplay hook |
| 589 | + * EditPage::showEditForm:initial hook |
532 | 590 | * |
533 | 591 | * Adds the modules to the edit form |
534 | 592 | * |
535 | 593 | * @param $out OutputPage output page |
536 | 594 | * @param $skin Skin current skin |
537 | 595 | */ |
538 | | - public static function beforePageDisplay( $out, $skin ) { |
539 | | - global $wgVectorModules; |
| 596 | + public static function editPageShowEditFormInitial( &$toolbar ) { |
| 597 | + global $wgOut; |
540 | 598 | |
541 | | - // Don't load Vector modules for non-Vector skins |
542 | | - if ( !( $skin instanceof SkinVector ) ) { |
543 | | - return true; |
544 | | - } |
545 | | - |
546 | | - // Add enabled modules |
547 | | - foreach ( $wgVectorModules as $module => $enable ) { |
548 | | - if ( self::isEnabled( $module ) ) { |
549 | | - $out->addModules( self::$modules[$module]['name'] ); |
| 599 | + // Add modules for enabled features |
| 600 | + foreach ( self::$features as $name => $feature ) { |
| 601 | + if ( isset( $feature['modules'] ) && self::isEnabled( $name ) ) { |
| 602 | + $wgOut->addModules( $feature['modules'] ); |
550 | 603 | } |
551 | 604 | } |
552 | 605 | return true; |
— | — | @@ -560,12 +613,15 @@ |
561 | 614 | * @param $skin array list of default user preference controls |
562 | 615 | */ |
563 | 616 | public static function getPreferences( $user, &$defaultPreferences ) { |
564 | | - global $wgVectorModules; |
| 617 | + global $wgWikiEditorFeatures; |
565 | 618 | |
566 | | - foreach ( $wgVectorModules as $module => $enable ) { |
567 | | - if ( $enable['user'] && isset( self::$modules['preferences'][$module]['ui'] ) ) { |
568 | | - $defaultPreferences[self::$modules['preferences'][$module]['key']] = |
569 | | - self::$modules['preferences'][$module]['ui']; |
| 619 | + foreach ( self::$features as $name => $feature ) { |
| 620 | + if ( |
| 621 | + isset( $feature['preferences'] ) && |
| 622 | + ( !isset( $wgWikiEditorFeatures[$name] ) || $wgWikiEditorFeatures[$name]['user'] ) |
| 623 | + ) { |
| 624 | + foreach ( $feature['preferences'] as $key => $options ) |
| 625 | + $defaultPreferences[$key] = $options; |
570 | 626 | } |
571 | 627 | } |
572 | 628 | return true; |
— | — | @@ -577,15 +633,15 @@ |
578 | 634 | * Adds enabled/disabled switches for Vector modules |
579 | 635 | */ |
580 | 636 | public static function makeGlobalVariablesScript( &$vars ) { |
581 | | - global $wgVectorModules; |
| 637 | + global $wgWikiEditorFeatures; |
582 | 638 | |
583 | 639 | $configurations = array(); |
584 | | - foreach ( $wgVectorModules as $module => $enable ) { |
| 640 | + foreach ( self::$features as $name => $feature ) { |
585 | 641 | if ( |
586 | | - isset( self::$modules[$module]['configurations'] ) && |
587 | | - is_array( self::$modules[$module]['configurations'] ) |
| 642 | + isset( $feature['configurations'] ) && |
| 643 | + ( !isset( $wgWikiEditorFeatures[$name] ) || self::isEnabled( $name ) ) |
588 | 644 | ) { |
589 | | - foreach ( self::$modules[$module]['configurations'] as $configuration ) { |
| 645 | + foreach ( $feature['configurations'] as $configuration ) { |
590 | 646 | global $$configuration; |
591 | 647 | $configurations[$configuration] = $$configuration; |
592 | 648 | } |
— | — | @@ -603,8 +659,8 @@ |
604 | 660 | * Adds modules to ResourceLoader |
605 | 661 | */ |
606 | 662 | public static function resourceLoaderRegisterModules() { |
607 | | - foreach ( self::$modules as $module ) { |
608 | | - ResourceLoader::register( $module['name'], new ResourceLoaderFileModule( $module['resources'] ) ); |
| 663 | + foreach ( self::$modules as $name => $resources ) { |
| 664 | + ResourceLoader::register( $name, new ResourceLoaderFileModule( $resources ) ); |
609 | 665 | } |
610 | 666 | return true; |
611 | 667 | } |
Index: trunk/extensions/WikiEditor/modules/wikiEditor.toolbar.js |
— | — | @@ -6,16 +6,6 @@ |
7 | 7 | if ( !$.wikiEditor.isSupported( $.wikiEditor.modules.toolbar ) ) { |
8 | 8 | return; |
9 | 9 | } |
10 | | - // Some of the tools we're about to add depend on knowing if dialogs have been enabled or not, this little hack will |
11 | | - // add a class to the textarea that signals that they are or or not, so that the 'filters' property can be used |
12 | | - if ( mediaWiki.user.options.get( 'usebetatoolbar-cgd' ) ) { |
13 | | - if ( |
14 | | - typeof $.wikiEditor.modules.dialogs !== 'undefined' && |
15 | | - $.wikiEditor.isSupported( $.wikiEditor.modules.dialogs ) |
16 | | - ) { |
17 | | - $( '#wpTextbox1' ).addClass( 'toolbar-dialogs' ); |
18 | | - } |
19 | | - } |
20 | 10 | // The old toolbar is still in place and needs to be removed so there aren't two toolbars |
21 | 11 | $( '#toolbar' ).remove(); |
22 | 12 | // Add toolbar module |
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toc.js |
— | — | @@ -55,20 +55,18 @@ |
56 | 56 | $.wikiEditor.modules.toc.fn.update( context ); |
57 | 57 | }, |
58 | 58 | ready: function( context, event ) { |
59 | | - if ( 'module' in event && event.module === 'toc' ) { |
60 | | - // Add the TOC to the document |
61 | | - $.wikiEditor.modules.toc.fn.build( context ); |
62 | | - if ( !context.$content ) { |
63 | | - return; |
64 | | - } |
65 | | - context.$content.parent() |
66 | | - .blur( function() { |
67 | | - var context = event.data.context; |
68 | | - $.wikiEditor.modules.toc.fn.unhighlight( context ); |
69 | | - }); |
70 | | - $.wikiEditor.modules.toc.fn.improveUI(); |
71 | | - $.wikiEditor.modules.toc.evt.resize( context ); |
| 59 | + // Add the TOC to the document |
| 60 | + $.wikiEditor.modules.toc.fn.build( context ); |
| 61 | + if ( !context.$content ) { |
| 62 | + return; |
72 | 63 | } |
| 64 | + context.$content.parent() |
| 65 | + .blur( function() { |
| 66 | + var context = event.data.context; |
| 67 | + $.wikiEditor.modules.toc.fn.unhighlight( context ); |
| 68 | + }); |
| 69 | + $.wikiEditor.modules.toc.fn.improveUI(); |
| 70 | + $.wikiEditor.modules.toc.evt.resize( context ); |
73 | 71 | }, |
74 | 72 | resize: function( context, event ) { |
75 | 73 | var availableWidth = context.$wikitext.width() - parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth ), |
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.js |
— | — | @@ -133,12 +133,12 @@ |
134 | 134 | if ( property in object ) { |
135 | 135 | return object[property]; |
136 | 136 | } else if ( property + 'Msg' in object ) { |
137 | | - var p = object[property + 'Msg' ]; |
138 | | - if ( typeof p == 'object' && typeof p.length !== undefined && p.length >= 2) { |
| 137 | + var p = object[property + 'Msg']; |
| 138 | + if ( p instanceof Array && p.length >= 2 ) { |
139 | 139 | // [ messageKey, { 'parameters': ['arg1, arg2, ...] } ] |
140 | 140 | return mediaWiki.msg.get( object[property + 'Msg' ][0], object[property + 'Msg' ][1] ); |
141 | 141 | } else { |
142 | | - return mediaWiki.msg.get( object[property + 'Msg'] ); |
| 142 | + return mediaWiki.msg.get( p ); |
143 | 143 | } |
144 | 144 | } else { |
145 | 145 | return ''; |
— | — | @@ -170,7 +170,7 @@ |
171 | 171 | if ( src.substr( 0, 7 ) != 'http://' && src.substr( 0, 8 ) != 'https://' && src[0] != '/' ) { |
172 | 172 | src = path + src; |
173 | 173 | } |
174 | | - return src + '?' + wikiEditor.config.get( 'wgWikiEditorIconVersion' ); |
| 174 | + return src + '?' + mediaWiki.config.get( 'wgWikiEditorIconVersion' ); |
175 | 175 | }, |
176 | 176 | /** |
177 | 177 | * Get the sprite offset for a language if available, icon for a language if available, or the default offset or icon, |
— | — | @@ -281,8 +281,6 @@ |
282 | 282 | context.modules[module] = {}; |
283 | 283 | // Tell the module to create itself on the context |
284 | 284 | $.wikiEditor.modules[module].fn.create( context, modules[module] ); |
285 | | - // This is triggered each time a module is ready, the event will contain a module property |
286 | | - context.fn.trigger( 'ready', { 'module': module } ); |
287 | 285 | } |
288 | 286 | } |
289 | 287 | } |
Index: trunk/extensions/WikiEditor/modules/wikiEditor.dialogs.js |
— | — | @@ -6,6 +6,16 @@ |
7 | 7 | if ( !$.wikiEditor.isSupported( $.wikiEditor.modules.dialogs ) ) { |
8 | 8 | return; |
9 | 9 | } |
| 10 | + // Some toolbar tools depend on knowing if dialogs have been enabled or not. By adding a class to the textarea, we |
| 11 | + // provide a way that the the 'filters' property can be used. |
| 12 | + if ( mediaWiki.user.options.get( 'usebetatoolbar-cgd' ) ) { |
| 13 | + if ( |
| 14 | + typeof $.wikiEditor.modules.dialogs !== 'undefined' && |
| 15 | + $.wikiEditor.isSupported( $.wikiEditor.modules.dialogs ) |
| 16 | + ) { |
| 17 | + $( '#wpTextbox1' ).addClass( 'toolbar-dialogs' ); |
| 18 | + } |
| 19 | + } |
10 | 20 | // Add dialogs module |
11 | 21 | $( '#wpTextbox1' ).wikiEditor( 'addModule', { 'dialogs': { |
12 | 22 | 'insert-link': { |
Index: trunk/extensions/WikiEditor/modules/wikiEditor.toc.js |
— | — | @@ -4,5 +4,8 @@ |
5 | 5 | |
6 | 6 | $( document ).ready( function() { |
7 | 7 | // Add table of contents module |
8 | | - $( '#wpTextbox1' ).wikiEditor( 'addModule', 'toc' ) |
9 | | -}); |
| 8 | + $( '#wpTextbox1' ) |
| 9 | + .wikiEditor( 'addModule', 'toc' ) |
| 10 | + // FIXME - should move the ready handler code to the create function so this isn't necissary |
| 11 | + .data( 'wikiEditor-context' ).fn.trigger( 'ready' ); |
| 12 | +} ); |
Index: trunk/extensions/WikiEditor/WikiEditor.i18n.php |
— | — | @@ -12,6 +12,10 @@ |
13 | 13 | * @author Trevor Parscal |
14 | 14 | */ |
15 | 15 | $messages['en'] = array( |
| 16 | + /* Editing Preference Categories */ |
| 17 | + 'prefs-beta' => 'Beta features', |
| 18 | + 'prefs-labs' => 'Labs features', |
| 19 | + /* WikiEditor */ |
16 | 20 | 'wikieditor' => 'Advanced wikitext editing interface', |
17 | 21 | 'wikieditor-desc' => 'Provides an extendable wikitext editing interface and many feature-providing modules', |
18 | 22 | 'wikieditor-wikitext-tab' => 'Wikitext', |