|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of dispositif/wikibot application |
|
4
|
|
|
* 2019 : Philippe M. <[email protected]> |
|
5
|
|
|
* For the full copyright and MIT license information, please view the LICENSE file. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
declare(strict_types=1); |
|
9
|
|
|
|
|
10
|
|
|
namespace App\Domain\Models\Wiki; |
|
11
|
|
|
|
|
12
|
|
|
use App\Domain\Utils\TextUtil; |
|
13
|
|
|
use App\Domain\Utils\WikiTextUtil; |
|
14
|
|
|
use Exception; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class ArticleTemplate |
|
18
|
|
|
*/ |
|
19
|
|
|
class ArticleTemplate extends AbstractWikiTemplate implements ArticleTemplateAlias, ArticleOrLienBriseInterface |
|
20
|
|
|
{ |
|
21
|
|
|
use ArticleTemplateParams, BiblioTemplateTrait; |
|
22
|
|
|
|
|
23
|
|
|
const WIKITEMPLATE_NAME = 'Article'; |
|
24
|
|
|
|
|
25
|
|
|
const REQUIRED_PARAMETERS = ['titre', 'périodique', 'date']; |
|
26
|
|
|
|
|
27
|
|
|
const MINIMUM_PARAMETERS |
|
28
|
|
|
= [ |
|
29
|
|
|
// 'langue' => '', |
|
30
|
|
|
'auteur1' => '', |
|
31
|
|
|
'titre' => '', // <!-- Paramètre obligatoire --> |
|
32
|
|
|
'périodique' => '', // <!-- Paramètre obligatoire --> |
|
33
|
|
|
// 'volume' => '', |
|
34
|
|
|
// 'numéro' => '', |
|
35
|
|
|
'date' => '', // <!-- Paramètre obligatoire --> |
|
36
|
|
|
// 'pages' => '', |
|
37
|
|
|
// 'issn' => '', // Inutile ? https://fr.wikipedia.org/wiki/Discussion_mod%C3%A8le:Article#ISSN |
|
38
|
|
|
// 'e-issn' => '', |
|
39
|
|
|
'lire en ligne' => '', |
|
40
|
|
|
// 'consulté le' => '', // 16 mars 2020 |
|
41
|
|
|
// 'id', |
|
42
|
|
|
]; |
|
43
|
|
|
|
|
44
|
|
|
/* |
|
45
|
|
|
* Default separator |
|
46
|
|
|
*/ |
|
47
|
|
|
public $userSeparator = ' |'; |
|
48
|
|
|
|
|
49
|
|
|
public $externalTemplates = []; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* todo move to BiblioTrait + fusion |
|
53
|
|
|
* Propose fubar pour un <ref name="fubar"> ou un {{article|'id=fubar'}}. |
|
54
|
|
|
* |
|
55
|
|
|
* @return string |
|
56
|
|
|
* @throws Exception |
|
57
|
|
|
*/ |
|
58
|
|
|
public function generateRefName(): string |
|
59
|
|
|
{ |
|
60
|
|
|
// Style "auto1234" |
|
61
|
|
|
if (empty($this->getParam('périodique') || empty($this->getParam('date')))) { |
|
62
|
|
|
return 'auto'.(string)rand(1000, 9999); |
|
63
|
|
|
} |
|
64
|
|
|
// Style "LeMonde15022017" |
|
65
|
|
|
$periodique = str_replace( |
|
66
|
|
|
' ', |
|
67
|
|
|
'', |
|
68
|
|
|
TextUtil::stripPunctuation( |
|
69
|
|
|
TextUtil::stripAccents( |
|
70
|
|
|
WikiTextUtil::unWikify( |
|
71
|
|
|
$this->getParam('périodique') ?? '' |
|
72
|
|
|
) |
|
73
|
|
|
) |
|
74
|
|
|
) |
|
75
|
|
|
); |
|
76
|
|
|
$date = str_replace([' ', '-'], ['', ''], $this->getParam('date')); |
|
77
|
|
|
|
|
78
|
|
|
return $periodique.$date; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
} |
|
82
|
|
|
|