|
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
|
|
|
namespace App\Domain\Transformers\Handlers; |
|
11
|
|
|
|
|
12
|
|
|
use App\Domain\Transformers\OuvrageMixTrait; |
|
13
|
|
|
use App\Domain\Utils\WikiTextUtil; |
|
14
|
|
|
|
|
15
|
|
|
class MixTitle extends AbstractMixHandler |
|
16
|
|
|
{ |
|
17
|
|
|
use OuvrageMixTrait; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Add or extract subtitle like in second book. |
|
21
|
|
|
*/ |
|
22
|
|
|
public function handle() |
|
23
|
|
|
{ |
|
24
|
|
|
if (!$this->book->hasParamValue('sous-titre') |
|
25
|
|
|
|| !$this->origin->hasParamValue('titre') |
|
26
|
|
|
|| !$this->book->hasParamValue('titre') |
|
27
|
|
|
) { |
|
28
|
|
|
return; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
// Skip pour éviter conflit entre 'sous-titre' et 'collection' ou 'titre volume' |
|
32
|
|
|
if ($this->origin->hasParamValue('titre volume') |
|
33
|
|
|
|| $this->origin->hasParamValue('titre chapitre') |
|
34
|
|
|
|| $this->origin->hasParamValue('titre tome') |
|
35
|
|
|
|| $this->origin->hasParamValue('collection') |
|
36
|
|
|
|| $this->origin->hasParamValue('nature ouvrage') |
|
37
|
|
|
) { |
|
38
|
|
|
return; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
// simple : titres identiques mais sous-titre manquant |
|
42
|
|
|
// même titre mais sous-titre manquant |
|
43
|
|
|
if ( |
|
44
|
|
|
$this->stripAll($this->origin->getParam('titre')) |
|
|
|
|
|
|
45
|
|
|
=== $this->stripAll($this->book->getParam('titre')) |
|
46
|
|
|
&& !$this->origin->hasParamValue('sous-titre') |
|
47
|
|
|
) { |
|
48
|
|
|
$this->origin->setParam('sous-titre', $this->book->getParam('sous-titre')); |
|
49
|
|
|
$this->optiStatus->addSummaryLog('++sous-titre'); |
|
50
|
|
|
$this->optiStatus->setMajor(true); |
|
51
|
|
|
$this->optiStatus->setNotCosmetic(true); |
|
52
|
|
|
|
|
53
|
|
|
return; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
// compliqué : sous-titre inclus dans titre original => on copie titre/sous-titre de book |
|
57
|
|
|
// Exclusion wikification "titre=[[Fu : Bar]]" pour éviter => "titre=Fu|sous-titre=Bar" |
|
58
|
|
|
if ($this->charsFromBigTitle($this->origin) === $this->charsFromBigTitle($this->book) |
|
59
|
|
|
&& !WikiTextUtil::isWikify($this->origin->getParam('titre') ?? '') && !$this->origin->hasParamValue('sous-titre')) { |
|
60
|
|
|
$this->origin->setParam('titre', $this->book->getParam('titre')); |
|
61
|
|
|
$this->origin->setParam('sous-titre', $this->book->getParam('sous-titre')); |
|
62
|
|
|
$this->optiStatus->addSummaryLog('>sous-titre'); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
} |