Index: trunk/extensions/CongressLookup/SpecialCongressLookup.php |
— | — | @@ -55,54 +55,6 @@ |
56 | 56 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
57 | 57 | <meta http-equiv="Content-Style-Type" content="text/css" /> |
58 | 58 | <meta name="generator" content="MediaWiki 1.18wmf1" /> |
59 | | -<script src="//geoiplookup.wikimedia.org/" type="text/javascript"></script> |
60 | | -HTML; |
61 | | - $htmlOut .= '<script type="text/javascript" src="' . $wgScriptPath . '/load.php?lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20111213T185322Z"> </script>'; |
62 | | - $htmlOut .= <<<HTML |
63 | | -<script type="text/javascript"> |
64 | | - |
65 | | -$(document).ready(function() { |
66 | | - |
67 | | - var geoHasUsRep = [ |
68 | | - 'US', // USA |
69 | | - 'PR', // Puerto Rico |
70 | | - 'VI', // Virgin Islands |
71 | | - 'MP', // Northern Mariana Islands |
72 | | - 'AS', // American Samoa |
73 | | - 'GU' // Guam |
74 | | - ]; |
75 | | - |
76 | | - // Fake country from get param |
77 | | - // Parse out GET params from the URL |
78 | | - var urlParams = {}; |
79 | | - (function () { |
80 | | - var e, |
81 | | - a = /\+/g, |
82 | | - r = /([^&=]+)=?([^&]*)/g, |
83 | | - d = function (s) { return decodeURIComponent(s.replace(a, " ")); }, |
84 | | - q = window.location.search.substring(1); |
85 | | - |
86 | | - while (e = r.exec(q)) { |
87 | | - urlParams[d(e[1])] = d(e[2]); |
88 | | - } |
89 | | - })(); |
90 | | - |
91 | | - // Defaults to the US, so if we can't determine location, show form |
92 | | - var country = 'US'; |
93 | | - if ( urlParams.country ) { |
94 | | - country = urlParams.country; |
95 | | - } else if ( window.Geo && window.Geo.country ) { |
96 | | - country = window.Geo.country; |
97 | | - } |
98 | | - |
99 | | - var hasUsRep = ( $.inArray( country, geoHasUsRep ) === 0 ); |
100 | | - if( !hasUsRep ) { |
101 | | - $("#sopaShareOptions").show(); |
102 | | - $("#sopaZipForm").hide(); |
103 | | - } |
104 | | - |
105 | | -}); |
106 | | -</script> |
107 | 59 | <style type="text/css"> |
108 | 60 | body { |
109 | 61 | color: #dedede; |
— | — | @@ -204,9 +156,6 @@ |
205 | 157 | .sopaActionHead { |
206 | 158 | font-weight: bold |
207 | 159 | } |
208 | | -#sopaShareOptions { |
209 | | - display: none; |
210 | | -} |
211 | 160 | </style> |
212 | 161 | </head> |
213 | 162 | <body> |
— | — | @@ -242,7 +191,6 @@ |
243 | 192 | $htmlOut .= $this->getCongressTables(); |
244 | 193 | } else { |
245 | 194 | $htmlOut .= $this->getZipForm(); |
246 | | - $htmlOut .= $this->getSocialMedia(); |
247 | 195 | } |
248 | 196 | |
249 | 197 | // Output end of the page |
— | — | @@ -307,6 +255,8 @@ |
308 | 256 | ) |
309 | 257 | ); |
310 | 258 | |
| 259 | + $congressTable .= Html::rawElement( 'tr', array(), |
| 260 | + Html::rawElement( 'td', array(), $this->getSocialMedia( $myRepresentative ) ) ); |
311 | 261 | $congressTable .= "\n" . Html::closeElement( 'table' ); |
312 | 262 | } |
313 | 263 | if ( count( $myRepresentatives ) > 1 ) { |
— | — | @@ -351,6 +301,8 @@ |
352 | 302 | ) |
353 | 303 | ); |
354 | 304 | |
| 305 | + $congressTable .= Html::rawElement( 'tr', array(), |
| 306 | + Html::rawElement( 'td', array(), $this->getSocialMedia( $senator ) ) ); |
355 | 307 | $congressTable .= "\n" . Html::closeElement( 'table' ); |
356 | 308 | } |
357 | 309 | if ( count( $mySenators ) == 0 ) { |
— | — | @@ -392,62 +344,82 @@ |
393 | 345 | * Get HTML for social media links |
394 | 346 | * @return string HTML for social media links |
395 | 347 | */ |
396 | | - private function getSocialMedia() { |
| 348 | + private function getSocialMedia( $senator ) { |
397 | 349 | // Update links here. Currently pointing to example.com |
398 | | - $htmlOut = <<<HTML |
399 | | -<div id="sopaShareOptions" class="sopaActionDiv"> |
400 | | -<p class="sopaActionHead">Make your voice heard</p> |
401 | | - <div> |
402 | | - <div class="sopaSocial"> |
403 | | - <a style="text-decoration: none;" |
404 | | - href="https://www.facebook.com/sharer.php?u=http://tinyurl.com/7vq4o8g" |
405 | | - target="wpblackout_Facebook_share"><img width="33" |
406 | | - height="33" |
407 | | - src= |
408 | | - "//upload.wikimedia.org/wikipedia/commons/2/2a/WP_SOPA_sm_icon_facebook_dedede.png"></a><br> |
| 350 | + $shareOptions = array( |
| 351 | + array( |
| 352 | + "url" => "https://www.facebook.com/sharer.php?u=http://tinyurl.com/7vq4o8g&t=$1", |
| 353 | + "img" => "//upload.wikimedia.org/wikipedia/commons/2/2a/WP_SOPA_sm_icon_facebook_dedede.png", |
| 354 | + "name" => "Facebook" |
| 355 | + ), |
| 356 | + array( |
| 357 | + "url" => "https://m.google.com/app/plus/x/?v=compose&content=$1", |
| 358 | + "img" => "//upload.wikimedia.org/wikipedia/commons/0/08/WP_SOPA_sm_icon_gplus_dedede.png", |
| 359 | + "name" => "Google+" |
| 360 | + ), |
| 361 | + array( |
| 362 | + "url" => "https://twitter.com/intent/tweet?text=$1", |
| 363 | + "img" => "//upload.wikimedia.org/wikipedia/commons/4/45/WP_SOPA_sm_icon_twitter_dedede.png", |
| 364 | + "name" => "Twitter" |
| 365 | + ) |
| 366 | + ); |
409 | 367 | |
410 | | - <a style="text-decoration: none; color: rgb(222, 222, 222);" |
411 | | - href="https://www.facebook.com/sharer.php?u=http://tinyurl.com/7vq4o8g" |
412 | | - target="wpblackout_Facebook_share">Facebook</a> |
413 | | - </div> |
| 368 | + $htmlShare = ''; |
| 369 | + foreach( $shareOptions as $option ) { |
| 370 | + $htmlShare .= Html::rawElement( 'div', |
| 371 | + array( |
| 372 | + 'class' => 'sopaSocial' |
| 373 | + ), |
| 374 | + Html::rawElement( 'a', |
| 375 | + array( |
| 376 | + 'href' => str_replace( '$1', $this->formatDoneText( $senator ), $option['url'] ), |
| 377 | + 'style' => 'text-decoration: none' |
| 378 | + ), |
| 379 | + Html::rawElement( 'img', |
| 380 | + array( |
| 381 | + 'src' => $option['img'], |
| 382 | + 'height' => '33', |
| 383 | + 'width' => '33' |
| 384 | + ), |
| 385 | + '' |
| 386 | + ) |
| 387 | + ) . |
| 388 | + Html::rawElement( 'br' ) . |
| 389 | + Html::rawElement( 'a', |
| 390 | + array( |
| 391 | + 'href' => $option['url'], |
| 392 | + 'style' => 'text-decoration: none' |
| 393 | + ), |
| 394 | + $option['name'] |
| 395 | + ) |
| 396 | + ); |
| 397 | + } |
| 398 | + $htmlOut = Html::rawElement( 'div', |
| 399 | + array( |
| 400 | + 'id' => 'sopaShareOptions', |
| 401 | + 'class' => 'sopaActionDiv' |
| 402 | + ), |
| 403 | + Html::rawElement( 'p', |
| 404 | + array(), 'Done? Tell the world!' |
| 405 | + ) . |
| 406 | + Html::rawElement( 'div', |
| 407 | + array(), |
| 408 | + $htmlShare) . |
| 409 | + Html::rawElement( 'div', |
| 410 | + array( |
| 411 | + 'style' => 'clear: both;' |
| 412 | + ), '' |
| 413 | + ) . |
| 414 | + Html::rawElement( 'hr' ) |
| 415 | + ); |
414 | 416 | |
415 | | - <div class="sopaSocial"> |
416 | | - <a style="text-decoration: none;" |
417 | | - href= |
418 | | - "https://m.google.com/app/plus/x/?v=compose&content=I%20support%20the%20January%2018th%20Wikipedia%20blackout%20to%20protest%20SOPA%20and%20PIPA.%20Show%20your%20support%20here%20%20http%3A%2F%2Ftinyurl.com%2F7vq4o8g"> |
419 | | - <img width="33" |
420 | | - height="33" |
421 | | - src= |
422 | | - "//upload.wikimedia.org/wikipedia/commons/0/08/WP_SOPA_sm_icon_gplus_dedede.png"></a><br> |
423 | | - |
424 | | - <a style="text-decoration: none;" |
425 | | - href= |
426 | | - "https://m.google.com/app/plus/x/?v=compose&content=I%20support%20the%20January%2018th%20Wikipedia%20blackout%20to%20protest%20SOPA%20and%20PIPA.%20Show%20your%20support%20here%20%20http%3A%2F%2Ftinyurl.com%2F7vq4o8g"> |
427 | | - Google+</a> |
428 | | - </div> |
429 | | - |
430 | | - <div class="sopaSocial"> |
431 | | - <a style="text-decoration: none;" |
432 | | - href= |
433 | | - "https://twitter.com/intent/tweet?text=I%20support%20%23wikipediablackout!%20Show%20your%20support%20here%20http%3A%2F%2Ftinyurl.com%2F7vq4o8g" |
434 | | - target="wpblackout_Twitter_share"><img width="33" |
435 | | - height="33" |
436 | | - src= |
437 | | - "//upload.wikimedia.org/wikipedia/commons/4/45/WP_SOPA_sm_icon_twitter_dedede.png"></a><br> |
438 | | - |
439 | | - <a style="text-decoration: none; color: rgb(222, 222, 222);" |
440 | | - href= |
441 | | - "https://twitter.com/intent/tweet?text=I%20support%20%23wikipediablackout!%20Show%20your%20support%20here%20http%3A%2F%2Ftinyurl.com%2F7vq4o8g" |
442 | | - target="wpblackout_Twitter_share">Twitter</a> |
443 | | - </div> |
444 | | - </div> |
445 | | - |
446 | | - <div style="clear: both;"></div> |
447 | | -</div> |
448 | | -HTML; |
449 | 417 | return $htmlOut; |
450 | 418 | } |
451 | 419 | |
| 420 | + private function formatDoneText( $rep ) { |
| 421 | + $name = trim( preg_replace( '/\[.*\]/', '', $rep['name'] ) ); |
| 422 | + return urlencode( "I just contacted $name to oppose #SOPA/#PIPA - Join me! http://tinyurl.com/7vq4o8g #wikipediablackout" ); |
| 423 | + } |
452 | 424 | /** |
453 | 425 | * Setter for $this->zip |
454 | 426 | * |