From 88f5d81264fed69601585d405c1931e43bdbcf19 Mon Sep 17 00:00:00 2001 From: Simon DELAGE Date: Wed, 10 Sep 2014 17:09:50 +0200 Subject: [PATCH] Trying new process on templates copy with msg() --- action.php | 27 +++++++++++++++------------ lang/en/lang.php | 2 ++ lang/fr/lang.php | 2 ++ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/action.php b/action.php index 7809416..f964031 100644 --- a/action.php +++ b/action.php @@ -27,23 +27,18 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{ if (($this->getConf('create_private_ns')) && (!file_exists(DOKU_INC.$this->getConf('templates_path').'/userhomepage_private.txt'))) { // If old template exists, use it as source to create userhomepage_private.txt in templates_path if (file_exists(DOKU_INC.$this->getConf('templatepath'))) { - $source_private = DOKU_INC.$this->getConf('templatepath'); + $source = DOKU_INC.$this->getConf('templatepath'); } else { - $source_private = DOKU_INC.'lib/plugins/userhomepage/lang/'.$conf['lang'].'/userhomepage_private.default'; - } - if (!copy($source_private, DOKU_INC.$this->getConf('templates_path').'/userhomepage_private.txt')) { -// echo ' An error occured while attempting to copy userhomepage_private.default to '.DOKU_INC.$this->getConf('templates_path').'/userhomepage_private.txt'; -// } else { -// echo ' Successfully copied private template.'; + $source = DOKU_INC.'lib/plugins/userhomepage/lang/'.$conf['lang'].'/userhomepage_private.default'; } + $dest = DOKU_INC.$this->getConf('templates_path').'/userhomepage_private.txt'; + copyFile($source, $dest); } // CREATE PUBLIC PAGE TEMPLATES IF NEEDED if (($this->getConf('create_public_page')) && (!file_exists(DOKU_INC.$this->getConf('templates_path').'/userhomepage_public.txt'))) { - if (!copy(DOKU_INC.'lib/plugins/userhomepage/lang/'.$conf['lang'].'/userhomepage_public.default', DOKU_INC.$this->getConf('templates_path').'/userhomepage_public.txt')) { -// echo ' An error occured while attempting to copy userhomepage_public.default to '.DOKU_INC.$this->getConf('templates_path').'/userhomepage_public.txt'; -// } else { -// echo ' Successfully copied public template.'; - } + $source = DOKU_INC.'lib/plugins/userhomepage/lang/'.$conf['lang'].'/userhomepage_public.default'; + $dest = DOKU_INC.$this->getConf('templates_path').'/userhomepage_public.txt'; + copyFile($source, $dest); } // TARGETS if ($this->getConf('group_by_name')) { @@ -85,6 +80,14 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{ file_put_contents(DOKU_INC.'conf/acl.auth.php', implode($lines)); } + function copyFile($source = null, $dest = null) { + if (!copy($source, $dest)) { + msg($lang['copyerror'].$dest, -1); + } else { + msg($lang['copysuccess'].$dest, 1); + } + } + function redirect(&$event, $param) { global $conf; global $INFO; diff --git a/lang/en/lang.php b/lang/en/lang.php index 47a10d7..d39a127 100644 --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -6,3 +6,5 @@ */ $lang['created'] = 'Page created from template by Userhompage plugin.'; + $lang['copyerror'] = 'An error occured while attempting to create '; + $lang['copysuccess'] = 'Successfully created '; diff --git a/lang/fr/lang.php b/lang/fr/lang.php index 464ceb7..e3e8cdb 100644 --- a/lang/fr/lang.php +++ b/lang/fr/lang.php @@ -6,3 +6,5 @@ */ $lang['created'] = 'Page créée à partir du modèle par le plugin Userhomepage.'; + $lang['copyerror'] = 'Une erreur est survenue à la création de '; + $lang['copysuccess'] = 'Création avec succès de ';