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