-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBibliographyLoader.php
44 lines (38 loc) · 1019 Bytes
/
BibliographyLoader.php
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
<?php
require_once('WikiLoader.php');
class BibliographyLoader {
static private function parseSource($rawText)
{
if(preg_match_all('/{{Quelle(.*)}}/s', $rawText, $matches) === 1) {
$text = $matches[1][0];
preg_match_all('/|\s*(\w+)\s*=\s*([^|]+)/', $text, $matches);
$i = 0;
$source = array();
while(isset($matches[1][$i])) {
if($matches[1][$i]) {
$source[$matches[1][$i]] = trim(html_entity_decode($matches[2][$i], ENT_QUOTES, 'UTF-8'));
}
$i++;
}
return $source;
} else {
return false;
}
}
static public function getSources(&$ignored = array())
{
$pageids = WikiLoader::getCategoryMembers('Kategorie:Quelle');
$entries = WikiLoader::getEntries($pageids, true, true);
$sources = array();
foreach($entries as $entry) {
$source = self::parseSource($entry['revisions'][0]['*']);
if ($source !== false) {
$source['title'] = $entry['title'];
$sources[] = $source;
} else {
$ignored[] = $entry['title'];
}
}
return $sources;
}
}