1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of dispositif/wikibot application |
5
|
|
|
* 2019 © Philippe M. <[email protected]> |
6
|
|
|
* For the full copyright and MIT license information, please view the LICENSE file. |
7
|
|
|
*/ |
8
|
|
|
declare(strict_types=1); |
9
|
|
|
|
10
|
|
|
namespace App\Application\Examples; |
11
|
|
|
|
12
|
|
|
use App\Application\AbstractBotTaskWorker; |
13
|
|
|
use App\Application\Ref2ArticleProcess; |
14
|
|
|
use App\Application\WikiBotConfig; |
15
|
|
|
use App\Infrastructure\CirrusSearch; |
16
|
|
|
use App\Infrastructure\ServiceFactory; |
17
|
|
|
|
18
|
|
|
include __DIR__.'/../myBootstrap.php'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* TODO move PROCESS FROM BOTTOM |
22
|
|
|
* Class Ref2ArticleWorker |
23
|
|
|
* |
24
|
|
|
* @package App\Application\Examples |
25
|
|
|
*/ |
26
|
|
|
class Ref2ArticleWorker extends AbstractBotTaskWorker |
27
|
|
|
{ |
28
|
|
|
const TASK_NAME = "Amélioration bibliographique : URL ⇒ {Article}"; // 😎 |
29
|
|
|
const SLEEP_AFTER_EDITION = 120; |
30
|
|
|
protected $botFlag = false; |
31
|
|
|
protected $modeAuto = true; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @inheritDoc |
35
|
|
|
*/ |
36
|
|
|
protected function processDomain(string $title, ?string $text): ?string |
37
|
|
|
{ |
38
|
|
|
$converter = new Ref2ArticleProcess(); |
39
|
|
|
|
40
|
|
|
// Signalement erreur |
41
|
|
|
if ($converter->hasWarning()) { |
42
|
|
|
$this->taskName = '⚠ Amélioration bibliographique : <ref> avec lien brisé !'; |
43
|
|
|
$this->botFlag = false; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
return $converter->processText($text); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
// &srqiprofile=popular_inclinks_pv&srsort=last_edit_desc |
52
|
|
|
$cirrusURL |
53
|
|
|
= 'https://fr.wikipedia.org/w/api.php?action=query&list=search&srsearch=%22https%3A%2F%2Fwww.lemonde.fr%22+insource%3A%2F%5C%3Cref%5C%3Ehttps%5C%3A%5C%2F%5C%2Fwww%5C.lemonde%5C.fr%5B%5E%5C%3E%5D%2B%5C%3C%5C%2Fref%3E%2F&formatversion=2&format=json&srnamespace=0&srlimit=100&srqiprofile=popular_inclinks_pv&srsort=random'; |
54
|
|
|
$wiki = ServiceFactory::wikiApi(); |
55
|
|
|
$botConfig = new WikiBotConfig(); |
56
|
|
|
$cirrusList = new CirrusSearch($cirrusURL); |
57
|
|
|
new Ref2ArticleWorker($botConfig, $wiki, $cirrusList); |
58
|
|
|
|