field_height int(10) default NULL,
field_size int(10) default NULL,
field_repeat int(10) default NULL,
- field_layout int(10) default NULL,
+ field_information TEXT default NULL,
PRIMARY KEY (field_id),
INDEX (field_form)
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
field_height integer DEFAULT NULL,
field_size integer DEFAULT NULL,
field_repeat integer DEFAULT NULL,
- field_layout integer DEFAULT NULL,
+ field_information text DEFAULT NULL,
PRIMARY KEY (field_id)
);
-- add index, field_form is used elsewhere
-- drop groups unique name constraint
ALTER TABLE galette_groups DROP INDEX `name`;
+-- add information on dynamic fields
+ALTER TABLE galette_field_types ADD COLUMN field_information text DEFAULT NULL;
+-- field that has never been used
+ALTER TABLE galette_field_types DROP COLUMN field_layout;
+
UPDATE galette_database SET version = 0.960;
\ No newline at end of file
-- drop groups unique name constraint
ALTER TABLE galette_groups DROP CONSTRAINT name;
+-- add information on dynamic fields
+ALTER TABLE galette_field_types ADD COLUMN field_information text DEFAULT NULL;
+-- field that has never been used
+ALTER TABLE galette_field_types DROP COLUMN field_layout;
+
UPDATE galette_database SET version = 0.960;
\ No newline at end of file
* @package Galette
*
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2012-2014 The Galette Team
+ * @copyright 2012-2021 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
*/
protected $old_size;
protected $values;
protected $form;
+ protected $information;
+ protected $name;
+ protected $old_name;
protected $errors = [];
$this->repeat = (int)$rs->field_repeat;
$this->size = $rs->field_size;
$this->form = $rs->field_form;
+ $this->information = $rs->field_information;
if ($values && $this->hasFixedValues()) {
$this->loadFixedValues();
}
return (bool)$this->has_permissions;
}
-
/**
* Get field id
*
return $this->perm;
}
-
/**
* Is field required?
*
return $this->index;
}
+ /**
+ * Get field information
+ *
+ * @return string
+ */
+ public function getInformation(): string
+ {
+ return $this->information ?? '';
+ }
+
/**
* Retrieve permissions names for display
*
$this->repeat = $values['field_repeat'];
}
+ if (isset($values['field_information']) && trim($values['field_information']) != '') {
+ global $preferences;
+ $this->information = $preferences->cleanHtmlValue($values['field_information']);
+ }
+
if ($this->hasFixedValues() && isset($values['fixed_values'])) {
$fixed_values = [];
foreach (explode("\n", $values['fixed_values']) as $val) {
'field_size' => ($this->size === null ? new Expression('NULL') : $this->size),
'field_repeat' => ($this->repeat === null ? new Expression('NULL') : $this->repeat),
'field_form' => $this->form,
- 'field_index' => $this->index
+ 'field_index' => $this->index,
+ 'field_information' => ($this->information === null ? new Expression('NULL') : $this->information)
);
if ($this->required === false) {
<div>
{assign var=access_level value=$login->getAccessLevel()}
{foreach from=$fields item=field}
+ {if $field->getInformation()}
+ <div>{$field->getInformation()}</div>
+ {/if}
+
{assign var=perm value=$field->getPerm()}
{if $field|is_a:'Galette\DynamicFields\Separator'}
<div class="separator">{$field->getName()|escape}</div>
{elseif ($field|is_a:'Galette\DynamicFields\File' || $field->isRepeatable()) && $masschange}
- <!-- File and repetable fields not shown in mass changes form -->
+ <!-- File and repeatable fields not shown in mass changes form -->
{else}
<p{if $field->isRepeatable()} class="repetable"{/if}>
{assign var=disabled value=false}
<br/><span class="exemple">{_T string="Choice list (one entry per line)."}</span>
</p>
{/if}
+ <p>
+ <label for="field_information" class="bline tooltip">{_T string="Information:"}</label>
+ <span class="tip">{_T string="Extra information displayed along with dynamic field."}</span>
+ <textarea name="field_information" id="field_information" cols="20" rows="6">{$df->getInformation()}</textarea>
+ </p>
</fieldset>
<div class="button-container">
<button type="submit" class="action">
</form>
{/if}
{/block}
+
+{block name="javascripts"}
+ <script>
+ $('#field_information').summernote({
+ lang: '{$i18n->getID()|replace:'_':'-'}',
+ height: 240,
+ toolbar: [
+ ['style', ['style']],
+ ['font', ['bold', 'italic', 'strikethrough', 'clear']],
+ ['para', ['ul', 'ol', 'paragraph']],
+ ['insert', ['link', 'picture']],
+ ['view', ['codeview', 'help']]
+ ],
+ styleTags: [
+ 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'
+ ]
+ });
+ $('#field_information').summernote('focus');
+
+ </script>
+{/block}
)->isInstanceOf('\PDOException');
$this->boolean(\Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df_id))->isFalse();
}
+
+ /**
+ * Test information
+ *
+ * @return void
+ */
+ public function testInformation()
+ {
+ $field_data = [
+ 'form_name' => 'adh',
+ 'field_name' => 'A first text field',
+ 'field_perm' => \Galette\DynamicFields\DynamicField::PERM_USER_WRITE,
+ 'field_type' => \Galette\DynamicFields\DynamicField::TEXT,
+ 'field_information' => '<p>This is an important information.</p><p>And here an xss... <img src=img.png onerror=alert(1) /></p>'
+ ];
+
+ $df = \Galette\DynamicFields\DynamicField::getFieldType($this->zdb, $field_data['field_type']);
+ $stored = $df->store($field_data);
+ $this->boolean($stored)->isTrue(
+ implode(
+ ' ',
+ $df->getErrors() + $df->getWarnings()
+ )
+ );
+ $this->boolean($stored)->isTrue();
+ $this->object(\Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df->getId()))->isEqualTo($df);
+
+ $this->string($df->getInformation())->isIdenticalTo('<p>This is an important information.</p><p>And here an xss... <img src="img.png" alt="img.png" /></p>');
+ }
}