From a1fd9cd45203475bb61792aa01393e5c66fd0a3a Mon Sep 17 00:00:00 2001 From: Szymon Olewniczak Date: Tue, 9 Jan 2018 14:29:10 +0100 Subject: [PATCH 01/50] class hierarchy --- helper/fieldmulticheck.php | 9 ++++++ helper/fieldmultiselect.php | 60 +++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 helper/fieldmulticheck.php create mode 100644 helper/fieldmultiselect.php diff --git a/helper/fieldmulticheck.php b/helper/fieldmulticheck.php new file mode 100644 index 0000000..e3bd641 --- /dev/null +++ b/helper/fieldmulticheck.php @@ -0,0 +1,9 @@ +init($args); + $this->opt['args'] = array_map('trim', explode('|',array_shift($args))); + $this->standardArgs($args); + if (!isset($this->opt['value']) && isset($this->opt['optional'])) { + array_unshift($this->opt['args'],' '); + } + } + + /** + * Render the field as XHTML + * + * Outputs the represented field using the passed Doku_Form object. + * Additional parameters (CSS class & HTML name) are passed in $params. + * + * @params array $params Additional HTML specific parameters + * @params Doku_Form $form The target Doku_Form object + * @params int $formid unique identifier of the form which contains this field + */ + public function renderfield($params, Doku_Form $form, $formid) { + $this->_handlePreload(); + if(!$form->_infieldset){ + $form->startFieldset(''); + } + if ($this->error) { + $params['class'] = 'bureaucracy_error'; + } + $params = array_merge($this->opt, $params); + $form->addElement(call_user_func_array('form_makeListboxField', + $this->_parse_tpl( + array( + '@@NAME@@', + $params['args'], + '@@VALUE|' . $params['args'][0] . '@@', + '@@DISPLAY@@', + '@@ID@@', + '@@CLASS@@' + ), + $params + ))); + } +} \ No newline at end of file From 91f85cb68acd701f2ebf6f985cd7c92b14cd798b Mon Sep 17 00:00:00 2001 From: Szymon Olewniczak Date: Wed, 10 Jan 2018 11:38:40 +0100 Subject: [PATCH 02/50] multiple select for bureaucracy this commit creates a syntax for multiple select: multiselect "Label" "Opt1|Opt2|Opt3" =Opt1|Opt3 "=" - one or more default options In mail action all options will be joined by ", " in e-mail message In template action: - if field is marked with "@" all selected options will be joined with page separator - during template substitution all options will be joined by ", " or you can provide optional separator: @@Label(separator)@@ needs docs update --- helper/actionmail.php | 1 + helper/actiontemplate.php | 1 + helper/fieldmulticheck.php | 9 ------ helper/fieldmultiselect.php | 63 ++++++++++++++++++++++++++++++++----- 4 files changed, 58 insertions(+), 16 deletions(-) delete mode 100644 helper/fieldmulticheck.php diff --git a/helper/actionmail.php b/helper/actionmail.php index dc32b76..a2aa5bf 100644 --- a/helper/actionmail.php +++ b/helper/actionmail.php @@ -140,6 +140,7 @@ protected function processFieldsBuildTable($fields, $mail) { default: if($value === null || $label === null) break; + if(is_array($value)) $value = implode(', ', $value); list($html, $text) = $this->mail_buildRow($label, $value); if(!is_null($field->getParam('replyto'))) { diff --git a/helper/actiontemplate.php b/helper/actiontemplate.php index 8e5a2cf..e2d86ee 100644 --- a/helper/actiontemplate.php +++ b/helper/actiontemplate.php @@ -70,6 +70,7 @@ protected function buildTargetPagename($fields, $sep) { foreach ($fields as $field) { $pname = $field->getParam('pagename'); if (!is_null($pname)) { + if (is_array($pname)) $pname = implode($sep, $pname); $this->pagename .= $sep . $pname; } } diff --git a/helper/fieldmulticheck.php b/helper/fieldmulticheck.php deleted file mode 100644 index e3bd641..0000000 --- a/helper/fieldmulticheck.php +++ /dev/null @@ -1,9 +0,0 @@ -init($args); $this->opt['args'] = array_map('trim', explode('|',array_shift($args))); $this->standardArgs($args); - if (!isset($this->opt['value']) && isset($this->opt['optional'])) { - array_unshift($this->opt['args'],' '); + if (isset($this->opt['value'])) { + $this->opt['value'] = array_map('trim', explode('|', $this->opt['value'])); + } else { + $this->opt['value'] = array(); } } + /** + * Get the replacement pattern used by action + * + * @return string + */ + public function getReplacementPattern() { + $label = $this->opt['label']; + $value = $this->opt['value']; + + return '/(@@|##)' . preg_quote($label, '/') . + '(?:\((?P.*?)\))?' .//delimiter + '(?:\|(?P.*?))' . (count($value) == 0 ? '' : '?') . + '\1/si'; + } + + /** + * Used as an callback for preg_replace_callback + * + * @param $matches + * @return string + */ + public function replacementValueCallback($matches) { + $value = $this->opt['value']; + + //default value + if (is_null($value) || $value === false) { + if (isset($matches['default']) && $matches['default'] != '') { + return $matches['default']; + } + return $matches[0]; + } + + //check if matched string containts a pair of brackets + $delimiter = preg_match('/\(.*\)/s', $matches[0]) ? $matches['delimiter'] : ', '; + + return implode($delimiter, $value); + } + + /** + * Return the callback for user replacement + * + * @return array + */ + public function getReplacementValue() { + return array($this, 'replacementValueCallback'); + } + /** * Render the field as XHTML * @@ -47,12 +95,13 @@ public function renderfield($params, Doku_Form $form, $formid) { $form->addElement(call_user_func_array('form_makeListboxField', $this->_parse_tpl( array( - '@@NAME@@', + '@@NAME@@[]', $params['args'], - '@@VALUE|' . $params['args'][0] . '@@', + $this->opt['value'], '@@DISPLAY@@', '@@ID@@', - '@@CLASS@@' + '@@CLASS@@', + array('multiple' => 'multiple') ), $params ))); From eb9f1ebade8b14ff6cdbb3ed1be46155814023ca Mon Sep 17 00:00:00 2001 From: Szymon Olewniczak Date: Wed, 10 Jan 2018 13:03:55 +0100 Subject: [PATCH 03/50] move mutliselect logic into field class this simplifies struct's bureaucracy integration code --- helper/field.php | 36 ++++++++++++++++++++++++++++ helper/fieldmultiselect.php | 47 ------------------------------------- 2 files changed, 36 insertions(+), 47 deletions(-) diff --git a/helper/field.php b/helper/field.php index 7ee325d..06b4a9a 100644 --- a/helper/field.php +++ b/helper/field.php @@ -219,11 +219,42 @@ public function getFieldType() { public function getReplacementPattern() { $label = $this->opt['label']; $value = $this->opt['value']; + + if (is_array($value)) { + return '/(@@|##)' . preg_quote($label, '/') . + '(?:\((?P.*?)\))?' .//delimiter + '(?:\|(?P.*?))' . (count($value) == 0 ? '' : '?') . + '\1/si'; + } + return '/(@@|##)' . preg_quote($label, '/') . '(?:\|(.*?))' . (is_null($value) ? '' : '?') . '\1/si'; } + /** + * Used as an callback for preg_replace_callback + * + * @param $matches + * @return string + */ + public function replacementMultiValueCallback($matches) { + $value = $this->opt['value']; + + //default value + if (is_null($value) || $value === false) { + if (isset($matches['default']) && $matches['default'] != '') { + return $matches['default']; + } + return $matches[0]; + } + + //check if matched string containts a pair of brackets + $delimiter = preg_match('/\(.*\)/s', $matches[0]) ? $matches['delimiter'] : ', '; + + return implode($delimiter, $value); + } + /** * Get the value used by action * If value is a callback preg_replace_callback is called instead preg_replace @@ -232,6 +263,11 @@ public function getReplacementPattern() { */ public function getReplacementValue() { $value = $this->opt['value']; + + if (is_array($value)) { + return array($this, 'replacementMultiValueCallback'); + } + return is_null($value) || $value === false ? '$2' : $value; } diff --git a/helper/fieldmultiselect.php b/helper/fieldmultiselect.php index c3f9802..7fec731 100644 --- a/helper/fieldmultiselect.php +++ b/helper/fieldmultiselect.php @@ -26,53 +26,6 @@ public function initialize($args) { } } - /** - * Get the replacement pattern used by action - * - * @return string - */ - public function getReplacementPattern() { - $label = $this->opt['label']; - $value = $this->opt['value']; - - return '/(@@|##)' . preg_quote($label, '/') . - '(?:\((?P.*?)\))?' .//delimiter - '(?:\|(?P.*?))' . (count($value) == 0 ? '' : '?') . - '\1/si'; - } - - /** - * Used as an callback for preg_replace_callback - * - * @param $matches - * @return string - */ - public function replacementValueCallback($matches) { - $value = $this->opt['value']; - - //default value - if (is_null($value) || $value === false) { - if (isset($matches['default']) && $matches['default'] != '') { - return $matches['default']; - } - return $matches[0]; - } - - //check if matched string containts a pair of brackets - $delimiter = preg_match('/\(.*\)/s', $matches[0]) ? $matches['delimiter'] : ', '; - - return implode($delimiter, $value); - } - - /** - * Return the callback for user replacement - * - * @return array - */ - public function getReplacementValue() { - return array($this, 'replacementValueCallback'); - } - /** * Render the field as XHTML * From c7753ea5717e99a252b2921766dc15c03433b87a Mon Sep 17 00:00:00 2001 From: Szymon Olewniczak Date: Wed, 10 Jan 2018 13:30:44 +0100 Subject: [PATCH 04/50] use "," instead of "|" as multi default value separator for compatibility with struct plugin --- helper/fieldmultiselect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper/fieldmultiselect.php b/helper/fieldmultiselect.php index 7fec731..5311d90 100644 --- a/helper/fieldmultiselect.php +++ b/helper/fieldmultiselect.php @@ -20,7 +20,7 @@ public function initialize($args) { $this->opt['args'] = array_map('trim', explode('|',array_shift($args))); $this->standardArgs($args); if (isset($this->opt['value'])) { - $this->opt['value'] = array_map('trim', explode('|', $this->opt['value'])); + $this->opt['value'] = array_map('trim', explode(',', $this->opt['value'])); } else { $this->opt['value'] = array(); } From d617126d2ccd2cfa0f4836567c370f63184b2342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schplurtz=20le=20D=C3=A9boulonn=C3=A9?= Date: Thu, 1 Feb 2018 05:45:05 +0100 Subject: [PATCH 05/50] translation update --- lang/fr/lang.php | 65 ++++++++++++++++++++++++-------------------- lang/fr/settings.php | 9 ++++-- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/lang/fr/lang.php b/lang/fr/lang.php index 5610500..e3a3a6e 100644 --- a/lang/fr/lang.php +++ b/lang/fr/lang.php @@ -1,31 +1,38 @@ + */ +$lang['e_unknowntype'] = 'Type inconu "%s"'; +$lang['e_unknownaction'] = 'Action inconnue "%s"'; +$lang['e_missingargs'] = 'Pas assez d\'arguments pour %s %s'; +$lang['e_noaction'] = 'Pas d\'action définie - que faire des données ?'; +$lang['e_mail'] = 'Erreur lors de l\'envoi des données'; +$lang['e_unknownconstraint'] = 'Contrainte de champ inconue %s'; +$lang['e_labelpage'] = 'Page de label %s non trouvée.'; +$lang['e_required'] = '"%s" est requis'; +$lang['e_match'] = '"%s" n\'a pas été remplis correctement. %s'; +$lang['checkagainst'] = '(vérifié avec /%s/i)'; +$lang['e_email'] = '"%s" doit être une adresse e-mail valide.'; +$lang['e_numeric'] = '"%s" doit être un nombre.'; +$lang['e_date'] = '"%s" doit être une date valide au format yyyy-mm-dd.'; +$lang['e_time'] = '"%s" nécessite une heure valide au format (h)h:mm(:ss).'; +$lang['e_user'] = '"%s" doit être le nom d\'un utilisateur existant.'; +$lang['e_users'] = '"%s" doit être une liste de noms d\'utilisateurs séparés par des virgules.'; +$lang['e_min'] = '"%s" doit être plus grand que %s.'; +$lang['e_max'] = '"%s" doit être plus petit que %s.'; +$lang['e_pagename'] = 'Nom de page manquant.'; +$lang['e_pageexists'] = 'La page "%s" existe déjà. Choisissez un autre nom.'; +$lang['e_template'] = 'Modèle "%s" introuvable. Il n\'existe pas ou vous n\'avez pas l\'autorisation de lecture.'; +$lang['e_denied'] = 'Vous n\'avez pas le droit de créer cette page, vous êtes vous connecté ?'; +$lang['mailsubject'] = 'Données du formulaire soumises à %s'; +$lang['mailintro'] = 'Les données suivantes on été envoyées vers %s.'; +$lang['mail_thanks'] = 'Données envoyées avec succès. Merci.'; +$lang['template_thanks'] = 'La page a été créée, suivez le lien pour l\'ouvrir.'; +$lang['summary'] = 'Créé depuis le formulaire %s'; +$lang['attachmentMailEmpty'] = '(fichier non envoyé)'; +$lang['attachmentMailToLarge'] = '(pièce jointe trop grosse)'; +$lang['attachmentMailToLarge_userinfo'] = 'fichier "%s" trop gros comme pièce jointe (>%s). Le message a tout de même été envoyé.'; +$lang['submit'] = 'Envoyer'; diff --git a/lang/fr/settings.php b/lang/fr/settings.php index 1b4fd6c..a97393d 100644 --- a/lang/fr/settings.php +++ b/lang/fr/settings.php @@ -1,4 +1,9 @@ + */ +$lang['runas'] = 'Mode «template» : teste les ACL avec les permissions de cet utilisateur (virtuel) pour la lecture des page modèles et la création de page.'; +$lang['maxEmailAttachmentSize'] = 'Taille max en octet des pièces jointes dans les courriels. (par fichier)'; From e787cd7c3b64127689e3cde16785fe8af6b9da03 Mon Sep 17 00:00:00 2001 From: Davor Turkalj Date: Sat, 3 Feb 2018 19:35:38 +0100 Subject: [PATCH 06/50] translation update --- lang/hr/lang.php | 68 +++++++++++++++++++++++--------------------- lang/hr/settings.php | 9 ++++-- 2 files changed, 43 insertions(+), 34 deletions(-) diff --git a/lang/hr/lang.php b/lang/hr/lang.php index f3a36ac..339d3b8 100644 --- a/lang/hr/lang.php +++ b/lang/hr/lang.php @@ -1,34 +1,38 @@ + */ +$lang['e_unknowntype'] = 'Nepoznat tip "%s"'; +$lang['e_unknownaction'] = 'Nepoznata aktivnost "%s"'; +$lang['e_missingargs'] = 'Nema dovoljno argumenata za %s %s'; +$lang['e_noaction'] = 'Nema definirane akcije - gdje podaci trebaju biti poslani?'; +$lang['e_mail'] = 'Nešto je pošlo krivo s slanjem ovih podataka'; +$lang['e_unknownconstraint'] = 'Nepoznato ograničenje polja %s'; +$lang['e_labelpage'] = 'Stranica s labelama %s nije nađena'; +$lang['e_required'] = '"%s" je obvezan'; +$lang['e_match'] = '"%s" nije ispravno popunjen. %s'; +$lang['checkagainst'] = '(Provjereno prema /%s/i)'; +$lang['e_email'] = '"%s" treba biti valjana adresa e-pošte.'; +$lang['e_numeric'] = '"%s" treba biti broj.'; +$lang['e_date'] = '"%s" treba biti valjani datum u obliku gggg-mm-dd.'; +$lang['e_time'] = '"%s" treba biti u valjanom obliku (h)h:mm(:ss).'; +$lang['e_user'] = '"%s" treba biti ime postojećeg korisnika.'; +$lang['e_users'] = '"%s" treba biti zarezom odvojena lista imena postojećih korisnika.'; +$lang['e_min'] = '"%s" treba biti veći od %s.'; +$lang['e_max'] = '"%s" treba biti manji od %s.'; +$lang['e_pagename'] = 'Nedostaje ime stranice.'; +$lang['e_pageexists'] = 'Strnaica "%s" već postoji. Molimo odaberite drugo ime stranice.'; +$lang['e_template'] = 'Nemogu pročitati predložak "%s". Možda ne postoji ili nemate pravo čitanja?'; +$lang['e_denied'] = 'Nije Vam dopušteno stvaranje ove stranice, možda ste se zaboravili prijaviti?'; +$lang['mailsubject'] = 'Podaci proslijeđeni u %s'; +$lang['mailintro'] = 'Slijedeći podaci su proslijeđeni u %s.'; +$lang['mail_thanks'] = 'Vaši podaci su uspješno poslani. Hvala.'; +$lang['template_thanks'] = 'Stranica je kreirana, slijedi vezu za njeno otvaranje.'; +$lang['summary'] = 'Kreirano iz forme u %s'; +$lang['attachmentMailEmpty'] = '(datoteka nije poslana)'; +$lang['attachmentMailToLarge'] = '(datoteka prevelika za prilog pošte)'; +$lang['attachmentMailToLarge_userinfo'] = 'datoteka "%s" prevelika za prilog pošte (>%s) (pošta je ipak poslana)'; +$lang['submit'] = 'Proslijedi'; diff --git a/lang/hr/settings.php b/lang/hr/settings.php index 68b3b33..d9df8dd 100644 --- a/lang/hr/settings.php +++ b/lang/hr/settings.php @@ -1,4 +1,9 @@ + */ +$lang['runas'] = 'Utječe na mod predloška. Koristi ove (virtualne) ovlasti kada provjeravaš ACL za čitanje predloška i stvaranje stranice.'; +$lang['maxEmailAttachmentSize'] = 'Maksimalna veličina priloga pošti u Bajtovima. (po datoteci)'; From f1bc6d04063fe837e3bc50ab35243943de9fb9ed Mon Sep 17 00:00:00 2001 From: Szymon Olewniczak Date: Thu, 8 Feb 2018 11:06:48 +0100 Subject: [PATCH 07/50] yesno replacement bugfix The current version of bureaucracy doesn't handle yesno template replacements correctly. The @@yesno@@ placeholder is always replaced by "1" or "0" regardless values provided in
. This commit fixes it. --- helper/field.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helper/field.php b/helper/field.php index 7ee325d..877e3e4 100644 --- a/helper/field.php +++ b/helper/field.php @@ -217,8 +217,8 @@ public function getFieldType() { * @return string */ public function getReplacementPattern() { - $label = $this->opt['label']; - $value = $this->opt['value']; + $label = $this->getParam('label'); + $value = $this->getParam('value'); return '/(@@|##)' . preg_quote($label, '/') . '(?:\|(.*?))' . (is_null($value) ? '' : '?') . '\1/si'; @@ -231,7 +231,7 @@ public function getReplacementPattern() { * @return mixed|string */ public function getReplacementValue() { - $value = $this->opt['value']; + $value = $this->getParam('value'); return is_null($value) || $value === false ? '$2' : $value; } From 11d388c9849836c112c058dab70731f22be62305 Mon Sep 17 00:00:00 2001 From: Thorsten Niederkrome Date: Fri, 23 Feb 2018 23:25:30 +0100 Subject: [PATCH 08/50] translation update --- lang/de/lang.php | 66 ++++++++++++++++++++++---------------------- lang/de/settings.php | 7 +++-- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/lang/de/lang.php b/lang/de/lang.php index b5e6362..a50631c 100644 --- a/lang/de/lang.php +++ b/lang/de/lang.php @@ -1,38 +1,38 @@ + */ +$lang['e_unknowntype'] = 'Unbekannter Typ "%s"'; +$lang['e_unknownaction'] = 'Unbekannte Aktion "%s"'; +$lang['e_missingargs'] = 'Nicht genug Argumente für %s %s'; +$lang['e_noaction'] = 'Keine Aktion definiert - wohin sollen die Daten gesendet werden?'; +$lang['e_mail'] = 'Beim Versenden der Daten ist ein Fehler augetreten'; +$lang['e_unknownconstraint'] = 'Unbekannter Feld-Parameter %s'; +$lang['e_labelpage'] = 'Seite mit Feldnamen %s nicht gefunden'; +$lang['e_required'] = '"%s" muss ausgefüllt werden.'; +$lang['e_match'] = '"%s" wurde nicht korrekt ausgefüllt. %s'; +$lang['checkagainst'] = '(überprüft gegen /%s/)'; +$lang['e_email'] = '"%s" muss eine gültige E-Mail Adresse sein.'; +$lang['e_numeric'] = '"%s" muss eine Nummer sein.'; +$lang['e_date'] = '"%s" muss ein gültiges Datum im Format jjjj-mm-tt sein.'; +$lang['e_time'] = '"%s" muss eine gültige Zeit im Format (h)h:mm(:ss) sein.'; +$lang['e_user'] = '"%s" muss der Name eines existierenden Benutzers sein.'; +$lang['e_users'] = '"%s" muss eine komma-separierte Liste existierender Benutzer sein.'; +$lang['e_min'] = '"%s" muss größer sein als %s.'; +$lang['e_max'] = '"%s" muss kleiner sein als %s.'; +$lang['e_pagename'] = 'Seitenname nicht angegeben.'; +$lang['e_pageexists'] = 'Die Seite "%s" exisistiert bereits. Bitte wählen Sie einen anderen Namen.'; +$lang['e_template'] = 'Das Template "%s" konnte nicht geladen werden. Möglicherweise existiert es nicht oder Sie verfügen nicht über die benötigten Rechte.'; +$lang['e_denied'] = 'Sie sind nicht berechtigt diese Seite anzulegen. Haben Sie vielleicht vergessen sich anzumelden?'; +$lang['mailsubject'] = 'Formulardaten übermittelt von %s'; +$lang['mailintro'] = 'Die folgenden Daten wurden am %s abgeschickt.'; +$lang['mail_thanks'] = 'Ihre Daten wurden erfolgreich versandt. Vielen Dank.'; +$lang['template_thanks'] = 'Die Seite wurde angelegt, folgen Sie dem Link um die neue Seite aufzurufen.'; +$lang['summary'] = 'Erstellt mit dem Formular %s'; $lang['attachmentMailEmpty'] = '(Datei nicht angegeben)'; $lang['attachmentMailToLarge'] = '(Datei zu groß für Mail-Anhang)'; $lang['attachmentMailToLarge_userinfo'] = 'Die Datei "%s" ist zu groß als Mail-Anhang (>%s) (E-Mail ohne Datei gesendet)'; - - -$lang['submit'] = 'Absenden'; +$lang['submit'] = 'Absenden'; diff --git a/lang/de/settings.php b/lang/de/settings.php index 4f8c39f..f81c634 100644 --- a/lang/de/settings.php +++ b/lang/de/settings.php @@ -1,5 +1,8 @@ Date: Sun, 25 Mar 2018 00:35:12 +0100 Subject: [PATCH 09/50] translation update --- lang/ru/lang.php | 61 ++++++++++++++++++++++++++------------------ lang/ru/settings.php | 8 +++++- 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/lang/ru/lang.php b/lang/ru/lang.php index 54a7e98..4981407 100644 --- a/lang/ru/lang.php +++ b/lang/ru/lang.php @@ -1,27 +1,38 @@ + */ +$lang['e_unknowntype'] = 'Неизвестный тип "%s"'; +$lang['e_unknownaction'] = 'Неизвестное действие "%s"'; +$lang['e_missingargs'] = 'Недостаточно аргументов для %s %s'; +$lang['e_noaction'] = 'Не указано действие - куда должны быть отправить данные?'; +$lang['e_mail'] = 'Произошла ошибка при отправке данных'; +$lang['e_unknownconstraint'] = 'Неизвестный ограничитель поля %s'; +$lang['e_labelpage'] = 'Метка страницы %s не найдена'; +$lang['e_required'] = '"%s" данное поле обязательно для заполнения'; +$lang['e_match'] = '"%s" заполнено неверно. %s'; +$lang['checkagainst'] = '(Checked against /%s/i)'; +$lang['e_email'] = '"%s" данное поле должно содержать правильный адрес электронной почты.'; +$lang['e_numeric'] = '"%s" данное поле должно содержать число.'; +$lang['e_date'] = '"%s" должно быть допустимой датой в формате гггг-мм-дд.'; +$lang['e_time'] = '"%s" должно быть допустимым временем в формате (ч)ч:мм(:сс).'; +$lang['e_user'] = '"%s" должно быть именем существующего пользователя.'; +$lang['e_users'] = '"%s" должно быть разделенным запятыми списком имен существующих пользователей.'; +$lang['e_min'] = '"%s" данное поле должно быть больше, чем %s.'; +$lang['e_max'] = '"%s" данное поле должно быть меньше, чем %s.'; +$lang['e_pagename'] = 'Отсутствует имя страницы.'; +$lang['e_pageexists'] = 'Страница "%s" уже существует. Пожалуйста, выберите другое имя.'; +$lang['e_template'] = 'Невозможно прочитать шаблон "%s". Возможно, он не существует, или у вас не хватает прав для чтения?'; +$lang['e_denied'] = 'Вам не разрешено создавать эту страницу, возможно, вы забыли войти?'; +$lang['mailsubject'] = 'Данные формы отправлены с %s'; +$lang['mailintro'] = 'Следующие данные отправлены %s.'; +$lang['mail_thanks'] = 'Ваши данные отправлены успешно. Спасибо.'; +$lang['template_thanks'] = 'Страница создана, следуйте по ссылке, чтобы открыть её.'; +$lang['summary'] = 'Создано по форме с %s'; +$lang['attachmentMailEmpty'] = '(файл не отправлен)'; +$lang['attachmentMailToLarge'] = '(файл слишком большой для почтового вложения)'; +$lang['attachmentMailToLarge_userinfo'] = 'файл "%s" слишком большой для почтового вложения (>%s) (но сообщение было отправлено)'; +$lang['submit'] = 'Отправить'; diff --git a/lang/ru/settings.php b/lang/ru/settings.php index 3eca059..ab9a8fc 100644 --- a/lang/ru/settings.php +++ b/lang/ru/settings.php @@ -1,3 +1,9 @@ + */ +$lang['runas'] = 'Использовать права (виртуального) пользователя при проверке доступа для чтения шаблонов и создания страниц.'; +$lang['maxEmailAttachmentSize'] = 'Макс. размер почтовых вложений в байтах. (на файл)'; From 6d211d0b88081a604162a8e35dd1de677312bfd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Wed, 28 Mar 2018 18:29:54 +0200 Subject: [PATCH 10/50] Adjust for PHP 7.2 --- helper/fieldusers.php | 2 +- syntax.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/helper/fieldusers.php b/helper/fieldusers.php index 0f6f8ce..767320d 100644 --- a/helper/fieldusers.php +++ b/helper/fieldusers.php @@ -45,7 +45,7 @@ public function replacementValueCallback($matches) { $value = $this->opt['value']; //copy the value by default - if (count($matches[2]) == 2) { + if (is_array($matches[2]) && count($matches[2]) == 2) { return is_null($value) || $value === false ? $matches[0] : $value; } diff --git a/syntax.php b/syntax.php index 965ad9f..59c17b9 100644 --- a/syntax.php +++ b/syntax.php @@ -480,7 +480,7 @@ function replace($input, $strftime = true) { if($strftime) { $input = preg_replace_callback( '/%./', - create_function('$m', 'return strftime($m[0]);'), + function($m){return strftime($m[0]);}, $input ); } From 7357d7100908ee44b2bc672128301825c9dcb8f4 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 28 Mar 2018 23:50:12 +0200 Subject: [PATCH 11/50] Version upped --- plugin.info.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.info.txt b/plugin.info.txt index 0664fd2..90c4ecd 100644 --- a/plugin.info.txt +++ b/plugin.info.txt @@ -1,7 +1,7 @@ base bureaucracy author Andreas Gohr email andi@splitbrain.org -date 2018-01-08 +date 2018-03-28 name Bureaucracy Plugin desc Create forms and generate pages or emails from them url https://www.dokuwiki.org/plugin:bureaucracy From 5e8d790efc1539013dae30af6b8f409ad82805a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 1 May 2018 16:20:25 +0200 Subject: [PATCH 12/50] refactor: consolidate tests into parametrized pattern This makes the structure much more obvious and easier to spot missing tests and to add new ones. The test failure for the empty user field, seems to be an actual bug. --- _test/fielduser.test.php | 327 ++++++++++++++++---------------------- _test/fieldusers.test.php | 285 ++++++++++++++------------------- 2 files changed, 261 insertions(+), 351 deletions(-) diff --git a/_test/fielduser.test.php b/_test/fielduser.test.php index 68c6eb6..ccb9409 100644 --- a/_test/fielduser.test.php +++ b/_test/fielduser.test.php @@ -13,204 +13,157 @@ class syntax_plugin_bureaucracy_fielduser_test extends BureaucracyTest { public function setUp() { parent::setUp(); - /** @var DokuWiki_Auth_Plugin $auth */ + /** @var \DokuWiki_Auth_Plugin $auth */ global $auth; - $auth->createUser("user1", "54321", "a User", "you@example.com"); - $auth->createUser("user2", "543210", "You", "he@example.com"); - $auth->createUser("mwuser", "12345", "Wiki User", "me@example.com", array('group1', 'gropu2')); + $auth->createUser("user1", "54321", "user1Name", "user1@example.com"); + $auth->createUser("user2", "543210", "user2Name", "user2@example.com"); + $auth->createUser("mwuser", "12345", "Wiki User", "wikiuser@example.com", array('group1', 'group2')); + } + + public function dataProvider() + { + return [ + [ + 'user:@@user@@', + 'mwuser', + 'user:mwuser', + [], + 'default substitution', + ], + [ + 'user:@@user@@', + '', + 'user:', + ['user'], + 'error for empty substitution', + ], + [ + 'user:@@user.name@@', + 'mwuser', + 'user:Wiki User', + [], + 'name substitution', + ], + [ + 'user:@@user.mail@@', + 'mwuser', + 'user:wikiuser@example.com', + [], + 'mail substitution', + ], + [ + 'user:@@user.grps@@', + 'mwuser', + 'user:group1, group2', + [], + 'groups substitution', + ], + [ + 'user:@@user.grps(;)@@', + 'mwuser', + 'user:group1;group2', + [], + 'groups substitution custom delimiter', + ], + [ + 'user:@@user.grps())@@', + 'mwuser', + 'user:group1)group2', + [], + 'groups substitution custom delimiter with brackets', + ], + [ + 'user:@@user.no_sutch_attribute@@', + 'mwuser', + 'user:@@user.no_sutch_attribute@@', + [], + 'template unknown attribute substitution', + ], + [ + 'user:##user##', + 'mwuser', + 'user:mwuser', + [], + 'hash substitution', + ], + [ + 'user:##user.mail##', + 'mwuser', + 'user:wikiuser@example.com', + [], + 'hash substitution with attribute', + ], + [ + 'user:##user@@', + 'mwuser', + 'user:##user@@', + [], + 'hash substitution sign mismatch', + ], + [ + "user:@@user@@\n\nmail:@@user.mail@@\n\ngrps:@@user.grps(\n)@@", + 'mwuser', + "user:mwuser\n\nmail:wikiuser@example.com\n\ngrps:group1\ngroup2", + [], + 'multiple replacements', + ], + [ + "grps1:@@user.grps(\n)@@\n\ngrps2:@@user.grps(())@@", + 'mwuser', + "grps1:group1\ngroup2\n\ngrps2:group1()group2", + [], + 'groups twice', + ], + [ + 'grps:@@user.grps(end))@@', + 'mwuser', + 'grps:group1end)group2', + [], + 'groups special glue', + ], + ]; } + /** - * Simulate a bureaucracy form send with the 'user' field + * @dataProvider dataProvider * - * @param string $template_syntax template to be used as form action - * @param string|array $users value of 'users' field or array('label' => 'own label', 'value' => 'value') - * @param bool $assertValid should we assert the form validity - * @param array &$validation_errors labels of invalid form fields + * @param string $templateSyntax + * @param string|array $users value of 'users' field or array('label' => 'own label', 'value' => 'value') + * @param string $expectedWikiText + * @param string $expectedValidationErrors + * @param string $msg * - * @return string content of newly created page - * @throws \Exception + * @throws \InvalidArgumentException */ - protected function send_form($template_syntax, $user, $assertValid=true, &$validation_errors=array()) { + public function test_field_user( + $templateSyntax, + $users, + $expectedWikiText, + $expectedValidationErrors, + $msg + ) { + $actualValidationErrors = []; + $label = 'user'; - if (is_array($user)) { - if (!isset($user['value'])) { - throw new \Exception('$user should be string or array("label" => label, "value" => value'); + if (is_array($users)) { + if (!isset($users['value'])) { + throw new \InvalidArgumentException('$users should be string or array("label" => label, "value" => value'); } - if (isset($user['label'])) $label = $user['label']; - $user = $user['value']; - } - $result = parent::send_form_action_template('user "'.$label.'"', $template_syntax, $validation_errors, $user); - if ($assertValid) { - $this->assertEmpty($validation_errors, 'validation error: fields not valid: '.implode(', ', $validation_errors)); + if (isset($users['label'])) { + $label = $users['label']; + } + $users = $users['value']; } + $actualWikiText = parent::send_form_action_template( + 'user "' . $label . '"', + $templateSyntax, + $actualValidationErrors, + $users + ); - return $result; - } - - public function test_regex_label() { - $label = '*]]'; //somthing to break a regex when not properly quoted - $user = array('label' => $label, 'value' => 'mwuser'); - $result = $this->send_form("user:@@$label@@", $user); - $this->assertEquals("user:$user[value]", $result); - } - - public function test_action_template_default_substitution() { - $user = 'mwuser'; - $result = $this->send_form('user:@@user@@', $user); - $this->assertEquals("user:$user", $result); - } - - public function test_action_template_empty_substitution() { - $template_syntax = 'user:@@user@@'; - $validation_errors = array(); - $result = $this->send_form($template_syntax, '', false, $validation_errors); - $this->assertEquals(array('user'), $validation_errors); - } - - public function test_action_template_name_substitution() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $user = 'mwuser'; - $name = $auth->getUserData($user)['name']; - - $result = $this->send_form('user:@@user.name@@', $user); - $this->assertEquals("user:$name", $result); - } - - public function test_action_template_email_substitution() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $user = 'mwuser'; - $mail = $auth->getUserData($user)['mail']; - - $result = $this->send_form('user:@@user.mail@@', $user); - $this->assertEquals("user:$mail", $result); - } - - public function test_action_template_group_substitution_default_delimiter() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $user = 'mwuser'; - $delimiter = ', '; - $grps = implode($delimiter, $auth->getUserData($user)['grps']); - - $result = $this->send_form('user:@@user.grps@@', $user); - $this->assertEquals("user:$grps", $result); - } - - //user.grps(, ) - public function test_action_template_group_substitution_custom_delimiter() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $user = 'mwuser'; - $delimiter = ';'; - $grps = implode($delimiter, $auth->getUserData($user)['grps']); - - $result = $this->send_form("user:@@user.grps($delimiter)@@", $user); - $this->assertEquals("user:$grps", $result); - } - - //user.grps(, ) - public function test_action_template_group_substitution_custom_delimiter_with_brackets() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $user = 'mwuser'; - $delimiter = ')'; - $grps = implode($delimiter, $auth->getUserData($user)['grps']); - - $result = $this->send_form("user:@@user.grps($delimiter)@@", $user); - $this->assertEquals("user:$grps", $result); - } - - public function test_action_template_unknown_user_substitution() { - $template_syntax = 'user:@@user@@'; - $user = 'no_such_user'; - - $validation_errors = array(); - $result = $this->send_form('user:@@user@@', $user, false, $validation_errors); - $this->assertEquals(array('user'), $validation_errors); + $this->assertEquals($expectedWikiText, $actualWikiText, $msg); + $this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg); } - - public function test_action_template_unknown_attribute_substitution() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $template_syntax = 'user:@@user.no_sutch_attribute@@'; - $user = 'mwuser'; - - $result = $this->send_form($template_syntax, $user); - $this->assertEquals($template_syntax, $result); - } - - public function test_action_template_hash_subsitution() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $template_syntax = 'user:##user##'; - $user = 'mwuser'; - - $result = $this->send_form($template_syntax, $user); - $this->assertEquals('user:mwuser', $result); - } - - public function test_action_template_hash_subsitution_with_attribute() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $user = 'mwuser'; - $mail = $auth->getUserData($user)['mail']; - - $result = $this->send_form('user:##user.mail##', $user); - $this->assertEquals("user:$mail", $result); - } - - - public function test_action_template_hash_at_sign_mismatch() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $template_syntax = 'user:##user@@'; - $user = 'mwuser'; - - $result = $this->send_form($template_syntax, $user); - $this->assertEquals($template_syntax, $result); - } - - public function test_action_template_multiple_replacements() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $user = 'mwuser'; - $mail = $auth->getUserData($user)['mail']; - - $delimiter = "\n"; - $grps = implode($delimiter, $auth->getUserData($user)['grps']); - - $result = $this->send_form("user:@@user@@\n\nmail:@@user.mail@@\n\ngrps:@@user.grps($delimiter)@@", $user); - $this->assertEquals("user:$user\n\nmail:$mail\n\ngrps:$grps", $result); - } - - public function test_action_template_grps_twice() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $user = 'mwuser'; - - $delimiter1 = "\n"; - $delimiter2 = "()"; - $grps1 = implode($delimiter1, $auth->getUserData($user)['grps']); - $grps2 = implode($delimiter2, $auth->getUserData($user)['grps']); - - $result = $this->send_form("grps1:@@user.grps($delimiter1)@@\n\ngrps2:@@user.grps($delimiter2)@@", $user); - $this->assertEquals("grps1:$grps1\n\ngrps2:$grps2", $result); - } - - public function test_action_template_grps_special_glue() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $user = 'mwuser'; - - $delimiter = "end)"; - $grps = implode($delimiter, $auth->getUserData($user)['grps']); - - $result = $this->send_form("grps:@@user.grps($delimiter)@@", $user); - $this->assertEquals("grps:$grps", $result); - } - } diff --git a/_test/fieldusers.test.php b/_test/fieldusers.test.php index e3fbeb3..d5842b7 100644 --- a/_test/fieldusers.test.php +++ b/_test/fieldusers.test.php @@ -1,193 +1,150 @@ createUser("user1", "54321", "a User", "you@example.com"); - $auth->createUser("user2", "543210", "You", "he@example.com"); - $auth->createUser("mwuser", "12345", "Wiki User", "me@example.com", array('group1', 'gropu2')); + $auth->createUser('user1', '54321', 'user1Name', 'user1@example.com'); + $auth->createUser('user2', '543210', 'user2Name', 'user2@example.com'); + $auth->createUser('mwuser', '12345', 'Wiki User', 'me@example.com', array('group1', 'group2')); + } + + public function dataProvider() + { + return [ + [ + 'users:@@users@@', + 'user1, user2', + 'users:user1, user2', + [], + 'default substitution', + ], + [ + 'users:@@users@@', + '', + 'users:', + ['users'], + 'error for empty substitution', + ], + [ + 'users:@@users(;)@@', + 'user1, user2', + 'users:user1;user2', + [], + 'custom delimiter', + ], + [ + "users:@@users(\n)@@", + 'user1, user2', + "users:user1\nuser2", + [], + 'newline delimiter', + ], + [ + 'users:@@users()@@', + 'user1, user2', + 'users:user1user2', + [], + 'empty delimiter', + ], + [ + 'users:@@users.name@@', + 'user1, user2', + 'users:user1Name, user2Name', + [], + 'names substitution default delitmiter', + ], + [ + 'users:@@users(;).name@@', + 'user1, user2', + 'users:user1Name;user2Name', + [], + 'names substitution custom delitmiter', + ], + [ + 'users:@@users.mail@@', + 'user1, user2', + 'users:user1@example.com, user2@example.com', + [], + 'mail substitution default delitmiter', + ], + [ + "mails:@@users.mail@@\n\nnames:@@users(\n).name@@", + 'user1, user2', + "mails:user1@example.com, user2@example.com\n\nnames:user1Name\nuser2Name", + [], + 'multiple replacements', + ], + [ + 'users:@@*]]@@', // the label must be something to break a regex when not properly quoted + ['label' => '*]]', 'value' => 'user1, user2'], + 'users:user1, user2', + [], + 'ensure label desn\'t break regex', + ], + [ + 'users:@@tHis Is UsEr@@', + ['label' => 'tHis Is UsEr', 'value' => 'user1, user2'], + 'users:user1, user2', + [], + 'label with spaces and mixed case', + ], + ]; } /** - * Simulate a bureaucracy form send with the 'users' field + * @dataProvider dataProvider * - * @param string $template_syntax template to be used as form action - * @param string|array $users value of 'users' field or array('label' => 'own label', 'value' => 'value') - * @param bool $assertValid should we assert the form validity - * @param array &$validation_errors labels of invalid form fields + * @param string $templateSyntax + * @param string|array $users value of 'users' field or array('label' => 'own label', 'value' => 'value') + * @param string $expectedWikiText + * @param string $expectedValidationErrors + * @param string $msg * - * @return string content of newly created page - * @throws \Exception + * @throws \InvalidArgumentException */ - protected function send_form($template_syntax, $users, $assertValid=true, &$validation_errors=array()) { + public function test_field_users( + $templateSyntax, + $users, + $expectedWikiText, + $expectedValidationErrors, + $msg + ) { + $actualValidationErrors = []; + $label = 'users'; if (is_array($users)) { if (!isset($users['value'])) { - throw new \Exception('$users should be string or array("label" => label, "value" => value'); + throw new \InvalidArgumentException('$users should be string or array("label" => label, "value" => value'); + } + if (isset($users['label'])) { + $label = $users['label']; } - if (isset($users['label'])) $label = $users['label']; $users = $users['value']; } - $result = parent::send_form_action_template('users "'.$label.'"', $template_syntax, $validation_errors, $users); - if ($assertValid) { - $this->assertEmpty($validation_errors, 'validation error: fields not valid: '.implode(', ', $validation_errors)); - } - - return $result; + $actualWikiText = parent::send_form_action_template( + 'users "' . $label . '"', + $templateSyntax, + $actualValidationErrors, + $users + ); + + $this->assertEquals($expectedWikiText, $actualWikiText, $msg); + $this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg); } - - public function test_regex_label() { - $label = '*]]'; //somthing to break a regex when not properly quoted - $user = array('label' => $label, 'value' => 'user1, user2'); - $result = $this->send_form("users:@@$label@@", $user); - $this->assertEquals("users:$user[value]", $result); - } - - public function test_mixed_case_and_spaces_label_names_substitution() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - - $label = 'tHis Is UsEr'; - $users = array('user1', 'user2'); - $names = array_map(function($user) use ($auth) { - return $auth->getUserData($user)['name']; - }, $users); - - $users_i = implode(', ', $users); - $names_i = implode(', ', $names); - - $user = array('label' => $label, 'value' => $users_i); - $result = $this->send_form("user:@@$label.name@@", $user); - $this->assertEquals("user:$names_i", $result); - } - - - public function test_action_template_default_substitution() { - $users = 'user1, user2'; - $result = $this->send_form('users:@@users@@', $users); - $this->assertEquals("users:$users", $result); - } - - public function test_action_template_empty_substitution() { - $template_syntax = 'users:@@users@@'; - $validation_errors = array(); - $result = $this->send_form($template_syntax, '', false, $validation_errors); - $this->assertEquals(array('users'), $validation_errors); - } - - public function test_action_template_substitution_custom_delimiter() { - $users = array('user1', 'user2'); - $delimiter = ';'; - - $post_users = implode(', ', $users); - $reuslt_users = implode($delimiter, $users); - - $result = $this->send_form("users:@@users($delimiter)@@", $post_users); - $this->assertEquals("users:$reuslt_users", $result); - } - - public function test_action_template_substitution_new_line_delimiter() { - $users = array('user1', 'user2'); - $delimiter = "\n"; - - $post_users = implode(', ', $users); - $reuslt_users = implode($delimiter, $users); - - $result = $this->send_form("users:@@users($delimiter)@@", $post_users); - $this->assertEquals("users:$reuslt_users", $result); - } - - public function test_action_template_substitution_empty_delimiter() { - $users = array('user1', 'user2'); - $delimiter = ''; - - $post_users = implode(', ', $users); - $reuslt_users = implode($delimiter, $users); - - $result = $this->send_form("users:@@users($delimiter)@@", $post_users); - $this->assertEquals("users:$reuslt_users", $result); - } - - public function test_action_template_names_substitution_default_delitmiter() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $users = array('user1', 'user2'); - $names = array_map(function($user) use ($auth) { - return $auth->getUserData($user)['name']; - }, $users); - - $delimiter = ', '; - $users_i = implode(', ', $users); - $names_i = implode($delimiter, $names); - - $result = $this->send_form('users:@@users.name@@', $users_i); - $this->assertEquals("users:$names_i", $result); - } - - public function test_action_template_names_substitution_custom_delitmiter() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $users = array('user1', 'user2'); - $names = array_map(function($user) use ($auth) { - return $auth->getUserData($user)['name']; - }, $users); - - $delimiter = ';'; - $users_i = implode(', ', $users); - $names_i = implode($delimiter, $names); - - $result = $this->send_form("users:@@users($delimiter).name@@", $users_i); - $this->assertEquals("users:$names_i", $result); - } - - public function test_action_template_mails_substitution_default_delitmiter() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $users = array('user1', 'user2'); - $mails = array_map(function($user) use ($auth) { - return $auth->getUserData($user)['mail']; - }, $users); - - $delimiter = ', '; - $users_i = implode(', ', $users); - $mails_i = implode($delimiter, $mails); - - $result = $this->send_form('users:@@users.mail@@', $users_i); - $this->assertEquals("users:$mails_i", $result); - } - - public function test_action_template_multiple_replacements() { - /** @var DokuWiki_Auth_Plugin $auth */ - global $auth; - $users = array('user1', 'user2'); - $names = array_map(function($user) use ($auth) { - return $auth->getUserData($user)['name']; - }, $users); - $mails = array_map(function($user) use ($auth) { - return $auth->getUserData($user)['mail']; - }, $users); - - $names_delimiter = "\n"; - $mails_delimiter = ', '; - $users_i = implode(', ', $users); - $names_i = implode($names_delimiter, $names); - $mails_i = implode($mails_delimiter, $mails); - - $result = $this->send_form("mails:@@users.mail@@\n\nnames:@@users($names_delimiter).name@@", $users_i); - $this->assertEquals("mails:$mails_i\n\nnames:$names_i", $result); - } - } From 809ebe4418b4a2be5bbe36b99a46b807e89708c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 1 May 2018 16:34:12 +0200 Subject: [PATCH 13/50] refactor: rename test files for better readability --- _test/{fieldfile.test.php => field_file.test.php} | 0 _test/{fielduser.test.php => field_user.test.php} | 0 _test/{fieldusers.test.php => field_users.test.php} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename _test/{fieldfile.test.php => field_file.test.php} (100%) rename _test/{fielduser.test.php => field_user.test.php} (100%) rename _test/{fieldusers.test.php => field_users.test.php} (100%) diff --git a/_test/fieldfile.test.php b/_test/field_file.test.php similarity index 100% rename from _test/fieldfile.test.php rename to _test/field_file.test.php diff --git a/_test/fielduser.test.php b/_test/field_user.test.php similarity index 100% rename from _test/fielduser.test.php rename to _test/field_user.test.php diff --git a/_test/fieldusers.test.php b/_test/field_users.test.php similarity index 100% rename from _test/fieldusers.test.php rename to _test/field_users.test.php From c8abb80c818348c3ab421627a21e3e658dbe5c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 1 May 2018 18:45:10 +0200 Subject: [PATCH 14/50] tests: add test cases to better cover user and users fields --- _test/field_user.test.php | 21 +++++++++++++++++++++ _test/field_users.test.php | 14 ++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/_test/field_user.test.php b/_test/field_user.test.php index ccb9409..dc8e996 100644 --- a/_test/field_user.test.php +++ b/_test/field_user.test.php @@ -122,6 +122,27 @@ public function dataProvider() [], 'groups special glue', ], + [ + 'grps:@@user.grps()@@', + 'mwuser', + 'grps:group1group2', + [], + 'groups with empty delimiter', + ], + [ + 'user:@@user@@', + 'non_existant_user', + 'user:non_existant_user', + ['user'], + 'error for non existant user', + ], + [ + 'user:@@user.name@@', + 'non_existant_user', + 'user:@@user.name@@', + ['user'], + 'error for non existant user with attribute', + ], ]; } diff --git a/_test/field_users.test.php b/_test/field_users.test.php index d5842b7..44a7bbb 100644 --- a/_test/field_users.test.php +++ b/_test/field_users.test.php @@ -90,6 +90,20 @@ public function dataProvider() [], 'multiple replacements', ], + [ + 'users:@@users@@', + 'not_existing1, not_existing2', + 'users:not_existing1, not_existing2', + ['users'], + 'unknown users should cause errors', + ], + [ + 'users:@@users.unknown_attribute@@', + 'user1, user2', + 'users:@@users.unknown_attribute@@', + [], + 'non existant attribute is not replaced', + ], [ 'users:@@*]]@@', // the label must be something to break a regex when not properly quoted ['label' => '*]]', 'value' => 'user1, user2'], From 7b3bab9462a22bcd83e10a389edd1a8d1fc1e432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 1 May 2018 19:43:26 +0200 Subject: [PATCH 15/50] tests: add tests for yesno checkbox field These tests are currently failing, but should pass when #234 is merged. --- _test/field_yesno.test.php | 70 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 _test/field_yesno.test.php diff --git a/_test/field_yesno.test.php b/_test/field_yesno.test.php new file mode 100644 index 0000000..26bd785 --- /dev/null +++ b/_test/field_yesno.test.php @@ -0,0 +1,70 @@ +assertEquals($expectedWikiText, $actualWikiText, $msg); + $this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg); + } +} \ No newline at end of file From 126858b192ac808827b532f9a8407b897fdbfae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 8 May 2018 17:08:20 +0200 Subject: [PATCH 16/50] chore: test on PHP 7.2 and send coverage to scrutinizer --- .scrutinizer.yml | 2 ++ .travis.yml | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .scrutinizer.yml diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..d73cd74 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,2 @@ +tools: + external_code_coverage: true diff --git a/.travis.yml b/.travis.yml index bc6f741..ad7e672 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,13 @@ language: php php: + - "7.2" - "7.1" - "7.0" - "5.6" before_install: wget https://raw.github.com/splitbrain/dokuwiki-travis/master/travis.sh install: sh travis.sh -script: cd _test && phpunit --stderr --group plugin_bureaucracy +script: + - cd _test + - phpunit --stderr --group plugin_bureaucracy --coverage-clover=coverage.clover + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover coverage.clover --repository=g/$TRAVIS_REPO_SLUG --revision=$TRAVIS_COMMIT From 92b9f1f002e78fe348eaf2dce81bbc41673ef45a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 8 May 2018 20:22:24 +0200 Subject: [PATCH 17/50] tests: run tests with custom config and push coverage to scrutinizer --- .travis.yml | 2 +- _test/general.test.php | 61 ++++++++++++++++++++++++++++++++++++++++++ phpunit.xml | 32 ++++++++++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 _test/general.test.php create mode 100644 phpunit.xml diff --git a/.travis.yml b/.travis.yml index ad7e672..2a87475 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,6 @@ before_install: wget https://raw.github.com/splitbrain/dokuwiki-travis/master/tr install: sh travis.sh script: - cd _test - - phpunit --stderr --group plugin_bureaucracy --coverage-clover=coverage.clover + - phpunit --configuration=../lib/plugins/bureaucracy/phpunit.xml --group plugin_bureaucracy --coverage-clover=coverage.clover - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover coverage.clover --repository=g/$TRAVIS_REPO_SLUG --revision=$TRAVIS_COMMIT diff --git a/_test/general.test.php b/_test/general.test.php new file mode 100644 index 0000000..0b3e0cf --- /dev/null +++ b/_test/general.test.php @@ -0,0 +1,61 @@ +assertFileExists($file); + + $info = confToHash($file); + + $this->assertArrayHasKey('base', $info); + $this->assertArrayHasKey('author', $info); + $this->assertArrayHasKey('email', $info); + $this->assertArrayHasKey('date', $info); + $this->assertArrayHasKey('name', $info); + $this->assertArrayHasKey('desc', $info); + $this->assertArrayHasKey('url', $info); + + $this->assertEquals('bureaucracy', $info['base']); + $this->assertRegExp('/^https?:\/\//', $info['url']); + $this->assertTrue(mail_isvalid($info['email'])); + $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); + $this->assertTrue(false !== strtotime($info['date'])); + } + + /** + * Test to ensure that every conf['...'] entry in conf/default.php has a corresponding meta['...'] entry in + * conf/metadata.php. + */ + public function test_plugin_conf() { + $conf_file = __DIR__.'/../conf/default.php'; + if (file_exists($conf_file)){ + include($conf_file); + } + $meta_file = __DIR__.'/../conf/metadata.php'; + if (file_exists($meta_file)) { + include($meta_file); + } + + $this->assertEquals(gettype($conf), gettype($meta),'Both ' . DOKU_PLUGIN . 'bureaucracy/conf/default.php and ' . DOKU_PLUGIN . 'bureaucracy/conf/metadata.php have to exist and contain the same keys.'); + + if (gettype($conf) != 'NULL' && gettype($meta) != 'NULL') { + foreach($conf as $key => $value) { + $this->assertArrayHasKey($key, $meta, 'Key $meta[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'bureaucracy/conf/metadata.php'); + } + + foreach($meta as $key => $value) { + $this->assertArrayHasKey($key, $conf, 'Key $conf[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'bureaucracy/conf/default.php'); + } + } + + } +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..b6873af --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,32 @@ + + + + + + ./_test + + + + + + flaky + + + + + + . + + ./lang/ + ./_test/ + + + + + From ae0a98398a555aa259487d598181ddaa314a9d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 15 May 2018 09:22:57 +0200 Subject: [PATCH 18/50] =?UTF-8?q?test:=20=F0=9F=94=A8=20Stylistic=20adjusm?= =?UTF-8?q?ents,=20type=20hints,=20specifying=20minor=20default=20params?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _test/BureaucracyTest.php | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/_test/BureaucracyTest.php b/_test/BureaucracyTest.php index 766d121..53322c6 100644 --- a/_test/BureaucracyTest.php +++ b/_test/BureaucracyTest.php @@ -1,44 +1,55 @@ \naction template $template_id $id\n$form_syntax\n"; saveWikiText($template_id, $template_syntax, 'summary'); + /** @var \syntax_plugin_bureaucracy $syntax_plugin */ $syntax_plugin = plugin_load('syntax', 'bureaucracy'); $data = $syntax_plugin->handle($form_syntax, 0, 0, new \Doku_Handler()); $actionData = $data['actions'][0]; + /** @var \helper_plugin_bureaucracy_action $action */ $action = plugin_load('helper', $actionData['actionname']); //this is the only form $form_id = 0; for ($i = 0; $i < count($data['fields']); ++$i) { //set null for not existing values - if (!isset($values[$i])) $values[$i] = null; + if (!isset($values[$i])) { + $values[$i] = null; + } + /** @var \helper_plugin_bureaucracy_field $field */ $field = $data['fields'][$i]; $isValid = $field->handle_post($values[$i], $data['fields'], $i, $form_id); if (!$isValid) { From 2f5beeec46f717af8caf5c4facd955bc47a6472e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 15 May 2018 09:47:07 +0200 Subject: [PATCH 19/50] test: use foreach loop if handling every element of an array --- _test/BureaucracyTest.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/_test/BureaucracyTest.php b/_test/BureaucracyTest.php index 53322c6..6bc67b2 100644 --- a/_test/BureaucracyTest.php +++ b/_test/BureaucracyTest.php @@ -43,14 +43,12 @@ protected function send_form_action_template($form_syntax, $template_syntax, &$v //this is the only form $form_id = 0; - for ($i = 0; $i < count($data['fields']); ++$i) { - //set null for not existing values + /** @var \helper_plugin_bureaucracy_field $field */ + foreach ($data['fields'] as $i => $field) { if (!isset($values[$i])) { $values[$i] = null; } - /** @var \helper_plugin_bureaucracy_field $field */ - $field = $data['fields'][$i]; $isValid = $field->handle_post($values[$i], $data['fields'], $i, $form_id); if (!$isValid) { $validation_errors[] = $field->getParam('label'); From 2014d3542ea3c9727df5b4617f5ad962f12e2fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 15 May 2018 10:07:13 +0200 Subject: [PATCH 20/50] test: Add tests for radio field --- _test/BureaucracyTest.php | 6 ++++ _test/field_radio.test.php | 74 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 _test/field_radio.test.php diff --git a/_test/BureaucracyTest.php b/_test/BureaucracyTest.php index 6bc67b2..90373d8 100644 --- a/_test/BureaucracyTest.php +++ b/_test/BureaucracyTest.php @@ -5,6 +5,12 @@ class BureaucracyTest extends \DokuWikiTest { + + const FORM_PREFIX_HTML = '
+
'; + const FORM_SUFFIX_HTML = '
+
'; + protected $pluginsEnabled = ['bureaucracy']; /** diff --git a/_test/field_radio.test.php b/_test/field_radio.test.php new file mode 100644 index 0000000..34839f6 --- /dev/null +++ b/_test/field_radio.test.php @@ -0,0 +1,74 @@ +assertEquals($expectedWikiText, $actualWikiText, $msg); + $this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg); + } + + public function test_field_date_render() + { + $formSyntax = 'radio "radioLabel" "Peaches|Apples|Oranges"'; + $instr = p_get_instructions("
\n$formSyntax\n
"); + + $actualHTML = p_render('xhtml', $instr, $info); + + $expectedFieldHTML = ' + +'; + $expectedHTML = self::FORM_PREFIX_HTML . "\n$expectedFieldHTML\n" . self::FORM_SUFFIX_HTML; + $this->assertEquals(trim($expectedHTML), trim($actualHTML)); + } +} From b4bc2c400e7331cd3a98c1b8358a09067e9b95f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 15 May 2018 10:30:19 +0200 Subject: [PATCH 21/50] test: Add tests for the date field --- _test/field_date.test.php | 80 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 _test/field_date.test.php diff --git a/_test/field_date.test.php b/_test/field_date.test.php new file mode 100644 index 0000000..ff51566 --- /dev/null +++ b/_test/field_date.test.php @@ -0,0 +1,80 @@ +assertEquals($expectedWikiText, $actualWikiText, $msg); + } + $this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg); + } + + public function test_field_date_render() + { + $formSyntax = 'date "dateLabel"'; + $instr = p_get_instructions("
\n$formSyntax\n
"); + + $actualHTML = p_render('xhtml', $instr, $info); + + $expectedFieldHTML = ''; + $expectedHTML = self::FORM_PREFIX_HTML . "\n$expectedFieldHTML\n" . self::FORM_SUFFIX_HTML; + $this->assertEquals(trim($expectedHTML), trim($actualHTML)); + } +} From f9e3f8b4730e70923bed0580661cd2260ce97a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 15 May 2018 10:37:19 +0200 Subject: [PATCH 22/50] test: Add tests for the time field --- _test/field_time.test.php | 86 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 _test/field_time.test.php diff --git a/_test/field_time.test.php b/_test/field_time.test.php new file mode 100644 index 0000000..b027d8c --- /dev/null +++ b/_test/field_time.test.php @@ -0,0 +1,86 @@ +assertEquals($expectedWikiText, $actualWikiText, $msg); + } + $this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg); + } + + public function test_field_time_render() + { + $formSyntax = 'time "timeLabel"'; + $instr = p_get_instructions("
\n$formSyntax\n
"); + + $actualHTML = p_render('xhtml', $instr, $info); + + $expectedFieldHTML = ''; + $expectedHTML = self::FORM_PREFIX_HTML . "\n$expectedFieldHTML\n" . self::FORM_SUFFIX_HTML; + $this->assertEquals(trim($expectedHTML), trim($actualHTML)); + } +} From e0122e76fcf43ae1163c3777ae080f6a64032c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 15 May 2018 11:11:29 +0200 Subject: [PATCH 23/50] test: Add tests for the email field --- _test/field_email.test.php | 92 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 _test/field_email.test.php diff --git a/_test/field_email.test.php b/_test/field_email.test.php new file mode 100644 index 0000000..c3c522a --- /dev/null +++ b/_test/field_email.test.php @@ -0,0 +1,92 @@ +assertEquals($expectedWikiText, $actualWikiText, $msg); + } + $this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg); + } + + public function test_field_email_render() + { + $formSyntax = 'email emailLabel'; + $instr = p_get_instructions("
\n$formSyntax\n
"); + + $actualHTML = p_render('xhtml', $instr, $info); + + $expectedFieldHTML = ''; + $expectedHTML = self::FORM_PREFIX_HTML . "\n$expectedFieldHTML\n" . self::FORM_SUFFIX_HTML; + $this->assertEquals(trim($expectedHTML), trim($actualHTML)); + } +} From eb0eb5d6f722885c6f1ed4d3f634b006226364c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 15 May 2018 13:44:43 +0200 Subject: [PATCH 24/50] test: Add tests for the hidden field --- _test/field_hidden.test.php | 77 +++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 _test/field_hidden.test.php diff --git a/_test/field_hidden.test.php b/_test/field_hidden.test.php new file mode 100644 index 0000000..386b28b --- /dev/null +++ b/_test/field_hidden.test.php @@ -0,0 +1,77 @@ +assertEquals($expectedWikiText, $actualWikiText, $msg); + } + $this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg); + } + + public function test_field_time_render() + { + $formSyntax = 'hidden hiddenLabel "=default value of the hidden field"'; + $instr = p_get_instructions("
\n$formSyntax\n
"); + + $actualHTML = p_render('xhtml', $instr, $info); + + $hiddenFormPrefix = '
+'; + $expectedFieldHTML = ''; + $hiddenFormSuffix = '
'; + $expectedHTML = "$hiddenFormPrefix$expectedFieldHTML$hiddenFormSuffix"; + + $this->assertEquals(trim($expectedHTML), trim($actualHTML)); + } +} From 973887b2adbf7d51120272e02fd3c0141e00b703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 15 May 2018 13:53:44 +0200 Subject: [PATCH 25/50] test: Add tests for custom date format --- _test/field_date.test.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/_test/field_date.test.php b/_test/field_date.test.php index ff51566..fb9dd3e 100644 --- a/_test/field_date.test.php +++ b/_test/field_date.test.php @@ -30,6 +30,22 @@ public function dataProvider() ['dateLabel'], 'invalid date', ], + [ + 'Date: @DATE(@@dateLabel@@)@', + 'date "dateLabel"', + '2018-02-15', + 'Date: 2018/02/15 00:00', + [], + 'formatted date with $conf[\'dformat\'] format', + ], + [ + 'Month: @DATE(@@dateLabel@@,%%m)@', + 'date "dateLabel"', + '2018-02-15', + 'Month: 02', + [], + 'formatted date with custom format', + ], ]; } From 15bdef96099f861b31f733384aa0b8e1122bb966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Thu, 17 May 2018 17:24:16 +0200 Subject: [PATCH 26/50] test: Refactor user and users field tests to make them similar to the others --- _test/field_user.test.php | 48 ++++++++++++++++++++++---------------- _test/field_users.test.php | 46 +++++++++++++++++++----------------- 2 files changed, 53 insertions(+), 41 deletions(-) diff --git a/_test/field_user.test.php b/_test/field_user.test.php index dc8e996..5012c1d 100644 --- a/_test/field_user.test.php +++ b/_test/field_user.test.php @@ -26,6 +26,7 @@ public function dataProvider() return [ [ 'user:@@user@@', + 'user user', 'mwuser', 'user:mwuser', [], @@ -33,6 +34,7 @@ public function dataProvider() ], [ 'user:@@user@@', + 'user user', '', 'user:', ['user'], @@ -40,6 +42,7 @@ public function dataProvider() ], [ 'user:@@user.name@@', + 'user user', 'mwuser', 'user:Wiki User', [], @@ -47,6 +50,7 @@ public function dataProvider() ], [ 'user:@@user.mail@@', + 'user user', 'mwuser', 'user:wikiuser@example.com', [], @@ -54,6 +58,7 @@ public function dataProvider() ], [ 'user:@@user.grps@@', + 'user user', 'mwuser', 'user:group1, group2', [], @@ -61,6 +66,7 @@ public function dataProvider() ], [ 'user:@@user.grps(;)@@', + 'user user', 'mwuser', 'user:group1;group2', [], @@ -68,6 +74,7 @@ public function dataProvider() ], [ 'user:@@user.grps())@@', + 'user user', 'mwuser', 'user:group1)group2', [], @@ -75,6 +82,7 @@ public function dataProvider() ], [ 'user:@@user.no_sutch_attribute@@', + 'user user', 'mwuser', 'user:@@user.no_sutch_attribute@@', [], @@ -82,6 +90,7 @@ public function dataProvider() ], [ 'user:##user##', + 'user user', 'mwuser', 'user:mwuser', [], @@ -89,6 +98,7 @@ public function dataProvider() ], [ 'user:##user.mail##', + 'user user', 'mwuser', 'user:wikiuser@example.com', [], @@ -96,6 +106,7 @@ public function dataProvider() ], [ 'user:##user@@', + 'user user', 'mwuser', 'user:##user@@', [], @@ -103,6 +114,7 @@ public function dataProvider() ], [ "user:@@user@@\n\nmail:@@user.mail@@\n\ngrps:@@user.grps(\n)@@", + 'user user', 'mwuser', "user:mwuser\n\nmail:wikiuser@example.com\n\ngrps:group1\ngroup2", [], @@ -110,6 +122,7 @@ public function dataProvider() ], [ "grps1:@@user.grps(\n)@@\n\ngrps2:@@user.grps(())@@", + 'user user', 'mwuser', "grps1:group1\ngroup2\n\ngrps2:group1()group2", [], @@ -117,6 +130,7 @@ public function dataProvider() ], [ 'grps:@@user.grps(end))@@', + 'user user', 'mwuser', 'grps:group1end)group2', [], @@ -124,6 +138,7 @@ public function dataProvider() ], [ 'grps:@@user.grps()@@', + 'user user', 'mwuser', 'grps:group1group2', [], @@ -131,6 +146,7 @@ public function dataProvider() ], [ 'user:@@user@@', + 'user user', 'non_existant_user', 'user:non_existant_user', ['user'], @@ -138,6 +154,7 @@ public function dataProvider() ], [ 'user:@@user.name@@', + 'user user', 'non_existant_user', 'user:@@user.name@@', ['user'], @@ -150,41 +167,32 @@ public function dataProvider() /** * @dataProvider dataProvider * - * @param string $templateSyntax - * @param string|array $users value of 'users' field or array('label' => 'own label', 'value' => 'value') - * @param string $expectedWikiText - * @param string $expectedValidationErrors - * @param string $msg + * @param string $templateSyntax + * @param string $formSyntax + * @param string $postedValue value of 'user' field + * @param string $expectedWikiText + * @param string $expectedValidationErrors + * @param string $msg * - * @throws \InvalidArgumentException */ public function test_field_user( $templateSyntax, - $users, + $formSyntax, + $postedValue, $expectedWikiText, $expectedValidationErrors, $msg ) { $actualValidationErrors = []; - $label = 'user'; - if (is_array($users)) { - if (!isset($users['value'])) { - throw new \InvalidArgumentException('$users should be string or array("label" => label, "value" => value'); - } - if (isset($users['label'])) { - $label = $users['label']; - } - $users = $users['value']; - } $actualWikiText = parent::send_form_action_template( - 'user "' . $label . '"', + $formSyntax, $templateSyntax, $actualValidationErrors, - $users + $postedValue ); - $this->assertEquals($expectedWikiText, $actualWikiText, $msg); $this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg); + $this->assertEquals($expectedWikiText, $actualWikiText, $msg); } } diff --git a/_test/field_users.test.php b/_test/field_users.test.php index 44a7bbb..d162357 100644 --- a/_test/field_users.test.php +++ b/_test/field_users.test.php @@ -29,6 +29,7 @@ public function dataProvider() return [ [ 'users:@@users@@', + 'users users', 'user1, user2', 'users:user1, user2', [], @@ -36,6 +37,7 @@ public function dataProvider() ], [ 'users:@@users@@', + 'users users', '', 'users:', ['users'], @@ -43,6 +45,7 @@ public function dataProvider() ], [ 'users:@@users(;)@@', + 'users users', 'user1, user2', 'users:user1;user2', [], @@ -50,6 +53,7 @@ public function dataProvider() ], [ "users:@@users(\n)@@", + 'users users', 'user1, user2', "users:user1\nuser2", [], @@ -57,6 +61,7 @@ public function dataProvider() ], [ 'users:@@users()@@', + 'users users', 'user1, user2', 'users:user1user2', [], @@ -64,6 +69,7 @@ public function dataProvider() ], [ 'users:@@users.name@@', + 'users users', 'user1, user2', 'users:user1Name, user2Name', [], @@ -71,6 +77,7 @@ public function dataProvider() ], [ 'users:@@users(;).name@@', + 'users users', 'user1, user2', 'users:user1Name;user2Name', [], @@ -78,6 +85,7 @@ public function dataProvider() ], [ 'users:@@users.mail@@', + 'users users', 'user1, user2', 'users:user1@example.com, user2@example.com', [], @@ -85,6 +93,7 @@ public function dataProvider() ], [ "mails:@@users.mail@@\n\nnames:@@users(\n).name@@", + 'users users', 'user1, user2', "mails:user1@example.com, user2@example.com\n\nnames:user1Name\nuser2Name", [], @@ -92,6 +101,7 @@ public function dataProvider() ], [ 'users:@@users@@', + 'users users', 'not_existing1, not_existing2', 'users:not_existing1, not_existing2', ['users'], @@ -99,6 +109,7 @@ public function dataProvider() ], [ 'users:@@users.unknown_attribute@@', + 'users users', 'user1, user2', 'users:@@users.unknown_attribute@@', [], @@ -106,14 +117,16 @@ public function dataProvider() ], [ 'users:@@*]]@@', // the label must be something to break a regex when not properly quoted - ['label' => '*]]', 'value' => 'user1, user2'], + 'users "*]]"', + 'user1, user2', 'users:user1, user2', [], 'ensure label desn\'t break regex', ], [ 'users:@@tHis Is UsEr@@', - ['label' => 'tHis Is UsEr', 'value' => 'user1, user2'], + 'users "tHis Is UsEr"', + 'user1, user2', 'users:user1, user2', [], 'label with spaces and mixed case', @@ -124,38 +137,29 @@ public function dataProvider() /** * @dataProvider dataProvider * - * @param string $templateSyntax - * @param string|array $users value of 'users' field or array('label' => 'own label', 'value' => 'value') - * @param string $expectedWikiText - * @param string $expectedValidationErrors - * @param string $msg + * @param string $templateSyntax + * @param string $formSyntax + * @param string $postedValue value of 'users' field + * @param string $expectedWikiText + * @param string $expectedValidationErrors + * @param string $msg * - * @throws \InvalidArgumentException */ public function test_field_users( $templateSyntax, - $users, + $formSyntax, + $postedValue, $expectedWikiText, $expectedValidationErrors, $msg ) { $actualValidationErrors = []; - $label = 'users'; - if (is_array($users)) { - if (!isset($users['value'])) { - throw new \InvalidArgumentException('$users should be string or array("label" => label, "value" => value'); - } - if (isset($users['label'])) { - $label = $users['label']; - } - $users = $users['value']; - } $actualWikiText = parent::send_form_action_template( - 'users "' . $label . '"', + $formSyntax, $templateSyntax, $actualValidationErrors, - $users + $postedValue ); $this->assertEquals($expectedWikiText, $actualWikiText, $msg); From 7e43563755bc5b391965e7d3029d9499f92191aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Thu, 17 May 2018 17:25:36 +0200 Subject: [PATCH 27/50] =?UTF-8?q?style(tests):=20Minor=20style=20adjustmen?= =?UTF-8?q?ts=20for=20user=20and=20users=20fields=20tests=20=F0=9F=8E=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _test/field_user.test.php | 9 ++++++--- _test/field_users.test.php | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/_test/field_user.test.php b/_test/field_user.test.php index 5012c1d..8e739c3 100644 --- a/_test/field_user.test.php +++ b/_test/field_user.test.php @@ -1,16 +1,19 @@ createUser("user1", "54321", "user1Name", "user1@example.com"); $auth->createUser("user2", "543210", "user2Name", "user2@example.com"); - $auth->createUser("mwuser", "12345", "Wiki User", "wikiuser@example.com", array('group1', 'group2')); + $auth->createUser("mwuser", "12345", "Wiki User", "wikiuser@example.com", ['group1', 'group2']); } public function dataProvider() diff --git a/_test/field_users.test.php b/_test/field_users.test.php index d162357..20e9133 100644 --- a/_test/field_users.test.php +++ b/_test/field_users.test.php @@ -21,7 +21,7 @@ public function setUp() $auth->createUser('user1', '54321', 'user1Name', 'user1@example.com'); $auth->createUser('user2', '543210', 'user2Name', 'user2@example.com'); - $auth->createUser('mwuser', '12345', 'Wiki User', 'me@example.com', array('group1', 'group2')); + $auth->createUser('mwuser', '12345', 'Wiki User', 'me@example.com', ['group1', 'group2']); } public function dataProvider() From c07c9deb93610e86fe235581c06bf2957d069020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Thu, 17 May 2018 17:28:08 +0200 Subject: [PATCH 28/50] =?UTF-8?q?fix(user=20field):=20An=20empty=20field?= =?UTF-8?q?=20should=20remove=20template=20placeholder=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds another test to ensure that a user field submitted with an empty string results in the expected behavior, which is to replace the placeholder with an empty string. --- _test/field_user.test.php | 8 ++++++++ helper/fielduser.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/_test/field_user.test.php b/_test/field_user.test.php index 8e739c3..e4ff488 100644 --- a/_test/field_user.test.php +++ b/_test/field_user.test.php @@ -43,6 +43,14 @@ public function dataProvider() ['user'], 'error for empty substitution', ], + [ + 'user:@@user@@', + 'user user !', + '', + 'user:', + [], + 'ok for empty substitution in optional field', + ], [ 'user:@@user.name@@', 'user user', diff --git a/helper/fielduser.php b/helper/fielduser.php index 866c071..49608e1 100644 --- a/helper/fielduser.php +++ b/helper/fielduser.php @@ -47,7 +47,7 @@ public function replacementValueCallback($matches) { $value = $this->opt['value']; //attr doesn't exists if (!isset($matches[2])) { - return is_null($value) || $value === false ? $matches[0] : $value; + return is_null($value) || $value === false ? '' : $value; } $attr = $matches[2]; From 214300f25bcca07131b0e1fadacc0d52382438ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Thu, 17 May 2018 17:31:52 +0200 Subject: [PATCH 29/50] =?UTF-8?q?docs(tests):=20adjust=20phpdoc=20block=20?= =?UTF-8?q?to=20match=20signature=20=F0=9F=92=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _test/field_date.test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_test/field_date.test.php b/_test/field_date.test.php index fb9dd3e..3164630 100644 --- a/_test/field_date.test.php +++ b/_test/field_date.test.php @@ -53,7 +53,8 @@ public function dataProvider() * @dataProvider dataProvider * * @param string $templateSyntax - * @param $postedValue + * @param string $formSyntax + * @param string $postedValue * @param string $expectedWikiText * @param string $expectedValidationErrors * @param string $msg From 54503b18cca9ebfbe9d68553a0c32d01bb289f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Thu, 17 May 2018 17:42:55 +0200 Subject: [PATCH 30/50] =?UTF-8?q?ci:=20Remove=20scrutinizer=20coverage=20a?= =?UTF-8?q?gain=20-=20this=20needs=20more=20work=20=F0=9F=92=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While code coverage via scrutinizer works well in principle, it is currently still clunky. Also, it is currently not activated for splitbrain/dokuwiki-plugin-bureaucracy and thus causes the ci check to fail. --- .scrutinizer.yml | 2 -- .travis.yml | 4 +--- phpunit.xml | 32 -------------------------------- 3 files changed, 1 insertion(+), 37 deletions(-) delete mode 100644 .scrutinizer.yml delete mode 100644 phpunit.xml diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index d73cd74..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,2 +0,0 @@ -tools: - external_code_coverage: true diff --git a/.travis.yml b/.travis.yml index 2a87475..3ee2bb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,4 @@ before_install: wget https://raw.github.com/splitbrain/dokuwiki-travis/master/tr install: sh travis.sh script: - cd _test - - phpunit --configuration=../lib/plugins/bureaucracy/phpunit.xml --group plugin_bureaucracy --coverage-clover=coverage.clover - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover coverage.clover --repository=g/$TRAVIS_REPO_SLUG --revision=$TRAVIS_COMMIT + - phpunit --group plugin_bureaucracy diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index b6873af..0000000 --- a/phpunit.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - ./_test - - - - - - flaky - - - - - - . - - ./lang/ - ./_test/ - - - - - From 4c8cd48880e4fb15a7ea085f885847eb7a750cb0 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 17 May 2018 23:50:11 +0200 Subject: [PATCH 31/50] Version upped --- plugin.info.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.info.txt b/plugin.info.txt index 90c4ecd..ac8b8e8 100644 --- a/plugin.info.txt +++ b/plugin.info.txt @@ -1,7 +1,7 @@ base bureaucracy author Andreas Gohr email andi@splitbrain.org -date 2018-03-28 +date 2018-05-17 name Bureaucracy Plugin desc Create forms and generate pages or emails from them url https://www.dokuwiki.org/plugin:bureaucracy From 8fb29ac4b8a5d09aa5885a214f90d9f46002876a Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Fri, 13 Oct 2017 15:24:46 +0000 Subject: [PATCH 32/50] Remove extra

in thanks message Because of the way consecutive

tags are rendered, wrapping each $thanks string in such tags causes unnecessary additional blank lines to be displayed before the message. For example, given a message `Page created`: - helper_plugin_bureaucracy_actiontemplate::buildThankYouPage() returns `

Page created

    `; - then syntax_plugin_bureaucracy::_handlepost() adds an extra

    wrapping, so we get `

    Page created

      ` - The browser renders this as `

      Page created

        ` so we get extra whitespace before and after the thanks message --- syntax.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/syntax.php b/syntax.php index 59c17b9..c61f431 100644 --- a/syntax.php +++ b/syntax.php @@ -356,10 +356,7 @@ private function _handlepost($data) { } // create thanks string - $thanks = ''; - foreach(array_unique($thanks_array) as $thanks_string) { - $thanks .= '

        ' . $thanks_string . '

        '; - } + $thanks = implode('', array_unique($thanks_array)); return $thanks; } From 04a7a0329169e9fe796739ecf8ac4f3589bde93c Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Fri, 13 Oct 2017 11:02:05 +0000 Subject: [PATCH 33/50] Remove '-' from scriptNamePattern valid chars Since '-' is not a valid char for PHP keywords, it cannot be used in the script handler file name, as we would get an error when submitting the form (either because the class was not found, or because of a syntax error in the script). --- helper/actionscript.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper/actionscript.php b/helper/actionscript.php index 277306f..a955b55 100644 --- a/helper/actionscript.php +++ b/helper/actionscript.php @@ -2,7 +2,7 @@ class helper_plugin_bureaucracy_actionscript extends helper_plugin_bureaucracy_action { - protected $scriptNamePattern = '/^[-_a-zA-Z0-9]+\.php$/'; + protected $scriptNamePattern = '/^[_a-zA-Z0-9]+\.php$/'; /** * @inheritDoc From 075ea528aca94f99f23bedcff6522d7ce57b60fc Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Fri, 13 Oct 2017 09:56:12 +0000 Subject: [PATCH 34/50] Change actionscript handler class prefix The class name prefix is now 'helper_plugin_bureaucracy_', so that handlers can use the Bureaucracy plugin's language strings. Fixes #219 --- helper/actionscript.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper/actionscript.php b/helper/actionscript.php index 277306f..b860c3d 100644 --- a/helper/actionscript.php +++ b/helper/actionscript.php @@ -30,7 +30,7 @@ public function run($fields, $thanks, $argv) { require $path; $classFragment = substr($scriptName, 0, strpos($scriptName, '.')); - $className = 'bureaucracy_handler_' . $classFragment; + $className = 'helper_plugin_bureaucracy_handler_' . $classFragment; /** @var dokuwiki\plugin\bureaucracy\interfaces\bureaucracy_handler_interface $handler */ $handler = new $className; From be68ab873bc322c1510b1aa32a9b7e6ace511a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Sat, 7 Jul 2018 00:27:57 +0200 Subject: [PATCH 35/50] =?UTF-8?q?=E2=9C=85=20Add=20tests=20for=20multisele?= =?UTF-8?q?ct=20field?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _test/BureaucracyTest.php | 3 -- _test/field_multiselect.test.php | 81 ++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 _test/field_multiselect.test.php diff --git a/_test/BureaucracyTest.php b/_test/BureaucracyTest.php index 90373d8..5a381e6 100644 --- a/_test/BureaucracyTest.php +++ b/_test/BureaucracyTest.php @@ -25,9 +25,6 @@ class BureaucracyTest extends \DokuWikiTest */ protected function send_form_action_template($form_syntax, $template_syntax, &$validation_errors, ...$values) { - if (is_array($values[0])) { - $values = $values[0]; - } $id = uniqid('page', true); $template_id = uniqid('template', true); diff --git a/_test/field_multiselect.test.php b/_test/field_multiselect.test.php new file mode 100644 index 0000000..9445dc2 --- /dev/null +++ b/_test/field_multiselect.test.php @@ -0,0 +1,81 @@ +assertEquals($expectedWikiText, $actualWikiText, $msg); + $this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg); + } + + public function test_field_multiselect_render() + { + $formSyntax = 'multiselect "multiSelectLabel" "Peaches|Apples|Oranges" =Peaches,Oranges'; + $instr = p_get_instructions("
        \n$formSyntax\n
        "); + + $actualHTML = p_render('xhtml', $instr, $info); + + $expectedFieldHTML = ''; + $expectedHTML = self::FORM_PREFIX_HTML . "\n$expectedFieldHTML\n" . self::FORM_SUFFIX_HTML; + $this->assertEquals(trim($expectedHTML), trim($actualHTML)); + } +} From 704f945dda62f48edf1c9337ad8815a549e3cb9f Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 7 Jul 2018 23:50:11 +0200 Subject: [PATCH 36/50] Version upped --- plugin.info.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.info.txt b/plugin.info.txt index ac8b8e8..24b5989 100644 --- a/plugin.info.txt +++ b/plugin.info.txt @@ -1,7 +1,7 @@ base bureaucracy author Andreas Gohr email andi@splitbrain.org -date 2018-05-17 +date 2018-07-06 name Bureaucracy Plugin desc Create forms and generate pages or emails from them url https://www.dokuwiki.org/plugin:bureaucracy From 5d3f7ae92921d8f8fff9f90022663f0a651af640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Tue, 14 Aug 2018 11:37:17 +0200 Subject: [PATCH 37/50] Make changes backwards compatible This should give people that are currently using this functionality time to update their code. --- helper/actionscript.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/helper/actionscript.php b/helper/actionscript.php index b860c3d..bb26f71 100644 --- a/helper/actionscript.php +++ b/helper/actionscript.php @@ -32,6 +32,13 @@ public function run($fields, $thanks, $argv) { $classFragment = substr($scriptName, 0, strpos($scriptName, '.')); $className = 'helper_plugin_bureaucracy_handler_' . $classFragment; + $deprecatedClassName = 'bureaucracy_handler_' . $classFragment; + if (!class_exists($className) && class_exists($deprecatedClassName)) { + msg("Please change this script's class-name to $className. +Your current scheme $deprecatedClassName is deprecated and will stop working in the future.", 2); + $className = $deprecatedClassName; + } + /** @var dokuwiki\plugin\bureaucracy\interfaces\bureaucracy_handler_interface $handler */ $handler = new $className; From bbb7cad0d1b9f50f5ee5d68e993128fd9a7a2739 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 14 Aug 2018 23:50:11 +0200 Subject: [PATCH 38/50] Version upped --- plugin.info.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.info.txt b/plugin.info.txt index 24b5989..5c6c891 100644 --- a/plugin.info.txt +++ b/plugin.info.txt @@ -1,7 +1,7 @@ base bureaucracy author Andreas Gohr email andi@splitbrain.org -date 2018-07-06 +date 2018-08-14 name Bureaucracy Plugin desc Create forms and generate pages or emails from them url https://www.dokuwiki.org/plugin:bureaucracy From 6bd81c8ddfb6d4967d71cf1abdc100ea84192ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Thu, 16 Aug 2018 09:12:15 +0200 Subject: [PATCH 39/50] Ensure there is still a

        around thanks messages 8fb29ac4b8a5d09aa5885a214f90d9f46002876a correctly removed the wrapping

        in syntax.php, as these produced invalid HTML for the template action. However that measure left the thanks message from the mail action without

        tags. This commit fixes that. --- helper/actionmail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper/actionmail.php b/helper/actionmail.php index dc32b76..9d106b6 100644 --- a/helper/actionmail.php +++ b/helper/actionmail.php @@ -79,7 +79,7 @@ public function run($fields, $thanks, $argv) { if(!$mail->send()) { throw new Exception($this->getLang('e_mail')); } - return $thanks; + return '

        ' . $thanks . '

        '; } /** From 8ac056fc75e891fe95dc6d9c952357ede87f58da Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 16 Aug 2018 23:50:12 +0200 Subject: [PATCH 40/50] Version upped --- plugin.info.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.info.txt b/plugin.info.txt index 5c6c891..fa926ba 100644 --- a/plugin.info.txt +++ b/plugin.info.txt @@ -1,7 +1,7 @@ base bureaucracy author Andreas Gohr email andi@splitbrain.org -date 2018-08-14 +date 2018-08-16 name Bureaucracy Plugin desc Create forms and generate pages or emails from them url https://www.dokuwiki.org/plugin:bureaucracy From 27f971a9359f3a9b76222d3841d458dd5efab7bf Mon Sep 17 00:00:00 2001 From: HokkaidoPerson Date: Fri, 7 Sep 2018 14:45:38 +0200 Subject: [PATCH 41/50] translation update --- lang/ja/lang.php | 64 ++++++++++++++++++++++---------------------- lang/ja/settings.php | 8 +++--- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/lang/ja/lang.php b/lang/ja/lang.php index c2788f2..5c57791 100644 --- a/lang/ja/lang.php +++ b/lang/ja/lang.php @@ -3,36 +3,36 @@ /** * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * + * @author HokkaidoPerson */ -$lang['e_unknowntype'] = '"%s" という型はありません。'; -$lang['e_missingargs'] = '%s %s には引数が十分ではありません。'; -$lang['e_noaction'] = 'action が定義されていません - どこにデータを送信するのですか?'; -$lang['e_mail'] = 'データの送信について何かがおかしいです。'; -$lang['e_unknownconstraint'] = '%s という項目制約がありません。'; -$lang['e_labelpage'] = '%s という Labelpage がありません。'; - -$lang['e_required'] = '"%s" が必要です。'; -$lang['e_match'] = '"%s" が正しく記入されていません。%s'; -$lang['e_email'] = '"%s" は有効なメールアドレスである必要があります。'; -$lang['checkagainst'] = '(/%s/i と照合)'; -$lang['e_numeric'] = '"%s" は数字である必要があります。'; -$lang['e_date'] = '"%s" は yyyy-mm-dd 形式の日付である必要があります。'; -$lang['e_user'] = '"%s" 既存のユーザー名である必要があります。'; -$lang['e_users'] = '"%s" 既存のユーザー名のカンマ区切り一覧である必要があります。'; -$lang['e_min'] = '"%s" は %s より大きい必要があります。'; -$lang['e_max'] = '"%s" は %s より小さい必要があります。'; - -$lang['e_pagename'] = 'ページ名がありません。'; -$lang['e_pageexists'] = '"%s" というページは既に存在します。別のページ名を選んで下さい。'; -$lang['e_template'] = '"%s" というテンプレートが読めません。存在しないか読み込み権限がないのではないですか?'; -$lang['e_denied'] = 'このページの作成は許可されません。ログインし忘れていませんか?'; - -$lang['mailsubject'] = 'フォームのデータは %s へ送信されました。'; -$lang['mailintro'] = '以下のデータは %s に送信されました。'; - -$lang['mail_thanks'] = 'データは正常に送信されました。ありがとう。'; -$lang['template_thanks'] = 'ページは作成されました。開くためにリンクをたどってください。'; - -$lang['summary'] = '%s のフォームから作成されました。'; - -$lang['submit'] = '送信'; +$lang['e_unknowntype'] = '"%s" という型はありません。'; +$lang['e_unknownaction'] = '不明なアクション「%s」'; +$lang['e_missingargs'] = '%s %s には引数が十分ではありません。'; +$lang['e_noaction'] = 'action が定義されていません - どこにデータを送信するのですか?'; +$lang['e_mail'] = 'データの送信について何かがおかしいです。'; +$lang['e_unknownconstraint'] = '%s という項目制約がありません。'; +$lang['e_labelpage'] = '%s という Labelpage がありません。'; +$lang['e_required'] = '"%s" が必要です。'; +$lang['e_match'] = '"%s" が正しく記入されていません。%s'; +$lang['checkagainst'] = '(/%s/i と照合)'; +$lang['e_email'] = '"%s" は有効なメールアドレスである必要があります。'; +$lang['e_numeric'] = '"%s" は数字である必要があります。'; +$lang['e_date'] = '"%s" は yyyy-mm-dd 形式の日付である必要があります。'; +$lang['e_time'] = '「%s」は、型 (h)h:mm(:ss) に沿った適切な時刻である必要があります。'; +$lang['e_user'] = '"%s" 既存のユーザー名である必要があります。'; +$lang['e_users'] = '"%s" 既存のユーザー名のカンマ区切り一覧である必要があります。'; +$lang['e_min'] = '"%s" は %s より大きい必要があります。'; +$lang['e_max'] = '"%s" は %s より小さい必要があります。'; +$lang['e_pagename'] = 'ページ名がありません。'; +$lang['e_pageexists'] = '"%s" というページは既に存在します。別のページ名を選んで下さい。'; +$lang['e_template'] = '"%s" というテンプレートが読めません。存在しないか読み込み権限がないのではないですか?'; +$lang['e_denied'] = 'このページの作成は許可されません。ログインし忘れていませんか?'; +$lang['mailsubject'] = 'フォームのデータは %s へ送信されました。'; +$lang['mailintro'] = '以下のデータは %s に送信されました。'; +$lang['mail_thanks'] = 'データは正常に送信されました。ありがとう。'; +$lang['template_thanks'] = 'ページは作成されました。開くためにリンクをたどってください。'; +$lang['summary'] = '%s のフォームから作成されました。'; +$lang['attachmentMailEmpty'] = '(ファイル未選択)'; +$lang['attachmentMailToLarge'] = '(メールに添付するにはファイルが大き過ぎます)'; +$lang['attachmentMailToLarge_userinfo'] = 'ファイル「%s」はメールに添付するには大き過ぎます(>%s)(メール自体は送信されました)'; +$lang['submit'] = '送信'; diff --git a/lang/ja/settings.php b/lang/ja/settings.php index 1078daf..ae1478a 100644 --- a/lang/ja/settings.php +++ b/lang/ja/settings.php @@ -1,7 +1,9 @@ */ -$lang['runas'] = 'テンプレートモードに影響があります。テンプレートを読み込み、ページを作成するために ACL チェックする場合、この(仮想)ユーザーの権限を使用してください。'; +$lang['runas'] = 'テンプレートモードに影響があります。テンプレートを読み込み、ページを作成するために ACL チェックする場合、この(仮想)ユーザーの権限を使用してください。'; +$lang['maxEmailAttachmentSize'] = 'メールに添付するファイルの最大サイズ(バイト数/1ファイルごと)'; From 9c944070ec00efbad11f5565aff9852d6ba2bcc1 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 10 Sep 2018 20:37:20 +0200 Subject: [PATCH 42/50] add missing formid parameter for hiddenautoinc field fixes #252 --- helper/fieldhiddenautoinc.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/helper/fieldhiddenautoinc.php b/helper/fieldhiddenautoinc.php index b359fb4..787e081 100644 --- a/helper/fieldhiddenautoinc.php +++ b/helper/fieldhiddenautoinc.php @@ -23,10 +23,11 @@ function initialize($args) { * * Outputs the represented field using the passed Doku_Form object. * - * @params array $params Additional HTML specific parameters - * @params Doku_Form $form The target Doku_Form object + * @param array $params Additional HTML specific parameters + * @param Doku_Form $form The target Doku_Form object + * @param $formid */ - function renderfield($params, Doku_Form $form) { + function renderfield($params, Doku_Form $form, $formid) { $this->_handlePreload(); $form->addHidden($params['name'], $this->getParam('value') . ''); } From 5fa58a8bf0df616efb7ad4a1f6d0fd741ecaf999 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 10 Sep 2018 23:50:11 +0200 Subject: [PATCH 43/50] Version upped --- plugin.info.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.info.txt b/plugin.info.txt index fa926ba..37ef825 100644 --- a/plugin.info.txt +++ b/plugin.info.txt @@ -1,7 +1,7 @@ base bureaucracy author Andreas Gohr email andi@splitbrain.org -date 2018-08-16 +date 2018-09-10 name Bureaucracy Plugin desc Create forms and generate pages or emails from them url https://www.dokuwiki.org/plugin:bureaucracy From a12a2f3bef19748e7c65d920d8061a15d2702819 Mon Sep 17 00:00:00 2001 From: Vicente Date: Sun, 7 Oct 2018 22:50:11 +0200 Subject: [PATCH 44/50] translation update --- lang/es/lang.php | 38 ++++++++++++++++++++++++++++++++++++++ lang/es/settings.php | 9 +++++++++ 2 files changed, 47 insertions(+) create mode 100644 lang/es/lang.php create mode 100644 lang/es/settings.php diff --git a/lang/es/lang.php b/lang/es/lang.php new file mode 100644 index 0000000..52624d7 --- /dev/null +++ b/lang/es/lang.php @@ -0,0 +1,38 @@ + + */ +$lang['e_unknowntype'] = 'Tipo desconocido "%s"'; +$lang['e_unknownaction'] = 'Acción desconocida "%s"'; +$lang['e_missingargs'] = 'Faltan argumentos para %s %s'; +$lang['e_noaction'] = 'Falta definir la acción - ¿Dónde enviamos los datos?'; +$lang['e_mail'] = 'Algún problema al enviar los datos'; +$lang['e_unknownconstraint'] = 'Faltan los límites del campo %s'; +$lang['e_labelpage'] = 'Pagina de LABELS "%s" no encontrada'; +$lang['e_required'] = '"%s" es necesario'; +$lang['e_match'] = '"%s" no esta completado correctamente. %s'; +$lang['checkagainst'] = '(Comprobado con /%s/i)'; +$lang['e_email'] = '"%s" tiene que ser un eMail válido.'; +$lang['e_numeric'] = '"%s" debe ser numérico.'; +$lang['e_date'] = '"%s" debe que ser una fecha válida con formato yyyy-mm-dd'; +$lang['e_time'] = '"%s" debe ser una hora válida con formato (h)h:mm(:ss)'; +$lang['e_user'] = '"%s" debe ser el nombre de un usuario existente.'; +$lang['e_users'] = '"%s" tiene que contener una lista de usuarios existentes separados por comas.'; +$lang['e_min'] = '"%s" debe ser mayor de %s.'; +$lang['e_max'] = '"%s" debe ser menor de %s.'; +$lang['e_pagename'] = 'Falta el nombre de la página.'; +$lang['e_pageexists'] = 'La pagina "%s" existe. Escoja un nombre diferente.'; +$lang['e_template'] = 'No se puede leer la plantilla "%s". O no existe, o no tenemos permisos de lectura.'; +$lang['e_denied'] = 'No tiene permisos para crear la página, ¿Esta logueado?'; +$lang['mailsubject'] = 'Formulario enviado en %s'; +$lang['mailintro'] = 'Los siguientes datos enviados en %s'; +$lang['mail_thanks'] = 'Formulario enviado correctamente. Gracias.'; +$lang['template_thanks'] = 'La página esta creada, siga el enlace para abrirla.'; +$lang['summary'] = 'Creada desde el formulario en %s'; +$lang['attachmentMailEmpty'] = '(fichero no enviado)'; +$lang['attachmentMailToLarge'] = '(fichero demasiado largo para incrustarlo en un eMail)'; +$lang['attachmentMailToLarge_userinfo'] = 'Fichero "%s" demasiado largo para incrustarlo en un eMail (>%s) (eMail enviado de todas formas)'; +$lang['submit'] = 'Enviar'; diff --git a/lang/es/settings.php b/lang/es/settings.php new file mode 100644 index 0000000..e783e78 --- /dev/null +++ b/lang/es/settings.php @@ -0,0 +1,9 @@ + + */ +$lang['runas'] = 'Afecta el modo plantilla. Use los permisos de este usuario (virtual) cuando compruebe los ACLs para leer plantillas y crear páginas.'; +$lang['maxEmailAttachmentSize'] = 'Maximo tamaño, en Bytes, de los elementos incrustados en un eMail. (por fichero)'; From 0c86297b4bcc22672a5da663e82d84a06fe7f903 Mon Sep 17 00:00:00 2001 From: Rafael Grando Date: Mon, 12 Nov 2018 15:00:44 +0100 Subject: [PATCH 45/50] translation update --- lang/pt/lang.php | 37 +++++++++++++++++++++++++++++++++++++ lang/pt/settings.php | 9 +++++++++ 2 files changed, 46 insertions(+) create mode 100644 lang/pt/lang.php create mode 100644 lang/pt/settings.php diff --git a/lang/pt/lang.php b/lang/pt/lang.php new file mode 100644 index 0000000..3e9913d --- /dev/null +++ b/lang/pt/lang.php @@ -0,0 +1,37 @@ + + */ +$lang['e_unknowntype'] = 'Tipo desconhecido "%s"'; +$lang['e_unknownaction'] = 'Ação desconhecida "%s"'; +$lang['e_missingargs'] = 'Argumentos insuficientes para %s %s'; +$lang['e_noaction'] = 'Nenhuma ação definida - para onde os dados devem ser enviados?'; +$lang['e_mail'] = 'Algo deu errado ao enviar esses dados'; +$lang['e_unknownconstraint'] = 'Restrição de campo desconhecida %s'; +$lang['e_labelpage'] = 'Labelpage %s não encontrada'; +$lang['e_required'] = '"%s" é obrigatório'; +$lang['e_match'] = '"%s" não foi preenchido corretamente. %s'; +$lang['checkagainst'] = '(Verificado contra /%s/i)'; +$lang['e_email'] = '"%s" precisa ser um endereço de email válido.'; +$lang['e_numeric'] = '"%s" precisa ser um número.'; +$lang['e_date'] = '"%s" precisa ser uma data válida no formato aaaa-mm-dd.'; +$lang['e_time'] = '"%s" precisa ser um horário válido no formato (h)h:mm:(:ss).'; +$lang['e_user'] = '"%s" precisa ser o nome de um usuário existente.'; +$lang['e_users'] = '"%s" precisa ser uma lista separada por vírgulas de nomes de usuários existentes.'; +$lang['e_min'] = '"%s" precisa ser maior que %s.'; +$lang['e_max'] = '"%s" precisa ser menor que %s.'; +$lang['e_pageexists'] = 'A página "%s" já existe. Por favor, escolha um nome diferente para a página.'; +$lang['e_template'] = 'Não foi possível ler o modelo "%s". Talvez ele não exista ou você não tenha permissões de leitura?'; +$lang['e_denied'] = 'Você não está autorizado a criar esta página. Talvez tenha esquecido de entrar?'; +$lang['mailsubject'] = 'Dados do formulário enviados às %s'; +$lang['mailintro'] = 'Os dados a seguir foram enviados em %s.'; +$lang['mail_thanks'] = 'Seus dados foram enviados com sucesso. Obrigado.'; +$lang['template_thanks'] = 'A página foi criada, siga o link para abri-la.'; +$lang['summary'] = 'Criado do formulário às %s.'; +$lang['attachmentMailEmpty'] = '(arquivo não enviado)'; +$lang['attachmentMailToLarge'] = '(arquivo muito grande para anexar ao email)'; +$lang['attachmentMailToLarge_userinfo'] = 'arquivo "%s" é muito grande para anexar ao email (>%s) (email enviado mesmo assim)'; +$lang['submit'] = 'Enviar'; diff --git a/lang/pt/settings.php b/lang/pt/settings.php new file mode 100644 index 0000000..174eb1c --- /dev/null +++ b/lang/pt/settings.php @@ -0,0 +1,9 @@ + + */ +$lang['runas'] = 'Afeta o modo template. Use essas permissões (virtuais) de usuário quando checar ACLs para ler modelos e criar páginas.'; +$lang['maxEmailAttachmentSize'] = 'Tamanho máximo de anexos em bytes. (por arquivo)'; From b3ccaa806f50eb819ed87ffc77ad0fdcb19e9c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schplurtz=20le=20D=C3=A9boulonn=C3=A9?= Date: Wed, 27 Feb 2019 08:15:20 +0100 Subject: [PATCH 46/50] translation update --- lang/fr/lang.php | 18 +++++++++--------- lang/fr/settings.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lang/fr/lang.php b/lang/fr/lang.php index e3a3a6e..5bae4e0 100644 --- a/lang/fr/lang.php +++ b/lang/fr/lang.php @@ -13,26 +13,26 @@ $lang['e_unknownconstraint'] = 'Contrainte de champ inconue %s'; $lang['e_labelpage'] = 'Page de label %s non trouvée.'; $lang['e_required'] = '"%s" est requis'; -$lang['e_match'] = '"%s" n\'a pas été remplis correctement. %s'; +$lang['e_match'] = '"%s" n\'est pas remplis correctement. %s'; $lang['checkagainst'] = '(vérifié avec /%s/i)'; -$lang['e_email'] = '"%s" doit être une adresse e-mail valide.'; +$lang['e_email'] = '"%s" doit être une adresse de courriel valide.'; $lang['e_numeric'] = '"%s" doit être un nombre.'; $lang['e_date'] = '"%s" doit être une date valide au format yyyy-mm-dd.'; $lang['e_time'] = '"%s" nécessite une heure valide au format (h)h:mm(:ss).'; $lang['e_user'] = '"%s" doit être le nom d\'un utilisateur existant.'; -$lang['e_users'] = '"%s" doit être une liste de noms d\'utilisateurs séparés par des virgules.'; +$lang['e_users'] = '"%s" doit être une liste à virgules de noms d\'utilisateurs.'; $lang['e_min'] = '"%s" doit être plus grand que %s.'; $lang['e_max'] = '"%s" doit être plus petit que %s.'; $lang['e_pagename'] = 'Nom de page manquant.'; -$lang['e_pageexists'] = 'La page "%s" existe déjà. Choisissez un autre nom.'; +$lang['e_pageexists'] = 'La page "%s" existe déjà. Veuillez choisir un autre nom.'; $lang['e_template'] = 'Modèle "%s" introuvable. Il n\'existe pas ou vous n\'avez pas l\'autorisation de lecture.'; $lang['e_denied'] = 'Vous n\'avez pas le droit de créer cette page, vous êtes vous connecté ?'; -$lang['mailsubject'] = 'Données du formulaire soumises à %s'; -$lang['mailintro'] = 'Les données suivantes on été envoyées vers %s.'; +$lang['mailsubject'] = 'Données du formulaire de la page %s'; +$lang['mailintro'] = 'Les données suivantes ont été envoyées le %s.'; $lang['mail_thanks'] = 'Données envoyées avec succès. Merci.'; -$lang['template_thanks'] = 'La page a été créée, suivez le lien pour l\'ouvrir.'; +$lang['template_thanks'] = 'La page est créée, suivez le lien pour l\'ouvrir.'; $lang['summary'] = 'Créé depuis le formulaire %s'; $lang['attachmentMailEmpty'] = '(fichier non envoyé)'; -$lang['attachmentMailToLarge'] = '(pièce jointe trop grosse)'; -$lang['attachmentMailToLarge_userinfo'] = 'fichier "%s" trop gros comme pièce jointe (>%s). Le message a tout de même été envoyé.'; +$lang['attachmentMailToLarge'] = '(fichier trop grand comme pièce jointe de courriel)'; +$lang['attachmentMailToLarge_userinfo'] = 'fichier "%s" trop grand comme pièce jointe (>%s). Le message est tout de même parti.'; $lang['submit'] = 'Envoyer'; diff --git a/lang/fr/settings.php b/lang/fr/settings.php index a97393d..72031df 100644 --- a/lang/fr/settings.php +++ b/lang/fr/settings.php @@ -5,5 +5,5 @@ * * @author Schplurtz le Déboulonné */ -$lang['runas'] = 'Mode «template» : teste les ACL avec les permissions de cet utilisateur (virtuel) pour la lecture des page modèles et la création de page.'; +$lang['runas'] = 'Mode «template» : teste les ACL avec les permissions de cet utilisateur (virtuel) pour la lecture des modèles et la création de page.'; $lang['maxEmailAttachmentSize'] = 'Taille max en octet des pièces jointes dans les courriels. (par fichier)'; From d37046c05edc4cee2556bc80531e049ff911e5e9 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 20 Mar 2019 16:38:36 +0100 Subject: [PATCH 47/50] fix testing --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3ee2bb1..8f5c366 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: php php: + - "7.3" - "7.2" - "7.1" - "7.0" @@ -8,4 +9,4 @@ before_install: wget https://raw.github.com/splitbrain/dokuwiki-travis/master/tr install: sh travis.sh script: - cd _test - - phpunit --group plugin_bureaucracy + - ./phpunit.phar --group plugin_bureaucracy From f559cfc49dff6b5706a0c831850d0751c5aed604 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 20 Mar 2019 23:50:12 +0100 Subject: [PATCH 48/50] Version upped --- plugin.info.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.info.txt b/plugin.info.txt index 37ef825..bd35457 100644 --- a/plugin.info.txt +++ b/plugin.info.txt @@ -1,7 +1,7 @@ base bureaucracy author Andreas Gohr email andi@splitbrain.org -date 2018-09-10 +date 2019-03-20 name Bureaucracy Plugin desc Create forms and generate pages or emails from them url https://www.dokuwiki.org/plugin:bureaucracy From be2c77b33297d0c8bdc8391f896a07dc2e46d2f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Sampaio?= Date: Thu, 30 May 2019 16:33:14 -0300 Subject: [PATCH 49/50] Update lang.php Add translation for $lang['e_time'] --- lang/pt-br/lang.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lang/pt-br/lang.php b/lang/pt-br/lang.php index f69c6ea..a3ab322 100644 --- a/lang/pt-br/lang.php +++ b/lang/pt-br/lang.php @@ -12,6 +12,7 @@ $lang['e_email'] = '"%s" tem de ser um endereço de email válido.'; $lang['e_numeric'] = '"%s" tem de ser um número.'; $lang['e_date'] = '"%s" tem de ser uma data válida no formato dd-mm-yyyy.'; +$lang['e_time'] = '"%s" tem de ser um horário válido no formato (h)h:mm(:ss).'; $lang['e_user'] = '"%s" tem de ser o nome de um usuário existente.'; $lang['e_users'] = '"%s" tem de ser uma lista de nomes de usuários existentes separados por vírgulas.'; $lang['e_min'] = '"%s" tem de ser maior que %s.'; From 22adff34400903c487f338dd1f706ab0721b6e2a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 19 Jun 2019 23:50:07 +0200 Subject: [PATCH 50/50] Version upped --- plugin.info.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.info.txt b/plugin.info.txt index bd35457..ff5973e 100644 --- a/plugin.info.txt +++ b/plugin.info.txt @@ -1,7 +1,7 @@ base bureaucracy author Andreas Gohr email andi@splitbrain.org -date 2019-03-20 +date 2019-05-30 name Bureaucracy Plugin desc Create forms and generate pages or emails from them url https://www.dokuwiki.org/plugin:bureaucracy