elfinder custom Filter

80 Views Asked by At

i have a working elfinder 2.1-instance with multiple roots running. In one root (withot subfolders) there are images with numeric filenames (eq. 1.jpg, 2.jpg, ...) based on these filenames there is a database with file-descriptions. (eq: {1 => "File 1", 2 => "next File"}).

My challenges:

  • kill files without description out of the resultset
  • replace the displayed filenames by descriptions.

I have a working javascript-solution but i think it's better to modify the php-connector - maybe on "accesscontrol". How can i solve this challenge?

Here my javascript-hack-solution:

... 
handlers : { 'open' : function (event, elfinderInstance) {ReplaceDescriptions(event, elfinderInstance)}
...
function ReplaceDescriptions(event, elfinderInstance) {
   var Root = JSON.stringify(elfinderInstance.cwd().name);
   Root = Root.replace(/"([^"]+(?="))"/g, '$1') // Hochkommas entfernen
   
   if (Root == "Bilder und Pläne") {
      setTimeout(function() { 
         arrBilder = getDescriptions();
         var view = JSON.stringify(elfinderInstance.viewType);
         view = view.replace(/"([^"]+(?="))"/g, '$1')
                                    
         var xfiles = $('#elfinder .elfinder-cwd-filename');
         $.each(xfiles, function() {
            fname = $(this).html();
            if (view == "list") { 
               title = $(this).closest('tr').attr('title');
               if (fname in arrBilder) {
                  $(this).html(arrBilder[fname]);   // set description
               } else {
                 if (title.indexOf(fname) == 0 ) {
                    $(this).closest('tr').remove(); // remove file                                           
                 }
               }
           } else {
              // view == "icon"
              //...
           }
        });
      } ,50)
   }
}

0

There are 0 best solutions below