Merge branch 'development' into 'master'

v.2.9.5

See merge request xevidos/codiad!12
This commit is contained in:
xevidos 2019-06-27 12:43:19 +00:00
commit 9d718331e8
14 changed files with 4012 additions and 3828 deletions

View file

@ -22,22 +22,28 @@ Stick to the conventions defined in other components as closely as possible.
In order to maintain a consistant code structure to the code across the application please follow the wordpress standard, or run any changes through [JSBeautifier] (http://jsbeautifier.org/) with the settings below. In order to maintain a consistant code structure to the code across the application please follow the wordpress standard, or run any changes through [JSBeautifier] (http://jsbeautifier.org/) with the settings below.
{ {
"indent_size": "1", "brace_style": "collapse",
"break_chained_methods": false,
"comma_first": false,
"e4x": false,
"end_with_newline": true,
"indent_char": "\t", "indent_char": "\t",
"indent_empty_lines": true,
"indent_inner_html": true,
"indent_scripts": "normal",
"indent_size": "1",
"jslint_happy": false,
"keep_array_indentation": true,
"max_preserve_newlines": "5", "max_preserve_newlines": "5",
"preserve_newlines": true, "preserve_newlines": true,
"keep_array_indentation": true, "space_after_anon_function": false,
"break_chained_methods": false, "space_after_named_function": false,
"indent_scripts": "normal",
"brace_style": "collapse",
"space_before_conditional": false, "space_before_conditional": false,
"space_in_empty_paren": false,
"space_in_paren": true,
"unescape_strings": false, "unescape_strings": false,
"jslint_happy": false, "unindent_chained_methods": true,
"end_with_newline": true, "wrap_line_length": "0"
"wrap_line_length": "0",
"indent_inner_html": true,
"comma_first": false,
"e4x": false
} }
If you have questions, please ask. Submit an issue or [contact us directly](mailto:support@telaaedifex.com). If you have questions, please ask. Submit an issue or [contact us directly](mailto:support@telaaedifex.com).

View file

@ -9,11 +9,13 @@ Distributed under the MIT-Style License. See LICENSE.txt file for more informati
Repositories: Repositories:
[GitLab](https://gitlab.com/xevidos/codiad) [GitLab](https://gitlab.com/xevidos/codiad)
[GitHub](https://github.com/xevidos/codiad) [GitHub](https://github.com/xevidos/codiad)
Issues: Issues:
[GitLab](https://gitlab.com/xevidos/codiad/issues) [GitLab](https://gitlab.com/xevidos/codiad/issues)
[GitHub](https://github.com/xevidos/codiad/issues) [GitHub](https://github.com/xevidos/codiad/issues)
Features: Features:
@ -37,16 +39,19 @@ Task List:
* Add ability to login with LDAP * Add ability to login with LDAP
* Add custom market * Add custom market
* Add in new admin interface ( Check admin-portal branch for progress ) * \- Add in new admin interface ( Check admin-portal branch for progress )
- Group Management - Group Management
- Permissions Management - Permissions Management
- Plugin Management - Plugin Management
- Project Management - Project Management
- System Settings - System Settings
- User Management - User Management
* Add Drag and Drop natively to filemanager
* Add folder / filestructure upload ability
* 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 multi level users. ( Projects for only certain groups, Permission levels )
* Add mobile compatibility * Add mobile compatibility
* Add permissions module ( more in depth permissions such as read/write, delete, etc )
* Add support for more database systems ( MSSQL, Oracle, SQLite, Filesystem storage, etc ) * Add support for more database systems ( MSSQL, Oracle, SQLite, Filesystem storage, etc )
* Add in auto save timer that saves after the user stops typing instead of after every change * Add in auto save timer that saves after the user stops typing instead of after every change
* Clean up update script * Clean up update script
@ -70,7 +75,9 @@ Completed:
* Updated for PHP 7.2 * Updated for PHP 7.2
Bugs: Known Bugs:
* Auto save does not save the most recent changes every once in a while requiring more information to be typed ( E.G. A couple spaces ) in order to show up in saved file. * Auto save does not save the most recent changes every once in a while requiring more information to be typed ( E.G. A couple spaces ) in order to show up in saved file
* Cursor is set to the wrong position if in split view. * Cursor is set to the wrong position if in split view
* In certain enviroments the update script pulls the old version of the sql class causing the update to fail
* The Server has new version of file alert causes auto save to stop when the user presses okay

View file

@ -4,7 +4,6 @@
* warranty under the MIT License. See [root]/license.txt for more. * warranty under the MIT License. See [root]/license.txt for more.
* This information must remain intact. * This information must remain intact.
*/ */
( function( global, $ ) { ( function( global, $ ) {
var EditSession = ace.require( 'ace/edit_session' ) var EditSession = ace.require( 'ace/edit_session' )
@ -59,7 +58,10 @@
//} //}
/* Notify listeners. */ /* Notify listeners. */
amplify.publish('active.onFileWillOpen', {path: path, content: content}); amplify.publish( 'active.onFileWillOpen', {
path: path,
content: content
});
if( focus === undefined ) { if( focus === undefined ) {
focus = true; focus = true;
@ -403,7 +405,10 @@
let _this = this; let _this = this;
codiad.editor.setSession( this.sessions[path] ); codiad.editor.setSession( this.sessions[path] );
this.history.push( path ); this.history.push( path );
$.get(this.controller, {'action':'focused', 'path':path}, function() { $.get( this.controller, {
'action': 'focused',
'path': path
}, function() {
if( !( _this.positions[`${path}`] === undefined ) ) { if( !( _this.positions[`${path}`] === undefined ) ) {
@ -448,8 +453,7 @@
/* Show the dropdown menu if needed */ /* Show the dropdown menu if needed */
this.showTabDropdownMenu(); this.showTabDropdownMenu();
} }
} } else if( this.history.length > 0 ) {
else if(this.history.length > 0) {
var prevPath = this.history[this.history.length - 1]; var prevPath = this.history[this.history.length - 1];
var prevSession = this.sessions[prevPath]; var prevSession = this.sessions[prevPath];
if( $( '#dropdown-list-active-files' ).has( prevSession.tabThumb ).length > 0 ) { if( $( '#dropdown-list-active-files' ).has( prevSession.tabThumb ).length > 0 ) {
@ -611,7 +615,9 @@
/* Animate only if the tabThumb if a tab, not a dropdown item. */ /* Animate only if the tabThumb if a tab, not a dropdown item. */
if( session.tabThumb.hasClass( 'tab-item' ) ) { if( session.tabThumb.hasClass( 'tab-item' ) ) {
session.tabThumb.css({'z-index': 1}); session.tabThumb.css( {
'z-index': 1
});
session.tabThumb.animate( { session.tabThumb.animate( {
top: $( '#editor-top-bar' ).height() + 'px' top: $( '#editor-top-bar' ).height() + 'px'
}, 300, function() { }, 300, function() {
@ -714,7 +720,10 @@
} }
$.get( this.controller + '?action=rename&old_path=' + encodeURIComponent( oldPath ) + '&new_path=' + encodeURIComponent( newPath ), function() { $.get( this.controller + '?action=rename&old_path=' + encodeURIComponent( oldPath ) + '&new_path=' + encodeURIComponent( newPath ), function() {
/* Notify listeners. */ /* Notify listeners. */
amplify.publish('active.onRename', {"oldPath": oldPath, "newPath": newPath}); amplify.publish( 'active.onRename', {
"oldPath": oldPath,
"newPath": newPath
});
}); });
}, },
@ -1010,8 +1019,7 @@
data: { data: {
positions: ( JSON.stringify( codiad.active.positions ) ) positions: ( JSON.stringify( codiad.active.positions ) )
}, },
success: function( data ) { success: function( data ) {},
},
}); });
}, },
@ -1097,16 +1105,16 @@
createTabThumb: function( path ) { createTabThumb: function( path ) {
split = this.splitDirectoryAndFileName( path ); split = this.splitDirectoryAndFileName( path );
return $('<li class="tab-item" data-path="' + path + '"><a class="label" title="' + path + '">' return $( '<li class="tab-item" data-path="' + path + '"><a class="label" title="' + path + '">' +
+ split.directory + '<span class="file-name">' + split.fileName + '</span>' split.directory + '<span class="file-name">' + split.fileName + '</span>' +
+ '</a><a class="close">x</a></li>'); '</a><a class="close">x</a></li>' );
}, },
createMenuItemThumb: function( path ) { createMenuItemThumb: function( path ) {
split = this.splitDirectoryAndFileName( path ); split = this.splitDirectoryAndFileName( path );
return $('<li data-path="' + path + '"><a title="' + path + '"><span class="label"></span><div class="label">' return $( '<li data-path="' + path + '"><a title="' + path + '"><span class="label"></span><div class="label">' +
+ split.directory + '<span class="file-name">' + split.fileName + '</span>' split.directory + '<span class="file-name">' + split.fileName + '</span>' +
+ '</div></a></li>'); '</div></a></li>' );
}, },
}; };

View file

@ -38,12 +38,13 @@
editor: null, editor: null,
invalid_states: [ "", " ", null, undefined ], invalid_states: [ "", " ", null, undefined ],
path: curpath, path: curpath,
save_interval: null,
saving: false, saving: false,
settings: { settings: {
autosave: true, autosave: true,
toggle: true, toggle: true,
}, },
verbose: false, verbose: true,
init: async function() { init: async function() {
@ -109,6 +110,10 @@
* try to close it, the program will throw an exception and * try to close it, the program will throw an exception and
* stop you from closing the file * stop you from closing the file
*/ */
if( codiad.auto_save.verbose ) {
console.log( "Error removing event listener", e );
}
} }
}); });
@ -128,6 +133,30 @@
}); });
}, },
auto_save: function() {
/**
* When saving after every change, we encounter an issue where every
* once in a while the last change or last few changes will not get
* saved. Due to this, I decided to instead only save after the user
* has finished typing their changes.
*
* On every change to the editor, we set a timeout of half a second
* to see if the user is still typing. If they are, we clear the
* timeout and set it again. If they have stopped typing then the
* timout is triggered after 500 miliseconds and the file is saved.
*/
let _this = codiad.auto_save;
if( _this.save_interval !== null ) {
clearTimeout( _this.save_interval );
_this.save_interval = null;
}
_this.save_interval = setTimeout( _this.save, 500 );
},
/** /**
* *
* This is where the core functionality goes, any call, references, * This is where the core functionality goes, any call, references,
@ -135,9 +164,15 @@
* *
*/ */
auto_save: function() { save: function() {
let _this = codiad.auto_save; let _this = codiad.auto_save;
if( _this.saving ) {
return;
}
_this.saving = true; _this.saving = true;
let tabs = document.getElementsByClassName( "tab-item" ); let tabs = document.getElementsByClassName( "tab-item" );
let path = codiad.active.getPath(); let path = codiad.active.getPath();
@ -157,9 +192,9 @@
if( _this.verbose ) { if( _this.verbose ) {
console.log( content, _this.content ); //console.log( content, _this.content );
} }
/*
if( content == _this.content ) { if( content == _this.content ) {
let session = codiad.active.sessions[path]; let session = codiad.active.sessions[path];
@ -180,7 +215,7 @@
return; return;
} }
/*
this code caused issues even though it is the proper way to save something. this code caused issues even though it is the proper way to save something.
Whenever in collaboration, the server constantly gave a wrong file version error. Whenever in collaboration, the server constantly gave a wrong file version error.
@ -210,13 +245,6 @@
} }
} }
_this.saving = false; _this.saving = false;
setTimeout(function() {
//Call the function again after one second so that if we missed the last change we resave the file.
let _this = codiad.auto_save;
_this.auto_save();
}, 1000);
}, },
reload_interval: async function() { reload_interval: async function() {
@ -226,7 +254,13 @@
window.clearInterval( codiad.autosave.auto_save_trigger ); window.clearInterval( codiad.autosave.auto_save_trigger );
window.clearInterval( this.auto_save_trigger ); window.clearInterval( this.auto_save_trigger );
} catch( error ) {} } catch( error ) {
if( codiad.auto_save.verbose ) {
console.log( "Error clearing interval", error );
}
}
if( codiad.auto_save.settings.autosave == true || codiad.auto_save.settings.autosave == "true" ) { if( codiad.auto_save.settings.autosave == true || codiad.auto_save.settings.autosave == "true" ) {

View file

@ -3,7 +3,6 @@
* as-is and without warranty under the MIT License. See * as-is and without warranty under the MIT License. See
* [root]/license.txt for more. This information must remain intact. * [root]/license.txt for more. This information must remain intact.
*/ */
( function( global, $ ) { ( function( global, $ ) {
// Classes from Ace // Classes from Ace
@ -46,8 +45,7 @@
if( _this.splitType === 'horizontal' ) { if( _this.splitType === 'horizontal' ) {
var w1, w2; var w1, w2;
w1 = ui.position.left - separatorWidth / 2; w1 = ui.position.left - separatorWidth / 2;
w2 = _this.root.width() - ui.position.left w2 = _this.root.width() - ui.position.left - separatorWidth / 2;
- separatorWidth/2;
_this.splitProp = w1 / _this.root.width(); _this.splitProp = w1 / _this.root.width();
_this.childElements[0] _this.childElements[0]
.width( w1 ) .width( w1 )
@ -60,8 +58,8 @@
} else { } else {
var h1, h2; var h1, h2;
h1 = ui.position.top - separatorWidth / 2; h1 = ui.position.top - separatorWidth / 2;
h2 = _this.root.width() - ui.position.top h2 = _this.root.width() - ui.position.top -
- separatorWidth/2; separatorWidth / 2;
_this.splitProp = h1 / _this.root.height(); _this.splitProp = h1 / _this.root.height();
_this.childElements[0] _this.childElements[0]
.height( h1 ) .height( h1 )
@ -90,10 +88,10 @@
e.stopPropagation(); e.stopPropagation();
if( _this.splitType === 'horizontal' ) { if( _this.splitType === 'horizontal' ) {
var w1, w2; var w1, w2;
w1 = _this.root.width() * _this.splitProp w1 = _this.root.width() * _this.splitProp -
- separatorWidth / 2; separatorWidth / 2;
w2 = _this.root.width() * (1 - _this.splitProp) w2 = _this.root.width() * ( 1 - _this.splitProp ) -
- separatorWidth / 2; separatorWidth / 2;
_this.childElements[0] _this.childElements[0]
.width( w1 ); .width( w1 );
_this.childElements[1] _this.childElements[1]
@ -132,10 +130,10 @@
.height( h ); .height( h );
_this.splitter.height( h ); _this.splitter.height( h );
} else if( _this.splitType === 'vertical' ) { } else if( _this.splitType === 'vertical' ) {
var h1 = _this.root.height() * _this.splitProp var h1 = _this.root.height() * _this.splitProp -
- separatorWidth / 2; separatorWidth / 2;
var h2 = _this.root.height() * (1 - _this.splitProp) var h2 = _this.root.height() * ( 1 - _this.splitProp ) -
- separatorWidth / 2; separatorWidth / 2;
_this.childElements[0] _this.childElements[0]
.height( h1 ); .height( h1 );
_this.childElements[1] _this.childElements[1]
@ -410,7 +408,9 @@
addInstance: function( session, where ) { addInstance: function( session, where ) {
var el = $( '<div class="editor">' ); var el = $( '<div class="editor">' );
var chType, chArr = [], sc = null, chIdx = null; var chType, chArr = [],
sc = null,
chIdx = null;
var _this = this; var _this = this;
if( this.instances.length == 0 ) { if( this.instances.length == 0 ) {
@ -1282,10 +1282,10 @@
*/ */
$( '#cursor-position' ) $( '#cursor-position' )
.html(i18n('Ln') + ': ' .html( i18n( 'Ln' ) + ': ' +
+ (i.getCursorPosition().row + 1) ( i.getCursorPosition().row + 1 ) +
+ ' &middot; ' + i18n('Col') + ': ' ' &middot; ' + i18n( 'Col' ) + ': ' +
+ i.getCursorPosition().column i.getCursorPosition().column
); );
//Register the changecursor function so updates continue //Register the changecursor function so updates continue
@ -1293,10 +1293,10 @@
codiad.active.savePosition(); codiad.active.savePosition();
$( '#cursor-position' ) $( '#cursor-position' )
.html(i18n('Ln') + ': ' .html( i18n( 'Ln' ) + ': ' +
+ (i.getCursorPosition().row + 1) ( i.getCursorPosition().row + 1 ) +
+ ' &middot; ' + i18n('Col') + ': ' ' &middot; ' + i18n( 'Col' ) + ': ' +
+ i.getCursorPosition().column i.getCursorPosition().column
); );
}); });
}, },
@ -1549,7 +1549,9 @@
paste: function() { paste: function() {
navigator.clipboard.readText().then(text => {codiad.editor.getActive().insert( text )}); navigator.clipboard.readText().then( text => {
codiad.editor.getActive().insert( text )
});
}, },
openSort: function() { openSort: function() {

View file

@ -3,17 +3,15 @@
* as-is and without warranty under the MIT License. See * as-is and without warranty under the MIT License. See
* [root]/license.txt for more. This information must remain intact. * [root]/license.txt for more. This information must remain intact.
*/ */
( function( global, $ ) { ( function( global, $ ) {
var codiad = global.codiad; var codiad = global.codiad;
$(window) $( window ).load( function() {
.load(function() {
codiad.filemanager.init(); codiad.filemanager.init();
}); });
codiad.filemanager = { codiad.filemanager = {
auto_reload: false, auto_reload: false,
@ -22,6 +20,7 @@
dialog: 'components/filemanager/dialog.php', dialog: 'components/filemanager/dialog.php',
dialogUpload: 'components/filemanager/dialog_upload.php', dialogUpload: 'components/filemanager/dialog_upload.php',
preview: null, preview: null,
refresh_interval: null,
init: async function() { init: async function() {
@ -33,7 +32,7 @@
'mp4', 'mp4',
'wav', 'wav',
'ogg', 'ogg',
], ];
this.noFiles = [ this.noFiles = [
//Files //Files
'exe', 'exe',
@ -41,7 +40,7 @@
'zip', 'zip',
'tar', 'tar',
'tar.gz', 'tar.gz',
], ];
this.noImages = [ this.noImages = [
//Images //Images
'ico', 'ico',
@ -51,7 +50,7 @@
'png', 'png',
'gif', 'gif',
'bmp', 'bmp',
], ];
this.noOpen = this.noAudio.concat( this.noFiles, this.noImages ), this.noOpen = this.noAudio.concat( this.noFiles, this.noImages ),
@ -96,7 +95,8 @@
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
nodeListener: function() { nodeListener: function() {
var _this = this;
let _this = this;
$( '#file-manager' ).on( 'selectstart', false ); $( '#file-manager' ).on( 'selectstart', false );
@ -178,7 +178,7 @@
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
contextMenuShow: function( e, path, type, name ) { contextMenuShow: function( e, path, type, name ) {
var _this = this; let _this = this;
$( '#context-menu a, #context-menu hr' ).hide(); $( '#context-menu a, #context-menu hr' ).hide();
// Selective options // Selective options
@ -240,7 +240,11 @@
$( '#context-menu, #editor-region' ).on( 'paste', codiad.editor.paste ); $( '#context-menu, #editor-region' ).on( 'paste', codiad.editor.paste );
/* Notify listeners. */ /* Notify listeners. */
amplify.publish('context-menu.onShow', {e: e, path: path, type: type}); amplify.publish( 'context-menu.onShow', {
e: e,
path: path,
type: type
});
// Hide on click // Hide on click
$( '#context-menu a' ) $( '#context-menu a' )
.click( function() { .click( function() {
@ -346,7 +350,7 @@
indexFiles: [], indexFiles: [],
index: function( path, rescan ) { index: function( path, rescan ) {
var _this = this; let _this = this;
if( rescan === undefined ) { if( rescan === undefined ) {
rescan = false; rescan = false;
} }
@ -360,41 +364,54 @@
node.removeClass( 'open' ); node.removeClass( 'open' );
}); });
} else { } else {
node.addClass( 'loading' ); node.addClass( 'loading' );
$.get( this.controller + '?action=index&path=' + encodeURIComponent( path ), function( data ) { $.get( this.controller + '?action=index&path=' + encodeURIComponent( path ), function( data ) {
node.addClass( 'open' ); node.addClass( 'open' );
var objectsResponse = codiad.jsend.parse( data ); var objectsResponse = codiad.jsend.parse( data );
if( objectsResponse != 'error' ) { if( objectsResponse != 'error' ) {
/* Notify listener */ /* Notify listener */
_this.indexFiles = objectsResponse.index; _this.indexFiles = objectsResponse.index;
amplify.publish("filemanager.onIndex", {path: path, files: _this.indexFiles}); amplify.publish( "filemanager.onIndex", {
path: path,
files: _this.indexFiles
});
var files = _this.indexFiles; var files = _this.indexFiles;
if( files.length > 0 ) { if( files.length > 0 ) {
if( node.parent().children( 'span' ).hasClass( 'plus' ) ) { if( node.parent().children( 'span' ).hasClass( 'plus' ) ) {
node.parent().children( 'span' ).removeClass( 'plus' ).addClass( 'minus' ); node.parent().children( 'span' ).removeClass( 'plus' ).addClass( 'minus' );
} }
var display = 'display:none;'; var display = 'display:none;';
if( rescan ) { if( rescan ) {
display = ''; display = '';
} }
var appendage = '<ul style="' + display + '">'; var appendage = '<ul style="' + display + '">';
$.each( files, function( index ) { $.each( files, function( index ) {
var ext = ''; var ext = '';
var name = files[index].name.replace( path, '' ); var name = files[index].name.replace( path, '' );
var nodeClass = 'none'; var nodeClass = 'none';
name = name.split( '/' ) name = name.split( '/' )
.join( ' ' ); .join( ' ' );
if( files[index].type == 'file' ) { if( files[index].type == 'file' ) {
var ext = ' ext-' + name.split( '.' ) var ext = ' ext-' + name.split( '.' )
.pop(); .pop();
} }
if( files[index].type == 'directory' && files[index].size > 0 ) { if( files[index].type == 'directory' && files[index].size > 0 ) {
nodeClass = 'plus'; nodeClass = 'plus';
} }
appendage += '<li><span class="' + nodeClass + '"></span><a class="' + files[index].type + ext + '" data-type="' + files[index].type + '" data-path="' + files[index].name + '">' + name + '</a></li>'; appendage += '<li><span class="' + nodeClass + '"></span><a class="' + files[index].type + ext + '" data-type="' + files[index].type + '" data-path="' + files[index].name + '">' + name + '</a></li>';
}); });
appendage += '</ul>'; appendage += '</ul>';
if( rescan ) { if( rescan ) {
node.parent( 'li' ) node.parent( 'li' )
.children( 'ul' ) .children( 'ul' )
.remove(); .remove();
@ -402,6 +419,7 @@
$( appendage ) $( appendage )
.insertAfter( node ); .insertAfter( node );
if( !rescan ) { if( !rescan ) {
node.siblings( 'ul' ) node.siblings( 'ul' )
.slideDown( 300 ); .slideDown( 300 );
} }
@ -409,8 +427,10 @@
} }
node.removeClass( 'loading' ); node.removeClass( 'loading' );
if( rescan && _this.rescanChildren.length > _this.rescanCounter ) { if( rescan && _this.rescanChildren.length > _this.rescanCounter ) {
_this.rescan( _this.rescanChildren[_this.rescanCounter++] ); _this.rescan( _this.rescanChildren[_this.rescanCounter++] );
} else { } else {
_this.rescanChildren = []; _this.rescanChildren = [];
_this.rescanCounter = 0; _this.rescanCounter = 0;
} }
@ -423,7 +443,7 @@
rescanCounter: 0, rescanCounter: 0,
rescan: function( path ) { rescan: function( path ) {
var _this = this; let _this = this;
if( this.rescanCounter === 0 ) { if( this.rescanCounter === 0 ) {
// Create array of open directories // Create array of open directories
node = $( '#file-manager a[data-path="' + path + '"]' ); node = $( '#file-manager a[data-path="' + path + '"]' );
@ -442,7 +462,9 @@
openFile: function( path, focus ) { openFile: function( path, focus ) {
/* Notify listeners. */ /* Notify listeners. */
amplify.publish('filemanager.onFileWillOpen', {path: path}); amplify.publish( 'filemanager.onFileWillOpen', {
path: path
});
if( focus === undefined ) { if( focus === undefined ) {
focus = true; focus = true;
@ -503,7 +525,21 @@
refreshPreview: function( event ) { refreshPreview: function( event ) {
_this = codiad.filemanager; let _this = codiad.filemanager;
/**
* When reloading after every change, we encounter performance issues
* in the editor. Therefore, we implement the same logic as the
* auto_save module where we only reload after the user has finished
* changing their document.
*/
if( _this.refresh_interval !== null ) {
clearTimeout( _this.refresh_interval );
_this.refresh_interval = null;
}
_this.refresh_interval = setTimeout( function() {
if( _this.preview == null ) { if( _this.preview == null ) {
@ -526,6 +562,7 @@
_this.preview = null; _this.preview = null;
codiad.editor.getActive().removeEventListener( "change", _this.refreshPreview ); codiad.editor.getActive().removeEventListener( "change", _this.refreshPreview );
} }
}, 500 );
}, },
openInModal: function( path ) { openInModal: function( path ) {
@ -547,8 +584,9 @@
}); });
}, },
saveModifications: function( path, data, callbacks, save = true ) { saveModifications: function( path, data, callbacks, save = true ) {
callbacks = callbacks || {}; callbacks = callbacks || {};
var _this = this, action, data; let _this = this, action;
var notifySaveErr = function() { var notifySaveErr = function() {
codiad.message.error( i18n( 'File could not be saved' ) ); codiad.message.error( i18n( 'File could not be saved' ) );
if( typeof callbacks.error === 'function' ) { if( typeof callbacks.error === 'function' ) {
@ -596,12 +634,17 @@
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
saveFile: function( path, content, callbacks, save = true ) { saveFile: function( path, content, callbacks, save = true ) {
this.saveModifications(path, {content: content}, callbacks, save); this.saveModifications( path, {
content: content
}, callbacks, save );
}, },
savePatch: function( path, patch, mtime, callbacks, alerts ) { savePatch: function( path, patch, mtime, callbacks, alerts ) {
if( patch.length > 0 ) if( patch.length > 0 )
this.saveModifications(path, {patch: patch, mtime: mtime}, callbacks, alerts); this.saveModifications( path, {
patch: patch,
mtime: mtime
}, callbacks, alerts );
else if( typeof callbacks.success === 'function' ) { else if( typeof callbacks.success === 'function' ) {
var context = callbacks.context || this; var context = callbacks.context || this;
callbacks.success.call( context, mtime ); callbacks.success.call( context, mtime );
@ -620,7 +663,6 @@
}); });
$( '#modal-content form' ) $( '#modal-content form' )
.live( 'submit', function( e ) { .live( 'submit', function( e ) {
let project = codiad.project.getCurrent();
e.preventDefault(); e.preventDefault();
var shortName = $( '#modal-content form input[name="object_name"]' ) var shortName = $( '#modal-content form input[name="object_name"]' )
.val(); .val();
@ -641,10 +683,15 @@
codiad.filemanager.openFile( createPath, true ); codiad.filemanager.openFile( createPath, true );
} }
codiad.filemanager.rescan( project ); codiad.filemanager.rescan( path );
/* Notify listeners. */ /* Notify listeners. */
amplify.publish('filemanager.onCreate', {createPath: createPath, path: path, shortName: shortName, type: type}); amplify.publish( 'filemanager.onCreate', {
createPath: createPath,
path: path,
shortName: shortName,
type: type
});
} }
}); });
}); });
@ -664,7 +711,7 @@
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
pasteNode: function( path ) { pasteNode: function( path ) {
var _this = this; let _this = this;
if( this.clipboard == '' ) { if( this.clipboard == '' ) {
codiad.message.error( i18n( 'Nothing in Your Clipboard' ) ); codiad.message.error( i18n( 'Nothing in Your Clipboard' ) );
} else if( path == this.clipboard ) { } else if( path == this.clipboard ) {
@ -683,7 +730,8 @@
e.preventDefault(); e.preventDefault();
var duplicate = false; var duplicate = false;
if( $( '#modal-content form select[name="or_action"]' ).val() == 1 ) { if( $( '#modal-content form select[name="or_action"]' ).val() == 1 ) {
duplicate=true; console.log('Dup!'); duplicate = true;
console.log( 'Dup!' );
} }
_this.processPasteNode( path, duplicate ); _this.processPasteNode( path, duplicate );
}); });
@ -696,19 +744,24 @@
}, },
processPasteNode: function( path, duplicate ) { processPasteNode: function( path, duplicate ) {
var _this = this; let _this = this;
var shortName = this.getShortName( this.clipboard ); var shortName = this.getShortName( this.clipboard );
var type = this.getType( this.clipboard ); var type = this.getType( this.clipboard );
$.get( this.controller + '?action=duplicate&path=' + $.get( this.controller + '?action=duplicate&path=' +
encodeURIComponent( this.clipboard ) + '&destination=' + encodeURIComponent( this.clipboard ) + '&destination=' +
encodeURIComponent(path + '/' + shortName) + '&duplicate=' + encodeURIComponent( duplicate ), function(data) { encodeURIComponent( path + '/' + shortName ) + '&duplicate=' + encodeURIComponent( duplicate ),
function( data ) {
var pasteResponse = codiad.jsend.parse( data ); var pasteResponse = codiad.jsend.parse( data );
if( pasteResponse != 'error' ) { if( pasteResponse != 'error' ) {
_this.createObject( path, path + '/' + shortName, type ); _this.createObject( path, path + '/' + shortName, type );
codiad.modal.unload(); codiad.modal.unload();
/* Notify listeners. */ /* Notify listeners. */
amplify.publish('filemanager.onPaste', {path: path, shortName: shortName, duplicate: duplicate}); amplify.publish( 'filemanager.onPaste', {
path: path,
shortName: shortName,
duplicate: duplicate
});
} }
}); });
}, },
@ -720,8 +773,13 @@
renameNode: function( path ) { renameNode: function( path ) {
var shortName = this.getShortName( path ); var shortName = this.getShortName( path );
var type = this.getType( path ); var type = this.getType( path );
var _this = this; let _this = this;
codiad.modal.load(250, this.dialog, { action: 'rename', path: path, short_name: shortName, type: type}); codiad.modal.load( 250, this.dialog, {
action: 'rename',
path: path,
short_name: shortName,
type: type
});
$( '#modal-content form' ) $( '#modal-content form' )
.live( 'submit', function( e ) { .live( 'submit', function( e ) {
let project = codiad.project.getCurrent(); let project = codiad.project.getCurrent();
@ -735,7 +793,11 @@
temp.push( arr[i] ) temp.push( arr[i] )
} }
var newPath = temp.join( '/' ) + '/' + newName; var newPath = temp.join( '/' ) + '/' + newName;
$.get(_this.controller, { action: 'modify', path: path, new_name: newName} , function(data) { $.get( _this.controller, {
action: 'modify',
path: path,
new_name: newName
}, function( data ) {
var renameResponse = codiad.jsend.parse( data ); var renameResponse = codiad.jsend.parse( data );
let renamedMessage = ""; let renamedMessage = "";
if( renameResponse != 'error' ) { if( renameResponse != 'error' ) {
@ -765,9 +827,16 @@
// Change any active files // Change any active files
codiad.active.rename( path, newPath ); codiad.active.rename( path, newPath );
codiad.modal.unload(); codiad.modal.unload();
codiad.filemanager.rescan( project );
let parent = path.split( '/' );
parent.pop();
codiad.filemanager.rescan( parent.join( '/' ) );
/* Notify listeners. */ /* Notify listeners. */
amplify.publish('filemanager.onRename', {path: path, newPath: newPath, project: project }); amplify.publish( 'filemanager.onRename', {
path: path,
newPath: newPath,
project: project
});
} }
}); });
}); });
@ -792,7 +861,7 @@
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
deleteNode: function( path ) { deleteNode: function( path ) {
var _this = this; let _this = this;
codiad.modal.load( 400, this.dialog, { codiad.modal.load( 400, this.dialog, {
action: 'delete', action: 'delete',
path: path path: path
@ -816,7 +885,10 @@
} }
}); });
/* Notify listeners. */ /* Notify listeners. */
amplify.publish('filemanager.onDelete', {deletePath: path, path: parent_path }); amplify.publish( 'filemanager.onDelete', {
deletePath: path,
path: parent_path
});
} }
codiad.modal.unload(); codiad.modal.unload();
}); });
@ -824,7 +896,7 @@
}, },
deleteInnerNode: function( path ) { deleteInnerNode: function( path ) {
var _this = this; let _this = this;
codiad.modal.load( 400, this.dialog, { codiad.modal.load( 400, this.dialog, {
action: 'delete', action: 'delete',
path: path path: path
@ -856,7 +928,10 @@
}); });
/* Notify listeners. */ /* Notify listeners. */
amplify.publish('filemanager.onDelete', {deletePath: path + "/*", path: path }); amplify.publish( 'filemanager.onDelete', {
deletePath: path + "/*",
path: path
});
} }
codiad.modal.unload(); codiad.modal.unload();
}); });
@ -883,7 +958,7 @@
} }
}); });
codiad.modal.hideOverlay(); codiad.modal.hideOverlay();
var _this = this; let _this = this;
$( '#modal-content form' ) $( '#modal-content form' )
.live( 'submit', function( e ) { .live( 'submit', function( e ) {
$( '#filemanager-search-processing' ) $( '#filemanager-search-processing' )
@ -947,7 +1022,9 @@
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
uploadToNode: function( path ) { uploadToNode: function( path ) {
codiad.modal.load(500, this.dialogUpload, {path: path}); codiad.modal.load( 500, this.dialogUpload, {
path: path
});
}, },
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////

View file

@ -1,9 +1,5 @@
<?php <?php
//ini_set('display_errors', 1);
//ini_set('display_startup_errors', 1);
//error_reporting(E_ALL);
require_once( __DIR__ . "/../sql/class.sql.php" ); require_once( __DIR__ . "/../sql/class.sql.php" );
require_once( __DIR__ . "/../settings/class.settings.php" ); require_once( __DIR__ . "/../settings/class.settings.php" );
@ -129,11 +125,11 @@ date_default_timezone_set("' . $_POST['timezone'] . '");
define("SITE_NAME", "' . $_POST['site_name'] . '"); define("SITE_NAME", "' . $_POST['site_name'] . '");
// Database Information // Database Information
define( "DBHOST", "' . $_POST['dbhost'] . '" ); define( "DBHOST", \'' . addslashes( urldecode( $_POST['dbhost'] ) ) . '\' );
define( "DBNAME", "' . $_POST['dbname'] . '" ); define( "DBNAME", \'' . addslashes( urldecode( $_POST['dbname'] ) ) . '\' );
define( "DBUSER", "' . $_POST['dbuser'] . '" ); define( "DBUSER", \'' . addslashes( urldecode( $_POST['dbuser'] ) ) . '\' );
define( "DBPASS", "' . $_POST['dbpass'] . '" ); define( "DBPASS", \'' . addslashes( urldecode( $_POST['dbpass'] ) ) . '\' );
define( "DBTYPE", "' . $_POST['dbtype'] . '" ); define( "DBTYPE", \'' . addslashes( urldecode( $_POST['dbtype'] ) ) . '\' );
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
// ** DO NOT EDIT CONFIG BELOW ** // ** DO NOT EDIT CONFIG BELOW **

View file

@ -170,7 +170,7 @@ if ( ! empty( $query ) ) {
"MBString"=>"required", "MBString"=>"required",
"MySQL"=>"", "MySQL"=>"",
"PGSQL"=>"", "PGSQL"=>"",
"SQLite3"=>"" //"SQLite3"=>""
] as $dep=>$status) { ] as $dep=>$status) {
if (extension_loaded(strtolower($dep))) { ?> if (extension_loaded(strtolower($dep))) { ?>
<div class="success"><span class="icon-check"></span> <?=$dep?></div> <div class="success"><span class="icon-check"></span> <?=$dep?></div>

View file

@ -107,6 +107,11 @@ switch( $_GET['action'] ) {
?> ?>
<td width="70"><a onclick="codiad.message.error(i18n('Active Project Cannot Be Removed'));" class="icon-block bigger-icon"></a></td> <td width="70"><a onclick="codiad.message.error(i18n('Active Project Cannot Be Removed'));" class="icon-block bigger-icon"></a></td>
<?php <?php
} elseif( $owner !== $_SESSION["user"] ) {
?>
<td width="70"><a onclick="codiad.message.error(i18n('Projects owned by others can not be deleted'));" class="icon-block bigger-icon"></a></td>
<?php
} else { } else {
?> ?>

View file

@ -1,60 +1,14 @@
<?php <?php
require_once('../../common.php'); require_once('../../common.php');
?> ?>
<label><span class="icon-home big-icon"></span><?php i18n("Editor Settings");?></label> <label><span class="icon-home big-icon"></span><?php i18n("Editor Settings");?></label>
<hr> <hr>
<table class="settings"> <table class="settings">
<tr> <tr>
<td width="50%"><?php i18n("Theme"); ?></td>
<td>
<select class="setting" data-setting="codiad.editor.theme">
<option value="ambiance">Ambiance</option>
<option value="chaos">Chaos</option>
<option value="chrome">Chrome</option>
<option value="clouds">Clouds</option>
<option value="clouds_midnight">Clouds - Midnight</option>
<option value="cobalt">Cobalt</option>
<option value="crimson_editor">Crimson Editor</option>
<option value="dawn">Dawn</option>
<option value="dreamweaver">Dreamweaver</option>
<option value="eclipse">Eclipse</option>
<option value="github">GitHub</option>
<option value="idle_fingers">Idle Fingers</option>
<option value="iplastic">IPlastic</option>
<option value="katzenmilch">Katzenmilch</option>
<option value="kuroir">Kuroir</option>
<option value="kr_theme">krTheme</option>
<option value="merbivore">Merbivore</option>
<option value="merbivore_soft">Merbivore Soft</option>
<option value="mono_industrial">Mono Industrial</option>
<option value="monokai">Monokai</option>
<option value="pastel_on_dark">Pastel On Dark</option>
<option value="solarized_dark">Solarized Dark</option>
<option value="solarized_light">Solarized Light</option>
<option value="sqlserver">SQL Server</option>
<option value="terminal">Terminal</option>
<option value="textmate">Textmate</option>
<option value="tomorrow">Tomorrow</option>
<option value="tomorrow_night">Tomorrow Night</option>
<option value="tomorrow_night_blue">Tomorrow Night Blue</option>
<option value="tomorrow_night_bright">Tomorrow Night Bright</option>
<option value="tomorrow_night_eighties">Tomorrow Night Eighties</option>
<option value="twilight" selected>Twilight</option>
<option value="vibrant_ink">Vibrant Ink</option>
<option value="xcode">XCode</option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Font Size");?></td> <td><?php i18n("Font Size");?></td>
<td> <td>
<select class="setting" data-setting="codiad.editor.fontSize"> <select class="setting" data-setting="codiad.editor.fontSize">
<option value="10px">10px</option> <option value="10px">10px</option>
<option value="11px">11px</option> <option value="11px">11px</option>
@ -66,54 +20,57 @@
<option value="17px">17px</option> <option value="17px">17px</option>
<option value="18px">18px</option> <option value="18px">18px</option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><?php i18n("Highlight Active Line");?></td> <td><?php i18n("Highlight Active Line");?></td>
<td> <td>
<select class="setting" data-setting="codiad.editor.highlightLine"> <select class="setting" data-setting="codiad.editor.highlightLine">
<option value="true" selected><?php i18n("Yes");?></option> <option value="true" selected><?php i18n("Yes");?></option>
<option value="false"><?php i18n("No");?></option> <option value="false"><?php i18n("No");?></option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><?php i18n("Indent Guides");?></td> <td><?php i18n("Indent Guides");?></td>
<td> <td>
<select class="setting" data-setting="codiad.editor.indentGuides"> <select class="setting" data-setting="codiad.editor.indentGuides">
<option value="true" selected><?php i18n("On");?></option> <option value="true" selected><?php i18n("On");?></option>
<option value="false"><?php i18n("Off");?></option> <option value="false"><?php i18n("Off");?></option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><?php i18n("Live Autocomplete"); ?></td>
<td>
<select class="setting" data-setting="codiad.editor.autocomplete">
<option value="false" selected><?php i18n("Off");?></option>
<option value="true"><?php i18n("On"); ?></option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Over Scroll"); ?></td>
<td>
<select class="setting" data-setting="codiad.editor.overScroll">
<option value="0" selected><?php i18n("None");?></option>
<option value="0.5"><?php i18n("Half");?></option>
<option value="1"><?php i18n("Full");?></option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Print Margin"); ?></td> <td><?php i18n("Print Margin"); ?></td>
<td> <td>
<select class="setting" data-setting="codiad.editor.printMargin"> <select class="setting" data-setting="codiad.editor.printMargin">
<option value="true"><?php i18n("Show");?></option> <option value="true"><?php i18n("Show");?></option>
<option value="false" selected><?php i18n("Hide");?></option> <option value="false" selected><?php i18n("Hide");?></option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><?php i18n("Print Margin Column");?></td> <td><?php i18n("Print Margin Column");?></td>
<td> <td>
<select class="setting" data-setting="codiad.editor.printMarginColumn"> <select class="setting" data-setting="codiad.editor.printMarginColumn">
<option value="80" selected>80</option> <option value="80" selected>80</option>
<option value="85">85</option> <option value="85">85</option>
@ -125,28 +82,20 @@
<option value="115">115</option> <option value="115">115</option>
<option value="120">120</option> <option value="120">120</option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><?php i18n("Soft Tabs");?></td>
<td><?php i18n("Wrap Lines"); ?></td>
<td> <td>
<select class="setting" data-setting="codiad.editor.softTabs">
<select class="setting" data-setting="codiad.editor.wrapMode"> <option value="false" selected><?php i18n("No");?></option>
<option value="false" selected><?php i18n("No wrap"); ?></option> <option value="true"><?php i18n("Yes");?></option>
<option value="true"><?php i18n("Wrap Lines"); ?></option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><?php i18n("Tab Size");?></td> <td><?php i18n("Tab Size");?></td>
<td> <td>
<select class="setting" data-setting="codiad.editor.tabSize"> <select class="setting" data-setting="codiad.editor.tabSize">
<option value="2">2</option> <option value="2">2</option>
<option value="3">3</option> <option value="3">3</option>
@ -156,46 +105,36 @@
<option value="7">7</option> <option value="7">7</option>
<option value="8">8</option> <option value="8">8</option>
</select> </select>
</td>
</tr>
<tr>
<td><?php i18n("Soft Tabs"); ?></td>
<td>
<select class="setting" data-setting="codiad.editor.softTabs">
<option value="false" selected><?php i18n("No"); ?></option>
<option value="true"><?php i18n("Yes"); ?></option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Over Scroll"); ?></td>
<td>
<select class="setting" data-setting="codiad.editor.overScroll">
<option value="0" selected><?php i18n("None"); ?></option>
<option value="0.5"><?php i18n("Half"); ?></option>
<option value="1"><?php i18n("Full"); ?></option>
</select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="50%"><?php i18n("Theme");?></td>
<td><?php i18n("Live Autocomplete"); ?></td>
<td> <td>
<select class="setting" data-setting="codiad.editor.theme">
<?php
<select class="setting" data-setting="codiad.editor.autocomplete"> $files = glob( COMPONENTS . "/editor/ace-editor/*.js" );
<option value="false" selected><?php i18n("Off"); ?></option> foreach( $files as $file ) {
<option value="true"><?php i18n("On"); ?></option>
$name = pathinfo( $file, PATHINFO_FILENAME );
if( strpos( strtolower( $name ), strtolower( "theme-" ) ) !== false ) {
$value = str_replace( "theme-", "", str_replace( ".js", "", $name ) );
$name = ucwords( str_replace( "_", " ", $value ) );
?><option value="<?php echo $value;?>"><?php echo $name;?></option><?php
}
}
?>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Wrap Lines"); ?></td>
<td>
<select class="setting" data-setting="codiad.editor.wrapMode">
<option value="false" selected><?php i18n("No wrap");?></option>
<option value="true"><?php i18n("Wrap Lines");?></option>
</select> </select>
</td> </td>
</tr> </tr>
</table> </table>

View file

@ -7,8 +7,8 @@ class sql {
const DB_TYPES = array( const DB_TYPES = array(
"MySQL" => "mysql", "MySQL" => "mysql",
"PostgresSQL" => "pgsql", "PostgreSQL" => "pgsql",
"SQLite" => "sqlite", //"SQLite" => "sqlite",
); );
public $connection = null; public $connection = null;

View file

@ -12,7 +12,7 @@ class Update {
// CONSTANTS // CONSTANTS
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
CONST VERSION = "v.2.9.4.1"; CONST VERSION = "v.2.9.5";
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
// PROPERTIES // PROPERTIES

View file

@ -5,11 +5,14 @@
//error_reporting(E_ALL); //error_reporting(E_ALL);
require_once('../../common.php'); require_once('../../common.php');
require_once('../settings/class.settings.php');
require_once('./class.update.php'); require_once('./class.update.php');
$user_settings_file = DATA . "/settings.php";
$projects_file = DATA . "/projects.php";
$users_file = DATA . "/users.php"; $user_settings_file = BASE_PATH . "/data/settings.php";
$projects_file = BASE_PATH . "/data/projects.php";
$users_file = BASE_PATH . "/data/users.php";
//checkSession(); //checkSession();
if ( ! checkAccess() ) { if ( ! checkAccess() ) {
echo "Error, you do not have access to update Codiad."; echo "Error, you do not have access to update Codiad.";
@ -102,8 +105,6 @@ class updater {
mkdir( $backup, 00755 ); mkdir( $backup, 00755 );
} }
function copy_backup( $source, $dest ) { function copy_backup( $source, $dest ) {
// Check for symlinks // Check for symlinks
@ -173,8 +174,6 @@ class updater {
function check_sql() { function check_sql() {
require_once('../../common.php');
require_once('../sql/class.sql.php');
$sql = new sql(); $sql = new sql();
$connection = $sql->connect(); $connection = $sql->connect();
$result = $sql->create_default_tables(); $result = $sql->create_default_tables();
@ -211,9 +210,6 @@ class updater {
function convert() { function convert() {
require_once('../sql/class.sql.php');
require_once('../settings/class.settings.php');
$user_settings_file = DATA . "/settings.php"; $user_settings_file = DATA . "/settings.php";
$projects_file = DATA . "/projects.php"; $projects_file = DATA . "/projects.php";
$users_file = DATA . "/users.php"; $users_file = DATA . "/users.php";
@ -235,6 +231,9 @@ class updater {
if( file_exists( $projects_file ) ) { if( file_exists( $projects_file ) ) {
$projects = getJSON( 'projects.php' ); $projects = getJSON( 'projects.php' );
if( is_array( $projects ) ) {
foreach( $projects as $project => $data ) { foreach( $projects as $project => $data ) {
$owner = 'nobody'; $owner = 'nobody';
@ -249,12 +248,16 @@ class updater {
exit( formatJSEND( "error", "There was an error adding projects to database." ) ); exit( formatJSEND( "error", "There was an error adding projects to database." ) );
} }
} }
}
unlink( $projects_file ); unlink( $projects_file );
} }
if( file_exists( $users_file ) ) { if( file_exists( $users_file ) ) {
$users = getJSON( 'users.php' ); $users = getJSON( 'users.php' );
if( is_array( $users ) ) {
foreach( $users as $user ) { foreach( $users as $user ) {
if( $user["username"] === $_SESSION["user"] ) { if( $user["username"] === $_SESSION["user"] ) {
@ -279,6 +282,7 @@ class updater {
exit(formatJSEND( "error", "The Username is Already Taken" )); exit(formatJSEND( "error", "The Username is Already Taken" ));
} }
} }
}
unlink( $users_file ); unlink( $users_file );
} }
} }
@ -415,7 +419,7 @@ class updater {
function remove_directory( $path ) { function remove_directory( $path ) {
$files = glob($path . '/*'); $files = glob( $path . '{,.}[!.,!..]*', GLOB_MARK|GLOB_BRACE );
foreach( $files as $file ) { foreach( $files as $file ) {
is_dir( $file ) ? $this->remove_directory( $file ) : unlink( $file ); is_dir( $file ) ? $this->remove_directory( $file ) : unlink( $file );
@ -524,8 +528,6 @@ class updater {
$this->copyr( $src, $dest ); $this->copyr( $src, $dest );
$this->remove_directory( $src ); $this->remove_directory( $src );
$this->convert();
$this->check_sql();
return( "true" ); return( "true" );
} catch( Exception $e ) { } catch( Exception $e ) {
@ -534,6 +536,21 @@ class updater {
} }
} }
public function update_database() {
try {
$this->convert();
} catch( Exception $e ) {
$this->restore();
return( $e );
}
$this->check_sql();
return( "true" );
}
public function update_option( $option, $value, $user_setting = null ) { public function update_option( $option, $value, $user_setting = null ) {
$sql = new sql(); $sql = new sql();
@ -619,6 +636,11 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
echo $updater->update(); echo $updater->update();
break; break;
case( "update_database" ):
echo $updater->update_database();
break;
} }
exit(); exit();
@ -674,6 +696,7 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
const codiad = {}; const codiad = {};
codiad.update = { codiad.update = {
base_url: `<?php echo BASE_URL;?>`,
progress: null, progress: null,
init: function() { init: function() {
@ -711,6 +734,35 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
}); });
}, },
apply_database: function() {
return jQuery.ajax({
url: "update.php",
type: "GET",
dataType: 'html',
data: {
action: 'update_database',
},
success: function( result ) {
return result;
},
error: function( jqXHR, textStatus, errorThrown ) {
console.log( 'jqXHR:' );
console.log( jqXHR );
console.log( 'textStatus:' );
console.log( textStatus);
console.log( 'errorThrown:' );
console.log( errorThrown );
return null;
}
});
},
check_update: function() { check_update: function() {
this.progress.innerText = "Checking for update ... "; this.progress.innerText = "Checking for update ... ";
@ -809,6 +861,33 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
update: async function() { update: async function() {
let GET = {};
let parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function( m, key, value) {
GET[key] = value;
});
if( Object.keys( GET ).includes( "step" ) && GET.step === "database_update" ) {
progress.innerText = "Applying database update.";
let apply = await this.apply_database();
if( apply !== "true" ) {
console.log( apply );
progress.innerText = "Error applying update.";
return;
}
progress.innerText = "Successfully completed update. Returning you to Codiad ...";
setTimeout( function() {
window.location.href = `${location.protocol}//${codiad.update.base_url}`;
}, 5000);
return;
}
let result = await this.check_update(); let result = await this.check_update();
console.log( result ); console.log( result );
@ -834,7 +913,7 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
return; return;
} }
progress.innerText = "Applying update."; progress.innerText = "Applying filesystem update.";
let apply = await this.apply(); let apply = await this.apply();
if( apply !== "true" ) { if( apply !== "true" ) {
@ -844,7 +923,12 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
return; return;
} }
progress.innerText = "Update Finished."; progress.innerText = "Filesystem update finished. Please wait, your browser will now reload and start the datbase update.";
setTimeout( function() {
window.location.href = window.location.href + "?step=database_update"
}, 5000);
} else if( result === "false" ) { } else if( result === "false" ) {
progress.innerText = "No update was found ..."; progress.innerText = "No update was found ...";
@ -856,6 +940,28 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
update_development: async function() { update_development: async function() {
let GET = {};
let parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function( m, key, value) {
GET[key] = value;
});
if( Object.keys( GET ).includes( "step" ) && GET.step === "database_update" ) {
progress.innerText = "Applying database update.";
let apply = await this.apply_database();
if( apply !== "true" ) {
console.log( apply );
progress.innerText = "Error applying update.";
return;
}
progress.innerText = "Successfully completed update. You may now return to Codiad.";
return;
}
progress.innerText = "An update was found. Downloading update."; progress.innerText = "An update was found. Downloading update.";
let download = await this.download( true ); let download = await this.download( true );
@ -876,7 +982,7 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
return; return;
} }
progress.innerText = "Applying update."; progress.innerText = "Applying filesystem update.";
let apply = await this.apply(); let apply = await this.apply();
if( apply !== "true" ) { if( apply !== "true" ) {
@ -886,7 +992,12 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
return; return;
} }
progress.innerText = "Update Finished."; progress.innerText = "Filesystem update finished. Please wait, your browser will now reload and start the datbase update.";
setTimeout( function() {
window.location.href = window.location.href + "?step=database_update"
}, 5000);
}, },
}; };
</script> </script>

View file

@ -41,7 +41,6 @@ class User {
public function __construct() { public function __construct() {
$this->actives = getJSON( 'active.php' );
} }
public function add_user() { public function add_user() {