Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 22 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
CreateMWSHarvest | |
0.00% |
0 / 19 |
|
0.00% |
0 / 5 |
56 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
generateIndexString | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |||
getHead | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getFooter | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * Generates harvest files for the MathWebSearch Deamon. |
4 | * Example: php CreateMathIndex.php ~/mws_harvest_files |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU General Public License along |
17 | * with this program; if not, write to the Free Software Foundation, Inc., |
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
19 | * http://www.gnu.org/copyleft/gpl.html |
20 | * |
21 | * @ingroup Maintenance |
22 | */ |
23 | |
24 | require_once __DIR__ . '/IndexBase.php'; |
25 | |
26 | /** |
27 | * @author Moritz Schubotz |
28 | */ |
29 | class CreateMWSHarvest extends IndexBase { |
30 | |
31 | /** @var MwsDumpWriter */ |
32 | private $dw; |
33 | |
34 | public function __construct() { |
35 | parent::__construct(); |
36 | $this->addDescription( 'Generates harvest files for the MathWebSearch Daemon.' ); |
37 | $this->addOption( 'mwsns', 'The namespace or mws normally "mws:"', false ); |
38 | } |
39 | |
40 | /** |
41 | * @param stdClass $row |
42 | * |
43 | * @return string |
44 | */ |
45 | protected function generateIndexString( $row ) { |
46 | $xml = simplexml_load_string( $row->math_mathml ); |
47 | if ( !$xml ) { |
48 | echo "ERROR while converting:\n " . var_export( $row->math_mathml, true ) . "\n"; |
49 | foreach ( libxml_get_errors() as $error ) { |
50 | echo "\t", $error->message; |
51 | } |
52 | libxml_clear_errors(); |
53 | return ''; |
54 | } |
55 | return $this->dw->getMwsExpression( |
56 | $row->math_mathml, |
57 | $row->mathindex_revision_id, |
58 | $row->mathindex_anchor ); |
59 | } |
60 | |
61 | protected function getHead() { |
62 | return $this->dw->getHead(); |
63 | } |
64 | |
65 | protected function getFooter() { |
66 | return $this->dw->getFooter(); |
67 | } |
68 | |
69 | public function execute() { |
70 | $ns = $this->getOption( 'mwsns', '' ); |
71 | $this->dw = new MwsDumpWriter( $ns ); |
72 | parent::execute(); |
73 | } |
74 | } |
75 | |
76 | $maintClass = CreateMWSHarvest::class; |
77 | /** @noinspection PhpIncludeInspection */ |
78 | require_once RUN_MAINTENANCE_IF_MAIN; |