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