File size: 3,731 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php

/**
 *
 * @package gulliver.system
 */
class XmlFormFieldLabel extends XmlFormField
{
    public $withoutValue = true;
    public $align = 'left';
}

/**
 * Special class for pagedTable
 * condition: PHP expression whose result defines whether to "mark"
 * the following columns (that is if true)
 *
 * @package gulliver.system
 */
class XmlFormFieldCellMark extends XmlFormField
{
    /* Defines the style of the next tds
      of the pagedTable.
     */
    public $showInTable = "0";
    public $style = "";
    public $styleAlt = "";
    public $className = "";
    public $classNameAlt = "";
    public $condition = 'false';

    /**
     * tdStyle
     *
     * @param string $values
     * @param string $owner
     *
     * @return string $value
     */
    public function tdStyle($values, $owner)
    {
        $value = G::replaceDataField($this->condition, $owner->values);
        $value = @eval('return (' . $value . ');');
        $row = $values['row__'];
        $style = ((($row % 2) == 0) && ($this->styleAlt != 0)) ? $this->styleAlt : $this->style;
        return ($value) ? $style : '';
    }

    /**
     * tdClass
     *
     * @param string $values
     * @param string $owner
     *
     * @return $value
     */
    public function tdClass($values, $owner)
    {
        $value = G::replaceDataField($this->condition, $owner->values);
        $value = @eval('return (' . $value . ');');
        $row = $values['row__'];
        $style = (($row % 2) == 0) ? $this->classNameAlt : $this->className;
        return ($value) ? $style : '';
    }
}

/**
 * XmlFormFieldDVEditor
 *
 * extends XmlFormField
 *
 * @package gulliver.system
 *
 */
class XmlFormFieldDVEditor extends XmlFormField
{
    public $toolbarSet = 'toolbar2lines.html';
    public $width = '90%';
    public $height = '200';

    /**
     * render
     *
     * @param string $value
     * @param string $owner default value NULL
     *
     * @return string '<div> ... </div>'
     */
    public function render($value = null, $owner = null)
    {
        return '<div style="width:' . htmlentities($this->width, ENT_QUOTES, 'utf-8') . ';height:' . htmlentities($this->height, ENT_QUOTES, 'utf-8') . '"><input id="form[' . $this->name . ']" name="form[' . $this->name . ']" type="hidden" value="' . htmlentities($value, ENT_QUOTES, 'UTF-8') . '"/></div>';
    }

    /**
     * attachEvents
     *
     * @param string $element
     *
     * @return $html
     */
    public function attachEvents($element)
    {
        $html = 'var _editor' . $this->name . '=new DVEditor(getField("form[' . $this->name . ']").parentNode,getField("form[' . $this->name . ']").value)';
        return $html;
    }
}

/**
 * Special field: Add a search box (fast search) for the related pagedTable
 *
 * The PAGED_TABLE_ID reserved field must be defined in the xml.
 * Use PAGED_TABLE_FAST_SEARCH reserved field, it contains the saved value for each table.
 * example:
 * Ex1.
 * <PAGED_TABLE_ID type="private"/>
 * <PAGED_TABLE_FAST_SEARCH type="FastSearch">
 * <en>Search</en>
 * </PAGED_TABLE_FAST_SEARCH>
 * Ex2 (Using type="text").
 * <PAGED_TABLE_ID type="private"/>
 * <PAGED_TABLE_FAST_SEARCH type="text" colAlign="right" colWidth="180" onkeypress="if (event.keyCode===13)@#PAGED_TABLE_ID.doFastSearch(this.value);if (event.keyCode===13)return false;">
 * <en>Search</en>
 * </PAGED_TABLE_FAST_SEARCH>
 *
 * @package gulliver.system
 */
class XmlFormFieldFastSearch extends XmlFormFieldText
{
    public $onkeypress = "if (event.keyCode===13)@#PAGED_TABLE_ID.doFastSearch(this.value);if (event.keyCode===13)return false;";
    public $colAlign = "right";
    public $colWidth = "180";
    public $label = "@G::LoadTranslation(ID_SEARCH)";
}