1: <?php
2:
3: /**
4: * This file contains the list GUI class.
5: *
6: * @package Core
7: * @subpackage GUI
8: * @author Timo Hummel
9: * @copyright four for business AG <www.4fb.de>
10: * @license http://www.contenido.org/license/LIZENZ.txt
11: * @link http://www.4fb.de
12: * @link http://www.contenido.org
13: */
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: /**
18: * List GUI class
19: *
20: * @package Core
21: * @subpackage GUI
22: */
23: class cGuiList {
24:
25: /**
26: *
27: * @todo names of protected members should have a leading underscore
28: * @var array
29: */
30: protected $cells;
31:
32: /**
33: * Constructor to create an instance of this class.
34: */
35: public function __construct() {
36: $this->cells = array();
37: }
38:
39: /**
40: *
41: * @param string|int $item
42: * @param string|int $cell
43: * @param string $value
44: */
45: public function setCell($item, $cell, $value) {
46: $this->cells[$item][$cell] = $value;
47: }
48:
49: /**
50: *
51: * @param bool $print [optional]
52: *
53: * @return string|void
54: * Complete template string or nothing
55: * @throws cInvalidArgumentException
56: */
57: public function render($print = false) {
58: global $cfg;
59:
60: $backendPath = cRegistry::getBackendPath();
61:
62: $tpl = new cTemplate();
63: $tpl2 = new cTemplate();
64:
65: $colcount = 0;
66:
67: if (is_array($this->cells)) {
68: foreach ($this->cells as $row => $cells) {
69: $thefont = '';
70: $unne = '';
71:
72: $colcount++;
73:
74: $content = "";
75: $count = 0;
76:
77: foreach ($cells as $key => $value) {
78: $count++;
79: $tpl2->reset();
80:
81: $tpl2->set('s', 'CONTENT', $value);
82: if ($colcount == 1) {
83: $content .= $tpl2->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['generic_list_head'], true);
84: } else {
85: $content .= $tpl2->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['generic_list_row'], true);
86: }
87: }
88:
89: $tpl->set('d', 'ROWS', $content);
90: $tpl->next();
91: }
92: }
93:
94: $rendered = $tpl->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['generic_list'], true);
95:
96: if ($print == true) {
97: echo $rendered;
98: } else {
99: return $rendered;
100: }
101: }
102:
103: }
104: