From 5c06784a8192604df97fd9d01f1d0e05bcc669fe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Tue, 11 Apr 2006 14:32:23 +0000 Subject: [PATCH] * Cleaned SpecialContributions a bit and separated some messages See 4777 and 5310 --- RELEASE-NOTES | 2 +- includes/SpecialContributions.php | 226 ++++++++++++++++-------------- languages/Messages.php | 8 +- languages/MessagesFi.php | 7 +- 4 files changed, 131 insertions(+), 112 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 917c93e592..fa9d1e0358 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -45,7 +45,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN (moved outside the parser cache) * Optional {{DISPLAYTITLE|title with markup}} magic word Deactivated by default, set "$wgAllowDisplayTitle = true" in LocalSettings.php to activate - +* Cleaned SpecialContributions a bit == Compatibility == diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index d13b30d87d..c44e97ee1c 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -113,12 +113,11 @@ class contribs_finder { } /* private */ function make_sql() { - $userCond = $condition = $index = $offsetQuery = $limitQuery = ""; + $userCond = $condition = $index = $offsetQuery = ''; extract($this->dbr->tableNames('page', 'revision')); list($index, $userCond) = $this->get_user_cond(); - $limitQuery = 'LIMIT '.$this->limit; if ($this->offset) $offsetQuery = "AND rev_timestamp <= '{$this->offset}'"; @@ -153,7 +152,7 @@ class contribs_finder { * @param string $par (optional) user name of the user for which to show the contributions */ function wfSpecialContributions( $par = null ) { - global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest, $wgTitle, $wgScript, $wgSysopUserBans; + global $wgUser, $wgOut, $wgLang, $wgRequest; $fname = 'wfSpecialContributions'; $target = isset($par) ? $par : $wgRequest->getVal( 'target' ); @@ -167,114 +166,59 @@ function wfSpecialContributions( $par = null ) { $wgOut->errorpage( 'notargettitle', 'notargettext' ); return; } - $nt =& Title::makeTitle(NS_USER, $nt->getDBkey()); - list( $limit, $offset) = wfCheckLimits(); - $offset = $wgRequest->getVal('offset'); + $options = array(); + + list( $options['limit'], $options['offset']) = wfCheckLimits(); + $options['offset'] = $wgRequest->getVal('offset'); /* Offset must be an integral. */ - if (!strlen($offset) || !preg_match('/^[0-9]+$/', $offset)) - $offset = 0; + if (!strlen($options['offset']) || !preg_match('/^[0-9]+$/', $options['offset'])) + $options['offset'] = ''; $title = Title::makeTitle(NS_SPECIAL, 'Contributions'); - $urlbits = 'target=' . wfUrlEncode($target); - $myurl = $title->escapeLocalURL($urlbits); - - $finder = new contribs_finder(($target == 'newbies') ? 'newbies' : $nt->getText()); - - $finder->set_limit($limit); - $finder->set_offset($offset); + $options['target'] = $target; - $nsurl = $xnsurl = ''; if (($ns = $wgRequest->getVal('namespace', null)) !== null && $ns !== '') { - $nsurl = '&namespace='.$ns; - $xnsurl = htmlspecialchars($nsurl); - $finder->set_namespace($ns); + $options['namespace'] = $ns; + } else { + $options['namespace'] = ''; } - $boturl = ''; - if ($wgUser->isAllowed('rollback') && $wgRequest->getBool( 'bot' )) - $boturl = '&bot=1'; + if ($wgUser->isAllowed('rollback') && $wgRequest->getBool( 'bot' )) { + $options['bot'] = '1'; + } + + $nt =& Title::makeTitle(NS_USER, $nt->getDBkey()); + $finder = new contribs_finder(($target == 'newbies') ? 'newbies' : $nt->getText()); + $finder->set_limit($options['limit']); + $finder->set_offset($options['offset']); + $finder->set_namespace($options['namespace']); if ($wgRequest->getText('go') == 'prev') { - $prevts = $finder->get_previous_offset_for_paging(); - $prevurl = $title->getLocalURL($urlbits . "&offset=$prevts&limit=$limit$nsurl$boturl"); + $options['offset'] = $finder->get_previous_offset_for_paging(); + $prevurl = $title->getLocalURL(wfArrayToCGI( $options )); $wgOut->redirect($prevurl); return; } if ($wgRequest->getText('go') == 'first' && $target != 'newbies') { - $prevts = $finder->get_first_offset_for_paging(); - $prevurl = $title->getLocalURL($urlbits . "&offset=$prevts&limit=$limit$nsurl$boturl"); + $options['offset'] = $finder->get_first_offset_for_paging(); + $prevurl = $title->getLocalURL(wfArrayToCGI( $options )); $wgOut->redirect($prevurl); return; } - $sk = $wgUser->getSkin(); - - $id = User::idFromName($nt->getText()); - - if ( 0 == $id ) { - $ul = $nt->getText(); - } else { - $ul = $sk->makeLinkObj( $nt, htmlspecialchars( $nt->getText() ) ); - $userCond = '=' . $id; - } - $talk = $nt->getTalkPage(); - if( $talk ) { - # Talk page link - $tools[] = $sk->makeLinkObj( $talk, $wgLang->getNsText( NS_TALK ) ); - if( ( $id != 0 && $wgSysopUserBans ) || ( $id == 0 && User::isIP( $nt->getText() ) ) ) { - # Block link - if( $wgUser->isAllowed( 'block' ) ) - $tools[] = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Blockip/' . $nt->getDBkey() ), wfMsgHtml( 'blocklink' ) ); - # Block log link - $tools[] = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Log' ), htmlspecialchars( LogPage::logName( 'block' ) ), 'type=block&page=' . $nt->getPrefixedUrl() ); - } - # Other logs link - $tools[] = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Log' ), wfMsgHtml( 'log' ), 'user=' . $nt->getPartialUrl() ); - $ul .= ' (' . implode( ' | ', $tools ) . ')'; - } - if ($target == 'newbies') { - $ul = wfMsg ('newbies'); + $wgOut->setSubtitle( wfMsgHtml( 'sp-contributions-newbies-sub') ); + } else { + $wgOut->setSubtitle( wfMsgHtml( 'contribsub', contributionsSub($nt) ) ); } - $wgOut->setSubtitle( wfMsgHtml( 'contribsub', $ul ) ); - + $id = User::idFromName($nt->getText()); wfRunHooks('SpecialContributionsBeforeMainOutput', $id ); - $arr = $wgContLang->getFormattedNamespaces(); - $nsform = "
\n"; - $nsform .= wfElement('input', array( - 'name' => 'title', - 'type' => 'hidden', - 'value' => $wgTitle->getPrefixedText())); - $nsform .= wfElement('input', array( - 'name' => 'offset', - 'type' => 'hidden', - 'value' => $offset)); - $nsform .= wfElement('input', array( - 'name' => 'limit', - 'type' => 'hidden', - 'value' => $limit)); - $nsform .= wfElement('input', array( - 'name' => 'target', - 'type' => 'hidden', - 'value' => $target)); - $nsform .= '

'; - $nsform .= wfMsgHtml('namespace'); - - $nsform .= ' '; - $nsform .= HTMLnamespaceselector( $ns, '' ); - - $nsform .= wfElement('input', array( - 'type' => 'submit', - 'value' => wfMsg('allpagessubmit'))); - $nsform .= "

\n"; - - $wgOut->addHTML($nsform); + $wgOut->addHTML(contributionsForm($options)); - $contribsPage = Title::makeTitle( NS_SPECIAL, 'Contributions' ); $contribs = $finder->find(); if (count($contribs) == 0) { @@ -287,43 +231,46 @@ function wfSpecialContributions( $par = null ) { $atstart = (!count($contribs) || $late == $contribs[0]->rev_timestamp); $atend = (!count($contribs) || $early == $lastts); - $firsttext = wfMsgHtml('histfirst'); - $lasttext = wfMsgHtml('histlast'); - - $prevtext = wfMsg('prevn', $limit); - if ($atstart) { - $lastlink = $lasttext; - $prevlink = $prevtext; - } else { - $lastlink = "$lasttext"; - $prevlink = "$prevtext"; + // These four are defaults + $newestlink = wfMsgHtml('sp-contributions-newest'); + $oldestlink = wfMsgHtml('sp-contributions-oldest'); + $newerlink = wfMsgHtml('sp-contributions-newer', $options['limit']); + $olderlink = wfMsgHtml('sp-contributions-older', $options['limit']); + + if (!$atstart) { + $stuff = $title->escapeLocalURL(wfArrayToCGI(array('offset' => ''), $options)); + $newestlink = "$newestlink"; + $stuff = $title->escapeLocalURL(wfArrayToCGI(array('go' => 'prev'), $options)); + $newerlink = "$newerlink"; } - $nexttext = wfMsg('nextn', $limit); - if ($atend) { - $firstlink = $firsttext; - $nextlink = $nexttext; - } else { - $firstlink = "$firsttext"; - $nextlink = "$nexttext"; + if (!$atend) { + $stuff = $title->escapeLocalURL(wfArrayToCGI(array('go' => 'first'), $options)); + $oldestlink = "$oldestlink"; + $stuff = $title->escapeLocalURL(wfArrayToCGI(array('offset' => $lastts), $options)); + $olderlink = "$olderlink"; } + if ($target == 'newbies') { - $firstlast ="($lastlink)"; + $firstlast ="($newestlink)"; } else { - $firstlast = "($lastlink | $firstlink)"; + $firstlast = "($newestlink | $oldestlink)"; } $urls = array(); - foreach (array(20, 50, 100, 250, 500) as $num) - $urls[] = "".$wgLang->formatNum($num).""; + foreach (array(20, 50, 100, 250, 500) as $num) { + $stuff = $title->escapeLocalURL(wfArrayToCGI(array('limit' => $num), $options)); + $urls[] = "".$wgLang->formatNum($num).""; + } $bits = implode($urls, ' | '); - $prevnextbits = $firstlast .' '. wfMsgHtml('viewprevnext', $prevlink, $nextlink, $bits); + $prevnextbits = $firstlast .' '. wfMsgHtml('viewprevnext', $newerlink, $olderlink, $bits); $wgOut->addHTML( "

{$prevnextbits}

\n"); $wgOut->addHTML( "