Merge remote-tracking branch 'upstream/master' into utf8

This commit is contained in:
daeks
2013-04-15 15:33:41 +02:00
7 changed files with 146 additions and 28 deletions

View File

@@ -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.

View File

@@ -67,6 +67,15 @@
$Active->Remove();
}
//////////////////////////////////////////////////////////////////
// Remove all active record
//////////////////////////////////////////////////////////////////
if($_GET['action']=='removeall'){
$Active->username = $_SESSION['user'];
$Active->RemoveAll();
}
//////////////////////////////////////////////////////////////////
// Mark file as focused
//////////////////////////////////////////////////////////////////

View File

@@ -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
@@ -493,6 +495,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
@@ -510,6 +525,47 @@
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) {
if(confirm('Found unsaved Files. Do you want to save them?')) {
_this.saveAll();
}
}
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 != tab) 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) {
/* Notify listeners. */
@@ -740,6 +796,7 @@
var menu = $('#dropdown-list-active-files');
var button = $('#tab-dropdown-button');
var closebutton = $('#tab-close-button');
menu.appendTo($('body'));
@@ -747,6 +804,11 @@
e.stopPropagation();
_this.toggleTabDropdownMenu();
});
closebutton.click(function(e) {
e.stopPropagation();
_this.removeAll();
});
},
showTabDropdownMenu: function() {
@@ -862,7 +924,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 +949,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();
}
},
//////////////////////////////////////////////////////////////////

View File

@@ -11,9 +11,9 @@
//////////////////////////////////////////////////////////////////
// Verify Session or Key
//////////////////////////////////////////////////////////////////
checkSession();
//////////////////////////////////////////////////////////////////
// Check $_GET for incorrect chars or '..' for workspace ecape
//////////////////////////////////////////////////////////////////
@@ -23,9 +23,9 @@
|| 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('<script>parent.message.error("Wrong data send")</script>');
exit('<script>parent.codiad.message.error("Wrong data send")</script>');
}
//////////////////////////////////////////////////////////////////
// Run Download
//////////////////////////////////////////////////////////////////
@@ -36,36 +36,36 @@
//$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('<script>parent.message.error("Directory not found.")</script>');
exit('<script>parent.codiad.message.error("Directory not found.")</script>');
}
//////////////////////////////////////////////////////////////////
// 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('<script>parent.message.error("Could not pack the folder, zip-extension missing")</script>');
exit('<script>parent.codiad.message.error("Could not pack the folder, zip-extension missing")</script>');
}
}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));

View File

@@ -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,

View File

@@ -224,6 +224,9 @@ foreach ($allFiles as $fname){
<div id="tab-dropdown">
<a id="tab-dropdown-button" class="icon-down-open"></a>
</div>
<div id="tab-close">
<a id="tab-close-button" class="icon-cancel-circled"></a>
</div>
<ul id="dropdown-list-active-files"></ul>
<div class="bar"></div>
</div>

View File

@@ -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;
}