Index: trunk/extensions/SemanticWatchlist/specials/SpecialSemanticWatchlist.php |
— | — | @@ -66,9 +66,39 @@ |
67 | 67 | } |
68 | 68 | |
69 | 69 | protected function displayWatchlist() { |
| 70 | + global $wgOut, $wgLang; |
| 71 | + |
| 72 | + $changeSetsHTML = array(); |
| 73 | + |
70 | 74 | 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 ); |
72 | 82 | } |
| 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 ); |
73 | 103 | } |
74 | 104 | |
75 | 105 | /** |
— | — | @@ -98,24 +128,54 @@ |
99 | 129 | return $changeSets; |
100 | 130 | } |
101 | 131 | |
102 | | - protected function displayChangeSet( SWLChangeSet $changeSet ) { |
103 | | - global $wgOut; |
| 132 | + protected function getChangeSetHTML( SWLChangeSet $changeSet ) { |
| 133 | + global $wgLang; |
104 | 134 | |
105 | | - $wgOut->addHTML( '<h3>' . $changeSet->getTitle()->getText() . '</h3><ul>' ); |
| 135 | + $html = ''; |
106 | 136 | |
| 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 | + |
107 | 157 | 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 ) ); |
115 | 159 | } |
116 | 160 | |
117 | | - SMWOutputs::commitToOutputPage( $wgOut ); |
| 161 | + $html .= implode( '', $propertyHTML ); |
118 | 162 | |
119 | | - $wgOut->addHTML( '</ul>' ); |
| 163 | + $html .= '</li>'; |
| 164 | + |
| 165 | + return $html; |
120 | 166 | } |
121 | 167 | |
| 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 | + |
122 | 182 | } |