http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88369
Revision: 88369
Author: jeroendedauw
Date: 2011-05-18 14:30:12 +0000 (Wed, 18 May 2011)
Log Message:
-----------
work on special:semanticwatchlist
Modified Paths:
--------------
trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
trunk/extensions/SemanticWatchlist/SemanticWatchlist.php
trunk/extensions/SemanticWatchlist/includes/SWL_ChangeSet.php
trunk/extensions/SemanticWatchlist/specials/SpecialSemanticWatchlist.php
trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php
trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlist.css
Modified: trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
===================================================================
--- trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
2011-05-18 13:33:41 UTC (rev 88368)
+++ trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
2011-05-18 14:30:12 UTC (rev 88369)
@@ -33,7 +33,12 @@
'swl-group-page-selection' => 'Pages in ',
// Special:SemanticWatchlist
- 'swl-wacthlist-position' => "Showing '''$1''' of the last changes
starting with '''#$2'''.",
+ 'swl-watchlist-position' => "Showing '''$1''' of the last changes
starting with '''#$2'''.",
+ 'swl-watchlist-insertions' => 'Added:',
+ 'swl-watchlist-deletions' => 'Deleted:',
+ 'swl-watchlist-pagincontrol' => 'View ($1) ($2)',
+ 'swl-watchlist-firstn' => 'First $1',
+ 'swl-watchlist-firstn-title' => 'First $1 {{PLURAL:$1|result|results}}',
);
/** German (Deutsch)
Modified: trunk/extensions/SemanticWatchlist/SemanticWatchlist.php
===================================================================
--- trunk/extensions/SemanticWatchlist/SemanticWatchlist.php 2011-05-18
13:33:41 UTC (rev 88368)
+++ trunk/extensions/SemanticWatchlist/SemanticWatchlist.php 2011-05-18
14:30:12 UTC (rev 88369)
@@ -88,6 +88,15 @@
'remoteBasePath' => $egSWLScriptPath
);
+$wgResourceModules['ext.swl.watchlist'] = $moduleTemplate + array(
+ 'styles' => array( 'specials/ext.swl.watchlist.css' ),
+ 'scripts' => array(
+ ),
+ 'dependencies' => array(),
+ 'messages' => array(
+ )
+);
+
$wgResourceModules['ext.swl.watchlistconditions'] = $moduleTemplate + array(
'styles' => array( 'specials/ext.swl.watchlistconditions.css' ),
'scripts' => array(
Modified: trunk/extensions/SemanticWatchlist/includes/SWL_ChangeSet.php
===================================================================
--- trunk/extensions/SemanticWatchlist/includes/SWL_ChangeSet.php
2011-05-18 13:33:41 UTC (rev 88368)
+++ trunk/extensions/SemanticWatchlist/includes/SWL_ChangeSet.php
2011-05-18 14:30:12 UTC (rev 88369)
@@ -1,5 +1,17 @@
<?php
+/**
+ * Wrapper around SMWChangeSet that holds extra info such as user and time,
+ * and has methods for (un)serialization and database interaction.
+ *
+ * @since 0.1
+ *
+ * @file SWL_ChangeSet.php
+ * @ingroup SemanticWatchlist
+ *
+ * @licence GNU GPL v3 or later
+ * @author Jeroen De Dauw < [email protected] >
+ */
class SWLChangeSet {
/**
Modified:
trunk/extensions/SemanticWatchlist/specials/SpecialSemanticWatchlist.php
===================================================================
--- trunk/extensions/SemanticWatchlist/specials/SpecialSemanticWatchlist.php
2011-05-18 13:33:41 UTC (rev 88368)
+++ trunk/extensions/SemanticWatchlist/specials/SpecialSemanticWatchlist.php
2011-05-18 14:30:12 UTC (rev 88369)
@@ -50,7 +50,7 @@
*
* @param string $arg
*/
- public function execute( $arg ) {
+ public function execute( $subPage ) {
global $wgOut, $wgUser, $wgRequest, $wgLang;
$this->setHeaders();
@@ -74,31 +74,97 @@
$sets[] = SWLChangeSet::newFromArray( $set );
}
- $hasContinue = array_key_exists( 'query-continue',
$changeSetData );
+ $newContinue = false;
- if ( $hasContinue ) {
+ if ( array_key_exists( 'query-continue', $changeSetData ) ) {
$newContinue =
$changeSetData['query-continue']['semanticwatchlist']['swcontinue'];
}
$wgOut->addHTML( '<p>' . wfMsgExt(
- 'swl-wacthlist-position',
+ 'swl-watchlist-position',
array( 'parseinline' ),
$wgLang->formatNum( count( $sets ) ),
$wgLang->formatNum( $offset + 1 )
) . '</p>' );
- $wgOut->addHTML( wfViewPrevNext(
- $offset,
- $limit,
- $this->getTitle( $arg ),
- $hasContinue ? 'continue=' . $newContinue : '',
- !$hasContinue
- ) );
+ $wgOut->addHTML( $this->getPagingControlHTML( $limit,
$continue, $subPage, $newContinue, $offset ) );
$this->displayWatchlist( $sets );
}
/**
+ * @since 0.1
+ *
+ * @return string
+ */
+ protected function getPagingControlHTML( $limit, $currentContinue,
$subPage, $newContinue, $offset ) {
+ global $wgLang;
+
+ $nextMsg = wfMsgExt( 'nextn', array( 'parsemag', 'escape' ),
$limit );
+ $firstMsg = wfMsgExt( 'swl-watchlist-firstn', array(
'parsemag', 'escape' ), $limit );
+
+ if ( $newContinue === false ) {
+ $nextLink = $nextMsg;
+ }
+ else {
+ $nextLink = Html::element(
+ 'a',
+ array(
+ 'href' => $this->getTitle( $subPage
)->getLocalURL( wfArrayToCGI( array(
+ 'limit' => $limit,
+ 'continue' => $newContinue,
+ 'offset' => $offset + $limit
+ ) ) ),
+ 'title' => wfMsgExt( 'nextn-title',
array( 'parsemag', 'escape' ), $limit ),
+ 'class' => 'mw-nextlink'
+ ),
+ $nextMsg
+ );
+ }
+
+ $limitLinks = array();
+ $limitLinkArgs = array();
+
+ if ( $currentContinue == '' ) {
+ $firstLink = $firstMsg;
+ }
+ else {
+ $limitLinkArgs['continue'] = $currentContinue;
+
+ $firstLink = Html::element(
+ 'a',
+ array(
+ 'href' => $this->getTitle( $subPage
)->getLocalURL( wfArrayToCGI( array( 'limit' => $limit ) ) ),
+ 'title' => wfMsgExt(
'swl-watchlist-firstn-title', array( 'parsemag', 'escape' ), $limit )
+ ),
+ $firstMsg
+ );
+ }
+
+ foreach ( array( 20, 50, 100, 250, 500 ) as $limitValue ) {
+ $limitLinkArgs['limit'] = $limitValue;
+ if ( $offset != 0 ) {
+ $limitLinkArgs['offset'] = $offset;
+ }
+
+ $limitLinks[] = Html::element(
+ 'a',
+ array(
+ 'href' => $this->getTitle( $subPage
)->getLocalURL( wfArrayToCGI( $limitLinkArgs ) ),
+ 'title' => wfMsgExt( 'shown-title',
array( 'parsemag', 'escape' ), $limitValue )
+ ),
+ $wgLang->formatNum( $limitValue )
+ );
+ }
+
+ return Html::rawElement(
+ 'p',
+ array(),
+ wfMsgHtml( 'swl-watchlist-pagincontrol',
$wgLang->pipeList( array( $firstLink, $nextLink ) ), $wgLang->pipeList(
$limitLinks ) )
+ );
+ }
+
+ /**
* Displays the watchlist.
*
* @since 0.1
@@ -123,7 +189,7 @@
krsort( $changeSetsHTML );
foreach ( $changeSetsHTML as $dayKey => $daySets ) {
- $wgOut->addHTML( HTML::element(
+ $wgOut->addHTML( Html::element(
'h4',
array(),
$wgLang->date( str_pad( $dayKey, 14, '0' ) )
@@ -139,6 +205,8 @@
}
SMWOutputs::commitToOutputPage( $wgOut );
+
+ $wgOut->addModules( 'ext.swl.watchlist' );
}
/**
@@ -185,34 +253,34 @@
$html .=
'<p>' .
$wgLang->time( $changeSet->getTime(), true ) .
' ' .
- HTML::element(
+ Html::element(
'a',
array( 'href' =>
$changeSet->getTitle()->getLocalURL() ),
$changeSet->getTitle()->getText()
) . ' (' .
- HTML::element(
+ Html::element(
'a',
array( 'href' =>
$changeSet->getTitle()->getLocalURL( 'action=history' ) ),
wfMsg( 'hist' )
) . ') . . ' .
- HTML::element(
+ Html::element(
'a',
array( 'href' =>
$changeSet->getUser()->getUserPage()->getLocalURL() ),
$changeSet->getUser()->getName()
) . ' (' .
- HTML::element(
+ Html::element(
'a',
array( 'href' =>
$changeSet->getUser()->getTalkPage()->getLocalURL() ),
wfMsg( 'talkpagelinktext' )
) . ' | ' .
( $changeSet->getUser()->isAnon() ? '' :
- HTML::element(
+ Html::element(
'a',
array( 'href' =>
SpecialPage::getTitleFor( 'Contributions', $changeSet->getUser()->getName()
)->getLocalURL() ),
wfMsg( 'contribslink' )
) . ' | '
) .
- HTML::element(
+ Html::element(
'a',
array( 'href' =>
SpecialPage::getTitleFor( 'Block', $changeSet->getUser()->getName()
)->getLocalURL() ),
wfMsg( 'blocklink' )
@@ -242,16 +310,37 @@
* @return string
*/
protected function getPropertyHTML( SMWDIProperty $property, array
$changes ) {
- $html = '';
+ $insertions = array();
+ $deletions = array();
+ // Convert the changes into a list of insertions and a list of
deletions.
foreach ( $changes as /* SMWPropertyChange */ $change ) {
- $old = $change->getOldValue();
- $old = is_null( $old ) ? wfMsg( 'swl-novalue' ) :
SMWDataValueFactory::newDataItemValue( $old, $property )->getLongHTMLText();
- $new = $change->getNewValue();
- $new = is_null( $new ) ? wfMsg( 'swl-novalue' ) :
SMWDataValueFactory::newDataItemValue( $new, $property )->getLongHTMLText();
- $html .= '* ' . $old . ' -> ' . $new;
+ if ( !is_null( $change->getOldValue() ) ) {
+ $deletions[] =
SMWDataValueFactory::newDataItemValue( $change->getOldValue(), $property
)->getLongHTMLText();
+ }
+ if ( !is_null( $change->getNewValue() ) ) {
+ $insertions[] =
SMWDataValueFactory::newDataItemValue( $change->getNewValue(), $property
)->getLongHTMLText();
+ }
}
+ $lines = array();
+
+ if ( count( $insertions ) > 0 ) {
+ $lines[] = Html::element( 'div', array( 'class' =>
'swl-watchlist-insertions' ), wfMsg( 'swl-watchlist-insertions' ) ) . ' ' .
implode( ', ', $insertions );
+ }
+
+ if ( count( $deletions ) > 0 ) {
+ $lines[] = Html::element( 'div', array( 'class' =>
'swl-watchlist-deletions' ), wfMsg( 'swl-watchlist-deletions' ) ) . ' ' .
implode( ', ', $deletions );
+ }
+
+ $html = Html::element( 'b', array(), $property->getLabel() );
+
+ $html .= Html::rawElement(
+ 'div',
+ array( 'class' => 'swl-prop-div' ),
+ implode( '<br />', $lines )
+ );
+
return $html;
}
Modified:
trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php
===================================================================
--- trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php
2011-05-18 13:33:41 UTC (rev 88368)
+++ trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php
2011-05-18 14:30:12 UTC (rev 88369)
@@ -75,6 +75,15 @@
$wgOut->addModules( 'ext.swl.watchlistconditions' );
}
+ /**
+ *
+ *
+ * @since 0.1
+ *
+ * @param SWLGroup $group
+ *
+ * @return string
+ */
protected function getGroupHtml( SWLGroup $group ) {
return Html::rawElement(
'fieldset',
Modified: trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlist.css
===================================================================
--- trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlist.css
2011-05-18 13:33:41 UTC (rev 88368)
+++ trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlist.css
2011-05-18 14:30:12 UTC (rev 88369)
@@ -1 +1,13 @@
-@CHARSET "UTF-8";
\ No newline at end of file
+@CHARSET "UTF-8";
+
+div .swl-prop-div {
+ padding-left: 15px;
+}
+
+.swl-watchlist-insertions {
+ display: inline;
+}
+
+.swl-watchlist-deletions {
+ display: inline;
+}
\ No newline at end of file
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs