Ejemplo n.º 1
0
 /**
  * Gets the required settings to initialize the JS file manager
  * @return array
  */
 public function js_config()
 {
     $settings = array('allow_upload' => $this->allow_upload, 'allow_editing' => $this->allow_editing, 'allow_folders' => $this->allow_folders, 'allow_paste_upload' => $this->allow_paste_upload, 'max_file_size' => $this->max_size, 'max_file_size_readable' => jQueryFM_Helper::format_size($this->max_size), 'accept_file_types' => $this->accept_file_types, 'ajax_endpoint' => $this->ajax_endpoint, 'icons_url' => $this->icons_url, 'drag_selector' => $this->drag_selector, 'force_downloads' => $this->force_downloads, 'strings' => $this->strings);
     if ($this->preload) {
         $files = array();
         foreach ($this->provider->read() as $f) {
             $files[] = $this->_export_file($f);
         }
         $settings['files'] = $files;
     }
     return $settings;
 }
Ejemplo n.º 2
0
 /**
  *  {@inheritDoc}
  */
 public function download(FileManagerItem $file, $force = true)
 {
     if (!file_exists($file->path)) {
         return false;
     }
     if ($force) {
         header("Content-Type: application/octet-stream");
         header('Content-Disposition: attachment; filename=' . $file->name);
     } else {
         $mime = jQueryFM_Helper::ext2mime(pathinfo($file->name, PATHINFO_EXTENSION));
         header("Content-Type: {$mime}");
         header('Content-Disposition: inline
         ; filename=' . $file->name);
     }
     header('Content-Transfer-Encoding: binary');
     header('Content-Length: ' . $file->size);
     //Cache control
     $mod_date = filemtime($file->path);
     $mod_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false;
     if ($mod_date && $mod_since && strtotime($mod_since) >= $mod_date) {
         header('HTTP/1.1 304 Not Modified');
         return true;
     } else {
         header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $mod_date) . ' GMT');
         header('Pragma: public');
     }
     ob_clean();
     flush();
     readfile($file->path);
     return true;
 }