1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
<?php
namespace SMW\MediaWiki\Specials;
use SMW\ApplicationFactory;
use SMW\MediaWiki\Specials\SearchByProperty\PageBuilder;
use SMW\MediaWiki\Specials\SearchByProperty\PageRequestOptions;
use SMW\MediaWiki\Specials\SearchByProperty\QueryResultLookup;
use SMWInfolink as Infolink;
use SpecialPage;
/**
* A special page to search for entities that have a certain property with
* a certain value.
*
* This special page for Semantic MediaWiki implements a view on a
* relation-object pair,i.e. a typed backlink. For example, it shows me all
* persons born in Croatia, or all winners of the Academy Award for best actress.
*
* @license GNU GPL v2+
* @since 2.1
*
* @author mwjames
*/
class SpecialSearchByProperty extends SpecialPage {
/**
* @codeCoverageIgnore
*/
public function __construct() {
parent::__construct( 'SearchByProperty' );
}
/**
* @see SpecialPage::execute
*/
public function execute( $query ) {
$this->setHeaders();
$output = $this->getOutput();
$request = $this->getRequest();
$output->setPageTitle( $this->msg( 'searchbyproperty' )->text() );
$output->addModules( 'ext.smw.tooltip' );
$output->addModules( 'ext.smw.autocomplete.property' );
list( $limit, $offset ) = $this->getLimitOffset();
if ( $request->getText( 'cl', '' ) !== '' ) {
$query = Infolink::decodeCompactLink( 'cl:'. $request->getText( 'cl' ) );
} else {
$query = Infolink::decodeCompactLink( $query );
}
// @see SMWInfolink::encodeParameters
if ( $query === null && $this->getRequest()->getCheck( 'x' ) ) {
$query = $this->getRequest()->getVal( 'x' );
}
$applicationFactory = ApplicationFactory::getInstance();
$requestOptions = [
'limit' => $limit,
'offset' => $offset,
'property' => $this->getRequest()->getVal( 'property' ),
'value' => $this->getRequest()->getVal( 'value' ),
'nearbySearchForType' => $applicationFactory->getSettings()->get( 'smwgSearchByPropertyFuzzy' )
];
$htmlFormRenderer = $applicationFactory->newMwCollaboratorFactory()->newHtmlFormRenderer(
$this->getContext()->getTitle(),
$this->getLanguage()
);
$pageBuilder = new PageBuilder(
$htmlFormRenderer,
new PageRequestOptions( $query, $requestOptions ),
new QueryResultLookup( $applicationFactory->getStore() )
);
$output->addHTML( $pageBuilder->getHtml() );
}
private function getLimitOffset() {
return $this->getRequest()->getLimitOffset();
}
protected function getGroupName() {
return 'smw_group';
}
}
|