@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | $first = mb_strtoupper(mb_substr($str, 0, 1, $e), $e); |
| 103 | 103 | $rest = mb_substr($str, 1, mb_strlen($str, $e), $e); |
| 104 | 104 | |
| 105 | - return $first . $rest; |
|
| 105 | + return $first.$rest; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $first = mb_strtolower(mb_substr($str, 0, 1, $e), $e); |
| 116 | 116 | $rest = mb_substr($str, 1, mb_strlen($str, $e), $e); |
| 117 | 117 | |
| 118 | - return $first . $rest; |
|
| 118 | + return $first.$rest; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | public static function replaceNonBreakingSpaces(string $text): string |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public static function trim(string $string): string |
| 130 | 130 | { |
| 131 | - return trim($string, self::NO_BREAK_SPACE . self::NO_BREAK_THIN_SPACE . "\n\t\r"); |
|
| 131 | + return trim($string, self::NO_BREAK_SPACE.self::NO_BREAK_THIN_SPACE."\n\t\r"); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | if (mb_strlen($text) > $maxLength) { |
| 255 | 255 | $spacePos = mb_strrpos(mb_substr($text, 0, $maxLength), ' '); |
| 256 | 256 | $spacePos = ($spacePos > ($maxLength - 12)) ? $spacePos : $maxLength; |
| 257 | - $text = trim(mb_substr($text, 0, $spacePos)) . self::SYMBOL_TEXT_CUT; |
|
| 257 | + $text = trim(mb_substr($text, 0, $spacePos)).self::SYMBOL_TEXT_CUT; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | return $text; |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | $refsData = $this->extractAllGoogleRefs($text); |
| 63 | - $this->logger->debug('GoogleTransformer: refs found: ' . count($refsData)); |
|
| 63 | + $this->logger->debug('GoogleTransformer: refs found: '.count($refsData)); |
|
| 64 | 64 | if ($refsData !== []) { |
| 65 | 65 | $text = $this->processRef($text, $refsData); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $links = $this->extractGoogleExternalBullets($text); |
| 69 | - $this->logger->debug('GoogleTransformer: links found: ' . count($links)); |
|
| 69 | + $this->logger->debug('GoogleTransformer: links found: '.count($links)); |
|
| 70 | 70 | if ($links !== []) { |
| 71 | 71 | $text = $this->processExternLinks($text, $links); |
| 72 | 72 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | // <ref>...</ref> or {{ref|...}} |
| 88 | 88 | // GoogleLivresTemplate::GOOGLEBOOK_URL_PATTERN |
| 89 | 89 | if (preg_match_all( |
| 90 | - '#(?:<ref[^>]*>|{{ref\|) ?(' . GoogleBooksUtil::GOOGLEBOOKS_START_URL_PATTERN . '[^>\]} \n]+) ?(?:</ref>|}})#i', |
|
| 90 | + '#(?:<ref[^>]*>|{{ref\|) ?('.GoogleBooksUtil::GOOGLEBOOKS_START_URL_PATTERN.'[^>\]} \n]+) ?(?:</ref>|}})#i', |
|
| 91 | 91 | $text, |
| 92 | 92 | $matches, |
| 93 | 93 | PREG_SET_ORDER |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | protected function processRef(string $text, array $refsData): string |
| 103 | 103 | { |
| 104 | 104 | foreach ($refsData as $ref) { |
| 105 | - $this->logger->info('Process GoogleBooks ref: ' . $ref[1]); |
|
| 105 | + $this->logger->info('Process GoogleBooks ref: '.$ref[1]); |
|
| 106 | 106 | if ($this->quota->isQuotaReached()) { |
| 107 | 107 | $this->logger->debug('Quota Google atteint'); |
| 108 | 108 | throw new DomainException('Quota Google atteint'); |
@@ -111,19 +111,19 @@ discard block |
||
| 111 | 111 | $citation = $this->convertGBurl2OuvrageCitation(WikiTextUtil::stripFinalPoint($ref[1])); |
| 112 | 112 | sleep(2); |
| 113 | 113 | } catch (Throwable $e) { |
| 114 | - $this->logger->debug("Exception " . $e->getMessage()); |
|
| 114 | + $this->logger->debug("Exception ".$e->getMessage()); |
|
| 115 | 115 | continue; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // ajout point final pour référence |
| 119 | 119 | $citation .= '.'; |
| 120 | 120 | |
| 121 | - $newRef = str_replace($ref[1], $citation, (string)$ref[0]); |
|
| 121 | + $newRef = str_replace($ref[1], $citation, (string) $ref[0]); |
|
| 122 | 122 | $this->logger->info($newRef); |
| 123 | 123 | |
| 124 | 124 | $text = str_replace($ref[0], $newRef, $text); |
| 125 | 125 | |
| 126 | - $this->logger->notice("sleep " . self::SLEEP_GOOGLE_API_INTERVAL); |
|
| 126 | + $this->logger->notice("sleep ".self::SLEEP_GOOGLE_API_INTERVAL); |
|
| 127 | 127 | sleep(self::SLEEP_GOOGLE_API_INTERVAL); |
| 128 | 128 | } |
| 129 | 129 | |
@@ -177,13 +177,13 @@ discard block |
||
| 177 | 177 | // Google page => 'passage' |
| 178 | 178 | if (!empty($gooDat['pg'])) { |
| 179 | 179 | // Exclusion de page=1, page=2 (vue par défaut sur Google Book) |
| 180 | - if (preg_match('#(?:PA|PT)(\d+)$#', (string)$gooDat['pg'], $matches) && (int)$matches[1] >= 3) { |
|
| 180 | + if (preg_match('#(?:PA|PT)(\d+)$#', (string) $gooDat['pg'], $matches) && (int) $matches[1] >= 3) { |
|
| 181 | 181 | $page = $matches[1]; |
| 182 | 182 | } |
| 183 | 183 | // conversion chiffres Romain pour PR |
| 184 | 184 | // Exclusion de page=1, page=2 (vue par défaut sur Google Book) |
| 185 | - if (preg_match('#PR(\d+)$#', (string)$gooDat['pg'], $matches) && (int)$matches[1] >= 3) { |
|
| 186 | - $page = NumberUtil::arab2roman((int)$matches[1], true); |
|
| 185 | + if (preg_match('#PR(\d+)$#', (string) $gooDat['pg'], $matches) && (int) $matches[1] >= 3) { |
|
| 186 | + $page = NumberUtil::arab2roman((int) $matches[1], true); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | if (!empty($page)) { |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | { |
| 245 | 245 | // match "* https://books.google.fr/..." |
| 246 | 246 | if (preg_match_all( |
| 247 | - '#^\* *(' . GoogleBooksUtil::GOOGLEBOOKS_START_URL_PATTERN . '[^ <{\]}\n\r]+) *$#im', |
|
| 247 | + '#^\* *('.GoogleBooksUtil::GOOGLEBOOKS_START_URL_PATTERN.'[^ <{\]}\n\r]+) *$#im', |
|
| 248 | 248 | $text, |
| 249 | 249 | $matches, |
| 250 | 250 | PREG_SET_ORDER |
@@ -261,10 +261,10 @@ discard block |
||
| 261 | 261 | * @return string|string[] |
| 262 | 262 | * @throws Throwable |
| 263 | 263 | */ |
| 264 | - protected function processExternLinks(string $text, array $links): string|array |
|
| 264 | + protected function processExternLinks(string $text, array $links): string | array |
|
| 265 | 265 | { |
| 266 | 266 | foreach ($links as $pattern) { |
| 267 | - $this->logger->info('Process links: ' . $pattern[1]); |
|
| 267 | + $this->logger->info('Process links: '.$pattern[1]); |
|
| 268 | 268 | if ($this->quota->isQuotaReached()) { |
| 269 | 269 | $this->logger->debug('Quota Google atteint'); |
| 270 | 270 | throw new DomainException('Quota Google atteint'); |
@@ -272,19 +272,19 @@ discard block |
||
| 272 | 272 | try { |
| 273 | 273 | $citation = $this->convertGBurl2OuvrageCitation(WikiTextUtil::stripFinalPoint($pattern[1])); |
| 274 | 274 | } catch (Exception $e) { |
| 275 | - $this->logger->debug("Exception " . $e->getMessage()); |
|
| 275 | + $this->logger->debug("Exception ".$e->getMessage()); |
|
| 276 | 276 | continue; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | // todo : ajout point final pour référence ??? |
| 280 | 280 | $citation .= '.'; |
| 281 | 281 | |
| 282 | - $newRef = str_replace($pattern[1], $citation, (string)$pattern[0]); |
|
| 282 | + $newRef = str_replace($pattern[1], $citation, (string) $pattern[0]); |
|
| 283 | 283 | $this->logger->info($newRef); |
| 284 | 284 | |
| 285 | 285 | $text = str_replace($pattern[0], $newRef, $text); |
| 286 | 286 | |
| 287 | - $this->logger->info("Sleep " . self::SLEEP_GOOGLE_API_INTERVAL); |
|
| 287 | + $this->logger->info("Sleep ".self::SLEEP_GOOGLE_API_INTERVAL); |
|
| 288 | 288 | sleep(self::SLEEP_GOOGLE_API_INTERVAL); |
| 289 | 289 | } |
| 290 | 290 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | public const SRQIPROFILE_DEFAULT = 'engine_autoselect'; |
| 39 | 39 | |
| 40 | 40 | protected const BASE_URL = 'https://fr.wikipedia.org/w/api.php'; // todo move config |
| 41 | - protected const CONTINUE_OFFSET_FILENAME = __DIR__ . '/../../resources/cirrusSearch-{HASH}.txt'; // todo move config |
|
| 41 | + protected const CONTINUE_OFFSET_FILENAME = __DIR__.'/../../resources/cirrusSearch-{HASH}.txt'; // todo move config |
|
| 42 | 42 | |
| 43 | 43 | protected array $requestParams = []; |
| 44 | 44 | protected array $defaultParams |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | if ($this->options[self::OPTION_CONTINUE] ?? false) { |
| 73 | 73 | $continueOffset = 0; |
| 74 | 74 | if (!empty($arrayResp['continue']['sroffset'])) { |
| 75 | - $continueOffset = (int)$arrayResp['continue']['sroffset']; |
|
| 75 | + $continueOffset = (int) $arrayResp['continue']['sroffset']; |
|
| 76 | 76 | } |
| 77 | 77 | $this->saveOffsetInFile($continueOffset); |
| 78 | 78 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $titles = []; |
| 86 | 86 | foreach ($results as $res) { |
| 87 | 87 | if (!empty($res['title'])) { |
| 88 | - $titles[] = trim((string)$res['title']); // trim utile ? |
|
| 88 | + $titles[] = trim((string) $res['title']); // trim utile ? |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | if ($response->getStatusCode() !== 200) { |
| 117 | 117 | throw new Exception( |
| 118 | - 'CirrusSearch error : ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase() |
|
| 118 | + 'CirrusSearch error : '.$response->getStatusCode().' '.$response->getReasonPhrase() |
|
| 119 | 119 | ); |
| 120 | 120 | } |
| 121 | 121 | $json = $response->getBody()->getContents(); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | return []; |
| 124 | 124 | } |
| 125 | 125 | try { |
| 126 | - $array = json_decode((string)$json, true, 512, JSON_THROW_ON_ERROR); |
|
| 126 | + $array = json_decode((string) $json, true, 512, JSON_THROW_ON_ERROR); |
|
| 127 | 127 | } catch (Throwable $e) { |
| 128 | 128 | throw new Exception($e->getMessage(), $e->getCode(), $e); |
| 129 | 129 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | // RFC3986 : space => %20 |
| 146 | 146 | $query = http_build_query($this->requestParams, 'bla', '&', PHP_QUERY_RFC3986); |
| 147 | 147 | |
| 148 | - return self::BASE_URL . '?' . $query; |
|
| 148 | + return self::BASE_URL.'?'.$query; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | protected function getOffsetFromFile(array $allParams): int |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | return 0; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - return (int)trim(file_get_contents($file)); |
|
| 159 | + return (int) trim(file_get_contents($file)); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | protected function hashSearchParams(array $params): string |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * Traitement synchrone des URL brutes http:// transformée en {lien web} ou {article} |
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | -include __DIR__ . '/../myBootstrap.php'; |
|
| 28 | +include __DIR__.'/../myBootstrap.php'; |
|
| 29 | 29 | |
| 30 | 30 | echo "WikiwixListProcess\n"; |
| 31 | 31 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $titles = []; |
| 63 | 63 | foreach ($rawtitles as $rawtitle) { |
| 64 | 64 | // $convTitle = @iconv('UTF-8', 'latin1', $rawtitle); |
| 65 | - $convTitle = TextUtil::fixWrongUTF8Encoding($rawtitle); |
|
| 65 | + $convTitle = TextUtil::fixWrongUTF8Encoding($rawtitle); |
|
| 66 | 66 | if ($convTitle !== false && trim($convTitle) !== '') { |
| 67 | 67 | $titles[] = $convTitle; |
| 68 | 68 | } |
@@ -71,14 +71,14 @@ discard block |
||
| 71 | 71 | echo sprintf("> %d converted titles\n", count($titles)); |
| 72 | 72 | |
| 73 | 73 | // filtering |
| 74 | -echo '> before filtering: ' . count($titles) . " articles.\n"; |
|
| 75 | -$edited = file(__DIR__ . '/../resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
| 74 | +echo '> before filtering: '.count($titles)." articles.\n"; |
|
| 75 | +$edited = file(__DIR__.'/../resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
| 76 | 76 | $titles = array_diff($titles, $edited); |
| 77 | 77 | $list = new PageList($titles); |
| 78 | 78 | // end HACK list manuelle |
| 79 | 79 | |
| 80 | 80 | |
| 81 | -echo ">" . $list->count() . " dans liste\n"; |
|
| 81 | +echo ">".$list->count()." dans liste\n"; |
|
| 82 | 82 | if ($list->count() === 0) { |
| 83 | 83 | echo "END of process: EMPTY ARTICLE LIST\n"; |
| 84 | 84 | sleep(120); |
@@ -42,20 +42,20 @@ |
||
| 42 | 42 | |
| 43 | 43 | $charset = self::extractCharset($html) ?? 'WINDOWS-1252'; |
| 44 | 44 | if (empty($charset)) { |
| 45 | - throw new DomainException('normalized html error and no charset found : ' . $url); |
|
| 45 | + throw new DomainException('normalized html error and no charset found : '.$url); |
|
| 46 | 46 | } |
| 47 | 47 | try { |
| 48 | 48 | // PHP Notice: iconv(): Detected an illegal character in input string |
| 49 | 49 | $html2 = @iconv($charset, 'UTF-8//TRANSLIT', $html); |
| 50 | 50 | if (false === $html2) { |
| 51 | - throw new DomainException("error iconv : $charset to UTF-8 on " . $url); |
|
| 51 | + throw new DomainException("error iconv : $charset to UTF-8 on ".$url); |
|
| 52 | 52 | } |
| 53 | 53 | $html2 = Normalizer::normalize($html2); |
| 54 | 54 | if (!is_string($html2)) { |
| 55 | - throw new DomainException("error normalizer : $charset to UTF-8 on " . $url); |
|
| 55 | + throw new DomainException("error normalizer : $charset to UTF-8 on ".$url); |
|
| 56 | 56 | } |
| 57 | 57 | } catch (Throwable $e) { |
| 58 | - throw new DomainException("error converting : $charset to UTF-8 on " . $url, $e->getCode(), $e); |
|
| 58 | + throw new DomainException("error converting : $charset to UTF-8 on ".$url, $e->getCode(), $e); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | return $html2; |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | final public const DELAY_BOTFLAG_SECONDS = 120; |
| 48 | 48 | final public const DELAY_NO_BOTFLAG_SECONDS = 120; |
| 49 | 49 | final public const DELAY_MINUTES_AFTER_HUMAN_EDIT = 10; |
| 50 | - final public const ERROR_MSG_TEMPLATE = __DIR__ . '/templates/message_errors.wiki'; |
|
| 50 | + final public const ERROR_MSG_TEMPLATE = __DIR__.'/templates/message_errors.wiki'; |
|
| 51 | 51 | protected const ALWAYS_NO_BOTFLAG_ON_BA = true; |
| 52 | 52 | protected const ALWAYS_NO_BOTFLAG_ON_ADQ = true; |
| 53 | 53 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | while (true) { |
| 96 | 96 | echo "\n-------------------------------------\n\n"; |
| 97 | - echo date("Y-m-d H:i:s") . " "; |
|
| 97 | + echo date("Y-m-d H:i:s")." "; |
|
| 98 | 98 | $this->log->info($this->memory->getMemory(true)); |
| 99 | 99 | $this->pageProcess(); |
| 100 | 100 | sleep(2); // précaution boucle infinie |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | try { |
| 127 | 127 | $this->wikiPageAction = ServiceFactory::wikiPageAction($this->pageWorkStatus->getTitle()); // , true ? |
| 128 | 128 | } catch (Exception) { |
| 129 | - $this->log->warning("*** WikiPageAction error : " . $this->pageWorkStatus->getTitle() . " \n"); |
|
| 129 | + $this->log->warning("*** WikiPageAction error : ".$this->pageWorkStatus->getTitle()." \n"); |
|
| 130 | 130 | sleep(20); |
| 131 | 131 | |
| 132 | 132 | return false; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | protected function printTitle(string $title): void |
| 164 | 164 | { |
| 165 | - echo Color::BG_CYAN . $title . Color::NORMAL . " \n"; |
|
| 165 | + echo Color::BG_CYAN.$title.Color::NORMAL." \n"; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | protected function checkArticleLabels($title): void |
@@ -240,10 +240,10 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | protected function printDebug(array $data) |
| 242 | 242 | { |
| 243 | - $this->log->debug('origin: ' . $data['raw']); |
|
| 244 | - $this->log->debug('completed: ' . $data['opti']); |
|
| 245 | - $this->log->debug('modifs: ' . $data['modifs']); |
|
| 246 | - $this->log->debug('version: ' . $data['version']); |
|
| 243 | + $this->log->debug('origin: '.$data['raw']); |
|
| 244 | + $this->log->debug('completed: '.$data['opti']); |
|
| 245 | + $this->log->debug('modifs: '.$data['modifs']); |
|
| 246 | + $this->log->debug('version: '.$data['version']); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | protected function editPage(): bool |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | $this->log->alert("*** Invalid CSRF token \n"); |
| 263 | 263 | throw new Exception('Invalid CSRF token', $e->getCode(), $e); |
| 264 | 264 | } else { |
| 265 | - $this->log->warning('Exception in editPage() ' . $e->getMessage()); |
|
| 265 | + $this->log->warning('Exception in editPage() '.$e->getMessage()); |
|
| 266 | 266 | sleep(10); |
| 267 | 267 | |
| 268 | 268 | return false; |
@@ -284,16 +284,16 @@ discard block |
||
| 284 | 284 | $this->sendOuvrageErrorsOnTalkPage($pageOuvrageCollection, $this->log); |
| 285 | 285 | } |
| 286 | 286 | } catch (Throwable $e) { |
| 287 | - $this->log->warning('Exception in editPage() ' . $e->getMessage()); |
|
| 287 | + $this->log->warning('Exception in editPage() '.$e->getMessage()); |
|
| 288 | 288 | unset($e); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | if (!$this->pageWorkStatus->botFlag) { |
| 292 | - $this->log->debug("sleep " . self::DELAY_NO_BOTFLAG_SECONDS); |
|
| 292 | + $this->log->debug("sleep ".self::DELAY_NO_BOTFLAG_SECONDS); |
|
| 293 | 293 | sleep(self::DELAY_NO_BOTFLAG_SECONDS); |
| 294 | 294 | } |
| 295 | 295 | if ($this->pageWorkStatus->botFlag) { |
| 296 | - $this->log->debug("sleep " . self::DELAY_BOTFLAG_SECONDS); |
|
| 296 | + $this->log->debug("sleep ".self::DELAY_BOTFLAG_SECONDS); |
|
| 297 | 297 | sleep(self::DELAY_BOTFLAG_SECONDS); |
| 298 | 298 | } |
| 299 | 299 | } |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | class TalkBotConfig extends WikiBotConfig |
| 24 | 24 | { |
| 25 | 25 | final public const BOT_TALK_SUMMARY = 'Réponse artificielle[[User:Irønie|.]]'; |
| 26 | - final public const BOT_TALK_FILE = __DIR__ . '/resources/phrases_zizibot.txt'; |
|
| 27 | - final public const TALKCONFIG_FILENAME = __DIR__ . '/resources/botTalk_config.json'; |
|
| 26 | + final public const BOT_TALK_FILE = __DIR__.'/resources/phrases_zizibot.txt'; |
|
| 27 | + final public const TALKCONFIG_FILENAME = __DIR__.'/resources/botTalk_config.json'; |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Add a freaky response in the bottom of the talk page. |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | // ugly dependency |
| 38 | 38 | $wiki = ServiceFactory::getMediawikiFactory(); |
| 39 | 39 | if (!$pageTitle) { |
| 40 | - $pageTitle = 'Discussion utilisateur:' . $this::getBotName(); |
|
| 40 | + $pageTitle = 'Discussion utilisateur:'.$this::getBotName(); |
|
| 41 | 41 | } |
| 42 | 42 | $page = new WikiPageAction($wiki, $pageTitle); |
| 43 | 43 | $last = $page->page->getRevisions()->getLatest(); |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | // No response if time < 24h since last bot owner response |
| 59 | 59 | if ($last->getUser() == self::getBotOwner()) { |
| 60 | - $talkConfig['owner_last_time'] = (int)strtotime($last->getTimestamp()); |
|
| 60 | + $talkConfig['owner_last_time'] = (int) strtotime($last->getTimestamp()); |
|
| 61 | 61 | file_put_contents(self::TALKCONFIG_FILENAME, json_encode($talkConfig, JSON_THROW_ON_ERROR)); |
| 62 | 62 | |
| 63 | 63 | return false; |
| 64 | 64 | } |
| 65 | 65 | // No response if time < 24h since last owner response |
| 66 | - if (isset($talkConfig['owner_last_time']) && (int)$talkConfig['owner_last_time'] > (time() - 60 * 60 * 48)) { |
|
| 66 | + if (isset($talkConfig['owner_last_time']) && (int) $talkConfig['owner_last_time'] > (time() - 60 * 60 * 48)) { |
|
| 67 | 67 | echo "No response if time < 24h after last owner response\n"; |
| 68 | 68 | |
| 69 | 69 | return false; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $editInfo = new EditInfo(static::BOT_TALK_SUMMARY); |
| 80 | 80 | $success = $page->addToBottomOfThePage($addText, $editInfo); |
| 81 | 81 | |
| 82 | - return (bool)$success; |
|
| 82 | + return (bool) $success; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | $lines = explode("\n", trim($text)); |
| 111 | 111 | $lastLine = $lines[count($lines) - 1]; |
| 112 | 112 | if (preg_match('#^(:*).+#', $lastLine, $matches) && !empty($matches[1])) { |
| 113 | - $nextIdent = $matches[1] . ':'; |
|
| 113 | + $nextIdent = $matches[1].':'; |
|
| 114 | 114 | if (empty($author)) { |
| 115 | 115 | return $nextIdent; |
| 116 | 116 | } |
| 117 | 117 | // search author signature link to check that he wrote on the page bottom |
| 118 | 118 | if (preg_match( |
| 119 | - '#\[\[(?:User|Utilisateur|Utilisatrice):' . preg_quote($author, '#') . '[|\]]#i', |
|
| 119 | + '#\[\[(?:User|Utilisateur|Utilisatrice):'.preg_quote($author, '#').'[|\]]#i', |
|
| 120 | 120 | $matches[0] |
| 121 | 121 | ) |
| 122 | 122 | ) { |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | throw new ConfigException('Pas de phrases disponibles pour TalkBot'); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - return (string)trim($sentences[array_rand($sentences)]); |
|
| 140 | + return (string) trim($sentences[array_rand($sentences)]); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | { |
| 149 | 149 | // TODO client |
| 150 | 150 | $url |
| 151 | - = 'https://fr.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuser=' . $this::getBotName() |
|
| 151 | + = 'https://fr.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuser='.$this::getBotName() |
|
| 152 | 152 | . '&ucnamespace=0&uclimit=40&ucprop=title|timestamp|comment&format=json'; |
| 153 | 153 | |
| 154 | 154 | return file_get_contents($url); |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | public const SLEEP_AFTER_EDITION = 60; |
| 33 | 33 | public const MINUTES_DELAY_AFTER_LAST_HUMAN_EDIT = 15; |
| 34 | 34 | public const CHECK_EDIT_CONFLICT = true; |
| 35 | - public const ARTICLE_ANALYZED_FILENAME = __DIR__ . '/resources/article_edited.txt'; |
|
| 35 | + public const ARTICLE_ANALYZED_FILENAME = __DIR__.'/resources/article_edited.txt'; |
|
| 36 | 36 | public const SKIP_LASTEDIT_BY_BOT = true; |
| 37 | 37 | public const SKIP_NOT_IN_MAIN_WIKISPACE = true; |
| 38 | 38 | public const SKIP_ADQ = false; |
| 39 | 39 | public const THROTTLE_DELAY_AFTER_EACH_TITLE = 2; //secs |
| 40 | - protected const GIT_COMMIT_HASH_PATH = __DIR__ . '/resources/commithash.txt'; |
|
| 40 | + protected const GIT_COMMIT_HASH_PATH = __DIR__.'/resources/commithash.txt'; |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @var PageListInterface |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $this->initializePastAnalyzedTitles(); |
| 94 | 94 | |
| 95 | 95 | // @throw exception on "Invalid CSRF token" |
| 96 | - $this->run();//todo delete that and use (Worker)->run($duration) or process management |
|
| 96 | + $this->run(); //todo delete that and use (Worker)->run($duration) or process management |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -104,13 +104,13 @@ discard block |
||
| 104 | 104 | final public function run(): void |
| 105 | 105 | { |
| 106 | 106 | $this->log->notice('*** '.date('Y-m-d H:i') |
| 107 | - .' New BotTaskWorker: ' . $this->defaultTaskname, ['stats' => 'bottaskworker.instance']); |
|
| 107 | + .' New BotTaskWorker: '.$this->defaultTaskname, ['stats' => 'bottaskworker.instance']); |
|
| 108 | 108 | $this->log->notice(sprintf( |
| 109 | 109 | '*** Bot: %s - commit: %s', |
| 110 | 110 | $this->bot::getBotName(), |
| 111 | 111 | $this->bot->getCurrentGitCommitHash() ?? '??' |
| 112 | 112 | )); |
| 113 | - $this->log->notice('*** Stats: ' . $this->log->stats::class); |
|
| 113 | + $this->log->notice('*** Stats: '.$this->log->stats::class); |
|
| 114 | 114 | |
| 115 | 115 | foreach ($this->getTitles() as $title) { |
| 116 | 116 | try { |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | $this->log->notice($result ? '>> EDIT OK' : '>> NOCHANGE'); |
| 228 | - $this->log->debug("Sleep " . static::SLEEP_AFTER_EDITION); |
|
| 228 | + $this->log->debug("Sleep ".static::SLEEP_AFTER_EDITION); |
|
| 229 | 229 | sleep(static::SLEEP_AFTER_EDITION); |
| 230 | 230 | } |
| 231 | 231 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * Traitement synchrone des URL brutes http:// transformée en {lien web} ou {article} |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | -include __DIR__ . '/../myBootstrap.php'; |
|
| 30 | +include __DIR__.'/../myBootstrap.php'; |
|
| 31 | 31 | |
| 32 | 32 | // --page="Skateboard" --stats=redis --stats=sqlite --debug --verbose |
| 33 | 33 | echo "OPTIONS: --debug --verbose --stats=redis --stats=sqlite --page=\"Skateboard\" --offset=1000 \n"; |
@@ -59,18 +59,18 @@ discard block |
||
| 59 | 59 | $torClient = ServiceFactory::getHttpClient(true); |
| 60 | 60 | |
| 61 | 61 | |
| 62 | -$list = PageList::FromFile(__DIR__ . '/../../../resources/titles/titles100kag'); |
|
| 62 | +$list = PageList::FromFile(__DIR__.'/../../../resources/titles/titles100kag'); |
|
| 63 | 63 | |
| 64 | 64 | // filter titles already in edited.txt |
| 65 | 65 | $titles = $list->getPageTitles(); |
| 66 | -echo '> before filtering: ' . count($titles) . " articles.\n"; |
|
| 66 | +echo '> before filtering: '.count($titles)." articles.\n"; |
|
| 67 | 67 | unset($list); |
| 68 | -$edited = file(__DIR__ . '/../resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
| 68 | +$edited = file(__DIR__.'/../resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
| 69 | 69 | $titles = array_diff($titles, $edited); |
| 70 | 70 | $list = new PageList($titles); |
| 71 | 71 | |
| 72 | 72 | |
| 73 | -echo ">" . $list->count() . " dans liste\n"; |
|
| 73 | +echo ">".$list->count()." dans liste\n"; |
|
| 74 | 74 | if ($list->count() === 0) { |
| 75 | 75 | echo "END of process: EMPTY ARTICLE LIST\n"; |
| 76 | 76 | sleep(120); |