var $mHeaders, $mCookies, $mMetatags, $mKeywords;
var $mLinktags, $mPagetitle, $mBodytext, $mDebugtext;
var $mHTMLtitle, $mRobotpolicy, $mIsarticle, $mPrintable;
- var $mSubtitle, $mRedirect, $mHeadtext;
+ var $mSubtitle, $mRedirect;
var $mLastModified, $mCategoryLinks;
+ var $mScripts;
var $mSuppressQuickbar;
var $mOnloadHandler;
$this->mContainsOldMagic = $this->mContainsNewMagic = 0;
$this->mParserOptions = ParserOptions::newFromUser( $temp = NULL );
$this->mSquidMaxage = 0;
+ $this->mScripts = "";
}
function addHeader( $name, $val ) { array_push( $this->mHeaders, "$name: $val" ) ; }
# To add an http-equiv meta tag, precede the name with "http:"
function addMeta( $name, $val ) { array_push( $this->mMetatags, array( $name, $val ) ); }
function addKeyword( $text ) { array_push( $this->mKeywords, $text ); }
+ function addScript( $script ) { $this->mScripts .= $script; }
+ function getScript() { return $this->mScripts; }
function addLink( $linkarr ) {
# $linkarr should be an associative array of attributes. We'll escape on output.
function isQuickbarSuppressed() { return $this->mSuppressQuickbar; }
function addHTML( $text ) { $this->mBodytext .= $text; }
- function addHeadtext( $text ) { $this->mHeadtext .= $text; }
function debug( $text ) { $this->mDebugtext .= $text; }
function setParserOptions( $options )
$sk = $wgUser->getSkin();
$ret .= $sk->getHeadScripts();
+ $ret .= $this->mScripts;
$ret .= $sk->getUserStyles();
$ret .= "</head>\n";
<?php
+require_once( "CardSet.php" );
+require_once( "TabbedCardSet.php" );
function wfSpecialPreferences()
{
. "id=\"$tname\" name=\"wpOp$tname\"$checked /><label for=\"$tname\">$ttext</label></div>\n";
}
+
/* private */ function mainPrefsForm( $err )
{
global $wgUser, $wgOut, $wgLang, $wgUseDynamicDates, $wgValidSkinNames;
+
+ $skin = $wgUser->getSkin();
+ $cardset = $skin->newCardSet( wfMsg( "preferences" ) );
$wgOut->setPageTitle( wfMsg( "preferences" ) );
$wgOut->setArticleRelated( false );
$titleObj = Title::makeTitle( NS_SPECIAL, "Preferences" );
$action = $titleObj->escapeLocalURL();
- $qb = wfMsg( "qbsettings" );
$cp = wfMsg( "changepassword" );
- $sk = wfMsg( "skin" );
- $math = wfMsg( "math" );
- $dateFormat = wfMsg("dateformat");
$opw = wfMsg( "oldpassword" );
$npw = wfMsg( "newpassword" );
$rpw = wfMsg( "retypenew" );
$svp = wfMsg( "saveprefs" );
$rsp = wfMsg( "resetprefs" );
- $tbs = wfMsg( "textboxsize" );
$tbr = wfMsg( "rows" );
$tbc = wfMsg( "columns" );
$ltz = wfMsg( "localtime" );
$emf = wfMsg( "emailflag" );
$ynn = wfMsg( "yournick" );
$stt = wfMsg ( "stubthreshold" ) ;
- $srh = wfMsg( "searchresultshead" );
$rpp = wfMsg( "resultsperpage" );
$scl = wfMsg( "contextlines" );
$scc = wfMsg( "contextchars" );
$rcc = wfMsg( "recentchangescount" );
- $dsn = wfMsg( "defaultns" );
$wgOut->addHTML( "<form id=\"preferences\" name=\"preferences\" action=\"$action\"
method=\"post\">" );
+ ######################################################################
# First section: identity
# Email, etc.
#
if ( $this->mEmailFlag ) { $emfc = 'checked="checked"'; }
else { $emfc = ""; }
- $ps = $this->namespacesCheckboxes();
-
- $wgOut->addHTML( "<fieldset>
- <legend>Idento</legend>
- <div><label>$yrn: <input type='text' name=\"wpRealName\" value=\"{$this->mRealName}\" size='20' /></label></div>
- <div><label>$yem: <input type='text' name=\"wpUserEmail\" value=\"{$this->mUserEmail}\" size='20' /></label></div>
- <div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" /> $emf</label></div>
- <div><label>$ynn: <input type='text' name=\"wpNick\" value=\"{$this->mNick}\" size='12' /></label></div>\n" );
-
# Fields for changing password
#
$this->mOldpass = wfEscapeHTML( $this->mOldpass );
$this->mNewpass = wfEscapeHTML( $this->mNewpass );
$this->mRetypePass = wfEscapeHTML( $this->mRetypePass );
- $wgOut->addHTML( "<fieldset>
+ $cardset->addCard( "Idento", "<div><label>$yrn: <input type='text' name=\"wpRealName\" value=\"{$this->mRealName}\" size='20' /></label></div>
+ <div><label>$yem: <input type='text' name=\"wpUserEmail\" value=\"{$this->mUserEmail}\" size='20' /></label></div>
+ <div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" /> $emf</label></div>
+ <div><label>$ynn: <input type='text' name=\"wpNick\" value=\"{$this->mNick}\" size='12' /></label></div>
+ <fieldset>
<legend>$cp:</legend>
<div><label>$opw: <input type='password' name=\"wpOldpass\" value=\"{$this->mOldpass}\" size='20' /></label></div>
<div><label>$npw: <input type='password' name=\"wpNewpass\" value=\"{$this->mNewpass}\" size='20' /></label></div>
<div><label>$rpw: <input type='password' name=\"wpRetypePass\" value=\"{$this->mRetypePass}\" size='20' /></label></div>
" . $this->getToggle( "rememberpassword" ) . "
- </fieldset>\n</fieldset>\n" );
+ </fieldset>");
+ ######################################################################
# Quickbar setting
#
- $wgOut->addHtml( "<fieldset>\n<legend>$qb:</legend>\n" );
+ $s="";
for ( $i = 0; $i < count( $qbs ); ++$i ) {
if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; }
else { $checked = ""; }
- $wgOut->addHTML( "<div><label><input type='radio' name=\"wpQuickbar\"
- value=\"$i\"$checked /> {$qbs[$i]}</label></div>\n" );
+ $s .= "<div><label><input type='radio' name=\"wpQuickbar\" value=\"$i\"$checked /> {$qbs[$i]}</label></div>\n";
}
- $wgOut->addHtml( "</fieldset>\n\n" );
+ $cardset->addCard( wfMsg( "qbsettings" ), $s );
+
+ ######################################################################
# Skin setting
#
- $wgOut->addHTML( "<fieldset>\n<legend>$sk:</legend>\n" );
# Only show members of $wgValidSkinNames rather than
# $skinNames (skins is all skin names from Language.php)
+ $s="";
foreach ($wgValidSkinNames as $skinkey => $skinname ) {
if ( $skinkey == $this->mSkin ) {
$checked = ' checked="checked"';
} else {
$checked = "";
}
- $wgOut->addHTML( "<div><label><input type='radio' name=\"wpSkin\"
- value=\"$skinkey\"$checked /> {$skinNames[$skinkey]}</label></div>\n" );
+ $s .= "<div><label><input type='radio' name=\"wpSkin\" value=\"$skinkey\"$checked /> {$skinNames[$skinkey]}</label></div>\n";
}
- $wgOut->addHTML( "</fieldset>\n\n" );
+ $cardset->addCard( wfMsg( "skin" ), $s );
+ ######################################################################
# Math setting
#
- $wgOut->addHTML( "<fieldset>\n<legend>$math:</legend>\n" );
+ $s="";
for ( $i = 0; $i < count( $mathopts ); ++$i ) {
if ( $i == $this->mMath ) { $checked = ' checked="checked"'; }
else { $checked = ""; }
- $wgOut->addHTML( "<div><label><input type='radio' name=\"wpMath\"
- value=\"$i\"$checked /> {$mathopts[$i]}</label></div>\n" );
+ $s .= "<div><label><input type='radio' name=\"wpMath\" value=\"$i\"$checked /> {$mathopts[$i]}</label></div>\n";
}
- $wgOut->addHTML( "</fieldset>\n\n" );
+ $cardset->addCard( wfMsg( "math" ), $s );
+ ######################################################################
# Date format
#
if ( $wgUseDynamicDates ) {
- $wgOut->addHTML( "<fieldset>\n<legend>$dateFormat:</legend>\n" );
+ $s="";
for ( $i = 0; $i < count( $dateopts ); ++$i) {
if ( $i == $this->mDate ) {
$checked = ' checked="checked"';
} else {
$checked = "";
}
- $wgOut->addHTML( "<div><label><input type='radio' name=\"wpDate\" ".
- "value=\"$i\"$checked /> {$dateopts[$i]}</label></div>\n" );
+ $s .= "<div><label><input type='radio' name=\"wpDate\" value=\"$i\"$checked /> {$dateopts[$i]}</label></div>\n" ;
}
- $wgOut->addHTML( "</fieldset>\n\n");
+ $cardset->addCard( wfMsg("dateformat"), $s );
}
+ ######################################################################
# Textbox rows, cols
#
$nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
$nowserver = $wgLang->time( $now, false );
- $wgOut->addHTML( "<fieldset>
- <legend>$tbs:</legend>\n
- <div>
+ $cardset->addCard( wfMsg( "textboxsize" ), "<div>
<label>$tbr: <input type='text' name=\"wpRows\" value=\"{$this->mRows}\" size='6' /></label>
<label>$tbc: <input type='text' name=\"wpCols\" value=\"{$this->mCols}\" size='6' /></label>
- </div> " .
- $this->getToggle( "editwidth" ) .
- $this->getToggle( "showtoolbar" ) .
- $this->getToggle( "previewontop" ) .
- $this->getToggle( "watchdefault" ) .
- $this->getToggle( "minordefault" ) . "
- </fieldset>
-
- <fieldset>
- <legend>$dateFormat:</legend>
- <div><b>$tzServerTime:</b> $nowserver</div>
- <div><b>$ltz:</b> $nowlocal</div>
- <div><label>$tzo*: <input type='text' name=\"wpHourDiff\" value=\"{$this->mHourDiff}\" size='6' /></label></div>
- <div><input type=\"button\" value=\"$tzGuess\" onClick=\"javascript:guessTimezone()\" /></div>
- </fieldset>\n\n" );
+ </div> " .
+ $this->getToggle( "editwidth" ) .
+ $this->getToggle( "showtoolbar" ) .
+ $this->getToggle( "previewontop" ) .
+ $this->getToggle( "watchdefault" ) .
+ $this->getToggle( "minordefault" ) );
+
+ $cardset->addCard( wfMsg( "dateformat" ), "<div><b>$tzServerTime:</b> $nowserver</div>
+ <div><b>$ltz:</b> $nowlocal</div>
+ <div><label>$tzo*: <input type='text' name=\"wpHourDiff\" value=\"{$this->mHourDiff}\" size='6' /></label></div>
+ <div><input type=\"button\" value=\"$tzGuess\" onClick=\"javascript:guessTimezone()\" /></div>" );
+
+ $cardset->addCard( wfMsg( "recentchangescount" ),
+ "<div><label>$rcc: <input type='text' name=\"wpRecent\" value=\"$this->mRecent\" size='6' /></label></div>
+ " . $this->getToggle( "hideminor" ) .
+ $this->getToggle( "usenewrc" ) . "
+ <div><label>$stt: <input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' /></label></div>" );
+
+ $cardset->addCard( wfMsg( "searchresultshead" ), "
+ <div><label>$rpp: <input type='text' name=\"wpSearch\" value=\"$this->mSearch\" size='6' /></label></div>
+ <div><label>$scl: <input type='text' name=\"wpSearchLines\" value=\"$this->mSearchLines\" size='6' /></label></div>
+ <div><label>$scc: <input type='text' name=\"wpSearchChars\" value=\"$this->mSearchChars\" size='6' /></label></div>
+ <div><fieldset><legend>" . wfMsg( "defaultns" ) . "</legend>\n" . $this->namespacesCheckboxes() . "</fieldset></div>" );
- $wgOut->addHTML( "
- <fieldset>
- <div><label>$rcc: <input type='text' name=\"wpRecent\" value=\"$this->mRecent\" size='6' /></label></div>
- " . $this->getToggle( "hideminor" ) .
- $this->getToggle( "usenewrc" ) . "
- <div><label>$stt: <input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' /></label></div>
- </fieldset>
-
- <fieldset>
- <legend>$srh</legend>
- <div><label>$rpp: <input type='text' name=\"wpSearch\" value=\"$this->mSearch\" size='6' /></label></div>
- <div><label>$scl: <input type='text' name=\"wpSearchLines\" value=\"$this->mSearchLines\" size='6' /></label></div>
- <div><label>$scc: <input type='text' name=\"wpSearchChars\" value=\"$this->mSearchChars\" size='6' /></label></div>
-
- <fieldset>
- <legend>$dsn</legend>
- $ps
- </fieldset>
- </fieldset>
- " );
+ ######################################################################
# Various checkbox options
#
- $wgOut->addHTML("<fieldset>");
+ $s="";
foreach ( $togs as $tname => $ttext ) {
if( !array_key_exists( $tname, $this->mUsedToggles ) ) {
- $wgOut->addHTML( $this->getToggle( $tname ) );
+ $s .= $this->getToggle( $tname ) ;
}
}
- $wgOut->addHTML( "</fieldset>\n\n" );
+ $cardset->addCard( wfMsg("misc"), $s );
+
+ $cardset->renderToOutpage( $wgOut );
$wgOut->addHTML( "
<div>
--- /dev/null
+<?php
+// CardSet is a widget for displaying a stack of cards, e.g. for
+// user preferences. It is skinnable by overloading.
+// Default CardSet uses fieldsets for the cards,
+// the derived class TabbedCardSet uses JavaScript-based tabs
+//
+// Usage:
+// First, create a CardSet using the constructor
+// Then, add cards to it
+// Finally Render to get the HTML
+
+class TabbedCardSet extends CardSet {
+
+ // Return the HTML of this CardSet
+ function renderToOutpage( &$out )
+ {
+ $s = "<div id=\"column-content\"><div id=\"content\">\n";
+
+ for ( $i=0; $i<count( $this->mLabels ); $i++ )
+ {
+ $s .= "<div class=\"usage\" id=\"area{$i}\"><div id=\"subheading{$i}\"><h2><a name=\"card{$i}\"></a>".
+ $this->mLabels[$i] . "</h2></div>" . $this->mBodies[$i] . "</div>\n\n";
+ }
+ $s .= "</div></div>\n\n<div id=\"bar\"><div id=\"p-cactions\" class=\"portlet\">\n<ul>\n";
+
+ for ( $i=0; $i<count( $this->mLabels ); $i++ )
+ {
+ $selected = ($i==0 ? "class=\"selected\"" : "");
+ $s .= "<li id=\"tab{$i}\" {$selected} onclick=\"chgArea({$i},this);\"
+ onmouseover=\"hilight({$i});\" onmouseout=\"if(prev!={$i}){hilight(this,-1);}\"><a href=\"#card{$i}\">".
+ $this->mLabels[$i] . "</a></li>";
+ }
+
+ $s .= "</ul></div></div>\n\n";
+
+ $out->addScript("
+ <script>
+ var elements=". count( $this->mLabels ) .";
+ var prev=-1;
+
+ function hideall(){
+ for(i=0; i<elements; i++){document.getElementById('area'+i).style.display='none';}
+ document.getElementById('bar').style.display='inline';
+ }
+
+ function chgArea(n,obj){
+ if(prev>=0){
+ hilight( document.getElementById('tab'+prev) , -1);
+ document.getElementById('area'+prev).style.display='none';
+ }
+ hilight(obj,n);
+
+ document.getElementById('area'+n).style.display='inline';
+ prev=n ;
+ }
+
+ function hilight(obj,n){
+ if (n<0) { obj.className=\"\"; }
+ else { obj.className=\"selected\"; }
+ }
+ function inittabs(){
+ hideall();
+ chgArea(0,document.getElementById('tab0'));
+ }
+ </script>
+ " );
+
+ $out->setOnloadHandler( $out->getOnloadHandler() . "inittabs();" );
+ $out->addHTML( $s );
+ }
+
+} // end of: class CardSet
+
+?>