Jump to content

User talk:Gatoatigrado/sidebarhack

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Addition for the toolbox

[edit]

Monobook.php

[edit]
	<div class="portlet" id="p-tb">
		<h5><?php $this->msg('toolbox') ?></h5>
		<div class="pBody">
			<ul>
<?php
        $toolbox = array();
	if(!empty($this->data['nav_urls']['permalink']['href'])) {
	    $toolbox['t-permalink'] = array(
	        'href' => htmlspecialchars($this->data['nav_urls']['permalink']['href']),
	        'text' => $this->getMsg('permalink')
	    );
	} elseif ($this->data['nav_urls']['permalink']['href'] === '') {
	    $toolbox['t-ispermalink'] = array(
	        'text' => $this->getMsg('permalink')
	    );
	}

	if(!empty($this->data['nav_urls']['print']['href'])) {
	    $toolbox['t-print'] = array(
		'href' => htmlspecialchars($this->data['nav_urls']['print']['href']),
		'text' => $this->getMsg('printableversion')
	    );
	}

	if($this->data['notspecialpage']) {
	    if( $this->data['nav_urls']['recentchangeslinked'] ) {
		$toolbox['t-recentchangeslinked'] = array(
		    'href' => htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href']),
		    'text' => $this->getMsg('recentchangeslinked')
		);
	    }
	    $toolbox['t-whatlinkshere'] = array(
		'href' => htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href']),
		'text' => $this->getMsg('whatlinkshere')
	    );
	}
	if(isset($this->data['nav_urls']['trackbacklink'])) {
	    $toolbox['t-trackbacklink'] = array(
	        'href' => htmlspecialchars($this->data['nav_urls']['trackbacklink']['href']),
	        'text' => $this->getMsg('trackbacklink')
	    );
        }
	if($this->data['feeds']) {
            $feedtext = '';
            foreach($this->data['feeds'] as $key => $feed) {
		$feedtext .= '<span id="feed-' . htmlspecialchars($key) . '"><a href="' . htmlspecialchars($feed['href'])
                    . '">' . htmlspecialchars($feed['text']) . '</a> </span>';
	    }
	    $toolbox['feedlinks'] = array(
		'text' => $feedtext
	    );
	}

	foreach( array('contributions', 'blockip', 'emailuser', 'ruler', 'specialpages', 'upload') as $special ) {
	    if($this->data['nav_urls'][$special]) {
		$toolbox['t-' . $special] = array(
		    'href' => htmlspecialchars($this->data['nav_urls'][$special]['href']),
		    'text' => $this->getMsg($special)
		);
            } elseif($special == 'ruler') {
                if(!empty($toolbox)) { // sanity check
		    $toolbox['ruler'] = array('html' => '</ul><hr/><ul>');
                }
		$toolbox['t-recentchanges'] = array(
		    'href' => $this->data['wgScript'] . '/Special:Recentchanges',
		    'text' => $this->getMsg('recentchanges')
		);
            }
	}

	foreach($toolbox as $id => $item) {
	    if($item['html']) {
	        echo $item['html'];
	    } else { ?>
	    <li id="<?php echo $id ?>"><?php
		if($item['href']) { // link present
		    ?><a href="<?php echo $item['href'] ?>"><?php echo $item['text'] ?></a><?php
		} else {
		    echo $item['text'];
		}
            ?></li><?php
            }
        }

Addition to SkinTemplate.php

[edit]
/**
 * Generic wrapper for template functions, with interface
 * compatible with what we use of PHPTAL 0.7.
 * @package MediaWiki
 * @subpackage Skins
 */
class QuickTemplate {

<!-- ... --->

	/**
	 * @private
	 */
	function getMsg( $str ) {
		return htmlspecialchars( $this->translator->translate( $str ) );
	}
}

Comments

[edit]

Implementing Cite this page (not done yet) means linking to $this->data['wgScript'] . '/Special:Cite/' . $this->text('title') (I think). Also, I may have the order of the toolbox links wrong since I was offline when I wrote this.

Can you give this code a quick once over and add it to the hack with the pretty printing please? Thanks. --DavidHOzAu 10:30, 1 October 2006 (UTC)[reply]