Index: sandbox/filemanager/inc/class.uifilemanager.inc.php
===================================================================
--- sandbox/filemanager/inc/class.uifilemanager.inc.php	(revision 1648)
+++ sandbox/filemanager/inc/class.uifilemanager.inc.php	(revision 1654)
@@ -61,7 +61,4 @@
 		var $newfile_x;
 		var $createfile_var;
-		var $delete_x;
-		var $renamefiles;
-		var $rename_x;
 		var $move_to_x;
 //		var $copy_to;
@@ -86,5 +83,4 @@
 		var $show_upload_boxes;
 
-		var $debug = false;
 		var $now;
 
@@ -123,12 +119,7 @@
 			$to_decode = array
 			(
-				/*
-				Decode
-				'var'	when	  'avar' == 'value'
-				or
-				'var'	when	  'var'  is set
-				*/
 				'op'	=> array('op' => ''),
 				'path'	=> array('path' => ''),
+				'filename' => array('filename' => ''),
 				'file'	=> array('file' => ''),
 				'sortby'	=> array('sortby' => ''),
@@ -333,5 +324,5 @@
 				)
 			));
-			$this->fileman[0] = $filename;
+			$this->filename = $filename;
 			$this->edit();
 
@@ -355,4 +346,5 @@
 			echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/common_functions.js'></script>";
 			echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/connector.js'></script>";
+			echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/draw_api.js'></script>";
 			include('load_lang.php');
 
@@ -524,9 +516,4 @@
 			}
 
-			if($this->debug)
-			{
-				$this->debug_filemanager();
-			}
-
 			# main action switch
 			// FIXME this will become a switch
@@ -555,8 +542,4 @@
 				$this->moveTo();
 			}
-			elseif($this->renamefiles)
-			{
-				$this->rename();
-			}
 			elseif($this->edit_cancel_x)
 			{
@@ -567,8 +550,4 @@
 			{
 				$this->edit();
-			}
-			elseif($this->delete_x)
-			{
-				$this->delete();
 			}
 			else
@@ -607,5 +586,6 @@
 				$vars[usedSpace]='<input type="hidden" id="usedSpace" value="'.$usedSpace.'">';
 				$vars[quotaSize]='<input type="hidden" id="quotaSize" value="'.($quota*1024*1024).'">';
-				$vars[javascript]='<script src="filemanager/js/draw_api.js"></script>
+				$vars[path]='<input type="hidden" id="currentPath" value="'.$this->path.'">';
+				$vars[css]='<script>initDrawApi();</script>
 					<link rel="stylesheet" type="text/css" href="filemanager/templates/default/main.css">';
 				$vars[toolbar0]=$this->toolbar('location');
@@ -692,24 +672,5 @@
 				{
 					$files = $this->files_array[$i];
-
-					if($this->rename_x)
-					{
-						unset($this_selected);
-						unset($renamethis);
-
-						for($j = 0; $j != $this->numoffiles; $j++)
-						{
-							if($this->fileman[$j] == $files['name'])
-							{
-								$this_selected = 1;
-								break;
-							}
-						}
-
-						if($this->rename_x && $this_selected)
-						{
-							$renamethis = 1;
-						}
-					}
+					
 
 					if(!$this->prefs['dotfiles'] && ereg("^\.", $files['name']))
@@ -719,12 +680,7 @@
 
 					# Checkboxes
-					if(!$this->rename_x && $this->path != $this->bo->fakebase && $this->path != '/')
-					{
-						$cbox='<input type="checkbox" class="checkbox" name="fileman['.$i.']" value="'.$files['name'].'">';
-						$this->t->set_var('actions',$cbox);
-					}
-					elseif($renamethis)
-					{
-						$cbox=$this->html_form_input('hidden', 'fileman[' . base64_encode($files['name']) . ']', $files['name'], NULL, NULL, 'checked');
+					if($this->path != $this->bo->fakebase && $this->path != '/')
+					{
+						$cbox='<input type="checkbox" name="fileman" value="'.$files['name'].'">';
 						$this->t->set_var('actions',$cbox);
 					}
@@ -761,43 +717,32 @@
 
 					# File name and icon
-					if($renamethis)
-					{
-						$col_data=$this->mime_icon($files['mime_type']);
-						$col_data.='<input type="text" maxlength="255" name="renamefiles[' . $files['name'] . ']" value="'.$files['name'].'">';
+					if($files['mime_type'] == 'Directory')
+					{
+						$link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path.$this->dispsep.$files['name']);
+
+						$icon=$this->mime_icon($files['mime_type']);
+
+						$col_data='<a href="'.$link.'">'.$icon.'</a>&nbsp;';
+						$col_data.='<a href="'.$link.'">'.$files['name'].'</a>&nbsp;';
 					}
 					else
 					{
-						if($files['mime_type'] == 'Directory')
+
+						if($this->prefs['viewonserver'] && isset($this->bo->filesdir) && !$files['link_directory'])
 						{
-							$link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path.$this->dispsep.$files['name']);
-
-							$icon=$this->mime_icon($files['mime_type']);
-
-							$col_data='<a href="'.$link.'">'.$icon.'</a>&nbsp;';
-							$col_data.='<a href="'.$link.'">'.$files['name'].'</a>&nbsp;';
+							#FIXME
+							$clickview = $this->filesdir.$pwd.'/'.$files['name'];
+
 						}
 						else
 						{
-
-							if($this->prefs['viewonserver'] && isset($this->bo->filesdir) && !$files['link_directory'])
-							{
-								#FIXME
-								$clickview = $this->filesdir.$pwd.'/'.$files['name'];
-
-								if($phpwh_debug)
-								{
-									echo 'Setting clickview = '.$clickview.'<br>'."\n";
-									$this->html_link($clickview,'', '',$files['name'], 0, 1, 0, '');
-								}
-							}
-							else
-							{
-								$icon=$this->mime_icon($files['mime_type']);
-								$link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.view','file='.$files['name'].'&path='.$this->path);
-
-								$col_data='<a href="'.$link.'" target="'.$this->target.'">'.$icon.'</a>&nbsp;<a href="'.$link.'" target="'.$this->target.'">'.$files['name'].'</a>';
-							}
+							$icon=$this->mime_icon($files['mime_type']);
+							$link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.view','file='.$files['name'].'&path='.$this->path);
+
+							$col_data='<a href="'.$link.'" target="'.$this->target.'">'.$icon.'</a>&nbsp;'.
+							'<a id="name_'.$files['name'].'" href="'.$link.'" target="'.$this->target.'">'.$files['name'].'</a>';
 						}
 					}
+
 
 					$this->t->set_var('col_data',$col_data);
@@ -923,15 +868,4 @@
 					$this->t->pparse('out','row');
 				}
-
-				// when renaming render extra sumbmit button
-				if($this->rename_x)
-				{
-					$col_data='<br/><input type="submit" name="save_changes" value="'.lang('Save changes').'">';
-					$this->t->set_var('col_data',$col_data);
-					$this->t->parse('columns','column');
-					$this->t->set_var('row_tr_color','');
-					$this->t->parse('rows','row');
-					$this->t->pparse('out','row');
-				}
 			}
 
@@ -1036,17 +970,8 @@
 				));
 
-				if($phpwh_debug)
-				{
-					echo '# of files found in "'.$this->path.'" : '.count($ls_array).'<br>'."\n";
-				}
-
 				while(list($num, $file_array) = each($ls_array))
 				{
 					$this->numoffiles++;
 					$this->files_array[] = $file_array;
-					if($phpwh_debug)
-					{
-						echo 'Filename: '.$file_array['name'].'<br>'."\n";
-					}
 				}
 			}
@@ -1076,5 +1001,5 @@
 					{
 						$link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->lesspath);
-						$toolbar.=$this->buttonImage($link,'up',lang('go up'));
+						$toolbar.=$this->linkButton($link,'up',lang('go up'));
 					}
 
@@ -1083,10 +1008,10 @@
 					{
 						$link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->bo->homedir);
-						$toolbar.=$this->buttonImage($link,'home',lang('go home'));
+						$toolbar.=$this->linkButton($link,'home',lang('go home'));
 					}
 
 					// reload button with this url
 					$link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path);
-					$toolbar.=$this->buttonImage($link,'reload',lang('reload'));
+					$toolbar.=$this->linkButton($link,'reload',lang('reload'));
 
 					$toolbar.='<td>'.lang('Location').':&nbsp;';
@@ -1118,12 +1043,7 @@
 					if($this->path != '/' && $this->path != $this->bo->fakebase)
 					{
-						//$toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>';
-						//$toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>';
 						// create dir and file button
 						if($this->can_add)
 						{
-							//$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>';
-							//$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>';
-
 							$toolbar.='<td><input type="hidden" id="newfile_or_dir" name="newfile_or_dir" value="" /></td>';
 							//TODO : create folder with problems
@@ -1132,5 +1052,5 @@
 						}
 
-						if(!$this->rename_x && $this->can_edit)
+						if($this->can_edit)
 						{
 							// edit text file button
@@ -1143,20 +1063,11 @@
 						}
 
-						if(!$this->rename_x && $this->can_delete)
+						if($this->can_delete)
 						{
 							$toolbar.=$this->inputImage('delete','delete',lang('Delete'));
 						}
 
-						/*if(!$this->rename_x && $this->can_edit && 
-                                                $_SESSION['phpgw_info']['user']['preferences']['filemanager']['comment'] == 1)
-						{
-							$toolbar.=$this->inputImage('edit_comments','edit_comments',lang('Edit comments'));
-						}*/
-
-					}
-
-					//	$toolbar.='</tr></table>';
-					if(!$this->rename_x)
-					{
+					}
+
 						// copy and move buttons
 						if($this->path != '/' && $this->path != $this->bo->fakebase)
@@ -1179,5 +1090,4 @@
 							<tr>'.$toolbar3;*/
 						}
-					}
 					$toolbar.='</tr></table>';
 
@@ -1312,36 +1222,4 @@
 			}
 		}
-		# Handle Renaming Files and Directories
-		function rename()
-		{
-			while(list($from, $to) = each($this->renamefiles))
-			{
-				if($badchar = $this->bo->bad_chars($to, True, True))
-				{
-					$this->messages[]=lang('Error:').$this->bo->html_encode(lang('File names cannot contain "%1"', $badchar), 1);
-					continue;
-				}
-
-				if(ereg("/", $to) || ereg("\\\\", $to))
-				{
-					$this->messages[]=lang('Error:').lang("File names cannot contain \\ or /");
-				}
-				elseif($this->vfs_functions->verifyLock($from,RELATIVE_CURRENT) && $this->bo->vfs->mv(array(
-					'from'	=> $this->disppath.'/'.$from,
-					'to'	=> $this->disppath.'/'.$to,
-					'relatives' => array(RELATIVE_NONE,RELATIVE_NONE)
-				)))
-				{
-					$this->messages[]=lang('Renamed %1 to %2', $from, $to);
-				}
-				else
-				{
-					$this->messages[]= lang('Error:').lang('Could not rename %1 to %2', $from, $to);
-				}
-			}
-			$this->readFilesInfo();
-			$this->filelisting();
-		}
-
 		# Handle Moving Files and Directories
 		function moveTo()
@@ -1470,49 +1348,4 @@
 			}
 		}
-		function delete()
-		{
-			if( is_array($this->fileman) && count($this->fileman) >= 1)
-			{
-				foreach($this->fileman as $filename)
-				{
-					if($this->vfs_functions->verifyLock($filename,RELATIVE_ALL) && $this->bo->vfs->delete(array('string' => $filename)))
-					{
-						$this->messages[]= lang('Deleted %1', $this->disppath.'/'.$filename).'<br/>';
-					}
-					else
-					{
-						$this->messages[]=lang('Error:').lang('Could not delete %1', $this->disppath.'/'.$filename);
-					}
-				}
-			}
-			else
-			{
-				// make this a javascript func for quicker respons
-				$this->messages[]=lang('Error:').lang('Please select a file to delete.');
-			}
-			$this->readFilesInfo();
-			$this->filelisting();
-		}
-
-		function debug_filemanager()
-		{
-			error_reporting(8);
-
-			echo "<b>Filemanager debug:</b><br>
-			path: {$this->path}<br>
-			disppath: {$this->disppath}<br>
-			cwd: {$this->cwd}<br>
-			lesspath: {$this->lesspath}
-			<p>
-			<b>eGroupware debug:</b><br>
-			real getabsolutepath: " . $this->bo->vfs->getabsolutepath(array('target' => False, 'mask' => False, 'fake' => False)) . "<br>
-			fake getabsolutepath: " . $this->bo->vfs->getabsolutepath(array('target' => False)) . "<br>
-			appsession: " . $GLOBALS['phpgw']->session->appsession('vfs','') . "<br>
-			pwd: " . $this->bo->vfs->pwd() . "<br>";
-
-			echo '<p></p>';
-			var_dump($this);
-		}
-
 		function showUploadboxes()
 		{
@@ -1546,8 +1379,8 @@
 		function createfile()
 		{
-			$this->createfile_var=$this->newfile_or_dir;
-			if($this->createfile_var)
-			{
-				if($badchar = $this->bo->bad_chars($this->createfile_var, True, True))
+			$this->filename=$this->newfile_or_dir;
+			if($this->filename)
+			{
+				if($badchar = $this->bo->bad_chars($this->filename, True, True))
 				{
 					$this->messages[] = lang('Error:').lang('File names cannot contain "%1"',$badchar);
@@ -1557,19 +1390,17 @@
 
 				if($this->bo->vfs->file_exists(array(
-					'string'=> $this->createfile_var,
+					'string'=> $this->filename,
 					'relatives'	=> array(RELATIVE_ALL)
 				)))
 				{
-					$this->messages[]= lang('Error:').lang('File %1 already exists. Please edit it or delete it first.', $this->createfile_var);
+					$this->messages[]= lang('Error:').lang('File %1 already exists. Please edit it or delete it first.', $this->filename);
 					$this->fileListing();
 				}
 
 				if($this->bo->vfs->touch(array(
-					'string'	=> $this->createfile_var,
+					'string'	=> $this->filename,
 					'relatives'	=> array(RELATIVE_ALL)
 				)))
 				{
-					$this->fileman = array();
-					$this->fileman[0] = $this->createfile_var;
 					$this->edit = 1;
 					$this->numoffiles++;
@@ -1578,5 +1409,5 @@
 				else
 				{
-					$this->messages[]= lang('Error:').lang('File %1 could not be created.', $this->createfile_var);
+					$this->messages[]= lang('Error:').lang('File %1 could not be created.', $this->filename);
 					$this->fileListing();
 				}
@@ -1587,9 +1418,7 @@
 		function edit()
 		{
-			$files = array_keys($this->fileman);
-			$this->file = $this->fileman[$files[0]];
-			if($this->file)
-			{
-				if (! $this->vfs_functions->verifyLock($this->path.'/'.$this->file,RELATIVE_NONE)){
+			if($this->filename)
+			{
+				if (! $this->vfs_functions->verifyLock($this->path.'/'.$this->filename,RELATIVE_NONE)){
 					echo $this->messages['0'];
 					$GLOBALS['phpgw']->redirect('/index.php');
@@ -1598,5 +1427,5 @@
 				}
 				$ls_array = $this->bo->vfs->ls(array(
-					'string'        => $this->path.'/'.$this->file,
+					'string'        => $this->path.'/'.$this->filename,
 					'relatives'     => array(RELATIVE_NONE),
 					'checksubdirs'  => False,
@@ -1604,5 +1433,5 @@
 				));
 				$this->bo->vfs->touch(array(
-					'string'=> $this->path.'/'.$this->file,
+					'string'=> $this->path.'/'.$this->filename,
 					'relatives'     => array(RELATIVE_NONE)
 				));
@@ -1677,71 +1506,65 @@
 			}
 
-			# Now we display the edit boxes and forms
-			for($j = 0; $j != $this->numoffiles; $j++)
-			{
-				# If we're in preview or save mode, we only show the file
-				# being previewed or saved
-				if($this->edit_file &&($this->fileman[$j] != $this->edit_file))
-				{
-					continue;
-				}
-
-				if($this->fileman[$j] && $this->bo->vfs->file_exists(array(
-					'string'	=> $this->fileman[$j],
-					'relatives'	=> array(RELATIVE_ALL)
-				)))
-				{
-					if($this->edit_file)
-					{
-						$content = stripslashes($this->edit_file_content);
-					}
-					else
-					{
-						$content = $this->bo->vfs->read(array('string' => $this->fileman[$j]));
-					}
-
-					$vars[form_action]= $GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path);
-					$vars[edit_file]=$this->fileman[$j];
-
-					# We need to include all of the fileman entries for each file's form,
-					# so we loop through again
-					for($i = 0; $i != $this->numoffiles; $i++)
-					{
-						if($this->fileman[$i]) $value='value="'.$this->fileman[$i].'"';
-						$vars[filemans_hidden]='<input type="hidden" name="fileman['.$i.']" '.$value.' />';
-					}
-
-					$vars[file_content]=$content;
-
-					$vars[buttonPreview]=$this->inputImage('edit_preview','edit_preview',lang('Preview %1', $this->bo->html_encode($this->fileman[$j], 1)));
-					$vars[buttonSave]=$this->inputImage('edit_save','save',lang('Save %1', $this->bo->html_encode($this->fileman[$j], 1)));
-					$vars[buttonDone]=$this->inputImage('edit_save_done','ok',lang('Save %1, and go back to file listing ', $this->bo->html_encode($this->fileman[$j], 1)));
-					$vars[buttonCancel]=$this->inputImage('edit_cancel','cancel',lang('Cancel editing %1 without saving', $this->bo->html_encode($this->fileman[$j], 1)));
-
-					 if ($mime_type == 'text/html'){
-						 $vars[fck_edit] = '<script type="text/javascript" src="filemanager/tp/ckeditor/ckeditor.js"></script>
-							 <textarea cols="80" id="edit_file_content" name="edit_file_content" rows="10">'.$content.'</textarea>
-							 <script type="text/javascript"> CKEDITOR.replace( \'edit_file_content\',{
-					removePlugins : \'elementspath\',
-					skin : \'office2003\',
-					toolbar : [["Source","Preview","-","Cut","Copy","Paste","-","Print",
-					"Undo","Redo","-","Find","Replace","-","SelectAll" ],
-					["Table","HorizontalRule","Smiley","SpecialChar","PageBreak","-","Bold",
-					"Italic","Underline","Strike","-","Subscript","Superscript",
-					"NumberedList","BulletedList","-","Outdent","Indent","Blockquote",
-					"JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock",
-					"Link", "TextColor","BGColor","Maximize"],
-					["Styles","Format","Font","FontSize"]]
-					 });</script>';
-
-					}
-
-
-					$this->t->set_var($vars);
-					$this->t->parse('rows','row');
-					$this->t->pparse('out','row');
-
-				}
-			}
+			# If we're in preview or save mode, we only show the file
+			# being previewed or saved
+			if($this->edit_file &&($this->filename != $this->edit_file))
+			{
+				continue;
+			}
+
+			if($this->filename && $this->bo->vfs->file_exists(array(
+				'string'	=> $this->filename,
+				'relatives'	=> array(RELATIVE_ALL)
+			)))
+			{
+				if($this->edit_file)
+				{
+					$content = stripslashes($this->edit_file_content);
+				}
+				else
+				{
+					$content = $this->bo->vfs->read(array('string' => $this->filename));
+				}
+				$vars[form_action]= $GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path);
+				$vars[edit_file]=$this->filename;
+				# We need to include all of the fileman entries for each file's form,
+				# so we loop through again
+				for($i = 0; $i != $this->numoffiles; $i++)
+				{
+					if($this->filename) $value='value="'.$this->filename.'"';
+					$vars[filemans_hidden]='<input type="hidden" name="filename" '.$value.' />';
+				}
+				$vars[file_content]=$content;
+
+				$vars[buttonPreview]=$this->inputButton('edit_preview','edit_preview',lang('Preview %1', $this->bo->html_encode($this->fileman[$j], 1)));
+				$vars[buttonSave]=$this->inputButton('edit_save','save',lang('Save %1', $this->bo->html_encode($this->filename, 1)));
+				$vars[buttonDone]=$this->inputButton('edit_save_done','ok',lang('Save %1, and go back to file listing ', $this->bo->html_encode($this->filename, 1)));
+				$vars[buttonCancel]=$this->inputButton('edit_cancel','cancel',lang('Cancel editing %1 without saving', $this->bo->html_encode($this->filename, 1)));
+
+				if ($mime_type == 'text/html'){
+					$vars[fck_edit] = '<script type="text/javascript" src="filemanager/tp/ckeditor/ckeditor.js"></script>
+						<textarea cols="80" id="edit_file_content" name="edit_file_content" rows="10">'.$content.'</textarea>
+						<script type="text/javascript"> CKEDITOR.replace( \'edit_file_content\',{
+removePlugins : \'elementspath\',
+skin : \'office2003\',
+toolbar : [["Source","Preview","-","Cut","Copy","Paste","-","Print",
+"Undo","Redo","-","Find","Replace","-","SelectAll" ],
+["Table","HorizontalRule","Smiley","SpecialChar","PageBreak","-","Bold",
+"Italic","Underline","Strike","-","Subscript","Superscript",
+"NumberedList","BulletedList","-","Outdent","Indent","Blockquote",
+"JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock",
+"Link", "TextColor","BGColor","Maximize"],
+["Styles","Format","Font","FontSize"]]
+				});</script>';
+
+				}
+
+
+				$this->t->set_var($vars);
+				$this->t->parse('rows','row');
+				$this->t->pparse('out','row');
+
+			}
+
 		}
 
@@ -1971,5 +1794,5 @@
 		}
 
-		function buttonImage($link,$img='',$description='')
+		function linkButton($link,$img='',$description='')
 		{
 			$image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img));
@@ -1983,4 +1806,15 @@
 		}
 
+		function inputButton($name,$img='',$description='')
+		{
+			$image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img));
+
+			if($img)
+			{
+				return '<td class="" align="center" valign="middle" height="28" width="70">
+				<input title="'.$description.'" name="'.$name.'" type="image" alt="'.$name.'" src="'.$image.'" value="clicked" /><br><small>'.$description.'</small>
+				</td>';
+			}
+		}
 		function inputImage($name,$img='',$description='')
 		{
@@ -1990,8 +1824,10 @@
 			{
 				return '<td class="" align="center" valign="middle" height="28" width="70">
-				<input onClick="return formfmValidate(\''.$name.'\')" title="'.$description.'" name="'.$name.'" type="image" alt="'.$name.'" src="'.$image.'" value="clicked" /><br><small>'.$description.'</small>
+				<img onClick="toolbar_control(\''.$name.'\')" title="'.$description.'" name="'.$name.'" alt="'.$name.'" src="'.$image.'" /><br><small>'.$description.'</small>
 				</td>';
 			}
 		}
+
+
 
 		function html_form_input($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = '', $return = 1)
