mimetype filter for filepicker
This commit is contained in:
parent
fe3d3be399
commit
96c99125da
|
@ -107,8 +107,8 @@ OCdialogs = {
|
|||
$(c_id + ' #dirtree').focus(function() { var t = $(this); t.data('oldval', t.val())})
|
||||
.change({dcid: c_id}, OC.dialogs.handleTreeListSelect);
|
||||
$(c_id).ready(function(){
|
||||
$.getJSON(OC.webroot+'/files/ajax/rawlist.php', function(r){OC.dialogs.fillFilePicker(r, c_id, callback)});
|
||||
}).data('multiselect', multiselect);
|
||||
$.getJSON(OC.webroot+'/files/ajax/rawlist.php', {mimetype: mimetype_filter} ,function(r){OC.dialogs.fillFilePicker(r, c_id, callback)});
|
||||
}).data('multiselect', multiselect).data('mimetype',mimetype_filter);
|
||||
// build buttons
|
||||
var b = [
|
||||
{text: t('dialogs', 'Choose'), click: function(){
|
||||
|
@ -222,7 +222,7 @@ OCdialogs = {
|
|||
$(this).children().each(function(i, element) { if (skip_first) {skip_first = false; return; }path += '/'+$(element).text(); });
|
||||
$(event.data.dcid).data('path', path);
|
||||
$(event.data.dcid + ' .filepicker_loader').css('visibility', 'visible');
|
||||
$.getJSON(OC.webroot+'/files/ajax/rawlist.php', {dir: path}, function(r){OC.dialogs.fillFilePicker(r, event.data.dcid)});
|
||||
$.getJSON(OC.webroot+'/files/ajax/rawlist.php', {dir: path, mimetype: $(event.data.dcid).data('mimetype')}, function(r){OC.dialogs.fillFilePicker(r, event.data.dcid)});
|
||||
},
|
||||
// this function is in early development state, please dont use it unlsess you know what you are doing
|
||||
handlePickerClick:function(element, name, dcid) {
|
||||
|
@ -240,6 +240,6 @@ OCdialogs = {
|
|||
var newval = parseInt($(dcid + ' #dirtree option:last').val())+1;
|
||||
$(dcid + ' #dirtree').append('<option selected="selected" value="'+newval+'">'+name+'</option>');
|
||||
$(dcid + ' .filepicker_loader').css('visibility', 'visible');
|
||||
$.getJSON(OC.webroot+'/files/ajax/rawlist.php', {dir: p}, function(r){OC.dialogs.fillFilePicker(r, dcid)});
|
||||
$.getJSON(OC.webroot+'/files/ajax/rawlist.php', {dir: p, mimetype: $(dcid).data('mimetype')}, function(r){OC.dialogs.fillFilePicker(r, dcid)});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -11,10 +11,11 @@ OC_JSON::checkLoggedIn();
|
|||
|
||||
// Load the files
|
||||
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
|
||||
$mimetype = isset($_GET['mimetype']) ? $_GET['mimetype'] : '';
|
||||
|
||||
// make filelist
|
||||
$files = array();
|
||||
foreach( OC_Files::getdirectorycontent( $dir ) as $i ){
|
||||
foreach( OC_Files::getdirectorycontent( $dir, $mimetype ) as $i ){
|
||||
$i["date"] = OC_Util::formatDate($i["mtime"] );
|
||||
$i['mimetype_icon'] = $i['type'] == 'dir' ? mimetype_icon('dir'): mimetype_icon($i['mimetype']);
|
||||
$files[] = $i;
|
||||
|
|
|
@ -240,7 +240,7 @@ class OC_FileCache{
|
|||
* - encrypted
|
||||
* - versioned
|
||||
*/
|
||||
public static function getFolderContent($path,$root=''){
|
||||
public static function getFolderContent($path,$root='',$mimetype_filter=''){
|
||||
if(self::isUpdated($path,$root)){
|
||||
self::updateFolder($path,$root);
|
||||
}
|
||||
|
@ -252,8 +252,8 @@ class OC_FileCache{
|
|||
}
|
||||
$path=$root.$path;
|
||||
$parent=self::getFileId($path);
|
||||
$query=OC_DB::prepare('SELECT name,ctime,mtime,mimetype,size,encrypted,versioned,writable FROM *PREFIX*fscache WHERE parent=?');
|
||||
$result=$query->execute(array($parent))->fetchAll();
|
||||
$query=OC_DB::prepare('SELECT name,ctime,mtime,mimetype,size,encrypted,versioned,writable FROM *PREFIX*fscache WHERE parent=? AND (mimetype LIKE ? OR mimetype = ?)');
|
||||
$result=$query->execute(array($parent, $mimetype_filter.'%', 'httpd/unix-directory'))->fetchAll();
|
||||
if(is_array($result)){
|
||||
return $result;
|
||||
}else{
|
||||
|
|
|
@ -32,11 +32,11 @@ class OC_Files {
|
|||
* get the content of a directory
|
||||
* @param dir $directory
|
||||
*/
|
||||
public static function getDirectoryContent($directory){
|
||||
public static function getDirectoryContent($directory, $mimetype_filter = ''){
|
||||
if(strpos($directory,OC::$CONFIG_DATADIRECTORY)===0){
|
||||
$directory=substr($directory,strlen(OC::$CONFIG_DATADIRECTORY));
|
||||
}
|
||||
$files=OC_FileCache::getFolderContent($directory);
|
||||
$files=OC_FileCache::getFolderContent($directory, '', $mimetype_filter);
|
||||
foreach($files as &$file){
|
||||
$file['directory']=$directory;
|
||||
$file['type']=($file['mimetype']=='httpd/unix-directory')?'dir':'file';
|
||||
|
|
Loading…
Reference in New Issue