(bug 4876) Add __NEWSECTIONLINK__ magic word to force the "new section" link/tab...
[lhc/web/wiklou.git] / includes / SkinTemplate.php
index a048fd5..e87987f 100644 (file)
@@ -14,7 +14,7 @@ if ( ! defined( 'MEDIAWIKI' ) )
 #
 # You should have received a copy of the GNU General Public License along
 # with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 # http://www.gnu.org/copyleft/gpl.html
 
 /**
@@ -37,7 +37,7 @@ require_once 'GlobalFunctions.php';
  * Wrapper object for MediaWiki's localization functions,
  * to be passed to the template engine.
  *
- * @access private
+ * @private
  * @package MediaWiki
  */
 class MediaWiki_I18N {
@@ -74,7 +74,7 @@ class MediaWiki_I18N {
  */
 class SkinTemplate extends Skin {
        /**#@+
-        * @access private
+        * @private
         */
 
        /**
@@ -120,7 +120,7 @@ class SkinTemplate extends Skin {
         * @param string $repository subdirectory where we keep template files
         * @param string $cache_dir
         * @return object
-        * @access private
+        * @private
         */
        function setupTemplate( $classname, $repository=false, $cache_dir=false ) {
                return new $classname();
@@ -130,7 +130,7 @@ class SkinTemplate extends Skin {
         * initialize various variables and generate the template
         *
         * @param OutputPage $out
-        * @access public
+        * @public
         */
        function outputPage( &$out ) {
                global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang, $wgOut;
@@ -187,6 +187,7 @@ class SkinTemplate extends Skin {
                wfProfileIn( "$fname-stuff2" );
                $tpl->set( 'title', $wgOut->getPageTitle() );
                $tpl->set( 'pagetitle', $wgOut->getHTMLTitle() );
+               $tpl->set( 'displaytitle', $wgOut->mPageLinkTitle );
 
                $tpl->setRef( "thispage", $this->thispage );
                $subpagestr = $this->subPageSubtitle();
@@ -307,7 +308,7 @@ class SkinTemplate extends Skin {
                        if ( !$wgDisableCounters ) {
                                $viewcount = $wgLang->formatNum( $wgArticle->getCount() );
                                if ( $viewcount ) {
-                                       $tpl->set('viewcount', wfMsg( "viewcount", $viewcount ));
+                                       $tpl->set('viewcount', wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ) );
                                } else {
                                        $tpl->set('viewcount', false);
                                }
@@ -435,7 +436,7 @@ class SkinTemplate extends Skin {
         * For the base class, assume strings all around.
         *
         * @param mixed $str
-        * @access private
+        * @private
         */
        function printOrError( &$str ) {
                echo $str;
@@ -444,7 +445,7 @@ class SkinTemplate extends Skin {
        /**
         * build array of urls for personal toolbar
         * @return array
-        * @access private
+        * @private
         */
        function buildPersonalUrls() {
                global $wgTitle, $wgShowIPinHeader;
@@ -548,7 +549,8 @@ class SkinTemplate extends Skin {
 
                $text = wfMsg( $message );
                if ( $text == "<$message>" ) {
-                       $text = html_entity_decode($text);
+                       global $wgContLang;
+                       $text = $wgContLang->getNsText( Namespace::getSubject( $title->getNamespace() ) );
                }
 
                return array(
@@ -580,10 +582,10 @@ class SkinTemplate extends Skin {
        /**
         * an array of edit links by default used for the tabs
         * @return array
-        * @access private
+        * @private
         */
        function buildContentActionUrls () {
-               global $wgContLang;
+               global $wgContLang, $wgOut;
                $fname = 'SkinTemplate::buildContentActionUrls';
                wfProfileIn( $fname );
 
@@ -623,7 +625,7 @@ class SkinTemplate extends Skin {
                                        'href' => $this->mTitle->getLocalUrl( $this->editUrlOptions() )
                                );
 
-                               if ( $istalk ) {
+                               if ( $istalk || $wgOut->showNewSectionLink() ) {
                                        $content_actions['addsection'] = array(
                                                'class' => $section == 'new'?'selected':false,
                                                'text' => wfMsg('addsection'),
@@ -672,20 +674,23 @@ class SkinTemplate extends Skin {
                                        );
                                }
                                if ( $this->mTitle->userCanMove()) {
+                                       $moveTitle = Title::makeTitle( NS_SPECIAL, 'Movepage' );
                                        $content_actions['move'] = array(
                                                'class' => ($this->mTitle->getDbKey() == 'Movepage' and $this->mTitle->getNamespace == NS_SPECIAL) ? 'selected' : false,
                                                'text' => wfMsg('move'),
-                                               'href' => $this->makeSpecialUrl("Movepage/$this->thispage" )
+                                               'href' => $moveTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) )
                                        );
                                }
                        } else {
                                //article doesn't exist or is deleted
-                               if($wgUser->isAllowed('delete')){
+                               if( $wgUser->isAllowed( 'delete' ) ) {
                                        if( $n = $this->mTitle->isDeleted() ) {
+                                               $undelTitle = Title::makeTitle( NS_SPECIAL, 'Undelete' );
                                                $content_actions['undelete'] = array(
                                                        'class' => false,
                                                        'text' => ($n == 1) ? wfMsg( 'undelete_short1' ) : wfMsg('undelete_short', $n ),
-                                                       'href' => $this->makeSpecialUrl("Undelete/$this->thispage")
+                                                       'href' => $undelTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) )
+                                                       #'href' => $this->makeSpecialUrl("Undelete/$this->thispage")
                                                );
                                        }
                                }
@@ -755,7 +760,7 @@ class SkinTemplate extends Skin {
        /**
         * build array of common navigation links
         * @return array
-        * @access private
+        * @private
         */
        function buildNavUrls () {
                global $wgUseTrackbacks, $wgTitle, $wgArticle;
@@ -814,13 +819,15 @@ class SkinTemplate extends Skin {
                        wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array( &$this, &$nav_urls, &$oldid, &$revid ) );
                }
 
-               if( $this->mTitle->getNamespace() != NS_SPECIAL) {
+               if( $this->mTitle->getNamespace() != NS_SPECIAL ) {
+                       $wlhTitle = Title::makeTitle( NS_SPECIAL, 'Whatlinkshere' );
                        $nav_urls['whatlinkshere'] = array(
-                               'href' => $this->makeSpecialUrl("Whatlinkshere/$this->thispage")
+                               'href' => $wlhTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) )
                        );
                        if( $this->mTitle->getArticleId() ) {
+                               $rclTitle = Title::makeTitle( NS_SPECIAL, 'Recentchangeslinked' );
                                $nav_urls['recentchangeslinked'] = array(
-                                       'href' => $this->makeSpecialUrl("Recentchangeslinked/$this->thispage")
+                                       'href' => $rclTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) )
                                );
                        }
                        if ($wgUseTrackbacks)
@@ -861,14 +868,14 @@ class SkinTemplate extends Skin {
        /**
         * Generate strings used for xml 'id' names
         * @return string
-        * @access private
+        * @private
         */
        function getNameSpaceKey () {
                return $this->mTitle->getNamespaceKey();
        }
 
        /**
-        * @access private
+        * @private
         */
        function setupUserCss() {
                $fname = 'SkinTemplate::setupUserCss';
@@ -917,7 +924,7 @@ class SkinTemplate extends Skin {
        }
 
        /**
-        * @access private
+        * @private
         */
        function setupUserJs() {
                $fname = 'SkinTemplate::setupUserJs';
@@ -941,7 +948,7 @@ class SkinTemplate extends Skin {
         * Code for extensions to hook into to provide per-page CSS, see
         * extensions/PageCSS/PageCSS.php for an implementation of this.
         *
-        * @access private
+        * @private
         */
        function setupPageCss() {
                $fname = 'SkinTemplate::setupPageCss';
@@ -955,7 +962,7 @@ class SkinTemplate extends Skin {
 
        /**
         * returns css with user-specific options
-        * @access public
+        * @public
         */
 
        function getUserStylesheet() {
@@ -969,7 +976,7 @@ class SkinTemplate extends Skin {
        }
 
        /**
-        * @access public
+        * @public
         */
        function getUserJs() {
                $fname = 'SkinTemplate::getUserJs';
@@ -1001,7 +1008,7 @@ class SkinTemplate extends Skin {
  */
 class QuickTemplate {
        /**
-        * @access public
+        * @public
         */
        function QuickTemplate() {
                $this->data = array();
@@ -1009,28 +1016,28 @@ class QuickTemplate {
        }
 
        /**
-        * @access public
+        * @public
         */
        function set( $name, $value ) {
                $this->data[$name] = $value;
        }
 
        /**
-        * @access public
+        * @public
         */
        function setRef($name, &$value) {
                $this->data[$name] =& $value;
        }
 
        /**
-        * @access public
+        * @public
         */
        function setTranslator( &$t ) {
                $this->translator = &$t;
        }
 
        /**
-        * @access public
+        * @public
         */
        function execute() {
                echo "Override this function.";
@@ -1038,28 +1045,28 @@ class QuickTemplate {
 
 
        /**
-        * @access private
+        * @private
         */
        function text( $str ) {
                echo htmlspecialchars( $this->data[$str] );
        }
 
        /**
-        * @access private
+        * @private
         */
        function html( $str ) {
                echo $this->data[$str];
        }
 
        /**
-        * @access private
+        * @private
         */
        function msg( $str ) {
                echo htmlspecialchars( $this->translator->translate( $str ) );
        }
 
        /**
-        * @access private
+        * @private
         */
        function msgHtml( $str ) {
                echo $this->translator->translate( $str );
@@ -1067,7 +1074,7 @@ class QuickTemplate {
 
        /**
         * An ugly, ugly hack.
-        * @access private
+        * @private
         */
        function msgWiki( $str ) {
                global $wgParser, $wgTitle, $wgOut;
@@ -1079,14 +1086,14 @@ class QuickTemplate {
        }
 
        /**
-        * @access private
+        * @private
         */
        function haveData( $str ) {
                return $this->data[$str];
        }
 
        /**
-        * @access private
+        * @private
         */
        function haveMsg( $str ) {
                $msg = $this->translator->translate( $str );