Ejemplo n.º 1
0
 public function initRepository()
 {
     if (is_array($this->pluginConf)) {
         $this->driverConf = $this->pluginConf;
     } else {
         $this->driverConf = array();
     }
     if ($this->getFilteredOption("PROBE_REAL_SIZE", $this->repository->getId()) == true) {
         // PASS IT TO THE WRAPPER
         ConfService::setConf("PROBE_REAL_SIZE", $this->getFilteredOption("PROBE_REAL_SIZE", $this->repository->getId()));
     }
     $create = $this->repository->getOption("CREATE");
     $path = SystemTextEncoding::toStorageEncoding($this->repository->getOption("PATH"));
     $recycle = $this->repository->getOption("RECYCLE_BIN");
     $chmod = $this->repository->getOption("CHMOD_VALUE");
     $wrapperData = $this->detectStreamWrapper(true);
     $this->wrapperClassName = $wrapperData["classname"];
     $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId();
     if ($create == true) {
         if (!is_dir($path)) {
             @mkdir($path, 0755, true);
         }
         if (!is_dir($path)) {
             throw new AJXP_Exception("Cannot create root path for repository (" . $this->repository->getDisplay() . "). Please check repository configuration or that your folder is writeable!");
         }
         if ($recycle != "" && !is_dir($path . "/" . $recycle)) {
             @mkdir($path . "/" . $recycle);
             if (!is_dir($path . "/" . $recycle)) {
                 throw new AJXP_Exception("Cannot create recycle bin folder. Please check repository configuration or that your folder is writeable!");
             } elseif (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
                 AJXP_Utils::winSetHidden($path . "/" . $recycle);
             }
         }
         $dataTemplate = $this->repository->getOption("DATA_TEMPLATE");
         if (!empty($dataTemplate) && is_dir($dataTemplate) && !is_file($path . "/.ajxp_template")) {
             $errs = array();
             $succ = array();
             $repoData = array('base_url' => $this->urlBase, 'wrapper_name' => $this->wrapperClassName, 'chmod' => $chmod, 'recycle' => $recycle);
             $this->dircopy($dataTemplate, $path, $succ, $errs, false, false, $repoData, $repoData);
             touch($path . "/.ajxp_template");
         }
     } else {
         if (!is_dir($path)) {
             throw new AJXP_Exception("Cannot find base path for your repository! Please check the configuration!");
         }
     }
     if ($recycle != "") {
         RecycleBinManager::init($this->urlBase, "/" . $recycle);
     }
 }