ContentsBuilder::displayData()   F
last analyzed

Complexity

Conditions 16
Paths 420

Size

Total Lines 98
Code Lines 58

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 16
eloc 58
c 0
b 0
f 0
nc 420
nop 4
dl 0
loc 98
rs 3.6086

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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 = '';
166
		$form = '';
167
168
		$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...
169
		$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...
170
171
		$html .= $this->displayHead();
172
		$html .= $this->displayData( $semanticData, $leftside, false, true );
173
		$html .= $this->displayBottom( false );
174
175
		if ( $this->getOption( 'printable' ) !== 'yes' && !$this->getOption( 'including' ) ) {
176
			$form = FormHelper::getQueryForm( $this->articletext );
177
		}
178
179
		return Html::rawElement(
180
			'div',
181
			array(
182
				'class' => 'smwb-content'
183
			), $html
184
		) . $form;
185
	}
186
187
	/**
188
	 * Create and output HTML including the complete factbox, based on the extracted
189
	 * parameters in the execute comment.
190
	 *
191
	 * @return string  A HTML string with the factbox
192
	 */
193
	private function doGenerateHtml() {
194
		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...
195
		$html = "<div class=\"smwb-datasheet\">";
196
		$leftside = !( $wgContLang->isRTL() ); // For right to left languages, all is mirrored
197
		$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...
198
199
		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...
200
			return $html;
201
		}
202
203
		$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...
204
		$html .= $this->displayHead();
205
206
		if ( $this->showoutgoing ) {
207
			$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...
208
			$html .= $this->displayData( $semanticData, $leftside );
209
			$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...
210
		}
211
212
		if ( $this->showincoming ) {
213
			list( $indata, $more ) = $this->getInData();
214
215
			if ( !$this->getOption( 'showInverse' ) ) {
216
				$leftside = !$leftside;
217
			}
218
219
			$html .= $this->displayData( $indata, $leftside, true );
220
			$html .= $this->displayBottom( $more );
221
		}
222
223
		$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...
224
		$html .= "</div>";
225
226
		\Hooks::run( 'SMW::Browse::AfterDataLookupComplete', array( $this->store, $semanticData, &$html, &$this->extraModules ) );
227
228
		if ( $this->getOption( 'printable' ) !== 'yes' && !$this->getOption( 'including' ) ) {
229
			$html .= FormHelper::getQueryForm( $this->articletext ) ;
230
		}
231
232
		$html .= Html::element(
233
			'div',
234
			array(
235
				'class' => 'smwb-modules',
236
				'data-modules' => json_encode( $this->extraModules )
237
			)
238
		);
239
240
		return $html;
241
	}
242
243
	/**
244
	 * Creates the HTML table displaying the data of one subject.
245
	 *
246
	 * @param[in] $data SMWSemanticData  The data to be displayed
247
	 * @param[in] $left bool  Should properties be displayed on the left side?
248
	 * @param[in] $incoming bool  Is this an incoming? Or an outgoing?
249
	 *
250
	 * @return string A string containing the HTML with the factbox
251
	 */
252
	private function displayData( SemanticData $data, $left = true, $incoming = false, $isLoading = false ) {
253
		// Some of the CSS classes are different for the left or the right side.
254
		// In this case, there is an "i" after the "smwb-". This is set here.
255
		$ccsPrefix = $left ? 'smwb-' : 'smwb-i';
256
257
		$html = "<div class=\"smw-table {$ccsPrefix}factbox smwb-bottom\">";
258
		$noresult = true;
259
260
		$contextPage = $data->getSubject();
261
		$diProperties = $data->getProperties();
262
		$showInverse = $this->getOption( 'showInverse' );
263
264
		foreach ( $diProperties as $key => $diProperty ) {
265
266
			$dvProperty = DataValueFactory::getInstance()->newDataValueByItem(
267
				$diProperty,
268
				null
269
			);
270
271
			$dvProperty->setContextPage(
272
				$contextPage
0 ignored issues
show
Documentation introduced by
$contextPage is of type object<SMW\DIWikiPage>, but the function expects a null|object<SMWDIWikiPage>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
273
			);
274
275
			$propertyLabel = ValueFormatter::getPropertyLabel(
276
				$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...
277
				$incoming,
278
				$showInverse
279
			);
280
281
			if ( $propertyLabel === null ) {
282
				continue;
283
			}
284
285
			$head  = "<div class=\"smw-table-cell smwb-cell smwb-prophead\">" . $propertyLabel . "</div>\n";
286
			$body  = "<div class=\"smw-table-cell smwb-cell smwb-propval\">\n";
287
288
			$values = $data->getPropertyValues( $diProperty );
289
290
			if ( $incoming && ( count( $values ) >= $this->incomingValuesCount ) ) {
291
				$moreIncoming = true;
292
				array_pop( $values );
293
			} else {
294
				$moreIncoming = false;
295
			}
296
297
			$first = true;
298
			foreach ( $values as /* SMWDataItem */ $di ) {
299
				if ( $first ) {
300
					$first = false;
301
				} else {
302
					$body .= ', ';
303
				}
304
305
				if ( $incoming ) {
306
					$dv = DataValueFactory::getInstance()->newDataValueByItem( $di, null );
307
				} else {
308
					$dv = DataValueFactory::getInstance()->newDataValueByItem( $di, $diProperty );
309
				}
310
311
				$body .= "<span class=\"{$ccsPrefix}value\">" .
312
				         $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...
313
			}
314
315
			// Added in 2.3
316
			// link to the remaining incoming pages
317
			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...
318
				$body .= \Html::element(
319
					'a',
320
					array(
321
						'href' => \SpecialPage::getSafeTitleFor( 'SearchByProperty' )->getLocalURL( array(
322
							 'property' => $dvProperty->getWikiValue(),
323
							 '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...
324
						) )
325
					),
326
					wfMessage( 'smw_browse_more' )->text()
327
				);
328
329
			}
330
331
			$body .= "</div>\n";
332
333
			// display row
334
			$html .= "<div class=\"smw-table-row {$ccsPrefix}propvalue\">\n" .
335
					( $left ? ( $head . $body ):( $body . $head ) ) . "</div>\n";
336
			$noresult = false;
337
		} // end foreach properties
338
339
		if ( $noresult ) {
340
			$noMsgKey = $incoming ? 'smw_browse_no_incoming':'smw_browse_no_outgoing';
341
			$rColumn = "<div class=\"smw-table-cell smwb-cell smwb-prophead\"></div>";
342
			$lColumn = "<div class=\"smw-table-cell smwb-cell smwb-propval\">" . wfMessage( $isLoading ? 'smw-browse-from-backend' : $noMsgKey )->escaped() . "</div>";
343
			$html .= "<div class=\"smw-table-row {$ccsPrefix}propvalue\">" . ( $left ? ( $rColumn . $lColumn ):( $lColumn . $rColumn ) ) . "</div>";
344
		}
345
346
		$html .= "</div>\n";
347
348
		return $html;
349
	}
350
351
	/**
352
	 * Displays a value, including all relevant links (browse and search by property)
353
	 *
354
	 * @param[in] $property SMWPropertyValue  The property this value is linked to the subject with
355
	 * @param[in] $value DataValue  The actual value
356
	 * @param[in] $incoming bool  If this is an incoming or outgoing link
357
	 *
358
	 * @return string  HTML with the link to the article, browse, and search pages
359
	 */
360
	private function displayValue( \SMWPropertyValue $property, DataValue $dataValue, $incoming ) {
361
362
		$dataValue->setContextPage(
363
			$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...
364
		);
365
366
		return ValueFormatter::getFormattedValue( $dataValue, $property, $incoming );
367
	}
368
369
	/**
370
	 * Displays the subject that is currently being browsed to.
371
	 *
372
	 * @return string A string containing the HTML with the subject line
373
	 */
374
	private function displayHead() {
375
376
		$label = ValueFormatter::getFormattedSubject( $this->subject );
0 ignored issues
show
Documentation introduced by
$this->subject is of type object<SMW\DIWikiPage>, but the function expects a object<SMWDataValue>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
377
378
		$html = "<div class=\"smw-table smwb-factbox\">" .
379
			"<div class=\"smw-table-header smwb-title\"><div class=\"smw-table-row\">" .
380
			$label . "\n" .
381
			"</div></div></div>";
382
383
		return $html;
384
	}
385
386
	/**
387
	 * Creates the HTML for the center bar including the links with further navigation options.
388
	 *
389
	 * @return string  HTMl with the center bar
390
	 */
391
	private function displayCenter( $article ) {
392
393
		if ( $this->showincoming ) {
394
			$parameters = array(
395
				'offset'  => 0,
396
				'dir'     => 'out',
397
				'article' => $article
398
			);
399
400
			$linkMsg = 'smw_browse_hide_incoming';
401
		} else {
402
			$parameters = array(
403
				'offset'  => $this->offset,
404
				'dir'     => 'both',
405
				'article' => $article
406
			);
407
408
			$linkMsg = 'smw_browse_show_incoming';
409
		}
410
411
		$html = FormHelper::createLink( $linkMsg, $parameters );
412
413
		return "<a name=\"smw_browse_incoming\"></a>\n" .
414
		       "<div class=\"smw-table smwb-factbox\">" .
415
		       "<div class=\"smw-table-row smwb-center\"><div >" . $html .
416
		       "&#160;\n" . "</div></div>\n" . "</div>\n";
417
	}
418
419
	/**
420
	 * Creates the HTML for the bottom bar including the links with further navigation options.
421
	 *
422
	 * @param[in] $more bool  Are there more inproperties to be displayed?
423
	 * @return string  HTMl with the bottom bar
424
	 */
425
	private function displayBottom( $more ) {
426
427
		$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...
428
429
		$open  = "<div class=\"smw-table smwb-factbox\">" .
430
		         "<div class=\"smw-table-row smwb-center\"><div >";
431
432
		$close = "&#160;\n" . "</div></div>\n" . "</div>\n";
433
		$html = '';
434
435
		if ( $this->getOption( 'showAll' ) ) {
436
			return $open . $close;
437
		}
438
439
		if ( ( $this->offset > 0 ) || $more ) {
440
			$offset = max( $this->offset - $this->incomingPropertiesCount + 1, 0 );
441
442
			$parameters = array(
443
				'offset'  => $offset,
444
				'dir'     => $this->showoutgoing ? 'both' : 'in',
445
				'article' => $article
446
			);
447
448
			$linkMsg = 'smw_result_prev';
449
450
			$html .= ( $this->offset == 0 ) ? wfMessage( $linkMsg )->escaped() : FormHelper::createLink( $linkMsg, $parameters );
451
452
			$offset = $this->offset + $this->incomingPropertiesCount - 1;
453
454
			$parameters = array(
455
				'offset'  => $offset,
456
				'dir'     => $this->showoutgoing ? 'both' : 'in',
457
				'article' => $article
458
			);
459
460
			$linkMsg = 'smw_result_next';
461
462
			// @todo FIXME: i18n patchwork.
463
			$html .= " &#160;&#160;&#160;  <strong>" . wfMessage( 'smw_result_results' )->escaped() . " " . ( $this->offset + 1 ) .
464
					 " – " . ( $offset ) . "</strong>  &#160;&#160;&#160; ";
465
			$html .= $more ? FormHelper::createLink( $linkMsg, $parameters ) : wfMessage( $linkMsg )->escaped();
466
		}
467
468
		return $open . $html . $close;
469
	}
470
471
	/**
472
	 * Creates a Semantic Data object with the incoming properties instead of the
473
	 * usual outproperties.
474
	 *
475
	 * @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...
476
	 */
477
	private function getInData() {
478
		$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...
479
480
		$propRequestOptions = new RequestOptions();
481
		$propRequestOptions->sort = true;
482
		$propRequestOptions->limit = $this->incomingPropertiesCount;
483
484
		if ( $this->offset > 0 ) {
485
			$propRequestOptions->offset = $this->offset;
486
		}
487
488
		$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...
489
		$more = false;
490
491
		if ( count( $incomingProperties ) == $this->incomingPropertiesCount ) {
492
			$more = true;
493
			array_pop( $incomingProperties ); // drop the last one
494
		}
495
496
		$valRequestOptions = new RequestOptions();
497
		$valRequestOptions->sort = true;
498
		$valRequestOptions->limit = $this->incomingValuesCount;
499
500
		foreach ( $incomingProperties as $property ) {
501
			$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...
502
			foreach ( $values as $value ) {
503
				$indata->addPropertyObjectValue( $property, $value );
504
			}
505
		}
506
507
		// Added in 2.3
508
		// Whether to show a more link or not can be set via
509
		// SMW::Browse::BeforeIncomingPropertyValuesFurtherLinkCreate
510
		\Hooks::run( 'SMW::Browse::AfterIncomingPropertiesLookupComplete', array( $this->store, $indata, $valRequestOptions ) );
511
512
		return array( $indata, $more );
513
	}
514
515
}
516