These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace SMW; |
||
4 | |||
5 | use Html; |
||
6 | |||
7 | /** |
||
8 | * Query class that provides content for the Special:WantedProperties page |
||
9 | * |
||
10 | * @ingroup QueryPage |
||
11 | * |
||
12 | * @licence GNU GPL v2+ |
||
13 | * @since 1.9 |
||
14 | * |
||
15 | * @author Markus Krötzsch |
||
16 | * @author mwjames |
||
17 | */ |
||
18 | class WantedPropertiesQueryPage extends QueryPage { |
||
19 | |||
20 | /** @var Store */ |
||
21 | protected $store; |
||
22 | |||
23 | /** @var Settings */ |
||
24 | protected $settings; |
||
25 | |||
26 | /** |
||
27 | * @var ListLookup |
||
28 | */ |
||
29 | private $listLookup; |
||
30 | |||
31 | /** |
||
32 | * @since 1.9 |
||
33 | * |
||
34 | * @param Store $store |
||
35 | * @param Settings $settings |
||
36 | */ |
||
37 | 5 | public function __construct( Store $store, Settings $settings ) { |
|
38 | 5 | $this->store = $store; |
|
39 | 5 | $this->settings = $settings; |
|
40 | 5 | } |
|
41 | |||
42 | /** |
||
43 | * @codeCoverageIgnore |
||
44 | * @return string |
||
45 | */ |
||
46 | function getName() { |
||
47 | return "WantedProperties"; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @codeCoverageIgnore |
||
52 | * @return boolean |
||
53 | */ |
||
54 | function isExpensive() { |
||
55 | return false; /// disables caching for now |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @codeCoverageIgnore |
||
60 | * @return boolean |
||
61 | */ |
||
62 | function isSyndicated() { |
||
0 ignored issues
–
show
|
|||
63 | return false; ///TODO: why not? |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @codeCoverageIgnore |
||
68 | * @return string |
||
69 | */ |
||
70 | function getPageHeader() { |
||
71 | return Html::element( 'p', array(), $this->msg( 'smw_wantedproperties_docu' )->text() ); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @param $skin |
||
76 | * @param array $result First item is SMWDIProperty, second item is int |
||
77 | * |
||
78 | * @return string |
||
79 | */ |
||
80 | 4 | function formatResult( $skin, $result ) { |
|
81 | // Only display user-defined properties because it can happen that |
||
82 | // custom predefined (fixed) properties are mixed within the result |
||
83 | // (did not use their own fixedProperty table and therefore were |
||
84 | // selected as well e.g _SF_PDF etc.) |
||
85 | 4 | if ( !$result[0] instanceof DIProperty || !$result[0]->isUserDefined() ) { |
|
86 | 2 | return ''; |
|
87 | } |
||
88 | |||
89 | 2 | $title = $result[0]->getDiWikiPage()->getTitle(); |
|
90 | |||
91 | 2 | if ( !$title instanceof \Title ) { |
|
92 | return ''; |
||
93 | } |
||
94 | |||
95 | 2 | $proplink = $this->getLinker()->link( |
|
96 | $title, |
||
97 | 2 | htmlspecialchars( $result[0]->getLabel() ), |
|
98 | 2 | array( 'action' => 'view' ) |
|
99 | ); |
||
100 | |||
101 | 2 | return $this->msg( 'smw_wantedproperty_template' ) |
|
102 | 2 | ->rawParams( $proplink ) |
|
103 | 2 | ->params( $result[1] ) |
|
104 | 2 | ->escaped(); |
|
105 | } |
||
106 | |||
107 | /** |
||
108 | * Get the list of results. |
||
109 | * |
||
110 | * @param SMWRequestOptions $requestOptions |
||
111 | * @return array of SMWDIProperty|SMWDIError |
||
112 | */ |
||
113 | 1 | function getResults( $requestoptions ) { |
|
114 | 1 | $this->listLookup = $this->store->getWantedPropertiesSpecial( $requestoptions ); |
|
115 | 1 | return $this->listLookup->fetchList(); |
|
116 | } |
||
117 | } |
||
118 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.