Example #1
0
 function RetrieveConfigurationPropertiesFromXml($Path)
 {
     $FauxContext = "0";
     if ($this->ConfigFile == "") {
         $this->ErrorManager->AddError($FauxContext, $this->Name, "RetrieveConfigurationPropertiesFromXml", "You must supply a path to the configuration file");
     }
     // Retrieve config file contents
     $File = new File();
     $File->Name = $this->ConfigFile;
     $File->Path = $Path;
     $FileManager = new FileManager();
     $FileManager->ErrorManager =& $this->ErrorManager;
     $File = $FileManager->Get($File);
     // If there were errors retrieving the config file and we're in the CWD, report an error
     if ($this->ErrorManager->ErrorCount > 0 && $Path == $this->CurrentWorkingDirectory) {
         $this->ErrorManager->Clear();
         $this->ErrorManager->AddError($FauxContext, $this->Name, "RetrieveConfigurationPropertiesFromXml", "The root configuration file could not be found/read (_config.xml).");
         // If failed to retrieve the file from a non-root directory,
         // just accept the root file
     } elseif ($this->ErrorManager->ErrorCount > 0) {
         $this->ErrorManager->Clear();
         // If no errors occurred, continue to retrieve new configuration settings
     } else {
         // Create an XML Parser to retrieve configuration settings
         $XMan = new XmlManager();
         $XMan->ErrorManager =& $this->ErrorManager;
         $MyConfig = $XMan->ParseNode($File->Body);
         if ($MyConfig && $this->ErrorManager->ErrorCount == 0) {
             $this->StyleUrl = $XMan->GetNodeValueByName($MyConfig, "StyleUrl");
             $this->PageTitle = $XMan->GetNodeValueByName($MyConfig, "PageTitle");
             $this->PageIntroduction = $XMan->GetNodeValueByName($MyConfig, "PageIntroduction");
             $this->PageIntroduction = str_replace("[", "<", $this->PageIntroduction);
             $this->PageIntroduction = str_replace("]", ">", $this->PageIntroduction);
             $this->PageIntroduction = str_replace("\n", "<br />", $this->PageIntroduction);
             $this->DisplayHiddenFiles = $XMan->GetNodeValueByName($MyConfig, "DisplayHiddenFiles");
             $this->BrowseSubFolders = $XMan->GetNodeValueByName($MyConfig, "BrowseSubFolders");
             $this->SortBy = $XMan->GetNodeValueByName($MyConfig, "SortBy");
             $this->SortDirection = $XMan->GetNodeValueByName($MyConfig, "SortDirection");
             $this->DateFormat = $XMan->GetNodeValueByName($MyConfig, "DateFormat");
             $this->UsePageIntroductionInSubFolders = ForceBool($XMan->GetNodeValueByName($MyConfig, "UsePageIntroductionInSubFolders"), false);
             $this->PluginHeight = ForceInt($XMan->GetNodeValueByName($MyConfig, "PluginHeight"), $this->PluginHeight);
             $this->PluginWidth = ForceInt($XMan->GetNodeValueByName($MyConfig, "PluginWidth"), $this->PluginWidth);
             $this->FilesPerPage = ForceIncomingInt("fpp", ForceInt($XMan->GetNodeValueByName($MyConfig, "FilesPerPage"), $this->FilesPerPage));
             $this->MaxFilesPerPage = ForceInt($XMan->GetNodeValueByName($MyConfig, "MaxFilesPerPage"), $this->MaxFilesPerPage);
             $this->FitImagesToPage = ForceBool($XMan->GetNodeValueByName($MyConfig, "FitImagesToPage"), $this->FitImagesToPage);
             $this->UseThumbnails = ForceBool($XMan->GetNodeValueByName($MyConfig, "UseThumbnails"), $this->UseThumbnails);
             $this->HideFiles = explode(",", $XMan->GetNodeValueByName($MyConfig, "HideFiles"));
             for ($i = 0; $i < count($this->HideFiles); $i++) {
                 $this->FullyQualifiedHideFiles[] = $this->CurrentBrowsingDirectory . "/" . $this->HideFiles[$i];
             }
         }
     }
     return $this->ErrorManager->Iif();
 }