summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/src/DataItemFactory.php
blob: 3ca95457a9330b463a55c02b842b77e17cbcd7b3 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php

namespace SMW;

use SMWContainerSemanticData as ContainerSemanticData;
use SMWDIBlob as DIBlob;
use SMWDIBoolean as DIBoolean;
use SMWDIContainer as DIContainer;
use SMWDIError as DIError;
use SMWDINumber as DINumber;
use SMWDIUri as DIUri;
use SMWDITime  as DITime;
use Title;

/**
 * @private
 *
 * @license GNU GPL v2+
 * @since 2.4
 *
 * @author mwjames
 */
class DataItemFactory {

	/**
	 * @since 2.4
	 *
	 * @param string $error
	 *
	 * @return DIError
	 */
	public function newDIError( $error ) {
		return new DIError( $error );
	}

	/**
	 * @since 2.4
	 *
	 * @param string $key
	 * @param boolean $inverse
	 *
	 * @return DIProperty
	 */
	public function newDIProperty( $key, $inverse = false ) {
		return new DIProperty( str_replace( ' ', '_', $key ), $inverse );
	}

	/**
	 * @since 2.4
	 *
	 * @param string|Title $title
	 * @param integer $namespace
	 * @param string $interwiki
	 * @param string $subobjectName
	 *
	 * @return DIWikiPage
	 */
	public function newDIWikiPage( $title, $namespace = NS_MAIN, $interwiki = '', $subobjectName = '' ) {

		if ( $title instanceof Title ) {
			return DIWikiPage::newFromTitle( $title );
		}

		return new DIWikiPage( $title, $namespace, $interwiki, $subobjectName );
	}

	/**
	 * @since 2.4
	 *
	 * @param ContainerSemanticData $containerSemanticData
	 *
	 * @return DIContainer
	 */
	public function newDIContainer( ContainerSemanticData $containerSemanticData ) {
		return new DIContainer( $containerSemanticData );
	}

	/**
	 * @since 3.0
	 *
	 * @param DIWikiPage $subject
	 *
	 * @return ContainerSemanticData
	 */
	public function newContainerSemanticData( DIWikiPage $subject ) {
		return new ContainerSemanticData( $subject );
	}

	/**
	 * @since 2.4
	 *
	 * @param integer $number
	 *
	 * @return DINumber
	 */
	public function newDINumber( $number ) {
		return new DINumber( $number );
	}

	/**
	 * @since 2.4
	 *
	 * @param string $text
	 *
	 * @return DIBlob
	 */
	public function newDIBlob( $text ) {
		return new DIBlob( $text );
	}

	/**
	 * @since 2.4
	 *
	 * @param boolean $boolean
	 *
	 * @return DIBoolean
	 */
	public function newDIBoolean( $boolean ) {
		return new DIBoolean( $boolean );
	}

	/**
	 * @since 2.5
	 *
	 * @param string $concept
	 * @param string $docu
	 * @param integer $queryfeatures
	 * @param integer $size
	 * @param integer $depth
	 *
	 * @return DIConcept
	 */
	public function newDIConcept( $concept, $docu = '', $queryfeatures = 0, $size = 0, $depth = 0 ) {
		return new DIConcept( $concept, $docu, $queryfeatures, $size, $depth );
	}

	/**
	 * @since 2.5
	 *
	 * @param string $scheme
	 * @param string $hierpart
	 * @param string $query
	 * @param string $fragment
	 *
	 * @return DIUri
	 */
	public function newDIUri( $scheme, $hierpart, $query = '', $fragment = '' ) {
		return new DIUri( $scheme, $hierpart, $query, $fragment );
	}

	/**
	 * @since 2.5
	 *
	 * @param integer $calendarmodel
	 * @param integer $year
	 * @param integer|false $month
	 * @param integer|false $day
	 * @param integer|false $hour
	 * @param integer|false $minute
	 * @param integer|false $second
	 * @param integer|false $timezone
	 *
	 * @return DITime
	 */
	public function newDITime( $calendarmodel, $year, $month = false, $day = false, $hour = false, $minute = false, $second = false, $timezone = false ) {
		return new DITime( $calendarmodel, $year, $month, $day, $hour, $minute, $second, $timezone );
	}

}