Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added functionality so that in case of multiple commands setting the … #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions conf/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
/**
* Default config settings of the fields plugin.
*/

$conf['firstfielddefinitionwins'] = 1;
6 changes: 6 additions & 0 deletions conf/metadata.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
/**
* Options for the fields plugin
*/

$meta['firstfielddefinitionwins'] = array('onoff');
5 changes: 5 additions & 0 deletions lang/de-informal/settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

/**
*/
$lang['firstfielddefinitionwins'] = 'Bei mehreren Definitionen von field auf einer Seite wird die erste verwendet. (Im Fall von false, wird das letzte verwendet.)';
5 changes: 5 additions & 0 deletions lang/de/settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

/**
*/
$lang['firstfielddefinitionwins'] = 'Bei mehreren Definitionen von field auf einer Seite wird die erste verwendet. (Im Fall von false, wird das letzte verwendet.)';
5 changes: 5 additions & 0 deletions lang/en/settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
/**
* English language file for config settings.
*/
$lang['firstfielddefinitionwins'] = 'In case of multiple definitions of a particular field, the first will be used. (The value false will apply the last definition, instead.)';
18 changes: 14 additions & 4 deletions syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class syntax_plugin_fields extends DokuWiki_Syntax_Plugin {
* Constructor. Loads helper plugin.
*/
public function __construct() {
$this->helper = $this->loadHelper('fields');
$this->fields_helper = plugin_load('helper','fields');
$this->usecounter_helper = plugin_load('helper','usecounter');
}

/**
Expand Down Expand Up @@ -70,7 +71,7 @@ public function render($format, Doku_Renderer $renderer, $data) {
$renderer->doc .= $renderer->fields[$field_name];
return true;
} elseif ($format == 'odt') {
$renderer->doc .= $this->helper->ODTDisplayUserField($renderer, $field_name);
$renderer->doc .= $this->fields_helper->ODTDisplayUserField($renderer, $field_name);
return true;
}
} else {
Expand All @@ -82,8 +83,17 @@ public function render($format, Doku_Renderer $renderer, $data) {
$renderer->fields[$field_name] = htmlentities($field_value);
return true;
} elseif ($format == 'odt') {
$this->helper->ODTSetUserField($renderer, $field_name,
$renderer->_xmlEntities($field_value));
if ($this->getConf('firstfielddefinitionwins')) {
if ($this->usecounter_helper && $this->usecounter_helper->amountOfUses('fields_'.$field_name) == 0) {
$this->fields_helper->ODTSetUserField($renderer, $field_name, $renderer->_xmlEntities($field_value));
}

if ($this->usecounter_helper) {
$this->usecounter_helper->incUsageOf('fields_'.$field_name);
}
} else {
$this->fields_helper->ODTSetUserField($renderer, $field_name, $renderer->_xmlEntities($field_value));
}
return true;
}
}
Expand Down