|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SCI; |
|
4
|
|
|
|
|
5
|
|
|
use SMW\ApplicationFactory; |
|
6
|
|
|
use SMW\NamespaceExaminer; |
|
7
|
|
|
use SMW\ParameterProcessorFactory; |
|
8
|
|
|
use SCI\Bibtex\BibtexProcessor; |
|
9
|
|
|
use SCI\Bibtex\BibtexParser; |
|
10
|
|
|
use SCI\Bibtex\BibtexAuthorListParser; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @license GNU GPL v2+ |
|
14
|
|
|
* @since 1.0 |
|
15
|
|
|
* |
|
16
|
|
|
* @author mwjames |
|
17
|
|
|
*/ |
|
18
|
|
|
class ParserFunctionFactory { |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* {{#scite:}} |
|
22
|
|
|
* |
|
23
|
|
|
* @since 1.0 |
|
24
|
|
|
* |
|
25
|
|
|
* @param NamespaceExaminer $namespaceExaminer |
|
26
|
|
|
* @param Options $options |
|
27
|
|
|
* |
|
28
|
|
|
* @return array |
|
29
|
|
|
*/ |
|
30
|
15 |
|
public function newSciteParserFunctionDefinition( NamespaceExaminer $namespaceExaminer, Options $options ) { |
|
31
|
|
|
|
|
32
|
|
|
$sciteParserFunctionDefinition = function( $parser ) use( $namespaceExaminer, $options ) { |
|
33
|
|
|
|
|
34
|
15 |
|
$parserData = ApplicationFactory::getInstance()->newParserData( |
|
35
|
15 |
|
$parser->getTitle(), |
|
36
|
15 |
|
$parser->getOutput() |
|
37
|
15 |
|
); |
|
38
|
|
|
|
|
39
|
15 |
|
$mwCollaboratorFactory = ApplicationFactory::getInstance()->newMwCollaboratorFactory(); |
|
40
|
|
|
|
|
41
|
15 |
|
$citationTextTemplateRenderer = new CitationTextTemplateRenderer( |
|
42
|
15 |
|
$mwCollaboratorFactory->newWikitextTemplateRenderer(), |
|
43
|
|
|
$parser |
|
44
|
15 |
|
); |
|
45
|
|
|
|
|
46
|
15 |
|
$mediaWikiNsContentMapper = new MediaWikiNsContentMapper( |
|
47
|
15 |
|
$mwCollaboratorFactory->newMediaWikiNsContentReader() |
|
48
|
15 |
|
); |
|
49
|
|
|
|
|
50
|
15 |
|
$sciteParserFunction = new SciteParserFunction( |
|
51
|
15 |
|
$parserData, |
|
52
|
15 |
|
$namespaceExaminer, |
|
53
|
15 |
|
$citationTextTemplateRenderer, |
|
54
|
15 |
|
$mediaWikiNsContentMapper, |
|
55
|
15 |
|
new BibtexProcessor( new BibtexParser(), new BibtexAuthorListParser() ) |
|
56
|
15 |
|
); |
|
57
|
|
|
|
|
58
|
15 |
|
$sciteParserFunction->setStrictParserValidationState( |
|
59
|
15 |
|
$options->get( 'enabledStrictParserValidation' ) |
|
|
|
|
|
|
60
|
15 |
|
); |
|
61
|
|
|
|
|
62
|
15 |
|
return $sciteParserFunction->doProcess( |
|
63
|
15 |
|
ParameterProcessorFactory::newFromArray( func_get_args() ), |
|
64
|
15 |
|
new PreTextFormatter() |
|
65
|
15 |
|
); |
|
66
|
2 |
|
}; |
|
67
|
|
|
|
|
68
|
2 |
|
return [ 'scite', $sciteParserFunctionDefinition, 0 ]; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* {{#referencelist:}} |
|
73
|
|
|
* |
|
74
|
|
|
* @since 1.0 |
|
75
|
|
|
* |
|
76
|
|
|
* @return array |
|
77
|
|
|
*/ |
|
78
|
|
|
public function newReferenceListParserFunctionDefinition() { |
|
79
|
|
|
|
|
80
|
5 |
|
$referenceListParserFunctionDefinition = function( $parser ) { |
|
81
|
|
|
|
|
82
|
5 |
|
$parserData = ApplicationFactory::getInstance()->newParserData( |
|
83
|
5 |
|
$parser->getTitle(), |
|
84
|
5 |
|
$parser->getOutput() |
|
85
|
5 |
|
); |
|
86
|
|
|
|
|
87
|
5 |
|
$referenceListParserFunction = new ReferenceListParserFunction( $parserData ); |
|
88
|
|
|
|
|
89
|
5 |
|
return $referenceListParserFunction->doProcess( |
|
90
|
5 |
|
ParameterProcessorFactory::newFromArray( func_get_args() ) |
|
91
|
5 |
|
); |
|
92
|
2 |
|
}; |
|
93
|
|
|
|
|
94
|
2 |
|
return [ 'referencelist', $referenceListParserFunctionDefinition, 0 ]; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
} |
|
98
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: