| Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/MobileFrontend.php |
| — | — | @@ -139,20 +139,18 @@ |
| 140 | 140 | |
| 141 | 141 | public function addMobileFooter( &$obj, &$tpl ) { |
| 142 | 142 | global $wgRequest; |
| 143 | | - wfProfileIn( __METHOD__ ); |
| 144 | 143 | $footerlinks = $tpl->data['footerlinks']; |
| 145 | 144 | $mobileViewUrl = $wgRequest->escapeAppendQuery( 'useformat=mobile' ); |
| 146 | 145 | |
| 147 | 146 | $tpl->set('mobileview', "<a href='{$mobileViewUrl}'>".wfMsg( 'mobile-frontend-view')."</a>"); |
| 148 | 147 | $footerlinks['places'][] = 'mobileview'; |
| 149 | 148 | $tpl->set('footerlinks', $footerlinks); |
| 150 | | - wfProfileOut( __METHOD__ ); |
| | 149 | + |
| 151 | 150 | return true; |
| 152 | 151 | } |
| 153 | 152 | |
| 154 | 153 | public function getMsg() { |
| 155 | 154 | global $wgUser, $wgContLang, $wgRequest; |
| 156 | | - wfProfileIn( __METHOD__ ); |
| 157 | 155 | |
| 158 | 156 | self::$disableImagesURL = $wgRequest->escapeAppendQuery( 'disableImages=1' ); |
| 159 | 157 | self::$enableImagesURL = $wgRequest->escapeAppendQuery( 'enableImages=1' ); |
| — | — | @@ -198,7 +196,6 @@ |
| 199 | 197 | |
| 200 | 198 | self::$mainPageUrl = Title::newMainPage()->getLocalUrl(); |
| 201 | 199 | self::$randomPageUrl = SpecialPage::getTitleFor( 'Randompage' )->getLocalUrl(); |
| 202 | | - wfProfileOut( __METHOD__ ); |
| 203 | 200 | } |
| 204 | 201 | |
| 205 | 202 | /** |
| — | — | @@ -208,7 +205,7 @@ |
| 209 | 206 | */ |
| 210 | 207 | public function beforePageDisplayHTML( &$out, &$text ) { |
| 211 | 208 | global $wgContLang, $wgRequest, $wgMemc, $wgUser; |
| 212 | | - wfProfileIn( __METHOD__ ); |
| | 209 | + |
| 213 | 210 | // The title |
| 214 | 211 | self::$title = $out->getTitle(); |
| 215 | 212 | |
| — | — | @@ -303,7 +300,6 @@ |
| 304 | 301 | if ( $mobileAction == 'disable_mobile_site' ) { |
| 305 | 302 | if ( $this->contentFormat == 'XHTML' ) { |
| 306 | 303 | echo $this->renderDisableMobileSiteXHTML(); |
| 307 | | - wfProfileOut( __METHOD__ ); |
| 308 | 304 | exit(); |
| 309 | 305 | } |
| 310 | 306 | } |
| — | — | @@ -311,7 +307,6 @@ |
| 312 | 308 | if ( $mobileAction == 'opt_in_mobile_site' ) { |
| 313 | 309 | if ( $this->contentFormat == 'XHTML' ) { |
| 314 | 310 | echo $this->renderOptInMobileSiteXHTML(); |
| 315 | | - wfProfileOut( __METHOD__ ); |
| 316 | 311 | exit(); |
| 317 | 312 | } |
| 318 | 313 | } |
| — | — | @@ -319,7 +314,6 @@ |
| 320 | 315 | if ( $mobileAction == 'opt_out_mobile_site' ) { |
| 321 | 316 | if ( $this->contentFormat == 'XHTML' ) { |
| 322 | 317 | echo $this->renderOptOutMobileSiteXHTML(); |
| 323 | | - wfProfileOut( __METHOD__ ); |
| 324 | 318 | exit(); |
| 325 | 319 | } |
| 326 | 320 | } |
| — | — | @@ -372,59 +366,49 @@ |
| 373 | 367 | } |
| 374 | 368 | } |
| 375 | 369 | |
| 376 | | - wfProfileOut( __METHOD__ ); |
| 377 | 370 | return true; |
| 378 | 371 | } |
| 379 | 372 | |
| 380 | 373 | private function setOptInOutCookie( $value ) { |
| 381 | 374 | global $wgCookieDomain, $wgRequest; |
| 382 | | - wfProfileIn( __METHOD__ ); |
| 383 | 375 | $tempWgCookieDomain = $wgCookieDomain; |
| 384 | 376 | $wgCookieDomain = $this->getBaseDomain(); |
| 385 | 377 | $wgRequest->response()->setcookie( 'optin', $value ); |
| 386 | 378 | $wgCookieDomain = $tempWgCookieDomain; |
| 387 | | - wfProfileOut( __METHOD__ ); |
| 388 | 379 | } |
| 389 | 380 | |
| 390 | 381 | private function getBaseDomain() { |
| 391 | | - wfProfileIn( __METHOD__ ); |
| 392 | 382 | //Validates value as IP address |
| 393 | 383 | if( !IP::isValid( $_SERVER['HTTP_HOST'] ) ) { |
| 394 | 384 | $domainParts = explode( '.', $_SERVER['HTTP_HOST'] ); |
| 395 | 385 | $domainParts = array_reverse( $domainParts ); |
| 396 | 386 | //Although some browsers will accept cookies without the initial ., » RFC 2109 requires it to be included. |
| 397 | | - wfProfileOut( __METHOD__ ); |
| 398 | 387 | return '.' . $domainParts[1] . '.' . $domainParts[0]; |
| 399 | 388 | } else { |
| 400 | | - wfProfileOut( __METHOD__ ); |
| 401 | 389 | return $_SERVER['HTTP_HOST']; |
| 402 | 390 | } |
| 403 | 391 | } |
| 404 | 392 | |
| 405 | 393 | private function disableCaching() { |
| 406 | 394 | global $wgRequest; |
| 407 | | - wfProfileIn( __METHOD__ ); |
| 408 | 395 | if ( isset( $_SERVER['HTTP_VIA'] ) && |
| 409 | 396 | stripos( $_SERVER['HTTP_VIA'], '.wikimedia.org:3128' ) !== false ) { |
| 410 | 397 | $wgRequest->response()->header( 'Cache-Control: no-cache, must-revalidate' ); |
| 411 | 398 | $wgRequest->response()->header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); |
| 412 | 399 | $wgRequest->response()->header( 'Pragma: no-cache' ); |
| 413 | 400 | } |
| 414 | | - wfProfileOut( __METHOD__ ); |
| 415 | 401 | } |
| 416 | 402 | |
| 417 | 403 | private function sendXDeviceVaryHeader() { |
| 418 | 404 | global $wgOut, $wgRequest; |
| 419 | | - wfProfileIn( __METHOD__ ); |
| | 405 | + |
| 420 | 406 | if ( !empty( $_SERVER['HTTP_X_DEVICE'] ) ) { |
| 421 | 407 | $wgRequest->response()->header( 'X-Device: ' . $_SERVER['HTTP_X_DEVICE'] ); |
| 422 | 408 | $wgOut->addVaryHeader( 'X-Device' ); |
| 423 | 409 | } |
| 424 | | - wfProfileOut( __METHOD__ ); |
| 425 | 410 | } |
| 426 | 411 | |
| 427 | 412 | private function renderOptInMobileSiteXHTML() { |
| 428 | | - wfProfileIn( __METHOD__ ); |
| 429 | 413 | if ( $this->contentFormat == 'XHTML' ) { |
| 430 | 414 | $this->getMsg(); |
| 431 | 415 | $yesButton = self::$messages['mobile-frontend-opt-in-yes-button']; |
| — | — | @@ -437,15 +421,12 @@ |
| 438 | 422 | require( 'views/information/optin.html.php' ); |
| 439 | 423 | $contentHtml = $optInHtml; |
| 440 | 424 | require( 'views/layout/application.html.php' ); |
| 441 | | - wfProfileOut( __METHOD__ ); |
| 442 | 425 | return $applicationHtml; |
| 443 | 426 | } |
| 444 | | - wfProfileOut( __METHOD__ ); |
| 445 | 427 | return ''; |
| 446 | 428 | } |
| 447 | 429 | |
| 448 | 430 | private function renderOptOutMobileSiteXHTML() { |
| 449 | | - wfProfileIn( __METHOD__ ); |
| 450 | 431 | if ( $this->contentFormat == 'XHTML' ) { |
| 451 | 432 | $this->getMsg(); |
| 452 | 433 | $yesButton = self::$messages['mobile-frontend-opt-out-yes-button']; |
| — | — | @@ -458,15 +439,12 @@ |
| 459 | 440 | require( 'views/information/optout.html.php' ); |
| 460 | 441 | $contentHtml = $optOutHtml; |
| 461 | 442 | require( 'views/layout/application.html.php' ); |
| 462 | | - wfProfileOut( __METHOD__ ); |
| 463 | 443 | return $applicationHtml; |
| 464 | 444 | } |
| 465 | | - wfProfileOut( __METHOD__ ); |
| 466 | 445 | return ''; |
| 467 | 446 | } |
| 468 | 447 | |
| 469 | 448 | private function renderDisableMobileSiteXHTML() { |
| 470 | | - wfProfileIn( __METHOD__ ); |
| 471 | 449 | if ( $this->contentFormat == 'XHTML' ) { |
| 472 | 450 | $this->getMsg(); |
| 473 | 451 | $areYouSure = self::$messages['mobile-frontend-are-you-sure']; |
| — | — | @@ -480,15 +458,12 @@ |
| 481 | 459 | require( 'views/information/disable.html.php' ); |
| 482 | 460 | $contentHtml = $disableHtml; |
| 483 | 461 | require( 'views/layout/application.html.php' ); |
| 484 | | - wfProfileOut( __METHOD__ ); |
| 485 | 462 | return $applicationHtml; |
| 486 | 463 | } |
| 487 | | - wfProfileOut( __METHOD__ ); |
| 488 | 464 | return ''; |
| 489 | 465 | } |
| 490 | 466 | |
| 491 | 467 | private function headingTransformCallbackWML( $matches ) { |
| 492 | | - wfProfileIn( __METHOD__ ); |
| 493 | 468 | static $headings = 0; |
| 494 | 469 | ++$headings; |
| 495 | 470 | |
| — | — | @@ -496,12 +471,12 @@ |
| 497 | 472 | "<h2 class='section_heading' id='section_{$headings}'>{$matches[2]}</h2>"; |
| 498 | 473 | |
| 499 | 474 | self::$headings = $headings; |
| 500 | | - wfProfileOut( __METHOD__ ); |
| | 475 | + |
| 501 | 476 | return $base; |
| 502 | 477 | } |
| 503 | 478 | |
| 504 | 479 | private function headingTransformCallbackXHTML( $matches ) { |
| 505 | | - wfProfileIn( __METHOD__ ); |
| | 480 | + |
| 506 | 481 | if ( isset( $matches[0] ) ) { |
| 507 | 482 | preg_match('/id="([^"]*)"/', $matches[0], $headlineMatches); |
| 508 | 483 | } |
| — | — | @@ -529,7 +504,7 @@ |
| 530 | 505 | } |
| 531 | 506 | |
| 532 | 507 | self::$headings = $headings; |
| 533 | | - wfProfileOut( __METHOD__ ); |
| | 508 | + |
| 534 | 509 | return $base; |
| 535 | 510 | } |
| 536 | 511 | |
| — | — | @@ -538,7 +513,6 @@ |
| 539 | 514 | * @return string |
| 540 | 515 | */ |
| 541 | 516 | public function headingTransform( $s ) { |
| 542 | | - wfProfileIn( __METHOD__ ); |
| 543 | 517 | $callback = 'headingTransformCallback'; |
| 544 | 518 | $callback .= $this->contentFormat; |
| 545 | 519 | |
| — | — | @@ -559,12 +533,11 @@ |
| 560 | 534 | $s |
| 561 | 535 | ); |
| 562 | 536 | } |
| 563 | | - wfProfileOut( __METHOD__ ); |
| | 537 | + |
| 564 | 538 | return $s; |
| 565 | 539 | } |
| 566 | 540 | |
| 567 | 541 | private function createWMLCard( $s ) { |
| 568 | | - wfProfileIn( __METHOD__ ); |
| 569 | 542 | $segments = explode( $this->WMLSectionSeperator, $s ); |
| 570 | 543 | $card = ''; |
| 571 | 544 | $idx = 0; |
| — | — | @@ -590,13 +563,11 @@ |
| 591 | 564 | } |
| 592 | 565 | |
| 593 | 566 | $card .= '</card>'; |
| 594 | | - wfProfileOut( __METHOD__ ); |
| 595 | 567 | return $card; |
| 596 | 568 | } |
| 597 | 569 | |
| 598 | 570 | private function parseItemsToRemove() { |
| 599 | 571 | global $wgMFRemovableClasses; |
| 600 | | - wfProfileIn( __METHOD__ ); |
| 601 | 572 | $itemToRemoveRecords = array(); |
| 602 | 573 | |
| 603 | 574 | foreach ( array_merge( $this->itemsToRemove, $wgMFRemovableClasses ) |
| — | — | @@ -607,13 +578,11 @@ |
| 608 | 579 | CssDetection::detectIdCssOrTag( $itemToRemove, $type, $rawName ); |
| 609 | 580 | $itemToRemoveRecords[$type][] = $rawName; |
| 610 | 581 | } |
| 611 | | - |
| 612 | | - wfProfileOut( __METHOD__ ); |
| | 582 | + |
| 613 | 583 | return $itemToRemoveRecords; |
| 614 | 584 | } |
| 615 | 585 | |
| 616 | 586 | public function DOMParseMainPage( $html ) { |
| 617 | | - wfProfileIn( __METHOD__ ); |
| 618 | 587 | $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8"); |
| 619 | 588 | libxml_use_internal_errors( true ); |
| 620 | 589 | $this->mainPage = new DOMDocument(); |
| — | — | @@ -644,13 +613,13 @@ |
| 645 | 614 | } |
| 646 | 615 | |
| 647 | 616 | $contentHtml = $this->mainPage->saveXML( $content, LIBXML_NOEMPTYTAG ); |
| 648 | | - wfProfileOut( __METHOD__ ); |
| | 617 | + |
| 649 | 618 | return $contentHtml; |
| 650 | 619 | } |
| 651 | 620 | |
| 652 | 621 | public function DOMParse( $html ) { |
| 653 | 622 | global $wgSitename; |
| 654 | | - wfProfileIn( __METHOD__ ); |
| | 623 | + |
| 655 | 624 | $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8"); |
| 656 | 625 | libxml_use_internal_errors( true ); |
| 657 | 626 | $this->doc = new DOMDocument(); |
| — | — | @@ -790,17 +759,15 @@ |
| 791 | 760 | $json_data['title'] = self::$title->getText(); |
| 792 | 761 | $json_data['html'] = $contentHtml; |
| 793 | 762 | |
| 794 | | - $json = FormatJson::encode( $json_data ); |
| | 763 | + $json = json_encode( $json_data ); |
| 795 | 764 | |
| 796 | 765 | if ( !empty( self::$callback ) ) { |
| 797 | 766 | $json = urlencode( self::$callback ) . '(' . $json . ')'; |
| 798 | 767 | } |
| 799 | 768 | |
| 800 | | - wfProfileOut( __METHOD__ ); |
| 801 | 769 | return $json; |
| 802 | 770 | } |
| 803 | | - |
| 804 | | - wfProfileOut( __METHOD__ ); |
| | 771 | + |
| 805 | 772 | return $applicationHtml; |
| 806 | 773 | } |
| 807 | 774 | |
| — | — | @@ -809,10 +776,8 @@ |
| 810 | 777 | */ |
| 811 | 778 | public function setDefaultLogo() { |
| 812 | 779 | global $wgMobileFrontendLogo, $wgExtensionAssetsPath; |
| 813 | | - wfProfileIn( __METHOD__ ); |
| 814 | 780 | if ( $wgMobileFrontendLogo === false ) { |
| 815 | 781 | $wgMobileFrontendLogo = $wgExtensionAssetsPath . '/MobileFrontend/stylesheets/images/mw.png'; |
| 816 | 782 | } |
| 817 | | - wfProfileOut( __METHOD__ ); |
| 818 | 783 | } |
| 819 | 784 | } |