From 7855aa2423cdde80362b3a57f032eb833525e926 Mon Sep 17 00:00:00 2001 From: daeks Date: Sun, 14 Apr 2013 10:27:23 +0200 Subject: [PATCH 01/11] close all button --- components/active/class.active.php | 14 +++++++ components/active/controller.php | 9 +++++ components/active/init.js | 61 +++++++++++++++++++++++++++++- index.php | 3 ++ themes/default/active/screen.css | 23 ++++++++++- 5 files changed, 107 insertions(+), 3 deletions(-) diff --git a/components/active/class.active.php b/components/active/class.active.php index badf1c1..5b1237f 100644 --- a/components/active/class.active.php +++ b/components/active/class.active.php @@ -130,6 +130,20 @@ class Active extends Common { echo formatJSEND("success"); } + ////////////////////////////////////////////////////////////////// + // Remove All Files + ////////////////////////////////////////////////////////////////// + + public function RemoveAll(){ + foreach($this->actives as $active=>$data){ + if(is_array($data) && isset($data['username']) && $this->username==$data['username']){ + unset($this->actives[$active]); + } + } + saveJSON('active.php',$this->actives); + echo formatJSEND("success"); + } + ////////////////////////////////////////////////////////////////// // Mark File As Focused // All other files will be marked as non-focused. diff --git a/components/active/controller.php b/components/active/controller.php index 27f03fb..8adcef5 100755 --- a/components/active/controller.php +++ b/components/active/controller.php @@ -67,6 +67,15 @@ $Active->Remove(); } + ////////////////////////////////////////////////////////////////// + // Remove all active record + ////////////////////////////////////////////////////////////////// + + if($_GET['action']=='removeall'){ + $Active->username = $_SESSION['user']; + $Active->RemoveAll(); + } + ////////////////////////////////////////////////////////////////// // Mark file as focused ////////////////////////////////////////////////////////////////// diff --git a/components/active/init.js b/components/active/init.js index 71ca1dc..b7cd6d8 100755 --- a/components/active/init.js +++ b/components/active/init.js @@ -510,6 +510,53 @@ this.close(path); } }, + + removeAll: function() { + var _this = this; + var changed = false; + + var opentabs = new Array(); + for(var session in _this.sessions) { + opentabs[session] = session; + if (_this.sessions[session].listThumb.hasClass('changed')) { + changed = true; + } + } + + if(changed) { + alert('Unsaved Files found. Please save them first.'); + } else { + for(var tab in opentabs) { + var session = this.sessions[tab]; + /* Animate only if the tabThumb if a tab, not a dropdown item. */ + if(session.tabThumb.hasClass('tab-item')) { + session.tabThumb.css({'z-index': 1}); + session.tabThumb.animate({ + top: $('#editor-top-bar').height() + 'px' + }, 300, function() { + session.tabThumb.remove(); + _this.updateTabDropdownVisibility(); + }); + } else { + session.tabThumb.remove(); + _this.updateTabDropdownVisibility(); + } + + session.listThumb.remove(); + + /* Remove closed path from history */ + var history = []; + $.each(this.history, function(index) { + if(this != tab) history.push(this); + }) + this.history = history; + delete this.sessions[tab]; + this.removeDraft(tab); + } + codiad.editor.exterminate(); + $.get(this.controller + '?action=removeall'); + } + }, close: function(path) { /* Notify listeners. */ @@ -740,6 +787,7 @@ var menu = $('#dropdown-list-active-files'); var button = $('#tab-dropdown-button'); + var closebutton = $('#tab-close-button'); menu.appendTo($('body')); @@ -747,6 +795,11 @@ e.stopPropagation(); _this.toggleTabDropdownMenu(); }); + + closebutton.click(function(e) { + e.stopPropagation(); + _this.removeAll(); + }); }, showTabDropdownMenu: function() { @@ -862,7 +915,8 @@ var tabListWidth = $("#tab-list-active-files").width(); var dropdownWidth = $('#tab-dropdown').width(); - var room = window.innerWidth - lsbarWidth - rsbarWidth - dropdownWidth - width - 30; + var closeWidth = $('#tab-close').width(); + var room = window.innerWidth - lsbarWidth - rsbarWidth - dropdownWidth - closeWidth - width - 30; return (room < 0); }, @@ -886,6 +940,11 @@ // Be sure to hide the menu if it is opened. $('#dropdown-list-active-files').hide(); } + if ($('#tab-list-active-files li').length > 1) { + $('#tab-close').show(); + } else { + $('#tab-close').hide(); + } }, ////////////////////////////////////////////////////////////////// diff --git a/index.php b/index.php index 28e3ccd..bbdcf8e 100755 --- a/index.php +++ b/index.php @@ -224,6 +224,9 @@ foreach ($allFiles as $fname){
+
+ +
diff --git a/themes/default/active/screen.css b/themes/default/active/screen.css index 1ef098f..27753f8 100644 --- a/themes/default/active/screen.css +++ b/themes/default/active/screen.css @@ -127,6 +127,25 @@ Gradients Generated by: http://www.colorzilla.com/gradient-editor/ background: linear-gradient(to bottom, #474747 0%,#141414 100%); /* W3C */ } +/* Close button */ + +#tab-close { + /* Adjust this size depending on the final editor-top-bar height. */ + position: fixed; + top: 7px; + right: 8px; + height: 35px; +} + +#tab-close-button { + font-size: 20px; + color: #666; +} + +#tab-close-button:hover { + color: #fff; +} + /************************ * Dropdown ************************/ @@ -136,8 +155,8 @@ Gradients Generated by: http://www.colorzilla.com/gradient-editor/ #tab-dropdown { /* Adjust this size depending on the final editor-top-bar height. */ position: fixed; - top: 9px; - right: 25px; + top: 7px; + right: 35px; height: 35px; } From ecf24c5bafe88a75a265fd7ac0e3326803cf9e03 Mon Sep 17 00:00:00 2001 From: daeks Date: Sun, 14 Apr 2013 10:46:03 +0200 Subject: [PATCH 02/11] small bugfix for closeall --- components/active/init.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/components/active/init.js b/components/active/init.js index b7cd6d8..fb0fa2f 100755 --- a/components/active/init.js +++ b/components/active/init.js @@ -528,32 +528,24 @@ } else { for(var tab in opentabs) { var session = this.sessions[tab]; - /* Animate only if the tabThumb if a tab, not a dropdown item. */ - if(session.tabThumb.hasClass('tab-item')) { - session.tabThumb.css({'z-index': 1}); - session.tabThumb.animate({ - top: $('#editor-top-bar').height() + 'px' - }, 300, function() { - session.tabThumb.remove(); - _this.updateTabDropdownVisibility(); - }); - } else { - session.tabThumb.remove(); - _this.updateTabDropdownVisibility(); - } + + session.tabThumb.remove(); + _this.updateTabDropdownVisibility(); session.listThumb.remove(); /* Remove closed path from history */ var history = []; $.each(this.history, function(index) { - if(this != tab) history.push(this); + if(this != path) history.push(this); }) - this.history = history; + this.history = history + delete this.sessions[tab]; this.removeDraft(tab); } codiad.editor.exterminate(); + $('#list-active-files').html(''); $.get(this.controller + '?action=removeall'); } }, From adf2b63c2e2df564554bbe6933225794d3f21240 Mon Sep 17 00:00:00 2001 From: daeks Date: Sun, 14 Apr 2013 10:48:38 +0200 Subject: [PATCH 03/11] use i18n for unsaved files --- components/active/init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/active/init.js b/components/active/init.js index fb0fa2f..45982f0 100755 --- a/components/active/init.js +++ b/components/active/init.js @@ -524,7 +524,7 @@ } if(changed) { - alert('Unsaved Files found. Please save them first.'); + alert(i18n('You have unsaved files.')); } else { for(var tab in opentabs) { var session = this.sessions[tab]; From 10b04311da526192a28debd74e0793ccd46a3811 Mon Sep 17 00:00:00 2001 From: daeks Date: Sun, 14 Apr 2013 10:53:22 +0200 Subject: [PATCH 04/11] save unsaved files --- components/active/init.js | 50 ++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/components/active/init.js b/components/active/init.js index 45982f0..3275809 100755 --- a/components/active/init.js +++ b/components/active/init.js @@ -524,30 +524,36 @@ } if(changed) { - alert(i18n('You have unsaved files.')); - } else { - for(var tab in opentabs) { - var session = this.sessions[tab]; - - session.tabThumb.remove(); - _this.updateTabDropdownVisibility(); - - session.listThumb.remove(); - - /* Remove closed path from history */ - var history = []; - $.each(this.history, function(index) { - if(this != path) history.push(this); - }) - this.history = history - - delete this.sessions[tab]; - this.removeDraft(tab); + if(confirm('Do you want to save all unsaved files?')) { + for(var tab in opentabs) { + if (_this.sessions[tab].listThumb.hasClass('changed')) { + codiad.active.save(tab); + } + } } - codiad.editor.exterminate(); - $('#list-active-files').html(''); - $.get(this.controller + '?action=removeall'); + } + + for(var tab in opentabs) { + var session = this.sessions[tab]; + + session.tabThumb.remove(); + _this.updateTabDropdownVisibility(); + + session.listThumb.remove(); + + /* Remove closed path from history */ + var history = []; + $.each(this.history, function(index) { + if(this != path) history.push(this); + }) + this.history = history + + delete this.sessions[tab]; + this.removeDraft(tab); } + codiad.editor.exterminate(); + $('#list-active-files').html(''); + $.get(this.controller + '?action=removeall'); }, close: function(path) { From 3b6e41b55241a1c14f6abcdcee21f1b3bdbfd32c Mon Sep 17 00:00:00 2001 From: daeks Date: Sun, 14 Apr 2013 10:54:09 +0200 Subject: [PATCH 05/11] better dialog --- components/active/init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/active/init.js b/components/active/init.js index 3275809..b18b9c0 100755 --- a/components/active/init.js +++ b/components/active/init.js @@ -524,7 +524,7 @@ } if(changed) { - if(confirm('Do you want to save all unsaved files?')) { + if(confirm('Found unsaved Files. Do you want to save them?')) { for(var tab in opentabs) { if (_this.sessions[tab].listThumb.hasClass('changed')) { codiad.active.save(tab); From e551e71b3e293f98968ac316c748d32963f65a30 Mon Sep 17 00:00:00 2001 From: daeks Date: Sun, 14 Apr 2013 10:56:54 +0200 Subject: [PATCH 06/11] saveall method --- components/active/init.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/components/active/init.js b/components/active/init.js index b18b9c0..f6a0468 100755 --- a/components/active/init.js +++ b/components/active/init.js @@ -493,6 +493,19 @@ }); } }, + + ////////////////////////////////////////////////////////////////// + // Save all files + ////////////////////////////////////////////////////////////////// + + saveAll: function() { + var _this = this; + for(var session in _this.sessions) { + if (_this.sessions[session].listThumb.hasClass('changed')) { + codiad.active.save(session); + } + } + }, ////////////////////////////////////////////////////////////////// // Remove file @@ -525,11 +538,7 @@ if(changed) { if(confirm('Found unsaved Files. Do you want to save them?')) { - for(var tab in opentabs) { - if (_this.sessions[tab].listThumb.hasClass('changed')) { - codiad.active.save(tab); - } - } + _this.saveAll(); } } From 1701d76bfd1428f9bc6319b42f01d30d2291add9 Mon Sep 17 00:00:00 2001 From: daeks Date: Sun, 14 Apr 2013 11:00:12 +0200 Subject: [PATCH 07/11] added saveall to rightbar --- components/right_bar.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/right_bar.json b/components/right_bar.json index 82d2fff..e848640 100755 --- a/components/right_bar.json +++ b/components/right_bar.json @@ -4,6 +4,11 @@ "icon": "icon-install", "onclick": "codiad.active.save();" }, + { + "title": "Save All", + "icon": "icon-install", + "onclick": "codiad.active.saveAll();" + }, { "title": "break", "icon": null, From bb309f38219d45a62a044804141c8470a0450132 Mon Sep 17 00:00:00 2001 From: daeks Date: Sun, 14 Apr 2013 18:50:36 +0200 Subject: [PATCH 08/11] prevent untained exception --- components/active/init.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/components/active/init.js b/components/active/init.js index f6a0468..4c2f824 100755 --- a/components/active/init.js +++ b/components/active/init.js @@ -458,11 +458,13 @@ var content = session.getValue(); var path = session.path; var handleSuccess = function(mtime){ - var session = codiad.active.sessions[path]; - session.untainted = newContent; - session.serverMTime = mtime; - if (session.listThumb) session.listThumb.removeClass('changed'); - if (session.tabThumb) session.tabThumb.removeClass('changed'); + var session = codiad.active.sessions[path]; + if(typeof session != 'undefined') { + session.untainted = newContent; + session.serverMTime = mtime; + if (session.listThumb) session.listThumb.removeClass('changed'); + if (session.tabThumb) session.tabThumb.removeClass('changed'); + } _this.removeDraft(path); } // Replicate the current content so as to avoid From e95feb4dd70bd17425c7e76ed3bf71b121753b11 Mon Sep 17 00:00:00 2001 From: daeks Date: Sun, 14 Apr 2013 20:50:20 +0200 Subject: [PATCH 09/11] path should be tab --- components/active/init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/active/init.js b/components/active/init.js index 4c2f824..3540f17 100755 --- a/components/active/init.js +++ b/components/active/init.js @@ -555,7 +555,7 @@ /* Remove closed path from history */ var history = []; $.each(this.history, function(index) { - if(this != path) history.push(this); + if(this != tab) history.push(this); }) this.history = history From 0e88c8df3c20238a7dcb0b01870f97eff230efd7 Mon Sep 17 00:00:00 2001 From: Hesham Ali Date: Mon, 15 Apr 2013 05:00:55 +0200 Subject: [PATCH 10/11] fixed issue #308: failure on "Download" --- components/filemanager/download.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/filemanager/download.php b/components/filemanager/download.php index 2b474ab..c7bf822 100755 --- a/components/filemanager/download.php +++ b/components/filemanager/download.php @@ -23,7 +23,7 @@ || preg_match('#^[\\\/]?$#i', trim($_GET['path'])) // download all Projects || preg_match('#[\:*?\"<>\|]#i', $_GET['path']) //illegal chars in filenames || strpos('..', $_GET['path']) !== false ){ // change directory up to escape Workspace - exit(''); + exit(''); } ////////////////////////////////////////////////////////////////// @@ -36,9 +36,9 @@ //$filename = array_pop($filename) . "-" . date('Y.m.d') . ".tar.gz"; $filename = array_pop($filename) . "-" . date('Y.m.d'); $targetPath = DATA . '/'; - $dir = WORKSPACE . $_GET['path']; + $dir = WORKSPACE . '/' . $_GET['path']; if(!is_dir($dir)){ - exit(''); + exit(''); } ////////////////////////////////////////////////////////////////// @@ -58,7 +58,7 @@ $download_file = $targetPath.$filename; DirZip::zipDir($dir, $targetPath .$filename); }else{ - exit(''); + exit(''); } }else{ $filename = explode("/",$_GET['path']); From 14ed7bd4ea22d10c5574d7caf42020763ad02355 Mon Sep 17 00:00:00 2001 From: Hesham Ali Date: Mon, 15 Apr 2013 05:31:55 +0200 Subject: [PATCH 11/11] fixed incorrect file extension for zipped folder download (was tag.gz instead of tar.gz) --- components/filemanager/download.php | 34 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/components/filemanager/download.php b/components/filemanager/download.php index c7bf822..19f15d9 100755 --- a/components/filemanager/download.php +++ b/components/filemanager/download.php @@ -11,9 +11,9 @@ ////////////////////////////////////////////////////////////////// // Verify Session or Key ////////////////////////////////////////////////////////////////// - + checkSession(); - + ////////////////////////////////////////////////////////////////// // Check $_GET for incorrect chars or '..' for workspace ecape ////////////////////////////////////////////////////////////////// @@ -25,7 +25,7 @@ || strpos('..', $_GET['path']) !== false ){ // change directory up to escape Workspace exit(''); } - + ////////////////////////////////////////////////////////////////// // Run Download ////////////////////////////////////////////////////////////////// @@ -40,32 +40,32 @@ if(!is_dir($dir)){ exit(''); } - + ////////////////////////////////////////////////////////////////// // Check system() command and a non windows OS ////////////////////////////////////////////////////////////////// if(isAvailable('system') && stripos(PHP_OS, 'win') === false){ - # Execute the tar command and save file - $filename .= '.tag.gz'; - - system("tar -pczf ".$targetPath.$filename." ".$dir); - $download_file = $targetPath.$filename; + # Execute the tar command and save file + $filename .= '.tar.gz'; + + system("tar -pczf ".$targetPath.$filename." ".$dir); + $download_file = $targetPath.$filename; }elseif(extension_loaded('zip')){ //Check if zip-Extension is availiable - //build zipfile - require_once 'class.dirzip.php'; - - $filename .= '.zip'; - $download_file = $targetPath.$filename; - DirZip::zipDir($dir, $targetPath .$filename); + //build zipfile + require_once 'class.dirzip.php'; + + $filename .= '.zip'; + $download_file = $targetPath.$filename; + DirZip::zipDir($dir, $targetPath .$filename); }else{ - exit(''); + exit(''); } }else{ $filename = explode("/",$_GET['path']); $filename = array_pop($filename); $download_file = WORKSPACE . $_GET['path']; } - + header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($filename));