|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File holding the Lingo\Backend class |
|
5
|
|
|
* |
|
6
|
|
|
* This file is part of the MediaWiki extension Lingo. |
|
7
|
|
|
* |
|
8
|
|
|
* @copyright 2011 - 2018, Stephan Gambke |
|
9
|
|
|
* @license GPL-2.0-or-later |
|
10
|
|
|
* |
|
11
|
|
|
* The Lingo extension is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU General Public License as published by the Free |
|
13
|
|
|
* Software Foundation; either version 2 of the License, or (at your option) any |
|
14
|
|
|
* later version. |
|
15
|
|
|
* |
|
16
|
|
|
* The Lingo extension is distributed in the hope that it will be useful, but |
|
17
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
18
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
19
|
|
|
* details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU General Public License along |
|
22
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>. |
|
23
|
|
|
* |
|
24
|
|
|
* @author Stephan Gambke |
|
25
|
|
|
* @file |
|
26
|
|
|
* @ingroup Lingo |
|
27
|
|
|
*/ |
|
28
|
|
|
|
|
29
|
|
|
namespace Lingo; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* The Lingo\Backend class. |
|
33
|
|
|
* |
|
34
|
|
|
* @ingroup Lingo |
|
35
|
|
|
*/ |
|
36
|
|
|
abstract class Backend { |
|
37
|
|
|
|
|
38
|
|
|
protected $mMessageLog; |
|
39
|
|
|
protected $mLingoParser; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Lingo\Backend constructor. |
|
43
|
|
|
* @param MessageLog|null &$messages |
|
44
|
|
|
*/ |
|
45
|
2 |
|
public function __construct( MessageLog &$messages = null ) { |
|
46
|
2 |
|
$this->mMessageLog = $messages; |
|
47
|
2 |
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return MessageLog |
|
51
|
|
|
*/ |
|
52
|
4 |
|
public function getMessageLog() { |
|
53
|
4 |
|
if ( !$this->mMessageLog ) { |
|
54
|
2 |
|
$this->mMessageLog = new MessageLog(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
4 |
|
return $this->mMessageLog; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return LingoParser |
|
62
|
|
|
*/ |
|
63
|
4 |
|
public function getLingoParser() { |
|
64
|
4 |
|
if ( !$this->mLingoParser ) { |
|
65
|
2 |
|
$this->mLingoParser = LingoParser::getInstance(); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
4 |
|
return $this->mLingoParser; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @param LingoParser $mLingoParser |
|
73
|
|
|
*/ |
|
74
|
2 |
|
public function setLingoParser( LingoParser $mLingoParser ) { |
|
75
|
2 |
|
$this->mLingoParser = $mLingoParser; |
|
76
|
2 |
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* This function returns true if the backend is cache-enabled. |
|
80
|
|
|
* |
|
81
|
|
|
* Actual caching is done by the parser, but to be cache-enabled the backend |
|
82
|
|
|
* has to call Lingo\LingoParser::purgeCache when necessary. |
|
83
|
|
|
* |
|
84
|
|
|
* @return bool |
|
85
|
|
|
*/ |
|
86
|
1 |
|
public function useCache() { |
|
87
|
1 |
|
return false; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* This function returns the next element. The element is an array of four |
|
92
|
|
|
* strings: Term, Definition (as wikitext), Link (as URL or Article title), Source (unused). |
|
93
|
|
|
* |
|
94
|
|
|
* If there is no next element the function returns null. |
|
95
|
|
|
* |
|
96
|
|
|
* @return array | null |
|
97
|
|
|
*/ |
|
98
|
|
|
abstract public function next(); |
|
99
|
|
|
} |
|
100
|
|
|
|