1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37:
38: function renderSelectProperty($name, $possibleValues, $value, $label, $width = 328) {
39: global $auth;
40:
41: $return = array();
42:
43: if (count($possibleValues) === 2 && (in_array('true', $possibleValues) && in_array('false', $possibleValues) || in_array('enabled', $possibleValues) && in_array('disabled', $possibleValues) || in_array('0', $possibleValues) && in_array('1', $possibleValues))) {
44:
45: $checked = $value == 'true' || $value == '1' || $value == 'enabled';
46: $html = new cHTMLCheckbox($name, $possibleValues[0], $name, $checked);
47: $html->setLabelText($label);
48: $return['label'] = '';
49: } else {
50:
51: $html = new cHTMLSelectElement($name);
52: foreach ($possibleValues as $possibleValue) {
53: $element = new cHTMLOptionElement($possibleValue, $possibleValue);
54: if ($possibleValue == $value) {
55: $element->setSelected(true);
56: }
57: $html->appendOptionElement($element);
58: }
59:
60:
61: if ($name == 'versioning{_}enabled') {
62: $html->setStyle('float:left;padding:3px;width:' . $width . 'px;');
63: $return['label'] =
64: ' <div>
65: <span style="width: 284px; display: inline-block; padding: 0px 0px 0px 2px; float:left;">
66: <span style="margin: 0px 10px 0px 0px;">' . i18n("Article versioning") . ':' . '</span>
67: <a
68: href="#"
69: id="pluginInfoDetails-link"
70: class="main i-link infoButton"
71: title="">
72: </a>
73: </span>
74: ' . $html->render() . '
75: </div>
76: <div id="pluginInfoDetails" class="nodisplay">'
77: . i18n('<p><strong>Article versioning:</strong></p>'
78: . '<ul style="list-style:none;">'
79: . '<li>'
80: . 'Review and restore older versions (simple) and create drafts (advanced).'
81: . ' Versions are generated automatically by changing an article.'
82: . '</li>'
83: . '</ul>'
84: . '<p><strong>Modes:</strong></p>'
85: . '<ul class="list">'
86: . '<li class="first"><strong>disabled: </strong> The article versioning is disabled.</li>'
87: . '<li><strong>simple: </strong>Older article versions can be reviewed and restored.</li>'
88: . '<li><strong>advanced: </strong>Additional to the simple-mode, unpublished drafts can be created.</li>'
89: . '</ul>'
90: . '<p><strong>Further informations</strong> can be found in related tabs (Content/Articles/Properties|SEO|Raw data|Editor).</p>'
91: . '</div>');
92: } else {
93: $html->setStyle('padding:3px;display:block;float:left;width:' . $width . 'px;');
94: $return['label'] = renderLabel($label, $name, 280, ':', 'left');
95: }
96:
97: }
98:
99:
100: if (strpos($auth->auth['perm'], 'sysadmin') === false) {
101: $html->updateAttribute('disabled', 'true');
102: }
103:
104:
105: if ($name != 'versioning{_}enabled') {
106: $return['input'] = $html->render();
107: }
108:
109: return $return;
110: }
111:
112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126:
127: function renderLabel($text, $name, $width = 280, $seperator = ':', $float = '') {
128: $label = new cHTMLLabel($text . $seperator, $name);
129: $label->setClass("sys_config_txt_lbl");
130: if ($float != '') {
131: $label->setStyle('width:' . $width . 'px;' . 'float:' . $float . ';');
132: } else {
133: $label->setStyle('width:' . $width . 'px;');
134: }
135:
136:
137:
138: return $label->render();
139: }
140:
141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156:
157: function renderTextProperty($name, $value, $label, $password = false) {
158: global $auth;
159:
160: $textbox = new cHTMLTextbox($name, conHtmlSpecialChars($value), '50', '96');
161: $textbox->updateAttribute('style', 'width:322px');
162:
163: if (strpos($auth->auth['perm'], 'sysadmin') === false) {
164: $textbox->updateAttribute('disabled', 'true');
165: }
166: if ($password === true) {
167: $textbox->updateAttribute('type', 'password');
168: }
169:
170: $return = array();
171: $return['input'] = $textbox->render();
172: $return['label'] = renderLabel($label, $name);
173:
174: return $return;
175: }
176:
177: $page = new cGuiPage('system_configuration', '', '1');
178:
179:
180: $propertyTypes = cXmlReader::xmlStringToArray(cFileHandler::read($cfg['path']['xml'] . 'system.xml'));
181: $propertyTypes = $propertyTypes['properties'];
182:
183:
184: $settings = getSystemProperties();
185:
186: $reloadHeader = false;
187:
188: if (isset($_POST['action']) && $_POST['action'] == 'edit_sysconf' && $perm->have_perm_area_action($area, 'edit_sysconf')) {
189: if (strpos($auth->auth['perm'], 'sysadmin') === false) {
190: $page->displayError(i18n('You don\'t have the permission to make changes here.'));
191: } else {
192:
193: if (defined('CON_STRIPSLASHES')) {
194: $post = cString::stripSlashes($_POST);
195: } else {
196: $post = $_POST;
197: }
198: $stored = false;
199: foreach ($propertyTypes as $type => $properties) {
200: foreach ($properties as $name => $infos) {
201:
202: $fieldName = $type . '{_}' . $name;
203: if (isset($post[$fieldName])) {
204: $value = $post[$fieldName];
205: } else {
206: $value = (isset($infos['values'][1])) ? $infos['values'][1] : 'false';
207: }
208:
209: $storedValue = $settings[$type][$name];
210: if ($storedValue != $value && (is_array($infos['values']) && $value != '' || !is_array($infos['values']))) {
211: if ($type == 'update' && $name == 'check_period' && $value < 60) {
212: $page->displayError(i18n('Update check period must be at least 60 minutes.'));
213: $stored = false;
214:
215: break 2;
216: } else {
217: setSystemProperty($type, $name, $value);
218:
219: $settings[$type][$name] = $value;
220: $stored = true;
221:
222: if (($type == 'debug' && $name == 'debug_to_screen') || ($type == 'system' && $name == 'clickmenu')) {
223: $reloadHeader = true;
224: }
225: }
226: }
227: }
228: }
229: if ($stored) {
230: $page->displayOk(i18n('Changes saved'));
231: }
232: }
233: }
234:
235:
236: $form = new cGuiTableForm('system_configuration');
237: $form->addHeader(i18n('System configuration'));
238: $form->setVar('area', $area);
239: $form->setVar('frame', $frame);
240: $form->setVar('action', 'edit_sysconf');
241:
242:
243: if (strpos($auth->auth['perm'], 'sysadmin') === false) {
244: $form->setActionButton('submit', cRegistry::getBackendUrl() . 'images/but_ok_off.gif', i18n("You are not sysadmin. You can't change these settings."), 's');
245: }
246:
247: $groups = array();
248: $currentGroup = '';
249: $leftContent = '';
250:
251: foreach ($propertyTypes as $type => $properties) {
252: foreach ($properties as $name => $infos) {
253:
254:
255: if (!isset($groups[$infos['group']])) {
256: $groups[$infos['group']] = '';
257: }
258:
259:
260: if (isset($settings[$type][$name])) {
261: $value = $settings[$type][$name];
262: } else {
263: $value = '';
264: }
265:
266:
267: $fieldName = $type . '{_}' . $name;
268: if (is_array($infos['values'])) {
269: $htmlElement = renderSelectProperty($fieldName, $infos['values'], $value, i18n($infos['label']));
270: } else {
271: if (strlen($name) > 5 && substr($name, -5) === '_pass') {
272: $htmlElement = renderTextProperty($fieldName, $value, i18n($infos['label']), true);
273: } else {
274: $htmlElement = renderTextProperty($fieldName, $value, i18n($infos['label']));
275: }
276: }
277:
278: $groups[$infos['group']] .= new cHTMLDiv($htmlElement['label'] . $htmlElement['input'], 'systemSetting');
279: }
280: }
281:
282:
283: foreach ($groups as $groupName => $groupSettings) {
284: $groupName = i18n($groupName);
285: $form->add(renderLabel($groupName, '', 150, ''), $groupSettings);
286: }
287:
288:
289: if ($perm->have_perm_area_action($area, 'edit_sysconf')) {
290: $page->set('s', 'RELOAD_HEADER', ($reloadHeader) ? 'true' : 'false');
291: $page->set('s', 'FORM', $form->render());
292: } else {
293: $page->displayCriticalError(i18n('Access denied'));
294: }
295:
296: $page->render();
297: