blob: 405f8a40a06559318daf2b7436ff83ffb89291da (
plain)
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
|
<?php
namespace SMW\Query\Language;
use SMW\Localizer;
/**
* Description of all pages within a given wiki namespace, given by a numerical
* constant. Corresponds to a class restriction with a special class that
* characterises the given namespace (or at least that is how one could map
* this to OWL etc.).
*
* @license GNU GPL v2+
* @since 1.6
*
* @author Markus Krötzsch
*/
class NamespaceDescription extends Description {
/**
* @var integer
*/
private $namespace;
/**
* @param integer $namespace
*/
public function __construct( $namespace ) {
$this->namespace = $namespace;
}
/**
* @see Description::getFingerprint
* @since 2.5
*
* @return string
*/
public function getFingerprint() {
// Avoid a simple `int` which may interfere with an associative array
// when compounding hash strings from different descriptions
return 'N:' . md5( $this->namespace );
}
/**
* @return integer
*/
public function getNamespace() {
return $this->namespace;
}
public function getQueryString( $asValue = false ) {
$localizedNamespaceText = Localizer::getInstance()->getNamespaceTextById( $this->namespace );
$prefix = $this->namespace == NS_CATEGORY ? ':' : '';
if ( $asValue ) {
return ' <q>[[' . $prefix . $localizedNamespaceText . ':+]]</q> ';
}
return '[[' . $prefix . $localizedNamespaceText . ':+]]';
}
public function isSingleton() {
return false;
}
public function getQueryFeatures() {
return SMW_NAMESPACE_QUERY;
}
}
|