mirror of
https://github.com/xevidos/codiad.git
synced 2024-12-22 05:42:17 +01:00
Remove file extensions modifier until recode due to issues with module, Switched to Ace\'s module detection system, Added a multi line option for find and replace, Fixed Delete contents button
This commit is contained in:
parent
3bae8c29fe
commit
359297af7b
12 changed files with 89 additions and 765 deletions
23
README.md
23
README.md
|
@ -25,8 +25,8 @@ Current Tasks:
|
|||
|
||||
Task List:
|
||||
|
||||
* Add ability to login with LDAP.
|
||||
* Add custom market.
|
||||
* Add ability to login with LDAP
|
||||
* Add custom market
|
||||
* Add in new admin interface
|
||||
- Group Management
|
||||
- Permissions Management
|
||||
|
@ -34,18 +34,19 @@ Task List:
|
|||
- Project Management
|
||||
- System Settings
|
||||
- User Management
|
||||
* Add if file could not be saved 5 times close the open file.
|
||||
* Add if file could not be saved 5 times close the open file
|
||||
* Add multi level users. ( Projects for only certain groups, Permission levels )
|
||||
* Add mobile compatibility.
|
||||
* Clean up update script.
|
||||
* Add mobile compatibility
|
||||
* Clean up update script
|
||||
* Re Add the language recognition system after recode
|
||||
|
||||
|
||||
Completed:
|
||||
|
||||
* Add Auto Save.
|
||||
* Add ability to center bottom of code.
|
||||
* Add updating script.
|
||||
* Add site renaming.
|
||||
* Fix JS errors already showing.
|
||||
* Remove Codiad autocomplete in favor of Ace's.
|
||||
* Updated for PHP 7.2.
|
||||
* Add ability to center bottom of code
|
||||
* Add updating script
|
||||
* Add site renaming
|
||||
* Fix JS errors already showing
|
||||
* Remove Codiad autocomplete in favor of Ace's
|
||||
* Updated for PHP 7.2
|
|
@ -66,8 +66,8 @@
|
|||
return;
|
||||
}
|
||||
var ext = codiad.filemanager.getExtension(path);
|
||||
var mode = codiad.editor.selectMode(ext);
|
||||
|
||||
var mode = codiad.editor.selectMode( path );
|
||||
|
||||
var fn = function() {
|
||||
//var Mode = require('ace/mode/' + mode)
|
||||
// .Mode;
|
||||
|
@ -82,7 +82,7 @@
|
|||
|
||||
//var session = new EditSession(content, new Mode());
|
||||
var session = new EditSession(content);
|
||||
session.setMode("ace/mode/" + mode);
|
||||
session.setMode(mode.mode);
|
||||
session.setUndoManager(new UndoManager());
|
||||
|
||||
session.path = path;
|
||||
|
@ -98,7 +98,7 @@
|
|||
};
|
||||
|
||||
// Assuming the mode file has no dependencies
|
||||
$.loadScript('components/editor/ace-editor/mode-' + mode + '.js',
|
||||
$.loadScript('components/editor/ace-editor/mode-' + mode.name + '.js',
|
||||
fn);
|
||||
},
|
||||
|
||||
|
@ -674,7 +674,7 @@
|
|||
}
|
||||
|
||||
newSession.on("changeMode", fn);
|
||||
newSession.setMode("ace/mode/" + mode);
|
||||
newSession.setMode( mode.mode );
|
||||
} else {
|
||||
// A folder was renamed
|
||||
var newKey;
|
||||
|
|
|
@ -28,16 +28,18 @@ switch($_GET['action']){
|
|||
$type = $_GET['type'];
|
||||
?>
|
||||
<label><?php i18n("Find:"); ?></label>
|
||||
<textarea name="find" autofocus="autofocus" autocomplete="off"></textarea>
|
||||
<input name="find" autofocus="autofocus" autocomplete="off">
|
||||
<textarea style="display: none;" name="find" autofocus="autofocus" autocomplete="off"></textarea>
|
||||
|
||||
<?php if($type=='replace'){ ?>
|
||||
|
||||
<label><?php i18n("Replace:"); ?></label>
|
||||
<textarea name="replace"></textarea>
|
||||
<input name="replace">
|
||||
<textarea style="display: none;" name="replace"></textarea>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<button class="btn-left" onclick="codiad.editor.search('find');return false;"><?php i18n("Find"); ?></button>
|
||||
<button class="btn-mid" onclick="codiad.editor.toggleMultiLine( this );return false;"><?php i18n("Multi Line"); ?></button>
|
||||
<?php if($type=='replace'){ ?>
|
||||
<button class="btn-mid" onclick="codiad.editor.search('replace');return false;"><?php i18n("Replace"); ?></button>
|
||||
<button class="btn-mid" onclick="codiad.editor.search('replaceAll');return false;"><?php i18n("Replace ALL"); ?></button>
|
||||
|
@ -52,8 +54,15 @@ switch($_GET['action']){
|
|||
<script>
|
||||
$(function(){
|
||||
<?php if($_GET['action']=='search'){ ?>
|
||||
$('textarea[name="find"]').val(codiad.active.getSelectedText());
|
||||
$('textarea[name="find"]').focus();
|
||||
if( codiad.editor.multi_line ) {
|
||||
|
||||
$('textarea[name="find"]').val(codiad.active.getSelectedText());
|
||||
$('textarea[name="find"]').focus();
|
||||
} else {
|
||||
|
||||
$('input[name="find"]').val(codiad.active.getSelectedText());
|
||||
$('input[name="find"]').focus();
|
||||
}
|
||||
<?php } ?>
|
||||
});
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
var VirtualRenderer = ace.require('ace/virtual_renderer').VirtualRenderer;
|
||||
var Editor = ace.require('ace/editor').Editor;
|
||||
var EditSession = ace.require('ace/edit_session').EditSession;
|
||||
var ModeList = ace.require("ace/ext/modelist");
|
||||
var UndoManager = ace.require("ace/undomanager").UndoManager;
|
||||
|
||||
// Editor modes that have been loaded
|
||||
|
@ -24,142 +25,6 @@
|
|||
codiad.editor.init();
|
||||
});
|
||||
|
||||
// modes available for selecting
|
||||
var availableTextModes = new Array(
|
||||
'abap',
|
||||
'abc',
|
||||
'actionscript',
|
||||
'ada',
|
||||
'apache_conf',
|
||||
'applescript',
|
||||
'asciidoc',
|
||||
'assembly_x86',
|
||||
'autohotkey',
|
||||
'batchfile',
|
||||
'c9search',
|
||||
'c_cpp',
|
||||
'cirru',
|
||||
'clojure',
|
||||
'cobol',
|
||||
'coffee',
|
||||
'coldfusion',
|
||||
'csharp',
|
||||
'css',
|
||||
'curly',
|
||||
'd',
|
||||
'dart',
|
||||
'diff',
|
||||
'django',
|
||||
'dockerfile',
|
||||
'dot',
|
||||
'eiffel',
|
||||
'ejs',
|
||||
'elixir',
|
||||
'elm',
|
||||
'erlang',
|
||||
'forth',
|
||||
'ftl',
|
||||
'gcode',
|
||||
'gherkin',
|
||||
'gitignore',
|
||||
'glsl',
|
||||
'gobstones',
|
||||
'golang',
|
||||
'groovy',
|
||||
'haml',
|
||||
'handlebars',
|
||||
'haskell',
|
||||
'haxe',
|
||||
'html',
|
||||
'html_elixir',
|
||||
'html_ruby',
|
||||
'ini',
|
||||
'io',
|
||||
'jack',
|
||||
'jade',
|
||||
'java',
|
||||
'javascript',
|
||||
'json',
|
||||
'jsoniq',
|
||||
'jsp',
|
||||
'jsx',
|
||||
'julia',
|
||||
'latex',
|
||||
'lean',
|
||||
'less',
|
||||
'liquid',
|
||||
'lisp',
|
||||
'livescript',
|
||||
'logiql',
|
||||
'lsl',
|
||||
'lua',
|
||||
'luapage',
|
||||
'lucene',
|
||||
'makefile',
|
||||
'markdown',
|
||||
'mask',
|
||||
'matlab',
|
||||
'maze',
|
||||
'mel',
|
||||
'mips_assembler',
|
||||
'mushcode',
|
||||
'mysql',
|
||||
'nix',
|
||||
'nsis',
|
||||
'objectivec',
|
||||
'ocaml',
|
||||
'pascal',
|
||||
'perl',
|
||||
'pgsql',
|
||||
'php',
|
||||
'plain_text',
|
||||
'powershell',
|
||||
'praat',
|
||||
'prolog',
|
||||
'protobuf',
|
||||
'python',
|
||||
'r',
|
||||
'razor',
|
||||
'rdoc',
|
||||
'rhtml',
|
||||
'rst',
|
||||
'ruby',
|
||||
'rust',
|
||||
'sass',
|
||||
'scad',
|
||||
'scala',
|
||||
'scheme',
|
||||
'scss',
|
||||
'sh',
|
||||
'sjs',
|
||||
'smarty',
|
||||
'snippets',
|
||||
'soy_template',
|
||||
'space',
|
||||
'sql',
|
||||
'sqlserver',
|
||||
'stylus',
|
||||
'svg',
|
||||
'swift',
|
||||
'swig',
|
||||
'tcl',
|
||||
'tex',
|
||||
'text',
|
||||
'textile',
|
||||
'toml',
|
||||
'twig',
|
||||
'typescript',
|
||||
'vala',
|
||||
'vbscript',
|
||||
'velocity',
|
||||
'verilog',
|
||||
'vhdl',
|
||||
'wollok',
|
||||
'xml',
|
||||
'xquery',
|
||||
'yaml'
|
||||
);
|
||||
|
||||
function SplitContainer(root, children, splitType) {
|
||||
var _this = this;
|
||||
|
||||
|
@ -400,7 +265,9 @@
|
|||
fileManagerTrigger: false,
|
||||
tabSize: 4
|
||||
},
|
||||
|
||||
|
||||
multi_line: false,
|
||||
|
||||
rootContainer: null,
|
||||
|
||||
fileExtensionTextMode: {},
|
||||
|
@ -636,10 +503,11 @@
|
|||
var firstOption = 0;
|
||||
|
||||
this.initMenuHandler($('#current-mode'),_thisMenu);
|
||||
|
||||
availableTextModes.sort();
|
||||
$.each(availableTextModes, function(i){
|
||||
modeOptions.push('<li><a>'+availableTextModes[i]+'</a></li>');
|
||||
|
||||
var modes = Object.keys( ModeList.modesByName ).sort();
|
||||
|
||||
$.each(modes, function(i){
|
||||
modeOptions.push('<li><a>'+modes[i]+'</a></li>');
|
||||
});
|
||||
|
||||
var html = '<table><tr>';
|
||||
|
@ -872,12 +740,7 @@
|
|||
return 'text';
|
||||
}
|
||||
e = e.toLowerCase();
|
||||
|
||||
if(e in this.fileExtensionTextMode){
|
||||
return this.fileExtensionTextMode[e];
|
||||
}else{
|
||||
return 'text';
|
||||
}
|
||||
return( ModeList.getModeForPath( e ) );
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
@ -1484,10 +1347,19 @@
|
|||
search: function(action, i) {
|
||||
i = i || this.getActive();
|
||||
if (! i) return;
|
||||
var find = $('#modal textarea[name="find"]')
|
||||
if( this.multi_line ) {
|
||||
|
||||
var find = $('#modal textarea[name="find"]')
|
||||
.val();
|
||||
var replace = $('#modal textarea[name="replace"]')
|
||||
var replace = $('#modal textarea[name="replace"]')
|
||||
.val();
|
||||
} else {
|
||||
|
||||
var find = $('#modal input[name="find"]')
|
||||
.val();
|
||||
var replace = $('#modal input[name="replace"]')
|
||||
.val();
|
||||
}
|
||||
switch (action) {
|
||||
case 'find':
|
||||
|
||||
|
@ -1599,7 +1471,33 @@
|
|||
//Database
|
||||
codiad.settings.update_option( 'codiad.editor.autocomplete', s );
|
||||
},
|
||||
|
||||
|
||||
toggleMultiLine: function( e ) {
|
||||
|
||||
if( e.innerText === "Multi Line" ) {
|
||||
|
||||
this.multi_line = true;
|
||||
e.innerText = "Single Line";
|
||||
$('input[name="find"]').hide();
|
||||
$('textarea[name="find"]').show();
|
||||
$('textarea[name="find"]').val( $('input[name="find"]').val() );
|
||||
|
||||
$('input[name="replace"]').hide();
|
||||
$('textarea[name="replace"]').show();
|
||||
$('textarea[name="replace"]').val( $('input[name="replace"]').val() );
|
||||
} else {
|
||||
|
||||
this.multi_line = false;
|
||||
e.innerText = "Multi Line";
|
||||
$('input[name="find"]').show();
|
||||
$('textarea[name="find"]').hide();
|
||||
$('input[name="find"]').val( $('textarea[name="find"]').val() );
|
||||
|
||||
$('input[name="replace"]').show();
|
||||
$('textarea[name="replace"]').hide();
|
||||
$('input[name="replace"]').val( $('textarea[name="replace"]').val() );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})(this, jQuery);
|
|
@ -1,353 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* (c) Codiad & ccvca (https://github.com/ccvca)
|
||||
* @author ccvca (https://github.com/ccvca)
|
||||
* This Code is released under the same licence as Codiad (https://github.com/Codiad/Codiad)
|
||||
* See [root]/license.txt for more. This information must remain intact.
|
||||
*/
|
||||
|
||||
require_once '../../common.php';
|
||||
|
||||
|
||||
class fileextension_textmode
|
||||
{
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//default associations
|
||||
//////////////////////////////////////////////////////////////////
|
||||
private $defaultExtensions = array(
|
||||
'html' => 'html',
|
||||
'htm' => 'html',
|
||||
'tpl' => 'html',
|
||||
'js' => 'javascript',
|
||||
'css' => 'css',
|
||||
'scss' => 'scss',
|
||||
'sass' => 'scss',
|
||||
'less' => 'less',
|
||||
'php' => 'php',
|
||||
'php4' => 'php',
|
||||
'php5' => 'php',
|
||||
'phtml' => 'php',
|
||||
'json' => 'json',
|
||||
'java' => 'java',
|
||||
'xml' => 'xml',
|
||||
'sql' => 'sql',
|
||||
'md' => 'markdown',
|
||||
'c' => 'c_cpp',
|
||||
'cpp' => 'c_cpp',
|
||||
'd' => 'd',
|
||||
'h' => 'c_cpp',
|
||||
'hpp' => 'c_cpp',
|
||||
'py' => 'python',
|
||||
'rb' => 'ruby',
|
||||
'erb' => 'html_ruby',
|
||||
'jade' => 'jade',
|
||||
'coffee' => 'coffee',
|
||||
'vm' => 'velocity');
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//availiable text modes
|
||||
//////////////////////////////////////////////////////////////////
|
||||
private $availiableTextModes = array(
|
||||
'abap',
|
||||
'abc',
|
||||
'actionscript',
|
||||
'ada',
|
||||
'apache_conf',
|
||||
'applescript',
|
||||
'asciidoc',
|
||||
'assembly_x86',
|
||||
'autohotkey',
|
||||
'batchfile',
|
||||
'c9search',
|
||||
'c_cpp',
|
||||
'cirru',
|
||||
'clojure',
|
||||
'cobol',
|
||||
'coffee',
|
||||
'coldfusion',
|
||||
'csharp',
|
||||
'css',
|
||||
'curly',
|
||||
'd',
|
||||
'dart',
|
||||
'diff',
|
||||
'django',
|
||||
'dockerfile',
|
||||
'dot',
|
||||
'eiffel',
|
||||
'ejs',
|
||||
'elixir',
|
||||
'elm',
|
||||
'erlang',
|
||||
'forth',
|
||||
'ftl',
|
||||
'gcode',
|
||||
'gherkin',
|
||||
'gitignore',
|
||||
'glsl',
|
||||
'gobstones',
|
||||
'golang',
|
||||
'groovy',
|
||||
'haml',
|
||||
'handlebars',
|
||||
'haskell',
|
||||
'haxe',
|
||||
'html',
|
||||
'html_elixir',
|
||||
'html_ruby',
|
||||
'ini',
|
||||
'io',
|
||||
'jack',
|
||||
'jade',
|
||||
'java',
|
||||
'javascript',
|
||||
'json',
|
||||
'jsoniq',
|
||||
'jsp',
|
||||
'jsx',
|
||||
'julia',
|
||||
'latex',
|
||||
'lean',
|
||||
'less',
|
||||
'liquid',
|
||||
'lisp',
|
||||
'livescript',
|
||||
'logiql',
|
||||
'lsl',
|
||||
'lua',
|
||||
'luapage',
|
||||
'lucene',
|
||||
'makefile',
|
||||
'markdown',
|
||||
'mask',
|
||||
'matlab',
|
||||
'maze',
|
||||
'mel',
|
||||
'mips_assembler',
|
||||
'mushcode',
|
||||
'mysql',
|
||||
'nix',
|
||||
'nsis',
|
||||
'objectivec',
|
||||
'ocaml',
|
||||
'pascal',
|
||||
'perl',
|
||||
'pgsql',
|
||||
'php',
|
||||
'plain_text',
|
||||
'powershell',
|
||||
'praat',
|
||||
'prolog',
|
||||
'protobuf',
|
||||
'python',
|
||||
'r',
|
||||
'razor',
|
||||
'rdoc',
|
||||
'rhtml',
|
||||
'rst',
|
||||
'ruby',
|
||||
'rust',
|
||||
'sass',
|
||||
'scad',
|
||||
'scala',
|
||||
'scheme',
|
||||
'scss',
|
||||
'sh',
|
||||
'sjs',
|
||||
'smarty',
|
||||
'snippets',
|
||||
'soy_template',
|
||||
'space',
|
||||
'sql',
|
||||
'sqlserver',
|
||||
'stylus',
|
||||
'svg',
|
||||
'swift',
|
||||
'swig',
|
||||
'tcl',
|
||||
'tex',
|
||||
'text',
|
||||
'textile',
|
||||
'toml',
|
||||
'twig',
|
||||
'typescript',
|
||||
'vala',
|
||||
'vbscript',
|
||||
'velocity',
|
||||
'verilog',
|
||||
'vhdl',
|
||||
'wollok',
|
||||
'xml',
|
||||
'xquery',
|
||||
'yaml'
|
||||
);
|
||||
|
||||
const storeFilename = 'extensions.php';
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//check the session if the user is allowed to do anything here
|
||||
//////////////////////////////////////////////////////////////////
|
||||
public function __construct()
|
||||
{
|
||||
Common::checkSession();
|
||||
}
|
||||
|
||||
public function getAvailiableTextModes()
|
||||
{
|
||||
return $this->availiableTextModes;
|
||||
}
|
||||
|
||||
public function getDefaultExtensions()
|
||||
{
|
||||
return $this->defaultExtensions;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//checks if the sended extensions are valid to prevent any injections
|
||||
//////////////////////////////////////////////////////////////////
|
||||
public function validateExtension($extension)
|
||||
{
|
||||
return preg_match('#^[a-z0-9\_]+$#i', $extension);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//checks if the sended extensions are valid to prevent any injections and usage of removed text modes
|
||||
//////////////////////////////////////////////////////////////////
|
||||
public function validTextMode($mode)
|
||||
{
|
||||
return in_array($mode, $this->availiableTextModes);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//process the form with the associations
|
||||
//////////////////////////////////////////////////////////////////
|
||||
private function processFileExtTextModeForm()
|
||||
{
|
||||
if (!Common::checkAccess()) {
|
||||
return array('status' =>'error', 'msg' =>'You are not allowed to edit the file extensions.');
|
||||
}
|
||||
//Store Fileextensions and Textmodes in File:
|
||||
if (!isset($_POST['extension']) || !is_array($_POST['extension'])
|
||||
|| !isset($_POST['textMode']) || !is_array($_POST['textMode'])) {
|
||||
return json_encode(array('status' => 'error', 'msg' => 'incorrect data send'));
|
||||
}
|
||||
|
||||
$exMap = array();
|
||||
|
||||
$warning = '';
|
||||
|
||||
//Iterate over the sended extensions
|
||||
foreach ($_POST['extension'] as $key => $extension) {
|
||||
//ignore empty extensions, so that they are going to removed
|
||||
if (trim($extension) == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
//get the sended data and check it
|
||||
if (!isset($_POST["textMode"][$key])) {
|
||||
return json_encode(array('status' => 'error', 'msg' => 'incorrect data send.'));
|
||||
}
|
||||
|
||||
$extension = strtolower(trim($extension));
|
||||
$textMode = strtolower(trim($_POST["textMode"][$key]));
|
||||
|
||||
if (!$this->validateExtension($extension)) {
|
||||
return json_encode(array('status' => 'error', 'msg' => 'incorrect extension:'.htmlentities($extension)));
|
||||
}
|
||||
|
||||
if (!$this->validTextMode($textMode)) {
|
||||
return json_encode(array('status' => 'error', 'msg' => 'incorrect text mode:'.htmlentities($textMode)));
|
||||
}
|
||||
|
||||
//data was correct and could be insert
|
||||
if (isset($exMap[$extension])) {
|
||||
$warning = htmlentities($extension).' is already set.<br/>';
|
||||
} else {
|
||||
$exMap[$extension] = $textMode;
|
||||
}
|
||||
}
|
||||
|
||||
//store the associations
|
||||
Common::saveJSON(fileextension_textmode::storeFilename, $exMap);
|
||||
if ($warning != '') {
|
||||
return json_encode(array('status' => 'warning', 'msg' => $warning, 'extensions' => $exMap ));
|
||||
} else {
|
||||
return json_encode(array('status' => 'success', 'msg' => 'File extensions are saved successfully.', 'extensions' => $exMap));
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//process all the possible forms
|
||||
//////////////////////////////////////////////////////////////////
|
||||
public function processForms()
|
||||
{
|
||||
if (!isset($_GET['action'])) {
|
||||
return json_encode(array('status' => 'error', 'msg' => 'incorrect data send.'));
|
||||
}
|
||||
|
||||
switch ($_GET['action']) {
|
||||
case 'FileExtTextModeForm':
|
||||
return $this->processFileExtTextModeForm();
|
||||
break;
|
||||
case 'GetFileExtTextModes':
|
||||
return $this->prcessGetFileExtTextModes();
|
||||
break;
|
||||
default:
|
||||
return json_encode(array('status' => 'error', 'msg' => 'Incorrect data send'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//Send the default extensions
|
||||
//////////////////////////////////////////////////////////////////
|
||||
private function prcessGetFileExtTextModes()
|
||||
{
|
||||
$ext = false;
|
||||
//ignore warnings
|
||||
$ext = @Common::getJSON(fileextension_textmode::storeFilename);
|
||||
|
||||
if (!is_array($ext)) {
|
||||
//default extensions
|
||||
$ext = $this->defaultExtensions;
|
||||
}
|
||||
|
||||
//the availiable extensions, which aren't removed
|
||||
$availEx = array();
|
||||
foreach ($ext as $ex => $mode) {
|
||||
if (in_array($mode, $this->availiableTextModes)) {
|
||||
$availEx[$ex] = $mode;
|
||||
}
|
||||
}
|
||||
return json_encode(array('status' => 'success', 'extensions' => $availEx, 'textModes' => $this->availiableTextModes));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//return a select-field with all availiable text modes, the one in the parameter is selected
|
||||
//////////////////////////////////////////////////////////////////
|
||||
public function getTextModeSelect($extension)
|
||||
{
|
||||
$extension = trim(strtolower($extension));
|
||||
$find = false;
|
||||
$ret = '<select name="textMode[]" class="textMode">'."\n";
|
||||
foreach ($this->getAvailiableTextModes() as $textmode) {
|
||||
$ret .= ' <option';
|
||||
if ($textmode == $extension) {
|
||||
$ret .= ' selected="selected"';
|
||||
$find = true;
|
||||
}
|
||||
$ret .='>'.$textmode.'</option>'."\n";
|
||||
}
|
||||
|
||||
//unknown extension, print it in the end
|
||||
if (!$find && $extension != '') {
|
||||
$ret .= ' <option selected="selected">'.$textmode.'</option>'."\n";
|
||||
}
|
||||
|
||||
$ret .= '</select>'."\n";
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* (c) Codiad & ccvca (https://github.com/ccvca)
|
||||
* @author ccvca (https://github.com/ccvca)
|
||||
* This Code is released under the same licence as Codiad (https://github.com/Codiad/Codiad)
|
||||
* See [root]/license.txt for more. This information must remain intact.
|
||||
*/
|
||||
|
||||
require_once 'class.fileextension_textmode.php';
|
||||
|
||||
$fileExTM = new fileextension_textmode();
|
||||
|
||||
|
||||
echo $fileExTM->processForms();
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* (c) Codiad & ccvca (https://github.com/ccvca)
|
||||
* @author ccvca (https://github.com/ccvca)
|
||||
* This Code is released under the same licence as Codiad (https://github.com/Codiad/Codiad)
|
||||
* See [root]/license.txt for more. This information must remain intact.
|
||||
*/
|
||||
|
||||
require_once 'class.fileextension_textmode.php';
|
||||
|
||||
//check Session is done in constructor
|
||||
$fileExTM = new fileextension_textmode();
|
||||
|
||||
if(!isset($_GET['action'])){
|
||||
die('Missing $_GET["action"]');
|
||||
}
|
||||
switch($_GET['action']){
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//The form for edit the assotiations
|
||||
//////////////////////////////////////////////////////////////////
|
||||
case 'fileextension_textmode_form':
|
||||
if(!Common::checkAccess()){
|
||||
die('You are not allowed to edit the file extensions.');
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//Reading the current extensions
|
||||
//////////////////////////////////////////////////////////////////
|
||||
$ext = false;
|
||||
//ignore warnings
|
||||
$ext = @Common::getJSON(fileextension_textmode::storeFilename);
|
||||
|
||||
if(!is_array($ext)){
|
||||
//default extensions
|
||||
$ext = $fileExTM->getDefaultExtensions();
|
||||
}
|
||||
|
||||
$textModes = $fileExTM->getAvailiableTextModes();
|
||||
|
||||
if(!@ksort($ext)){
|
||||
die(json_encode(array('status' => 'error', 'msg' => 'Internal PHP error.') ));
|
||||
}
|
||||
?>
|
||||
<label><span class="icon-pencil big-icon"></span><?php i18n("Extensions"); ?></label>
|
||||
<table id="FileExtModeHeader">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php i18n("Extension"); ?></th>
|
||||
<th><?php i18n("Mode"); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<div id="FileExtTextModeDiv">
|
||||
<table id="FileExtTextModeTable">
|
||||
<tbody id="FileExtTextModeTableTbody">
|
||||
<?php
|
||||
foreach($ext as $ex => $mode){
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//print only valid assotiations
|
||||
//////////////////////////////////////////////////////////////////
|
||||
if(!$fileExTM->validTextMode($mode)){
|
||||
continue;
|
||||
}?>
|
||||
<tr>
|
||||
<td><input class="FileExtension" type="text" name="extension[]" value="<?php echo $ex ?>" /></td>
|
||||
<td><?php echo $fileExTM->getTextModeSelect($mode)?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<br>
|
||||
<button class="btn-left" onClick="codiad.fileext_textmode.addFieldToForm()"><?php i18n("New Extension"); ?></button>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
?>
|
|
@ -1,136 +0,0 @@
|
|||
/*
|
||||
* (c) Codiad & ccvca (https://github.com/ccvca)
|
||||
* @author ccvca (https://github.com/ccvca)
|
||||
* This Code is released under the same licence as Codiad (https://github.com/Codiad/Codiad)
|
||||
* See [root]/license.txt for more. This information must remain intact.
|
||||
*/
|
||||
|
||||
(function(global, $) {
|
||||
var self = null;
|
||||
|
||||
$(function() {
|
||||
codiad.fileext_textmode.init();
|
||||
});
|
||||
|
||||
global.codiad.fileext_textmode = {
|
||||
|
||||
dialog: 'components/fileext_textmode/dialog.php',
|
||||
controller: 'components/fileext_textmode/controller.php',
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//do a post request for the first associations of fileextensions and textmodes
|
||||
//////////////////////////////////////////////////////////////////
|
||||
availableTextModes : [],
|
||||
|
||||
init : function() {
|
||||
self = this;
|
||||
this.initEditorFileExtensionTextModes();
|
||||
|
||||
amplify.subscribe('settings.dialog.save', function(){
|
||||
if ($('#FileExtTextModeDiv:visible').length !== 0) {
|
||||
self.sendForm();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//do a post request for the first associations of fileextensions and textmodes
|
||||
//////////////////////////////////////////////////////////////////
|
||||
initEditorFileExtensionTextModes : function(){
|
||||
$.get(this.controller, {'action' : 'GetFileExtTextModes'}, this.setEditorFileExtensionTextModes);
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//initial method to get the stored associations
|
||||
//////////////////////////////////////////////////////////////////
|
||||
setEditorFileExtensionTextModes : function(data){
|
||||
resp = $.parseJSON(data);
|
||||
if(resp.status != 'error' && resp.extensions != undefined){
|
||||
codiad.editor.clearFileExtensionTextMode();
|
||||
|
||||
for(i in resp.extensions){
|
||||
codiad.editor.addFileExtensionTextMode(i, resp.extensions[i]);
|
||||
}
|
||||
|
||||
if(resp.textModes != undefined && resp.textModes != []){
|
||||
self.availableTextModes = resp.textModes;
|
||||
}
|
||||
|
||||
/* Notify listeners. */
|
||||
amplify.publish('fileext_textmode.loadedExtensions');
|
||||
}
|
||||
self.showStatus(data);
|
||||
},
|
||||
|
||||
formWidth : 400,
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Open the component dialog
|
||||
//////////////////////////////////////////////////////////////////
|
||||
open : function() {
|
||||
//codiad.modal.unload();
|
||||
codiad.modal.load(this.formWidth,
|
||||
this.dialog+"?action=fileextension_textmode_form");
|
||||
codiad.modal.hideOverlay();
|
||||
},
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//send the insert extesions and textmodes to the server.
|
||||
//////////////////////////////////////////////////////////////////
|
||||
sendForm : function(){
|
||||
var $div = $('#FileExtTextModeDiv');
|
||||
var extensions = $div.find('.FileExtension');
|
||||
//data to send
|
||||
var formData = {'extension[]' : [], 'textMode[]' : []};
|
||||
for(var i = 0; i < extensions.size(); ++i){
|
||||
formData['extension[]'].push(extensions[i].value);
|
||||
}
|
||||
|
||||
var textMode = $div.find('.textMode');
|
||||
for(var i = 0; i < textMode.size(); ++i){
|
||||
formData['textMode[]'].push(textMode[i].value);
|
||||
}
|
||||
|
||||
$.post(this.controller+'?action=FileExtTextModeForm', formData, self.setEditorFileExtensionTextModes);
|
||||
},
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//Add a new insert line to the form
|
||||
//////////////////////////////////////////////////////////////////
|
||||
addFieldToForm : function(){
|
||||
var $table = $('#FileExtTextModeTable');
|
||||
var $tbody = $('#FileExtTextModeTableTbody');
|
||||
|
||||
var code = '<tr><td><input class="FileExtension" type="text" name="extension[]" value="" /></td>';
|
||||
code += '<td><select name="textMode[]" class="textMode">';
|
||||
for(var i = 0; i < this.availableTextModes.length; ++i){
|
||||
code += '<option>'+ this.availableTextModes[i] +'</option>';
|
||||
}
|
||||
|
||||
code += '</select></td></tr>';
|
||||
|
||||
$tbody.append(code);
|
||||
|
||||
//scroll as far down as possible
|
||||
$table.scrollTop(1000000);
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//showing the status and msg from a http-request
|
||||
//////////////////////////////////////////////////////////////////
|
||||
showStatus : function(resp) {
|
||||
resp = $.parseJSON(resp);
|
||||
if(resp.status != undefined && resp.status != '' && resp.msg != undefined && resp.message != ''){
|
||||
switch (resp.status) {
|
||||
case 'success':
|
||||
codiad.message.success(resp.msg);
|
||||
break;
|
||||
case 'error':
|
||||
codiad.message.error(resp.msg);
|
||||
break;
|
||||
case 'notice':
|
||||
codiad.message.notice(resp.msg);
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
})(this, jQuery);
|
|
@ -95,10 +95,16 @@
|
|||
"applies-to" : "non-root",
|
||||
"onclick": "codiad.filemanager.deleteNode($('#context-menu').attr('data-path'));"
|
||||
},
|
||||
{
|
||||
"title": "Break",
|
||||
"icon": null,
|
||||
"applies-to" : "both no-external",
|
||||
"onclick": null
|
||||
},
|
||||
{
|
||||
"title": "Delete Contents",
|
||||
"icon": "icon-cancel-circled",
|
||||
"applies-to" : "non-root",
|
||||
"applies-to" : "directory-only",
|
||||
"onclick": "codiad.filemanager.deleteInnerNode($('#context-menu').attr('data-path'));"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -32,15 +32,6 @@
|
|||
<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>
|
||||
<?php
|
||||
if (COMMON::checkAccess()) {
|
||||
?>
|
||||
<li name="extension-settings" data-file="components/fileext_textmode/dialog.php?action=fileextension_textmode_form" data-name="fileext_textmode">
|
||||
<a><span class="icon-pencil bigger-icon"></span><?php i18n("Extensions"); ?></a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<hr>
|
||||
|
|
|
@ -12,7 +12,7 @@ class Update {
|
|||
// CONSTANTS
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
CONST VERSION = "v.2.9.3.1";
|
||||
CONST VERSION = "v.2.9.3.2";
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// PROPERTIES
|
||||
|
|
|
@ -419,6 +419,8 @@ if( defined( "SITE_NAME" ) && ! ( SITE_NAME === "" || SITE_NAME === null ) ) {
|
|||
<!-- ACE -->
|
||||
<script src="components/editor/ace-editor/ace.js"></script>
|
||||
<script src="components/editor/ace-editor/ext-language_tools.js"></script>
|
||||
<script src="components/editor/ace-editor/ext-modelist.js"></script>
|
||||
<script src="components/editor/ace-editor/ext-themelist.js"></script>
|
||||
|
||||
<!-- Codiad System Variables -->
|
||||
<script>
|
||||
|
|
Loading…
Reference in a new issue