1<?php
2/**
3 * Class helper_plugin_bureaucracy_fieldstatic
4 *
5 * Adds some static text to the form
6 */
7class helper_plugin_bureaucracy_fieldstatic extends helper_plugin_bureaucracy_field {
8    protected $tpl = '<p>@@DISPLAY@@</p>';
9
10    /**
11     * Arguments:
12     *  - cmd
13     *  - text
14     *
15     * @param array $args The tokenized definition, only split at spaces
16     */
17    public function initialize($args) {
18        parent::initialize($args);
19        // make always optional to prevent being marked as required
20        $this->opt['optional'] = true;
21    }
22
23    /**
24     * Handle a post to the field
25     *
26     * @param string $value The passed value
27     * @param helper_plugin_bureaucracy_field[] $fields (reference) form fields (POST handled upto $this field)
28     * @param int    $index  index number of field in form
29     * @param int    $formid unique identifier of the form which contains this field
30     * @return bool Whether the passed value is valid
31     */
32    public function handle_post($value, &$fields, $index, $formid) {
33        return true;
34    }
35
36    /**
37     * Get an arbitrary parameter
38     *
39     * @param string $name
40     * @return mixed|null
41     */
42    public function getParam($name) {
43        return ($name === 'value') ? null : parent::getParam($name);
44    }
45
46    /**
47     * Render the field as XHTML
48     *
49     * @params array     $params Additional HTML specific parameters
50     * @params Doku_Form $form   The target Doku_Form object
51     * @params int       $formid unique identifier of the form which contains this field
52     */
53    public function renderfield($params, Doku_Form $form, $formid) {
54        if (!isset($this->opt['display'])) {
55            $this->opt['display'] = $this->opt['label'];
56        }
57        parent::renderfield($params, $form, $formid);
58    }
59
60}
61