Changeset 3879
- Timestamp:
- 03/18/11 18:18:12 (12 years ago)
- Location:
- branches/2.2/filemanager
- Files:
-
- 1 added
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/filemanager/inc/class.uifilemanager.inc.php
r3873 r3879 1 1 <?php 2 /**************************************************************************\ 3 * -------------------------------------------------------------------------* 4 * This library is free software; you can redistribute it and/or modify it * 5 * under the terms of the GNU Lesser General Public License as published by * 6 * the Free Software Foundation; either version 2.1 of the License, * 7 * or any later version. * 8 * This library is distributed in the hope that it will be useful, but * 9 * WITHOUT ANY WARRANTY; without even the implied warranty of * 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 11 * See the GNU Lesser General Public License for more details. * 12 * You should have received a copy of the GNU Lesser General Public License * 13 * along with this library; if not, write to the Free Software Foundation, * 14 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 15 \**************************************************************************/ 16 17 /* $Id: class.uifilemanager.inc.php 17511 2004-12-12 06:35:24Z dawnlinux $ */ 18 19 class uifilemanager 20 { 2 3 /* * ************************************************************************\ 4 * -------------------------------------------------------------------------* 5 * This library is free software; you can redistribute it and/or modify it * 6 * under the terms of the GNU Lesser General Public License as published by * 7 * the Free Software Foundation; either version 2.1 of the License, * 8 * or any later version. * 9 * This library is distributed in the hope that it will be useful, but * 10 * WITHOUT ANY WARRANTY; without even the implied warranty of * 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 12 * See the GNU Lesser General Public License for more details. * 13 * You should have received a copy of the GNU Lesser General Public License * 14 * along with this library; if not, write to the Free Software Foundation, * 15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 16 \************************************************************************* */ 17 18 /* $Id: class.uifilemanager.inc.php 17511 2004-12-12 06:35:24Z dawnlinux $ */ 19 20 class uifilemanager { 21 21 22 var $public_functions = array( 22 'index'=> True,23 'help'=> True,24 'view'=> True,25 'export'=> True,26 'touch'=> True,27 'history'=> True,28 'edit'=> True,29 'fileModels'=> True,30 'getReturnExecuteForm'=> True,31 'dir_ls'=> True,32 'search'=> True,33 'get_folders_list'=> True,34 'showUploadboxes'=> True,35 'createdir'=> True,36 'removedir'=> True,37 'uploadModel'=> True23 'index' => True, 24 'help' => True, 25 'view' => True, 26 'export' => True, 27 'touch' => True, 28 'history' => True, 29 'edit' => True, 30 'fileModels' => True, 31 'getReturnExecuteForm' => True, 32 'dir_ls' => True, 33 'search' => True, 34 'get_folders_list' => True, 35 'showUploadboxes' => True, 36 'createdir' => True, 37 'removedir' => True, 38 'uploadModel' => True 38 39 ); 39 40 40 //keep 41 41 var $bo; … … 49 49 var $numoffiles; 50 50 var $dispsep; 51 52 51 var $target; 53 54 var $prefs;//array 55 52 var $prefs; //array 56 53 var $groups_applications; 57 58 54 var $current_config; 59 55 var $dirs; … … 72 68 var $edit_save_done_x; 73 69 var $edit_cancel_x; 74 75 70 // this ones must be checked thorougly; 76 71 var $fileman = Array(); … … 82 77 var $limit; //for paging (paginacao) 83 78 var $offset; //for paging (paginacao) 84 85 79 var $now; 86 80 87 function uifilemanager() 88 { 81 function uifilemanager() { 89 82 $this->messages = &$_SESSION['phpgw_info']['filemanager']['user']['messages']; 90 83 … … 98 91 99 92 $this->t = $GLOBALS['phpgw']->template; 100 $c = CreateObject('phpgwapi.config', 'filemanager');93 $c = CreateObject('phpgwapi.config', 'filemanager'); 101 94 $c->read_repository(); 95 102 96 $this->current_config = $c->config_data; 103 104 97 105 98 // here local vars are created from the HTTP vars 106 99 @reset($GLOBALS['HTTP_POST_VARS']); 107 while(list($name,) = @each($GLOBALS['HTTP_POST_VARS'])) 108 { 100 while (list($name, ) = @each($GLOBALS['HTTP_POST_VARS'])) { 109 101 $this->$name = $GLOBALS['HTTP_POST_VARS'][$name]; 110 102 } 111 103 112 104 @reset($GLOBALS['HTTP_GET_VARS']); 113 while(list($name,) = @each($GLOBALS['HTTP_GET_VARS'])) 114 { 105 while (list($name, ) = @each($GLOBALS['HTTP_GET_VARS'])) { 115 106 $$name = $GLOBALS['HTTP_GET_VARS'][$name]; 116 107 $this->$name = $GLOBALS['HTTP_GET_VARS'][$name]; 117 118 108 } 119 109 120 110 $to_decode = array 121 ( 122 'op' => array('op' => ''), 123 'path' => array('path' => ''), 124 'filename' => array('filename' => ''), 125 'file' => array('file' => ''), 126 'sortby' => array('sortby' => ''), 127 'messages' => array('messages' => ''), 128 'show_upload_boxes' => array('show_upload_boxes' => ''), 129 'from' => array('from' => ''), 130 'to' => array('to' => '') 131 111 ( 112 'op' => array('op' => ''), 113 'path' => array('path' => ''), 114 'filename' => array('filename' => ''), 115 'file' => array('file' => ''), 116 'sortby' => array('sortby' => ''), 117 'messages' => array('messages' => ''), 118 'show_upload_boxes' => array('show_upload_boxes' => ''), 119 'from' => array('from' => ''), 120 'to' => array('to' => '') 132 121 ); 133 122 134 123 reset($to_decode); 135 while(list($var, $conditions) = each($to_decode)) 136 { 137 while(list($condvar, $condvalue) = each($conditions)) 138 { 139 if(isset($$condvar) && ($condvar == $var || $$condvar == $condvalue)) 140 { 124 while (list($var, $conditions) = each($to_decode)) { 125 while (list($condvar, $condvalue) = each($conditions)) { 126 if (isset($$condvar) && ($condvar == $var || $$condvar == $condvalue)) { 141 127 $this->$var = stripslashes(base64_decode($$var)); 142 128 } … … 151 137 $pref_array = $pref->read_repository(); 152 138 $this->prefs = $pref_array[$this->bo->appname]; //FIXME check appname var in _debug_array 153 154 139 //always show name 155 140 156 $this->prefs[name] =1; 157 158 159 if($this->prefs['viewinnewwin']) 160 { 141 $this->prefs[name] = 1; 142 143 144 if ($this->prefs['viewinnewwin']) { 161 145 $this->target = '_blank'; 162 146 } … … 164 148 165 149 /* 166 167 168 */169 150 Check for essential directories 151 admin must be able to disable these tests 152 */ 153 170 154 // check if basedir exist 171 $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 172 if($test[mime_type]!='Directory') 173 { 155 $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->basedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 156 if ($test[mime_type] != 'Directory') { 174 157 die('Base directory does not exist, Ask adminstrator to check the global configuration.'); 175 158 } 176 159 177 $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 178 if($test[mime_type]!='Directory') 179 { 160 $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->basedir . $this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 161 if ($test[mime_type] != 'Directory') { 180 162 $this->bo->vfs->override_acl = 1; 181 163 182 164 $this->bo->vfs->mkdir(array( 183 'string' => $this->bo->fakebase,184 'relatives' => array(RELATIVE_NONE)165 'string' => $this->bo->fakebase, 166 'relatives' => array(RELATIVE_NONE) 185 167 )); 186 168 187 169 $this->bo->vfs->override_acl = 0; 188 170 189 171 //test one more time 190 $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 191 192 if($test[mime_type]!='Directory') 193 { 172 $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->basedir . $this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 173 174 if ($test[mime_type] != 'Directory') { 194 175 die('Fake Base directory does not exist and could not be created, please ask the administrator to check the global configuration.'); 195 } 196 else 197 { 198 $this->messages[]= lang('Fake Base Dir did not exist, created a new one.'); 199 } 200 } 201 202 $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 203 if($test[mime_type]!='Directory') 204 { 176 } else { 177 $this->messages[] = lang('Fake Base Dir did not exist, created a new one.'); 178 } 179 } 180 181 $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->basedir . $this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 182 if ($test[mime_type] != 'Directory') { 205 183 $this->bo->vfs->override_acl = 1; 206 184 207 185 $this->bo->vfs->mkdir(array( 208 'string' => $this->bo->homedir,209 'relatives' => array(RELATIVE_NONE)186 'string' => $this->bo->homedir, 187 'relatives' => array(RELATIVE_NONE) 210 188 )); 211 189 $this->bo->vfs->set_quota(array( 212 'string' => $this->bo->homedir,213 'relatives' => array(RELATIVE_NONE),214 'new_quota' => $this->current_config['filemanager_quota_size']190 'string' => $this->bo->homedir, 191 'relatives' => array(RELATIVE_NONE), 192 'new_quota' => $this->current_config['filemanager_quota_size'] 215 193 )); 216 194 … … 218 196 219 197 //test one more time 220 $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 221 222 if($test[mime_type]!='Directory') 223 { 198 $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->basedir . $this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 199 200 if ($test[mime_type] != 'Directory') { 224 201 die('Your Home Dir does not exist and could not be created, please ask the adminstrator to check the global configuration.'); 225 } 226 else 227 { 228 $this->messages[]= lang('Your Home Dir did not exist, eGroupWare created a new one.'); 202 } else { 203 $this->messages[] = lang('Your Home Dir did not exist, eGroupWare created a new one.'); 229 204 // FIXME we just created a fresh home dir so we know there nothing in it so we have to remove all existing content 230 205 } 231 232 233 } 234 } 235 function fileModels() 236 { 206 } 207 } 208 209 function fileModels() { 237 210 $GLOBALS['phpgw_info']['flags'] = array 238 (239 'currentapp'=> 'filemanager',240 'noheader'=> False,241 242 'nofooter'=> False,243 'noappheader'=> False,244 'enable_browser_class'=> True245 211 ( 212 'currentapp' => 'filemanager', 213 'noheader' => False, 214 'nonavbar' => False, 215 'nofooter' => False, 216 'noappheader' => False, 217 'enable_browser_class' => True 218 ); 246 219 247 220 $GLOBALS['phpgw']->common->phpgw_header(); 248 221 $this->t->set_file(array('models' => 'fileModels.tpl')); 249 $this->t->set_block('models', 'header','header');250 $this->t->set_block('models', 'body','body');251 $this->t->set_block('models', 'footer','footer');222 $this->t->set_block('models', 'header', 'header'); 223 $this->t->set_block('models', 'body', 'body'); 224 $this->t->set_block('models', 'footer', 'footer'); 252 225 $this->t->set_var('url_1', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=article'); 253 $this->t->set_var('model_1','article'); 254 $this->t->set_var('lang_1',lang('article')); 255 256 $this->t->set_var('url_2','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=calendar'); 257 $this->t->set_var('model_2','calendar'); 258 $this->t->set_var('lang_2',lang('calendar')); 259 260 $this->t->set_var('url_3','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=todo'); 261 $this->t->set_var('model_3','todo'); 262 $this->t->set_var('lang_3',lang('todo')); 263 264 $this->t->set_var('url_4','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=slide'); 265 $this->t->set_var('model_4','slide'); 266 $this->t->set_var('lang_4',lang('slide')); 267 268 $this->t->set_var('url_5','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=cards'); 269 $this->t->set_var('model_5','cards'); 270 $this->t->set_var('lang_5',lang('cards')); 271 272 $this->t->set_var('url_6','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=resume'); 273 $this->t->set_var('model_6','resume'); 274 $this->t->set_var('lang_6',lang('resume')); 275 276 277 $this->t->pparse('out','models'); 278 279 280 } 281 function uploadModel(){ 226 $this->t->set_var('model_1', 'article'); 227 $this->t->set_var('lang_1', lang('article')); 228 229 $this->t->set_var('url_2', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=calendar'); 230 $this->t->set_var('model_2', 'calendar'); 231 $this->t->set_var('lang_2', lang('calendar')); 232 233 $this->t->set_var('url_3', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=todo'); 234 $this->t->set_var('model_3', 'todo'); 235 $this->t->set_var('lang_3', lang('todo')); 236 237 $this->t->set_var('url_4', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=slide'); 238 $this->t->set_var('model_4', 'slide'); 239 $this->t->set_var('lang_4', lang('slide')); 240 241 $this->t->set_var('url_5', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=cards'); 242 $this->t->set_var('model_5', 'cards'); 243 $this->t->set_var('lang_5', lang('cards')); 244 245 $this->t->set_var('url_6', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=resume'); 246 $this->t->set_var('model_6', 'resume'); 247 $this->t->set_var('lang_6', lang('resume')); 248 249 250 $this->t->pparse('out', 'models'); 251 } 252 253 function uploadModel() { 282 254 $GLOBALS['phpgw_info']['flags'] = array 283 (284 'currentapp'=> 'filemanager',285 'noheader'=> False,286 287 'nofooter'=> False,288 'noappheader'=> False,289 'enable_browser_class'=> True290 255 ( 256 'currentapp' => 'filemanager', 257 'noheader' => False, 258 'nonavbar' => False, 259 'nofooter' => False, 260 'noappheader' => False, 261 'enable_browser_class' => True 262 ); 291 263 292 264 $GLOBALS['phpgw']->common->phpgw_header(); 293 265 294 $filename = lang('new') ."_".lang($this->model).rand(0,1000).".html";266 $filename = lang('new') . "_" . lang($this->model) . rand(0, 1000) . ".html"; 295 267 $this->bo->vfs->cp(array( 296 'from'=> PHPGW_SERVER_ROOT . '/filemanager/templates/default/'.$this->model.'.html',297 'to'=> $filename,298 'relatives' => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)268 'from' => PHPGW_SERVER_ROOT . '/filemanager/templates/default/' . $this->model . '.html', 269 'to' => $filename, 270 'relatives' => array(RELATIVE_NONE | VFS_REAL, RELATIVE_ALL) 299 271 )); 300 272 301 273 $this->bo->vfs->set_attributes(array( 302 'string'=> $filename,303 'relatives'=> array(RELATIVE_ALL),304 'attributes'=> array(305 'mime_type' => "text/html",306 'comment' => ""307 )274 'string' => $filename, 275 'relatives' => array(RELATIVE_ALL), 276 'attributes' => array( 277 'mime_type' => "text/html", 278 'comment' => "" 279 ) 308 280 )); 309 281 $this->filename = $filename; 310 282 $this->edit(); 311 312 } 313 function index() 314 { 283 } 284 285 function index() { 315 286 $GLOBALS['phpgw_info']['flags'] = array 316 (317 'currentapp'=> 'filemanager',318 'noheader'=> False,319 'nonavbar' => False,320 'nofooter'=> False,321 'noappheader'=> False,322 'enable_browser_class'=> True287 ( 288 'currentapp' => 'filemanager', 289 'noheader' => False, 290 'nonavbar' => False, 291 'nofooter' => False, 292 'noappheader' => False, 293 'enable_browser_class' => True 323 294 ); 324 295 325 296 $GLOBALS['phpgw']->common->phpgw_header(); 297 298 echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/inc/load_lang.php'></script>"; 299 echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/global.js'></script>"; 300 echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/main.js'></script>"; 301 echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/common_functions.js'></script>"; 302 echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/connector.js'></script>"; 303 echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/draw_api.js'></script>"; 304 echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/drag_area.js'></script>"; 305 echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/handler.js'></script>"; 326 306 327 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/inc/load_lang.php'></script>"; 328 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/global.js'></script>"; 329 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/main.js'></script>"; 330 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/common_functions.js'></script>"; 331 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/connector.js'></script>"; 332 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/draw_api.js'></script>"; 333 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/drag_area.js'></script>"; 334 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/handler.js'></script>"; 307 //echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/NewHandler.js'></script>"; 335 308 336 309 … … 338 311 $theme = "window_" . $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] . ".css"; 339 312 340 if ( !file_exists('filemanager/tp/expressowindow/css/'.$theme))313 if (!file_exists('filemanager/tp/expressowindow/css/' . $theme)) 341 314 $theme = "window_default.css"; 342 315 343 316 // Path FileManager 344 317 $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url']; 345 $webserver_url = ( 346 347 if (strrpos($webserver_url,'/') === false || strrpos($webserver_url,'/') != (strlen($webserver_url)-1))318 $webserver_url = (!empty($webserver_url) ) ? $webserver_url : '/'; 319 320 if (strrpos($webserver_url, '/') === false || strrpos($webserver_url, '/') != (strlen($webserver_url) - 1)) 348 321 $webserver_url .= '/'; 349 350 $webserver_url = $webserver_url . 'filemanager/';351 352 $js = "var path_filemanager = '".$webserver_url."';";353 $js .= "var my_home_filemanager = '".trim($GLOBALS['uifilemanager']->bo->vfs->my_home)."';";354 355 echo "<script type='text/javascript'>" .$js."</script>";322 323 $webserver_url = $webserver_url . 'filemanager/'; 324 325 $js = "var path_filemanager = '" . $webserver_url . "';"; 326 $js .= "var my_home_filemanager = '" . trim($GLOBALS['uifilemanager']->bo->vfs->my_home) . "';"; 327 328 echo "<script type='text/javascript'>" . $js . "</script>"; 356 329 357 330 // Expresso Window - CSS 358 print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'tp/expressowindow/css/' .$theme.'" >';331 print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'tp/expressowindow/css/' . $theme . '" >'; 359 332 360 333 // Expresso Window - JS 361 echo "<script src='" .$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/xtools.js'></script>";362 echo "<script src='" .$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/jsloader.js'></script>";363 echo "<script src='" .$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/makeW.js'></script>";364 echo "<script src='" .$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/dragdrop.js'></script>";365 echo "<script src='" .$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/show_hidden.js'></script>";334 echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/tp/expressowindow/js/xtools.js'></script>"; 335 echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/tp/expressowindow/js/jsloader.js'></script>"; 336 echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/tp/expressowindow/js/makeW.js'></script>"; 337 echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/tp/expressowindow/js/dragdrop.js'></script>"; 338 echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/tp/expressowindow/js/show_hidden.js'></script>"; 366 339 367 340 echo "<script src='./phpgwapi/js/dftree/dftree.js'></script>"; … … 370 343 # Code is fairly hackish at the beginning, but it gets better 371 344 # Highly suggest turning wrapping off due to long SQL queries 372 373 345 ### 374 346 # Some hacks to set and display directory paths correctly 375 347 ### 376 348 // new method for switching to a new dir. 377 if($this->changedir=='true' && $this->cdtodir || $this->goto_x) 378 { 349 if ($this->changedir == 'true' && $this->cdtodir || $this->goto_x) { 379 350 $this->path = $this->cdtodir; 380 351 } 381 352 382 if(!$this->path) 383 { 353 if (!$this->path) { 384 354 $this->path = $this->bo->vfs->pwd(); 385 355 386 if(!$this->path || $this->bo->vfs->pwd(array('full' => False)) == '') 387 { 388 $this->path = $this->bo->homedir; 356 if (!$this->path || $this->bo->vfs->pwd(array('full' => False)) == '') { 357 $this->path = $this->bo->homedir; 389 358 } 390 359 } … … 395 364 $pwd = $this->bo->vfs->pwd(); 396 365 397 if(!$this->cwd = substr($this->path, strlen($this->bo->homedir) + 1)) 398 { 366 if (!$this->cwd = substr($this->path, strlen($this->bo->homedir) + 1)) { 399 367 $this->cwd = '/'; 400 } 401 else 402 { 368 } else { 403 369 $this->cwd = substr($pwd, strrpos($pwd, '/') + 1); 404 370 } … … 407 373 408 374 /* This just prevents // in some cases */ 409 if($this->path == '/') 410 { 375 if ($this->path == '/') { 411 376 $this->dispsep = ''; 412 } 413 else 414 { 377 } else { 415 378 $this->dispsep = '/'; 416 379 } 417 380 418 if(!($this->lesspath = substr($this->path, 0, strrpos($this->path, '/')))) 419 { 381 if (!($this->lesspath = substr($this->path, 0, strrpos($this->path, '/')))) { 420 382 $this->lesspath = '/'; 421 383 } 422 384 423 /*Check permission*/ 424 if($this->bo->vfs->acl_check(array( 425 'string' => $this->path, 426 'relatives' => array(RELATIVE_NONE), 427 'operation' => PHPGW_ACL_READ 428 ))) 429 { 385 /* Check permission */ 386 if ($this->bo->vfs->acl_check(array( 387 'string' => $this->path, 388 'relatives' => array(RELATIVE_NONE), 389 'operation' => PHPGW_ACL_READ 390 ))) { 430 391 $this->can_read = True; 431 392 } 432 393 433 394 434 if ($_SESSION['phpgw_info']['user']['filemanager']['flush'] != 'flushed') 435 { 436 /*Flush journal-deleted*/ 395 if ($_SESSION['phpgw_info']['user']['filemanager']['flush'] != 'flushed') { 396 /* Flush journal-deleted */ 437 397 $this->bo->vfs->flush_journal(array( 438 'string' => $this->path,439 'relatives' => array(RELATIVE_NONE),440 'deleteall' => True398 'string' => $this->path, 399 'relatives' => array(RELATIVE_NONE), 400 'deleteall' => True 441 401 )); 442 402 $_SESSION['phpgw_info']['user']['filemanager']['flush'] = 'flushed'; … … 446 406 447 407 # if is different path than home and no permission allowed 448 if($this->path != $this->bo->homedir && $this->path != $this->bo->fakebase && $this->path != '/' && !$this->can_read) 449 { 408 if ($this->path != $this->bo->homedir && $this->path != $this->bo->fakebase && $this->path != '/' && !$this->can_read) { 450 409 $this->messages[] = lang('You do not have access to %1', $this->path); 451 410 $this->path = $this->homedir; … … 459 418 460 419 # Verify path is real 461 if($this->path != $this->bo->homedir && $this->path != '/' && $this->path != $this->bo->fakebase) 462 { 463 if(!$this->bo->vfs->file_exists(array( 464 'string' => $this->path, 465 'relatives' => array(RELATIVE_NONE) 466 ))) 467 { 468 $this->messages[] = lang('Error:').lang('Directory %1 does not exist', $this->path); 420 if ($this->path != $this->bo->homedir && $this->path != '/' && $this->path != $this->bo->fakebase) { 421 if (!$this->bo->vfs->file_exists(array( 422 'string' => $this->path, 423 'relatives' => array(RELATIVE_NONE) 424 ))) { 425 $this->messages[] = lang('Error:') . lang('Directory %1 does not exist', $this->path); 469 426 $this->path = $this->homedir; 470 427 $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); … … 476 433 477 434 # Default is to sort by name 478 if(!$this->sortby) 479 { 435 if (!$this->sortby) { 480 436 $this->sortby = 'name'; 481 437 } 482 if ($this->update_x == 1){438 if ($this->update_x == 1) { 483 439 $this->bo->vfs->update_real(array( 484 'string'=> $this->path,485 'relatives'=> array(RELATIVE_NONE)440 'string' => $this->path, 441 'relatives' => array(RELATIVE_NONE) 486 442 )); 487 header('Location:'.$this->encode_href('index.php?menuaction=filemanager.uifilemanager.index','&path='.base64_encode($this->bo->homedir))); 488 } 489 elseif($this->newfile_x && $this->newfile_or_dir) // create new textfile 490 { 443 header('Location:' . $this->encode_href('index.php?menuaction=filemanager.uifilemanager.index', '&path=' . base64_encode($this->bo->homedir))); 444 } elseif ($this->newfile_x && $this->newfile_or_dir) { // create new textfile 491 445 $this->createfile(); 492 } 493 elseif($this->edit_cancel_x) 494 { 446 } elseif ($this->edit_cancel_x) { 495 447 $this->readFilesInfo(); 496 448 $this->fileListing(); 497 } 498 elseif($this->edit_x || $this->edit_preview_x || $this->edit_save_x || $this->edit_save_done_x) 499 { 449 } elseif ($this->edit_x || $this->edit_preview_x || $this->edit_save_x || $this->edit_save_done_x) { 500 450 $this->edit(); 501 } 502 else 503 { 451 } else { 504 452 //$this->readFilesInfo(); 505 453 $this->fileListing(); 506 454 } 507 455 } 508 function get_permissions(){ 456 457 function get_permissions() { 509 458 /* get permissions */ 510 if((preg_match('+^'.$this->bo->fakebase.'\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $this->bo->userinfo['account_lid']) //FIXME matches not defined 511 512 { 513 $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]);//FIXME matches not defined 514 515 } 516 else 517 { 459 if ((preg_match('+^' . $this->bo->fakebase . '\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $this->bo->userinfo['account_lid']) { //FIXME matches not defined 460 $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]); //FIXME matches not defined 461 } else { 518 462 $this->bo->vfs->working_id = $this->bo->userinfo['username']; 519 463 } 520 464 521 465 # Check available permissions for $this->path, so we can disable unusable operations in user interface 522 $path = explode('/', $this->path);523 $owner_id = $this->bo->vfs->ownerOf($this->bo->fakebase, $path[2]);466 $path = explode('/', $this->path); 467 $owner_id = $this->bo->vfs->ownerOf($this->bo->fakebase, $path[2]); 524 468 $user_id = $GLOBALS['phpgw_info']['user']['account_id']; 525 if ($owner_id == $user_id) 526 { 469 if ($owner_id == $user_id) { 527 470 $rights = 31; 528 }else 529 { 530 $acl = CreateObject ('phpgwapi.acl', $owner_id); 471 } else { 472 $acl = CreateObject('phpgwapi.acl', $owner_id); 531 473 $acl->account_id = $owner_id; 532 474 $acl->read_repository(); 533 475 $rights = $acl->get_rights($user_id); 534 476 } 535 return $rights; 536 } 537 function dir_ls() 538 {477 return $rights; 478 } 479 480 function dir_ls() { 539 481 // change dir to this->path 540 482 $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 541 483 $return['permissions'] = $this->get_permissions(); 542 484 $return['quota']['usedSpace'] = $this->bo->vfs->get_size(array( 543 'string'=> $this->path,544 'relatives'=> array(RELATIVE_NONE)545 ));485 'string' => $this->path, 486 'relatives' => array(RELATIVE_NONE) 487 )); 546 488 $return['files_count'] = $this->bo->vfs->count_files(array( 547 'string'=> $this->path,548 ));489 'string' => $this->path, 490 )); 549 491 $quota = $this->bo->vfs->get_quota(array( 550 'string'=> $this->path551 ));492 'string' => $this->path 493 )); 552 494 reset($this->files_array); 553 495 $this->readFilesInfo(); 554 496 555 for($i = 0; $i != $this->numoffiles; $i++) 556 { 497 for ($i = 0; $i != $this->numoffiles; $i++) { 557 498 $files = $this->files_array[$i]; 558 499 559 if($files['mime_type'] == "Directory") 560 { 500 if ($files['mime_type'] == "Directory") { 561 501 continue; 562 502 } 563 503 /* small keys to safe bandwidth */ 564 504 $tuple['name'] = htmlentities($files['name']); 565 if ($_SESSION['phpgw_info']['user']['preferences']['filemanager']['viewIcons'] == 1){ 566 if ($files['mime_type'] == 'image/png' || 567 $files['mime_type'] == 'image/gif' || 568 $files['mime_type'] == 'image/jpg') 569 { 570 $filename = str_replace('=','',base64_encode($tuple['name'])); 571 $pathname = str_replace('=','',base64_encode($this->path)); 572 $tuple['icon'] = './index.php?menuaction=filemanager.vfs_functions.summary&file='.$filename.'&path='.$pathname; 505 if ($_SESSION['phpgw_info']['user']['preferences']['filemanager']['viewIcons'] == 1) { 506 if ($files['mime_type'] == 'image/png' || 507 $files['mime_type'] == 'image/gif' || 508 $files['mime_type'] == 'image/jpg') { 509 $filename = str_replace('=', '', base64_encode($tuple['name'])); 510 $pathname = str_replace('=', '', base64_encode($this->path)); 511 $tuple['icon'] = './index.php?menuaction=filemanager.vfs_functions.summary&file=' . $filename . '&path=' . $pathname; 573 512 } 574 513 else 575 $tuple['icon'] = $this->mime_icon($files['mime_type'],64);514 $tuple['icon'] = $this->mime_icon($files['mime_type'], 64); 576 515 } 577 516 else … … 584 523 $tuple['pub'] = $files['type']; 585 524 $tuple['createdby_id'] = $GLOBALS['phpgw']->accounts->id2name($files['createdby_id']); 586 $tuple['modifiedby_id'] = $files['modifiedby_id'] ?$GLOBALS['phpgw']->accounts->id2name($files['modifiedby_id']):'';525 $tuple['modifiedby_id'] = $files['modifiedby_id'] ? $GLOBALS['phpgw']->accounts->id2name($files['modifiedby_id']) : ''; 587 526 $tuple['owner'] = $GLOBALS['phpgw']->accounts->id2name($files['owner_id']); 588 527 $tuple['comment'] = $files['comment']; 589 528 $tuple['version'] = $files['version']; 590 529 $output[] = $tuple; 591 592 530 } 593 531 $return['files'] = $output; 594 $return['quota']['quotaSize'] = ($quota *1024*1024);532 $return['quota']['quotaSize'] = ($quota * 1024 * 1024); 595 533 echo serialize($return); 596 534 } 597 function get_folders_list() 598 {599 $this->update_groups(); 535 536 function get_folders_list() { 537 $this->update_groups(); 600 538 $this->groups_applications = array(); 601 539 602 540 $user_groups = $GLOBALS['phpgw']->accounts->membership(); 603 foreach ($user_groups as $val){541 foreach ($user_groups as $val) { 604 542 $account_name = $GLOBALS['phpgw']->accounts->id2name($val['account_id']); 605 543 $this->readable_groups[$account_name] = array( 606 'account_id' => $val['account_id'],607 'account_name' => $account_name544 'account_id' => $val['account_id'], 545 'account_name' => $account_name 608 546 ); 609 547 } 610 548 611 foreach ($this->readable_groups as $value) 612 { 549 foreach ($this->readable_groups as $value) { 613 550 $applications = CreateObject('phpgwapi.applications', $value['account_id']); 614 551 $this->groups_applications[$value['account_name']] = $applications->read_account_specific(); … … 618 555 // selectbox for change/move/and copy to 619 556 $this->dirs = $this->all_other_directories(); 620 foreach ($this->dirs as $dir)557 foreach ($this->dirs as $dir) 621 558 $return[] = $dir['directory'] . $dir['name']; 622 559 sort(&$return, SORT_STRING); 623 560 echo serialize($return); 624 561 } 625 function fileListing() 626 {562 563 function fileListing() { 627 564 $this->t->set_file(array('filemanager_list_t' => 'main.tpl')); 628 $this->t->set_block('filemanager_list_t','filemanager_header','filemanager_header'); 629 $this->t->set_block('filemanager_list_t','filemanager_footer','filemanager_footer'); 630 631 if($this->numoffiles || $this->cwd) 632 { 633 $vars[path]='<input type="hidden" id="currentPath" value="'.$this->path.'">'; 634 $vars[css]='<link rel="stylesheet" type="text/css" href="filemanager/templates/default/main.css">'; 565 $this->t->set_block('filemanager_list_t', 'filemanager_header', 'filemanager_header'); 566 $this->t->set_block('filemanager_list_t', 'filemanager_footer', 'filemanager_footer'); 567 568 if ($this->numoffiles || $this->cwd) { 569 $vars[path] = '<input type="hidden" id="currentPath" value="' . $this->path . '">'; 570 $vars[css] = '<link rel="stylesheet" type="text/css" href="filemanager/templates/default/main.css">'; 635 571 $vars[css].='<link rel="stylesheet" type="text/css" href="phpgwapi/js/dftree/dftree.css">'; 636 572 $_SESSION['phpgw_info']['user']['preferences']['filemanager']['lid'] = $GLOBALS['phpgw_info']['user']['account_lid']; 637 $vars[preferences] ='<input type="hidden" id="userPreferences" value=\''.serialize($_SESSION['phpgw_info']['user']['preferences']['filemanager']).'\'>';573 $vars[preferences] = '<input type="hidden" id="userPreferences" value=\'' . serialize($_SESSION['phpgw_info']['user']['preferences']['filemanager']) . '\'>'; 638 574 // Used for important operations that needs security 639 for ($key = ""; strlen($key) < 150; $key .= chr(rand(48,95))); 575 for ($key = ""; strlen($key) < 150; $key .= chr(rand(48, 95))) 576 ; 640 577 $_SESSION['phpgw_info']['filemanager']['user']['sec_key'] = $key; 641 $vars[sec_key] ='<input type="hidden" id="userKey" value=\''.$key.'\'>';642 $vars[script] ='<script>initDrawApi();</script>';643 644 $vars[new_button] =$this->toolButton('new','createfile',lang('New...'));578 $vars[sec_key] = '<input type="hidden" id="userKey" value=\'' . $key . '\'>'; 579 $vars[script] = '<script>initDrawApi();</script>'; 580 581 $vars[new_button] = $this->toolButton('new', 'createfile', lang('New...')); 645 582 $vars[new_button].='<input type="hidden" id="newfile_or_dir" name="newfile_or_dir" value="" />'; 646 583 647 584 // reload button with this url 648 $vars[refresh_button] =$this->toolButton('reload','reload',lang('reload'));585 $vars[refresh_button] = $this->toolButton('reload', 'reload', lang('reload')); 649 586 650 587 // go up icon when we're not at the top, dont allow to go outside /home = fakebase 651 if($this->path != '/' && $this->path != $this->bo->fakebase) 652 { 653 $vars[tools_button] = $this->toolButton('tools','tools',lang('tools')); 588 if ($this->path != '/' && $this->path != $this->bo->fakebase) { 589 $vars[tools_button] = $this->toolButton('tools', 'tools', lang('tools')); 654 590 } 655 591 else 656 592 $vars[tools_button] = ""; 657 593 658 $vars[toolbar1]=$toolbar; 659 660 if(count($this->messages)>0) 661 { 662 foreach($this->messages as $msg) 663 { 664 $messages.='<span>'.$msg.'</span>'; 594 $vars[toolbar1] = $toolbar; 595 596 if (count($this->messages) > 0) { 597 foreach ($this->messages as $msg) { 598 $messages.='<span>' . $msg . '</span>'; 665 599 } 666 600 } 667 601 $this->messages = NULL; 668 669 $vars[messages] =$messages;602 603 $vars[messages] = $messages; 670 604 671 605 $this->t->set_var($vars); 672 $this->t->pparse('out', 'filemanager_header');606 $this->t->pparse('out', 'filemanager_header'); 673 607 } 674 608 675 609 $this->t->set_var($vars); 676 $this->t->pparse('out', 'filemanager_footer');610 $this->t->pparse('out', 'filemanager_footer'); 677 611 678 612 $GLOBALS['phpgw']->common->phpgw_footer(); … … 680 614 } 681 615 682 function readFilesInfo() 683 { 616 function readFilesInfo() { 684 617 // start files info 685 686 618 # Read in file info from database to use in the rest of the script 687 619 # $fakebase is a special directory. In that directory, we list the user's 688 620 # home directory and the directories for the groups they're in 689 621 $this->numoffiles = 0; 690 if($this->path == $this->bo->fakebase) 691 { 622 if ($this->path == $this->bo->fakebase) { 692 623 // FIXME this test can be removed 693 if(!$this->bo->vfs->file_exists(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE)))) 694 { 624 if (!$this->bo->vfs->file_exists(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE)))) { 695 625 $this->bo->vfs->mkdir(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE))); 696 626 } 697 627 698 628 $ls_array = $this->bo->vfs->ls(array( 699 'string' => $this->bo->homedir,700 'relatives' => array(RELATIVE_NONE),701 'checksubdirs' => False,702 'nofiles' => True703 ));629 'string' => $this->bo->homedir, 630 'relatives' => array(RELATIVE_NONE), 631 'checksubdirs' => False, 632 'nofiles' => True 633 )); 704 634 705 635 $this->files_array[] = $ls_array[0]; … … 707 637 708 638 reset($this->readable_groups); 709 while(list($num, $group_array) = each($this->readable_groups)) 710 { 639 while (list($num, $group_array) = each($this->readable_groups)) { 711 640 # If the group doesn't have access to this app, we don't show it 712 /*if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled']) 713 { 714 continue; 715 } 716 */ 717 718 719 if(!$this->bo->vfs->file_exists(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE)))) 720 { 641 /* if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled']) 642 { 643 continue; 644 } 645 */ 646 647 648 if (!$this->bo->vfs->file_exists(array('string' => $this->bo->fakebase . '/' . $group_array['account_name'], 'relatives' => array(RELATIVE_NONE)))) { 721 649 $this->bo->vfs->override_acl = 1; 722 650 $this->bo->vfs->mkdir(array( 723 'string' => $this->bo->fakebase.'/'.$group_array['account_name'],724 'relatives' => array(RELATIVE_NONE)651 'string' => $this->bo->fakebase . '/' . $group_array['account_name'], 652 'relatives' => array(RELATIVE_NONE) 725 653 )); 726 654 727 655 // FIXME we just created a fresh group dir so we know there nothing in it so we have to remove all existing content 728 729 656 657 730 658 $this->bo->vfs->override_acl = 0; 731 659 732 $this->bo->vfs->set_attributes(array('string' => $this->bo->fakebase .'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE),'attributes' => array('owner_id' => $group_array['account_id'],'createdby_id' => $group_array['account_id'])));660 $this->bo->vfs->set_attributes(array('string' => $this->bo->fakebase . '/' . $group_array['account_name'], 'relatives' => array(RELATIVE_NONE), 'attributes' => array('owner_id' => $group_array['account_id'], 'createdby_id' => $group_array['account_id']))); 733 661 } 734 662 735 $ls_array = $this->bo->vfs->ls(array('string' => $this->bo->fakebase .'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE),'checksubdirs' => False,'nofiles' => True));663 $ls_array = $this->bo->vfs->ls(array('string' => $this->bo->fakebase . '/' . $group_array['account_name'], 'relatives' => array(RELATIVE_NONE), 'checksubdirs' => False, 'nofiles' => True)); 736 664 737 665 $this->files_array[] = $ls_array[0]; … … 739 667 $this->numoffiles++; 740 668 } 741 } 742 else 743 { 669 } else { 744 670 $ls_array = $this->bo->vfs->ls(array( 745 'string' => $this->path, 746 'relatives' => array(RELATIVE_NONE), 747 'checksubdirs' => False, 748 'nofiles' => False, 749 'orderby' => $this->criteria, 750 'otype' => $this->otype, 751 'limit' => $this->limit, 752 'offset' => $this->offset 753 )); 754 755 while(list($num, $file_array) = each($ls_array)) 756 { 671 'string' => $this->path, 672 'relatives' => array(RELATIVE_NONE), 673 'checksubdirs' => False, 674 'nofiles' => False, 675 'orderby' => $this->criteria, 676 'otype' => $this->otype, 677 'limit' => $this->limit, 678 'offset' => $this->offset 679 )); 680 681 while (list($num, $file_array) = each($ls_array)) { 757 682 $this->numoffiles++; 758 683 $this->files_array[] = $file_array; … … 760 685 } 761 686 762 if(!is_array($this->files_array)) 763 { 687 if (!is_array($this->files_array)) { 764 688 $this->files_array = array(); 765 689 } 766 690 // end file count 767 691 } 768 769 function removedir() 770 { 692 693 function removedir() { 771 694 //$toRemove = $this->path ^ $_SESSION['phpgw_info']['filemanager']['user']['sec_key']; 772 695 $toRemove = $this->path; 773 774 if ( $this->bo->vfs->rm(array( 'string' => $toRemove, 'relatives' => array (RELATIVE_NONE) )))696 697 if ($this->bo->vfs->rm(array('string' => $toRemove, 'relatives' => array(RELATIVE_NONE)))) 775 698 echo "True"; 776 699 else 777 700 echo "False"; 778 701 } 779 780 function createdir() 781 { 782 if( $this->bo->badchar = $this->bo->bad_chars($this->filename, True, True) ) 783 { 784 echo lang('Error:').$this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1); 702 703 function createdir() { 704 if ($this->bo->badchar = $this->bo->bad_chars($this->filename, True, True)) { 705 echo lang('Error:') . $this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1); 785 706 return; 786 707 } 787 708 /* TODO is this right or should it be a single $ ? */ 788 if($this->filename[strlen($this->filename)-1] == ' ' || $this->filename[0] == ' ') 789 { 790 echo lang('Error:').lang('Cannot create directory because it begins or ends in a space'); 791 } 792 709 if ($this->filename[strlen($this->filename) - 1] == ' ' || $this->filename[0] == ' ') { 710 echo lang('Error:') . lang('Cannot create directory because it begins or ends in a space'); 711 } 712 793 713 $ls_array = $this->bo->vfs->ls(array( 794 'string'=> $this->path . '/' . $this->filename,795 'relatives'=> array(RELATIVE_NONE),796 'checksubdirs'=> False,797 'nofiles'=> True798 ));714 'string' => $this->path . '/' . $this->filename, 715 'relatives' => array(RELATIVE_NONE), 716 'checksubdirs' => False, 717 'nofiles' => True 718 )); 799 719 800 720 $fileinfo = $ls_array[0]; 801 721 802 if($fileinfo['name']) 803 { 804 if($fileinfo['mime_type'] != 'Directory') 805 { 806 echo lang('Error:').lang('%1 already exists as a file',$fileinfo['name']); 807 } 808 else 809 { 810 echo lang('Error:').lang('Directory %1 already exists', $fileinfo['name']); 811 } 812 } 813 else 814 { 722 if ($fileinfo['name']) { 723 if ($fileinfo['mime_type'] != 'Directory') { 724 echo lang('Error:') . lang('%1 already exists as a file', $fileinfo['name']); 725 } else { 726 echo lang('Error:') . lang('Directory %1 already exists', $fileinfo['name']); 727 } 728 } else { 815 729 $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 816 817 if( $this->bo->vfs->mkdir(array('string' => $this->filename )) ) 818 { 819 echo lang('Created directory %1', $this->disppath.'/'.$this->filename); 820 } 821 else 822 { 823 echo lang('Error:').lang('Could not create %1', $this->disppath.'/'.$this->filename); 730 731 if ($this->bo->vfs->mkdir(array('string' => $this->filename))) { 732 echo lang('Created directory %1', $this->disppath . '/' . $this->filename); 733 } else { 734 echo lang('Error:') . lang('Could not create %1', $this->disppath . '/' . $this->filename); 824 735 } 825 736 } 826 737 echo lang('Directory created'); 827 738 } 828 829 function getReturnExecuteForm() 830 { 739 740 function getReturnExecuteForm() { 831 741 $response = $_SESSION['response']; 832 742 833 743 unset($_SESSION['response']); 834 744 835 745 echo $response; 836 746 } 837 747 838 748 function showUploadboxes() 839 749 { 840 750 $notify = CreateObject('filemanager.notifications'); 841 751 842 752 $var = array( 843 'change_upload_boxes' => lang('Show'),844 'form_action'=> $GLOBALS[phpgw]->link('/filemanager/inc/upload.php'),845 846 'lang_file' => lang('File'),847 'lang_comment' => lang('Comment'),848 849 'lang_upload'=> lang('Upload files'),850 'max_size' => lang('Note: Uploaded is limited to %1MB',( $this->current_config['filemanager_Max_file_size'])),851 753 'change_upload_boxes' => lang('Show'), 754 'form_action' => $GLOBALS[phpgw]->link('/filemanager/inc/upload.php'), 755 'emails_to' => $notify->EmailsToSend($GLOBALS['phpgw']->preferences->values['email']), 756 'lang_file' => lang('File(s)'), 757 'lang_comment' => lang('Comment(s)'), 758 'lang_advanced_upload' => lang('Advanced Upload'), 759 'lang_upload' => lang('Upload files'), 760 'max_size' => lang('The maximum size for each file is %1MB', ($this->current_config['filemanager_Max_file_size'])), 761 'path' => $this->path 852 762 ); 853 854 print( serialize($var) ); 855 763 764 print( serialize($var)); 856 765 } 857 766 858 767 /* create textfile */ 859 function createfile() 768 function createfile() 860 769 { 861 $this->filename=$this->newfile_or_dir; 862 if($this->filename) 863 { 864 if($badchar = $this->bo->bad_chars($this->filename, True, True)) 865 { 866 $this->messages[] = lang('Error:').lang('File names cannot contain "%1"',$badchar); 770 $this->filename = $this->newfile_or_dir; 771 if ($this->filename) { 772 if ($badchar = $this->bo->bad_chars($this->filename, True, True)) { 773 $this->messages[] = lang('Error:') . lang('File names cannot contain "%1"', $badchar); 867 774 868 775 $this->fileListing(); 869 776 } 870 777 871 if($this->bo->vfs->file_exists(array( 872 'string'=> $this->filename, 873 'relatives' => array(RELATIVE_ALL) 874 ))) 875 { 876 $this->messages[]= lang('Error:').lang('File %1 already exists. Please edit it or delete it first.', $this->filename); 778 if ($this->bo->vfs->file_exists(array( 779 'string' => $this->filename, 780 'relatives' => array(RELATIVE_ALL) 781 ))) { 782 $this->messages[] = lang('Error:') . lang('File %1 already exists. Please edit it or delete it first.', $this->filename); 877 783 $this->fileListing(); 878 784 } 879 785 880 if($this->bo->vfs->touch(array( 881 'string' => $this->filename, 882 'relatives' => array(RELATIVE_ALL) 883 ))) 884 { 786 if ($this->bo->vfs->touch(array( 787 'string' => $this->filename, 788 'relatives' => array(RELATIVE_ALL) 789 ))) { 885 790 $this->edit = 1; 886 791 $this->numoffiles++; 887 792 $this->edit(); 888 } 889 else 890 { 891 $this->messages[]= lang('Error:').lang('File %1 could not be created.', $this->filename); 793 } else { 794 $this->messages[] = lang('Error:') . lang('File %1 could not be created.', $this->filename); 892 795 $this->fileListing(); 893 796 } … … 896 799 897 800 # Handle Editing files 898 function edit() 899 { 900 if($this->filename) 901 { 902 if (! $this->vfs_functions->verifyLock($this->path.'/'.$this->filename,RELATIVE_NONE)){ 801 802 function edit() { 803 if ($this->filename) { 804 if (!$this->vfs_functions->verifyLock($this->path . '/' . $this->filename, RELATIVE_NONE)) { 903 805 $GLOBALS['phpgw']->redirect('/index.php'); 904 806 } 905 807 $ls_array = $this->bo->vfs->ls(array( 906 'string' => $this->path.'/'.$this->filename, 907 'relatives' => array(RELATIVE_NONE), 908 'checksubdirs' => False, 909 'nofiles' => True 808 'string' => $this->path . '/' . $this->filename, 809 'relatives' => array(RELATIVE_NONE), 810 'checksubdirs' => False, 811 'nofiles' => True 812 )); 813 $this->bo->vfs->touch(array( 814 'string' => $this->path . '/' . $this->filename, 815 'relatives' => array(RELATIVE_NONE) 910 816 )); 911 $this->bo->vfs->touch(array( 912 'string'=> $this->path.'/'.$this->filename, 913 'relatives' => array(RELATIVE_NONE) 914 )); 915 916 917 if($ls_array[0]['mime_type']) 918 { 817 818 819 if ($ls_array[0]['mime_type']) { 919 820 $mime_type = $ls_array[0]['mime_type']; 920 } 921 elseif($this->prefs['viewtextplain']) 922 { 821 } elseif ($this->prefs['viewtextplain']) { 923 822 $mime_type = 'text/plain'; 924 823 } 925 $editable = array('', 'text/plain','text/csv','text/html','text/text','message/rfc822');926 927 if (!in_array($mime_type,$editable)){928 $this->messages[] = lang('Error:') .lang('Impossible to edit this file');824 $editable = array('', 'text/plain', 'text/csv', 'text/html', 'text/text', 'message/rfc822'); 825 826 if (!in_array($mime_type, $editable)) { 827 $this->messages[] = lang('Error:') . lang('Impossible to edit this file'); 929 828 $this->readFilesInfo(); 930 829 $this->fileListing(); … … 940 839 $this->t->set_file(array('filemanager_edit' => 'edit_file.tpl')); 941 840 942 $this->t->set_block('filemanager_edit', 'row','row');841 $this->t->set_block('filemanager_edit', 'row', 'row'); 943 842 944 843 945 844 $vars[refresh_script] = "<script src='filemanager/js/refresh.js'></script>"; 946 845 947 $vars[preview_content]=''; 948 if($this->edit_file) 949 { 846 $vars[preview_content] = ''; 847 if ($this->edit_file) { 950 848 $this->edit_file_content = stripslashes($this->edit_file_content); 951 849 } 952 850 953 if($this->edit_preview_x) 954 { 851 if ($this->edit_preview_x) { 955 852 $content = $this->edit_file_content; 956 853 957 $vars[lang_preview_of]=lang('Preview of %1', $this->path.'/'.$edit_file); 958 959 $vars[preview_content]=nl2br($content); 960 } 961 elseif($this->edit_save_x || $this->edit_save_done_x) 962 { 854 $vars[lang_preview_of] = lang('Preview of %1', $this->path . '/' . $edit_file); 855 856 $vars[preview_content] = nl2br($content); 857 } elseif ($this->edit_save_x || $this->edit_save_done_x) { 963 858 $content = $this->edit_file_content; 964 859 //die( $content); 965 if($this->bo->vfs->write(array( 966 'string' => $this->path.'/'.$this->edit_file, 967 'relatives' => array(RELATIVE_NONE), 968 'content' => $content 969 ))) 970 { 971 $this->messages[]=lang('Saved %1', $this->path.'/'.$this->edit_file); 972 973 if($this->edit_save_done_x) 974 { 860 if ($this->bo->vfs->write(array( 861 'string' => $this->path . '/' . $this->edit_file, 862 'relatives' => array(RELATIVE_NONE), 863 'content' => $content 864 ))) { 865 $this->messages[] = lang('Saved %1', $this->path . '/' . $this->edit_file); 866 867 if ($this->edit_save_done_x) { 975 868 $this->readFilesInfo(); 976 869 $this->fileListing(); 977 870 exit; 978 871 } 979 } 980 else 981 { 982 $this->messages[]=lang('Could not save %1', $this->path.'/'.$this->edit_file); 872 } else { 873 $this->messages[] = lang('Could not save %1', $this->path . '/' . $this->edit_file); 983 874 } 984 875 } … … 986 877 # If we're in preview or save mode, we only show the file 987 878 # being previewed or saved 988 if($this->edit_file &&($this->filename != $this->edit_file)) 989 { 879 if ($this->edit_file && ($this->filename != $this->edit_file)) { 990 880 continue; 991 881 } 992 882 993 if($this->filename && $this->bo->vfs->file_exists(array( 994 'string' => $this->filename, 995 'relatives' => array(RELATIVE_ALL) 996 ))) 997 { 998 if($this->edit_file) 999 { 883 if ($this->filename && $this->bo->vfs->file_exists(array( 884 'string' => $this->filename, 885 'relatives' => array(RELATIVE_ALL) 886 ))) { 887 if ($this->edit_file) { 1000 888 $content = stripslashes($this->edit_file_content); 1001 } 1002 else 1003 { 889 } else { 1004 890 $content = $this->bo->vfs->read(array('string' => $this->filename)); 1005 891 } 1006 $vars[form_action] = $GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path);1007 $vars[edit_file] =$this->filename;892 $vars[form_action] = $GLOBALS['phpgw']->link('/index.php', 'menuaction=filemanager.uifilemanager.index', 'path=' . $this->path); 893 $vars[edit_file] = $this->filename; 1008 894 # We need to include all of the fileman entries for each file's form, 1009 895 # so we loop through again 1010 for ($i = 0; $i != $this->numoffiles; $i++)1011 {1012 if($this->filename) $value='value="'.$this->filename.'"';1013 $vars[filemans_hidden] ='<input type="hidden" name="filename" '.$value.' />';1014 } 1015 $vars[file_content] =$content;1016 1017 $vars[buttonPreview] =$this->inputButton('edit_preview','edit_preview',lang('Preview %1', $this->bo->html_encode($this->fileman[0], 1)));1018 $vars[buttonSave] =$this->inputButton('edit_save','save',lang('Save %1', $this->bo->html_encode($this->filename, 1)));1019 $vars[buttonDone] =$this->inputButton('edit_save_done','ok',lang('Save %1, and go back to file listing ', $this->bo->html_encode($this->filename, 1)));1020 $vars[buttonCancel] =$this->inputButton('edit_cancel','cancel',lang('Cancel editing %1 without saving', $this->bo->html_encode($this->filename, 1)));1021 1022 if ($mime_type == 'text/html') {896 for ($i = 0; $i != $this->numoffiles; $i++) { 897 if ($this->filename) 898 $value = 'value="' . $this->filename . '"'; 899 $vars[filemans_hidden] = '<input type="hidden" name="filename" ' . $value . ' />'; 900 } 901 $vars[file_content] = $content; 902 903 $vars[buttonPreview] = $this->inputButton('edit_preview', 'edit_preview', lang('Preview %1', $this->bo->html_encode($this->fileman[0], 1))); 904 $vars[buttonSave] = $this->inputButton('edit_save', 'save', lang('Save %1', $this->bo->html_encode($this->filename, 1))); 905 $vars[buttonDone] = $this->inputButton('edit_save_done', 'ok', lang('Save %1, and go back to file listing ', $this->bo->html_encode($this->filename, 1))); 906 $vars[buttonCancel] = $this->inputButton('edit_cancel', 'cancel', lang('Cancel editing %1 without saving', $this->bo->html_encode($this->filename, 1))); 907 908 if ($mime_type == 'text/html') { 1023 909 $vars[fck_edit] = '<script type="text/javascript" src="filemanager/tp/ckeditor/ckeditor.js"></script> 1024 <textarea cols="80" id="edit_file_content" name="edit_file_content" rows="10">' .$content.'</textarea>910 <textarea cols="80" id="edit_file_content" name="edit_file_content" rows="10">' . $content . '</textarea> 1025 911 <script type="text/javascript"> CKEDITOR.replace( \'edit_file_content\',{ 1026 912 removePlugins : \'elementspath\', … … 1035 921 ["Styles","Format","Font","FontSize"]] 1036 922 });</script>'; 1037 1038 923 } 1039 924 1040 925 1041 926 $this->t->set_var($vars); 1042 $this->t->parse('rows','row'); 1043 $this->t->pparse('out','row'); 1044 1045 } 1046 1047 } 1048 1049 function history() 1050 { 1051 if($this->file) // FIXME this-file is never defined 1052 { 927 $this->t->parse('rows', 'row'); 928 $this->t->pparse('out', 'row'); 929 } 930 } 931 932 function history() { 933 if ($this->file) { // FIXME this-file is never defined 1053 934 $journal_array = $this->bo->vfs->get_journal(array( 1054 'string' => $this->file,//FIXME 1055 'relatives' => array(RELATIVE_ALL) 1056 )); 1057 1058 if(is_array($journal_array)) 1059 { 935 'string' => $this->file, //FIXME 936 'relatives' => array(RELATIVE_ALL) 937 )); 938 939 if (is_array($journal_array)) { 1060 940 $this->html_table_begin(); 1061 941 $this->html_table_row_begin(); … … 1074 954 $this->html_table_row_end(); 1075 955 1076 while(list($num, $journal_entry) = each($journal_array)) 1077 { 956 while (list($num, $journal_entry) = each($journal_array)) { 1078 957 $this->html_table_row_begin(); 1079 958 $this->html_table_col_begin(); … … 1081 960 $this->html_table_col_end(); 1082 961 $this->html_table_col_begin(); 1083 $this->bo->html_text($journal_entry['version'] . ' ' 962 $this->bo->html_text($journal_entry['version'] . ' '); 1084 963 $this->html_table_col_end(); 1085 964 $this->html_table_col_begin(); … … 1094 973 $GLOBALS['phpgw']->common->phpgw_footer(); 1095 974 $GLOBALS['phpgw']->common->phpgw_exit(); 1096 } 1097 else 1098 { 975 } else { 1099 976 echo lang('No version history for this file/directory'); 1100 977 } 1101 978 } 1102 979 } 1103 function view() 1104 {980 981 function view() { 1105 982 if (!$this->bo->vfs->acl_check(array( 1106 'string' => $this->path, 1107 'relatives' => array(RELATIVE_NONE), 1108 'operation' => PHPGW_ACL_READ 1109 ))) 1110 { 983 'string' => $this->path, 984 'relatives' => array(RELATIVE_NONE), 985 'operation' => PHPGW_ACL_READ 986 ))) { 1111 987 $this->messages[] = lang("You have no permission to access this file"); 1112 header('Location:' .$this->encode_href('inc/index.php?menuaction=filemanager.uifilemanager.index','&path='.base64_encode($this->bo->homedir)));988 header('Location:' . $this->encode_href('inc/index.php?menuaction=filemanager.uifilemanager.index', '&path=' . base64_encode($this->bo->homedir))); 1113 989 1114 990 return; 1115 991 } 1116 if($this->file) //FIXME 1117 { 992 if ($this->file) { //FIXME 1118 993 $ls_array = $this->bo->vfs->ls(array( 1119 'string' => $this->path.'/'.$this->file,//FIXME 1120 'relatives' => array(RELATIVE_NONE), 1121 'checksubdirs' => False, 1122 'nofiles' => True 1123 )); 1124 if($ls_array[0]['mime_type']) 1125 { 994 'string' => $this->path . '/' . $this->file, //FIXME 995 'relatives' => array(RELATIVE_NONE), 996 'checksubdirs' => False, 997 'nofiles' => True 998 )); 999 if ($ls_array[0]['mime_type']) { 1126 1000 $mime_type = $ls_array[0]['mime_type']; 1127 } 1128 elseif($this->prefs['viewtextplain']) 1129 { 1001 } elseif ($this->prefs['viewtextplain']) { 1130 1002 $mime_type = 'text/plain'; 1131 1003 } 1132 $viewable = array('text/plain','text/csv','text/html', 1133 'text/text','image/jpeg','image/png','image/gif', 1134 'audio/mpeg','video/mpeg'); 1135 1136 if(in_array($mime_type,$viewable)) 1137 { 1138 /*Note: if you put application/octet-stream you force download */ 1004 $viewable = array('text/plain', 'text/csv', 'text/html', 1005 'text/text', 'image/jpeg', 'image/png', 'image/gif', 1006 'audio/mpeg', 'video/mpeg'); 1007 1008 if (in_array($mime_type, $viewable)) { 1009 /* Note: if you put application/octet-stream you force download */ 1139 1010 header('Content-type: ' . $mime_type); 1140 1011 header('Content-disposition: filename="' . addslashes($this->file) . '"'); 1141 1012 Header("Pragma: public"); 1142 } 1143 else 1144 { 1145 $GLOBALS['phpgw']->browser->content_header($this->file,$mime_type,$ls_array[0]['size']); 1146 } 1147 if ($ls_array[0]['size'] < 10240) 1148 { 1013 } else { 1014 $GLOBALS['phpgw']->browser->content_header($this->file, $mime_type, $ls_array[0]['size']); 1015 } 1016 if ($ls_array[0]['size'] < 10240) { 1149 1017 echo $this->bo->vfs->read(array( 1150 'string' => $this->path.'/'.$this->file,//FIXME1151 'relatives'=> array(RELATIVE_NONE)1018 'string' => $this->path . '/' . $this->file, //FIXME 1019 'relatives' => array(RELATIVE_NONE) 1152 1020 )); 1153 } 1154 else 1155 { 1021 } else { 1156 1022 $this->bo->vfs->print_content(array( 1157 'string' => $this->path.'/'.$this->file,1158 'relatives' => array(RELATIVE_NONE)1159 )1160 );1023 'string' => $this->path . '/' . $this->file, 1024 'relatives' => array(RELATIVE_NONE) 1025 ) 1026 ); 1161 1027 } 1162 1028 $GLOBALS['phpgw']->common->phpgw_exit(); … … 1164 1030 } 1165 1031 1166 function export(){ 1167 if($this->file) 1168 { 1032 function export() { 1033 if ($this->file) { 1169 1034 $ls_array = $this->bo->vfs->ls(array( 1170 'string' => $this->path.'/'.$this->file,1171 'relatives'=> array(RELATIVE_NONE),1172 'checksubdirs'=> False,1173 'nofiles'=> True1174 ));1175 /* $timestamp = $this->vfs_functions->dateString2timeStamp($ls_array[0]['modified']);1176 if (time() - $timestamp < 60 && $ls_array[0]['modifiedby_id'] != $GLOBALS['phpgw_info']['user']['account_id']);1177 {1178 1179 }*/1035 'string' => $this->path . '/' . $this->file, 1036 'relatives' => array(RELATIVE_NONE), 1037 'checksubdirs' => False, 1038 'nofiles' => True 1039 )); 1040 /* $timestamp = $this->vfs_functions->dateString2timeStamp($ls_array[0]['modified']); 1041 if (time() - $timestamp < 60 && $ls_array[0]['modifiedby_id'] != $GLOBALS['phpgw_info']['user']['account_id']); 1042 { 1043 // recently than last minute: someone is editing 1044 } */ 1180 1045 $mime_type = $ls_array[0]['mime_type']; 1181 1046 $formats = array('text/html'); 1182 if (!in_array($mime_type,$formats)){1047 if (!in_array($mime_type, $formats)) { 1183 1048 echo lang('Impossible to export this file'); 1184 1049 return False; 1185 1050 } 1186 $content = $this->bo->vfs->read(array('string' => $this->path .'/'.$this->file,1187 'relatives'=> array(RELATIVE_NONE)1188 1051 $content = $this->bo->vfs->read(array('string' => $this->path . '/' . $this->file, 1052 'relatives' => array(RELATIVE_NONE) 1053 )); 1189 1054 1190 1055 include_once('filemanager/tp/dompdf/dompdf_config.inc.php'); … … 1192 1057 $dompdf->load_html($content); 1193 1058 $dompdf->set_paper($this->prefs['pdf_paper_type'], $this->prefs['pdf_type']); 1194 /* Would be nice to implement 'Title','Subject','Author','Creator','CreationDate' */1059 /* Would be nice to implement 'Title','Subject','Author','Creator','CreationDate' */ 1195 1060 $dompdf->render(); 1196 $dompdf->stream(strtok($this->file, '.').".pdf");1061 $dompdf->stream(strtok($this->file, '.') . ".pdf"); 1197 1062 $GLOBALS['phpgw']->common->phpgw_exit(); 1198 1063 } … … 1200 1065 1201 1066 //give back an array with all directories except current and dirs that are not accessable 1202 function all_other_directories() 1203 { 1067 function all_other_directories() { 1204 1068 # First we get the directories in their home directory 1205 1069 $dirs = array(); 1206 1070 $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $this->bo->userinfo['account_lid']); 1207 1071 1208 $tmp_arr =array(1209 'string'=> $this->bo->homedir,1210 'relatives'=> array(RELATIVE_NONE),1211 'checksubdirs'=> True,1212 'mime_type'=> 'Directory'1072 $tmp_arr = array( 1073 'string' => $this->bo->homedir, 1074 'relatives' => array(RELATIVE_NONE), 1075 'checksubdirs' => True, 1076 'mime_type' => 'Directory' 1213 1077 ); 1214 1078 1215 $ls_array = $this->bo->vfs->ls($tmp_arr,True); 1216 1217 while(list($num, $dir) = each($ls_array)) 1218 { 1079 $ls_array = $this->bo->vfs->ls($tmp_arr, True); 1080 1081 while (list($num, $dir) = each($ls_array)) { 1219 1082 $dirs[] = $dir; 1220 1083 } … … 1223 1086 # Then we get the directories in their readable groups' home directories 1224 1087 reset($this->readable_groups); 1225 while(list($num, $group_array) = each($this->readable_groups)) 1226 { 1088 while (list($num, $group_array) = each($this->readable_groups)) { 1227 1089 // Don't list directories for groups that don't exists 1228 $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'], 1229 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 1230 if($test[mime_type]!='Directory') 1231 { 1090 $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->fakebase . '/' . $group_array['account_name'], 1091 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 1092 if ($test[mime_type] != 'Directory') { 1232 1093 continue; 1233 1094 } … … 1235 1096 $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $group_array['account_name']); 1236 1097 1237 $tmp_arr =array(1238 'string' => $this->bo->fakebase.'/'.$group_array['account_name'],1239 'relatives'=> array(RELATIVE_NONE),1240 'checksubdirs'=> True,1241 'mime_type'=> 'Directory'1098 $tmp_arr = array( 1099 'string' => $this->bo->fakebase . '/' . $group_array['account_name'], 1100 'relatives' => array(RELATIVE_NONE), 1101 'checksubdirs' => True, 1102 'mime_type' => 'Directory' 1242 1103 ); 1243 1104 1244 $ls_array = $this->bo->vfs->ls($tmp_arr,True); 1245 while(list($num, $dir) = each($ls_array)) 1246 { 1105 $ls_array = $this->bo->vfs->ls($tmp_arr, True); 1106 while (list($num, $dir) = each($ls_array)) { 1247 1107 $dirs[] = $dir; 1248 1108 } 1249 1109 } 1250 1110 reset($dirs); 1251 while(list($num, $dir) = each($dirs)) 1252 { 1253 if(!$dir['directory']) 1254 { 1111 while (list($num, $dir) = each($dirs)) { 1112 if (!$dir['directory']) { 1255 1113 continue; 1256 1114 } 1257 1115 1258 1116 # So we don't display // 1259 if($dir['directory'] != '/') 1260 { 1117 if ($dir['directory'] != '/') { 1261 1118 $dir['directory'] .= '/'; 1262 1119 } … … 1266 1123 } 1267 1124 1268 function update_groups() 1269 { 1125 function update_groups() { 1270 1126 # Get their readable groups to be used throughout the script 1271 1127 $acl = array(); 1272 1128 $groups = array(); 1273 $acl = $GLOBALS['phpgw']->acl->get_ids_for_location($GLOBALS['phpgw_info']['user']['account_id'], 1,'filemanager');1129 $acl = $GLOBALS['phpgw']->acl->get_ids_for_location($GLOBALS['phpgw_info']['user']['account_id'], 1, 'filemanager'); 1274 1130 if (is_array($acl)) 1275 foreach ($acl as $key => $value){1131 foreach ($acl as $key => $value) { 1276 1132 $info = array(); 1277 1133 $info = $GLOBALS['phpgw']->accounts->get_account_data($value); … … 1283 1139 } 1284 1140 $this->readable_groups = array(); 1285 while(list($num, $account) = each($groups)) 1286 { 1287 if($this->bo->vfs->acl_check(array('owner_id' => $account['account_id'],'operation' => PHPGW_ACL_READ))) 1288 { 1141 while (list($num, $account) = each($groups)) { 1142 if ($this->bo->vfs->acl_check(array('owner_id' => $account['account_id'], 'operation' => PHPGW_ACL_READ))) { 1289 1143 $this->readable_groups[$account['account_lid']] = Array('account_id' => $account['account_id'], 'account_name' => $account['account_lid']); 1290 1144 } 1291 1145 } 1292 1293 } 1294 function search() 1295 { 1146 } 1147 1148 function search() { 1296 1149 /* TODO this is a primitive search */ 1297 1150 $this->update_groups(); 1298 1151 $this->dirs = $this->all_other_directories(); 1299 1152 $path = $this->path; 1300 if (strlen($this->text) > 3) 1301 { 1153 if (strlen($this->text) > 3) { 1302 1154 $this->text = strtoupper($this->text); 1303 foreach($this->dirs as $elem) 1304 { 1305 $this->path = $elem['directory'].$elem['name']; 1155 foreach ($this->dirs as $elem) { 1156 $this->path = $elem['directory'] . $elem['name']; 1306 1157 reset($this->files_array); 1307 $this->readFilesInfo(); 1308 for($i = 0; $i < count($this->files_array); $i++) 1309 { 1158 $this->readFilesInfo(); 1159 for ($i = 0; $i < count($this->files_array); $i++) { 1310 1160 $comment = strtoupper($this->files_array[$i]['comment']); 1311 1161 $name = strtoupper($this->files_array[$i]['name']); 1312 if (strstr($name, $this->text) ||1313 strstr($comment,$this->text) ){1314 $return[$this->files_array[$i]['directory'] .$name] = $this->files_array[$i];1315 $return[$this->files_array[$i]['directory'] .$name]['icon'] = $this->mime_icon($this->files_array[$i]['mime_type']);1162 if (strstr($name, $this->text) || 1163 strstr($comment, $this->text)) { 1164 $return[$this->files_array[$i]['directory'] . $name] = $this->files_array[$i]; 1165 $return[$this->files_array[$i]['directory'] . $name]['icon'] = $this->mime_icon($this->files_array[$i]['mime_type']); 1316 1166 } 1317 1167 } 1318 if (count($return) > 50) 1319 { 1320 $return = array_slice($return,0,50); 1168 if (count($return) > 50) { 1169 $return = array_slice($return, 0, 50); 1321 1170 break; 1322 1171 } 1323 } 1172 } 1324 1173 } 1325 1174 echo serialize(array_values($return)); … … 1327 1176 1328 1177 /* seek icon for mimetype else return an unknown icon */ 1329 function mime_icon($mime_type, $size=16) 1330 { 1331 if(!$mime_type) $mime_type='unknown'; 1332 1333 $mime_type=str_replace ('/','_',$mime_type); 1334 1335 $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_'.strtolower($mime_type)); 1336 if(!$img) $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_unknown'); 1178 1179 function mime_icon($mime_type, $size=16) { 1180 if (!$mime_type) 1181 $mime_type = 'unknown'; 1182 1183 $mime_type = str_replace('/', '_', $mime_type); 1184 1185 $img = $GLOBALS['phpgw']->common->image('filemanager', 'mime' . $size . '_' . strtolower($mime_type)); 1186 if (!$img) 1187 $img = $GLOBALS['phpgw']->common->image('filemanager', 'mime' . $size . '_unknown'); 1337 1188 1338 1189 return $img; 1339 1190 } 1340 1191 1341 function toolButton($link,$img='',$description='') 1342 { 1343 $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img)); 1344 1345 if($img) 1346 { 1347 return '<div name="'.$link.'" class="toolButton" onclick="toolbar.control(\''.$link.'\',this);" title="'.$description.'"><img src="'.$image.'" alt="'.$description.'"/><small>'.$description.'</small></div>'; 1348 } 1349 } 1350 1351 function inputButton($name,$img='',$description='') 1352 { 1353 $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img)); 1354 1355 if($img) 1356 { 1192 function toolButton($link, $img='', $description='') { 1193 $image = $GLOBALS['phpgw']->common->image('filemanager', 'button_' . strtolower($img)); 1194 1195 if ($img) { 1196 return '<div name="' . $link . '" class="toolButton" onclick="toolbar.control(\'' . $link . '\',this);" title="' . $description . '"><img src="' . $image . '" alt="' . $description . '"/><small>' . $description . '</small></div>'; 1197 } 1198 } 1199 1200 function inputButton($name, $img='', $description='') { 1201 $image = $GLOBALS['phpgw']->common->image('filemanager', 'button_' . strtolower($img)); 1202 1203 if ($img) { 1357 1204 return '<td class="" align="center" valign="middle" height="28" width="70"> 1358 <input title="' .$description.'" name="'.$name.'" type="image" alt="'.$name.'" src="'.$image.'" value="clicked" /><br><small>'.$description.'</small>1205 <input title="' . $description . '" name="' . $name . '" type="image" alt="' . $name . '" src="' . $image . '" value="clicked" /><br><small>' . $description . '</small> 1359 1206 </td>'; 1360 1207 } 1361 1208 } 1362 1209 1363 1364 function html_form_input($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = '', $return = 1) 1365 { 1210 function html_form_input($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = '', $return = 1) { 1366 1211 $text = ' '; 1367 if($type != NULL && $type) 1368 { 1369 if($type == 'checkbox') 1370 { 1212 if ($type != NULL && $type) { 1213 if ($type == 'checkbox') { 1371 1214 $value = $this->bo->string_encode($value, 1); 1372 1215 } 1373 $text .= 'type="'.$type.'" '; 1374 } 1375 if($name != NULL && $name) 1376 { 1377 $text .= 'name="'.$name.'" '; 1378 } 1379 if($value != NULL && $value) 1380 { 1381 $text .= 'value="'.$value.'" '; 1382 } 1383 if(is_int($maxlength) && $maxlength >= 0) 1384 { 1385 $text .= 'maxlength="'.$maxlength.'" '; 1386 } 1387 if(is_int($size) && $size >= 0) 1388 { 1389 $text .= 'size="'.$size.'" '; 1390 } 1391 if($checked != NULL && $checked) 1392 { 1216 $text .= 'type="' . $type . '" '; 1217 } 1218 if ($name != NULL && $name) { 1219 $text .= 'name="' . $name . '" '; 1220 } 1221 if ($value != NULL && $value) { 1222 $text .= 'value="' . $value . '" '; 1223 } 1224 if (is_int($maxlength) && $maxlength >= 0) { 1225 $text .= 'maxlength="' . $maxlength . '" '; 1226 } 1227 if (is_int($size) && $size >= 0) { 1228 $text .= 'size="' . $size . '" '; 1229 } 1230 if ($checked != NULL && $checked) { 1393 1231 $text .= 'checked '; 1394 1232 } 1395 1233 1396 return '<input'.$text.$string.'>'; 1397 } 1398 1399 function html_form_option($value = NULL, $displayed = NULL, $selected = NULL, $return = 0) 1400 { 1234 return '<input' . $text . $string . '>'; 1235 } 1236 1237 function html_form_option($value = NULL, $displayed = NULL, $selected = NULL, $return = 0) { 1401 1238 $text = ' '; 1402 if($value != NULL && $value) 1403 { 1404 $text .= ' value="'.$value.'" '; 1405 } 1406 if($selected != NULL && $selected) 1407 { 1239 if ($value != NULL && $value) { 1240 $text .= ' value="' . $value . '" '; 1241 } 1242 if ($selected != NULL && $selected) { 1408 1243 $text .= ' selected'; 1409 1244 } 1410 return '<option'.$text.'>'.$displayed.'</option>'; 1411 } 1412 1413 function encode_href($href = NULL, $args = NULL , $extra_args) 1414 { 1245 return '<option' . $text . '>' . $displayed . '</option>'; 1246 } 1247 1248 function encode_href($href = NULL, $args = NULL, $extra_args) { 1415 1249 $href = $this->bo->string_encode($href, 1); 1416 $all_args = $args .'&'.$this->bo->string_encode($extra_args, 1);1250 $all_args = $args . '&' . $this->bo->string_encode($extra_args, 1); 1417 1251 1418 1252 $address = $GLOBALS['phpgw']->link($href, $all_args); … … 1421 1255 } 1422 1256 1423 function html_link($href = NULL, $args = NULL , $extra_args, $text = NULL, $return = 1, $encode = 1, $linkonly = 0, $target = NULL) 1424 { 1257 function html_link($href = NULL, $args = NULL, $extra_args, $text = NULL, $return = 1, $encode = 1, $linkonly = 0, $target = NULL) { 1425 1258 // unset($encode); 1426 if($encode) 1427 { 1259 if ($encode) { 1428 1260 $href = $this->bo->string_encode($href, 1); 1429 $all_args = $args.'&'.$this->bo->string_encode($extra_args, 1); 1430 } 1431 else 1432 { 1261 $all_args = $args . '&' . $this->bo->string_encode($extra_args, 1); 1262 } else { 1433 1263 // $href = $this->bo->string_encode($href, 1); 1434 $all_args = $args .'&'.$extra_args;1264 $all_args = $args . '&' . $extra_args; 1435 1265 } 1436 1266 ### … … 1441 1271 1442 1272 /* Auto-detect and don't disturb absolute links */ 1443 if(!preg_match("|^http(.{0,1})://|", $href)) 1444 { 1273 if (!preg_match("|^http(.{0,1})://|", $href)) { 1445 1274 //Only add an extra / if there isn't already one there 1446 1447 1275 // die(SEP); 1448 if(!($href[0] == SEP)) 1449 { 1276 if (!($href[0] == SEP)) { 1450 1277 $href = SEP . $href; 1451 1278 } … … 1455 1282 $address = $GLOBALS['phpgw']->link($href, $all_args); 1456 1283 // $address = $GLOBALS['phpgw']->link($href); 1457 } 1458 else 1459 { 1284 } else { 1460 1285 $address = $href; 1461 1286 } 1462 1287 1463 1288 /* If $linkonly is set, don't add any HTML */ 1464 if($linkonly) 1465 { 1289 if ($linkonly) { 1466 1290 $rstring = $address; 1467 } 1468 else 1469 { 1470 if($target) 1471 { 1472 $target = 'target='.$target; 1291 } else { 1292 if ($target) { 1293 $target = 'target=' . $target; 1473 1294 } 1474 1295 1475 1296 $text = trim($text); 1476 $rstring = '<a href="' .$address.'" '.$target.'>'.$text.'</a>';1297 $rstring = '<a href="' . $address . '" ' . $target . '>' . $text . '</a>'; 1477 1298 } 1478 1299 … … 1480 1301 } 1481 1302 1482 function html_table_begin($width = NULL, $border = NULL, $cellspacing = NULL, $cellpadding = NULL, $rules = NULL, $string = '', $return = 0) 1483 { 1484 if($width != NULL && $width) 1485 { 1303 function html_table_begin($width = NULL, $border = NULL, $cellspacing = NULL, $cellpadding = NULL, $rules = NULL, $string = '', $return = 0) { 1304 if ($width != NULL && $width) { 1486 1305 $width = "width=$width"; 1487 1306 } 1488 if(is_int($border) && $border >= 0) 1489 { 1307 if (is_int($border) && $border >= 0) { 1490 1308 $border = "border=$border"; 1491 1309 } 1492 if(is_int($cellspacing) && $cellspacing >= 0) 1493 { 1310 if (is_int($cellspacing) && $cellspacing >= 0) { 1494 1311 $cellspacing = "cellspacing=$cellspacing"; 1495 1312 } 1496 if(is_int($cellpadding) && $cellpadding >= 0) 1497 { 1313 if (is_int($cellpadding) && $cellpadding >= 0) { 1498 1314 $cellpadding = "cellpadding=$cellpadding"; 1499 1315 } 1500 if($rules != NULL && $rules) 1501 { 1316 if ($rules != NULL && $rules) { 1502 1317 $rules = "rules=$rules"; 1503 1318 } … … 1507 1322 } 1508 1323 1509 function html_table_end($return = 0) 1510 { 1324 function html_table_end($return = 0) { 1511 1325 $rstring = "</table>"; 1512 1326 return($this->bo->eor($rstring, $return)); 1513 1327 } 1514 1328 1515 function html_table_row_begin($align = NULL, $halign = NULL, $valign = NULL, $bgcolor = NULL, $string = '', $return = 0) 1516 { 1517 if($align != NULL && $align) 1518 { 1329 function html_table_row_begin($align = NULL, $halign = NULL, $valign = NULL, $bgcolor = NULL, $string = '', $return = 0) { 1330 if ($align != NULL && $align) { 1519 1331 $align = "align=$align"; 1520 1332 } 1521 if($halign != NULL && $halign) 1522 { 1333 if ($halign != NULL && $halign) { 1523 1334 $halign = "halign=$halign"; 1524 1335 } 1525 if($valign != NULL && $valign) 1526 { 1336 if ($valign != NULL && $valign) { 1527 1337 $valign = "valign=$valign"; 1528 1338 } 1529 if($bgcolor != NULL && $bgcolor) 1530 { 1339 if ($bgcolor != NULL && $bgcolor) { 1531 1340 $bgcolor = "bgcolor=$bgcolor"; 1532 1341 } … … 1535 1344 } 1536 1345 1537 function html_table_row_end($return = 0) 1538 { 1346 function html_table_row_end($return = 0) { 1539 1347 $rstring = "</tr>"; 1540 1348 return($this->bo->eor($rstring, $return)); 1541 1349 } 1542 1350 1543 function html_table_col_begin($align = NULL, $halign = NULL, $valign = NULL, $rowspan = NULL, $colspan = NULL, $string = '', $return = 0) 1544 { 1545 if($align != NULL && $align) 1546 { 1351 function html_table_col_begin($align = NULL, $halign = NULL, $valign = NULL, $rowspan = NULL, $colspan = NULL, $string = '', $return = 0) { 1352 if ($align != NULL && $align) { 1547 1353 $align = "align=$align"; 1548 1354 } 1549 if($halign != NULL && $halign) 1550 { 1355 if ($halign != NULL && $halign) { 1551 1356 $halign = "halign=$halign"; 1552 1357 } 1553 if($valign != NULL && $valign) 1554 { 1358 if ($valign != NULL && $valign) { 1555 1359 $valign = "valign=$valign"; 1556 1360 } 1557 if(is_int($rowspan) && $rowspan >= 0) 1558 { 1361 if (is_int($rowspan) && $rowspan >= 0) { 1559 1362 $rowspan = "rowspan=$rowspan"; 1560 1363 } 1561 if(is_int($colspan) && $colspan >= 0) 1562 { 1364 if (is_int($colspan) && $colspan >= 0) { 1563 1365 $colspan = "colspan=$colspan"; 1564 1366 } … … 1568 1370 } 1569 1371 1570 function html_table_col_end($return = 0) 1571 { 1372 function html_table_col_end($return = 0) { 1572 1373 $rstring = "</td>"; 1573 1374 return($this->bo->eor($rstring, $return)); 1574 1375 } 1376 1575 1377 } -
branches/2.2/filemanager/inc/upload.php
r3610 r3879 14 14 15 15 $bo = CreateObject('filemanager.bofilemanager'); 16 17 $c = CreateObject('phpgwapi.config','filemanager'); 16 $c = CreateObject('phpgwapi.config','filemanager'); 18 17 $c->read_repository(); 19 $current_config = $c->config_data; 20 $upload_max_size = $current_config['filemanager_Max_file_size']; 21 $path = $_POST['path']; 22 $notifUser = $_POST['notifTo']; 23 $show_upload_boxes = count($_FILES['upload_file']['name']); 24 $filesUpload = $_FILES['upload_file']; 18 19 $current_config = $c->config_data; 20 $upload_max_size = $current_config['filemanager_Max_file_size']; 21 $path = $_POST['path']; 22 $notifUser = $_POST['notifTo']; 23 $show_upload_boxes = count($_FILES['upload_file']['name']); 24 $filesUpload = $_FILES['upload_file']; 25 26 27 error_log( print_r($_FILES['upload_file'], true), 3, "/tmp/log" ); 25 28 26 29 function create_summaryImage($file) … … 84 87 } 85 88 86 if($path != '/') 87 { 88 for($i = 0; $i != $show_upload_boxes; $i++) 89 { 90 if($badchar = $bo->bad_chars($_FILES['upload_file']['name'][$i], True, True)) 91 { 92 $return[] = lang('Error:').lang('File names cannot contain "%1"', $badchar); 89 if( $path != '/' ) 90 { 91 for( $i = 0; $i != $show_upload_boxes; $i++) 92 { 93 if ( $_FILES['upload_file']['size'][$i] > ($upload_max_size*1024*1024) ) 94 { 95 $return[] = array( 96 "file" => $_FILES['upload_file']['name'][$i] , 97 "size" => $_FILES['upload_file']['size'][$i] , 98 "size_max" => ($upload_max_size*1024*1024) 99 ); 93 100 continue; 94 101 } 95 96 # Check to see if the file exists in the database, and get its info at the same time 97 $ls_array = $bo->vfs->ls(array( 98 'string'=> $path . '/' . $_FILES['upload_file']['name'][$i], 99 'relatives' => array(RELATIVE_NONE), 100 'checksubdirs' => False, 101 'nofiles' => True 102 )); 103 104 $fileinfo = $ls_array[0]; 105 106 if($fileinfo['name']) 107 { 108 if($fileinfo['mime_type'] == 'Directory') 109 { 110 $return[] = lang('Error:').lang('Cannot replace %1 because it is a directory', $fileinfo['name']); 102 elseif( $_FILES['upload_file']['size'][$i] > 0 ) 103 { 104 if( $badchar = $bo->bad_chars($_FILES['upload_file']['name'][$i], True, True )) 105 { 106 $return[] = array( 107 "file" => $_FILES['upload_file']['name'][$i], 108 "badchar" => lang('File names cannot contain "%1"', $badchar) 109 ); 111 110 continue; 112 111 } 113 } 114 115 if ($_FILES['upload_file']['size'][$i] > ($upload_max_size*1024*1024)) 116 { 117 $return[] = lang('The size of %1 has exceded the limit: %2', $_FILES['upload_file']['name'][$i], $upload_max_size); 118 continue; 119 } 120 elseif($_FILES['upload_file']['size'][$i] > 0) 121 { 112 113 # Check to see if the file exists in the database, and get its info at the same time 114 $ls_array = $bo->vfs->ls(array( 115 'string'=> $path . '/' . $_FILES['upload_file']['name'][$i], 116 'relatives' => array(RELATIVE_NONE), 117 'checksubdirs' => False, 118 'nofiles' => True 119 )); 120 121 $fileinfo = $ls_array[0]; 122 123 if( $fileinfo['name'] ) 124 { 125 if( $fileinfo['mime_type'] == 'Directory' ) 126 { 127 $return[] = array( 128 "file" => $_FILES['upload_file']['name'][$i], 129 "directory" => lang('Cannot replace %1 because it is a directory', $fileinfo['name'] ) 130 ); 131 continue; 132 } 133 } 134 122 135 if($fileinfo['name'] && $fileinfo['deleteable'] != 'N') 123 136 { … … 131 144 $bo->vfs->cp($tmp_arr); 132 145 $tmp_arr=array( 133 'string'=> $_FILES['upload_file']['name'][$i],134 'relatives' => array(RELATIVE_ALL),135 'attributes' => array(136 'owner_id' => $bo->userinfo['username'],137 'modifiedby_id' => $bo->userinfo['username'],138 'size' => $_FILES['upload_file']['size'][$i],139 'mime_type' => $_FILES['upload_file']['type'][$i],140 'deleteable' => 'Y',141 'comment' => stripslashes($_POST['upload_comment'][$i])146 'string'=> $_FILES['upload_file']['name'][$i], 147 'relatives' => array(RELATIVE_ALL), 148 'attributes' => array( 149 'owner_id' => $bo->userinfo['username'], 150 'modifiedby_id' => $bo->userinfo['username'], 151 'size' => $_FILES['upload_file']['size'][$i], 152 'mime_type' => $_FILES['upload_file']['type'][$i], 153 'deleteable' => 'Y', 154 'comment' => stripslashes($_POST['upload_comment'][$i]) 142 155 ) 143 156 ); 144 157 $bo->vfs->set_attributes($tmp_arr); 145 158 146 $return[] = lang("There is a file %1, that was not replaced",$_FILES['upload_file']['name'][$i]); 159 $return[] = array( 160 "file" => $_FILES['upload_file']['name'][$i], 161 "undefined" => lang( "There is a file %1, that was not replaced", $_FILES['upload_file']['name'][$i] ) 162 ); 147 163 } 148 164 else … … 155 171 { 156 172 $bo->vfs->set_attributes(array( 157 'string'=> $_FILES['upload_file']['name'][$i],158 'relatives' => array(RELATIVE_ALL),159 'attributes'=> array(160 'mime_type'=> $_FILES['upload_file']['type'][$i],161 'comment'=> stripslashes($_POST['upload_comment'][$i])162 )173 'string' => $_FILES['upload_file']['name'][$i], 174 'relatives' => array(RELATIVE_ALL), 175 'attributes' => array( 176 'mime_type' => $_FILES['upload_file']['type'][$i], 177 'comment' => stripslashes($_POST['upload_comment'][$i]) 178 ) 163 179 )); 164 180 } 165 else{ 166 $return[] = lang('Error:').lang('It was not possible to send your file'); 181 else 182 { 183 $return[] = array ( 184 "file" => $_FILES['upload_file']['name'][$i], 185 "sendFile" => lang('It was not possible to send your file') 186 ); 167 187 } 168 169 } 170 } 171 elseif($_FILES['upload_file']['name'][$i]) 188 } 189 } 190 elseif( $_FILES['upload_file']['name'][$i] ) 172 191 { 173 192 $bo->vfs->touch(array( … … 177 196 178 197 $bo->vfs->set_attributes(array( 179 'string'=> $_FILES['upload_file']['name'][$i],180 'relatives' => array(RELATIVE_ALL),181 'attributes'=> array(182 'mime_type'=> $_FILES['upload_file']['type'][$i],183 'comment'=> stripslashes($_POST['upload_comment'][$i])184 )198 'string' => $_FILES['upload_file']['name'][$i], 199 'relatives' => array(RELATIVE_ALL), 200 'attributes' => array( 201 'mime_type' => $_FILES['upload_file']['type'][$i], 202 'comment' => stripslashes($_POST['upload_comment'][$i]) 203 ) 185 204 )); 186 187 } 188 189 if (!(strpos(strtoupper($_FILES['upload_file']['type'][$i]),'IMAGE') === FALSE)) 205 } 206 207 if ( !(strpos(strtoupper($_FILES['upload_file']['type'][$i]),'IMAGE') === FALSE ) ) 190 208 { 191 209 $content = create_summaryImage($_FILES['upload_file']['tmp_name'][$i]); 192 if ($content){ 210 if ($content) 211 { 193 212 $bo->vfs->set_summary(array( 194 213 'string'=> $_FILES['upload_file']['name'][$i], -
branches/2.2/filemanager/js/common_functions.js
r3679 r3879 98 98 99 99 var pArgs = unserialize(data); 100 pArgs.lang_add_file = get_lang("Add file");101 100 pArgs.lang_click_here = get_lang("Click here"); 102 101 pArgs.lang_more_files = get_lang("More files"); … … 104 103 pArgs.height = 210; 105 104 pArgs.path_filemanager = path_filemanager; 106 pArgs.width = 450;105 pArgs.width = 500; 107 106 108 107 var _html = Xtools.parse( Xtools.xml("upload_files"), "upload.xsl", pArgs ); … … 233 232 234 233 235 function setRestricted(name){ 234 function setRestricted(name) 235 { 236 236 var continue_set = confirm(get_lang('This property will change the visibility of all users that have access to this file, continue?')); 237 if (continue_set) 238 cExecute_('./index.php?menuaction=filemanager.vfs_functions.setRestricted&file='+base64_encode(name)+'&path='+base64_encode(currentPath),handler.restricted); 239 } 240 241 function presetComments(el){ 237 238 if ( continue_set ) 239 { 240 cExecute_('./index.php?menuaction=filemanager.vfs_functions.setRestricted&file=' 241 + base64_encode(name)+'&path='+base64_encode(currentPath),handler.restricted); 242 } 243 } 244 245 function presetComments(el) 246 { 242 247 if (permissions['edit'] == 0){ 243 248 el.blur(); … … 247 252 } 248 253 249 function setComments(el){ 250 if (el.value == oldValue) return; 254 function setComments(el) 255 { 256 if ( el.value == oldValue ) 257 return; 258 251 259 var filename = base64_encode(el.id); 252 cExecute_('./index.php?menuaction=filemanager.vfs_functions.editComment&file='+filename+'&comment='+base64_encode(el.value),handler.updateComment); 260 261 cExecute_('./index.php?menuaction=filemanager.vfs_functions.editComment&file=' 262 + filename+'&comment='+base64_encode(el.value), handler.updateComment); 253 263 } 254 264 … … 320 330 width : 250, 321 331 height : 290, 322 top : 100,323 left : 400,332 top : 100, 333 left : 400, 324 334 draggable : true, 325 visible : "display",335 visible : "display", 326 336 resizable : true, 327 337 zindex : zIndex++, 328 338 title : "Expresso FileManager - " + get_lang('View'), 329 closeAction : "remove",339 closeAction : "remove", 330 340 content : Xtools.parse(Xtools.xml("view_config"), "view.xsl", pTools) 331 341 }; … … 369 379 if (size < kbyte) 370 380 { 371 return size + ' B';381 return size + ' B'; 372 382 } 373 383 else if (size < mbyte) 374 384 { 375 return parseInt(size/kbyte) + ' KB';385 return parseInt(size/kbyte) + ' KB'; 376 386 } 377 387 else if (size < gbyte) 378 388 { 379 389 if ( size/mbyte > 100) 380 return (size/mbyte).toFixed(0) + ' MB';390 return (size/mbyte).toFixed(0) + ' MB'; 381 391 else 382 return (size/mbyte).toFixed(1) + ' MB';392 return (size/mbyte).toFixed(1) + ' MB'; 383 393 } 384 394 else 385 395 { 386 return (size/gbyte).toFixed(1) + ' GB';396 return (size/gbyte).toFixed(1) + ' GB'; 387 397 } 388 398 } … … 391 401 { 392 402 var newElement = document.createElement('div'); 393 newElement.innerHTML = '<input maxlength="255" name="upload_file[]" type="file" style="margin-right:5px;" />' + 394 '<input name="upload_comment[]" type="text" style="margin-right:2px;" />' + 395 '<span style="color:red; cursor:pointer;" onclick="removeInput(this);">'+get_lang('delete')+'</span>'; 403 newElement.innerHTML = '<div></div>' + 404 '<input maxlength="255" name="upload_file[]" type="file" style="margin-right:5px;" />' + 405 '<input name="upload_comment[]" type="text" style="margin-right:2px;" />' + 406 '<span style="color:red; cursor:pointer;" onclick="removeInput(this);">'+get_lang('delete')+'</span>'; 396 407 397 408 document.getElementById('uploadOption').parentNode.appendChild(newElement); … … 447 458 { 448 459 var _formUp = document.getElementById('form_up'); 449 var _uploadFiles = document.getElementsByTagName('input');460 var _uploadFiles = document.getElementsByTagName('input'); 450 461 var _flagSend = true; 451 462 … … 463 474 464 475 if( _flagSend ) 465 { 466 cExecuteForm_( _formUp ,handler.upload); 467 } 476 cExecuteForm_( _formUp , handler.upload ); 468 477 else 469 478 write_msg(get_lang("No file(s) to send") + "!"); 470 471 close_window(); 472 } 479 } -
branches/2.2/filemanager/js/config.js
r3875 r3879 162 162 } 163 163 164 function rename_folder(){ 164 function rename_folder() 165 { 165 166 var dirName = document.getElementById('search1').value; 166 167 var toName = prompt(get_lang('enter the name you want to move %1 to',dirName),dirName); 167 if (toName.length > 1){ 168 if (toName.length > 1) 169 { 168 170 cExecute_('index.php?menuaction=filemanager.uiconfig.renameFolder&dir='+base64_encode(dirName)+'&to='+base64_encode(toName),alert); 169 171 } -
branches/2.2/filemanager/js/connector.js
r3678 r3879 100 100 function cExecuteForm_(form, handler){ 101 101 connector.showProgressBar(); 102 if(! (divUpload = document.getElementById('divUpload'))) { 103 divUpload = document.createElement('DIV'); 104 divUpload.id = 'divUpload'; 102 103 if( ! ( divUpload = document.getElementById('divUpload') ) ) 104 { 105 divUpload = document.createElement('DIV'); 106 divUpload.id = 'divUpload'; 105 107 document.body.appendChild(divUpload); 106 108 } 107 109 108 110 handlerExecuteForm = handler; 109 var form_handler = function (data){ 111 112 var form_handler = function (data) 113 { 110 114 handlerExecuteForm(data); 111 115 handlerExecuteForm = null; 112 116 } 117 113 118 divUpload.innerHTML= "<iframe onload=\"connector.hideProgressBar();cExecute_('./index.php/index.php?menuaction=filemanager.uifilemanager.getReturnExecuteForm',"+form_handler+");\" style='display:none;width:0;height:0;' name='uploadFile'></iframe>"; 119 114 120 form.target ="uploadFile"; 115 121 form.submit(); 116 122 } 117 123 -
branches/2.2/filemanager/js/draw_api.js
r3869 r3879 169 169 } 170 170 171 function initDrawApi(){ 172 SecEl = document.getElementById('userKey'); 171 function initDrawApi() 172 { 173 var SecEl = document.getElementById('userKey'); 173 174 crypt = new crypt(SecEl.value); 175 174 176 SecEl.parentNode.removeChild(SecEl); 175 177 … … 184 186 window.onresize = resizeDiv; 185 187 document.body.style.overflow = "hidden"; 186 cExecute_('./index.php?menuaction=filemanager.uifilemanager.get_folders_list',handler.draw_folders_list); 187 } 188 189 function folderList(){ 188 cExecute_('./index.php?menuaction=filemanager.uifilemanager.get_folders_list', handler.draw_folders_list ); 189 } 190 191 function folderList() 192 { 190 193 this.td = '<td style="padding-left: 2px; padding-right: 2px;" valign="middle">'; 191 194 } 192 folderList.prototype.init = function(){ 195 196 folderList.prototype.init = function() 197 { 193 198 this.element = document.getElementById('fmFileWindow'); 194 199 } 195 folderList.prototype.clear = function(){ 200 201 folderList.prototype.clear = function() 202 { 196 203 this.element.innerHTML = ""; 197 204 } 198 205 199 folderList.prototype.drawSearch = function(data){ 206 folderList.prototype.drawSearch = function(data) 207 { 200 208 var fl = folderList; 201 209 var files = unserialize(data); … … 555 563 } 556 564 var pswd = crypt.encode(password); 557 cExecute_('./index.php?menuaction=filemanager.vfs_functions.archive&pswd='+base64_encode(pswd.toString())+'&path='+base64_encode(currentPath)+filesUrl,handler.archive); 565 cExecute_('./index.php?menuaction=filemanager.vfs_functions.archive&pswd=' 566 + base64_encode(pswd.toString())+'&path='+base64_encode(currentPath)+filesUrl,handler.archive); 558 567 break; 559 568 case 'move_to': … … 633 642 function unarchive(filename) 634 643 { 635 password = crypt.encode(prompt(get_lang('Please, type archive password or leave it empty if it is not encrypted'))); 636 if (password == null) 644 var password = crypt.encode(prompt(get_lang('Please, type archive password or leave it empty if it is not encrypted'))); 645 646 if (password != null ) 647 { 648 cExecute_('./index.php?menuaction=filemanager.vfs_functions.unarchive&pswd=' 649 + base64_encode(password)+'&path='+base64_encode(currentPath)+'&file='+base64_encode(filename), handler.archive); 650 } 651 else 637 652 return; 638 cExecute_('./index.php?menuaction=filemanager.vfs_functions.unarchive&pswd='+base64_encode(password)+'&path='+base64_encode(currentPath)+'&file='+base64_encode(filename),handler.archive);639 653 } 640 654 641 655 function move_to(to,filesUrl) 642 656 { 643 cExecute_('./index.php?menuaction=filemanager.vfs_functions.moveto&from='+base64_encode(currentPath)+'&to='+base64_encode(to)+filesUrl,handler.moveto); 657 cExecute_( './index.php?menuaction=filemanager.vfs_functions.moveto&from=' 658 + base64_encode(currentPath)+'&to='+base64_encode(to)+filesUrl, handler.moveto ); 644 659 } 645 660 646 661 function copy_to(to,filesUrl) 647 662 { 648 cExecute_('./index.php?menuaction=filemanager.vfs_functions.copyto&from='+base64_encode(currentPath)+'&to='+base64_encode(to)+filesUrl,handler.copyto); 663 cExecute_('./index.php?menuaction=filemanager.vfs_functions.copyto&from=' 664 + base64_encode(currentPath)+'&to='+base64_encode(to)+filesUrl, handler.copyto ); 649 665 } 650 666 … … 696 712 697 713 var parentDir_en = base64_encode( parentDir ); 698 cExecute_('./index.php?menuaction=filemanager.uifilemanager.createdir&path='+parentDir_en+'&filename='+base64_encode(name), handler.refreshDir); 714 cExecute_('./index.php?menuaction=filemanager.uifilemanager.createdir&path=' 715 + parentDir_en+'&filename='+base64_encode(name), handler.refreshDir); 716 699 717 currentPath = parentDir + '/' + name; 700 718 close_window(); … … 744 762 var pArgs = 745 763 { 746 'lang_new_folder' 764 'lang_new_folder' : get_lang('new folder'), 747 765 'lang_remove_folder' : get_lang('remove folder'), 748 'path_filemanager' 766 'path_filemanager' : path_filemanager, 749 767 'onclick_new_folder' : 'editFolders("new")', 750 'onclick_remove_folder' 768 'onclick_remove_folder' : 'editFolders("remove")' 751 769 }; 752 770 … … 758 776 } 759 777 760 function draw_window_card(content){ 778 function draw_window_card(content) 779 { 761 780 var menu = document.getElementById('menu_newFile'); 762 if (menu == null){ 781 if (menu == null) 782 { 763 783 menu = document.createElement('DIV'); 764 784 menu.className = 'menubox'; … … 783 803 menuTimeout = setTimeout("hide_card()",4000); 784 804 } 785 function hide_card(){ 786 var e=document.getElementById('menu_newFile'); 787 if (e!=null) 788 e.style.visibility = 'hidden'; 789 } 790 791 function draw_paging(num_files,data){ 792 num_files = parseInt(num_files); 793 total_pages = 1; 794 795 if(last_folder != current_folder){ 796 lastPage = 1; 797 current_page = 1; 798 last_folder = current_folder; 799 } 800 801 if(num_files > parseInt(preferences.files_per_page)) { 802 total_pages = parseInt(num_files/preferences.files_per_page); 803 if((num_files/preferences.files_per_page) > total_pages) 804 total_pages++; 805 } 806 807 if(total_pages == 1) { 808 if(span_paging = document.getElementById("span_paging")) { 809 span_paging.parentNode.removeChild(span_paging); 810 } 811 return; 812 } 813 814 span_paging = document.getElementById("span_paging"); 815 if(!span_paging){ 816 span_paging = document.createElement("DIV"); 817 span_paging.id = "span_paging"; 818 span_paging.className = "boxHeaderText"; 819 span_paging.align="right"; 820 document.getElementById("div_menu_c3").appendChild(span_paging); 821 } 822 span_paging.style.width="100%"; 823 span_paging.innerHTML=""; 824 files_range_begin = 1; 825 files_range_end = preferences.files_per_page; 826 if(current_page != 1) { 827 lnk_page = document.createElement("A"); 828 lnk_page.setAttribute("href", "javascript:current_page=1;offset=0;toolbar.control('reload');"); 829 } 830 else { 831 lnk_page = document.createElement("SPAN"); 832 } 833 span_paging.appendChild(lnk_page); 834 835 lnk_page.innerHTML = "<<"; 836 lnk_page.title = get_lang("First"); 837 span_paging.innerHTML += " "; 838 839 if(current_page == lastPage + numPages) 840 lastPage = current_page - 1; 841 else if((lastPage != 1 && lastPage == current_page) || current_page == total_pages) 842 lastPage = current_page - (numPages - 1); 843 else if(current_page == 1) 844 lastPage = 1; 845 846 if(lastPage < 1) 847 lastPage = 1; 848 else if(lastPage > 1 && (lastPage > (total_pages -(numPages - 1)))) 849 lastPage = total_pages -(numPages - 1); 850 851 var hasMarked = false; 852 853 for(i = lastPage; i <= total_pages; i++) { 854 855 if(current_page == i || (i == total_pages && !hasMarked)) { 856 lnk_page = document.createElement("SPAN"); 857 span_paging.appendChild(lnk_page); 858 lnk_page.innerHTML = " <b>"+i+"</b> "; 859 hasMarked = true; 860 continue; 861 } 862 else{ 863 lnk_page = document.createElement("A"); 864 span_paging.appendChild(lnk_page); 865 files_range_begin = ((i*preferences.files_per_page)-(preferences.files_per_page-1)); 866 files_range_end = (i*preferences.files_per_page); 867 lnk_page.setAttribute("href", "javascript:current_page="+i+";offset=((current_page-1)*preferences.files_per_page);toolbar.control('reload');"); 868 } 869 870 lnk_page.innerHTML = " ... "; 871 872 if(i == (lastPage + numPages)) 873 break; 874 else if(lastPage == 1 || i != lastPage) 875 lnk_page.innerHTML = " "+i+" "; 876 877 span_paging.innerHTML += " "; 878 } 879 880 if(current_page != total_pages) { 881 lnk_page = document.createElement("A"); 882 files_range_begin = ((total_pages*preferences.files_per_page)-(preferences.files_per_page-1)); 883 files_range_end = (total_pages*preferences.files_per_page); 884 lnk_page.setAttribute("href", "javascript:current_page="+total_pages+";offset=((current_page-1)*preferences.files_per_page);toolbar.control('reload');"); 885 } 886 else { 887 lnk_page = document.createElement("SPAN"); 888 } 889 span_paging.innerHTML += " "; 890 span_paging.appendChild(lnk_page); 891 892 lnk_page.title = get_lang("Last"); 893 lnk_page.innerHTML = ">>"; 894 } 895 805 function hide_card() 806 { 807 var menuNewFile = document.getElementById('menu_newFile'); 808 809 if ( menuNewFile != null ) 810 menuNewFile.style.visibility = 'hidden'; 811 } 812 813 function draw_paging( num_files, data) 814 { 815 num_files = parseInt(num_files); 816 var total_pages = 1; 817 818 if( last_folder != current_folder ) 819 { 820 lastPage = 1; 821 current_page = 1; 822 last_folder = current_folder; 823 } 824 825 if( num_files > parseInt(preferences.files_per_page) ) 826 { 827 total_pages = parseInt(num_files/preferences.files_per_page); 828 829 if( (num_files/preferences.files_per_page) > total_pages ) 830 total_pages++; 831 } 832 833 if( total_pages == 1) 834 { 835 if( span_paging = document.getElementById("span_paging") ) 836 { 837 span_paging.parentNode.removeChild(span_paging); 838 } 839 840 return; 841 } 842 843 span_paging = document.getElementById("span_paging"); 844 845 if( !span_paging ) 846 { 847 span_paging = document.createElement("DIV"); 848 span_paging.id = "span_paging"; 849 span_paging.className = "boxHeaderText"; 850 span_paging.align="right"; 851 document.getElementById("div_menu_c3").appendChild(span_paging); 852 } 853 span_paging.style.width="100%"; 854 span_paging.innerHTML=""; 855 files_range_begin = 1; 856 files_range_end = preferences.files_per_page; 857 858 if ( current_page != 1) 859 { 860 lnk_page = document.createElement("A"); 861 lnk_page.setAttribute("href", "javascript:current_page=1;offset=0;toolbar.control('reload');"); 862 } 863 else 864 { 865 lnk_page = document.createElement("SPAN"); 866 } 867 868 span_paging.appendChild(lnk_page); 869 870 lnk_page.innerHTML = "<<"; 871 lnk_page.title = get_lang("First"); 872 span_paging.innerHTML += " "; 873 874 if( current_page == lastPage + numPages) 875 lastPage = current_page - 1; 876 else if( (lastPage != 1 && lastPage == current_page) || current_page == total_pages ) 877 lastPage = current_page - (numPages - 1); 878 else if( current_page == 1 ) 879 lastPage = 1; 880 881 if(lastPage < 1) 882 lastPage = 1; 883 else if( lastPage > 1 && (lastPage > (total_pages -(numPages - 1))) ) 884 lastPage = total_pages -(numPages - 1); 885 886 var hasMarked = false; 887 888 for( i = lastPage; i <= total_pages; i++) 889 { 890 if( current_page == i || (i == total_pages && !hasMarked)) 891 { 892 lnk_page = document.createElement("SPAN"); 893 span_paging.appendChild(lnk_page); 894 lnk_page.innerHTML = " <b>"+i+"</b> "; 895 hasMarked = true; 896 continue; 897 } 898 else 899 { 900 lnk_page = document.createElement("A"); 901 span_paging.appendChild(lnk_page); 902 files_range_begin = ((i*preferences.files_per_page)-(preferences.files_per_page-1)); 903 files_range_end = (i*preferences.files_per_page); 904 lnk_page.setAttribute("href", "javascript:current_page="+i+";offset=((current_page-1)*preferences.files_per_page);toolbar.control('reload');"); 905 } 906 907 lnk_page.innerHTML = " ... "; 908 909 if( i == (lastPage + numPages) ) 910 break; 911 else if(lastPage == 1 || i != lastPage) 912 lnk_page.innerHTML = " "+i+" "; 913 914 span_paging.innerHTML += " "; 915 } 916 917 if( current_page != total_pages ) 918 { 919 lnk_page = document.createElement("A"); 920 files_range_begin = ((total_pages*preferences.files_per_page)-(preferences.files_per_page-1)); 921 files_range_end = (total_pages*preferences.files_per_page); 922 lnk_page.setAttribute("href", "javascript:current_page="+total_pages+";offset=((current_page-1)*preferences.files_per_page);toolbar.control('reload');"); 923 } 924 else 925 { 926 lnk_page = document.createElement("SPAN"); 927 } 928 929 span_paging.innerHTML += " "; 930 span_paging.appendChild(lnk_page); 931 932 lnk_page.title = get_lang("Last"); 933 lnk_page.innerHTML = ">>"; 934 } -
branches/2.2/filemanager/js/handler.js
r3619 r3879 1 function handler(){ 2 } 3 4 handler.prototype.del = function(data) 1 (function() 5 2 { 6 var _return = data; 7 var deletedFiles = ""; 3 function archive(data) 4 { 5 var returnVal = data.split('|'); 6 7 if (returnVal[0] == 'False') 8 { 9 write_error(get_lang('It was not possible to execute it')); 10 } 11 else 12 13 if (returnVal[0] == 'wpasswd') 14 { 15 write_error(get_lang('Wrong password')); 16 return; 17 } 18 else 19 write_msg(get_lang('Your operation was successfully executed')); 20 21 toolbar.control('reload'); 22 } 23 24 function copyto(data) 25 { 26 var returnVal = data.split('|'); 27 28 if (returnVal[0] == 'NODIR') 29 write_error(get_lang('Could not copy file because no destination directory is given')); 30 else if(returnVal[0] == 'SOMEERROR') 31 { 32 write_error(get_lang('Could not copy %1 file(s)',returnVal[1])); 33 } 34 else if(returnVal[0] == 'COPIED') 35 { 36 if (returnVal[1] == 1) 37 write_msg(get_lang('File copied successfuly')); 38 else 39 write_msg(get_lang('%1 files copied successfuly', returnVal[1])); 40 } 41 } 42 43 function del(data) 44 { 45 var _return = data; 46 var deletedFiles = ""; 47 48 _return = _return.substring(0, ( _return.length - 1 ) ); 49 _return = _return.split("|"); 50 51 52 for (var i = 0 ; i < _return.length; i++) 53 { 54 if ( _return[i] == 'False') 55 { 56 write_error(get_lang('Could not delete %1', _return[i+1]) ); 57 return; 58 } 59 else 60 { 61 if ( _return[i] != "" ) 62 { 63 deletedFiles += ", " + _return[i]; 64 } 65 66 if (i > 3) //to avoid big message 67 { 68 deletedFiles = " " + _return.length + " " +get_lang("files"); 69 break; 70 } 71 } 72 } 73 74 write_msg(get_lang('Deleted %1',deletedFiles.substr(2))); 75 76 toolbar.control('reload'); 77 } 78 79 function draw_folders_list(data) 80 { 81 toolbar.control('reload'); 82 folders_tree = new dFTree({name: 'main'}); 83 84 folders = unserialize(data); 85 86 var rootFold = new dNode({id:'root', caption: get_lang("Directories") }); 87 folders_tree.add(rootFold,'root'); 88 89 for ( var i = 0 ; i < folders.length; i++ ) 90 { 91 var lastIndex = folders[i].lastIndexOf('/'); 92 if (folders[i] != "/home/"+preferences.lid) 93 var name = folders[i].substr(lastIndex+1,folders[i].length); 94 else 95 var name = get_lang("My Folder"); 96 var parentDir = folders[i].substr(0,lastIndex); 97 98 if ( parentDir == '/home' ) 99 parentDir = 'root'; 100 101 var search_child = function( ListFolders, name ) 102 { 103 for ( j = 0 ; j < ListFolders.length; j++ ) 104 { 105 if ( ListFolders[j].indexOf( name + '/') > -1 ) 106 return true; 107 } 108 109 return false; 110 } 111 112 folder = new dNode({id:folders[i], caption:name, plusSign:search_child(folders,folders[i]), onClick:'load(\''+folders[i]+'\',this)'}); 113 114 if (i == 0) 115 folders_tree.add(folder,'root'); 116 else 117 folders_tree.add(folder,parentDir); 118 } 119 120 document.getElementById('content_folders').innerHTML = ""; 121 122 folders_tree.draw(document.getElementById('content_folders')); 123 124 folders_tree.openTo(currentPath); 125 126 folders_tree.getNodeById(currentPath)._select(); 127 } 128 129 function moveto(data) 130 { 131 returnVal = data.split('|'); 132 if (returnVal[0] == 'NODIR') 133 write_error(get_lang('Could not copy file because no destination directory is given')); 134 else if(returnVal[0] == 'SOMEERROR'){ 135 write_error(get_lang('Could not move %1 file(s)',returnVal[1])); 136 } 137 else if(returnVal[0] == 'MOVED'){ 138 if (returnVal[1] == 1) 139 write_msg(get_lang('File moved successfuly')); 140 else 141 write_msg(get_lang('%1 files moved successfuly', returnVal[1])); 142 } 143 handler.refreshDir(); 144 } 145 146 function refreshDir(data) 147 { 148 cExecute_('./index.php?menuaction=filemanager.uifilemanager.get_folders_list',handler.draw_folders_list); 149 } 150 151 function rename(data) 152 { 153 if ( data == null ) 154 { 155 var returnVal = new Array ("True",oldValue,oldValue); 156 } 157 else 158 var returnVal = data.split('|'); 159 160 if ( returnVal[0] == "True" ) 161 { 162 if (returnVal[1] != returnVal[2]) write_msg(get_lang('Renamed %1 to %2',returnVal[1],returnVal[2])); 163 var nameLink = document.createElement('A'); 164 165 var inputName = document.getElementById('input_'+returnVal[1]); 166 var trFile = inputName.parentNode.parentNode.parentNode; 167 168 nameLink.innerHTML = returnVal[2]; 169 nameLink.href="./index.php?menuaction=filemanager.uifilemanager.view&file=" 170 + base64_encode(returnVal[2])+"&path="+base64_encode(currentPath); 171 nameLink.target = "_blank"; 172 nameLink.id = "name_"+returnVal[2]; 173 174 inputName.parentNode.appendChild(nameLink); 175 inputName.parentNode.removeChild(inputName); 176 trFile.innerHTML = trFile.innerHTML.replace(returnVal[1],returnVal[2]); 177 trFile.id = trFile.id.replace(returnVal[1],returnVal[2]); 178 } 179 else 180 { 181 if ( returnVal[1] == "badchar" ) 182 write_error(get_lang('File names cannot contain "%1"',returnVal[2])); 183 else if (returnVal[1] == "slashes") 184 write_error(get_lang('File names cannot contain \\ or /')); 185 else if (returnVal[1] == "editing") 186 write_error(get_lang('This file is being edited right now')); 187 else 188 write_error(get_lang('Could not rename %1 to %2', returnVal[1], returnVal[2])); 189 } 190 191 } 8 192 9 _return = _return.substring(0, ( _return.length - 1 ) ); 10 _return = _return.split("|"); 193 function restricted(data) 194 { 195 if (data.indexOf("True") == 0) 196 { 197 returnVal = data.split('|'); 198 var img_lock = document.getElementById('restrict_'+returnVal[1]); 199 200 if (img_lock.style.backgroundImage.indexOf('button_unlock') > 0) 201 { 202 img_lock.style.backgroundImage = img_lock.style.backgroundImage.replace(/button_unlock/g,'button_lock'); 203 write_msg(get_lang('%1 marked as restricted',returnVal[1])); 204 } 205 else 206 { 207 img_lock.style.backgroundImage = img_lock.style.backgroundImage.replace(/button_lock/g,'button_unlock'); 208 write_msg(get_lang('%1 unmarked as restricted',returnVal[1])); 209 } 210 } 211 else 212 write_error("Could not mark as restricted"); 213 } 214 215 function updateComment(data) 216 { 217 var returnVal = data.split('|'); 218 if (data.indexOf("True") == 0) 219 { 220 write_msg(get_lang('Updated comment for %1',returnVal[1])); 221 } 222 else 223 { 224 if (returnVal[1] == "badchar") 225 write_error(get_lang('Comments cannot contain "%1"',returnVal[2])); 226 else 227 write_error(get_lang('You have no permission to access this file')); 228 } 229 230 } 11 231 232 function upload(data) 233 { 234 var response = unserialize(data); 235 236 if ( response[0] == "Ok" ) 237 { 238 write_msg(get_lang('All files created sucessfuly')); 239 _winBuild( "dwindownewUpload" , "remove" ); 240 } 241 else 242 { 243 var _inputs = document.getElementsByTagName('input'); 244 245 for( var i = 0; i < response.length; i++ ) 246 { 247 for( var j = 0 ; j < _inputs.length ; j++ ) 248 { 249 if( _inputs[j].getAttribute('type') == 'file' ) 250 { 251 if( _inputs[j].value.indexOf( response[i]['file'] ) > -1 ) 252 { 253 var _parent = _inputs[j].parentNode; 254 var _div = _parent.firstChild; 255 _div.style.display = "block"; 256 _div.style.color = "red"; 257 _div.style.height = "16px"; 258 _div.style.paddingLeft = "17px"; 259 _div.style.background = "url('"+path_filemanager+"images/warning.gif') no-repeat left top"; 260 _div.style.cursor = "pointer"; 261 _div.onclick = function(){ this.style.display = 'none'; } ; 262 263 if( response[i]['size_max'] ) 264 { 265 _div.innerHTML = "<span style='font-weight:bold' >Erro </span>:: Tamanho do arquivo " 266 + borkb( response[i]['size'] ) + " - Permitido " + borkb( response[i]['size_max'] ); 267 } 268 else if( response[i]['badchar'] ) 269 { 270 _div.innerHTML = "<span style='font-weight:bold' >Erro </span>:: " + response[i]['badchar']; 271 } 272 else if( response[i]['directory'] ) 273 { 274 _div.innerHTML = "<span style='font-weight:bold' >Erro </span>:: " + response[i]['directory']; 275 } 276 else if( response[i]['sendFile'] ) 277 { 278 _div.innerHTML = "<span style='font-weight:bold' >Erro </span>:: " + response[i]['sendFile']; 279 } 280 else if( response[i]['undefined'] ) 281 { 282 _div.innerHTML = "<span style='font-weight:bold' >Erro </span>:: " + response[i]['undefined']; 283 } 284 } 285 } 286 } 287 } 288 } 289 290 connector.hideProgressBar(); 291 toolbar.control('reload'); 292 } 293 294 function handler(){} 295 296 handler.prototype.archive = archive; 297 handler.prototype.copyto = copyto; 298 handler.prototype.del = del; 299 handler.prototype.draw_folders_list = draw_folders_list; 300 handler.prototype.moveto = moveto; 301 handler.prototype.refreshDir = refreshDir; 302 handler.prototype.rename = rename; 303 handler.prototype.restricted = restricted; 304 handler.prototype.updateComment = updateComment; 305 handler.prototype.upload = upload; 306 307 window.handler = new handler; 12 308 13 for (var i = 0 ; i < _return.length; i++) 14 { 15 if ( _return[i] == 'False') 16 { 17 write_error(get_lang('Could not delete %1', _return[i+1]) ); 18 return; 19 } 20 else 21 { 22 if ( _return[i] != "" ) 23 { 24 deletedFiles += ", " + _return[i]; 25 } 26 27 if (i > 3) //to avoid big message 28 { 29 deletedFiles = " " + _return.length + " " +get_lang("files"); 30 break; 31 } 32 } 33 } 34 35 write_msg(get_lang('Deleted %1',deletedFiles.substr(2))); 36 37 toolbar.control('reload'); 38 39 } 40 41 handler.prototype.rename = function(data) { 42 if (data == null){ 43 var returnVal = new Array ("True",oldValue,oldValue); 44 } 45 else 46 var returnVal = data.split('|'); 47 if ( returnVal[0] == "True" ){ 48 if (returnVal[1] != returnVal[2]) write_msg(get_lang('Renamed %1 to %2',returnVal[1],returnVal[2])); 49 var nameLink = document.createElement('A'); 50 var inputName = document.getElementById('input_'+returnVal[1]); 51 var trFile = inputName.parentNode.parentNode.parentNode; 52 53 nameLink.innerHTML = returnVal[2]; 54 nameLink.href="./index.php?menuaction=filemanager.uifilemanager.view&file="+base64_encode(returnVal[2])+"&path="+base64_encode(currentPath); 55 nameLink.target = "_blank"; 56 nameLink.id = "name_"+returnVal[2]; 57 58 inputName.parentNode.appendChild(nameLink); 59 inputName.parentNode.removeChild(inputName); 60 trFile.innerHTML = trFile.innerHTML.replace(returnVal[1],returnVal[2]); 61 trFile.id = trFile.id.replace(returnVal[1],returnVal[2]); 62 } 63 else 64 { 65 if (returnVal[1] == "badchar") 66 write_error(get_lang('File names cannot contain "%1"',returnVal[2])); 67 else if (returnVal[1] == "slashes") 68 write_error(get_lang('File names cannot contain \\ or /')); 69 else if (returnVal[1] == "editing") 70 write_error(get_lang('This file is being edited right now')); 71 else 72 write_error(get_lang('Could not rename %1 to %2', returnVal[1], returnVal[2])); 73 } 74 75 } 76 77 handler.prototype.upload = function(data) 78 { 79 80 connector.hideProgressBar(); 81 var response = unserialize(data); 82 if (response[0] == "Ok") 83 write_msg(get_lang('All files created sucessfuly')); 84 else 85 for (var i=0;i < response.length; i++) 86 write_error(response[i]); 87 toolbar.control('reload'); 88 } 89 90 handler.prototype.restricted = function(data) 91 { 92 if (data.indexOf("True") == 0){ 93 returnVal = data.split('|'); 94 var img_lock = document.getElementById('restrict_'+returnVal[1]); 95 if (img_lock.style.backgroundImage.indexOf('button_unlock') > 0) 96 { 97 img_lock.style.backgroundImage = img_lock.style.backgroundImage.replace(/button_unlock/g,'button_lock'); 98 write_msg(get_lang('%1 marked as restricted',returnVal[1])); 99 } 100 else 101 { 102 img_lock.style.backgroundImage = img_lock.style.backgroundImage.replace(/button_lock/g,'button_unlock'); 103 write_msg(get_lang('%1 unmarked as restricted',returnVal[1])); 104 } 105 } 106 else 107 write_error("Could not mark as restricted"); 108 } 109 110 handler.prototype.archive = function(data) 111 { 112 returnVal = data.split('|'); 113 if (returnVal[0] == 'False') 114 { 115 write_error(get_lang('It was not possible to execute it')); 116 } 117 else 118 if (returnVal[0] == 'wpasswd') 119 { 120 write_error(get_lang('Wrong password')); 121 return; 122 } 123 else 124 write_msg(get_lang('Your operation was successfully executed')); 125 toolbar.control('reload'); 126 127 } 128 129 handler.prototype.updateComment = function (data) 130 { 131 var returnVal = data.split('|'); 132 if (data.indexOf("True") == 0) 133 { 134 write_msg(get_lang('Updated comment for %1',returnVal[1])); 135 } 136 else 137 { 138 if (returnVal[1] == "badchar") 139 write_error(get_lang('Comments cannot contain "%1"',returnVal[2])); 140 else 141 write_error(get_lang('You have no permission to access this file')); 142 } 143 144 } 145 146 handler.prototype.draw_folders_list = function (data) 147 { 148 toolbar.control('reload'); 149 folders_tree = new dFTree({name: 'main'}); 150 151 folders = unserialize(data); 152 153 var rootFold = new dNode({id:'root', caption: get_lang("Directories") }); 154 folders_tree.add(rootFold,'root'); 155 156 for ( var i = 0 ; i < folders.length; i++ ) 157 { 158 var lastIndex = folders[i].lastIndexOf('/'); 159 if (folders[i] != "/home/"+preferences.lid) 160 var name = folders[i].substr(lastIndex+1,folders[i].length); 161 else 162 var name = get_lang("My Folder"); 163 var parentDir = folders[i].substr(0,lastIndex); 164 165 if ( parentDir == '/home' ) 166 parentDir = 'root'; 167 168 var search_child = function( ListFolders, name ) 169 { 170 for ( j = 0 ; j < ListFolders.length; j++ ) 171 { 172 if ( ListFolders[j].indexOf( name + '/') > -1 ) 173 return true; 174 } 175 176 return false; 177 } 178 179 folder = new dNode({id:folders[i], caption:name, plusSign:search_child(folders,folders[i]), onClick:'load(\''+folders[i]+'\',this)'}); 180 181 if (i == 0) 182 folders_tree.add(folder,'root'); 183 else 184 folders_tree.add(folder,parentDir); 185 } 186 187 document.getElementById('content_folders').innerHTML = ""; 188 189 folders_tree.draw(document.getElementById('content_folders')); 190 191 folders_tree.openTo(currentPath); 192 193 folders_tree.getNodeById(currentPath)._select(); 194 } 195 196 handler.prototype.copyto = function (data) 197 { 198 returnVal = data.split('|'); 199 if (returnVal[0] == 'NODIR') 200 write_error(get_lang('Could not copy file because no destination directory is given')); 201 else if(returnVal[0] == 'SOMEERROR'){ 202 write_error(get_lang('Could not copy %1 file(s)',returnVal[1])); 203 } 204 else if(returnVal[0] == 'COPIED'){ 205 if (returnVal[1] == 1) 206 write_msg(get_lang('File copied successfuly')); 207 else 208 write_msg(get_lang('%1 files copied successfuly', returnVal[1])); 209 } 210 } 211 212 handler.prototype.moveto = function (data) { 213 returnVal = data.split('|'); 214 if (returnVal[0] == 'NODIR') 215 write_error(get_lang('Could not copy file because no destination directory is given')); 216 else if(returnVal[0] == 'SOMEERROR'){ 217 write_error(get_lang('Could not move %1 file(s)',returnVal[1])); 218 } 219 else if(returnVal[0] == 'MOVED'){ 220 if (returnVal[1] == 1) 221 write_msg(get_lang('File moved successfuly')); 222 else 223 write_msg(get_lang('%1 files moved successfuly', returnVal[1])); 224 } 225 handler.refreshDir(); 226 } 227 handler.prototype.refreshDir = function (data) { 228 cExecute_('./index.php?menuaction=filemanager.uifilemanager.get_folders_list',handler.draw_folders_list); 229 } 230 231 var handler = new handler(); 309 })(); -
branches/2.2/filemanager/setup/phpgw_pt-br.lang
r3875 r3879 12 12 comment filemanager pt-br Comentário 13 13 comments cannot contain "%1" filemanager pt-br Comentários não podem conter "%1" 14 Comment(s) filemanager pt-br Comentário(s) 14 15 %1 files copied successfuly filemanager pt-br %1 arquivos foram copiados com sucesso 15 16 File copied successfuly filemanager pt-br O arquivo foi copiado com sucesso … … 39 40 You have no permission to access this file filemanager pt-br Você não tem permissão para acessar este arquivo 40 41 One of the files sent was considered infected filemanager pt-bt Um dos arquivos enviados foi considerado infectado por vírus 41 Note: Uploaded is limited to %1MB filemanager pt-br Nota: O tamanho máximo de envio é limitado a%1MB42 The maximum size for each file is %1MB filemanager pt-br O tamanho máximo para cada arquivo é de %1MB 42 43 This property will change the visibility of all users that have access to this file, continue? filemanager pt-br Esta propriedade altera visibilidade dos usuários que estão compartilhados, deseja continuar? 43 44 Click to change comments filemanager pt-br Clique para alterar comentários … … 89 90 filemanager preferences filemanager pt-br Preferências para Gerenciador de Arquivos 90 91 files filemanager pt-br Arquivos 92 File(s) filemanager pt-br Arquivo(s) 91 93 files in this directory filemanager pt-br Arquivos nesse diretório 92 94 folder filemanager pt-br Pasta -
branches/2.2/filemanager/tp/expressowindow/xsl/upload.xsl
r3647 r3879 6 6 <xsl:param name="form_action" /> 7 7 <xsl:param name="height"/> 8 <xsl:param name="lang_add_file" />9 8 <xsl:param name="lang_advanced_upload" /> 10 9 <xsl:param name="lang_click_here"/> … … 32 31 </div> 33 32 34 <div style="height:{$height}px; margin: 4px; overflow-y:auto;"> 35 33 <div style="height:{$height}px; margin: 4px; overflow-y:auto; overflow-x:hidden;"> 36 34 <div id="sendNotifcation" style="margin: 4px; overflow-y:auto;"/> 37 38 <div id="uploadOption"> 39 <span style="margin-right:{($width)-250}px;"> 40 <xsl:value-of select="$lang_file"/> 41 </span> 42 <span> 43 <xsl:value-of select="$lang_comment"/> 44 </span> 45 <br/> 46 <input maxlength="255" name="upload_file[]" type="file" style="margin-right:5px" /> 35 <span style="margin-right:{($width)-250}px;"> 36 <label style="margin-left:1px;"><xsl:value-of select="$lang_file"/></label> 37 <label style="margin-left:200px;"><xsl:value-of select="$lang_comment"/></label> 38 </span> 39 <br/> 40 <div id="uploadOption" > 41 <div></div> 42 <input maxlength="255" name="upload_file[]" type="file" style="margin-right:5px" /> 47 43 <input name="upload_comment[]" type="text"/> 48 44 <input type="hidden" name="uploadprocess" value="true"/> … … 65 61 </div> 66 62 67 <div style="font-weight:bold; margin-top: 15px;">63 <div style="font-weight:bold; color: #f00; font-size:10pt; margin-top: 15px;"> 68 64 <xsl:value-of select="$max_size"/> 69 65 </div>
Note: See TracChangeset
for help on using the changeset viewer.