Index: trunk/extensions/ArticleCreationWorkflow/includes/ArticleCreationTemplates.php |
— | — | @@ -18,13 +18,14 @@ |
19 | 19 | |
20 | 20 | $html = ''; |
21 | 21 | $buttons = array(); |
22 | | - if ( ! $title->userCan('create') || ! $title->userCan('edit') ) { |
| 22 | + $variant = self::getLandingVariant( $title ); |
| 23 | + |
| 24 | + if ( $variant == 'anonymous' ) { |
23 | 25 | $html .= wfMessage( 'ac-landing-login-required' )->parse(); |
24 | | - $buttons = $wgArticleCreationButtons['anonymous']; |
25 | | - } else { |
26 | | - $buttons = $wgArticleCreationButtons['logged-in']; |
27 | 26 | } |
28 | 27 | |
| 28 | + $buttons = $wgArticleCreationButtons[$variant]; |
| 29 | + |
29 | 30 | $buttons = self::formatButtons( $buttons, $page ); |
30 | 31 | |
31 | 32 | $html .= <<<HTML |
— | — | @@ -38,6 +39,33 @@ |
39 | 40 | } |
40 | 41 | |
41 | 42 | /** |
| 43 | + * Decides which ArticleCreationLanding page to show. |
| 44 | + * |
| 45 | + * @return String key for $wgArticleCreationButtons |
| 46 | + */ |
| 47 | + public static function getLandingVariant( $title = null ) { |
| 48 | + global $wgUser; |
| 49 | + |
| 50 | + if ( $title && $title->isSpecial('ArticleCreationLanding') ) { |
| 51 | + list($specialTitle, $par) = SpecialPageFactory::resolveAlias( $title ); |
| 52 | + $title = Title::newFromText($par); |
| 53 | + } |
| 54 | + |
| 55 | + if ( !$title ) { |
| 56 | + $title = Title::newFromText( '!ACW permissions test!' ); |
| 57 | + } |
| 58 | + |
| 59 | + if ( |
| 60 | + $wgUser->isAnon() && |
| 61 | + (! $title->userCan('create') || ! $title->userCan('edit') ) |
| 62 | + ) { |
| 63 | + return 'anonymous'; |
| 64 | + } else { |
| 65 | + return 'logged-in'; |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + /** |
42 | 70 | * Formats a set of buttons from an array. |
43 | 71 | * @param $description Associative array. Keys are button names, |
44 | 72 | * Values are associative arrays suitable to pass to formatButton |
— | — | @@ -113,7 +141,7 @@ |
114 | 142 | |
115 | 143 | if ( ! empty($info['interstitial'] ) ) { |
116 | 144 | $content = $info['interstitial']; |
117 | | - $tips .= self::formatInterstitial( $content ); |
| 145 | + $tips .= self::formatInterstitial( ); |
118 | 146 | } |
119 | 147 | |
120 | 148 | // Get the action URL |
— | — | @@ -135,8 +163,8 @@ |
136 | 164 | data-ac-color="$color" href="$target"> |
137 | 165 | <div class="ac-arrow ac-arrow-forward"> </div> |
138 | 166 | <div class="ac-button-text"> |
139 | | - <div class="ac-button-title">$buttonTitle</div> |
140 | | - <div class="ac-button-body">$buttonText</div> |
| 167 | + <span class="ac-button-title">$buttonTitle</span><br/> |
| 168 | + <span class="ac-button-body">$buttonText</span> |
141 | 169 | </div> |
142 | 170 | </a> |
143 | 171 | $tips |
— | — | @@ -176,19 +204,15 @@ |
177 | 205 | |
178 | 206 | /** |
179 | 207 | * Formats an interstitial tooltip shown when certain buttons are clicked. |
180 | | - * @param $content String HTML content, to be passed through jQuery.localize() on the client side. |
| 208 | + * Returns an empty shell which is filled in JS for IE<9 support. |
| 209 | + * |
181 | 210 | * @return String HTML |
182 | 211 | */ |
183 | | - public static function formatInterstitial( $content ) { |
184 | | - if ( ! $content ) { |
185 | | - return ''; |
186 | | - } |
187 | | - |
| 212 | + public static function formatInterstitial( ) { |
188 | 213 | return <<<HTML |
189 | 214 | <div class="mw-ac-tip mw-ac-interstitial" style="display: none;"> |
190 | 215 | <div class="mw-ac-tooltip-pointy"></div> |
191 | 216 | <div class="mw-ac-tooltip-innards"> |
192 | | - $content |
193 | 217 | </div> |
194 | 218 | </div> |
195 | 219 | HTML; |
Index: trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.user/ext.articleCreation.user.js |
— | — | @@ -121,7 +121,20 @@ |
122 | 122 | |
123 | 123 | setupTooltips: function ( ) { |
124 | 124 | |
125 | | - ac.panel.find('.mw-ac-tip').localize(); |
| 125 | + ac.panel.find('.mw-ac-interstitial') |
| 126 | + .each( function() { |
| 127 | + var button = $(this) |
| 128 | + .parent() |
| 129 | + .find('.ac-article-button') |
| 130 | + .data('ac-button'); |
| 131 | + |
| 132 | + var $content = $( ac.config.buttons[ac.config.variant][button].interstitial ); |
| 133 | + |
| 134 | + $content.localize(); |
| 135 | + |
| 136 | + $(this).find('.mw-ac-tooltip-innards') |
| 137 | + .append($content); |
| 138 | + } ); |
126 | 139 | |
127 | 140 | ac.panel.find('.mw-ac-interstitial') |
128 | 141 | .find('.ac-action-button') |
— | — | @@ -138,8 +151,8 @@ |
139 | 152 | .css('top', (( $tooltip.height() / 2) -10) + 'px' ) |
140 | 153 | .end(); |
141 | 154 | //set the tooltip position |
142 | | - var newPosition = ($button.height() / 2) - |
143 | | - ($tooltip.height() / 2 ) + 10; |
| 155 | + var newPosition = ($tooltip.height() / 2 ) - |
| 156 | + ($button.height() / 2) - 10; |
144 | 157 | $tooltip.css('top', newPosition+'px'); |
145 | 158 | }, |
146 | 159 | |
Index: trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.core/ext.articleCreation.core.css |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | } |
41 | 41 | |
42 | 42 | .ac-button-wrap { |
43 | | - position: relative; |
| 43 | + /*position: relative;*/ |
44 | 44 | } |
45 | 45 | |
46 | 46 | .ac-button-title, .ac-button-body { |
Index: trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.php |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | $wgHooks['ArticleSaveComplete'][] = 'ArticleCreationHooks::trackEditSuccess'; |
35 | 35 | $wgHooks['EditPage::attemptSave'][] = 'ArticleCreationHooks::trackEditAttempt'; |
36 | 36 | |
37 | | -$wgHooks['ResourceLoaderGetConfigVars'][] = 'ArticleCreationHooks::resourceLoaderGetConfigVars'; |
| 37 | +$wgHooks['MakeGlobalVariablesScript'][] = 'ArticleCreationHooks::getGlobalVariables'; |
38 | 38 | |
39 | 39 | /* Internationalization */ |
40 | 40 | $wgExtensionMessagesFiles['ArticleCreation'] = $articleCreationDir . 'ArticleCreationWorkflow.i18n.php'; |
Index: trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.hooks.php |
— | — | @@ -61,15 +61,20 @@ |
62 | 62 | return true; |
63 | 63 | } |
64 | 64 | |
65 | | - public static function resourceLoaderGetConfigVars( &$vars ) { |
66 | | - global $wgArticleCreationConfig, $wgUser; |
67 | | - |
| 65 | + public static function getGlobalVariables( &$vars ) { |
| 66 | + global $wgArticleCreationConfig, $wgUser, $wgArticleCreationButtons, $wgTitle; |
| 67 | + |
| 68 | + if ( ! $wgTitle->isSpecial( 'ArticleCreationLanding' ) ) { |
| 69 | + return true; |
| 70 | + } |
| 71 | + |
68 | 72 | $vars['acConfig'] = $wgArticleCreationConfig + |
69 | | - array( |
70 | | - 'enabled' => ArticleCreationUtil::isEnabled(), |
71 | | - 'tracking-turned-on' => ArticleCreationUtil::trackingEnabled(), |
72 | | - 'tracking-code-prefix' => ArticleCreationUtil::trackingCodePrefix(), |
73 | | - ); |
| 73 | + array( |
| 74 | + 'enabled' => ArticleCreationUtil::isEnabled(), |
| 75 | + 'tracking-turned-on' => ArticleCreationUtil::trackingEnabled(), |
| 76 | + 'tracking-code-prefix' => ArticleCreationUtil::trackingCodePrefix(), |
| 77 | + 'variant' => ArticleCreationTemplates::getLandingVariant( $wgTitle ), |
| 78 | + ); |
74 | 79 | |
75 | 80 | return true; |
76 | 81 | } |