|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SCI; |
|
4
|
|
|
|
|
5
|
|
|
use SMW\MediaWiki\Renderer\WikitextTemplateRenderer; |
|
|
|
|
|
|
6
|
|
|
use Parser; |
|
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @license GNU GPL v2+ |
|
10
|
|
|
* @since 1.0 |
|
11
|
|
|
* |
|
12
|
|
|
* @author mwjames |
|
13
|
|
|
*/ |
|
14
|
|
|
class CitationTextTemplateRenderer { |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @var WikitextTemplateRenderer |
|
18
|
|
|
*/ |
|
19
|
|
|
private $wikitextTemplateRenderer; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var Parser |
|
23
|
|
|
*/ |
|
24
|
|
|
private $parser; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var string |
|
28
|
|
|
*/ |
|
29
|
|
|
private $templateName = ''; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @since 1.0 |
|
33
|
|
|
* |
|
34
|
|
|
* @param WikitextTemplateRenderer $wikitextTemplateRenderer |
|
35
|
|
|
* @param Parser $parser |
|
36
|
|
|
*/ |
|
37
|
15 |
|
public function __construct( WikitextTemplateRenderer $wikitextTemplateRenderer, Parser $parser ) { |
|
38
|
15 |
|
$this->wikitextTemplateRenderer = $wikitextTemplateRenderer; |
|
39
|
15 |
|
$this->parser = $parser; |
|
40
|
15 |
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @since 1.0 |
|
44
|
|
|
* |
|
45
|
|
|
* @param string $templateName |
|
46
|
|
|
*/ |
|
47
|
2 |
|
public function packFieldsForTemplate( $templateName ) { |
|
48
|
2 |
|
$this->templateName = $templateName; |
|
49
|
2 |
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @since 1.0 |
|
53
|
|
|
* |
|
54
|
|
|
* @param array $parameters |
|
55
|
|
|
* |
|
56
|
|
|
* @return string |
|
57
|
|
|
*/ |
|
58
|
2 |
|
public function renderFor( array $parameters ) { |
|
59
|
|
|
|
|
60
|
2 |
|
$wikiText = $this->doFormat( $parameters ); |
|
61
|
|
|
|
|
62
|
2 |
|
if ( $wikiText === '' ) { |
|
63
|
|
|
return ''; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
2 |
|
return $this->parser->recursivePreprocess( $wikiText ); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
2 |
|
private function doFormat( array $parameters ) { |
|
70
|
|
|
|
|
71
|
2 |
|
if ( $this->templateName === '' ) { |
|
72
|
|
|
return ''; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
2 |
|
foreach ( $parameters as $key => $values ) { |
|
76
|
|
|
|
|
77
|
2 |
|
$key = strtolower( trim( $key ) ); |
|
78
|
2 |
|
$pieces = []; |
|
79
|
|
|
|
|
80
|
2 |
|
foreach ( $values as $value ) { |
|
81
|
2 |
|
$pieces[] = trim( $value ); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
2 |
|
$this->wikitextTemplateRenderer->addField( $key, implode( ', ', $pieces ) ); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
2 |
|
$this->wikitextTemplateRenderer->packFieldsForTemplate( $this->templateName ); |
|
88
|
|
|
|
|
89
|
2 |
|
return $this->wikitextTemplateRenderer->render(); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
} |
|
93
|
|
|
|
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