1<?php 2/** 3 * Egroupware - Filemanager - A portlet for displaying a list of entries 4 * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License 5 * @package filemanager 6 * @subpackage home 7 * @link http://www.egroupware.org 8 * @author Nathan Gray 9 * @version $Id$ 10 */ 11 12use EGroupware\Api; 13use EGroupware\Api\Vfs; 14use EGroupware\Api\Etemplate; 15 16/** 17 * The filemanager_list_portlet uses a nextmatch / favorite 18 * to display a list of entries. 19 */ 20class filemanager_favorite_portlet extends home_favorite_portlet 21{ 22 /** 23 * Construct the portlet 24 * 25 */ 26 public function __construct(Array &$context = array(), &$need_reload = false) 27 { 28 $context['appname'] = 'filemanager'; 29 30 // Let parent handle the basic stuff 31 parent::__construct($context,$need_reload); 32 33 $this->nm_settings += array( 34 'get_rows' => 'filemanager.filemanager_favorite_portlet.get_rows', 35 'csv_export' => true, 36 // Use a different template so it can be accessed from client side 37 'template' => ($this->nm_settings['view'] == 'tile' ? 'filemanager.tile' : 'filemanager.home.rows' ), 38 // Filemanager needs this header, it's an important component for actions, but we reduce it to the minimum 39 'header_left' => 'filemanager.home.header_left', 40 // Use a reduced column set for home, user can change if needed 41 'default_cols' => 'mime,name', 42 'no_cat' => true, 43 'no_filter2' => true, 44 'row_id' => 'path', 45 'row_modified' => 'mtime', 46 'parent_id' => 'dir', 47 'is_parent' => 'mime', 48 'is_parent_value'=> Vfs::DIR_MIME_TYPE, 49 'placeholder_actions' => array('mkdir','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink') 50 ); 51 } 52 53 public function exec($id = null, Etemplate &$etemplate = null) 54 { 55 56 $this->context['sel_options']['filter'] = array( 57 '' => 'Current directory', 58 '2' => 'Directories sorted in', 59 '3' => 'Show hidden files', 60 '4' => 'All subdirectories', 61 '5' => 'Files from links', 62 '0' => 'Files from subdirectories', 63 ); 64 $this->nm_settings['actions'] = filemanager_ui::get_actions(); 65 66 $this->nm_settings['home_dir'] = filemanager_ui::get_home_dir(); 67 parent::exec($id, $etemplate); 68 } 69 70 /** 71 * Override from filemanager to clear the app header 72 * 73 * @param type $query 74 * @param type $rows 75 * @param type $readonlys 76 * @return integer Total rows found 77 */ 78 public static function get_rows(&$query, &$rows, &$readonlys) 79 { 80 $ui = new filemanager_ui(); 81 $total = $ui->get_rows($query, $rows, $readonlys); 82 // Change template to match selected view 83 if($query['view']) 84 { 85 $query['template'] = ($query['view'] == 'row' ? 'filemanager.home.rows' : 'filemanager.tile'); 86 } 87 unset($GLOBALS['egw_info']['flags']['app_header']); 88 return $total; 89 } 90 91 /** 92 * Here we need to handle any incoming data. Setup is done in the constructor, 93 * output is handled by parent. 94 * 95 * @param type $id 96 * @param Etemplate $etemplate 97 */ 98 public static function process($content = array()) 99 { 100 parent::process($content); 101 102 // This is just copy+pasted from filemanager_ui line 378, but we don't want 103 // the etemplate exec to fire again. 104 if ($content['nm']['action']) 105 { 106 $msg = filemanager_ui::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); 107 if($msg) Api\Json\Response::get()->apply('egw.message',array($msg)); 108 foreach($content['nm']['selected'] as &$id) 109 { 110 $id = 'filemanager::'.$id; 111 } 112 // Directly request an update - this will get filemanager tab too 113 Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected'])); 114 } 115 } 116 }