2018-07-13 18:39:55 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) Codiad & Andr3as, distributed
|
|
|
|
* as-is and without warranty under the MIT License. See
|
|
|
|
* [root]/license.txt for more. This information must remain intact.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once('../../common.php');
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
// Verify Session or Key
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
checkSession();
|
|
|
|
|
|
|
|
if (!isset($_GET['action'])) {
|
|
|
|
$_GET['action'] = "settings";
|
|
|
|
}
|
|
|
|
|
|
|
|
switch($_GET['action']) {
|
|
|
|
case "settings":
|
2018-12-21 17:43:51 +01:00
|
|
|
?>
|
2018-07-13 18:39:55 +02:00
|
|
|
<div class="settings-view">
|
|
|
|
<div class="config-menu">
|
|
|
|
<label><?php i18n("Settings"); ?></label>
|
|
|
|
<div class="panels-components">
|
|
|
|
<ul>
|
|
|
|
<li name="editor-settings" data-file="components/settings/settings.editor.php" data-name="editor" class="active">
|
|
|
|
<a><span class="icon-home bigger-icon"></span><?php i18n("Editor"); ?></a>
|
|
|
|
</li>
|
|
|
|
<li name="system-settings" data-file="components/settings/settings.system.php" data-name="system">
|
|
|
|
<a><span class="icon-doc-text bigger-icon"></span><?php i18n("System"); ?></a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
<div class="panels-plugins">
|
|
|
|
<?php
|
|
|
|
$plugins = Common::readDirectory(PLUGINS);
|
|
|
|
|
|
|
|
foreach($plugins as $plugin){
|
|
|
|
if(file_exists(PLUGINS . "/" . $plugin . "/plugin.json")){
|
|
|
|
$datas = json_decode(file_get_contents(PLUGINS . "/" . $plugin . "/plugin.json"), true);
|
|
|
|
foreach($datas as $data) {
|
|
|
|
if (isset($data['config'])) {
|
|
|
|
foreach($data['config'] as $config) {
|
|
|
|
if(isset($config['file']) && isset($config['icon']) && isset($config['title'])) {
|
|
|
|
echo('<li data-file="plugins/' . $plugin . '/' .$config['file'].'" data-name="'. $data['name'] .'">
|
|
|
|
<a><span class="' . $config['icon'] . ' bigger-icon"></span>' . $config['title'] . '</a></li>');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="panels">
|
|
|
|
<div class="panel active" data-file="components/settings/settings.editor.php">
|
|
|
|
<?php include('settings.editor.php'); ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-02-06 23:52:49 +01:00
|
|
|
<button class="btn-left" onclick="save(); return false;"><?php i18n("Save"); ?></button>
|
2018-07-13 18:39:55 +02:00
|
|
|
<button class="btn-right" onclick="codiad.modal.unload(); return false;"><?php i18n("Close"); ?></button>
|
2018-12-21 17:43:51 +01:00
|
|
|
<div class="loading"></div>
|
2018-07-13 18:39:55 +02:00
|
|
|
<script>
|
2018-10-09 21:30:00 +02:00
|
|
|
|
|
|
|
var settings = {};
|
2018-07-13 18:39:55 +02:00
|
|
|
$('.settings-view .config-menu li').click(function(){
|
|
|
|
codiad.settings._showTab($(this).attr('data-file'));
|
|
|
|
});
|
2018-10-09 21:30:00 +02:00
|
|
|
|
2018-07-13 18:39:55 +02:00
|
|
|
function save() {
|
2018-12-21 17:43:51 +01:00
|
|
|
codiad.modal.show_loading();
|
2018-07-13 18:39:55 +02:00
|
|
|
$('.setting').each(function(){
|
|
|
|
var setting = $(this).data('setting');
|
|
|
|
var val = $(this).val();
|
2019-01-15 16:33:59 +01:00
|
|
|
if( val===null ){
|
2018-07-13 18:39:55 +02:00
|
|
|
codiad.message.alert(i18n("You Must Choose A Value"));
|
|
|
|
return;
|
2019-01-15 16:33:59 +01:00
|
|
|
} else {
|
2018-10-09 21:30:00 +02:00
|
|
|
switch(setting) {
|
2018-07-13 18:39:55 +02:00
|
|
|
case 'codiad.editor.theme':
|
|
|
|
codiad.editor.setTheme(val);
|
|
|
|
break;
|
|
|
|
case 'codiad.editor.fontSize':
|
|
|
|
codiad.editor.setFontSize(val);
|
|
|
|
break;
|
|
|
|
case 'codiad.editor.highlightLine':
|
|
|
|
var bool_val = (val == "true");
|
|
|
|
codiad.editor.setHighlightLine(bool_val);
|
|
|
|
break;
|
|
|
|
case 'codiad.editor.indentGuides':
|
|
|
|
var bool_val = (val == "true");
|
|
|
|
codiad.editor.setIndentGuides(bool_val);
|
|
|
|
break;
|
|
|
|
case 'codiad.editor.printMargin':
|
|
|
|
var bool_val = (val == "true");
|
|
|
|
codiad.editor.setPrintMargin(bool_val);
|
|
|
|
break;
|
|
|
|
case 'codiad.editor.printMarginColumn':
|
|
|
|
var int_val = (!isNaN(parseFloat(val)) && isFinite(val))
|
|
|
|
? parseInt(val, 10)
|
|
|
|
: 80;
|
|
|
|
codiad.editor.setPrintMarginColumn(int_val);
|
|
|
|
break;
|
|
|
|
case 'codiad.editor.wrapMode':
|
|
|
|
var bool_val = (val == "true");
|
|
|
|
codiad.editor.setWrapMode(bool_val);
|
|
|
|
break;
|
|
|
|
case 'codiad.editor.rightSidebarTrigger':
|
|
|
|
var bool_val = (val == "true");
|
|
|
|
codiad.editor.setRightSidebarTrigger(bool_val);
|
|
|
|
break;
|
|
|
|
case 'codiad.editor.fileManagerTrigger':
|
|
|
|
var bool_val = (val == "true");
|
|
|
|
codiad.editor.setFileManagerTrigger(bool_val);
|
|
|
|
break;
|
|
|
|
case 'codiad.editor.persistentModal':
|
|
|
|
var bool_val = (val == "true");
|
|
|
|
codiad.editor.setPersistentModal(bool_val);
|
|
|
|
break;
|
|
|
|
case "codiad.editor.softTabs":
|
|
|
|
var bool_val = (val == "true");
|
|
|
|
codiad.editor.setSoftTabs(bool_val);
|
|
|
|
break;
|
|
|
|
case "codiad.editor.tabSize":
|
|
|
|
codiad.editor.setTabSize(val);
|
|
|
|
break;
|
2018-09-21 03:44:10 +02:00
|
|
|
case "codiad.editor.overScroll":
|
|
|
|
codiad.editor.setOverScroll(val);
|
|
|
|
break;
|
2018-12-11 22:52:53 +01:00
|
|
|
case "codiad.editor.autocomplete":
|
2019-02-07 19:55:17 +01:00
|
|
|
var bool_val = (val == "true");
|
2018-12-11 22:52:53 +01:00
|
|
|
codiad.editor.setLiveAutocomplete(bool_val)
|
|
|
|
break;
|
2019-01-15 16:33:59 +01:00
|
|
|
case "codiad.settings.autosave":
|
|
|
|
var bool_val = (val == "true");
|
2019-02-07 19:55:17 +01:00
|
|
|
break;
|
Changed $path to __DIR__ for config location, Updated auto reload variables, Removed unload listener for auto reload, Changed project default to array so that if no projects exist the program does not crash, Updated autosave to use let instead of vars, Fixed capitalization for sideExpanded variable, Added try catch to pdo initialization on install, Added more error checks on install, Removed password function on install query, Changed default settings array, Added loading div to user delete, Updated queries that threw errors when a default value was zero, Added blank username and password check,
2019-02-09 22:14:27 +01:00
|
|
|
case "codiad.filemanager.autoReloadPreview":
|
2019-02-07 19:55:17 +01:00
|
|
|
var bool_val = (val == "true");
|
2019-01-15 16:33:59 +01:00
|
|
|
break;
|
2018-07-13 18:39:55 +02:00
|
|
|
}
|
|
|
|
}
|
2018-10-09 21:30:00 +02:00
|
|
|
|
2019-01-15 16:33:59 +01:00
|
|
|
if( bool_val != undefined && bool_val != null ) {
|
|
|
|
|
|
|
|
if( bool_val ) {
|
|
|
|
|
|
|
|
val = "true";
|
|
|
|
} else {
|
|
|
|
|
|
|
|
val = "false";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-09 21:30:00 +02:00
|
|
|
//localStorage.setItem(setting, val);
|
2019-01-15 16:33:59 +01:00
|
|
|
settings[setting] = val;
|
|
|
|
bool_val = null;
|
2018-07-13 18:39:55 +02:00
|
|
|
});
|
|
|
|
/* Notify listeners */
|
2019-01-15 16:33:59 +01:00
|
|
|
amplify.publish( 'settings.dialog.save', null );
|
2018-10-09 21:30:00 +02:00
|
|
|
codiad.settings.save( settings );
|
2018-07-13 18:39:55 +02:00
|
|
|
}
|
|
|
|
</script>
|
2018-12-21 17:43:51 +01:00
|
|
|
<?php
|
2018-07-13 18:39:55 +02:00
|
|
|
break;
|
|
|
|
case "iframe":
|
2018-12-21 17:43:51 +01:00
|
|
|
?>
|
2018-07-13 18:39:55 +02:00
|
|
|
<script>
|
|
|
|
/*
|
|
|
|
* Storage Event:
|
|
|
|
* Note: Event fires only if change was made in different window and not in this one
|
|
|
|
* Details: http://dev.w3.org/html5/webstorage/#dom-localstorage
|
|
|
|
*/
|
|
|
|
window.addEventListener('storage', function(e){
|
|
|
|
if (/^codiad/.test(e.key)) {
|
|
|
|
var obj = { key: e.key, oldValue: e.oldValue, newValue: e.newValue };
|
|
|
|
/* Notify listeners */
|
|
|
|
window.parent.amplify.publish('settings.changed', obj);
|
|
|
|
}
|
|
|
|
}, false);
|
|
|
|
</script>
|
2018-12-21 17:43:51 +01:00
|
|
|
<?php
|
2018-07-13 18:39:55 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
?>
|