Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 30 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
MathEngineMws | |
0.00% |
0 / 30 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
processMathResults | |
0.00% |
0 / 28 |
|
0.00% |
0 / 1 |
30 |
1 | <?php |
2 | |
3 | use MediaWiki\Logger\LoggerFactory; |
4 | |
5 | /** |
6 | * MediaWiki MathSearch extension |
7 | * |
8 | * (c) 2014 Moritz Schubotz |
9 | * GPLv2 license; info in main package. |
10 | * |
11 | * @file |
12 | * @ingroup extensions |
13 | */ |
14 | class MathEngineMws extends MathEngineRest { |
15 | |
16 | function __construct( $query ) { |
17 | global $wgMathSearchMWSUrl; |
18 | parent::__construct( $query, $wgMathSearchMWSUrl ); |
19 | } |
20 | |
21 | /** |
22 | * @param SimpleXMLElement $xmlRoot |
23 | */ |
24 | function processMathResults( $xmlRoot ) { |
25 | foreach ( $xmlRoot->children( "mws", true ) as $page ) { |
26 | $attrs = $page->attributes(); |
27 | if ( str_contains( $attrs['uri'], '#' ) ) { |
28 | $uri = explode( "#", $attrs["uri"] ); |
29 | $revisionID = $uri[0]; |
30 | $AnchorID = $uri[1]; |
31 | } else { |
32 | $uri = explode( ".", $attrs["uri"] ); |
33 | if ( count( $uri ) > 2 ) { |
34 | $revisionID = $uri[1]; |
35 | $AnchorID = $uri[2]; |
36 | } else { |
37 | LoggerFactory::getInstance( 'MathSearch' )->error( $attrs["uri"] . |
38 | ' has an invalid result format.' ); |
39 | continue; |
40 | } |
41 | } |
42 | $this->relevanceMap[] = $revisionID; |
43 | $substarr = []; |
44 | foreach ( $page->children( "mws", true ) as $substpair ) { |
45 | $substattrs = $substpair->attributes(); |
46 | $substarr[] = |
47 | [ |
48 | "qvar" => (string)$substattrs["qvar"], |
49 | "xpath" => (string)$substattrs["xpath"] |
50 | ]; |
51 | } |
52 | $this->resultSet[(string)$revisionID][(string)$AnchorID][] = |
53 | [ |
54 | "xpath" => (string)$attrs["xpath"], |
55 | "mappings" => $substarr |
56 | ]; // ,"original"=>$page->asXML() |
57 | } |
58 | $this->relevanceMap = array_unique( $this->relevanceMap ); |
59 | } |
60 | } |