diff --git a/.github/workflows/dokuwiki.yml b/.github/workflows/dokuwiki.yml
new file mode 100644
index 0000000..e6b8435
--- /dev/null
+++ b/.github/workflows/dokuwiki.yml
@@ -0,0 +1,11 @@
+name: DokuWiki Default Tasks
+on:
+ push:
+ pull_request:
+ schedule:
+ - cron: '1 9 8 * *'
+
+
+jobs:
+ all:
+ uses: dokuwiki/github-action/.github/workflows/all.yml@main
diff --git a/.github/workflows/phpTestLinux.yml b/.github/workflows/phpTestLinux.yml
index 194e707..8b13789 100644
--- a/.github/workflows/phpTestLinux.yml
+++ b/.github/workflows/phpTestLinux.yml
@@ -1,52 +1 @@
-name: PHP Tests on Linux
-on: [push, pull_request]
-
-jobs:
- run:
- name: PHP ${{ matrix.php-versions }} DokuWiki ${{ matrix.dokuwiki-branch }}
- runs-on: ubuntu-latest
- if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
-
- strategy:
- matrix:
- php-versions: ['7.2', '7.3', '7.4', '8.0']
- dokuwiki-branch: [ 'master', 'stable']
- exclude:
- - dokuwiki-branch: 'stable'
- php-versions: '8.0'
- fail-fast: true
-
- steps:
- - name: Checkout
- uses: actions/checkout@v2
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php-versions }}
- extensions: mbstring, intl, PDO, pdo_sqlite, bz2
-
- - name: Setup problem matchers
- run: |
- echo ::add-matcher::${{ runner.tool_cache }}/php.json
- echo ::add-matcher::${{ runner.tool_cache }}/phpunit.json
-
- - name: Download DokuWiki Test-setup
- run: wget https://raw.github.com/splitbrain/dokuwiki-travis/master/travis.sh
-
- - name: Run DokuWiki Test-setup
- env:
- CI_SERVER: 1
- DOKUWIKI: ${{ matrix.dokuwiki-branch }}
- run: sh travis.sh
-
- - name: Setup PHPUnit
- run: |
- php _test/fetchphpunit.php
- cd _test
-
- - name: Run PHPUnit
- run: |
- cd _test
- php phpunit.phar --verbose --stderr --group plugin_bureaucracy
diff --git a/conf/default.php b/conf/default.php
index ed0463f..812786c 100644
--- a/conf/default.php
+++ b/conf/default.php
@@ -1,4 +1,5 @@
handleData($fields, $thanks);
+ } elseif (is_a($handler, dokuwiki\plugin\bureaucracy\interfaces\bureaucracy_handler_interface_ex::class)) {
+ return $handler->handleData($fields, $thanks,$argv);
+ } else {
throw new InvalidArgumentException('The handler must implement the interface dokuwiki\\plugin\\bureaucracy\\interfaces\\bureaucracy_handler_interface !');
}
-
- return $handler->handleData($fields, $thanks);
}
/**
diff --git a/helper/field.php b/helper/field.php
index 070e331..89a3399 100644
--- a/helper/field.php
+++ b/helper/field.php
@@ -103,6 +103,8 @@ protected function standardArgs($args) {
}
} elseif($arg == '@') {
$this->opt['pagename'] = true;
+ } elseif($arg == '#') {
+ $this->opt['readonly'] = true;
} elseif($arg == '@@') {
$this->opt['replyto'] = true;
} elseif(preg_match('/x\d/', $arg)) {
diff --git a/helper/fieldfieldset.php b/helper/fieldfieldset.php
index ddce2b6..4a66ff3 100644
--- a/helper/fieldfieldset.php
+++ b/helper/fieldfieldset.php
@@ -69,7 +69,6 @@ public function handle_post($value, &$fields, $index, $formid) {
if(empty($this->depends_on)) {
return true;
}
-
// search the field where fieldset depends on in fields before fieldset
$hidden = false;
for ($n = 0 ; $n < $index; ++$n) {
@@ -78,7 +77,7 @@ public function handle_post($value, &$fields, $index, $formid) {
continue;
}
if(count($this->depends_on) > 1) {
- $hidden = $field->getParam('value') != $this->depends_on[1];
+ $hidden = (in_array($field->getParam('value'), explode("|",$this->depends_on[1]))==false);
} else {
$hidden = !$field->isSet_();
}
diff --git a/helper/fieldsubmit.php b/helper/fieldsubmit.php
index b9f2e45..318ff42 100644
--- a/helper/fieldsubmit.php
+++ b/helper/fieldsubmit.php
@@ -4,6 +4,7 @@
*
* Creates a submit button
*/
+
class helper_plugin_bureaucracy_fieldsubmit extends helper_plugin_bureaucracy_field {
protected $mandatory_args = 1;
static $captcha_displayed = array();
@@ -23,6 +24,14 @@ public function initialize($args) {
$this->opt['optional'] = true;
}
+ function form_button($attrs)
+ {
+ $p = (!empty($attrs['_action'])) ? 'name="do[' . $attrs['_action'] . ']" ' : '';
+ $label = $attrs['label'];
+ unset($attrs['label']);
+ return '';
+ }
+
/**
* Render the field as XHTML
*
@@ -40,12 +49,37 @@ public function renderfield($params, Doku_Form $form, $formid) {
$form->addElement($helper->getHTML());
}
}
+
$attr = array();
+ $attr['name'] = 'submit';
+ if(isset($this->opt['value'])) {
+ $attr['value'] = $this->opt['value'];
+ }
+ if(isset($this->opt['label'])) {
+ $attr['label'] = $this->opt['label'];
+ }
if(isset($this->opt['id'])) {
$attr['id'] = $this->opt['id'];
}
+ if(isset($this->opt['class'])) {
+ $attr['class'] = $this->opt['class'];
+ }
+
$this->tpl = form_makeButton('submit','', '@@DISPLAY|' . $this->getLang('submit') . '@@', $attr);
- parent::renderfield($params, $form, $formid);
+
+ $this->_handlePreload();
+
+ if(!$form->_infieldset){
+ $form->startFieldset('');
+ }
+ if ($this->error) {
+ $params['class'] = 'bureaucracy_error';
+ }
+
+ $params = array_merge($this->opt, $params);
+ $element = $this->_parse_tpl($this->tpl, $params);
+ $form->addElement($this->form_button($element));
+
}
/**
@@ -57,9 +91,13 @@ public function renderfield($params, Doku_Form $form, $formid) {
* @param helper_plugin_bureaucracy_field[] $fields (reference) form fields (POST handled upto $this field)
* @param int $index index number of field in form
* @param int $formid unique identifier of the form which contains this field
- * @return bool Whether the posted form has a valid captcha
+ * @return bool Whether the posted f$_POSTorm has a valid captcha
*/
public function handle_post($value, &$fields, $index, $formid) {
+
+ // Set the value of the submit filed to the label of the button which was pressed
+ $this->setVal($_POST['submit']);
+
if ($this->hidden) {
return true;
}
@@ -83,7 +121,7 @@ public function handle_post($value, &$fields, $index, $formid) {
* @return mixed|null
*/
public function getParam($name) {
- return ($name === 'value') ? null : parent::getParam($name);
+ return ($name === 'value') ? (($this->hidden)? null : parent::getParam($name)) : parent::getParam($name);
}
}
diff --git a/helper/fieldtextbox.php b/helper/fieldtextbox.php
index 430cc2d..b6604d5 100644
--- a/helper/fieldtextbox.php
+++ b/helper/fieldtextbox.php
@@ -23,6 +23,10 @@ function initialize($args) {
$attr['required'] = 'required';
}
+ if(isset($this->opt['readonly'])) {
+ $attr['readonly'] = 'readonly';
+ }
+
$this->tpl = form_makeTextField('@@NAME@@', '@@VALUE@@', '@@DISPLAY@@', '@@ID@@', '@@CLASS@@', $attr);
if(isset($this->opt['class'])){
$this->tpl['class'] .= ' '.$this->opt['class'];
diff --git a/interfaces/bureaucracy_handler_interface_ex.php b/interfaces/bureaucracy_handler_interface_ex.php
new file mode 100644
index 0000000..215757e
--- /dev/null
+++ b/interfaces/bureaucracy_handler_interface_ex.php
@@ -0,0 +1,19 @@
+
*/
$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['namespaces'] = 'If set it limits the usage of forms to the given namspaces and page ids. The character * is a wildcard sysmbol and ** includes all subnamespaces';
$lang['maxEmailAttachmentSize'] = 'Maximo tamaño, en Bytes, de los elementos incrustados en un eMail. (por fichero)';
diff --git a/lang/fa/settings.php b/lang/fa/settings.php
index 8bfc3b8..f06017a 100644
--- a/lang/fa/settings.php
+++ b/lang/fa/settings.php
@@ -6,4 +6,5 @@
* @author nima
*/
$lang['runas'] = 'روی حالت قالب اثر میگذارد. از این اجازههای کاربر (مجازی) وقتی استفاده کنید که ACL ها برای خواندن قالبها و ایجاد صفحات بررسی میشوند. ';
+$lang['namespaces'] = 'If set it limits the usage of forms to the given namspaces and page ids. The character * is a wildcard sysmbol and ** includes all subnamespaces';
$lang['maxEmailAttachmentSize'] = 'اندازه حداکثر پیوستهای ایمیل بر حسب بایت. (به ازای هر فایل)';
diff --git a/lang/fr/settings.php b/lang/fr/settings.php
index 72031df..c57e6a8 100644
--- a/lang/fr/settings.php
+++ b/lang/fr/settings.php
@@ -6,4 +6,5 @@
* @author Schplurtz le Déboulonné
*/
$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['namespaces'] = 'If set it limits the usage of forms to the given namspaces and page ids. The character * is a wildcard sysmbol and ** includes all subnamespaces';
$lang['maxEmailAttachmentSize'] = 'Taille max en octet des pièces jointes dans les courriels. (par fichier)';
diff --git a/lang/hr/settings.php b/lang/hr/settings.php
index d9df8dd..124524f 100644
--- a/lang/hr/settings.php
+++ b/lang/hr/settings.php
@@ -6,4 +6,5 @@
* @author Davor Turkalj
*/
$lang['runas'] = 'Utječe na mod predloška. Koristi ove (virtualne) ovlasti kada provjeravaš ACL za čitanje predloška i stvaranje stranice.';
+$lang['namespaces'] = 'If set it limits the usage of forms to the given namspaces and page ids. The character * is a wildcard sysmbol and ** includes all subnamespaces';
$lang['maxEmailAttachmentSize'] = 'Maksimalna veličina priloga pošti u Bajtovima. (po datoteci)';
diff --git a/lang/it/settings.php b/lang/it/settings.php
new file mode 100644
index 0000000..46d3c4c
--- /dev/null
+++ b/lang/it/settings.php
@@ -0,0 +1,6 @@
+
*/
$lang['runas'] = 'テンプレートモードに影響があります。テンプレートを読み込み、ページを作成するために ACL チェックする場合、この(仮想)ユーザーの権限を使用してください。';
+$lang['namespaces'] = 'If set it limits the usage of forms to the given namspaces and page ids. The character * is a wildcard sysmbol and ** includes all subnamespaces';
$lang['maxEmailAttachmentSize'] = 'メールに添付するファイルの最大サイズ(バイト数/1ファイルごと)';
diff --git a/lang/lv/settings.php b/lang/lv/settings.php
new file mode 100644
index 0000000..46d3c4c
--- /dev/null
+++ b/lang/lv/settings.php
@@ -0,0 +1,6 @@
+
*/
$lang['runas'] = 'Gebruikt in de template mode. Gebruik de rechten van deze (virtuele) gebruiker bij het controleren van de ACL gebruiker voor het lezen van templates en het maken van pagina\'s';
+$lang['namespaces'] = 'If set it limits the usage of forms to the given namspaces and page ids. The character * is a wildcard sysmbol and ** includes all subnamespaces';
$lang['maxEmailAttachmentSize'] = 'Max grootte van e-mailbijlages in Bytes. (per bestand)';
diff --git a/lang/no/settings.php b/lang/no/settings.php
index 70227ce..fa704d2 100644
--- a/lang/no/settings.php
+++ b/lang/no/settings.php
@@ -1,5 +1,6 @@
*/
$lang['runas'] = 'Afeta o modo de template. Use estas permissões de usuário (virtual) quando verificando ACLs para leitura de templates e criação de páginas.';
+$lang['namespaces'] = 'If set it limits the usage of forms to the given namspaces and page ids. The character * is a wildcard sysmbol and ** includes all subnamespaces';
$lang['maxEmailAttachmentSize'] = 'Tamanho máximo para anexos de e-mail em Bytes. (por arquivo)';
diff --git a/lang/pt/settings.php b/lang/pt/settings.php
index 174eb1c..c7f2137 100644
--- a/lang/pt/settings.php
+++ b/lang/pt/settings.php
@@ -6,4 +6,5 @@
* @author Rafael Grando
*/
$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['namespaces'] = 'If set it limits the usage of forms to the given namspaces and page ids. The character * is a wildcard sysmbol and ** includes all subnamespaces';
$lang['maxEmailAttachmentSize'] = 'Tamanho máximo de anexos em bytes. (por arquivo)';
diff --git a/lang/ru/settings.php b/lang/ru/settings.php
index cb8fe7b..e644bf4 100644
--- a/lang/ru/settings.php
+++ b/lang/ru/settings.php
@@ -7,4 +7,5 @@
* @author Yuriy Skalko
*/
$lang['runas'] = '(Влияет на режим шаблона.) Использовать права этого (виртуального) пользователя при проверке доступа для чтения шаблонов и создания страниц.';
+$lang['namespaces'] = 'If set it limits the usage of forms to the given namspaces and page ids. The character * is a wildcard sysmbol and ** includes all subnamespaces';
$lang['maxEmailAttachmentSize'] = 'Максимальный размер почтовых вложений в байтах. (на файл)';
diff --git a/lang/zh/settings.php b/lang/zh/settings.php
index 6989239..565e77d 100644
--- a/lang/zh/settings.php
+++ b/lang/zh/settings.php
@@ -1,5 +1,6 @@
count($id)-1) {
+ $found=false;
+ break;
+ } elseif ($pat[$i]=='**') {
+ break;
+ } elseif ($pat[$i]=='*') {
+ continue;
+ } elseif ($pat[$i]!=$id[$i]) {
+ $found=false;
+ break;
+ }
+ }
+ if ($found) {
+ break;
+ }
+ }
+ return $found;
+ } else {
+ return true;
+ }
+ }
/**
* Connect pattern to lexer
*
@@ -75,12 +106,19 @@ public function connectTo($mode) {
* @return bool|array Return an array with all data you want to use in render, false don't add an instruction
*/
public function handle($match, $state, $pos, Doku_Handler $handler) {
+ global $ID;
$match = substr($match, 6, -7); // remove form wrap
$lines = explode("\n", $match);
$actions = $rawactions = array();
$thanks = '';
$labels = '';
+ $namespaces = $this->getConf('namespaces');
+ if (!$this->_checkvalidpages($ID, $namespaces)) {
+ msg($this->getLang('e_namespace'), -1);
+ return false;
+ }
+
// parse the lines into an command/argument array
$cmds = array();
while(count($lines) > 0) {
@@ -203,7 +241,6 @@ public function handle($match, $state, $pos, Doku_Handler $handler) {
public function render($format, Doku_Renderer $R, $data) {
if($format != 'xhtml') return false;
$R->info['cache'] = false; // don't cache
-
/**
* replace some time and name placeholders in the default values
* @var $field helper_plugin_bureaucracy_field
@@ -309,7 +346,6 @@ private function _handlepost($data) {
$success = true;
foreach($data['fields'] as $index => $field) {
/** @var $field helper_plugin_bureaucracy_field */
-
$isValid = true;
if($field->getFieldType() === 'file') {
$file = array();