<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/file_upload/_browse.html.erb</filename>
    </added>
    <added>
      <filename>app/views/file_upload/_directory.html.erb</filename>
    </added>
    <added>
      <filename>public/images/admin/Thumbs.db</filename>
    </added>
    <added>
      <filename>public/images/admin/delete.gif</filename>
    </added>
    <added>
      <filename>public/images/admin/directory.gif</filename>
    </added>
    <added>
      <filename>public/images/admin/file.gif</filename>
    </added>
    <added>
      <filename>public/images/admin/newDirectory.gif</filename>
    </added>
    <added>
      <filename>public/images/admin/up.gif</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,28 +1,108 @@
 class FileUploadController &lt; ApplicationController
 
-  protect_from_forgery :except =&gt; [:upload]
+  protect_from_forgery :except =&gt; [:upload, :new_folder, :destroy]
   skip_before_filter :authenticate
   skip_before_filter :set_current_user
   
   def upload
+	unless params[:path] =~ /public/
+		render :nothing, :status =&gt; :forbidden
+		return false
+	end
 	file_name = params[:Filename]
 	counter = 1
 	while(true)
 		begin
-			open(&quot;#{RAILS_ROOT}/public/uploads/File/#{file_name}&quot;, &quot;rb&quot;)
+			open(&quot;#{params[:path]}/#{file_name}&quot;, &quot;rb&quot;)
 		rescue
 			break
 		end
 		file_name = params[:Filename].reverse.sub('.', &quot;.#{counter}_&quot;).reverse
 		counter = counter + 1
 	end
-	open(&quot;#{RAILS_ROOT}/public/uploads/File/#{file_name}&quot;, &quot;wb&quot;) do |f|
+	open(&quot;#{params[:path]}/#{file_name}&quot;, &quot;wb&quot;) do |f|
 		f.write params[:Filedata].read
 	end
 	render :nothing =&gt; true
   end
   
   def index
+	@dir = &quot;#{RAILS_ROOT}/public/uploads&quot;
+	@save_to = &quot;/public/uploads&quot;
+	@parent = &quot;#{RAILS_ROOT}/public&quot;
+  end
+  
+  def browse
+	unless params[:path] =~ /public/
+		render :nothing, :status =&gt; :forbidden
+		return false
+	end
+	@dir = params[:path]
+	
+	@save_to = @dir.split('/')
+	i = 0
+	while i &lt; @save_to.length do
+		if @save_to[i] == 'public'
+			break
+		end
+		i = i + 1
+	end
+	@save_to = &quot;/&quot; + File.join( @save_to.last(@save_to.length - i) )
+	
+	@parent = @dir.split('/')
+	@parent.pop
+	@parent = @parent.join('/')
+	
+	render :update do |page|
+		page.replace 'browse_dialog', :partial =&gt; 'browse'
+	end
+  end
+  
+  def new_folder
+	unless params[:path] =~ /public/
+		render :nothing, :status =&gt; :forbidden
+		return false
+	end
+	
+	error = false
+	begin
+		FileUtils.mkdir(File.join(params[:path], params[:folder_name]))
+	rescue Exception =&gt; e
+		render :update do |page|
+			error = true
+			page.call &quot;alert&quot;, &quot;an error occurred while creating the folder!!\nThe folder name might already exist&quot;
+		end
+	end
+	
+	unless error
+		render :update do |page|
+			page.insert_html :top, 'dir_entries', :partial =&gt; 'directory', :locals =&gt; {:dir =&gt; params[:path], :filename =&gt; params[:folder_name]}
+			page.visual_effect :highlight, &quot;directory_#{params[:folder_name]}&quot;
+		end
+	end
+  end
+  
+  def destroy
+	unless params[:path] =~ /public/
+		render :nothing, :status =&gt; :forbidden
+		return false
+	end
+	
+	error = false
+	begin
+		FileUtils.remove_file( File.join(params[:path], params[:file]) )
+	rescue Exception =&gt; e
+		render :update do |page|
+			error = true
+			page.call &quot;alert&quot;, &quot;an error occurred while deleting this file!!&quot;
+		end
+	end
+	
+	unless error
+		render :update do |page|
+			page.visual_effect :fade, &quot;directory_#{params[:file]}&quot;, :afterFinish =&gt; &quot;function(){$('directory_#{params[:file]}').remove();}&quot;
+		end
+	end
   end
   
 end</diff>
      <filename>app/controllers/file_upload_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,16 @@
 &lt;script type=&quot;text/javascript&quot; src=&quot;/swfupload/swfupload.js&quot;&gt;&lt;/script&gt;
 &lt;script type=&quot;text/javascript&quot; src=&quot;/swfupload/plugins/swfupload.queue.js&quot;&gt;&lt;/script&gt;
 &lt;script type=&quot;text/javascript&quot;&gt;
+	Ajax.Responders.register({
+	  onCreate: function() {
+	    document.body.style.cursor = 'progress';
+	  },
+	  onComplete: function() {
+	    document.body.style.cursor = '';
+	  }
+	});
 	var uploader;
+	var currentPath = &quot;#{RAILS_ROOT}/public/uploads&quot;
 	
 	window.onload = function() {
 		var settings = {
@@ -19,6 +28,7 @@
 			debug: false,
 
 			file_queued_handler : fileQueued,
+			file_dialog_start_handler: fileDialogStart,
 			file_dialog_complete_handler : fileDialogComplete,
 			upload_start_handler : uploadStart,
 			upload_progress_handler : uploadProgress,
@@ -30,6 +40,12 @@
 		
 	};
 	
+	fileDialogStart = function(){
+		uploader.removePostParam('path');
+		uploader.addPostParam('path', currentPath);
+		//uploader.settings.upload_url = &quot;/files/upload?path=&quot; + currentPath;
+	}
+	
 	fileDialogComplete = function(numberSelected, numberQueued){
 		uploader.startUpload();
 		$('cancel_upload').disabled = false;
@@ -65,23 +81,152 @@
 		$('queue_entry_' + file.id).className = &quot;done&quot;;
 		new Effect.Highlight(&quot;queue_entry_&quot; + file.id);
 	}
+	
+	browse = function(path){
+		new Ajax.Request(&quot;/files/browse&quot;, {
+			method: 'get',
+			parameters: {'path': path}
+		});
+	}
+	
+	newFolder = function(path){
+		folderName = prompt(&quot;Folder name:&quot;);
+		if (folderName == &quot;&quot;){
+			return false;
+		}
+		new Ajax.Request(&quot;/files/new_folder&quot;, {
+			method: 'post',
+			parameters: {'path': path, 'folder_name': folderName},
+			evalScript: true
+		});
+	}
+	
+	deleteFile = function(path, file){
+		new Ajax.Request(&quot;/files/delete&quot;, {
+			method: 'post',
+			parameters: {'path': path, 'file': file},
+			evalScript: true
+		});
+	}
+	
 &lt;/script&gt;
 
 &lt;style&gt;
-h3{background:#f5f1e2; margin:20px 20px 10px 20px; border:1px solid #cdc295; font-size:1.4em; padding:10px;}
-.upload-content{background:#f5f1e2; margin:0px 20px; border:1px solid #cdc295;}
-.upload-content p{margin:3px 5px; background:#FFFFFF; padding:10px; border:1px solid #cdc295; font-size:0.9em; clear:both}
-.upload-content p.done{background:#e9ffd2; color:#2d8a00;}
-.upload-content p.uploading{background:#fffee7;}
-.upload-content p.cancelled{background:#fff4ef; color:#c12d00;}
+body{font-family:Arial, Helvetica, sans-serif;}
+h3 {
+background:#f5f1e2;
+margin:20px 20px 10px 20px;
+border:1px solid #cdc295;
+font-size:1.4em;
+padding:10px;
+}
+.upload-content {
+background:#f5f1e2;
+margin:0px 20px;
+border:1px solid #cdc295;
+}
+.upload-content p {
+margin:3px 5px;
+background:#FFFFFF;
+padding:10px;
+border:1px solid #cdc295;
+font-size:0.9em;
+clear:both
+}
+.upload-content p.done {
+background:#e9ffd2;
+color:#2d8a00;
+}
+.upload-content p.uploading {
+background:#fffee7;
+}
+.upload-content p.cancelled {
+background:#fff4ef;
+color:#c12d00;
+}
+.upload-fileName {
+font-weight:bold;
+}
+.upload-fileSize {
+width:100px;
+text-align:right;
+color:#666666;
+font-size:0.9em;
+}
+.upload-fileStatus {
+width:180px;
+text-align:right;
+float:right;
+margin:-20px 10px 0px 0px;
+display:inline;
+}
+.upload-message {
+padding:10px 0px 10px 20px;
+clear:both;
+background:#feffce;
+border:1px solid #fff177;
+margin:10px 20px;
+}
+#parent_dir{
+margin:3px 20px;
+border-bottom:1px solid #CCCCCC;
+font-size:0.9em;
+}
+#parent_dir A{
+background:url(../../images/admin/up.gif) no-repeat 5px 5px;
+padding:5px 0px 5px 25px;
+display:block;
+color:#000000;
+text-decoration:none;
+font-weight:bold;
+}
+#parent_dir A:hover{
+background:url(../../images/admin/up.gif) no-repeat 5px 5px #F0F0F0;
+}
+
+#new_dir{
+margin:20px 20px;
+border-top:1px solid #CCCCCC;
+font-size:0.9em;
+}
+#new_dir A{
+background:url(../../images/admin/newDirectory.gif) no-repeat 5px 5px;
+padding:5px 0px 5px 25px;
+display:block;
+color:#000000;
+text-decoration:none;
+font-weight:bold;
+}
+#new_dir A:hover{
+background:url(../../images/admin/newDirectory.gif) no-repeat 5px 5px #F0F0F0;
+}
 
-.upload-fileName{font-weight:bold;}
-.upload-fileSize{ width:100px; text-align:right;color:#666666; font-size:0.9em;}
-.upload-fileStatus{ width:180px; text-align:right; float:right; margin:-20px 10px 0px 0px; display:inline;}
-.upload-message{ padding:10px 0px 10px 20px; clear:both; background:#feffce;border:1px solid #fff177; margin:10px 20px;}
+#dir_entries p{
+margin:5px 20px;
+font-size:0.9em;
+}
+#dir_entries p a{
+background:url(../../images/admin/directory.gif) no-repeat 2px 3px;
+padding:2px 5px 2px 22px;
+font-weight:bold;
+}
+#dir_entries p a:hover{
+text-decoration:none;
+background:url(../../images/admin/directory.gif) no-repeat 2px 3px #F0F0F0;
+}
+#dir_entries p span{
+display:block;
+background:url(../../images/admin/file.gif) no-repeat 2px 3px;
+padding:2px 5px 2px 22px;
+}
+#dir_entries p span img{
+vertical-align:middle;
+cursor:pointer;
+margin:1px 0px 0px 4px;
 &lt;/style&gt;
 
-&lt;div id=&quot;content&quot;&gt;
+&lt;%= render :partial =&gt; 'browse' %&gt;
+&lt;div&gt;
 		&lt;div&gt;
 			&lt;h3&gt;Upload Queue&lt;/h3&gt;
 			&lt;div id=&quot;upload_queue&quot; class=&quot;upload-content&quot;&gt;&lt;/div&gt;</diff>
      <filename>app/views/file_upload/index.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,10 @@
 class UploadManagerExtension &lt; Radiant::Extension
   
   define_routes do |map|
+	map.connect 'files/browse', :controller =&gt; 'file_upload', :action =&gt; 'browse'
     map.connect 'files/upload', :controller =&gt; 'file_upload', :action =&gt; 'upload'
+	map.connect 'files/new_folder', :controller =&gt; 'file_upload', :action =&gt; 'new_folder'
+	map.connect 'files/delete', :controller =&gt; 'file_upload', :action =&gt; 'destroy'
 	map.connect 'admin/upload_manager', :controller =&gt; 'file_upload', :action =&gt; 'index'
   end
 </diff>
      <filename>upload_manager_extension.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7a210c61d844b4d3b5a8013d5b8119c8114d1e69</id>
    </parent>
  </parents>
  <author>
    <name>unknown</name>
    <email>haitham.mohammad@espace.com.eg</email>
  </author>
  <url>http://github.com/espace/radiant-upload-manager/commit/01f14379f9d93088263678b2e2dd7dc0398f996c</url>
  <id>01f14379f9d93088263678b2e2dd7dc0398f996c</id>
  <committed-date>2008-10-07T04:51:38-07:00</committed-date>
  <authored-date>2008-10-07T04:51:38-07:00</authored-date>
  <message>added a dialog for browsing the server and creating new folders and deleting existing files</message>
  <tree>eb4f81cab20c87b2bbd57b79d8a0b2d6b3091f99</tree>
  <committer>
    <name>unknown</name>
    <email>haitham.mohammad@espace.com.eg</email>
  </committer>
</commit>
