19 if (
$res=
$db->query(
"SELECT * FROM {settings} WHERE property LIKE '".$property.
"%'")) {
20 $settingsArray = array();
21 while ($row =
$res->fetch_assoc())
23 $settingsArray[$row[
'property']] = $row;
28 \YAWK\sys::setSyslog(
$db, 35, 1,
"failed to get settings from database ", 0, 0, 0, 0);
29 \YAWK\alert::draw(
"warning",
"Warning!",
"Fetch database error: getSettingsArray failed.",
"",
"4800");
32 return $settingsArray;
44 if (
$res=
$db->query(
"SELECT property, value FROM {settings} WHERE property LIKE '".$property.
"%'")) {
45 $settingsArray = array();
46 while ($row =
$res->fetch_assoc())
48 $settingsArray[$row[
'property']] = $row[
'value'];
53 \YAWK\sys::setSyslog(
$db, 35, 1,
"failed to get settings from database ", 0, 0, 0, 0);
54 \YAWK\alert::draw(
"warning",
"Warning!",
"Fetch database error: getSettingsArray failed.",
"",
"4800");
57 return $settingsArray;
80 if (!isset($setting[
'fieldType']) && (empty($fieldType)))
82 $setting[
'fieldType'] =
"input";
87 if ($setting[
'type'] ===
"$type" && ($setting[
'activated'] ===
"1"))
91 if (isset($setting[
'icon']) && (!empty($setting[
'icon'])))
93 $setting[
'icon'] =
"<i class=\"$setting[icon]\"></i>";
97 $setting[
'icon'] =
'';
102 if (isset($setting[
'label']) && (!empty($setting[
'label'])))
104 $setting[
'label'] =
$lang[$setting[
'label']];
108 $setting[
'label'] =
'sorry, there is not label set. meh!';
113 if (isset($setting[
'heading']) && (!empty($setting[
'heading'])))
115 $setting[
'heading'] =
$lang[$setting[
'heading']];
119 $setting[
'heading'] =
'';
124 if (isset($setting[
'subtext']) && (!empty($setting[
'subtext'])))
126 $setting[
'subtext'] =
$lang[$setting[
'subtext']];
130 $setting[
'subtext'] =
'';
137 if (isset($setting[
'description']) && (!empty($setting[
'description'])))
139 $setting[
'description'] =
$lang[$setting[
'description']];
140 $setting[
'description'] =
" <small><i class=\"fa fa-question-circle-o text-info\" data-placement=\"auto right\" data-toggle=\"tooltip\" title=\"$setting[description]\"></i></small>";
144 $setting[
'description'] =
'';
148 if ($setting[
'options'] ===
"readonly")
150 $readonly =
" readonly";
151 $disabled =
" disabled";
160 if (isset($setting[
'placeholder']) && (!empty($setting[
'placeholder'])))
162 $ph = $setting[
'placeholder'];
163 $placeholder =
$lang[$ph];
171 if ($setting[
'fieldType'] ===
"checkbox")
173 if ($setting[
'value'] ===
"1")
175 $checked =
"checked";
181 if (!empty($setting[
'icon']) || (!empty($setting[
'heading']) || (!empty($setting[
'subtext']))))
183 echo
"<h3>$setting[icon] $setting[heading] <small>$setting[subtext]</small></h3>";
185 echo
"<input type=\"hidden\" name=\"$setting[property]\" value=\"0\">
186 <input type=\"checkbox\" id=\"$setting[property]\" name=\"$setting[property]\" value=\"1\" $checked>
187 <label style=\"margin-bottom:10px;\" for=\"$setting[property]\"> $setting[label] $setting[description]</label><br>";
191 if ($setting[
'fieldType'] ===
"radio")
193 echo
"<label for=\"$setting[property]\">$setting[label] $setting[description]</label>
194 <input style=\"margin-bottom:10px;\" type=\"radio\" id=\"$setting[property]\" name=\"$setting[property]\">";
195 echo
"<input type=\"radio\" value=\"$setting[value]\">$lang[SETTING_CURRENT] $setting[value]</option>";
197 $optionValues = explode(
":", $setting[
'options']);
198 foreach ($optionValues as
$value)
201 $optionValue = preg_replace(
"/,[a-zA-Z0-9]*/",
"",
$value);
203 $optionDesc = preg_replace(
'/.*,(.*)/',
'$1',
$value);
205 echo
"<option value=\"$optionValue\">$optionDesc</option>";
208 echo
"<p>$setting[description]</p>";
212 else if ($setting[
'fieldType'] ===
"select")
214 if (!empty($setting[
'icon']) || (!empty($setting[
'heading']) || (!empty($setting[
'subtext']))))
216 echo
"<h3>$setting[icon] $setting[heading] <small>$setting[subtext]</small></h3>";
219 if ($setting[
'property'] ===
"selectedTemplate")
221 echo
"<b>".$setting[
'label'].
" ".$setting[
'description'].
"</b>";
225 else if ($setting[
'property'] ===
"globalmenuid")
228 echo
"<label for=\"$setting[property]\">$setting[label] $setting[description]</label>
229 <select style=\"margin-bottom:10px;\" name=\"$setting[property]\" class=\"form-control\" id=\"$setting[property]\">";
230 echo
"<option value=\"$setting[value]\">$currentMenu</option>";
233 if ($row[
'id'] !== $setting[
'value']){
234 echo
"<option value=\"$row[id]\">$row[name]</option>";
238 echo
"<option value=\"0\">$lang[NO_ENTRY]</option>";
243 echo
"<label for=\"$setting[property]\">$setting[label] $setting[description]</label>
244 <select style=\"margin-bottom:10px;\" class=\"form-control\" id=\"$setting[property]\" name=\"$setting[property]\">";
245 echo
"<option value=\"$setting[value]\">$lang[SETTING_CURRENT] $setting[value]</option>";
247 $optionValues = explode(
":", $setting[
'options']);
248 foreach ($optionValues as
$value)
253 $optionDesc = preg_replace(
'/.*,(.*)/',
'$1',
$value);
254 $optionValue = preg_split(
"/,[a-zA-Z0-9]*/",
$value);
256 echo
"<option value=\"$optionValue[0]\">$optionDesc</option>";
265 else if ($setting[
'fieldType'] ===
"textarea")
267 if (!empty($setting[
'icon']) || (!empty($setting[
'heading']) || (!empty($setting[
'subtext']))))
269 echo
"<h3>$setting[icon] $setting[heading] <small>$setting[subtext]</small></h3>";
271 $placeholder = $setting[
'placeholder'];
272 if (isset($setting[
'longValue']) && (!empty($setting[
'longValue'])))
274 $setting[
'longValue'] = nl2br($setting[
'longValue']);
275 echo
"<label for=\"$setting[property]-long\">$setting[label] $setting[description]</label>
276 <textarea style=\"margin-bottom:10px;\" cols=\"64\" rows=\"4\" placeholder=\"$placeholder\" class=\"$setting[fieldClass]\" id=\"$setting[property]-long\" name=\"$setting[property]-long\"$disabled>$setting[longValue]</textarea>";
280 $placeholder = $setting[
'placeholder'];
281 $setting[
'value'] = nl2br($setting[
'value']);
282 echo
"<label for=\"$setting[property]-long\">$setting[label] $setting[description]</label>
283 <textarea style=\"margin-bottom:10px;\" cols=\"64\" rows=\"4\" placeholder=\"$placeholder\" class=\"$setting[fieldClass]\" id=\"$setting[property]\" name=\"$setting[property]\"$disabled>$setting[value]</textarea>";
288 else if ($setting[
'fieldType'] ===
"password")
290 $placeholder = $setting[
'placeholder'];
291 if (!empty($setting[
'icon']) || (!empty($setting[
'heading']) || (!empty($setting[
'subtext']))))
293 echo
"<h3>$setting[icon] $setting[heading] <small>$setting[subtext]</small></h3>";
295 echo
"<label for=\"$setting[property]\">$setting[label] $setting[description]</label>
296 <input style=\"margin-bottom:10px;\" type=\"password\" class=\"$setting[fieldClass]\" id=\"$setting[property]\" name=\"$setting[property]\"
297 value=\"$setting[value]\" placeholder=\"$placeholder\"$readonly$disabled>";
301 else if ($setting[
'fieldType'] ===
"input")
304 if (!empty($setting[
'icon']) || (!empty($setting[
'heading']) || (!empty($setting[
'subtext']))))
306 echo
"<h3>$setting[icon] $setting[heading] <small>$setting[subtext]</small></h3>";
308 echo
"<label for=\"$setting[property]\">$setting[label] $setting[description]</label>
309 <input style=\"margin-bottom:10px;\" type=\"text\" class=\"$setting[fieldClass]\" id=\"$setting[property]\" name=\"$setting[property]\"
310 value=\"$setting[value]\" placeholder=\"$placeholder\"$readonly$disabled>";
314 else if ($setting[
'fieldType'] ===
"color")
316 $placeholder = $setting[
'placeholder'];
317 if (!empty($setting[
'icon']) || (!empty($setting[
'heading']) || (!empty($setting[
'subtext']))))
319 echo
"<h3>$setting[icon] $setting[heading] <small>$setting[subtext]</small></h3>";
321 echo
"<label for=\"$setting[property]\">$setting[label] $setting[description]</label>
322 <input style=\"margin-bottom:10px;\" type=\"text\" class=\"$setting[fieldClass]\" id=\"$setting[property]\" name=\"$setting[property]\"
323 value=\"$setting[value]\">";
336 echo
"<h2>Language <small>override the selected language</small></h2>";
338 foreach (
$lang as $property=>$tag)
341 echo
"<label for=\"$property\">$property</label>
342 <input type=\"text\" id=\"$property\" class=\"form-control\" name=\"$property\" value=\"$tag\"><br>";
344 echo
"Total: ".$i.
" language tags found.";
355 if (
$res =
$db->query(
"SELECT * FROM {settings} WHERE type = $typeID"))
357 $settingsArray = array();
358 while ($row =
$res->fetch_assoc())
360 $settingsArray[] = $row;
365 \YAWK\sys::setSyslog(
$db, 35, 1,
"could not get settings for typeID $typeID ", 0, 0, 0, 0);
368 return $settingsArray;
380 if (!isset($typeID) || ($typeID == 0))
382 if (
$res =
$db->query(
"SELECT id FROM {settings_types} WHERE value = 'editor'"))
384 if ($row = mysqli_fetch_row(
$res))
391 \YAWK\sys::setSyslog(
$db, 35, 1,
"failed to get editor settings from database ", 0, 0, 0, 0);
392 \YAWK\alert::draw(
"danger",
"Could not fetch editor settings.",
"Settings type not set. Tried to fetch, but it seems that there is no setting type called editor.",
"", 6500);
396 if (
$res =
$db->query(
"SELECT * FROM {settings} WHERE type = $typeID"))
398 $editorSettingsArray = array();
399 while ($row =
$res->fetch_assoc())
401 if ($row[
'property'] ===
"editorLineNumbers") {
402 if ($row[
'value'] ==
"1") { $row[
'value'] =
"true"; }
else { $row[
'value'] =
"false"; }
404 if ($row[
'property'] ===
"editorSmartIndent") {
405 if ($row[
'value'] ==
"1") { $row[
'value'] =
"true"; }
else { $row[
'value'] =
"false"; }
407 if ($row[
'property'] ===
"editorActiveLine") {
408 if ($row[
'value'] ==
"1") { $row[
'value'] =
"true"; }
else { $row[
'value'] =
"false"; }
410 if ($row[
'property'] ===
"editorCloseBrackets") {
411 if ($row[
'value'] ==
"1") { $row[
'value'] =
"true"; }
else { $row[
'value'] =
"false"; }
413 if ($row[
'property'] ===
"editorCloseTags") {
414 if ($row[
'value'] ==
"1") { $row[
'value'] =
"true"; }
else { $row[
'value'] =
"false"; }
416 if ($row[
'property'] ===
"editorMatchBrackets") {
417 if ($row[
'value'] ==
"1") { $row[
'value'] =
"true"; }
else { $row[
'value'] =
"false"; }
419 if ($row[
'property'] ===
"editorMatchTags") {
420 if ($row[
'value'] ==
"1") { $row[
'value'] =
"true"; }
else { $row[
'value'] =
"false"; }
422 if ($row[
'property'] ===
"editorAutoCodeview") {
423 if ($row[
'value'] ==
"1") { $row[
'value'] =
"true"; }
else { $row[
'value'] =
"false"; }
425 $editorSettingsArray[$row[
'property']] = $row[
'value'];
432 return $editorSettingsArray;
444 if (
$res=
$db->query(
"SELECT * FROM {settings} ORDER by sortation"))
446 $settingsArray = array();
447 while ($row =
$res->fetch_assoc())
449 $settingsArray[] = $row;
454 \YAWK\sys::setSyslog(
$db, 35, 1,
"failed to get settings from database ", 0, 0, 0, 0);
458 return $settingsArray;
472 $sql =
$db->query(
"SELECT value FROM {settings} WHERE property = '".$property.
"'");
475 if ($row = mysqli_fetch_row(
$sql))
477 if (isset($row[0]) && (!empty($row[0])))
504 $property =
$db->quote($property);
506 if (
$res =
$db->query(
"UPDATE {settings} SET value = '".$value.
"' WHERE property = '".$property.
"'")) {
513 \YAWK\sys::setSyslog(
$db, 35, 1,
"failed to set <b>$value</b> to <b>$property</b> ", 0, 0, 0, 0);
514 \YAWK\alert::draw(
"warning",
"$lang[WARNING]",
"$lang[SETTING] $property $lang[NOT_SAVED]",
"",
"4800");
529 if (
$res =
$db->query(
"SELECT longValue FROM {settings} WHERE property = '".$property.
"'")) {
530 $row = mysqli_fetch_row(
$res);
536 \YAWK\sys::setSyslog(
$db, 35, 1,
"failed to get settings longValue from property <b>$property</b> ", 0, 0, 0, 0);
537 \YAWK\alert::draw(
"warning",
"Warning!",
"Fetch database error: getLongSetting failed.",
"",
"4800");
554 $property =
$db->quote($property);
556 if (
$res =
$db->query(
"UPDATE {template_settings} SET value = '".$value.
"' WHERE property = '".$property.
"'"))
558 \YAWK\alert::draw(
"success",
"Success!",
"Template setting $property saved.",
"",
"120");
563 \YAWK\sys::setSyslog(
$db, 35, 1,
"failed to set templateSetting <b>$value</b> to <b>$property</b> ", 0, 0, 0, 0);
564 \YAWK\alert::draw(
"danger",
"Error!",
"Sorry, could not save template setting $property.",
"",
"4800");
588 $property =
$db->quote($property);
590 if (
$res =
$db->query(
"UPDATE {settings} SET longValue = '".$value.
"' WHERE property = '".$property.
"'"))
597 \YAWK\sys::setSyslog(
$db, 35, 1,
"failed to set settings longValue <b>$value</b> to <b>$property</b> ", 0, 0, 0, 0);
598 \YAWK\alert::draw(
"danger",
"Error!",
"Sorry, update database error: could not set LongValue: ".
$value.
" - setLongSetting failed.",
"",
"4800");
614 if (
$res =
$db->query(
"SELECT description FROM {settings} WHERE property = '".$property.
"'")) {
615 $row = mysqli_fetch_row(
$res);
620 \YAWK\sys::setSyslog(
$db, 35, 1,
"failed to set settings description of <b>$property</b> ", 0, 0, 0, 0);
621 \YAWK\alert::draw(
"warning",
"Warning!",
"Error loading setting description of property $property",
"",
"4800");
637 if (
$res =
$db->query(
"SELECT value FROM {widget_settings}
638 WHERE property = '".$property.
"' AND widgetID = '".$widgetID.
"'")) {
639 $row = mysqli_fetch_row(
$res);
645 \YAWK\sys::setSyslog(
$db, 35, 1,
"failed to get widget setting of <b>$property</b> ", 0, 0, 0, 0);
646 \YAWK\alert::draw(
"warning",
"Warning!",
"Error loading Widget Setting $property",
"",
"4800");
664 $property =
$db->quote($property);
668 if (
$res =
$db->query(
"UPDATE {widget_settings} SET value = '".$value.
"'
669 WHERE property = '".$property.
"' AND widgetID = '".$widgetID.
"'"))
678 \YAWK\sys::setSyslog(
$db, 35, 1,
"failed to set widget value <b>$value</b> of <b>$property</b> ", 0, 0, 0, 0);
679 \YAWK\alert::draw(
"danger",
"Error!",
"Sorry, update database error: could not set Widget Setting $value of property $property.",
"",
"4800");
698 $property =
$db->quote($property);
699 $new_status =
$db->quote($new_status);
700 if (
$res =
$db->query(
"UPDATE {settings} SET activated = '" . $new_status .
"'
701 WHERE property = '" . $property .
"'"))
707 \YAWK\sys::setSyslog(
$db, 35, 1,
"failed to toggle <b>$new_status</b> of <b>$property</b> ", 0, 0, 0, 0);
708 \YAWK\alert::draw(
"danger",
"Error!",
"$lang[TOGGLE_FAILED] $property $lang[TO] $new_status",
"",
"4800");
print $lang['SAVE_SETTINGS']
static draw($type, $title, $text, $redirect, $delay)
static drawTemplateSelectField($db, $description)
Draw a SELECT field with all templates, current active template is selected.
static getMenuNamesArray($db)
return all menu ids and names as array
Settings class: get and set YaWK system settings.
static setSetting($db, $property, $value, $lang)
Set value for property into settings database.
static getAllSettingsIntoArray($db)
Returns an array with all settings data.
static getSettingsByType($db, $typeID)
get all settings by typeID
static toggleOffline($db, $property, $new_status, $lang)
Toggle setting offline where requested property.
static setWidgetSetting($db, $property, $value, $widgetID)
Set widget setting value into widgets_settings.
static getCurrentLanguageFormElements($lang)
override the current language
static getWidgetSetting($db, $property)
Get widget setting value from widgets_settings.
static setTemplateSetting($db, $property, $value)
Set (update) template setting value for property.
static getSetting($db, $property)
Get and return value for property from settings database.
static setLongSetting($db, $property, $value)
Set (update) long setting value for property.
static getFormElements($db, $settings, $type, $lang)
Return corresponding form elements for given settings.
static getEditorSettings($db, $typeID=0)
Returns an associative array containing the editor settings.
static getValueSettingsArray($db, $property)
Returns an array containing property as key and values corresponding to this property where p like $p...
static getSettingDescription($db, $property)
Get setting description from requested property.
static getLongSetting($db, $property)
Get and return longValue for property from settings database.
static getAllSettingsArray($db, $property)
Returns an array with all setings where property is like $property.
This class serves methods to create backup from files.