diff --git a/_config.php b/_config.php index 47aba46..872fa01 100644 --- a/_config.php +++ b/_config.php @@ -32,11 +32,17 @@ if ($cinecturlink2_public_nbrpp < 1) { $cinecturlink2_public_nbrpp = 10; } +$combo_dirs = cinecturlink2::getPublicDirs($core); + if (!empty($_POST['save'])) { try { + $cinecturlink2_active = !empty($_POST['cinecturlink2_active']); $cinecturlink2_widthmax = abs((integer) $_POST['cinecturlink2_widthmax']); - $cinecturlink2_folder = (string) files::tidyFileName($_POST['cinecturlink2_folder']); + $cinecturlink2_newdir = (string) files::tidyFileName($_POST['cinecturlink2_newdir']); + $cinecturlink2_folder = empty($cinecturlink2_newdir) ? + (string) files::tidyFileName($_POST['cinecturlink2_folder']) : + $cinecturlink2_newdir; $cinecturlink2_triggeronrandom = !empty($_POST['cinecturlink2_triggeronrandom']); $cinecturlink2_public_active = !empty($_POST['cinecturlink2_public_active']); $cinecturlink2_public_title = (string) $_POST['cinecturlink2_public_title']; @@ -48,7 +54,7 @@ if (!empty($_POST['save'])) { if (empty($cinecturlink2_folder)) { throw new Exception(__('You must provide a specific folder for images.')); } - cinecturlink2::test_folder( + cinecturlink2::makePublicDir( DC_ROOT . '/' . $core->blog->settings->system->public_path, $cinecturlink2_folder, true @@ -82,11 +88,14 @@ echo ' form::checkbox('cinecturlink2_active', 1, $cinecturlink2_active) . __('Enable plugin') . '

-

+

' . +form::combo('cinecturlink2_folder', $combo_dirs, $cinecturlink2_folder) . '

-

+

' . +form::field('cinecturlink2_newdir', 60, 64, '', 'maximal') . '

+ +

' . +form::number('cinecturlink2_widthmax', 10, 512, $cinecturlink2_widthmax) . '

@@ -108,14 +117,14 @@ form::checkbox('cinecturlink2_public_active', 1, $cinecturlink2_public_active) . __('Enable public page') . '

' . sprintf(__('Public page has url: %s'), '' . $core->blog->url . $core->url->getBase('cinecturlink2') . '') . '

-

+

' . +form::field('cinecturlink2_public_title', 60, 255, $cinecturlink2_public_title, 'maximal') . '

-

+

' . +form::field('cinecturlink2_public_description', 60, 255, $cinecturlink2_public_description, 'maximal') . '

-

+

' . +form::number('cinecturlink2_public_nbrpp', 1, 100, $cinecturlink2_public_nbrpp) . '

diff --git a/inc/class.cinecturlink2.php b/inc/class.cinecturlink2.php index 0d8ae58..f1d28e7 100644 --- a/inc/class.cinecturlink2.php +++ b/inc/class.cinecturlink2.php @@ -446,7 +446,7 @@ class cinecturlink2 * @param boolean $throw Throw exception or not * @return boolean True if exists and writable */ - public static function test_folder($root, $folder, $throw = false) + public static function makePublicDir($root, $folder, $throw = false) { if (!is_dir($root . '/' . $folder)) { if (!is_dir($root) || !is_writable($root) || !mkdir($root . '/' . $folder)) { @@ -458,4 +458,22 @@ class cinecturlink2 } return true; } + + /** + * Get list of public directories + * + * @param dcCore $core Core instance + * @return array Directories + */ + public static function getPublicDirs($core) + { + $dirs = []; + $all = files::getDirList($core->blog->public_path); + foreach($all['dirs'] as $dir) { + $dir = substr($dir, strlen($core->blog->public_path) + 1); + $dirs[$dir] = $dir; + } + + return $dirs; + } } \ No newline at end of file diff --git a/index.php b/index.php index 8a65c76..905e968 100644 --- a/index.php +++ b/index.php @@ -196,7 +196,7 @@ if ($part == 'link') { if (!empty($_POST['save'])) { try { - cinecturlink2::test_folder( + cinecturlink2::makePublicDir( DC_ROOT . '/' .$core->blog->settings->system->public_path, $core->blog->settings->cinecturlink2->cinecturlink2_folder ); diff --git a/locales/fr/main.po b/locales/fr/main.po index 0a354c2..c6bc1a9 100644 --- a/locales/fr/main.po +++ b/locales/fr/main.po @@ -3,7 +3,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Project-Id-Version: cinecturlink2 0.9.1\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-10-24T22:24:00+00:00\n" +"PO-Revision-Date: 2021-11-02T22:51:46+00:00\n" "Last-Translator: Jean-Christian Denis\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -19,12 +19,15 @@ msgstr "Évaluation" msgid "You must provide a specific folder for images." msgstr "Vous devez fournir un dossier spécifique pour les images." -msgid "Maximum width of images (in pixel):" -msgstr "Largeur maximum des images (en pixels) :" - msgid "Public folder of images (under public folder of blog):" msgstr "Dossier publique des images (dans le répertoire \"public\" du blog) :" +msgid "Or create a new public folder of images:" +msgstr "Ou créer un nouveau dossier public :" + +msgid "Maximum width of images (in pixel):" +msgstr "Largeur maximum des images (en pixels) :" + msgid "Update cache when use \"Random\" or \"Number of view\" order on widget (Need reload of widgets on change)" msgstr "Mettre à jour le cache lors de l'utilisation de l'ordre \"Aléatoire\" ou \"Nombre d'affichages\" dans le widget (Nécessite le rechargement du widget)"