|
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 - 2016, Stephan Gambke |
|
9
|
|
|
* @license GNU General Public License, version 2 (or any later version) |
|
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
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Lingo\Backend constructor. |
|
42
|
|
|
* @param MessageLog|null $messages |
|
43
|
|
|
*/ |
|
44
|
2 |
|
public function __construct( MessageLog &$messages = null ) { |
|
45
|
|
|
|
|
46
|
2 |
|
if ( !$messages ) { |
|
47
|
2 |
|
$this->mMessageLog = new MessageLog(); |
|
48
|
2 |
|
} else { |
|
49
|
|
|
$this->mMessageLog = $messages; |
|
50
|
|
|
} |
|
51
|
2 |
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @return MessageLog |
|
55
|
|
|
*/ |
|
56
|
|
|
public function getMessageLog() { |
|
57
|
|
|
return $this->mMessageLog; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* This function returns true if the backend is cache-enabled. |
|
62
|
|
|
* |
|
63
|
|
|
* Actual caching is done by the parser, but to be cache-enabled the backend |
|
64
|
|
|
* has to call Lingo\LingoParser::purgeCache when necessary. |
|
65
|
|
|
* |
|
66
|
|
|
* @return boolean |
|
67
|
|
|
*/ |
|
68
|
2 |
|
public function useCache() { |
|
69
|
2 |
|
return false; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* This function returns the next element. The element is an array of four |
|
74
|
|
|
* strings: Term, Definition, Link, Source. If there is no next element the |
|
75
|
|
|
* function returns null. |
|
76
|
|
|
* |
|
77
|
|
|
* @return Element | null |
|
78
|
|
|
*/ |
|
79
|
|
|
abstract public function next(); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
|