|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
|
4
|
|
|
|
|
5
|
|
|
namespace ModernTimeline\SlidePresenter; |
|
6
|
|
|
|
|
7
|
|
|
use MediaWiki\MediaWikiServices; |
|
|
|
|
|
|
8
|
|
|
use ModernTimeline\ResultFacade\PropertyValueCollection; |
|
9
|
|
|
use ModernTimeline\ResultFacade\Subject; |
|
10
|
|
|
use SMW\DataValueFactory; |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class TemplateSlidePresenter implements SlidePresenter { |
|
13
|
|
|
|
|
14
|
|
|
public function __construct( |
|
15
|
|
|
private string $templateName |
|
16
|
2 |
|
) { |
|
17
|
2 |
|
} |
|
18
|
2 |
|
|
|
19
|
|
|
public function getText( Subject $subject ): string { |
|
20
|
1 |
|
$parser = $this->getParser(); |
|
21
|
1 |
|
|
|
22
|
|
|
return $parser->recursiveTagParseFully( |
|
23
|
1 |
|
( new TemplateSlidePresenter( $this->templateName ) )->getTemplateText( $subject ) |
|
24
|
1 |
|
); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
private function getParser(): \Parser { |
|
|
|
|
|
|
28
|
1 |
|
return MediaWikiServices::getInstance()->getParser(); |
|
29
|
1 |
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function getTemplateText( Subject $subject ): string { |
|
32
|
2 |
|
return '{{' . implode( '|', $this->getTemplateSegments( $subject ) ) . '}}'; |
|
33
|
2 |
|
} |
|
34
|
|
|
|
|
35
|
|
|
private function getTemplateSegments( Subject $subject ): array { |
|
36
|
2 |
|
return array_merge( |
|
37
|
2 |
|
[ |
|
38
|
|
|
$this->templateName, |
|
39
|
2 |
|
$this->parameter( 'title', $subject->getWikiPage()->getTitle()->getFullText() ) |
|
40
|
2 |
|
], |
|
41
|
|
|
array_map( |
|
42
|
2 |
|
function( PropertyValueCollection $pvc ) { |
|
43
|
2 |
|
return $this->parameter( |
|
44
|
2 |
|
$pvc->getPrintRequest()->getText( null ) ?? '', |
|
45
|
2 |
|
$pvc->getDataItems() === [] ? '' : $this->dataItemToText( $pvc->getDataItems()[0] ) |
|
46
|
2 |
|
); |
|
47
|
|
|
}, |
|
48
|
2 |
|
$subject->getPropertyValueCollections()->toArray() |
|
49
|
2 |
|
) |
|
50
|
|
|
); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
private function dataItemToText( \SMWDataItem $dataItem ): string { |
|
|
|
|
|
|
54
|
2 |
|
return DataValueFactory::getInstance()->newDataValueByItem( $dataItem )->getLongHTMLText(); |
|
55
|
2 |
|
} |
|
56
|
|
|
|
|
57
|
|
|
private function parameter( string $name, string $value ): string { |
|
58
|
2 |
|
return $name . '=' . $value; |
|
59
|
2 |
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths