1<?php
2/**
3 * Class helper_plugin_bureaucracy_fieldaddpage
4 *
5 * Adds another page page_tgt based on a template page page_tpl only for use with the template action
6 */
7class helper_plugin_bureaucracy_fieldaddpage extends helper_plugin_bureaucracy_field {
8
9    /**
10     * Arguments:
11     *  - cmd
12     *  - page_tpl
13     *  - page_tgt
14     *
15     * @param array $args The tokenized definition, only split at spaces
16     */
17    function initialize($args) {
18        if(count($args) < 3){
19            msg(sprintf($this->getLang('e_missingargs'), hsc($args[0]),
20                        hsc($args[1])), -1);
21            return;
22        }
23
24        // get standard arguments
25        $this->opt = array_combine(array('cmd', 'page_tpl', 'page_tgt'), $args);
26    }
27
28    /**
29     * Nothing displayed
30     *
31     * @params array     $params Additional HTML specific parameters
32     * @params Doku_Form $form   The target Doku_Form object
33     * @params int       $formid unique identifier of the form which contains this field
34     */
35    function renderfield($params, Doku_Form $form, $formid) {
36    }
37
38    /**
39     * Handle a post to the field
40     *
41     * @param string $value null
42     * @param helper_plugin_bureaucracy_field[] $fields (reference) form fields (POST handled upto $this field)
43     * @param int    $index  index number of field in form
44     * @param int    $formid unique identifier of the form which contains this field
45     * @return bool Whether the passed value is valid
46     */
47    function handle_post($value, &$fields, $index, $formid) {
48        return true;
49    }
50
51    /**
52     * Get an arbitrary parameter
53     *
54     * @param string $name
55     * @return mixed|null
56     */
57    function getParam($name) {
58        return ($name === 'value' ||
59                (in_array($name, array('page_tpl', 'page_tgt')) && $this->hidden)) ?
60               null :
61               parent::getParam($name);
62    }
63}
64