Completed
Push — master ( b9b0af...b944a3 )
by mw
279:13 queued 244:18
created

ContentsBuilder::doGenerateHtml()   C

Complexity

Conditions 7
Paths 13

Size

Total Lines 48
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 29
nc 13
nop 0
dl 0
loc 48
rs 6.7272
c 0
b 0
f 0
1
<?php
2
3
namespace SMW\MediaWiki\Specials\Browse;
4
5
use SMW\SemanticData;
6
use SMW\ApplicationFactory;
7
use SMW\DataValueFactory;
8
use SMW\Localizer;
9
use SMW\DIProperty;
10
use SMW\DIWikiPage;
11
use SMW\Store;
12
use Html;
13
use SMW\Message;
14
use SMWDataValue as DataValue;
15
use SMW\DataValues\ValueFormatters\DataValueFormatter;
16
use SMW\RequestOptions;
17
18
/**
19
 * @license GNU GPL v2+
20
 * @since   2.5
21
 *
22
 * @author Denny Vrandecic
23
 * @author mwjames
24
 */
25
class ContentsBuilder {
26
27
	/**
28
	 * @var Store
29
	 */
30
	private $store;
31
32
	/**
33
	 * @var DIWikiPage
34
	 */
35
	private $subject;
36
37
	/**
38
	 * @var boolean
39
	 */
40
	private $showoutgoing = true;
41
42
	/**
43
	 * To display incoming values?
44
	 *
45
	 * @var boolean
46
	 */
47
	private $showincoming = false;
48
49
	/**
50
	 * At which incoming property are we currently?
51
	 * @var integer
52
	 */
53
	private $offset = 0;
54
55
	/**
56
	 * How many incoming values should be asked for
57
	 * @var integer
58
	 */
59
	private $incomingValuesCount = 8;
60
61
	/**
62
	 * How many incoming properties should be asked for
63
	 * @var integer
64
	 */
65
	private $incomingPropertiesCount = 21;
66
67
	/**
68
	 * @var array
69
	 */
70
	private $extraModules = array();
71
72
	/**
73
	 * @var array
74
	 */
75
	private $options = array();
76
77
	/**
78
	 * @since 2.5
79
	 *
80
	 * @param Store $store
81
	 * @param DIWikiPage $subject
82
	 */
83
	public function __construct( Store $store, DIWikiPage $subject ) {
84
		$this->store = $store;
85
		$this->subject = DataValueFactory::getInstance()->newDataValueByItem( $subject );
0 ignored issues
show
Documentation Bug introduced by
It seems like \SMW\DataValueFactory::g...taValueByItem($subject) of type object<SMWDataValue> is incompatible with the declared type object<SMW\DIWikiPage> of property $subject.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
86
	}
87
88
	/**
89
	 * @since 2.5
90
	 *
91
	 * @param string $key
92
	 * @param mixed $value
93
	 */
94
	public function setOption( $key, $value ) {
95
		$this->options[$key] = $value;
96
	}
97
98
	/**
99
	 * @since 2.5
100
	 *
101
	 * @param string $key
102
	 *
103
	 * @return mixed
104
	 */
105
	public function getOption( $key ) {
106
107
		if ( isset( $this->options[$key] ) ) {
108
			return $this->options[$key];
109
		}
110
111
		return null;
112
	}
113
114
	/**
115
	 * @since 2.5
116
	 *
117
	 * @param string $json
118
	 */
119
	public function importOptionsFromJson( $json ) {
120
		$this->options = json_decode( $json, true );
0 ignored issues
show
Documentation Bug introduced by
It seems like json_decode($json, true) of type * is incompatible with the declared type array of property $options.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
121
	}
122
123
	/**
124
	 * @since 2.5
125
	 *
126
	 * @return string
127
	 */
128
	public function getHtml() {
129
130
		if ( ( $offset = $this->getOption( 'offset' ) ) ) {
131
			$this->offset = $offset;
132
		}
133
134
		if ( $this->getOption( 'showAll' ) ) {
135
			$this->incomingValuesCount = 21;
136
			$this->incomingPropertiesCount = - 1;
137
			$this->showoutgoing = true;
138
			$this->showincoming = true;
139
		}
140
141
		if ( $this->getOption( 'dir' ) === 'both' || $this->getOption( 'dir' ) === 'in' ) {
142
			$this->showincoming = true;
143
		}
144
145
		if ( $this->getOption( 'dir' ) === 'in' ) {
146
			$this->showoutgoing = false;
147
		}
148
149
		if ( $this->getOption( 'dir' ) === 'out' ) {
150
			$this->showincoming = false;
151
		}
152
153
		return $this->doGenerateHtml();
154
	}
155
156
	/**
157
	 * @since 2.5
158
	 *
159
	 * @return string
160
	 */
161
	public function getEmptyHtml() {
162
		global $wgContLang;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
163
164
		$leftside = !( $wgContLang->isRTL() );
165
		$html = "\n";
166
167
		$semanticData = new SemanticData( $this->subject->getDataItem() );
0 ignored issues
show
Bug introduced by
The method getDataItem() does not exist on SMW\DIWikiPage. Did you maybe mean getDataItemClassNameForId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
168
		$this->articletext = $this->subject->getWikiValue();
0 ignored issues
show
Bug introduced by
The property articletext does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
The method getWikiValue() does not seem to exist on object<SMW\DIWikiPage>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
169
170
		$html .= $this->displayHead();
171
		$html .= $this->displayData( $semanticData, $leftside, false, true );
172
		$html .= $this->displayCenter( $this->subject->getLongWikiText() );
0 ignored issues
show
Bug introduced by
The method getLongWikiText() does not seem to exist on object<SMW\DIWikiPage>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
173
		$html .= $this->displayData( $semanticData, $leftside, true, true );
174
		$html .= $this->displayBottom( false );
175
176
		if ( $this->getOption( 'printable' ) !== 'yes' && !$this->getOption( 'including' ) ) {
177
			$html .= FormHelper::getQueryForm( $this->articletext );
178
		}
179
180
		return $html;
181
	}
182
183
	/**
184
	 * Create and output HTML including the complete factbox, based on the extracted
185
	 * parameters in the execute comment.
186
	 *
187
	 * @return string  A HTML string with the factbox
188
	 */
189
	private function doGenerateHtml() {
190
		global $wgContLang;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
191
		$html = "\n";
192
		$leftside = !( $wgContLang->isRTL() ); // For right to left languages, all is mirrored
193
		$modules = array();
0 ignored issues
show
Unused Code introduced by
$modules is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
194
195
		if ( !$this->subject->isValid() ) {
0 ignored issues
show
Bug introduced by
The method isValid() does not seem to exist on object<SMW\DIWikiPage>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
196
			return $html;
197
		}
198
199
		$semanticData = new SemanticData( $this->subject->getDataItem() );
0 ignored issues
show
Bug introduced by
The method getDataItem() does not exist on SMW\DIWikiPage. Did you maybe mean getDataItemClassNameForId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
200
		$html .= $this->displayHead();
201
202
		if ( $this->showoutgoing ) {
203
			$semanticData = $this->store->getSemanticData( $this->subject->getDataItem() );
0 ignored issues
show
Bug introduced by
The method getDataItem() does not exist on SMW\DIWikiPage. Did you maybe mean getDataItemClassNameForId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
204
			$html .= $this->displayData( $semanticData, $leftside );
205
			$html .= $this->displayCenter( $this->subject->getLongWikiText() );
0 ignored issues
show
Bug introduced by
The method getLongWikiText() does not seem to exist on object<SMW\DIWikiPage>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
206
		}
207
208
		if ( $this->showincoming ) {
209
			list( $indata, $more ) = $this->getInData();
210
211
			if ( !$this->getOption( 'showInverse' ) ) {
212
				$leftside = !$leftside;
213
			}
214
215
			$html .= $this->displayData( $indata, $leftside, true );
216
			$html .= $this->displayBottom( $more );
217
		}
218
219
		$this->articletext = $this->subject->getWikiValue();
0 ignored issues
show
Bug introduced by
The method getWikiValue() does not seem to exist on object<SMW\DIWikiPage>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
220
221
		\Hooks::run( 'SMW::Browse::AfterDataLookupComplete', array( $this->store, $semanticData, &$html, &$this->extraModules ) );
222
223
		if ( $this->getOption( 'printable' ) !== 'yes' && !$this->getOption( 'including' ) ) {
224
			$html .= FormHelper::getQueryForm( $this->articletext );
225
		}
226
227
		$html .= Html::element(
228
			'div',
229
			array(
230
				'class' => 'smwb-modules',
231
				'data-modules' => json_encode( $this->extraModules )
232
			)
233
		);
234
235
		return $html;
236
	}
237
238
	/**
239
	 * Creates the HTML table displaying the data of one subject.
240
	 *
241
	 * @param[in] $data SMWSemanticData  The data to be displayed
242
	 * @param[in] $left bool  Should properties be displayed on the left side?
243
	 * @param[in] $incoming bool  Is this an incoming? Or an outgoing?
244
	 *
245
	 * @return string A string containing the HTML with the factbox
246
	 */
247
	private function displayData( SemanticData $data, $left = true, $incoming = false, $isLoading = false ) {
248
		// Some of the CSS classes are different for the left or the right side.
249
		// In this case, there is an "i" after the "smwb-". This is set here.
250
		$ccsPrefix = $left ? 'smwb-' : 'smwb-i';
251
252
		$html = "<table class=\"{$ccsPrefix}factbox\" cellpadding=\"0\" cellspacing=\"0\">\n";
253
		$noresult = true;
254
255
		$diProperties = $data->getProperties();
256
		$showInverse = $this->getOption( 'showInverse' );
257
258
		foreach ( $diProperties as $key => $diProperty ) {
259
260
			$dvProperty = DataValueFactory::getInstance()->newDataValueByItem(
261
				$diProperty,
262
				null
263
			);
264
265
			$propertyLabel = ValueFormatter::getPropertyLabel(
266
				$dvProperty,
0 ignored issues
show
Compatibility introduced by
$dvProperty of type object<SMWDataValue> is not a sub-type of object<SMWPropertyValue>. It seems like you assume a child class of the class SMWDataValue to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
267
				$incoming,
268
				$showInverse
269
			);
270
271
			if ( $propertyLabel === null ) {
272
				continue;
273
			}
274
275
			$head  = '<th>' . $propertyLabel . "</th>\n";
276
			$body  = "<td>\n";
277
278
			$values = $data->getPropertyValues( $diProperty );
279
280
			if ( $incoming && ( count( $values ) >= $this->incomingValuesCount ) ) {
281
				$moreIncoming = true;
282
				array_pop( $values );
283
			} else {
284
				$moreIncoming = false;
285
			}
286
287
			$first = true;
288
			foreach ( $values as /* SMWDataItem */ $di ) {
0 ignored issues
show
Bug introduced by
The expression $values of type array|object<SMWDataItem> is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
289
				if ( $first ) {
290
					$first = false;
291
				} else {
292
					$body .= ', ';
293
				}
294
295
				if ( $incoming ) {
296
					$dv = DataValueFactory::getInstance()->newDataValueByItem( $di, null );
297
				} else {
298
					$dv = DataValueFactory::getInstance()->newDataValueByItem( $di, $diProperty );
299
				}
300
301
				$body .= "<span class=\"{$ccsPrefix}value\">" .
302
				         $this->displayValue( $dvProperty, $dv, $incoming ) . "</span>\n";
0 ignored issues
show
Compatibility introduced by
$dvProperty of type object<SMWDataValue> is not a sub-type of object<SMWPropertyValue>. It seems like you assume a child class of the class SMWDataValue to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
303
			}
304
305
			// Added in 2.3
306
			// link to the remaining incoming pages
307
			if ( $moreIncoming && \Hooks::run( 'SMW::Browse::BeforeIncomingPropertyValuesFurtherLinkCreate', array( $diProperty, $this->subject->getDataItem(), &$body ) ) ) {
0 ignored issues
show
Bug introduced by
The method getDataItem() does not exist on SMW\DIWikiPage. Did you maybe mean getDataItemClassNameForId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
308
				$body .= \Html::element(
309
					'a',
310
					array(
311
						'href' => \SpecialPage::getSafeTitleFor( 'SearchByProperty' )->getLocalURL( array(
312
							 'property' => $dvProperty->getWikiValue(),
313
							 'value' => $this->subject->getWikiValue()
0 ignored issues
show
Bug introduced by
The method getWikiValue() does not seem to exist on object<SMW\DIWikiPage>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
314
						) )
315
					),
316
					wfMessage( 'smw_browse_more' )->text()
317
				);
318
319
			}
320
321
			$body .= "</td>\n";
322
323
			// display row
324
			$html .= "<tr class=\"{$ccsPrefix}propvalue\">\n" .
325
					( $left ? ( $head . $body ):( $body . $head ) ) . "</tr>\n";
326
			$noresult = false;
327
		} // end foreach properties
328
329
		if ( $noresult ) {
330
			$noMsgKey = $incoming ? 'smw_browse_no_incoming':'smw_browse_no_outgoing';
331
332
			$html .= "<tr class=\"smwb-propvalue\"><th> &#160; </th><td><em>" .
333
				wfMessage( $isLoading ? 'smw-browse-from-backend' : $noMsgKey )->escaped() . "</em></td></tr>\n";
334
		}
335
336
		$html .= "</table>\n";
337
338
		return $html;
339
	}
340
341
	/**
342
	 * Displays a value, including all relevant links (browse and search by property)
343
	 *
344
	 * @param[in] $property SMWPropertyValue  The property this value is linked to the subject with
345
	 * @param[in] $value DataValue  The actual value
346
	 * @param[in] $incoming bool  If this is an incoming or outgoing link
347
	 *
348
	 * @return string  HTML with the link to the article, browse, and search pages
349
	 */
350
	private function displayValue( \SMWPropertyValue $property, DataValue $dataValue, $incoming ) {
351
352
		$dataValue->setContextPage(
353
			$this->subject->getDataItem()
0 ignored issues
show
Bug introduced by
The method getDataItem() does not exist on SMW\DIWikiPage. Did you maybe mean getDataItemClassNameForId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
354
		);
355
356
		return ValueFormatter::getFormattedValue( $dataValue, $property, $incoming );
357
	}
358
359
	/**
360
	 * Displays the subject that is currently being browsed to.
361
	 *
362
	 * @return string A string containing the HTML with the subject line
363
	 */
364
	private function displayHead() {
365
366
		if ( $this->subject->getDataItem()->getNamespace() === SMW_NS_PROPERTY ) {
0 ignored issues
show
Bug introduced by
The method getDataItem() does not exist on SMW\DIWikiPage. Did you maybe mean getDataItemClassNameForId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
367
			$caption = '';
0 ignored issues
show
Unused Code introduced by
$caption is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
368
369
			$dv = DataValueFactory::getInstance()->newDataValueByItem(
370
				DIProperty::newFromUserLabel( $this->subject->getDataItem()->getDBKey() )
0 ignored issues
show
Bug introduced by
The method getDataItem() does not exist on SMW\DIWikiPage. Did you maybe mean getDataItemClassNameForId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
371
			);
372
373
			$this->subject->setCaption( $dv->getFormattedLabel( DataValueFormatter::WIKI_LONG ) );
0 ignored issues
show
Bug introduced by
The method setCaption() does not seem to exist on object<SMW\DIWikiPage>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
374
		}
375
376
		$html = "<table class=\"smwb-factbox\" cellpadding=\"0\" cellspacing=\"0\">\n" .
377
			"<tr class=\"smwb-title\"><td colspan=\"2\">\n" .
378
			$this->subject->getLongHTMLText( smwfGetLinker() ) . "\n" .
0 ignored issues
show
Bug introduced by
The method getLongHTMLText() does not seem to exist on object<SMW\DIWikiPage>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
379
			"</td></tr>\n</table>\n";
380
381
		return $html;
382
	}
383
384
	/**
385
	 * Creates the HTML for the center bar including the links with further navigation options.
386
	 *
387
	 * @return string  HTMl with the center bar
388
	 */
389
	private function displayCenter( $article ) {
390
391
		if ( $this->showincoming ) {
392
			$parameters = array(
393
				'offset'  => 0,
394
				'dir'     => 'out',
395
				'article' => $article
396
			);
397
398
			$linkMsg = 'smw_browse_hide_incoming';
399
		} else {
400
			$parameters = array(
401
				'offset'  => $this->offset,
402
				'dir'     => 'both',
403
				'article' => $article
404
			);
405
406
			$linkMsg = 'smw_browse_show_incoming';
407
		}
408
409
		$html = FormHelper::createLink( $linkMsg, $parameters );
410
411
		return "<a name=\"smw_browse_incoming\"></a>\n" .
412
		       "<table class=\"smwb-factbox\" cellpadding=\"0\" cellspacing=\"0\">\n" .
413
		       "<tr class=\"smwb-center\"><td colspan=\"2\">\n" . $html .
414
		       "&#160;\n" . "</td></tr>\n" . "</table>\n";
415
	}
416
417
	/**
418
	 * Creates the HTML for the bottom bar including the links with further navigation options.
419
	 *
420
	 * @param[in] $more bool  Are there more inproperties to be displayed?
421
	 * @return string  HTMl with the bottom bar
422
	 */
423
	private function displayBottom( $more ) {
424
425
		$article = $this->subject->getLongWikiText();
0 ignored issues
show
Bug introduced by
The method getLongWikiText() does not seem to exist on object<SMW\DIWikiPage>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
426
427
		$open  = "<table class=\"smwb-factbox\" cellpadding=\"0\" cellspacing=\"0\">\n" .
428
		         "<tr class=\"smwb-center\"><td colspan=\"2\">\n";
429
430
		$close = "&#160;\n" . "</td></tr>\n" . "</table>\n";
431
		$html = '';
432
433
		if ( $this->getOption( 'showAll' ) ) {
434
			return $open . $close;
435
		}
436
437
		if ( ( $this->offset > 0 ) || $more ) {
438
			$offset = max( $this->offset - $this->incomingPropertiesCount + 1, 0 );
439
440
			$parameters = array(
441
				'offset'  => $offset,
442
				'dir'     => $this->showoutgoing ? 'both' : 'in',
443
				'article' => $article
444
			);
445
446
			$linkMsg = 'smw_result_prev';
447
448
			$html .= ( $this->offset == 0 ) ? wfMessage( $linkMsg )->escaped() : FormHelper::createLink( $linkMsg, $parameters );
449
450
			$offset = $this->offset + $this->incomingPropertiesCount - 1;
451
452
			$parameters = array(
453
				'offset'  => $offset,
454
				'dir'     => $this->showoutgoing ? 'both' : 'in',
455
				'article' => $article
456
			);
457
458
			$linkMsg = 'smw_result_next';
459
460
			// @todo FIXME: i18n patchwork.
461
			$html .= " &#160;&#160;&#160;  <strong>" . wfMessage( 'smw_result_results' )->escaped() . " " . ( $this->offset + 1 ) .
462
					 " – " . ( $offset ) . "</strong>  &#160;&#160;&#160; ";
463
			$html .= $more ? FormHelper::createLink( $linkMsg, $parameters ) : wfMessage( $linkMsg )->escaped();
464
		}
465
466
		return $open . $html . $close;
467
	}
468
469
	/**
470
	 * Creates a Semantic Data object with the incoming properties instead of the
471
	 * usual outproperties.
472
	 *
473
	 * @return array(SMWSemanticData, bool)  The semantic data including all inproperties, and if there are more inproperties left
0 ignored issues
show
Documentation introduced by
The doc-type array(SMWSemanticData, could not be parsed: Expected "|" or "end of type", but got "(" at position 5. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
474
	 */
475
	private function getInData() {
476
		$indata = new SemanticData( $this->subject->getDataItem() );
0 ignored issues
show
Bug introduced by
The method getDataItem() does not exist on SMW\DIWikiPage. Did you maybe mean getDataItemClassNameForId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
477
478
		$propRequestOptions = new RequestOptions();
479
		$propRequestOptions->sort = true;
480
		$propRequestOptions->limit = $this->incomingPropertiesCount;
481
482
		if ( $this->offset > 0 ) {
483
			$propRequestOptions->offset = $this->offset;
484
		}
485
486
		$incomingProperties = $this->store->getInProperties( $this->subject->getDataItem(), $propRequestOptions );
0 ignored issues
show
Bug introduced by
The method getDataItem() does not exist on SMW\DIWikiPage. Did you maybe mean getDataItemClassNameForId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
487
		$more = false;
488
489
		if ( count( $incomingProperties ) == $this->incomingPropertiesCount ) {
490
			$more = true;
491
			array_pop( $incomingProperties ); // drop the last one
492
		}
493
494
		$valRequestOptions = new RequestOptions();
495
		$valRequestOptions->sort = true;
496
		$valRequestOptions->limit = $this->incomingValuesCount;
497
498
		foreach ( $incomingProperties as $property ) {
499
			$values = $this->store->getPropertySubjects( $property, $this->subject->getDataItem(), $valRequestOptions );
0 ignored issues
show
Bug introduced by
The method getDataItem() does not exist on SMW\DIWikiPage. Did you maybe mean getDataItemClassNameForId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
500
			foreach ( $values as $value ) {
501
				$indata->addPropertyObjectValue( $property, $value );
502
			}
503
		}
504
505
		// Added in 2.3
506
		// Whether to show a more link or not can be set via
507
		// SMW::Browse::BeforeIncomingPropertyValuesFurtherLinkCreate
508
		\Hooks::run( 'SMW::Browse::AfterIncomingPropertiesLookupComplete', array( $this->store, $indata, $valRequestOptions ) );
509
510
		return array( $indata, $more );
511
	}
512
513
}
514