From 06c912c7a8011a8d14604942c289da8c2a45e3f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tempez?= Date: Sat, 15 Oct 2022 09:00:53 +0200 Subject: [PATCH] Ajouter une pagination --- core/module/translate/translate.php | 30 +++++++++++++++++++++++----- core/module/translate/view/ui/ui.php | 12 ++++++----- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/core/module/translate/translate.php b/core/module/translate/translate.php index 13a9e1f2..a8105984 100644 --- a/core/module/translate/translate.php +++ b/core/module/translate/translate.php @@ -26,18 +26,26 @@ class translate extends common 'content' => self::GROUP_VISITOR, ]; + const PAGINATION = '20'; + // Language contents public static $translateOptions = []; + // Page pour la configuration dans la langue public static $pagesList = []; public static $orphansList = []; + public static $pages = ''; + // Liste des langues installées public static $languagesUiInstalled = []; public static $languagesInstalled = []; + // Liste des langues cibles public static $languagesTarget = []; + // Activation du bouton de copie public static $siteCopy = true; + // Localisation en cours d'édition public static $locales = []; @@ -145,7 +153,7 @@ class translate extends common self::$i18nUI === $key ? helper::translate('Interface') : '', '', template::button('translateContentLanguageEdit' . $key, [ - 'href' => helper::baseUrl() . $this->getUrl(0) . '/locale/' . $key , + 'href' => helper::baseUrl() . $this->getUrl(0) . '/locale/' . $key, 'value' => template::ico('pencil'), 'help' => 'Éditer' ]), @@ -179,7 +187,7 @@ class translate extends common self::$i18nUI === $selected ? helper::translate('Interface') : '', '', template::button('translateContentLanguageEdit' . $file, [ - 'href' => helper::baseUrl() . $this->getUrl(0) . '/ui/' . $selected , + 'href' => helper::baseUrl() . $this->getUrl(0) . '/ui/' . $selected, 'value' => template::ico('pencil'), 'help' => 'Éditer', 'disabled' => 'fr_FR' === $selected @@ -272,7 +280,7 @@ class translate extends common { // Jeton incorrect ou URl avec le code langue incorrecte if ( - !array_key_exists($this->getUrl(2), self::$languages) + !array_key_exists($this->getUrl(2), self::$languages) ) { // Valeurs en sortie $this->addOutput([ @@ -390,7 +398,7 @@ class translate extends common { // Jeton incorrect ou URl avec le code langue incorrecte if ( - !array_key_exists($this->getUrl(2), self::$languages) + !array_key_exists($this->getUrl(2), self::$languages) ) { // Valeurs en sortie $this->addOutput([ @@ -435,7 +443,19 @@ class translate extends common // Tableau des chaines à traduire dans la langue sélectionnée foreach ($data as $key => $value) { - self::$languagesUiInstalled[$key] = $value; + $dialogues[] = ['source' => $key, 'target' => $value]; + } + + // Pagination + $pagination = helper::pagination($dialogues, $this->getUrl(), self::PAGINATION); + + // Liste des pages + self::$pages = $pagination['pages']; + + + // Articles en fonction de la pagination + for ($i = $pagination['first']; $i < $pagination['last']; $i++) { + self::$languagesUiInstalled[$i] = $dialogues[$i]; } // Valeurs en sortie diff --git a/core/module/translate/view/ui/ui.php b/core/module/translate/view/ui/ui.php index ebc33d6b..819600e3 100644 --- a/core/module/translate/view/ui/ui.php +++ b/core/module/translate/view/ui/ui.php @@ -17,17 +17,19 @@
$value) : ?>
- - + +
- '', - 'value' => $value + 'value' => $value['target'] ]); ?>
+ - \ No newline at end of file + + \ No newline at end of file