1: <?php
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: class DEnumView extends AlphaView {
49: 50: 51: 52: 53: 54:
55: public function listView() {
56: global $config;
57:
58: $reflection = new ReflectionClass(get_class($this->BO));
59: $properties = $reflection->getProperties();
60: $labels = $this->BO->getDataLabels();
61: $colCount = 1;
62:
63: $html = '<table class="list_view">';
64: $html .= '<form action="'.$_SERVER['REQUEST_URI'].'" method="POST">';
65:
66: $html .= '<tr>';
67: foreach($properties as $propObj) {
68: $prop = $propObj->name;
69: if (!in_array($prop, $this->BO->getDefaultAttributes()) && !in_array($prop, $this->BO->getTransientAttributes())) {
70: if (get_class($this->BO->getPropObject($prop)) != 'Text') {
71: $colCount ++;
72: $html .= ' <th>'.$labels[$prop].'</th>';
73: }
74: }
75: if ($prop == 'OID')
76: $html .= ' <th>'.$labels[$prop].'</th>';
77: }
78:
79: $html .= ' <th>Item count</th>';
80:
81: $html .= '</tr><tr>';
82:
83:
84: foreach($properties as $propObj) {
85: $prop = $propObj->name;
86: if (!in_array($prop, $this->BO->getDefaultAttributes()) && !in_array($prop, $this->BO->getTransientAttributes())) {
87: if (get_class($this->BO->getPropObject($prop)) != 'Text') {
88: $html .= ' <td> '.$this->BO->get($prop).'</td>';
89: }
90: }
91: if ($prop == 'OID')
92: $html .= ' <td> '.$this->BO->getID().'</td>';
93: }
94:
95: $html .= ' <td> '.$this->BO->getItemCount().'</td>';
96:
97: $html .= '</tr>';
98:
99: $html .= '<tr><td colspan="'.($colCount+1).'" align="center">';
100:
101: if (isset($_SESSION['currentUser']) && $_SESSION['currentUser']->inGroup('Admin')) {
102: $html .= ' ';
103: $button = new Button("document.location = '".FrontController::generateSecureURL('act=EditDEnum&oid='.$this->BO->getOID())."'", "Edit", "edit".$this->BO->getOID()."But");
104: $html .= $button->render();
105: }
106: $html .= '</td></tr>';
107:
108: $html .= '</form>';
109: $html .= '</table>';
110:
111: return $html;
112: }
113:
114: 115: 116: 117: 118: 119:
120: public function editView() {
121: global $config;
122:
123: $labels = $this->BO->getDataLabels();
124: $obj_type = '';
125:
126: $html = '<table cols="2" class="edit_view">';
127: $html .= '<form action="'.$_SERVER['REQUEST_URI'].'" method="POST">';
128:
129: $temp = new StringBox($this->BO->getPropObject('name'), $labels['name'], 'name', '', 0, true, true);
130: $html .= $temp->render();
131:
132: $html .= '<tr><td colspan="2"><h3>DEnum display values:</h3></td></tr>';
133:
134:
135: $denum = $this->BO;
136: $tmp = new DEnumItem();
137: $denumItems = $tmp->loadItems($denum->getID());
138:
139: foreach ($denumItems as $item) {
140: $labels = $item->getDataLabels();
141: $temp = new StringBox($item->getPropObject('value'), $labels['value'], 'value_'.$item->getID(), '');
142: $html .= $temp->render();
143: }
144:
145: $html .= '<input type="hidden" name="version_num" value="'.$this->BO->getVersion().'"/>';
146:
147: $html .= '<tr><td colspan="2"><h3>Add a new value to the DEnum dropdown list:</h3></td></tr>';
148:
149: $temp = new StringBox(new String(), 'Dropdown value', 'new_value', '');
150: $html .= $temp->render();
151:
152: $html .= '<tr><td colspan="2">';
153:
154: $temp = new Button('submit', 'Save', 'saveBut');
155: $html .= $temp->render();
156: $html .= ' ';
157: $temp = new Button("document.location = '".FrontController::generateSecureURL('act=ListDEnums')."'", 'Back to List', 'cancelBut');
158: $html .= $temp->render();
159: $html .= '</td></tr>';
160:
161: $html .= AlphaView::renderSecurityFields();
162:
163: $html .= '</form></table>';
164:
165: return $html;
166: }
167: }
168:
169: ?>