1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of dispositif/wikibot application (@github) |
4
|
|
|
* 2019/2020 © 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
|
|
|
|
11
|
|
|
namespace App\Application; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
trait EditSummaryTrait |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* For substantive or ambiguous modifications done. |
18
|
|
|
* |
19
|
|
|
* @param string $tag |
20
|
|
|
*/ |
21
|
|
|
private function addSummaryTag(string $tag) |
22
|
|
|
{ |
23
|
|
|
if (!in_array($tag, $this->importantSummary)) { |
24
|
|
|
$this->importantSummary[] = $tag; |
|
|
|
|
25
|
|
|
} |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* todo extract |
30
|
|
|
* Generate wiki edition summary. |
31
|
|
|
* |
32
|
|
|
* @return string |
33
|
|
|
*/ |
34
|
|
|
public function generateSummary(): string |
35
|
|
|
{ |
36
|
|
|
// Start summary with "WikiBotConfig" when using botFlag, else "*" |
37
|
|
|
$prefix = ($this->botFlag) ? 'bot' : '☆'; //🧐 🤖 |
38
|
|
|
// add "/!\" when errorWarning |
39
|
|
|
$prefix .= (!empty($this->errorWarning)) ? ' ⚠️' : ''; |
40
|
|
|
|
41
|
|
|
// basic modifs |
42
|
|
|
$citeSummary = implode(' ', $this->citationSummary); |
43
|
|
|
// replace by list of modifs to verify by humans |
44
|
|
|
if (!empty($this->importantSummary)) { |
45
|
|
|
$citeSummary = implode(', ', $this->importantSummary); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
$summary = sprintf( |
49
|
|
|
'%s [%s/%s] %s %sx : %s', |
50
|
|
|
$prefix, |
51
|
|
|
str_replace('v', '', $this->bot::getGitVersion()), |
52
|
|
|
str_replace(['v0.', 'v1.'], '', $this->citationVersion), |
53
|
|
|
self::TASK_NAME, |
|
|
|
|
54
|
|
|
$this->nbRows, |
55
|
|
|
$citeSummary |
56
|
|
|
); |
57
|
|
|
|
58
|
|
|
if (!empty($this->importantSummary)) { |
59
|
|
|
$summary .= '...'; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
// shrink long summary if no important details to verify |
63
|
|
|
if (empty($this->importantSummary)) { |
64
|
|
|
$length = strlen($summary); |
65
|
|
|
$summary = mb_substr($summary, 0, 80); |
66
|
|
|
$summary .= ($length > strlen($summary)) ? '…' : ''; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
return $summary; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
} |
73
|
|
|
|