From eba365d05770df0a002f4b4e49724b35c008867a Mon Sep 17 00:00:00 2001 From: Sebastian Castro Date: Mon, 1 Jul 2024 15:40:33 +0000 Subject: [PATCH] lint --- handlers/DuplicateHandler.php | 26 ++++--- includes/YesWiki.php | 2 +- includes/controllers/ApiController.php | 14 ++-- includes/controllers/PageController.php | 4 +- includes/services/DuplicationManager.php | 41 ++++++---- includes/services/ImportFilesManager.php | 69 +++++++++------- includes/services/PageManager.php | 6 +- javascripts/handlers/duplicate.js | 6 +- javascripts/yeswiki-base.js | 4 +- lang/yeswiki_fr.php | 2 +- lang/yeswikijs_fr.php | 78 +++++++++---------- tools/attach/lang/attach_en.inc.php | 2 +- tools/bazar/controllers/ListController.php | 2 +- .../javascripts/jquery.photobox.js | 2 +- tools/bazar/services/EntryManager.php | 3 +- tools/bazar/services/SearchManager.php | 2 +- tools/lang/actions/translation.php | 2 +- tools/login/actions/LoginAction.php | 1 + tools/login/controllers/ApiController.php | 16 ++-- tools/templates/actions/barreredaction.php | 24 +++--- 20 files changed, 169 insertions(+), 137 deletions(-) diff --git a/handlers/DuplicateHandler.php b/handlers/DuplicateHandler.php index aabc1043b..1e0f8bd3b 100644 --- a/handlers/DuplicateHandler.php +++ b/handlers/DuplicateHandler.php @@ -1,12 +1,12 @@ entryController = $this->getService(EntryController::class); $this->duplicationManager = $this->getService(DuplicationManager::class); $title = $error = ''; - $toExternalWiki = isset($_GET['toUrl']) && $_GET['toUrl'] == "1"; + $toExternalWiki = isset($_GET['toUrl']) && $_GET['toUrl'] == '1'; if (!$this->wiki->page) { $error .= $this->render('@templates\alert-message.twig', [ 'type' => 'warning', 'message' => str_replace( - ["{beginLink}", "{endLink}"], - ["wiki->href('')}\">", ""], - _t("NOT_FOUND_PAGE") + ['{beginLink}', '{endLink}'], + ["wiki->href('')}\">", ''], + _t('NOT_FOUND_PAGE') ), ]); } elseif (!$this->getService(AclService::class)->hasAccess('read', $this->wiki->GetPageTag())) { // if no read access to the page - if ($contenu = $this->getService(PageManager::class)->getOne("PageLogin")) { + if ($contenu = $this->getService(PageManager::class)->getOne('PageLogin')) { // si une page PageLogin existe, on l'affiche - $error .= $this->wiki->Format($contenu["body"]); + $error .= $this->wiki->Format($contenu['body']); } else { // sinon on affiche le formulaire d'identification minimal $error .= '
' . "\n" @@ -51,12 +51,15 @@ public function run() $this->duplicationManager->duplicateLocally($data); if ($data['duplicate-action'] == 'edit') { $this->wiki->Redirect($this->wiki->href('edit', $data['pageTag'])); + return; - } else if ($data['duplicate-action'] == 'return') { + } elseif ($data['duplicate-action'] == 'return') { $this->wiki->Redirect($this->wiki->href()); + return; } $this->wiki->Redirect($this->wiki->href('', $data['pageTag'])); + return; } catch (\Throwable $th) { $error .= $this->render('@templates\alert-message-with-back.twig', [ @@ -118,6 +121,7 @@ public function run() if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { $title = ''; } + return $this->renderInSquelette('@core/handlers/duplicate.twig', [ 'title' => $title, 'originalTag' => $this->wiki->GetPageTag(), @@ -133,4 +137,4 @@ public function run() 'toExternalWiki' => $toExternalWiki, ]); } -} \ No newline at end of file +} diff --git a/includes/YesWiki.php b/includes/YesWiki.php index f89b999dc..a4b12b2dc 100755 --- a/includes/YesWiki.php +++ b/includes/YesWiki.php @@ -2067,4 +2067,4 @@ public function GetCookie($name) { return $_COOKIE[$name]; } -} \ No newline at end of file +} diff --git a/includes/controllers/ApiController.php b/includes/controllers/ApiController.php index 0a1dd75ac..154104dd2 100644 --- a/includes/controllers/ApiController.php +++ b/includes/controllers/ApiController.php @@ -3,11 +3,11 @@ namespace YesWiki\Core\Controller; use Exception; -use Throwable; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Csrf\Exception\TokenNotFoundException; +use Throwable; use YesWiki\Bazar\Controller\EntryController; use YesWiki\Bazar\Service\EntryManager; use YesWiki\Core\ApiResponse; @@ -76,7 +76,7 @@ public function getDocumentation() if (file_exists($pluginBase . 'controllers/ApiController.php')) { $apiClassName = 'YesWiki\\' . ucfirst($extension) . '\\Controller\\ApiController'; if (!class_exists($apiClassName, false)) { - include($pluginBase . 'controllers/ApiController.php'); + include $pluginBase . 'controllers/ApiController.php'; } if (class_exists($apiClassName, false)) { $apiController = new $apiClassName(); @@ -393,6 +393,7 @@ public function duplicatePage(Request $request, $tag) } catch (\Throwable $th) { return new ApiResponse($th->getMessage(), Response::HTTP_FORBIDDEN); } + return new ApiResponse($request->request->all(), Response::HTTP_OK); } @@ -835,13 +836,13 @@ private function extractTriplesParams(string $method, $resource): array ); } else { $property = filter_input($method, 'property', FILTER_UNSAFE_RAW); - $property = in_array($property, [false, null], true) ? "" : htmlspecialchars(strip_tags($property)); + $property = in_array($property, [false, null], true) ? '' : htmlspecialchars(strip_tags($property)); if (empty($property)) { $property = null; } $username = filter_input($method, 'user', FILTER_UNSAFE_RAW); - $username = in_array($username, [false, null], true) ? "" : htmlspecialchars(strip_tags($username)); + $username = in_array($username, [false, null], true) ? '' : htmlspecialchars(strip_tags($username)); if (empty($username)) { if (!$this->wiki->UserIsAdmin()) { $username = $this->getService(AuthController::class)->getLoggedUser()['name']; @@ -857,6 +858,7 @@ private function extractTriplesParams(string $method, $resource): array ); } } + return compact(['property', 'username', 'apiResponse']); } @@ -875,7 +877,7 @@ public function getArchiveStatus($uid) { return $this->getService(ArchiveController::class)->getArchiveStatus( $uid, - empty($_GET['forceStarted']) ? false : in_array($_GET['forceStarted'], [1, true, "1", "true"], true) + empty($_GET['forceStarted']) ? false : in_array($_GET['forceStarted'], [1, true, '1', 'true'], true) ); } @@ -932,4 +934,4 @@ public function archivesAction() { return $this->getService(ArchiveController::class)->manageArchiveAction(); } -} \ No newline at end of file +} diff --git a/includes/controllers/PageController.php b/includes/controllers/PageController.php index 26f4194cc..45569b860 100644 --- a/includes/controllers/PageController.php +++ b/includes/controllers/PageController.php @@ -47,9 +47,9 @@ public function delete(string $tag): bool } } - public function duplicate(string $sourceTag, string $destinationTag = '') : bool + public function duplicate(string $sourceTag, string $destinationTag = ''): bool { - if ($this->entryManager->isEntry($sourceTag)){ + if ($this->entryManager->isEntry($sourceTag)) { return $this->entryController->duplicate($sourceTag, $destinationTag); } else { return $this->pageManager->duplicate($sourceTag, $destinationTag); diff --git a/includes/services/DuplicationManager.php b/includes/services/DuplicationManager.php index 64394cd04..1a7396b73 100644 --- a/includes/services/DuplicationManager.php +++ b/includes/services/DuplicationManager.php @@ -6,10 +6,9 @@ use YesWiki\Bazar\Field\FileField; use YesWiki\Bazar\Field\ImageField; use YesWiki\Bazar\Field\TextareaField; -use YesWiki\Bazar\Service\FormManager; use YesWiki\Bazar\Service\EntryManager; +use YesWiki\Bazar\Service\FormManager; use YesWiki\Bazar\Service\ListManager; -use YesWiki\Core\Service\PageManager; use YesWiki\Wiki; class DuplicationManager @@ -17,9 +16,9 @@ class DuplicationManager protected $uploadPath; protected $wiki; - /** - * DuplicationManager constructor + * DuplicationManager constructor. + * * @param Wiki $wiki the injected Wiki instance */ public function __construct(Wiki $wiki) @@ -29,7 +28,7 @@ public function __construct(Wiki $wiki) } /** - * Get the local path to files uploads (usually "files") + * Get the local path to files uploads (usually "files"). * * @return string local path to files uploads */ @@ -38,7 +37,7 @@ private function getLocalFileUploadPath() $attachConfig = $this->wiki->config['attach_config']; if (!is_array($attachConfig)) { - $attachConfig = array(); + $attachConfig = []; } if (empty($attachConfig['upload_path'])) { @@ -51,9 +50,10 @@ private function getLocalFileUploadPath() } /** - * Return fields that may contain attachments to import (fichier, image, or textelong fields for bazar entries) + * Return fields that may contain attachments to import (fichier, image, or textelong fields for bazar entries). * * @param array $id + * * @return array keys of fields that may contain attachments to import */ public function getUploadFieldsFromEntry($id) @@ -68,11 +68,12 @@ public function getUploadFieldsFromEntry($id) if ($field instanceof TextareaField or $field instanceof ImageField or $field instanceof FileField) { $fields[] = [ 'id' => $field->getPropertyName(), - 'type' => $field->getType() + 'type' => $field->getType(), ]; } } } + return $fields; } @@ -82,6 +83,7 @@ public function findFilesInUploadField($fieldValue) if ($f !== $this->uploadPath . '/' && file_exists($f)) { $size = filesize($f); $humanSize = $this->humanFilesize($size); + return ['path' => $f, 'size' => $size, 'humanSize' => $humanSize]; } else { return []; @@ -89,10 +91,11 @@ public function findFilesInUploadField($fieldValue) } /** - * find files in wiki text + * find files in wiki text. * * @param string $wikiTag * @param string $wikiText + * * @return array files */ public function findFilesInWikiText($tag, $wikiText) @@ -141,13 +144,15 @@ public function findFilesInWikiText($tag, $wikiText) $filesMatched[] = ['path' => $f, 'size' => $size, 'humanSize' => $humanSize]; } } + return $filesMatched; } /** - * Get file attachements from pageTag - * + * Get file attachements from pageTag. + * * @param string $tag page id + * * @return array attachments filenames */ public function findFiles($tag = '') @@ -157,7 +162,7 @@ public function findFiles($tag = '') $tag = $this->wiki->GetPageTag(); } if ($this->wiki->services->get(EntryManager::class)->isEntry($tag)) { - // bazar + // bazar $fields = $this->getUploadFieldsFromEntry($tag); $entry = $this->wiki->services->get(EntryManager::class)->getOne($tag); foreach ($fields as $f) { @@ -177,6 +182,7 @@ public function findFiles($tag = '') $files = array_merge($files, $fi); } } + return $files; } @@ -200,6 +206,7 @@ public function duplicateFiles($fromTag, $toTag) 'duplicatedFile' => str_replace($this->uploadPath . '/', '', $newPath), ]; } + return $doneFiles; } @@ -224,6 +231,7 @@ public function checkPostData($data) if (empty($data['duplicate-action']) || !in_array($data['duplicate-action'], ['open', 'edit', 'return'])) { throw new \Exception(_t('NO_DUPLICATE_ACTION') . '.'); } + return $data; } @@ -281,7 +289,7 @@ public function duplicateLocally($data) // duplicate metadatas and tags (TODO: is there more duplicable triples?) $properties = [ 'http://outils-reseaux.org/_vocabulary/metadata', - 'http://outils-reseaux.org/_vocabulary/tag' + 'http://outils-reseaux.org/_vocabulary/tag', ]; foreach ($properties as $prop) { $values = $this->wiki->services->get(TripleStore::class)->getAll($this->wiki->GetPageTag(), $prop, '', ''); @@ -295,12 +303,14 @@ public function importDistantContent($tag, $request) { if ($this->wiki->services->get(PageManager::class)->getOne($tag)) { throw new Exception(_t('ACEDITOR_LINK_PAGE_ALREADY_EXISTS')); + return; } $req = $request->request->all(); foreach (['pageContent', 'sourceUrl', 'originalTag', 'type'] as $key) { if (empty($req[$key])) { throw new Exception(_t('NOT_FOUND_IN_REQUEST', $key)); + return; } } @@ -308,7 +318,7 @@ public function importDistantContent($tag, $request) $this->downloadFile($fileUrl, $req['originalTag'], $tag); } - $newUrl = explode('/?', $this->wiki->config['base_url'])[0]; + $newUrl = explode('/?', $this->wiki->config['base_url'])[0]; $newBody = str_replace($req['sourceUrl'], $newUrl, $req['pageContent']); if ($req['type'] === 'page') { $this->wiki->services->get(PageManager::class)->save($tag, $newBody); @@ -348,6 +358,7 @@ public function humanFilesize($bytes, $decimals = 2) if ($factor > 0) { $sz = 'KMGT'; } + return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor - 1] . 'B'; } -} \ No newline at end of file +} diff --git a/includes/services/ImportFilesManager.php b/includes/services/ImportFilesManager.php index 7095ee2b5..d18cf40af 100644 --- a/includes/services/ImportFilesManager.php +++ b/includes/services/ImportFilesManager.php @@ -4,8 +4,6 @@ use YesWiki\Bazar\Field\TextareaField; use YesWiki\Bazar\Service\FormManager; -use YesWiki\Bazar\Service\EntryManager; -use YesWiki\Core\Service\PageManager; use YesWiki\Wiki; class ImportFilesManager @@ -13,9 +11,9 @@ class ImportFilesManager protected $uploadPath; protected $wiki; - /** - * ImportManager constructor + * ImportManager constructor. + * * @param Wiki $wiki the injected Wiki instance */ public function __construct(Wiki $wiki) @@ -25,7 +23,7 @@ public function __construct(Wiki $wiki) } /** - * Get the local path to files uploads (usually "files") + * Get the local path to files uploads (usually "files"). * * @return string local path to files uploads */ @@ -38,7 +36,7 @@ private function getLocalFileUploadPath() $attachConfig = $this->wiki->config['attach_config']; if (!is_array($attachConfig)) { - $attachConfig = array(); + $attachConfig = []; } if (empty($attachConfig['upload_path'])) { @@ -51,11 +49,12 @@ private function getLocalFileUploadPath() } /** - * Download file url to local wiki using cURL + * Download file url to local wiki using cURL. + * + * @param string $from file url + * @param string $to local path + * @param bool $overwrite overwrite existing file ? (default:false) * - * @param string $from file url - * @param string $to local path - * @param boolean $overwrite overwrite existing file ? (default:false) * @return void */ private function cURLDownload($from, $to, $overwrite = false) @@ -66,6 +65,7 @@ private function cURLDownload($from, $to, $overwrite = false) $output .= _t('FILE') . ' ' . $to . ' ' . _t('FILE_OVERWRITE') . '.'; } else { $output .= _t('FILE') . ' ' . $to . ' ' . _t('FILE_NO_OVERWRITE') . '.'; + return $output; } } @@ -85,13 +85,15 @@ private function cURLDownload($from, $to, $overwrite = false) unlink($to); throw new \Exception($output . _t('ERROR_DOWNLOADING') . ' ' . $from . ': ' . $err . "\n" . _t('REMOVING_CORRUPTED_FILE') . ' ' . $to); } + return $output; } /** - * Return fields that may contain attachments to import (body for wikipage, or textelong fields for bazar entries) + * Return fields that may contain attachments to import (body for wikipage, or textelong fields for bazar entries). * * @param array $wikiPage page or entry content as an array + * * @return array keys of $wikiPage that may contain attachments to import */ public function getTextFieldsFromWikiPage($wikiPage) @@ -109,13 +111,15 @@ public function getTextFieldsFromWikiPage($wikiPage) } } } + return $fields; } /** - * Get attachements from raw page content + * Get attachements from raw page content. * * @param string $tag page id + * * @return array attachments filenames */ public function findDirectLinkAttachements($tag = '') @@ -151,6 +155,7 @@ public function findDirectLinkAttachements($tag = '') } } } + return $filesMatched; } @@ -160,15 +165,17 @@ public function humanFilesize($bytes, $decimals = 2) if ($factor > 0) { $sz = 'KMGT'; } + return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor - 1] . 'B'; } /** - * Generate distant file url and download to local file path + * Generate distant file url and download to local file path. * * @param string $remoteUrl distant file url - * @param string $filename file name - * @param boolean $overwrite overwrite existing file ? (default:false) + * @param string $filename file name + * @param bool $overwrite overwrite existing file ? (default:false) + * * @return void */ public function downloadDirectLinkAttachment($remoteUrl, $filename, $overwrite = false) @@ -181,11 +188,12 @@ public function downloadDirectLinkAttachment($remoteUrl, $filename, $overwrite = /** * Find file attachments in page or bazar entry - * It finds attachments linked with /download links + * It finds attachments linked with /download links. * * @param string $remoteUrl distant url - * @param array $wikiPage page or entry content as an array - * @param boolean $transform transform attachments urls for their new location (default:false) + * @param array $wikiPage page or entry content as an array + * @param bool $transform transform attachments urls for their new location (default:false) + * * @return array all file attachments */ public function findHiddenAttachments($remoteUrl, &$wikiPage, $transform = false) @@ -219,23 +227,24 @@ public function findHiddenAttachments($remoteUrl, &$wikiPage, $transform = false /** * Generate local path and download hidden attachments - * It downloads attachments linked with /download links + * It downloads attachments linked with /download links. * - * @param string $remoteUrl distant url - * @param string $pageTag page tag + * @param string $remoteUrl distant url + * @param string $pageTag page tag * @param string $lastPageUpdate last update time - * @param string $filename file name - * @param boolean $overwrite overwrite existing file ? (default:false) + * @param string $filename file name + * @param bool $overwrite overwrite existing file ? (default:false) + * * @return array all file attachments */ public function downloadHiddenAttachment($remoteUrl, $pageTag, $lastPageUpdate, $filename, $overwrite = false) { if (!class_exists('attach')) { - require_once("tools/attach/libs/attach.lib.php"); + require_once 'tools/attach/libs/attach.lib.php'; } $this->wiki->tag = $pageTag; - $this->wiki->page = array('tag' => $pageTag, 'time' => $lastPageUpdate); + $this->wiki->page = ['tag' => $pageTag, 'time' => $lastPageUpdate]; $remoteFileUrl = $remoteUrl . '?' . $pageTag . '/download&file=' . $filename; $att = new \attach($this->wiki); @@ -245,13 +254,13 @@ public function downloadHiddenAttachment($remoteUrl, $pageTag, $lastPageUpdate, $this->cURLDownload($remoteFileUrl, $newFilename, $overwrite); } - /** - * All type of attachment related to a page or a bazar entry + * All type of attachment related to a page or a bazar entry. * * @param string $remoteUrl distant url - * @param array $wikiPage page or entry content as an array - * @param boolean $overwrite overwrite existing file ? (default:false) + * @param array $wikiPage page or entry content as an array + * @param bool $overwrite overwrite existing file ? (default:false) + * * @return void */ public function downloadAttachments($remoteUrl, &$wikiPage, $overwrite = false) @@ -270,7 +279,7 @@ public function downloadAttachments($remoteUrl, &$wikiPage, $overwrite = false) if (!empty($attachments)) { foreach ($attachments as $attachment) { - $this->downloadHiddenAttachment($remoteUrl, $wikiPage['id_fiche'], date("Y-m-d H:i:s"), $attachment, $overwrite); + $this->downloadHiddenAttachment($remoteUrl, $wikiPage['id_fiche'], date('Y-m-d H:i:s'), $attachment, $overwrite); } } } diff --git a/includes/services/PageManager.php b/includes/services/PageManager.php index 678a8a659..e4f355a13 100644 --- a/includes/services/PageManager.php +++ b/includes/services/PageManager.php @@ -219,6 +219,7 @@ public function getAll(): array SELECT * FROM {$this->dbService->prefixTable('pages')} WHERE LATEST = 'Y' ORDER BY tag SQL); $pages = $this->checkEntriesACL($pages); + return $pages; } @@ -408,7 +409,7 @@ public function getOwner($tag = '', $time = '') $page = $this->dbService->loadSingle( "SELECT `owner` FROM {$this->dbService->prefixTable('pages')} " . "WHERE tag = '{$this->dbService->escape($tag)}' AND {$timeQuery} " . - "LIMIT 1" + 'LIMIT 1' ); $this->ownersCache[$tag] = $page['owner'] ?? null; } @@ -510,7 +511,8 @@ private function checkEntriesACL(array $pages, ?string $tag = null, ?string $use private function duplicate($sourceTag, $destinationTag): bool { $result = false; - $this->wiki->LogAdministrativeAction($this->authController->getLoggedUserName(), "Duplication de la page \"\"" . $sourceTag . "\"\" vers la page \"\"" . $destinationTag . "\"\""); + $this->wiki->LogAdministrativeAction($this->authController->getLoggedUserName(), 'Duplication de la page ""' . $sourceTag . '"" vers la page ""' . $destinationTag . '""'); + return $result; } } diff --git a/javascripts/handlers/duplicate.js b/javascripts/handlers/duplicate.js index 5d690d917..318aeec1e 100644 --- a/javascripts/handlers/duplicate.js +++ b/javascripts/handlers/duplicate.js @@ -84,7 +84,7 @@ document.addEventListener('DOMContentLoaded', () => { }) $('[name="duplicate-action"]').on('click', (e) => { - var btnAction = e.currentTarget.value + const btnAction = e.currentTarget.value $.ajax({ method: 'POST', url: `${shortUrl}/?api/pages/${$('#pageTag').val()}/duplicate`, @@ -95,7 +95,7 @@ document.addEventListener('DOMContentLoaded', () => { } else if (btnAction == 'edit') { location = `${shortUrl}/?${data.pageTag}/edit` } else { - let url = location.href.replace(/\/duplicate.*/, '') + const url = location.href.replace(/\/duplicate.*/, '') location = url } }).fail((jqXHR) => { @@ -138,4 +138,4 @@ document.addEventListener('DOMContentLoaded', () => { toastMessage(_t('NOT_VALID_URL', { url }), 3000, 'alert alert-danger') } }) -}) \ No newline at end of file +}) diff --git a/javascripts/yeswiki-base.js b/javascripts/yeswiki-base.js index c9a850ad0..4d66c52d7 100755 --- a/javascripts/yeswiki-base.js +++ b/javascripts/yeswiki-base.js @@ -126,7 +126,7 @@ function toastMessage( $modal .find('.modal-body') .html( - ``, + `` ) } else if (iframe === 1) { const modalTitle = $modal.find('.modal-header h3') @@ -914,4 +914,4 @@ $('.tab-content [data-toggle="tab"]').on('click', function() { } else { $('html, body').animate({ scrollTop: $(base).offset().top - 80 }, 500) } -}) \ No newline at end of file +}) diff --git a/lang/yeswiki_fr.php b/lang/yeswiki_fr.php index ce319e44d..135520aba 100755 --- a/lang/yeswiki_fr.php +++ b/lang/yeswiki_fr.php @@ -705,4 +705,4 @@ 'VERIFY_PAGE_AVAILABILITY' => 'Vérifier la disponibilité de la page', 'ONLY_ADMINS_CAN_DUPLICATE' => 'Seuls les membres du groupe "admins" de ce wiki peuvent dupliquer localement', 'DISTANT_LOGIN' => 'Se connecter sur le YesWiki', -]; \ No newline at end of file +]; diff --git a/lang/yeswikijs_fr.php b/lang/yeswikijs_fr.php index 8bf9f06ef..3db74a47b 100644 --- a/lang/yeswikijs_fr.php +++ b/lang/yeswikijs_fr.php @@ -40,50 +40,50 @@ 'YES' => 'Oui', // /javascripts/actions/admin-backups.js - "ADMIN_BACKUPS_LOADING_LIST" => "Chargement de la liste des sauvegardes", - "ADMIN_BACKUPS_NOT_POSSIBLE_TO_LOAD_LIST" => "Impossible de mettre à jour la liste des sauvegardes", - "ADMIN_BACKUPS_DELETE_ARCHIVE" => "Suppression de {filename}", - "ADMIN_BACKUPS_DELETE_ARCHIVE_POSSIBLE_ERROR" => "Une erreur pourrait avoir eu lieu en supprimant {filename}", - "ADMIN_BACKUPS_DELETE_ARCHIVE_SUCCESS" => "Suppression réussie de {filename}", - "ADMIN_BACKUPS_DELETE_ARCHIVE_ERROR" => "Suppression impossible de {filename}", - "ADMIN_BACKUPS_NO_ARCHIVE_TO_DELETE" => "Aucune sauvegarde à supprimer", - "ADMIN_BACKUPS_DELETE_SELECTED_ARCHIVES" => "Suppression des sauvegardes sélectionnées", - "ADMIN_BACKUPS_RESTORE_ARCHIVE" => "Restauration de {filename}", - "ADMIN_BACKUPS_RESTORE_ARCHIVE_POSSIBLE_ERROR" => "Une erreur pourrait avoir eu lieu en restraurant {filename}", - "ADMIN_BACKUPS_RESTORE_ARCHIVE_SUCCESS" => "Restauration réussie de {filename}", - "ADMIN_BACKUPS_RESTORE_ARCHIVE_ERROR" => "Restauration impossible de {filename}", - "ADMIN_BACKUPS_START_BACKUP" => "Lancement d'une sauvegarde", - "ADMIN_BACKUPS_START_BACKUP_SYNC" => "Lancement d'une sauvegarde en direct (moins stable)\n" . + 'ADMIN_BACKUPS_LOADING_LIST' => 'Chargement de la liste des sauvegardes', + 'ADMIN_BACKUPS_NOT_POSSIBLE_TO_LOAD_LIST' => 'Impossible de mettre à jour la liste des sauvegardes', + 'ADMIN_BACKUPS_DELETE_ARCHIVE' => 'Suppression de {filename}', + 'ADMIN_BACKUPS_DELETE_ARCHIVE_POSSIBLE_ERROR' => 'Une erreur pourrait avoir eu lieu en supprimant {filename}', + 'ADMIN_BACKUPS_DELETE_ARCHIVE_SUCCESS' => 'Suppression réussie de {filename}', + 'ADMIN_BACKUPS_DELETE_ARCHIVE_ERROR' => 'Suppression impossible de {filename}', + 'ADMIN_BACKUPS_NO_ARCHIVE_TO_DELETE' => 'Aucune sauvegarde à supprimer', + 'ADMIN_BACKUPS_DELETE_SELECTED_ARCHIVES' => 'Suppression des sauvegardes sélectionnées', + 'ADMIN_BACKUPS_RESTORE_ARCHIVE' => 'Restauration de {filename}', + 'ADMIN_BACKUPS_RESTORE_ARCHIVE_POSSIBLE_ERROR' => 'Une erreur pourrait avoir eu lieu en restraurant {filename}', + 'ADMIN_BACKUPS_RESTORE_ARCHIVE_SUCCESS' => 'Restauration réussie de {filename}', + 'ADMIN_BACKUPS_RESTORE_ARCHIVE_ERROR' => 'Restauration impossible de {filename}', + 'ADMIN_BACKUPS_START_BACKUP' => "Lancement d'une sauvegarde", + 'ADMIN_BACKUPS_START_BACKUP_SYNC' => "Lancement d'une sauvegarde en direct (moins stable)\n" . "Il ne sera pas possible de mettre à jour le statut en direct\n" . - "Ne pas fermer, ni rafraîchir cette fenêtre !", - "ADMIN_BACKUPS_STARTED" => "Sauvegarde lancée", - "ADMIN_BACKUPS_START_BACKUP_ERROR" => "Lancement de la sauvegarde impossible", - "ADMIN_BACKUPS_UPDATE_UID_STATUS_ERROR" => "Impossible de mettre à jour le statut de la sauvegarde", - "ADMIN_BACKUPS_UID_STATUS_NOT_FOUND" => "Les informations de suivi n'ont pas été trouvées", - "ADMIN_BACKUPS_UID_STATUS_RUNNING" => "Sauvegarde en cours", - "ADMIN_BACKUPS_UID_STATUS_FINISHED" => "Sauvegarde terminée", - "ADMIN_BACKUPS_UID_STATUS_NOT_FINISHED" => "Il y a un problème car la sauvegarde n'est plus en cours et elle n'est pas terminée !", - "ADMIN_BACKUPS_UID_STATUS_STOP" => "Sauvegarde arrêtée", - "ADMIN_BACKUPS_STOP_BACKUP_ERROR" => "Erreur : impossible d'arrêter la sauvegarde", - "ADMIN_BACKUPS_STOPPING_ARCHIVE" => "Arrêt en cours de la sauvegarde", - "ADMIN_BACKUPS_CONFIRMATION_TO_DELETE" => "Les fichiers suivants seront supprimés par la sauvegarde.\n" . + 'Ne pas fermer, ni rafraîchir cette fenêtre !', + 'ADMIN_BACKUPS_STARTED' => 'Sauvegarde lancée', + 'ADMIN_BACKUPS_START_BACKUP_ERROR' => 'Lancement de la sauvegarde impossible', + 'ADMIN_BACKUPS_UPDATE_UID_STATUS_ERROR' => 'Impossible de mettre à jour le statut de la sauvegarde', + 'ADMIN_BACKUPS_UID_STATUS_NOT_FOUND' => "Les informations de suivi n'ont pas été trouvées", + 'ADMIN_BACKUPS_UID_STATUS_RUNNING' => 'Sauvegarde en cours', + 'ADMIN_BACKUPS_UID_STATUS_FINISHED' => 'Sauvegarde terminée', + 'ADMIN_BACKUPS_UID_STATUS_NOT_FINISHED' => "Il y a un problème car la sauvegarde n'est plus en cours et elle n'est pas terminée !", + 'ADMIN_BACKUPS_UID_STATUS_STOP' => 'Sauvegarde arrêtée', + 'ADMIN_BACKUPS_STOP_BACKUP_ERROR' => "Erreur : impossible d'arrêter la sauvegarde", + 'ADMIN_BACKUPS_STOPPING_ARCHIVE' => 'Arrêt en cours de la sauvegarde', + 'ADMIN_BACKUPS_CONFIRMATION_TO_DELETE' => "Les fichiers suivants seront supprimés par la sauvegarde.\n" . "Veuillez confirmer leur suppression en cochant la case ci-dessous.\n
{files}
", - "ADMIN_BACKUPS_START_BACKUP_ERROR_ARCHIVING" => "Lancement de la sauvegarde impossible car une sauvegarde semble être déjà en cours.\n" . - "Suivez cette aide pour corriger ceci.", - "ADMIN_BACKUPS_START_BACKUP_ERROR_HIBERNATE" => "Lancement de la sauvegarde impossible car le site est en hibernation.\n" . + 'ADMIN_BACKUPS_START_BACKUP_ERROR_ARCHIVING' => "Lancement de la sauvegarde impossible car une sauvegarde semble être déjà en cours.\n" . + 'Suivez cette aide pour corriger ceci.', + 'ADMIN_BACKUPS_START_BACKUP_ERROR_HIBERNATE' => "Lancement de la sauvegarde impossible car le site est en hibernation.\n" . "Suivez cette aide pour en sortir.", - "ADMIN_BACKUPS_START_BACKUP_PATH_NOT_WRITABLE" => "Lancement de la sauvegarde impossible car le dossier de sauvegarde n'est pas accessible en écriture.\n" . - "Suivez cette aide pour configurer le dossier de sauvegarde.", - "ADMIN_BACKUPS_FORCED_UPDATE_NOT_POSSIBLE" => "Mise à jour forcée impossible", - "ADMIN_BACKUPS_UID_STATUS_FINISHED_THEN_UPDATING" => "Mise à jour lancée (veuillez patienter)", - "ADMIN_BACKUPS_START_BACKUP_CANNOT_EXEC" => "Lancement de la sauvegarde impossible \n" . + 'ADMIN_BACKUPS_START_BACKUP_PATH_NOT_WRITABLE' => "Lancement de la sauvegarde impossible car le dossier de sauvegarde n'est pas accessible en écriture.\n" . + 'Suivez cette aide pour configurer le dossier de sauvegarde.', + 'ADMIN_BACKUPS_FORCED_UPDATE_NOT_POSSIBLE' => 'Mise à jour forcée impossible', + 'ADMIN_BACKUPS_UID_STATUS_FINISHED_THEN_UPDATING' => 'Mise à jour lancée (veuillez patienter)', + 'ADMIN_BACKUPS_START_BACKUP_CANNOT_EXEC' => "Lancement de la sauvegarde impossible \n" . "Car il n'est pas possible de lancer des commandes console sur le serveur " . - "(voir aide).", - "ADMIN_BACKUPS_START_BACKUP_FOLDER_AVAILABLE" => "Lancement de la sauvegarde impossible car le dossier de sauvegarde est accessible sur internet.\n" . + '(voir aide).', + 'ADMIN_BACKUPS_START_BACKUP_FOLDER_AVAILABLE' => "Lancement de la sauvegarde impossible car le dossier de sauvegarde est accessible sur internet.\n" . "Suivez cette aide pour restreindre l'accès au dossier de sauvegarde.", - "ADMIN_BACKUPS_START_BACKUP_NOT_ENOUGH_SPACE" => "Lancement de la sauvegarde impossible \n" . + 'ADMIN_BACKUPS_START_BACKUP_NOT_ENOUGH_SPACE' => "Lancement de la sauvegarde impossible \n" . "Il n'y a plus assez d'espace disque disponible pour une nouvelle sauvegarde.", - "ADMIN_BACKUPS_START_BACKUP_NOT_DB" => "Lancement de la sauvegarde non optimal \n" . + 'ADMIN_BACKUPS_START_BACKUP_NOT_DB' => "Lancement de la sauvegarde non optimal \n" . "L'utilitaire d'export de base de données ('mysqldump') n'est pas accessible (voir aide).", // /javascripts/handlers/revisions.js @@ -148,7 +148,7 @@ 'REACTION_CONFIRM_DELETE_ALL' => 'Etes-vous sur de vouloir supprimer toutes les réactions de ce vote ?', // Doc - "DOC_EDIT_THIS_PAGE_ON_GITHUB" => "Modifier cette page sur Github", + 'DOC_EDIT_THIS_PAGE_ON_GITHUB' => 'Modifier cette page sur Github', // Duplication 'NOT_VALID_URL' => 'Url non valide : {url}', diff --git a/tools/attach/lang/attach_en.inc.php b/tools/attach/lang/attach_en.inc.php index d628b19f0..d8efe7b4c 100644 --- a/tools/attach/lang/attach_en.inc.php +++ b/tools/attach/lang/attach_en.inc.php @@ -88,7 +88,7 @@ 'DROP_SHADOW' => 'Drop shadow', 'ZOOM_HOVER' => 'Zoom on hover', 'ALT_INFOS' => 'This text will be displayed instead of the image, if the image is not found. It will also be read out loud by assistive technology (screen readers). Let it empty if the image serves a purely decorative purpose', - 'ALTERNATIVE_TEXT' => 'Alternative text, for visually impaired people', + 'ALTERNATIVE_TEXT' => 'Alternative text, for visually impaired people', // 'NONE' => 'Texte en dessous', 'LEFT' => 'Left', 'CENTER' => 'Center', diff --git a/tools/bazar/controllers/ListController.php b/tools/bazar/controllers/ListController.php index e51d03456..5ae0299b1 100644 --- a/tools/bazar/controllers/ListController.php +++ b/tools/bazar/controllers/ListController.php @@ -130,4 +130,4 @@ public function delete($id) $this->wiki->href('', '', [BAZ_VARIABLE_VOIR => BAZ_VOIR_LISTES], false) ); } -} \ No newline at end of file +} diff --git a/tools/bazar/presentation/javascripts/jquery.photobox.js b/tools/bazar/presentation/javascripts/jquery.photobox.js index 4c0f9c7e0..dc53a4358 100644 --- a/tools/bazar/presentation/javascripts/jquery.photobox.js +++ b/tools/bazar/presentation/javascripts/jquery.photobox.js @@ -980,4 +980,4 @@ history, defaults } -}(jQuery, document, window)) \ No newline at end of file +}(jQuery, document, window)) diff --git a/tools/bazar/services/EntryManager.php b/tools/bazar/services/EntryManager.php index 78c0e1ad1..e7c29b808 100644 --- a/tools/bazar/services/EntryManager.php +++ b/tools/bazar/services/EntryManager.php @@ -1184,7 +1184,8 @@ function ($attributeName) { private function duplicate($sourceTag, $destinationTag): bool { $result = false; - $this->wiki->LogAdministrativeAction($this->authController->getLoggedUserName(), "Duplication de la fiche \"\"" . $sourceTag . "\"\" vers la fiche \"\"" . $destinationTag . "\"\""); + $this->wiki->LogAdministrativeAction($this->authController->getLoggedUserName(), 'Duplication de la fiche ""' . $sourceTag . '"" vers la fiche ""' . $destinationTag . '""'); + return $result; } } diff --git a/tools/bazar/services/SearchManager.php b/tools/bazar/services/SearchManager.php index 6e37d07fd..02db5c99a 100644 --- a/tools/bazar/services/SearchManager.php +++ b/tools/bazar/services/SearchManager.php @@ -133,4 +133,4 @@ private function prepareNeedleForRegexp(string $needle): string return $needle; } -} \ No newline at end of file +} diff --git a/tools/lang/actions/translation.php b/tools/lang/actions/translation.php index 13200bd16..2d946be36 100755 --- a/tools/lang/actions/translation.php +++ b/tools/lang/actions/translation.php @@ -42,4 +42,4 @@ } } else { echo _t(LANG_FLAG_FILE_MISSING); -} \ No newline at end of file +} diff --git a/tools/login/actions/LoginAction.php b/tools/login/actions/LoginAction.php index 8e9bc0919..89d5db2a3 100644 --- a/tools/login/actions/LoginAction.php +++ b/tools/login/actions/LoginAction.php @@ -165,6 +165,7 @@ private function renderForm(string $action): string if (!empty($this->arguments['class']) && substr($this->arguments['template'], -strlen('.tpl.html')) == '.tpl.html') { $output = "
arguments['class']}\">\n$output\n
\n"; } + return $output; } diff --git a/tools/login/controllers/ApiController.php b/tools/login/controllers/ApiController.php index c78cae6a4..e04737a74 100644 --- a/tools/login/controllers/ApiController.php +++ b/tools/login/controllers/ApiController.php @@ -2,17 +2,17 @@ namespace YesWiki\Login\Controller; -use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Routing\Annotation\Route; use YesWiki\Core\ApiResponse; -use YesWiki\Core\YesWikiController; use YesWiki\Core\Controller\AuthController; use YesWiki\Core\Service\UserManager; +use YesWiki\Core\YesWikiController; class ApiController extends YesWikiController { /** - * Attempt to login user + * Attempt to login user. * * @return string json * @@ -33,15 +33,16 @@ public function login() return new ApiResponse(['error' => _t('LOGIN_WRONG_PASSWORD')], Response::HTTP_UNAUTHORIZED); } else { $this->wiki->services->get(AuthController::class)->login($user); + return new ApiResponse([ 'user' => $user->getName(), - 'isAdmin' => $this->wiki->UserIsAdmin() + 'isAdmin' => $this->wiki->UserIsAdmin(), ]); } } /** - * Return basic information if user is authenticated + * Return basic information if user is authenticated. * * @return string json * @@ -55,13 +56,13 @@ public function getMyAuth() } else { return new ApiResponse([ 'user' => $loggedUser['name'], - 'isAdmin' => $this->wiki->UserIsAdmin() + 'isAdmin' => $this->wiki->UserIsAdmin(), ]); } } /** - * Get all users or one user's information + * Get all users or one user's information. * * @param string $username specify username * @@ -116,6 +117,7 @@ public function getDocumentation() '

GET ' . $urlAuth . '/me Get basic info (username, isAdmin) for connected user (needs authenticated user)

' . '

POST ' . $urlAuth . '/login login user with param user and password

' . '

POST ' . $urlAuth . '/logout logout current connected user

'; + return $output; } } diff --git a/tools/templates/actions/barreredaction.php b/tools/templates/actions/barreredaction.php index adc10c98f..4de1f2acd 100755 --- a/tools/templates/actions/barreredaction.php +++ b/tools/templates/actions/barreredaction.php @@ -35,14 +35,14 @@ if ($this->HasAccess('write')) { // on ajoute le lien d'édition si l'action est autorisée - if ($this->HasAccess("write", $page) && !$this->services->get(SecurityController::class)->isWikiHibernated()) { - $options['linkedit'] = $this->href("edit", $page); + if ($this->HasAccess('write', $page) && !$this->services->get(SecurityController::class)->isWikiHibernated()) { + $options['linkedit'] = $this->href('edit', $page); } if ($time) { // hack to hide E_STRICT error if no timezone set date_default_timezone_set(@date_default_timezone_get()); - $options['linkrevisions'] = $this->href("revisions", $page); + $options['linkrevisions'] = $this->href('revisions', $page); $options['time'] = date(_t('TEMPLATE_DATE_FORMAT'), strtotime($time)); } @@ -51,9 +51,9 @@ $owner = $this->GetPageOwner($page); // message if ($this->UserIsOwner($page)) { - $options['owner'] = _t('TEMPLATE_OWNER') . " : " . _t('TEMPLATE_YOU'); + $options['owner'] = _t('TEMPLATE_OWNER') . ' : ' . _t('TEMPLATE_YOU'); } elseif ($owner) { - $options['owner'] = _t('TEMPLATE_OWNER') . " : " . $owner; + $options['owner'] = _t('TEMPLATE_OWNER') . ' : ' . $owner; } else { $options['owner'] = _t('TEMPLATE_NO_OWNER'); } @@ -62,29 +62,29 @@ if ($this->UserIsOwner($page) || $this->UserIsAdmin()) { $options['owner'] .= ' - ' . _t('TEMPLATE_PERMISSIONS'); if (!$this->services->get(SecurityController::class)->isWikiHibernated()) { - $options['linkacls'] = $this->href("acls", $page); - $options['linkdeletepage'] = $this->href("deletepage", $page); + $options['linkacls'] = $this->href('acls', $page); + $options['linkdeletepage'] = $this->href('deletepage', $page); } $aclsService = $this->services->get(AclService::class); $hasAccessComment = $aclsService->hasAccess('comment'); $options['wikigroups'] = $this->GetGroupsList(); if ($this->services->get(ParameterBagInterface::class)->get('comments_activated')) { if ($hasAccessComment && $hasAccessComment !== 'comments-closed') { - $options['linkclosecomments'] = $this->href("claim", $page, ['action' => 'closecomments'], false); + $options['linkclosecomments'] = $this->href('claim', $page, ['action' => 'closecomments'], false); } else { - $options['linkopencomments'] = $this->href("claim", $page, ['action' => 'opencomments'], false); + $options['linkopencomments'] = $this->href('claim', $page, ['action' => 'opencomments'], false); } } } elseif (!$owner && $this->GetUser()) { - $options['owner'] .= " - " . _t('TEMPLATE_CLAIM'); + $options['owner'] .= ' - ' . _t('TEMPLATE_CLAIM'); if (!$this->services->get(SecurityController::class)->isWikiHibernated()) { - $options['linkacls'] = $this->href("claim", $page); + $options['linkacls'] = $this->href('claim', $page); } } } } $options['linkduplicate'] = $this->href('duplicate', $page); - $options['linkshare'] = $this->href("share", $page); + $options['linkshare'] = $this->href('share', $page); $options['userIsOwner'] = $this->UserIsOwner($page); $options['userIsAdmin'] = $this->UserIsAdmin(); $options['userIsAdminOrOwner'] = $this->UserIsAdmin() || $this->UserIsOwner($page);