# For now, PHPTAL 1.0.x must be installed via PEAR in system dir.
require_once 'PEAR.php';
require_once 'PHPTAL.php';
- require_once 'PHPTAL/Attribute.php';
- require_once 'PHPTAL/Attribute/I18N/Attributes.php';
}
/**
* @todo document
* @package MediaWiki
*/
+// PHPTAL 1.0 no longer has the PHPTAL_I18N stub class.
//class MediaWiki_I18N extends PHPTAL_I18N {
class MediaWiki_I18N {
var $_context = array();
}
function translate($value) {
+ // Hack for i18n:attributes in PHPTAL 1.0.0 dev version as of 2004-10-23
+ $value = preg_replace( '/^string:/', '', $value );
+
$value = wfMsg( $value );
// interpolate variables
while (preg_match('/\$([0-9]*?)/sm', $value, $m)) {
}
return $value;
}
-
- /* For PHPTAL 1.0: */
- function setLanguage( $langCode ) {
- }
-
- function setDomain( $domain ) {
- }
-
- function setVar( $key, $value ) {
- $this->set( $key, $value );
- }
}
/**
*
* @access private
*/
function &setupTemplate( $file, $repository=false, $cache_dir=false ) {
- if( NEW_PHPTAL ) {
+ if( defined( 'NEW_PHPTAL' ) ) {
return new PHPTAL_version_bridge( $file, $repository, $cache_dir );
} else {
return new PHPTAL( $file, $repository, $cache_dir );
$tpl->set( "watch", $wgTitle->userIsWatching() ? "unwatch" : "watch" );
$tpl->set( "protect", count($wgTitle->getRestrictions()) ? "unprotect" : "protect" );
$tpl->set( "helppage", wfMsg('helppage'));
- $tpl->set( "sysop", $wgUser->isSysop() );
*/
$tpl->set( 'searchaction', $this->escapeSearchLink() );
$tpl->setRef( 'stylepath', $wgStylePath );
$viewcount = $wgLang->formatNum( $wgArticle->getCount() );
if ( $viewcount ) {
$tpl->set('viewcount', wfMsg( "viewcount", $viewcount ));
+ } else {
+ $tpl->set('viewcount', false);
}
}
$tpl->set('lastmod', $this->lastModified());
$out->mBodytext .= $printfooter ;
$tpl->setRef( 'bodytext', $out->mBodytext );
+ # Language links
$language_urls = array();
foreach( $wgOut->getLanguageLinks() as $l ) {
$nt = Title::newFromText( $l );
} else {
$tpl->set('language_urls', false);
}
+
+ # Personal toolbar
$tpl->set('personal_urls', $this->buildPersonalUrls());
$content_actions = $this->buildContentActionUrls();
$tpl->setRef('content_actions', $content_actions);
} else {
$tpl->set('body_ondblclick', false);
}
+ $tpl->set( 'navigation_urls', $this->buildNavigationUrls() );
$tpl->set( 'nav_urls', $this->buildNavUrls() );
// execute template
}
if ( $wgTitle->userCanEdit() ) {
- $oid = ( $oldid && ! isset( $diff ) ) ? '&oldid='.$oldid : false;
+ $oid = ( $oldid && ! isset( $diff ) ) ? '&oldid='.IntVal( $oldid ) : false;
$istalk = ( Namespace::isTalk( $wgTitle->getNamespace()) );
$istalkclass = $istalk?' istalk':'';
$content_actions['edit'] = array(
);
}
} else {
- $oid = ( $oldid && ! isset( $diff ) ) ? '&oldid='.$oldid : '';
+ $oid = ( $oldid && ! isset( $diff ) ) ? '&oldid='.IntVal( $oldid ) : '';
$content_actions['viewsource'] = array('class' => ($action == 'edit') ? 'selected' : false,
'text' => wfMsg('viewsource'),
'href' => $this->makeUrl($this->thispage, 'action=edit'.$oid));
'href' => $this->makeUrl($this->thispage, 'action=rollback'),
'ttip' => wfMsg('tooltip-rollback'),
'akey' => wfMsg('accesskey-rollback'));
- }*/
+ }
+ */
- if($wgUser->isSysop()){
+ if($wgUser->isAllowed('protect')){
if(!$wgTitle->isProtected()){
$content_actions['protect'] = array(
'class' => ($action == 'protect') ? 'selected' : false,
'href' => $this->makeUrl($this->thispage, 'action=unprotect')
);
}
+ }
+ if($wgUser->isAllowed('delete')){
$content_actions['delete'] = array(
'class' => ($action == 'delete') ? 'selected' : false,
'text' => wfMsg('delete'),
'text' => wfMsg('move'),
'href' => $this->makeSpecialUrl('Movepage', 'target='. urlencode( $this->thispage ))
);
- } else {
- $content_actions['move'] = array('class' => 'inactive',
- 'text' => wfMsg('move'),
- 'href' => false);
-
}
}
} else {
//article doesn't exist or is deleted
- if($wgUser->isSysop()){
+ if($wgUser->isAllowed('delete')){
if( $n = $wgTitle->isDeleted() ) {
- $content_actions['delete'] = array(
+ $content_actions['undelete'] = array(
'class' => false,
'text' => wfMsg( "undelete_short", $n ),
'href' => $this->makeSpecialUrl('Undelete/'.$this->thispage)
return $content_actions;
}
+ /**
+ * build array of global navigation links
+ */
+ function buildNavigationUrls () {
+ global $wgNavigationLinks;
+ $result = array();
+ foreach ( $wgNavigationLinks as $link ) {
+ if (wfMsg( $link['text'] ) != '-') {
+ $result[] = array(
+ 'text' => wfMsg( $link['text'] ),
+ 'href' => $this->makeInternalOrExternalUrl( wfMsgForContent( $link['href'] ) ),
+ 'id' => 'n-'.$link['text']
+ );
+ }
+ }
+ return $result;
+ }
+
/**
* build array of common navigation links
*/
$diff = $wgRequest->getVal( 'diff' );
// XXX: remove htmlspecialchars when tal:attributes works with i18n:attributes
$nav_urls = array();
- $nav_urls['mainpage'] = array('href' => htmlspecialchars( $this->makeI18nUrl('mainpage')));
- $nav_urls['randompage'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Randompage')));
- $nav_urls['recentchanges'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Recentchanges')));
- $nav_urls['currentevents'] = (wfMsg('currentevents') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('currentevents'))) : false;
- $nav_urls['portal'] = (wfMsg('portal') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('portal-url'))) : false;
- $nav_urls['bugreports'] = array('href' => htmlspecialchars( $this->makeI18nUrl('bugreportspage')));
- // $nav_urls['sitesupport'] = array('href' => htmlspecialchars( $this->makeI18nUrl('sitesupportpage')));
- $nav_urls['sitesupport'] = array('href' => htmlspecialchars( $wgSiteSupportPage));
- $nav_urls['help'] = array('href' => htmlspecialchars( $this->makeI18nUrl('helppage')));
+ $nav_urls['mainpage'] = array('href' => $this->makeI18nUrl('mainpage'));
+ $nav_urls['randompage'] = array('href' => $this->makeSpecialUrl('Randompage'));
+ $nav_urls['recentchanges'] = array('href' => $this->makeSpecialUrl('Recentchanges'));
+ $nav_urls['currentevents'] = (wfMsg('currentevents') != '-') ? array('href' => $this->makeI18nUrl('currentevents')) : false;
+ $nav_urls['portal'] = (wfMsg('portal') != '-') ? array('href' => $this->makeI18nUrl('portal-url')) : false;
+ $nav_urls['bugreports'] = array('href' => $this->makeI18nUrl('bugreportspage'));
+ // $nav_urls['sitesupport'] = array('href' => $this->makeI18nUrl('sitesupportpage'));
+ $nav_urls['sitesupport'] = array('href' => $wgSiteSupportPage);
+ $nav_urls['help'] = array('href' => $this->makeI18nUrl('helppage'));
if( $this->loggedin && !$wgDisableUploads ) {
- $nav_urls['upload'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Upload')));
+ $nav_urls['upload'] = array('href' => $this->makeSpecialUrl('Upload'));
} else {
$nav_urls['upload'] = false;
}
- $nav_urls['specialpages'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Specialpages')));
+ $nav_urls['specialpages'] = array('href' => $this->makeSpecialUrl('Specialpages'));
if( $wgTitle->getNamespace() != NS_SPECIAL) {
- $nav_urls['whatlinkshere'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Whatlinkshere', 'target='.urlencode( $this->thispage ))));
- $nav_urls['recentchangeslinked'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Recentchangeslinked', 'target='.urlencode( $this->thispage ))));
+ $nav_urls['whatlinkshere'] = array('href' => $this->makeSpecialUrl('Whatlinkshere', 'target='.urlencode( $this->thispage)));
+ $nav_urls['recentchangeslinked'] = array('href' => $this->makeSpecialUrl('Recentchangeslinked', 'target='.urlencode( $this->thispage)));
}
if( $wgTitle->getNamespace() == NS_USER || $wgTitle->getNamespace() == NS_USER_TALK ) {
if($id || $ip) { # both anons and non-anons have contri list
$nav_urls['contributions'] = array(
- 'href' => htmlspecialchars( $this->makeSpecialUrl('Contributions', "target=" . $wgTitle->getPartialURL() ) )
+ 'href' => $this->makeSpecialUrl('Contributions', "target=" . $wgTitle->getPartialURL() )
);
} else {
$nav_urls['contributions'] = false;
if ( 0 != $wgUser->getID() ) { # show only to signed in users
if($id) { # can only email non-anons
$nav_urls['emailuser'] = array(
- 'href' => htmlspecialchars( $this->makeSpecialUrl('Emailuser', "target=" . $wgTitle->getPartialURL() ) )
+ 'href' => $this->makeSpecialUrl('Emailuser', "target=" . $wgTitle->getPartialURL() )
);
}
}
$this->userjs = $this->makeUrl($this->userpage.'/'.$this->skinname.'.js', 'action=raw&ctype=text/javascript&dontcountme=s');
}
}
+ $this->usercss = '/*<![CDATA[*/ ' . $this->usercss . ' /*]]>*/';
+ if( $this->userjsprev ) {
+ $this->userjsprev = '/*<![CDATA[*/ ' . $this->userjsprev . ' /*]]>*/';
+ }
}
/**