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
|
<?php
class Garradin_Wiki
{
const LECTURE_PUBLIC = -1;
const LECTURE_NORMAL = 0;
const LECTURE_GROUPE = 1;
const ECRITURE_NORMAL = 0;
const ECRITURE_GROUPE = 1;
protected $restriction_categorie = null;
protected $restriction_droit = null;
static public function transformTitleToURI($str)
{
$str = htmlentities($str, ENT_NOQUOTES, 'UTF-8');
$str = preg_replace('#&([A-za-z])(?:acute|cedil|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $str);
$str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $str); // pour les ligatures e.g. 'œ'
$str = preg_replace('#&[^;]+;#', '', $str); // supprime les autres caractères
$str = preg_replace('!\s+!', ' ', $str);
$str = preg_replace('![^a-z0-9_-]!i', '', $str);
return $str;
}
// Gestion des données ///////////////////////////////////////////////////////
|
|
|
<
|
<
<
<
<
|
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
|
<?php
class Garradin_Wiki
{
const LECTURE_PUBLIC = -1;
const LECTURE_NORMAL = 0;
const LECTURE_CATEGORIE = 1;
const ECRITURE_NORMAL = 0;
const ECRITURE_CATEGORIE = 1;
protected $restriction_categorie = null;
protected $restriction_droit = null;
static public function transformTitleToURI($str)
{
$str = utils::transliterateToAscii($str);
$str = preg_replace('!\s+!', ' ', $str);
$str = preg_replace('![^a-z0-9_-]!i', '', $str);
return $str;
}
// Gestion des données ///////////////////////////////////////////////////////
|
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
if ($this->restriction_droit == Garradin_Membres::DROIT_AUCUN)
{
throw new UserException('Vous n\'avez pas accès au wiki.');
}
if ($this->restriction_droit == Garradin_Membres::DROIT_ADMIN)
return '';
return '(droit_lecture = '.self::LECTURE_NORMAL.' OR droit_lecture = '.self::LECTURE_PUBLIC.'
OR droit_lecture = '.(int)$this->restriction_categorie.')';
}
public function canReadPage($lecture)
{
|
|
|
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
if ($this->restriction_droit == Garradin_Membres::DROIT_AUCUN)
{
throw new UserException('Vous n\'avez pas accès au wiki.');
}
if ($this->restriction_droit == Garradin_Membres::DROIT_ADMIN)
return '1';
return '(droit_lecture = '.self::LECTURE_NORMAL.' OR droit_lecture = '.self::LECTURE_PUBLIC.'
OR droit_lecture = '.(int)$this->restriction_categorie.')';
}
public function canReadPage($lecture)
{
|
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
SQLITE3_ASSOC,
(int) $parent
);
}
public function getById($id)
{
}
public function getByURI($uri)
{
}
}
?>
|
>
>
>
>
>
>
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
|
SQLITE3_ASSOC,
(int) $parent
);
}
public function getById($id)
{
$db = Garradin_DB::getInstance();
$page = $db->simpleQuerySingle('SELECT *,
strftime(\'%s\', date_creation) AS date_creation,
strftime(\'%s\', date_modification) AS date_modification
FROM wiki_pages
WHERE id = ? AND '.$this->_getLectureClause().';', true, (int)$id);
if (!$page)
{
return false;
}
if ($page['revision'] > 0)
{
$page['contenu'] = $db->simpleQuerySingle('SELECT * FROM wiki_revisions
WHERE id_page = ? AND revision = ?;', true, (int)$page['id'], (int)$page['revision']);
}
else
{
$page['contenu'] = false;
}
return $page;
}
public function getByURI($uri)
{
$db = Garradin_DB::getInstance();
$page = $db->simpleQuerySingle('SELECT *,
strftime(\'%s\', date_creation) AS date_creation,
strftime(\'%s\', date_modification) AS date_modification
FROM wiki_pages
WHERE uri = ? AND '.$this->_getLectureClause().';', true, trim($uri));
if (!$page)
{
return false;
}
if ($page['revision'] > 0)
{
$page['contenu'] = $db->simpleQuerySingle('SELECT * FROM wiki_revisions
WHERE id_page = ? AND revision = ?;', true, (int)$page['id'], (int)$page['revision']);
}
else
{
$page['contenu'] = false;
}
return $page;
}
}
?>
|