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