File: tableset_html.php

package info (click to toggle)
horde3 3.1.3-4etch7
  • links: PTS
  • area: main
  • in suites: etch
  • size: 22,876 kB
  • ctags: 18,071
  • sloc: php: 75,151; xml: 2,979; sql: 1,069; makefile: 79; sh: 64
file content (87 lines) | stat: -rw-r--r-- 3,108 bytes parent folder | download | duplicates (2)
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
<?php

require_once 'Horde/UI/VarRenderer/html.php';

/**
 * $Horde: framework/UI/UI/VarRenderer/tableset_html.php,v 1.3.2.1 2005/10/18 11:01:36 jan Exp $
 *
 * @package Horde_UI
 * @since   Horde 3.1
 */
class Horde_UI_VarRenderer_tableset_html extends Horde_UI_VarRenderer_html {

    function _renderVarInput_tableset(&$form, &$var, &$vars)
    {
        $header = $var->type->getHeader();
        $name   = $var->getVarName();
        $values = $var->getValues();
        $checkedValues = $var->getValue($vars);
        $actions = $this->_getActionScripts($form, $var);

        $html = '<table width="100%" class="item" cellspacing="1"><tr class="selected">' .
            '<th class="widget" align="right" width="1%">&nbsp;</th>';
        foreach ($header as $col_title) {
            $html .= sprintf('<th align="left" class="widget">%s</th>', $col_title);
        }
        $html .= '</tr>';

        if (!is_array($checkedValues)) {
            $checkedValues = array();
        }
        $i = 0;
        foreach ($values as $value => $displays) {
            $class = 'item' . ($i + 1) % 2;
            $checked = (in_array($value, $checkedValues)) ? ' checked="checked"' : '';
            $html .= sprintf('<tr class="%s">', $class) .
                sprintf('<td align="center"><input id="%s%s" type="checkbox" name="%s[]" value="%s"%s%s /></td>',
                        $name,
                        $i,
                        $name,
                        $value,
                        $checked,
                        $actions);
            foreach ($displays as $col) {
                $html .= sprintf('<td align="left">&nbsp;%s</td>', $col);
            }
            $html .= '</tr>';
            $i++;
        }

        return $html . '</table>';
    }

    function _renderVarDisplay_tableset(&$form, &$var, &$vars)
    {
        $header = $var->type->getHeader();
        $name   = $var->getVarName();
        $values = $var->getValues();
        $checkedValues = $var->getValue($vars);
        $actions = $this->_getActionScripts($form, $var);

        $html = '<table width="100%" cellspacing="1"><tr class="selected">' .
            '<th class="widget" align="right" width="1%">&nbsp;</th>';
        foreach ($header as $col_title) {
            $html .= sprintf('<th align="left" class="widget">%s</th>', $col_title);
        }
        $html .= '</tr>';

        if (!is_array($checkedValues)) {
            $checkedValues = array();
        }
        $i = 0;
        foreach ($values as $value => $displays) {
            $class   = 'item' . ($i + 1) % 2;
            $checked = (in_array($value, $checkedValues)) ? '[ <strong><font color=green>V</font></strong> ]' : '[ <strong><font color=red>X</font></strong> ]';
            $html .= sprintf('<tr class="%s">', $class) .
                sprintf('<td align="center">%s</td>', $checked);
            foreach ($displays as $col) {
                $html .= sprintf('<td align="left">&nbsp;%s</td>', $col);
            }
            $html .= '</tr>';
            $i++;
        }

        return $html . '</table>';
    }

}