r88360 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88359‎ | r88360 | r88361 >
Date:23:09, 17 May 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on special:semanticwatchlist
Modified paths:
  • /trunk/extensions/SemanticWatchlist/specials/SpecialSemanticWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticWatchlist/specials/SpecialSemanticWatchlist.php
@@ -66,9 +66,39 @@
6767 }
6868
6969 protected function displayWatchlist() {
 70+ global $wgOut, $wgLang;
 71+
 72+ $changeSetsHTML = array();
 73+
7074 foreach ( $this->getChangeSets() as $set ) {
71 - $this->displayChangeSet( $set );
 75+ $dayKey = substr( $set->getTime(), 0, 8 ); // Get the YYYYMMDD part.
 76+
 77+ if ( !array_key_exists( $dayKey, $changeSetsHTML ) ) {
 78+ $changeSetsHTML[$dayKey] = array();
 79+ }
 80+
 81+ $changeSetsHTML[$dayKey][] = $this->getChangeSetHTML( $set );
7282 }
 83+
 84+ krsort( $changeSetsHTML );
 85+
 86+ foreach ( $changeSetsHTML as $daySets ) {
 87+ $wgOut->addHTML( HTML::element(
 88+ 'h4',
 89+ array(),
 90+ $wgLang->date( str_pad( $set->getTime(), 14, '0' ) )
 91+ ) );
 92+
 93+ $wgOut->addHTML( '<ul>' );
 94+
 95+ foreach ( $daySets as $setHTML ) {
 96+ $wgOut->addHTML( $setHTML );
 97+ }
 98+
 99+ $wgOut->addHTML( '</ul>' );
 100+ }
 101+
 102+ SMWOutputs::commitToOutputPage( $wgOut );
73103 }
74104
75105 /**
@@ -98,24 +128,54 @@
99129 return $changeSets;
100130 }
101131
102 - protected function displayChangeSet( SWLChangeSet $changeSet ) {
103 - global $wgOut;
 132+ protected function getChangeSetHTML( SWLChangeSet $changeSet ) {
 133+ global $wgLang;
104134
105 - $wgOut->addHTML( '<h3>' . $changeSet->getTitle()->getText() . '</h3><ul>' );
 135+ $html = '';
106136
 137+ $html .= '<li>';
 138+
 139+ $html .=
 140+ '<p>' .
 141+ $wgLang->time( $changeSet->getTime(), true ) . ' ' .
 142+ HTML::element(
 143+ 'a',
 144+ array( 'href' => $changeSet->getTitle()->getLocalURL() ),
 145+ $changeSet->getTitle()->getText()
 146+ ) . ' (' .
 147+ HTML::element(
 148+ 'a',
 149+ array( 'href' => $changeSet->getTitle()->getLocalURL( 'action=history' ) ),
 150+ wfMsg( 'hist' )
 151+ ) . ')' .
 152+ '</p>'
 153+ ;
 154+
 155+ $propertyHTML= array();
 156+
107157 foreach ( $changeSet->getAllProperties() as /* SMWDIProperty */ $property ) {
108 - foreach ( $changeSet->getAllPropertyChanges( $property ) as /* SMWPropertyChange */ $change ) {
109 - $old = $change->getOldValue();
110 - $old = is_null( $old ) ? wfMsg( 'swl-novalue' ) : SMWDataValueFactory::newDataItemValue( $old, $property )->getLongHTMLText();
111 - $new = $change->getNewValue();
112 - $new = is_null( $new ) ? wfMsg( 'swl-novalue' ) : SMWDataValueFactory::newDataItemValue( $new, $property )->getLongHTMLText();
113 - $wgOut->addHTML( '<li>' . $old . ' -> ' . $new . '</li>' );
114 - }
 158+ $propertyHTML[] = $this->getPropertyHTML( $property, $changeSet->getAllPropertyChanges( $property ) );
115159 }
116160
117 - SMWOutputs::commitToOutputPage( $wgOut );
 161+ $html .= implode( '', $propertyHTML );
118162
119 - $wgOut->addHTML( '</ul>' );
 163+ $html .= '</li>';
 164+
 165+ return $html;
120166 }
121167
 168+ protected function getPropertyHTML( SMWDIProperty $property, array $changes ) {
 169+ $html = '';
 170+
 171+ foreach ( $changes as /* SMWPropertyChange */ $change ) {
 172+ $old = $change->getOldValue();
 173+ $old = is_null( $old ) ? wfMsg( 'swl-novalue' ) : SMWDataValueFactory::newDataItemValue( $old, $property )->getLongHTMLText();
 174+ $new = $change->getNewValue();
 175+ $new = is_null( $new ) ? wfMsg( 'swl-novalue' ) : SMWDataValueFactory::newDataItemValue( $new, $property )->getLongHTMLText();
 176+ $html .= '* ' . $old . ' -> ' . $new;
 177+ }
 178+
 179+ return $html;
 180+ }
 181+
122182 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r88361follow up to r88360jeroendedauw23:50, 17 May 2011

Status & tagging log