Пример #1
0
 function DefineProperties()
 {
     $this->DefineBrowsingDirectory();
     // Create some holder variables
     $this->FolderCollection = array();
     $this->ImageCollection = new FileCollection();
     $ThumbnailCollection = array();
     // RETRIEVE FILES
     // Loop through files in the current browsing directory
     $FolderKey = 0;
     $FolderHandle = opendir($this->CurrentBrowsingDirectory);
     $CurrentExtension = "";
     $RecordItem = true;
     while (false !== ($Item = readdir($FolderHandle))) {
         $RecordItem = true;
         if ($Item == "." || $Item == ".." || $Item == $this->SelfUrl || in_array($this->CurrentBrowsingDirectory . "/" . $Item, $this->FullyQualifiedHideFiles)) {
             $RecordItem = false;
         }
         if ($RecordItem) {
             // If dealing with a folder, add it to the folder collection
             if (is_dir($this->CurrentBrowsingDirectory . "/" . $Item)) {
                 $this->FolderCollection[] = $Item;
                 // If not dealing with a folder, add it to the proper file collection
             } elseif (substr($Item, 0, 7) == $this->ThumbPrefix) {
                 $ThumbnailCollection[] = $Item;
             } elseif (substr($Item, 0, 1) == "_") {
                 // Ignore "hidden" files
             } elseif (in_array($this->GetFileType($this->CurrentBrowsingDirectory, $Item), $this->ThumbnailableFormats)) {
                 $this->ImageCollection->AddFile($Item, filesize($this->CurrentBrowsingDirectory . "/" . $Item), filemtime($this->CurrentBrowsingDirectory . "/" . $Item), "");
             }
         }
     }
     // BUILD THE PAGE ELEMENTS
     $ThumbedList = "";
     $NonThumbedList = "";
     // Create a parameters class to manage querystring values
     $Params = new Parameters();
     $Params->DefineCollection($_GET);
     $Params->Remove("smf");
     if ($this->FolderIDs == "") {
         $Params->Remove("did");
     }
     $FileCounter = 0;
     // Build the file listing
     // Get the sorted files
     $Files = $this->ImageCollection->GetFiles($this->SortBy, $this->SortDirection, $ThumbnailCollection);
     $ThumbBool = 0;
     $NonThumbBool = 0;
     if (count($Files) > 0) {
         for ($j = 0; $j < count($Files); $j++) {
             $FileCounter += 1;
             $CurrentFileName = $Files[$j]["Name"];
             $CurrentFileSize = $Files[$j]["Size"];
             $CurrentFileDate = $Files[$j]["Date"];
             $CurrentFileHandlerMethod = $Files[$j]["HandlerMethod"];
             if ($Files[$j]["ThumbnailPresent"]) {
                 $ThumbedList .= $this->FormatListItem($FileCounter, $CurrentFileName, $CurrentFileSize, $CurrentFileDate, $Params, $ThumbBool);
                 $ThumbBool = FlipBool($ThumbBool);
             } else {
                 $NonThumbedList .= $this->FormatListItem($FileCounter, $CurrentFileName, $CurrentFileSize, $CurrentFileDate, $Params, $NonThumbBool);
                 $NonThumbBool = FlipBool($NonThumbBool);
             }
         }
     }
     if ($NonThumbedList != "") {
         $NonThumbedList = $this->FormatImageList($NonThumbedList, "Images Without Thumbnails", "Images");
     }
     if ($ThumbedList != "") {
         $ThumbedList = $this->FormatImageList($ThumbedList, "Images With Thumbnails", "ThumbedImages");
     }
     $this->FileList = $NonThumbedList . $ThumbedList;
     // Define the current folder path
     $RootPath = substr($this->SelfWebPath, 0, strlen($this->SelfWebPath) - 1);
     $CurrentPath = "<a href=\"" . $RootPath . "/" . $this->SelfUrl . "\">" . str_replace("http://", "", $RootPath) . "</a>";
     $this->FolderList = "<div class=\"Container Folders\">\r\n\t\t\t<dl class=\"CurrentFolder\">\r\n\t\t\t\t<dt>Current Folder</dt>\r\n\t\t\t\t<dd>" . $CurrentPath . BuildPath($this->FolderNavigator, $this->SelfUrl, 0) . "</dd>\r\n\t\t\t</dl>";
     // Build the folder listing
     if (count($this->FolderCollection) > 0 || count($this->aFolderID) > 0) {
         // Sort the folders
         usort($this->FolderCollection, "strcasecmp");
         reset($this->FolderCollection);
         if ($this->SortDirection == "desc") {
             $this->FolderCollection = array_reverse($this->FolderCollection);
         }
         $Params->Remove("fid");
         $this->FolderList .= "<h2>Folders</h2>\r\n\t\t\t\t<ul class=\"FolderList\">\r\n";
         // Display the updirectory link if necessary
         if (count($this->aFolderID) > 0) {
             $ParentFolder = "";
             if (count($this->aFolderID) > 1) {
                 for ($i = 0; $i < count($this->aFolderID) - 1; $i++) {
                     $ParentFolder = FormatDelimitedString($ParentFolder, $this->aFolderID[$i], $this->FolderDelimiter);
                 }
                 $Params->Set("did", $ParentFolder);
             } else {
                 $Params->Remove("did");
             }
             $this->FolderList .= "<li><a href=\"" . $this->SelfUrl . $Params->GetQueryString() . "\">Parent Folder</a></li>\r\n";
         }
         // Add actual folders
         for ($i = 0; $i < count($this->FolderCollection); $i++) {
             $Params->Set("did", FormatDelimitedString($this->FolderIDs, $i, $this->FolderDelimiter));
             $this->FolderList .= "<li><a href=\"" . $this->SelfUrl . $Params->GetQueryString() . "\">" . $this->FolderCollection[$i] . "</a></li>\r\n";
         }
         $this->FolderList .= "</ul>";
     }
     $this->FolderList .= "</div>";
 }
Пример #2
0
function CheckForFolder($Path, $FolderKey, &$Config)
{
    $FolderHandle = opendir($Path);
    $aCurrentSubFolders = array();
    // Only look at folders
    while (false !== ($Item = readdir($FolderHandle))) {
        if ($Item != '.' && $Item != '..' && is_dir($Path . "/" . $Item) && !in_array($Path . "/" . $Item, $Config->FullyQualifiedHideFiles)) {
            $aCurrentSubFolders[] = $Item;
        }
    }
    closedir($FolderHandle);
    // Sort the folders according to the config setting
    usort($aCurrentSubFolders, "strcasecmp");
    reset($aCurrentSubFolders);
    if ($Config->SortDirection == "desc") {
        $aCurrentSubFolders = array_reverse($aCurrentSubFolders);
    }
    // If the key supplied is less than the total count of folders found, append the folder name to the path
    if ($FolderKey < count($aCurrentSubFolders)) {
        $Config->FolderNavigatorLocation = FormatDelimitedString($Config->FolderNavigatorLocation, $FolderKey, $Config->FolderDelimiter);
        $Config->FolderNavigator[] = array($aCurrentSubFolders[$FolderKey], $Config->FolderNavigatorLocation);
        return AppendFolder($Path, $aCurrentSubFolders[$FolderKey]);
    } else {
        return false;
    }
}
Пример #3
0
            }
            $Params->Set("did", $ParentFolder);
        } else {
            $Params->Remove("did");
        }
        $FileList .= "<li><a href=\"" . CurrentUrl() . $Params->GetQueryString() . "\">Parent Folder</a></li>";
    }
    // Sort the folders
    usort($FolderCollection, "strcasecmp");
    reset($FolderCollection);
    if ($Config->SortDirection == "desc") {
        $FolderCollection = array_reverse($FolderCollection);
    }
    // Add actual folders
    for ($i = 0; $i < count($FolderCollection); $i++) {
        $Params->Set("did", FormatDelimitedString($Config->FolderIDs, $i, $Config->FolderDelimiter));
        $FileList .= "<li>\r\n         <a href=\"" . CurrentUrl() . $Params->GetQueryString() . "\">" . $FolderCollection[$i] . "</a>\r\n         </li>";
    }
    $FileList .= "</ul>\r\n";
}
// ------------------
// 5. WRITE PAGE HEAD
// ------------------
// Define the current folder path
$RootPath = substr(CurrentWebPath(), 0, strlen(CurrentWebPath()) - 1);
$CurrentPath = "<a href=\"{$RootPath}?fpp=" . $Config->FilesPerPage . "\">" . str_replace("http://", "", $RootPath) . "</a>";
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-ca\">\r\n   <head>\r\n   <title>" . $Config->PageTitle . "</title>\r\n\r\n   <link rel=\"stylesheet\" type=\"text/css\" href=\"" . $Config->StyleUrl . "\" />\r\n\r\n   <script language=\"Javascript\" type=\"text/javascript\">\r\n      //<![CDATA[\r\n      var BodyLoaded = 0;\r\n      if (document.all && !document.getElementById) {\r\n          document.getElementById = function(id) {\r\n               return document.all[id];\r\n          }\r\n      }\r\n      function copy(inElement) {\r\n         if (inElement.createTextRange) {\r\n            var range = inElement.createTextRange();\r\n            if (range && BodyLoaded==1) range.execCommand('Copy');\r\n         } else {\r\n            var flashcopier = 'flashcopier';\r\n            if(!document.getElementById(flashcopier)) {\r\n               var divholder = document.createElement('div');\r\n               divholder.id = flashcopier;\r\n               document.body.appendChild(divholder);\r\n            }\r\n            document.getElementById(flashcopier).innerHTML = '';\r\n            var divinfo = '<embed src=\"_clipboard.swf\" FlashVars=\"clipboard='+escape(inElement.value)+'\" width=\"0\" height=\"0\" type=\"application/x-shockwave-flash\"></embed>';\r\n            document.getElementById(flashcopier).innerHTML = divinfo;\r\n         }\r\n      }\r\n      function writeImage(imageName, imageWidth, imageHeight, imageID) {\r\n         var windowWidth = getWindowWidth();\r\n         if (windowWidth < imageWidth) {\r\n            var newWidth = windowWidth - 40;\r\n            var newHeight = Math.round((newWidth*imageHeight)/(imageWidth+40));\r\n\r\n            document.write('<span id=\"sm'+imageID+'\">'\r\n               +'<div class=\"Notice\">Note: this image has been shrunk to fit on your screen. <a href=\"Javascript:resizeImage('+imageID+');\">Click here to view the image at actual size.</a></div>'\r\n               +'<img src=\"'+imageName+'\" height=\"'+newHeight+'\" width=\"'+newWidth+'\" />'\r\n            +'</span>'\r\n            +'<span id=\"lg'+imageID+'\" style=\"display: none;\">'\r\n               +'<div class=\"Notice\">Note: this image does not fit on your screen. <a href=\"Javascript:resizeImage('+imageID+');\">Click here to fit the image to your screen.</a></div>'\r\n               +'<img src=\"'+imageName+'\" height=\"'+imageHeight+'\" width=\"'+imageWidth+'\" />'\r\n            +'</span>');\r\n         } else {\r\n            document.write('<img src=\"'+imageName+'\" height=\"'+imageHeight+'\" width=\"'+imageWidth+'\" />');\r\n         }\r\n      }\r\n      function getWindowWidth() {\r\n         var myWidth = 0;\r\n         if( typeof( window.innerWidth ) == 'number' ) {\r\n            myWidth = window.innerWidth - 20;\r\n         } else if (document.documentElement && document.documentElement.clientWidth) {\r\n            myWidth = document.documentElement.clientWidth;\r\n         } else if (document.body && document.body.clientWidth) {\r\n            myWidth = document.body.clientWidth;\r\n         } else {\r\n            myWidth = screen.width;\r\n         }\r\n         return myWidth;\r\n      }\r\n      function resizeImage(imageID, link) {\r\n         var lg = document.getElementById('lg'+imageID);\r\n         var sm = document.getElementById('sm'+imageID);\r\n         if (lg && sm) {\r\n            switchVisibility(lg);\r\n            switchVisibility(sm);\r\n         }\r\n      }\r\n      function switchVisibility(object) {\r\n         if (object.style.display == 'none') {\r\n            object.style.display = 'block';\r\n         } else {\r\n            object.style.display = 'none';\r\n         }\r\n      }\r\n      //]]>\r\n   </script>\r\n   </head>\r\n   <body onload=\"BodyLoaded=1\">\r\n      <div class=\"SiteContainer\">\r\n      <div class=\"Head\">\r\n         <h1>" . $Config->PageTitle . "</h1>\r\n         " . $CurrentPath . BuildPath($Config->FolderNavigator, $Config->FilesPerPage) . "\r\n      </div>";
// ------------------------------------
// 6. CONFIGURE & WRITE NAVIGATION MENU
// ------------------------------------
$TotalItemCount = ForceInt(count($aItemHistory), 0);