1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SMW; |
4
|
|
|
|
5
|
|
|
use Html; |
6
|
|
|
use SMW\Query\Language\ConceptDescription; |
7
|
|
|
use SMWPageLister; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Special handling for relation/attribute description pages. |
11
|
|
|
* Some code based on CategoryPage.php |
12
|
|
|
* |
13
|
|
|
* Indicate class aliases in a way PHPStorm and Eclipse understand. |
14
|
|
|
* This is purely an IDE helper file, and is not loaded by the extension. |
15
|
|
|
* |
16
|
|
|
* @since 1.9 |
17
|
|
|
* |
18
|
|
|
* @ingroup SMW |
19
|
|
|
* |
20
|
|
|
* @license GNU GPL v2+ |
21
|
|
|
* @author: Markus Krötzsch |
22
|
|
|
* @author: mwjames |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Implementation of MediaWiki's Article that shows additional information on |
27
|
|
|
* Concept: pages. Very similar to CategoryPage. |
28
|
|
|
* @ingroup SMW |
29
|
|
|
*/ |
30
|
|
|
class ConceptPage extends \SMWOrderedListPage { |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Initialize parameters to use a higher limit. This operation is very |
34
|
|
|
* similar to showing members of categories. |
35
|
|
|
*/ |
36
|
|
|
protected function initParameters() { |
37
|
|
|
global $smwgConceptPagingLimit; |
|
|
|
|
38
|
|
|
$this->limit = $smwgConceptPagingLimit; |
39
|
|
|
return true; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Returns the HTML which is added to $wgOut after the article text. |
44
|
|
|
* |
45
|
|
|
* @return string |
46
|
|
|
*/ |
47
|
|
|
protected function getHtml() { |
48
|
|
|
|
49
|
|
|
if ( $this->limit > 0 ) { // limit==0: configuration setting to disable this completely |
50
|
|
|
$description = new ConceptDescription( $this->getDataItem() ); |
51
|
|
|
$query = SMWPageLister::getQuery( $description, $this->limit, $this->from, $this->until ); |
|
|
|
|
52
|
|
|
$queryResult = ApplicationFactory::getInstance()->getStore()->getQueryResult( $query ); |
53
|
|
|
|
54
|
|
|
$diWikiPages = $queryResult->getResults(); |
55
|
|
|
if ( $this->until !== '' ) { |
56
|
|
|
$diWikiPages = array_reverse( $diWikiPages ); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
$errors = $queryResult->getErrors(); |
60
|
|
|
} else { |
61
|
|
|
$diWikiPages = array(); |
62
|
|
|
$errors = array(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
$pageLister = new SMWPageLister( $diWikiPages, null, $this->limit, $this->from, $this->until ); |
66
|
|
|
$this->mTitle->setFragment( '#SMWResults' ); // Make navigation point to the result list. |
67
|
|
|
$navigation = $pageLister->getNavigationLinks( $this->mTitle ); |
68
|
|
|
|
69
|
|
|
$titleText = htmlspecialchars( $this->mTitle->getText() ); |
70
|
|
|
$resultNumber = min( $this->limit, count( $diWikiPages ) ); |
71
|
|
|
|
72
|
|
|
return Html::element( 'br', array( 'id' => 'smwfootbr' ) ) . |
73
|
|
|
Html::element( 'a', array( 'name' => 'SMWResults' ), null ) . |
74
|
|
|
Html::rawElement( 'div', array( 'id' => 'mw-pages'), |
75
|
|
|
$this->getCacheInformation() . |
76
|
|
|
Html::rawElement( 'h2', array(), $this->getContext()->msg( 'smw_concept_header', $titleText )->text() ) . |
77
|
|
|
Html::element( 'span', array(), $this->getContext()->msg( 'smw_conceptarticlecount', $resultNumber )->parse() ) . |
78
|
|
|
smwfEncodeMessages( $errors ) . ' '. $navigation . |
79
|
|
|
$pageLister->formatList() |
80
|
|
|
); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
private function getCacheInformation() { |
84
|
|
|
|
85
|
|
|
$concept = ApplicationFactory::getInstance()->getStore()->getConceptCacheStatus( $this->getDataItem() ); |
86
|
|
|
$cacheInformation = wfMessage( 'smw-concept-no-cache' )->text(); |
87
|
|
|
|
88
|
|
|
if ( $concept instanceof DIConcept && $concept->getCacheStatus() === 'full' ) { |
|
|
|
|
89
|
|
|
$cacheInformation = wfMessage( |
90
|
|
|
'smw-concept-cache-count', |
91
|
|
|
$this->getContext()->getLanguage()->formatNum( $concept->getCacheCount() ), |
92
|
|
|
$this->getContext()->getLanguage()->timeanddate( $concept->getCacheDate() ) |
93
|
|
|
)->parse(); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
return Html::rawElement( |
97
|
|
|
'h2', |
98
|
|
|
array(), |
99
|
|
|
$this->getContext()->msg( 'smw-concept-cache-header' )->text() |
100
|
|
|
) . $cacheInformation; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
} |
104
|
|
|
|
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state