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: * @return string|void
53: * Complete template string or nothing
54: */
55: public function render($print = false) {
56: global $cfg;
57:
58: $backendPath = cRegistry::getBackendPath();
59:
60: $tpl = new cTemplate();
61: $tpl2 = new cTemplate();
62:
63: $colcount = 0;
64:
65: if (is_array($this->cells)) {
66: foreach ($this->cells as $row => $cells) {
67: $thefont = '';
68: $unne = '';
69:
70: $colcount++;
71:
72: $content = "";
73: $count = 0;
74:
75: foreach ($cells as $key => $value) {
76: $count++;
77: $tpl2->reset();
78:
79: $tpl2->set('s', 'CONTENT', $value);
80: if ($colcount == 1) {
81: $content .= $tpl2->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['generic_list_head'], true);
82: } else {
83: $content .= $tpl2->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['generic_list_row'], true);
84: }
85: }
86:
87: $tpl->set('d', 'ROWS', $content);
88: $tpl->next();
89: }
90: }
91:
92: $rendered = $tpl->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['generic_list'], true);
93:
94: if ($print == true) {
95: echo $rendered;
96: } else {
97: return $rendered;
98: }
99: }
100:
101: }
102: