From: Brion Vibber Date: Thu, 11 Sep 2003 12:21:03 +0000 (+0000) Subject: Initial attempt at using Smarty templates based on Tarquin's Paddington and Montparna... X-Git-Tag: 1.1.0~281 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=b1b8b5597b3a658925d870a65e0f12b599db7486;p=lhc%2Fweb%2Fwiklou.git Initial attempt at using Smarty templates based on Tarquin's Paddington and Montparnasse demo templates --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index f43d8d4962..f5b464cf73 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -239,10 +239,8 @@ class OutputPage { { global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration; global $wgInputEncoding, $wgOutputEncoding, $wgLanguageCode; - wfProfileIn( "OutputPage::output" ); $sk = $wgUser->getSkin(); - wfProfileIn( "OutputPage::output-headers" ); $this->sendCacheControl(); header( "Content-type: text/html; charset={$wgOutputEncoding}" ); @@ -250,7 +248,6 @@ class OutputPage { if ( "" != $this->mRedirect ) { header( "Location: {$this->mRedirect}" ); - wfProfileOut(); return; } @@ -258,36 +255,8 @@ class OutputPage { foreach( $this->mCookies as $name => $val ) { setcookie( $name, $val, $exp, "/" ); } - wfProfileOut(); - - wfProfileIn( "OutputPage::output-middle" ); - $sk->initPage(); - $this->out( $this->headElement() ); - - $this->out( "\ngetBodyOptions(); - foreach ( $ops as $name => $val ) { - $this->out( " $name='$val'" ); - } - $this->out( ">\n" ); - if ( $wgDebugComments ) { - $this->out( "\n" ); - } - $this->out( $sk->beforeContent() ); - wfProfileOut(); - - wfProfileIn( "OutputPage::output-bodytext" ); - $this->out( $this->mBodytext ); - wfProfileOut(); - wfProfileIn( "OutputPage::output-after" ); - $this->out( $sk->afterContent() ); - wfProfileOut(); - - wfProfileOut(); # A hack - we can't report after here - $this->out( $this->reportTime() ); - $this->out( "\n" ); + $sk->outputPage( $this ); flush(); } diff --git a/includes/Skin.php b/includes/Skin.php index 957687024f..dc6886cced 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -6,7 +6,7 @@ # Language class has internationalized names # /* private */ $wgValidSkinNames = array( - "Standard", "Nostalgia", "CologneBlue" + "Standard", "Nostalgia", "CologneBlue", "Smarty", "Montparnasse" ); # For some odd PHP bug, this function can't be part of a class @@ -78,6 +78,33 @@ class Skin { $wgOut->addLink( "stylesheet", "", "{$wgStyleSheetPath}/{$ss}" ); wfProfileOut(); } + + function outputPage( &$out ) { + $this->initPage(); + $out->out( $out->headElement() ); + + $out->out( "\ngetBodyOptions(); + foreach ( $ops as $name => $val ) { + $out->out( " $name='$val'" ); + } + $out->out( ">\n" ); + if ( $wgDebugComments ) { + $out->out( "\n" ); + } + $out->out( $this->beforeContent() ); + + $out->out( $out->mBodytext ); + + $out->out( $this->afterContent() ); + wfProfileOut(); + + wfProfileOut(); # A hack - we can't report after here + $out->out( $out->reportTime() ); + + $out->out( "\n" ); + } function getHeadScripts() { global $wgStyleSheetPath; @@ -1785,5 +1812,6 @@ if ( isset ( $wgUseApproval ) && $wgUseApproval ) include_once( "SkinStandard.php" ); include_once( "SkinNostalgia.php" ); include_once( "SkinCologneBlue.php" ); +include_once( "SkinSmarty.php" ); ?> diff --git a/includes/SkinSmarty.php b/includes/SkinSmarty.php new file mode 100644 index 0000000000..7033ab5be7 --- /dev/null +++ b/includes/SkinSmarty.php @@ -0,0 +1,204 @@ +template = "paddington"; + } + + function outputPage( &$out ) { + global $wgTitle, $wgArticle, $wgUser, $wgLang; + global $wgScriptPath, $wgStyleSheetPath, $wgLanguageCode; + + $this->initPage(); + + $smarty = new Smarty(); + $smarty->register_function( "wikimsg", + array( &$this,"smarty_function_wikimsg" ), true ); + $smarty->register_function( "wikilink", + array( &$this, "smarty_function_wikilink" ) ); + + $smarty->assign( "title", $wgTitle->getPrefixedText() ); // ? + $smarty->assign( "thispage", $wgTitle->getPrefixedDbKey() ); + $smarty->assign( "subtitle", $out->getSubtitle() ); + + $smarty->assign( "editable", ($wgTitle->getNamespace != Namespace::getSpecial() ) ); + $smarty->assign( "exists", $wgTitle->getArticleID() != 0 ); + $smarty->assign( "watch", $wgTitle->userIsWatching() ? "unwatch" : "watch" ); + $smarty->assign( "protect", count($wgTitle->getRestrictions()) ? "unprotect" : "protect" ); + + $smarty->assign( "searchaction", $wgScriptPath ); + $smarty->assign( "stylepath", $wgStyleSheetPath ); + $smarty->assign( "lang", $wgLanguageCode ); + $smarty->assign( "langname", $wgLang->getLanguageName( $wgLanguageCode ) ); + + $smarty->assign( "username", $wgUser->getName() ); + $smarty->assign( "userpage", $wgLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName() ); + $smarty->assign( "loggedin", $wgUser->getID() != 0 ); + $smarty->assign( "sysop", $wgUser->isSysop() ); + if( $wgUser->getNewtalk() ) { + $ntl = wfMsg( "newmessages", + $this->makeKnownLink( + $wgLang->getNsText( Namespace::getTalk( Namespace::getUser() ) ) + . ":" . $wgUser->getName(), + wfMsg("newmessageslink") + ) + ); + } else { + $ntl = ""; + } + $smarty->assign( "newtalk", $ntl ); + + $smarty->assign( "logo", $this->logoText() ); + $smarty->assign( "pagestats", $this->pageStats() ); + $smarty->assign( "otherlanguages", $this->otherLanguages() ); + + $smarty->assign( "debug", $out->mDebugtext ); + $smarty->assign( "reporttime", $out->reportTime() ); + + $smarty->assign( "bodytext", $out->mBodytext ); + + $smarty->display( $this->template . ".tpl" ); + } + + function smarty_function_wikimsg( $params, &$smarty ) { + return wfMsg( $params['key'] ); + } + + function smarty_function_wikilink( $params, &$smarty ) { + global $wgLang; + $action = ""; + $popup = ""; + $page = ""; + + if($params['action']) $action = "action=" . $params['action']; + + if($params['special']) { + $page = $wgLang->specialPage( $params['special'] ); + #$text = $wgLang->getSpecialPageName( $params['special'] ); + $text = $popup = $params['special']; + if($params['target']) $action .= "target=" . urlencode( $params['target'] ); + } else { + if( $params['keypage'] ) + $title = Title::newFromText( wfMsg( $params['keypage'] ) ); + else + $title = Title::newFromText( $params['name'] ); + if(isset($params["talk"])) { + $title = Title::makeTitle( $title->getNamespace() ^ 1, $title->getDbKey() ); + } + $text = $popup = $title->getPrefixedText(); + $page = urlencode( $title->getPrefixedUrl() ); + } + + $url = wfLocalUrlE( $page, $action ); + + if($params['text']) $text = $params['text']; + if($params['key']) $text = wfMsg( $params['key'] ); + if($popup) $popup = ' title="' . htmlspecialchars( $popup ) . '"'; + + return "$text"; + } + +/* + function Skin() + function getSkinNames() + function getStylesheet() + + function qbSetting() + function initPage() + function getHeadScripts() { + function getUserStyles() + function doGetUserStyles() + function getBodyOptions() + function getExternalLinkAttributes( $link, $text ) + function getInternalLinkAttributes( $link, $text, $broken = false ) + + function getLogo() + function beforeContent() + function doBeforeContent() + function getQuickbarCompensator( $rows = 1 ) + function afterContent() + function doAfterContent() + function pageTitleLinks() + function printableLink() + function pageTitle() + function pageSubtitle() + function nameAndLogin() + function searchForm() + function topLinks() + function bottomLinks() + function pageStats() + function lastModified() + function logoText( $align = "" ) + function quickBar() + function specialPagesList() + function mainPageLink() + function copyrightLink() + function aboutLink() + function editThisPage() + function deleteThisPage() + function protectThisPage() + function watchThisPage() + function moveThisPage() + function historyLink() + function whatLinksHere() + function userContribsLink() + function emailUserLink() + function watchPageLinksLink() + function otherLanguages() + function bugReportsLink() + function dateLink() + function talkLink() + function transformContent( $text ) + + function makeLink( $title, $text= "", $query = "", $trail = "" ) + function makeKnownLink( $title, $text = "", $query = "", $trail = "" ) + function makeBrokenLink( $title, $text = "", $query = "", $trail = "" ) + function makeStubLink( $title, $text = "", $query = "", $trail = "" ) + function fnamePart( $url ) + function makeImage( $url, $alt = "" ) + function makeImageLink( $name, $url, $alt = "" ) + function makeMediaLink( $name, $url, $alt = "" ) + function specialLink( $name, $key = "" ) + + function beginHistoryList() + function beginImageHistoryList() + function endRecentChangesList() + function endHistoryList() + function endImageHistoryList() + function historyLine( $ts, $u, $ut, $ns, $ttl, $oid, $c, $isminor ) + function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c ) + + + function beginRecentChangesList() + function recentChangesBlockLine ( $y ) { + function recentChangesBlockGroup ( $y ) { + function recentChangesBlock () + function recentChangesLine( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 ) + function recentChangesLineOld( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0, $diffid = 0 ) + function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 ) + + function tocIndent($level) { + function tocUnindent($level) { + function tocLine($anchor,$tocline,$level) { + function tocTable($toc) { + function editSectionScript($section,$head) { + function editSectionLink($section) { +*/ + +} + +class SkinMontparnasse extends SkinSmarty { + function initPage() { + SkinSmarty::initPage(); + $this->template = "montparnasse"; + } +} + +?> diff --git a/languages/Language.php b/languages/Language.php index 1ce22c1270..44cff95cc7 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -66,7 +66,7 @@ define("MAG_CURRENTMONTHNAMEGEN", 10); ); /* private */ $wgSkinNamesEn = array( - "Standard", "Nostalgia", "Cologne Blue" + "Standard", "Nostalgia", "Cologne Blue", "Paddington", "Montparnasse" ); /* private */ $wgMathNamesEn = array( diff --git a/stylesheets/montparnasse.css b/stylesheets/montparnasse.css new file mode 100644 index 0000000000..16b7c4eac1 --- /dev/null +++ b/stylesheets/montparnasse.css @@ -0,0 +1,152 @@ +body.encyclopedia { background: white; } +body.meta { background: #ffffdd; } +body { + margin: 0px; + padding:0px; + } +/* ================= masthead */ +#topbar { + background: #6688AA; /* from ColBlue */ + background: #8ad; /* light blue */ + color:white; + color:#fff; + border:none; /* for NN4 */ + width:100%; + margin: 0px; + } + +#topbar h1 { + font-size: 160%; + margin: 0px; + padding:1px 2px; + } +#topbar h1 span { + font-size: 65%; + } +#topbar span#alert { + color:#f08; + font-weight:bold; + } +#topbar div { + background: #ddd; + font-size: 90%; + color:black; + padding:1px; +} +#topbar div a { + text-decoration:none; +} +#topbar div a:hover { + text-decoration:underline; +} + +/* ================= article */ +#article { + padding:0.5em; + margin-left:0.5em; + margin-right:15em; /* sidebar margin */ +} +h1.pagetitle { + font-size: 150%; + padding-top: 0; margin-top: 0; padding-bottom: 0; margin-bottom: 0; + } +p.subtitle , p.languages , p.actions { + padding: 0em 1em; + margin: 0em ; + font-size: 90%; + color:#723; + } +/* ================= sidebar */ +#main { + position:relative; + /* only needed if sidebar sits below masthead */ +} + +#sidebar { + position:absolute; + top:0px; + right:0px; + width:11em; + padding:0.5em; +} +#dummylogo { + width:100px; + height:100px; + background: #ddd; + margin:0px auto; + font-size:75%; + +} +#sidebar h2 { + margin: 4px 0px 0px; + padding: 0px 0.5em; + font-size:100%; + background: #8ad; + color:white; + } +#sidebar div { + border: solid 2px #8ad; + padding: 0.5em ; + margin: 0em ; + font-size: 90%; + background: #def; +} +#sidebar #search { + text-align:center; +} +#sidebar #dummylogo { + margin:0px auto ; + width:100px; + height:100px; + background: #eee; +} + +/* ================= footer */ +#footer { + padding:2px; + margin-left:0.5em; + margin-right:12em; /* sidebar margin */ + /* + border-top: solid 2px #8ad; /* light blue */; + +} +#footer div { + + border: solid 2px #8ad; + padding: 0.5em ; + margin: 0em ; + font-size: 90%; + background: #def; + +} +#footer h2 { + margin: 4px 0px 0px; + padding: 0px 0.5em; + font-size:100%; + background: #8ad; + color:white; +} +#footer #pagestats { + margin: 4px 0px 0px; + background: #8ad; + color:white; + font-weight:bold; +} + +/* ================= hacks */ + /* Feed these styles only to NS4.... */ + /*/*/ /*/ + h1.pagetitle { + margin-top: -30px; + color:red; + } + p.actions { + margin-top: -20px; + } + /* Okay, we can let the others back in.... */ + + + + + + diff --git a/stylesheets/paddington.css b/stylesheets/paddington.css new file mode 100644 index 0000000000..ee456f848a --- /dev/null +++ b/stylesheets/paddington.css @@ -0,0 +1,122 @@ +body.encyclopedia { background: white } +body.meta { background: #ffffdd } +body { + margin: 0px; + padding:0px; + } +form.inline { + display: inline; + } + +/* borders */ +/* +#topbar h1, #topbar div.navbox { + border-bottom:solid grey 1px; +} +*/ + +/* ********************************** TOPBAR */ +#topbar { + border-bottom: solid 1px black; + +} +/* common to all 3 topbar blocks */ +#topbar h1, #topbar div.navbox { + /* + background-color: #eef; + background-color: #f8f8f8; + */ + padding: 0px 4px; + margin: 0px; + /* + border-bottom:solid white 2px; + border-bottom:solid grey 1px; + */ + } +#topbar h1 { + font-size: 2.2em; + } +#topbar h1 span { + font-size: 0.6em; + color:#aaa; + } +div.navbox { + font-size:0.9em; + } +#topbar div#navboxsubtitle { + } +#topbar div#sitelinks { + padding-bottom: 2px; +} + +div.spacer { + clear:both; +} + +div.row span.left { + float: left; + text-align: left; + width: 49%; + } + +div.row span.right { + float: right; + text-align: right; + width: 49%; + } + +/* ********************************* CONTENT */ +#content { + top: 0px; + margin: 0px; + /* + padding: 0px 5px 0px ; + position:relative; + */ + } +h1.pagetitle { + padding-top: 0; margin-top: 0; padding-bottom: 0; margin-bottom: 0; + font-size: 2em; + + } +p.subtitle , p.languages , p.actions { + padding: 0em 1em; + margin: 0em ; + font-size: 0.9em; + color:#723; + } +p.languages { + font-style: italic; + } + +#article { + padding: 0px 4px; +} + +/* ********************************* quickbar */ +#quickbar-left , #quickbar-right { + position: absolute; + top: 0px; + bottom:0px; + width: 148px; + padding: 0px; + visibility: visible; + z-index: 99; + } +#quickbar-left { + left: 0px; + border-right:1px solid black; + } +#quickbar-right { + right: 0px; + border-left:1px solid black; + } +.quickbarsection { + padding: 6px; + border-bottom:1px solid black; +} +/* ********************************** QUICKBAR DEPENDENCIES */ +#content { + margin-left: 148px; + } + diff --git a/templates/montparnasse.tpl b/templates/montparnasse.tpl new file mode 100644 index 0000000000..4ebf95bf0b --- /dev/null +++ b/templates/montparnasse.tpl @@ -0,0 +1,112 @@ + + +{$title|escape:"html"} + + +{if $favicon}{/if} + + + + +
+ + +
+

{wikimsg key="sitetitle"} - {wikimsg key="sitesubtitle"} - {$langname}

+ +
{wikilink keypage="mainpage"} - + {wikilink special="Recentchanges"} - + {wikilink special="Randompage"} - + {wikilink keypage="currentevents"} - + {if $loggedin}{wikilink special="Userlogout"}{else}{wikilink special="Userlogin"}{/if} + {if $newtalk}- {$newtalk}{/if}
+
+ + +
+
+

{$title|escape:"html"}

+

{wikilink name=$thispage printable=true key="printable"} + {if $editable} + | {wikilink name=$thispage action="edit" key=$editpage} + {if $exists}| {wikilink name=$thispage action="history" key="pagehistory"}{/if} + {/if}

+ +{$bodytext} + +
+ + +
+ + + + diff --git a/templates/paddington.tpl b/templates/paddington.tpl new file mode 100644 index 0000000000..a21dea069c --- /dev/null +++ b/templates/paddington.tpl @@ -0,0 +1,125 @@ + + + +{$title|escape:"html"} + + +{if $favicon}{/if} + + + + + +
+ + + +
+

{wikimsg key="sitetitle"} {$langname}

+
+ + + + + +
+ + +
+

{$title|escape:"html"}

+ +

{$subtitle}

+ +

{wikilink name=$thispage printable=true key="printable"} | + {if $editable} + {wikilink name=$title action="edit" key=$editpage} + {if $exists} | {wikilink name=$title action="history" key="history"}{/if} + {/if}

+ +

{wikimsg key="otherlanguages"} {$langlist}

+ + +{$bodytext} + +
+ +
+{$pagestats} +
+ +
+ + + +
+
+ {$logo} +
+
+ {wikilink keypage="mainpage"} +
{wikilink special="Recentchanges"} +
{wikilink special="Random"} + {if $loggedin}
{wikilink special="Watchlist"}{/if} +
{wikilink special="Contributions" target=$username} +
{wikilink keypage="currentevents"} +
+{if $editable}
+ {wikilink name=$thispage action="edit" key=$editpage} + {if $loggedin} +
{wikilink name=$thispage action="watch" key=$watchpage} + {if $exists} +
{wikilink special="Movepage" target=$thispage} + {if $sysop} +
{wikilink name=$thispage action="delete" key="deletepage"} +
{wikilink name=$thispage action=$protect key=$protect} + {/if} + {/if} + {/if} +
{wikilink name=$thispage talk=true key=$talkpage} + {if $exists}
{wikilink name=$thispage action="history" key="history"}{/if} +
{wikilink special="Whatlinkshere" target=$thispage} +
{wikilink special="Recentchangeslinked" target=$thispage} +
{/if} +
+ {if $loggedin}{wikilink special="Upload"} +
{/if}{wikilink special="Specialpages"} +
{wikilink keypage="bugreports"} +
+
+ + +