| author | cavaliet |
| Mon, 24 Oct 2011 18:45:34 +0200 | |
| changeset 11 | 5f038a505cd7 |
| parent 8 | 7d2fb5d7c9ff |
| child 14 | 673b2766024e |
| permissions | -rwxr-xr-x |
| 2 | 1 |
<?php |
2 |
/* |
|
3 |
* This file is part of the WikiTagBundle package. |
|
4 |
* |
|
5 |
* (c) IRI <http://www.iri.centrepompidou.fr/> |
|
6 |
* |
|
7 |
* For the full copyright and license information, please view the LICENSE |
|
8 |
* file that was distributed with this source code. |
|
9 |
*/ |
|
10 |
namespace IRI\Bundle\WikiTagBundle\Model; |
|
11 |
||
| 8 | 12 |
use IRI\Bundle\WikiTagBundle\Utils\WikiTagUtils; |
13 |
||
14 |
abstract class Tag implements TagInterface { |
|
| 2 | 15 |
|
16 |
public static $TAG_URL_STATUS_DICT = array('null_result'=>0,'redirection'=>1,'homonyme'=>2,'match'=>3); |
|
17 |
||
18 |
/** |
|
19 |
* @var integer $id |
|
20 |
*/ |
|
21 |
protected $id; |
|
22 |
||
23 |
/** |
|
24 |
* @var string $label |
|
25 |
*/ |
|
26 |
protected $label; |
|
27 |
||
28 |
/** |
|
29 |
* @var string $normalizedLabel |
|
30 |
*/ |
|
31 |
protected $normalizedLabel; |
|
32 |
||
33 |
/** |
|
34 |
* @var string $originalLabel |
|
35 |
*/ |
|
36 |
protected $originalLabel; |
|
37 |
||
38 |
/** |
|
39 |
* @var string $alias |
|
40 |
*/ |
|
41 |
protected $alias; |
|
42 |
||
43 |
/** |
|
44 |
* @var string $wikipediaUrl |
|
45 |
*/ |
|
46 |
protected $wikipediaUrl; |
|
47 |
||
48 |
/** |
|
49 |
* @var bigint $wikipediaPageId |
|
50 |
*/ |
|
51 |
protected $wikipediaPageId; |
|
52 |
||
53 |
/** |
|
54 |
* @var smallint $urlStatus |
|
55 |
*/ |
|
56 |
protected $urlStatus; |
|
57 |
||
58 |
/** |
|
59 |
* @var string $dbpediaUri |
|
60 |
*/ |
|
61 |
protected $dbpediaUri; |
|
62 |
||
63 |
/** |
|
64 |
* @var integer $popularity |
|
65 |
*/ |
|
66 |
protected $popularity = 0; |
|
67 |
||
68 |
/** |
|
69 |
* @var object $category |
|
70 |
*/ |
|
71 |
protected $category; |
|
72 |
||
73 |
||
74 |
/** |
|
75 |
* Get id |
|
76 |
* |
|
77 |
* @return integer |
|
78 |
*/ |
|
79 |
public function getId() |
|
80 |
{ |
|
81 |
return $this->id; |
|
82 |
} |
|
83 |
||
84 |
/** |
|
85 |
* Set label |
|
86 |
* |
|
87 |
* @param string $label |
|
88 |
*/ |
|
89 |
public function setLabel($label) |
|
90 |
{ |
|
91 |
$this->label = $label; |
|
| 8 | 92 |
$this->normalizedLabel = WikiTagUtils::normalizeTag($label); |
| 2 | 93 |
} |
94 |
||
95 |
/** |
|
96 |
* Get label |
|
97 |
* |
|
98 |
* @return string |
|
99 |
*/ |
|
100 |
public function getLabel() |
|
101 |
{ |
|
102 |
return $this->label; |
|
103 |
} |
|
104 |
||
105 |
/** |
|
106 |
* Set normalizedLabel |
|
107 |
* |
|
108 |
* @param string $normalizedLabel |
|
109 |
*/ |
|
110 |
public function setNormalizedLabel($normalizedLabel) |
|
111 |
{ |
|
112 |
$this->normalizedLabel = $normalizedLabel; |
|
113 |
} |
|
114 |
||
115 |
/** |
|
116 |
* Get normalizedLabel |
|
117 |
* |
|
118 |
* @return string |
|
119 |
*/ |
|
120 |
public function getNormalizedLabel() |
|
121 |
{ |
|
122 |
return $this->normalizedLabel; |
|
123 |
} |
|
124 |
||
125 |
/** |
|
126 |
* Set originalLabel |
|
127 |
* |
|
128 |
* @param string $originalLabel |
|
129 |
*/ |
|
130 |
public function setOriginalLabel($originalLabel) |
|
131 |
{ |
|
132 |
$this->originalLabel = $originalLabel; |
|
133 |
} |
|
134 |
||
135 |
/** |
|
136 |
* Get originalLabel |
|
137 |
* |
|
138 |
* @return string |
|
139 |
*/ |
|
140 |
public function getOriginalLabel() |
|
141 |
{ |
|
142 |
return $this->originalLabel; |
|
143 |
} |
|
144 |
||
145 |
/** |
|
146 |
* Set alias |
|
147 |
* |
|
148 |
* @param string $alias |
|
149 |
*/ |
|
150 |
public function setAlias($alias) |
|
151 |
{ |
|
152 |
$this->alias = $alias; |
|
153 |
} |
|
154 |
||
155 |
/** |
|
156 |
* Get alias |
|
157 |
* |
|
158 |
* @return string |
|
159 |
*/ |
|
160 |
public function getAlias() |
|
161 |
{ |
|
162 |
return $this->alias; |
|
163 |
} |
|
164 |
||
165 |
/** |
|
166 |
* Set wikipediaUrl |
|
167 |
* |
|
168 |
* @param string $wikipediaUrl |
|
169 |
*/ |
|
170 |
public function setWikipediaUrl($wikipediaUrl) |
|
171 |
{ |
|
172 |
$this->wikipediaUrl = $wikipediaUrl; |
|
173 |
} |
|
174 |
||
175 |
/** |
|
176 |
* Get wikipediaUrl |
|
177 |
* |
|
178 |
* @return string |
|
179 |
*/ |
|
180 |
public function getWikipediaUrl() |
|
181 |
{ |
|
182 |
return $this->wikipediaUrl; |
|
183 |
} |
|
184 |
||
185 |
/** |
|
186 |
* Set wikipediaPageId |
|
187 |
* |
|
188 |
* @param bigint $wikipediaPageId |
|
189 |
*/ |
|
190 |
public function setWikipediaPageId($wikipediaPageId) |
|
191 |
{ |
|
192 |
$this->wikipediaPageId = $wikipediaPageId; |
|
193 |
} |
|
194 |
||
195 |
/** |
|
196 |
* Get wikipediaPageId |
|
197 |
* |
|
198 |
* @return bigint |
|
199 |
*/ |
|
200 |
public function getWikipediaPageId() |
|
201 |
{ |
|
202 |
return $this->wikipediaPageId; |
|
203 |
} |
|
204 |
||
205 |
/** |
|
206 |
* Set urlStatus |
|
207 |
* |
|
208 |
* @param smallint $urlStatus |
|
209 |
*/ |
|
210 |
public function setUrlStatus($urlStatus) |
|
211 |
{ |
|
212 |
$this->urlStatus = $urlStatus; |
|
213 |
} |
|
214 |
||
215 |
/** |
|
216 |
* Get urlStatus |
|
217 |
* |
|
218 |
* @return smallint |
|
219 |
*/ |
|
220 |
public function getUrlStatus() |
|
221 |
{ |
|
222 |
return $this->urlStatus; |
|
223 |
} |
|
|
5
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
224 |
|
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
225 |
/** |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
226 |
* Get UrlStatusText |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
227 |
* |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
228 |
* @return string |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
229 |
*/ |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
230 |
public function getUrlStatusText() |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
231 |
{ |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
232 |
switch ($this->getUrlStatus()) { |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
233 |
case 0: |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
234 |
return "null_result"; |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
235 |
case 1: |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
236 |
return "redirection"; |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
237 |
case 2: |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
238 |
return "homonyme"; |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
239 |
case 3: |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
240 |
return "match"; |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
241 |
} |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
242 |
} |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
243 |
|
| 2 | 244 |
|
245 |
/** |
|
246 |
* Set dbpediaUri |
|
247 |
* |
|
248 |
* @param string $dbpediaUri |
|
249 |
*/ |
|
250 |
public function setDbpediaUri($dbpediaUri) |
|
251 |
{ |
|
252 |
$this->dbpediaUri = $dbpediaUri; |
|
253 |
} |
|
254 |
||
255 |
/** |
|
256 |
* Get dbpediaUri |
|
257 |
* |
|
258 |
* @return string |
|
259 |
*/ |
|
260 |
public function getDbpediaUri() |
|
261 |
{ |
|
262 |
return $this->dbpediaUri; |
|
263 |
} |
|
264 |
||
265 |
/** |
|
266 |
* Set popularity |
|
267 |
* |
|
268 |
* @param integer $popularity |
|
269 |
*/ |
|
270 |
public function setPopularity($popularity) |
|
271 |
{ |
|
272 |
$this->popularity = $popularity; |
|
273 |
} |
|
274 |
||
275 |
/** |
|
276 |
* Get popularity |
|
277 |
* |
|
278 |
* @return integer |
|
279 |
*/ |
|
280 |
public function getPopularity() |
|
281 |
{ |
|
282 |
return $this->popularity; |
|
283 |
} |
|
284 |
||
|
5
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
285 |
/** |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
286 |
* Set category |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
287 |
* |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
288 |
* @param object $category |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
289 |
*/ |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
290 |
public function setCategory($category) |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
291 |
{ |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
292 |
$this->category = $category; |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
293 |
} |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
294 |
|
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
295 |
/** |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
296 |
* Get category |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
297 |
* |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
298 |
* @return object |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
299 |
*/ |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
300 |
function getCategory() |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
301 |
{ |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
302 |
return $this->category; |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
303 |
} |
|
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
304 |
|
|
11
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
8
diff
changeset
|
305 |
/** |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
8
diff
changeset
|
306 |
* Set category to Null |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
8
diff
changeset
|
307 |
* |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
8
diff
changeset
|
308 |
*/ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
8
diff
changeset
|
309 |
function nullCategory() |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
8
diff
changeset
|
310 |
{ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
8
diff
changeset
|
311 |
return $this->setCategory(NULL); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
8
diff
changeset
|
312 |
} |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
8
diff
changeset
|
313 |
|
| 2 | 314 |
|
315 |
} |