1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of dispositif/wikibot application (@github) |
4
|
|
|
* 2019-2023 © Philippe M./Irønie <[email protected]> |
5
|
|
|
* For the full copyright and MIT license information, view the license file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
declare(strict_types=1); |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace App\Domain\WikiOptimizer\Handlers; |
12
|
|
|
|
13
|
|
|
use Exception; |
14
|
|
|
|
15
|
|
|
class ExternalTemplateHandler extends AbstractOuvrageHandler |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* TODO move+refac |
19
|
|
|
* TODO CommentaireBiblioTemplate ExtraitTemplate |
20
|
|
|
* Probleme {{commentaire biblio}} <> {{commentaire biblio SRL}} |
21
|
|
|
* Generate supplementary templates from obsoletes params. |
22
|
|
|
* @throws Exception |
23
|
|
|
*/ |
24
|
|
|
public function handle() |
25
|
|
|
{ |
26
|
|
|
// "extrait=bla" => {{citation bloc|bla}} |
27
|
|
|
if ($this->hasParamValue('extrait')) { |
28
|
|
|
$extrait = $this->getParam('extrait'); |
29
|
|
|
// todo bug {{citation bloc}} si "=" ou "|" dans texte de citation |
30
|
|
|
// Legacy : use {{début citation}} ... {{fin citation}} |
31
|
|
|
if (preg_match('#[=|]#', $extrait) > 0) { |
|
|
|
|
32
|
|
|
$this->ouvrage->externalTemplates[] = (object)[ |
33
|
|
|
'template' => 'début citation', |
34
|
|
|
'1' => '', |
35
|
|
|
'raw' => '{{Début citation}}' . $extrait . '{{Fin citation}}', |
36
|
|
|
]; |
37
|
|
|
$this->addSummaryLog('{Début citation}'); |
38
|
|
|
$this->optiStatus->setNotCosmetic(true); |
39
|
|
|
} else { |
40
|
|
|
// StdClass |
41
|
|
|
$this->ouvrage->externalTemplates[] = (object)[ |
42
|
|
|
'template' => 'citation bloc', |
43
|
|
|
'1' => $extrait, |
44
|
|
|
'raw' => '{{Citation bloc|' . $extrait . '}}', |
45
|
|
|
]; |
46
|
|
|
$this->addSummaryLog('{Citation bloc}'); |
47
|
|
|
$this->optiStatus->setNotCosmetic(true); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$this->unsetParam('extrait'); |
51
|
|
|
$this->optiStatus->setNotCosmetic(true); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
// "commentaire=bla" => {{Commentaire biblio|1=bla}} |
55
|
|
|
if ($this->hasParamValue('commentaire')) { |
56
|
|
|
$commentaire = $this->getParam('commentaire'); |
57
|
|
|
$this->ouvrage->externalTemplates[] = (object)[ |
58
|
|
|
'template' => 'commentaire biblio', |
59
|
|
|
'1' => $commentaire, |
60
|
|
|
'raw' => '{{Commentaire biblio|' . $commentaire . '}}', |
61
|
|
|
]; |
62
|
|
|
$this->unsetParam('commentaire'); |
63
|
|
|
$this->addSummaryLog('{commentaire}'); |
64
|
|
|
$this->optiStatus->setNotCosmetic(true); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
} |