* API: Add documentation to important API classes
[lhc/web/wiklou.git] / includes / OutputPage.php
index dcd5c30..acf7986 100644 (file)
@@ -309,20 +309,20 @@ class OutputPage {
                }
        }
 
-       public function setHTMLTitle( $name ) {$this->mHTMLtitle = $name; }
+       public function setHTMLTitle( $name ) { $this->mHTMLtitle = $name; }
        public function setPageTitle( $name ) {
-               global $action, $wgContLang;
-               $name = $wgContLang->convert($name, true);
+               global $wgContLang;
+               $name = $wgContLang->convert( $name, true );
                $this->mPagetitle = $name;
-               if(!empty($action)) {
-                       $taction =  $this->getPageTitleActionText();
-                       if( !empty( $taction ) ) {
-                               $name .= ' - '.$taction;
-                       }
+
+               $taction =  $this->getPageTitleActionText();
+               if( !empty( $taction ) ) {
+                       $name .= ' - '.$taction;
                }
 
                $this->setHTMLTitle( wfMsg( 'pagetitle', $name ) );
        }
+
        public function getHTMLTitle() { return $this->mHTMLtitle; }
        public function getPageTitle() { return $this->mPagetitle; }
        public function setSubtitle( $str ) { $this->mSubtitle = /*$this->parse(*/$str/*)*/; } // @bug 2514
@@ -408,7 +408,12 @@ class OutputPage {
                if ( wfRunHooks( 'OutputPageMakeCategoryLinks', array( &$this, $categories, &$this->mCategoryLinks ) ) ) {
                        $sk = $wgUser->getSkin();
                        foreach ( $categories as $category => $type ) {
+                               $origcategory = $category;
                                $title = Title::makeTitleSafe( NS_CATEGORY, $category );
+                               $wgContLang->findVariantLink( $category, $title, true );
+                               if ( $category != $origcategory )
+                                       if ( array_key_exists( $category, $categories ) )
+                                               continue;
                                $text = $wgContLang->convertHtml( $title->getText() );
                                $this->mCategoryLinks[$type][] = $sk->makeLinkObj( $title, $text );
                        }
@@ -538,9 +543,11 @@ class OutputPage {
                                $this->mTemplateIds[$ns] = $dbks;
                        }
                }
-               // Display title
+               // Page title
                if( ( $dt = $parserOutput->getDisplayTitle() ) !== false )
                        $this->setPageTitle( $dt );
+               else if ( ( $title = $parserOutput->getTitleText() ) != '' )
+                       $this->setPageTitle( $title );
 
                // Hooks registered in the object
                global $wgParserOutputHooks;
@@ -642,6 +649,18 @@ class OutputPage {
                return $parserOutput->getText();
        }
 
+       /** Parse wikitext, strip paragraphs, and return the HTML. */
+       public function parseInline( $text, $linestart = true, $interface = false ) {
+               $parsed = $this->parse( $text, $linestart, $interface );
+
+               $m = array();
+               if ( preg_match( '/^<p>(.*)\n?<\/p>\n?/sU', $parsed, $m ) ) {
+                       $parsed = $m[1];
+               }
+
+               return $parsed;
+       }
+
        /**
         * @param Article $article
         * @param User    $user
@@ -1383,6 +1402,7 @@ class OutputPage {
         */
        public function addReturnTo( $title ) {
                global $wgUser;
+               $this->addLink( array( 'rel' => 'next', 'href' => $title->getFullUrl() ) );
                $link = wfMsg( 'returnto', $wgUser->getSkin()->makeLinkObj( $title ) );
                $this->addHTML( "<p>{$link}</p>\n" );
        }
@@ -1842,7 +1862,7 @@ class OutputPage {
                                $args = array();
                                $name = $spec;
                        }
-                       $s = str_replace( '$' . ($n+1), wfMsgExt( $name, $options, $args ), $s );
+                       $s = str_replace( '$' . ( $n + 1 ), wfMsgExt( $name, $options, $args ), $s );
                }
                $this->addHTML( $this->parse( $s, /*linestart*/true, /*uilang*/true ) );
        }