Make SVGMetadataExtractor less noisy when it reads SVGs from Adobe Illustrator.
[lhc/web/wiklou.git] / includes / Exception.php
index 2244362..afa46ce 100644 (file)
@@ -22,7 +22,7 @@ class MWException extends Exception {
        function useOutputPage() {
                return $this->useMessageCache() &&
                        !empty( $GLOBALS['wgFullyInitialised'] ) &&
-                       ( !empty( $GLOBALS['wgArticle'] ) || ( !empty( $GLOBALS['wgOut'] ) && !$GLOBALS['wgOut']->isArticle() ) ) &&
+                       ( !empty( $GLOBALS['wgArticle'] ) || ( !empty( $GLOBALS['wgOut'] ) && !$GLOBALS['wgOut']->isArticleRelated() ) ) &&
                        !empty( $GLOBALS['wgTitle'] );
        }
 
@@ -39,7 +39,7 @@ class MWException extends Exception {
                        }
                }
 
-               return is_object( $wgLang );
+               return $wgLang instanceof Language;
        }
 
        /**
@@ -179,7 +179,8 @@ class MWException extends Exception {
                        $wgOut->redirect( '' );
                        $wgOut->clearHTML();
 
-                       if ( $hookResult = $this->runHooks( get_class( $this ) ) ) {
+                       $hookResult = $this->runHooks( get_class( $this ) );
+                       if ( $hookResult ) {
                                $wgOut->addHTML( $hookResult );
                        } else {
                                $wgOut->addHTML( $this->getHTML() );
@@ -187,7 +188,8 @@ class MWException extends Exception {
 
                        $wgOut->output();
                } else {
-                       if ( $hookResult = $this->runHooks( get_class( $this ) . "Raw" ) ) {
+                       $hookResult = $this->runHooks( get_class( $this ) . "Raw" );
+                       if ( $hookResult ) {
                                die( $hookResult );
                        }
 
@@ -224,7 +226,7 @@ class MWException extends Exception {
         * $wgOut to output the exception.
         */
        function htmlHeader() {
-               global $wgLogo, $wgOutputEncoding;
+               global $wgLogo, $wgOutputEncoding, $wgLang;
 
                if ( !headers_sent() ) {
                        header( 'HTTP/1.0 500 Internal Server Error' );
@@ -234,21 +236,39 @@ class MWException extends Exception {
                        header( 'Pragma: nocache' );
                }
 
-               $title = $this->getPageTitle();
-               return "<html>
-               <head>
-               <title>$title</title>
-               </head>
-               <body>
-               <h1><img src='$wgLogo' style='float:left;margin-right:1em' alt=''/>$title</h1>
-               ";
+               $title = Html::element( 'title', null, $this->getPageTitle() );
+
+               $left = 'left';
+               $right = 'right';
+               $dir = 'ltr';
+               $code = 'en';
+
+               if ( $wgLang instanceof Language ) {
+                       $left = $wgLang->alignStart();
+                       $right = $wgLang->alignEnd();
+                       $dir = $wgLang->getDir();
+                       $code = $wgLang->getCode();
+               }
+
+               $header = Html::element( 'img', array(
+                       'src' => $wgLogo,
+                       'style' => "float: $left; margin-$right: 1em;",
+                       'alt' => '' ), $this->getPageTitle() );
+
+               $attribs = array( 'dir' => $dir, 'lang' => $code );
+
+               return
+                       Html::htmlHeader( $attribs ) .
+                       Html::rawElement( 'head', null, $title ) . "\n". 
+                       Html::openElement( 'body' ) . "\n" .
+                       Html::rawElement( 'h1', null, $header ) . "\n";
        }
 
        /**
         * print the end of the html page if not using $wgOut.
         */
        function htmlFooter() {
-               return "</body></html>";
+               return Html::closeElement( 'body' ) . Html::closeElement( 'html' );
        }
 
        /**
@@ -388,7 +408,7 @@ function wfExceptionHandler( $e ) {
 
        wfReportException( $e );
 
-       // Final cleanup, similar to wfErrorExit()
+       // Final cleanup
        if ( $wgFullyInitialised ) {
                try {
                        wfLogProfilingData(); // uses $wgRequest, hence the $wgFullyInitialised condition