Source of file FilePageController.php
Size: 2,419 Bytes - Last Modified: 2021-12-23T10:11:15+00:00
/var/www/docs.ssmods.com/process/src/code/FilePageController.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 | <?php namespace PurpleSpider\FileListing; use SilverStripe\ORM\DataObject; use SilverStripe\Assets\File; use PageController; class FilePageController extends PageController { /** * Gets the current folder ID from query string and validates * it * * @return boolean */ public function getCurrentFolderID() { $folderID = $this->request->getVar('fid'); if ($folderID) { return filter_var($folderID, FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE); } return false; } /** * Returns files/folders for the current folder * * @return SS_List */ public function Listing($ParentID = null) { if (!$this->FolderID) { return false; } $currentFolderID = $this->getCurrentFolderID(); $filter = []; $sort = $this->SortSubFolders; if ($currentFolderID) { if (File::get()->byID($currentFolderID)) { $ParentID = $currentFolderID; } } else { $ParentID = $this->FolderID; } if ($ParentID == $this->FolderID) { $sort = $this->SortTopLevel; } return File::get() ->filter("ParentID", $ParentID) ->sort($sort); } /** * Checks if not at the root folder * * @return boolean */ public function NotRoot() { $currentFolderID = $this->getCurrentFolderID(); if ($currentFolderID) { if (File::get()->byID($currentFolderID)) { return true; } } return false; } /** * Gets current folder from $_GET['fid'] * * @return void */ public function CurrentFolder() { $currentFolderID = $this->getCurrentFolderID(); if ($currentFolderID) { return File::get()->byID($currentFolderID); } return false; } // Creates link to go back to parent folder public function BackLink() { if ($this->CurrentFolder()) { if ($this->CurrentFolder()->ParentID != $this->FolderID) { return "?fid=".$this->CurrentFolder()->ParentID; } else { return "?"; } } else { return false; } } } |