Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
WikiLinkExtractor | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
getXPath | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
perform | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace Flow\Parsoid\Extractor; |
4 | |
5 | use DOMElement; |
6 | use Flow\Model\Reference; |
7 | use Flow\Parsoid\Extractor; |
8 | use Flow\Parsoid\ReferenceFactory; |
9 | |
10 | /** |
11 | * Finds and creates References for internal wiki links in parsoid HTML |
12 | */ |
13 | class WikiLinkExtractor implements Extractor { |
14 | /** |
15 | * @inheritDoc |
16 | */ |
17 | public function getXPath() { |
18 | return '//a[contains(concat(" ",normalize-space(@rel)," ")," mw:WikiLink ")][not(@typeof)]'; |
19 | } |
20 | |
21 | /** |
22 | * @inheritDoc |
23 | */ |
24 | public function perform( ReferenceFactory $factory, DOMElement $element ) { |
25 | $href = $element->getAttribute( 'href' ); |
26 | if ( $href === '' ) { |
27 | return null; |
28 | } |
29 | |
30 | return $factory->createWikiReference( |
31 | Reference::TYPE_LINK, |
32 | urldecode( $href ) |
33 | ); |
34 | } |
35 | } |