r89413 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89412‎ | r89413 | r89414 >
Date:14:14, 3 June 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
replace skin by linker
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php
@@ -117,10 +117,10 @@
118118 * @param[in] $data SMWSemanticData The data to be displayed
119119 * @param[in] $left bool Should properties be displayed on the left side?
120120 * @param[in] $incoming bool Is this an incoming? Or an outgoing?
 121+ *
121122 * @return A string containing the HTML with the factbox
122123 */
123124 private function displayData( SMWSemanticData $data, $left = true, $incoming = false ) {
124 - $skin = $this->getSkin();
125125 // Some of the CSS classes are different for the left or the right side.
126126 // In this case, there is an "i" after the "smwb-". This is set here.
127127 $ccsPrefix = $left ? 'smwb-' : 'smwb-i';
@@ -134,11 +134,11 @@
135135
136136 if ( $dvProperty->isVisible() ) {
137137 $dvProperty->setCaption( $this->getPropertyLabel( $dvProperty, $incoming ) );
138 - $proptext = $dvProperty->getShortHTMLText( $skin ) . "\n";
 138+ $proptext = $dvProperty->getShortHTMLText( smwfGetLinker() ) . "\n";
139139 } elseif ( $diProperty->getKey() == '_INST' ) {
140 - $proptext = $skin->specialLink( 'Categories' );
 140+ $proptext = smwfGetLinker()->specialLink( 'Categories' );
141141 } elseif ( $diProperty->getKey() == '_REDI' ) {
142 - $proptext = $skin->specialLink( 'Listredirects', 'isredirect' );
 142+ $proptext = smwfGetLinker()->specialLink( 'Listredirects', 'isredirect' );
143143 } else {
144144 continue; // skip this line
145145 }
@@ -173,7 +173,17 @@
174174 }
175175
176176 if ( $moreIncoming ) { // link to the remaining incoming pages:
177 - $body .= '<a href="' . $skin->makeSpecialUrl( 'SearchByProperty', 'property=' . urlencode( $dvProperty->getWikiValue() ) . '&value=' . urlencode( $this->subject->getWikiValue() ) ) . '">' . wfMsg( "smw_browse_more" ) . "</a>\n";
 177+ $body .= Html::element(
 178+ 'a',
 179+ array(
 180+ 'href' => SpecialPage::getSafeTitleFor( 'SearchByProperty' )->getLocalURL(
 181+ 'property=' . urlencode( $dvProperty->getWikiValue() ) .
 182+ '&value=' . urlencode( $this->subject->getWikiValue() )
 183+ )
 184+ ),
 185+ wfMsg( "smw_browse_more" )
 186+ );
 187+
178188 }
179189
180190 $body .= "</td>\n";
@@ -225,12 +235,10 @@
226236 private function displayHead() {
227237 global $wgOut;
228238
229 - $skin = $this->getSkin();
230 -
231239 $wgOut->setHTMLTitle( $this->subject->getTitle() );
232240 $html = "<table class=\"smwb-factbox\" cellpadding=\"0\" cellspacing=\"0\">\n";
233241 $html .= "<tr class=\"smwb-title\"><td colspan=\"2\">\n";
234 - $html .= $skin->makeLinkObj( $this->subject->getTitle() ) . "\n"; // @todo Replace makeLinkObj with link as soon as we drop MW1.12 compatibility
 242+ $html .= smwfGetLinker()->makeLinkObj( $this->subject->getTitle() ) . "\n"; // @todo Replace makeLinkObj with link as soon as we drop MW1.12 compatibility
235243 $html .= "</td></tr>\n";
236244 $html .= "</table>\n";
237245
@@ -247,8 +255,8 @@
248256 "<table class=\"smwb-factbox\" cellpadding=\"0\" cellspacing=\"0\">\n" .
249257 "<tr class=\"smwb-center\"><td colspan=\"2\">\n" .
250258 ( $this->showincoming ?
251 - $this->linkhere( wfMsg( 'smw_browse_hide_incoming' ), true, false, 0 ):
252 - $this->linkhere( wfMsg( 'smw_browse_show_incoming' ), true, true, $this->offset ) ) .
 259+ $this->linkHere( wfMsg( 'smw_browse_hide_incoming' ), true, false, 0 ):
 260+ $this->linkHere( wfMsg( 'smw_browse_show_incoming' ), true, true, $this->offset ) ) .
253261 "&#160;\n" . "</td></tr>\n" . "</table>\n";
254262 }
255263
@@ -266,11 +274,11 @@
267275 if ( ( $this->offset > 0 ) || $more ) {
268276 $offset = max( $this->offset - SMWSpecialBrowse::$incomingpropertiescount + 1, 0 );
269277 $html .= ( $this->offset == 0 ) ? wfMsg( 'smw_result_prev' ):
270 - $this->linkhere( wfMsg( 'smw_result_prev' ), $this->showoutgoing, true, $offset );
 278+ $this->linkHere( wfMsg( 'smw_result_prev' ), $this->showoutgoing, true, $offset );
271279 $offset = $this->offset + SMWSpecialBrowse::$incomingpropertiescount - 1;
272280 $html .= " &#160;&#160;&#160; <strong>" . wfMsg( 'smw_result_results' ) . " " . ( $this->offset + 1 ) .
273281 " – " . ( $offset ) . "</strong> &#160;&#160;&#160; ";
274 - $html .= $more ? $this->linkhere( wfMsg( 'smw_result_next' ), $this->showoutgoing, true, $offset ):wfMsg( 'smw_result_next' );
 282+ $html .= $more ? $this->linkHere( wfMsg( 'smw_result_next' ), $this->showoutgoing, true, $offset ):wfMsg( 'smw_result_next' );
275283 }
276284 }
277285 $html .= "&#160;\n" . "</td></tr>\n" . "</table>\n";
@@ -284,13 +292,23 @@
285293 * @param[in] $out bool Should the linked to page include outgoing properties?
286294 * @param[in] $in bool Should the linked to page include incoming properties?
287295 * @param[in] $offset int What is the offset for the incoming properties?
 296+ *
288297 * @return string HTML with the link to this page
289298 */
290 - private function linkhere( $text, $out, $in, $offset ) {
291 - $dir = $out ? ( $in ? 'both':'out' ):'in';
292 - $frag = ( $text == wfMsg( 'smw_browse_show_incoming' ) ) ? '#smw_browse_incoming':'';
293 - return '<a href="' . htmlspecialchars( $this->getSkin()->makeSpecialUrl( 'Browse',
294 - "offset={$offset}&dir={$dir}&article=" . urlencode( $this->subject->getLongWikiText() ) ) ) . "$frag\">$text</a>";
 299+ private function linkHere( $text, $out, $in, $offset ) {
 300+ $dir = $out ? ( $in ? 'both' : 'out' ) : 'in';
 301+ $frag = ( $text == wfMsg( 'smw_browse_show_incoming' ) ) ? '#smw_browse_incoming' : '';
 302+
 303+ return Html::element(
 304+ 'a',
 305+ array(
 306+ 'href' => SpecialPage::getSafeTitleFor( 'Browse' )->getLocalURL(
 307+ "offset={$offset}&dir={$dir}" .
 308+ '&article=' . urlencode( $this->subject->getLongWikiText() ) . $frag
 309+ )
 310+ ),
 311+ $text
 312+ );
295313 }
296314
297315 /**
@@ -318,6 +336,7 @@
319337 $valoptions = new SMWRequestOptions();
320338 $valoptions->sort = true;
321339 $valoptions->limit = SMWSpecialBrowse::$incomingvaluescount;
 340+
322341 foreach ( $inproperties as $property ) {
323342 $values = smwfGetStore()->getPropertySubjects( $property, $this->subject->getDataItem(), $valoptions );
324343 foreach ( $values as $value ) {
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php
@@ -38,9 +38,11 @@
3939 $pagename = $wgRequest->getVal( 'from' );
4040 $propname = $wgRequest->getVal( 'type' );
4141 $limit = $wgRequest->getVal( 'limit' );
 42+ $offset = $wgRequest->getVal( 'offset' );
 43+
4244 if ( $limit == '' ) $limit = 20;
43 - $offset = $wgRequest->getVal( 'offset' );
4445 if ( $offset == '' ) $offset = 0;
 46+
4547 if ( $propname == '' ) { // No GET parameters? Try the URL:
4648 $queryparts = explode( '::', $query );
4749 $propname = $query;

Status & tagging log