Index: branches/wmf/1.16wmf4/extensions/VariablePage/VariablePage.body.php |
— | — | @@ -13,24 +13,24 @@ |
14 | 14 | |
15 | 15 | public function execute() { |
16 | 16 | global $wgOut, $wgRequest; |
17 | | - global $wgVariablePagePossibilities, $wgVariablePageUtmMedium; |
| 17 | + global $wgVariablePagePossibilities; |
18 | 18 | |
19 | 19 | $lang = ( preg_match( '/^[A-Za-z-]+$/', $wgRequest->getVal( 'lang' ) ) ) ? $wgRequest->getVal( 'lang' ) : 'en' ; |
20 | 20 | $utm_source = $wgRequest->getVal( 'utm_source' ); |
21 | | - $utm_medium = ( strlen($wgVariablePageUtmMedium )) ? $wgVariablePageUtmMedium : $wgRequest->getVal( 'utm_medium' ); |
| 21 | + $utm_medium = $wgRequest->getVal( 'utm_medium' ); |
22 | 22 | $utm_campaign = $wgRequest->getVal( 'utm_campaign' ); |
23 | | - $referrer = $wgRequest->getHeader( 'referrer' ); |
| 23 | + $referrer = ( $wgRequest->getVal( 'referrer' )) ? $wgRequest->getVal( 'referrer' ) : $wgRequest->getHeader( 'referer' ); |
24 | 24 | |
25 | 25 | $query = array(); |
26 | 26 | if ( strlen( $lang ) ) $query[ 'language' ] = $lang; |
27 | | - if ( strlen( $utm_source )) $query[ 'utm_source' ] = $utm_source; |
28 | | - if ( strlen( $utm_medium )) $query[ 'utm_medium' ] = $utm_medium; |
29 | | - if ( strlen( $utm_campaign )) $query[ 'utm_campaign' ] = $utm_campaign; |
30 | | - if ( strlen( $referrer )) $query[ 'referrer' ] = $referrer; |
| 27 | + if ( strlen( $utm_source ) ) $query[ 'utm_source' ] = $utm_source; |
| 28 | + if ( strlen( $utm_medium ) ) $query[ 'utm_medium' ] = $utm_medium; |
| 29 | + if ( strlen( $utm_campaign ) ) $query[ 'utm_campaign' ] = $utm_campaign; |
| 30 | + if ( strlen( $referrer ) ) $query[ 'referrer' ] = $referrer; |
31 | 31 | |
32 | 32 | // determine the URL to which we will redirect the user |
33 | 33 | $url = $this->determinePage( $wgVariablePagePossibilities ); |
34 | | - $wgOut->redirect( wfAppendQuery( $url, $query )); |
| 34 | + $wgOut->redirect( wfAppendQuery( $url, $query ) ); |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
— | — | @@ -80,10 +80,10 @@ |
81 | 81 | $total_probability += $probability; |
82 | 82 | } |
83 | 83 | |
84 | | - if ( $total_probability != 100 && !strlen( $wgVariablePageDefault )) { |
85 | | - return FALSE; |
| 84 | + if ( $total_probability != 100 && !strlen( $wgVariablePageDefault ) ) { |
| 85 | + return false; |
86 | 86 | } else { |
87 | | - return TRUE; |
| 87 | + return true; |
88 | 88 | } |
89 | 89 | } |
90 | 90 | } |
Index: branches/wmf/1.16wmf4/extensions/VariablePage/VariablePage.i18n.php |
— | — | @@ -13,8 +13,9 @@ |
14 | 14 | * @author Arthur Richards |
15 | 15 | */ |
16 | 16 | $messages['en'] = array( |
| 17 | + 'variablepage' => 'VariablePage', |
| 18 | + 'variablepage-navlink_text' => 'Donate', |
17 | 19 | 'variablepage-desc' => 'Lightweight variable page redirection', |
18 | | - 'variablepage-randomurl' => 'Special:VariablePage', |
19 | 20 | ); |
20 | 21 | |
21 | 22 | /** Bosnian (Bosanski) |
— | — | @@ -31,6 +32,13 @@ |
32 | 33 | 'variablepage-desc' => 'Ermöglicht ressourcenschonende variable Weiterleitungen von Wikiseiten', |
33 | 34 | ); |
34 | 35 | |
| 36 | +/** French (Français) |
| 37 | + * @author Peter17 |
| 38 | + */ |
| 39 | +$messages['fr'] = array( |
| 40 | + 'variablepage-desc' => 'Redirection de page légère et variable', |
| 41 | +); |
| 42 | + |
35 | 43 | /** Galician (Galego) |
36 | 44 | * @author Toliño |
37 | 45 | */ |
— | — | @@ -38,6 +46,13 @@ |
39 | 47 | 'variablepage-desc' => 'Redirección lixeira de páxina variable', |
40 | 48 | ); |
41 | 49 | |
| 50 | +/** Swiss German (Alemannisch) |
| 51 | + * @author Als-Holder |
| 52 | + */ |
| 53 | +$messages['gsw'] = array( |
| 54 | + 'variablepage-desc' => 'Lychti variabli Wyterleitige', |
| 55 | +); |
| 56 | + |
42 | 57 | /** Interlingua (Interlingua) |
43 | 58 | * @author McDutchie |
44 | 59 | */ |
— | — | @@ -45,6 +60,20 @@ |
46 | 61 | 'variablepage-desc' => 'Redirection variabile de paginas sin consumption excessive de ressources', |
47 | 62 | ); |
48 | 63 | |
| 64 | +/** Japanese (日本語) |
| 65 | + * @author 青子守歌 |
| 66 | + */ |
| 67 | +$messages['ja'] = array( |
| 68 | + 'variablepage-desc' => '軽い可変ページのリダイレクト', |
| 69 | +); |
| 70 | + |
| 71 | +/** Colognian (Ripoarisch) |
| 72 | + * @author Purodha |
| 73 | + */ |
| 74 | +$messages['ksh'] = array( |
| 75 | + 'variablepage-desc' => 'Ein eijfache Ömleidung op ongerscheidlijje Sigge.', |
| 76 | +); |
| 77 | + |
49 | 78 | /** Luxembourgish (Lëtzebuergesch) |
50 | 79 | * @author Robby |
51 | 80 | */ |
— | — | @@ -66,6 +95,13 @@ |
67 | 96 | 'variablepage-desc' => "Lichtgewicht variabele doorverwijzing voor pagina's", |
68 | 97 | ); |
69 | 98 | |
| 99 | +/** Polish (Polski) |
| 100 | + * @author Sp5uhe |
| 101 | + */ |
| 102 | +$messages['pl'] = array( |
| 103 | + 'variablepage-desc' => 'Prosta strona przekierowująca losowo', |
| 104 | +); |
| 105 | + |
70 | 106 | /** Piedmontese (Piemontèis) |
71 | 107 | * @author Dragonòt |
72 | 108 | */ |
— | — | @@ -94,3 +130,10 @@ |
95 | 131 | 'variablepage-desc' => 'Простое перенаправление на различные страницы', |
96 | 132 | ); |
97 | 133 | |
| 134 | +/** Tagalog (Tagalog) |
| 135 | + * @author AnakngAraw |
| 136 | + */ |
| 137 | +$messages['tl'] = array( |
| 138 | + 'variablepage-desc' => 'Magaang na pabagubaong muling pagiiba ng pupuntahan ng pahina', |
| 139 | +); |
| 140 | + |
Index: branches/wmf/1.16wmf4/extensions/VariablePage/VariablePage.php |
— | — | @@ -34,29 +34,58 @@ |
35 | 35 | * 'http://foo.com/bar' => 90, |
36 | 36 | * ); |
37 | 37 | */ |
38 | | -$wgVariablePagePossibilities = array( |
39 | | - 'http://wikimediafoundation.org/wiki/Support_Wikipedia' => 100 |
40 | | -); |
| 38 | +$wgVariablePagePossibilities = array(); |
41 | 39 | |
42 | 40 | /** |
43 | | - * You may set a custom utm_medium to be used for pages reached via VariablePage |
44 | | - * |
45 | | - * This can be set to whatever string you wish to use for utm_medium |
46 | | - */ |
47 | | -$wgVariablePageUtmMedium = ''; |
48 | | - |
49 | | -/** |
50 | 41 | * The default URL to send a user to in the event that one of the URLs in |
51 | 42 | * $wgVariablePagePossibilities not selected. |
52 | 43 | * |
53 | 44 | * Either this must be set or the probabilities in $wgVariablePagePossibiliites |
54 | 45 | * must add up to 100. |
55 | 46 | */ |
56 | | -$wgVariablePageDefault = ''; |
| 47 | +$wgVariablePageDefault = 'http://wikimediafoundation.org/wiki/Support_Wikipedia'; |
57 | 48 | |
| 49 | +/** |
| 50 | + * If this is set to TRUE, a sidebar nav link to Special:VariablePage will be displayed |
| 51 | + */ |
| 52 | +$wgVariablePageShowSidebarLink = false; |
| 53 | + |
| 54 | +/** |
| 55 | + * If you need to add a query to the sidebar nav link, set them with this. |
| 56 | + * |
| 57 | + * array( $key => $value ) will become ?key=value |
| 58 | + */ |
| 59 | +$wgVariablePageSidebarLinkQuery = array(); |
| 60 | + |
| 61 | +/** |
| 62 | + * Edit the sidebar navigation |
| 63 | + */ |
| 64 | +$wgHooks['SkinBuildSidebar'][] = 'efVariablePageSidebarLink'; |
| 65 | + |
58 | 66 | $dir = dirname( __FILE__ ) . '/'; |
59 | 67 | |
60 | 68 | $wgAutoloadClasses[ 'SpecialVariablePage' ] = $dir . 'VariablePage.body.php'; |
61 | 69 | $wgExtensionMessagesFiles[ 'VariablePage' ] = $dir . 'VariablePage.i18n.php'; |
62 | 70 | $wgSpecialPages[ 'VariablePage' ] = 'SpecialVariablePage'; |
63 | 71 | $wgSpecialPageGroups[ 'VariablePage' ] = 'contribution'; |
| 72 | + |
| 73 | +/** |
| 74 | + * Place a link to Special:VariablePage in the navigation sidebar |
| 75 | + * @return bool |
| 76 | + */ |
| 77 | +function efVariablePageSidebarLink( $skin, &$bar ) { |
| 78 | + global $wgVariablePageShowSidebarLink, $wgVariablePageSidebarLinkQuery; |
| 79 | + |
| 80 | + // make sure that we should be showing a sidebar link |
| 81 | + if ( $wgVariablePageShowSidebarLink ) { |
| 82 | + $url = Title::makeTitle( NS_SPECIAL, wfMsg( 'variablepage' ) )->getLocalUrl(); |
| 83 | + $bar['navigation'][] = array( |
| 84 | + 'text' => wfMsg( 'variablepage-navlink_text' ), |
| 85 | + 'href' => wfAppendQuery( $url, $wgVariablePageSidebarLinkQuery ), |
| 86 | + 'id' => 'n-variablepage', |
| 87 | + 'active' => true, |
| 88 | + ); |
| 89 | + } |
| 90 | + |
| 91 | + return true; |
| 92 | +} |
Property changes on: branches/wmf/1.16wmf4/extensions/VariablePage |
___________________________________________________________________ |
Modified: svn:mergeinfo |
64 | 93 | Merged /trunk/extensions/VariablePage:r73150-73620 |