Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Always show the Folders in FileBrowser

edited August 2005 in Vanilla 1.0 Help
Im currently attempting to hack away at FileBrowser and change the way it works but im getting lost! What i would like is for it to always show the folders and not change to "Parent Directory" now ive found the bit that works out the directory but im unsure of what i need to do to stop it from not displaying a the folders from the base directory. Basicly i would like to achive summat like the below Base Folder - Folder one ----- Sub Folder One ----- Sub Folder Two --------------- Selected Sub Sub Folder ----- Sub Folder Three - Folder two - Folder three So we basicly end up with a cascading menu system. Any ideas where im to start >_<

Comments

  • Options
    MarkMark Vanilla Staff
    I know exactly what you'd need to do, but I don't have enough time to get into it right now - I'll bookmark the thread and come back to it later.
  • Options
    Thank you, shall come back later then :D
  • Options
    MarkMark Vanilla Staff
    edited August 2005
    If I get swamped today and forget to come back here, feel free to remind me by bumping this thread.
  • Options
    MarkMark Vanilla Staff
    edited August 2005
    On line 1071 of the latest release of the filebrowser's index.php file, I get a handle for the folder that is currently being browsed and begin looping through the contents of the folder. As I loop through the contents of the folder, if the item is a folder, I add it to the folder collection, and if it's something else, I add it to a different appropriate collection:
    <strong>// Get a handle on the folder being browsed
    $FolderHandle = opendir($Config->CurrentBrowsingDirectory);</strong>
    $CurrentExtension = "";
    $RecordItem = true;
    $ThumbnailCollection = array();
    while (false !== ($Item = readdir($FolderHandle))) {
       $RecordItem = true;
       if ($Item == "."
           || $Item == ".."
           || in_array($Config->CurrentBrowsingDirectory."/".$Item, $Config->FullyQualifiedHideFiles)
       ) $RecordItem = false;
       if ($Config->DisplayHiddenFiles == "false" && $Item == $Config->SelfUrl) $RecordItem = false;
       if ($Config->DisplayHiddenFiles == "false" && substr($Item,0,1) == "_") $RecordItem = false;
       if ($Config->UseThumbnails && substr($Item,0,7) == "_thumb.") {
          // Don't record the current item in the regular file collections, dump it into a thumbnail collection
          $RecordItem = false;
          $ThumbnailCollection[] = $Item;
       }
       
       if ($RecordItem) {
          <strong>// If dealing with a folder, add it to the folder collection
          if (is_dir($Config->CurrentBrowsingDirectory."/".$Item)) {
             $FolderCollection[] = $Item;</strong>
          // If not dealing with a folder, add it to the proper file collection
          } else {
             // Match the current file extension with an item in the extension library
             $CurrentExtension = GetExtension($Item);
             $KeyMatch = @$ExtensionLibrary[$CurrentExtension];
             
             // If the match came back positive, add the file to the collection
             if ($KeyMatch) {
                $FileCollections[$ExtensionLibrary[$CurrentExtension][0]]->AddFile($Item, filesize($Config->CurrentBrowsingDirectory."/".$Item), filemtime($Config->CurrentBrowsingDirectory."/".$Item), $ExtensionLibrary[$CurrentExtension][1]);
                
             // If the match came back false, attempt to add this file to the wildcard group
             } elseif ($ExtensionLibrary["*"]) {
                $FileCollections[$ExtensionLibrary["*"][0]]->AddFile($Item, filesize($Config->CurrentBrowsingDirectory."/".$Item), filemtime($Config->CurrentBrowsingDirectory."/".$Item), $ExtensionLibrary["*"][1], $ExtensionLibrary["*"]);
                   
             } // Ignore all other files
          }
       }
    }
    So, as you can see (check out the stuff in bold), I only ever look at the directory currently being browsed. In order to list all of the directories underneath this one, you'll need to add another chunk of code below this that now gets a handle on each of the items in the FolderCollection array and get's THEIR contents. You'll only be interested in the folders within them, and you'll need to add each of those to your foldercollection as well (properly related to the current browsing directory, of course).

    After that, there is still a big chunk of work to be done with making sure that when you click a folder, it takes you to that folder. It's not a small task, but it is possible, of course.
This discussion has been closed.