}
$packager = Packager::package($this->entry->id, $this->version, $zip);
$packager->makePackage($zip);
- Log::debug($this->action . '/' . $this->entry->id . '/' . $this->version . '/' . get_class($packager) . '///' . $packager->getFinalURL() . '//' . $packager->getFinalPath());
$url = $packager->getFinalURL();
if ($url) {
return $url;
protected function getBaseFile()
{
- return $this->type . '-' . date('Ymdhis', $this->_time) . '-' . $this->escapeTitle();
+ return $this->type . '-' . $this->book_id . '-' . date('Ymdhis', $this->_time) . '-' . $this->escapeTitle();
}
protected function getDownloadURL($ext = '')
{
- $res = '/download/' . $this->getBaseFile();
+ $res = $this->getBaseFile();
if ($ext != '') {
$res .= '.' . $ext;
}
- return url('packager' . $res);
+ return url('fluidbook-publication/' . $this->book_id . '/download/' . $res);
}
protected function escapeTitle()
use App\Fluidbook\Packager\Download;
use App\Models\FluidbookPublication;
+use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
use Illuminate\Support\Facades\Route;
use Prologue\Alerts\Facades\Alert;
protected function setupDownloadRoutes($segment, $routeName, $controller)
{
Route::match(['get'], $segment . '/{id}/delivery', $controller . '@delivery');
- Route::match(['get'], $segment . '/{id}/{action}/{version}', $controller . '@download');
+ Route::match(['get'], $segment . '/{id}/package/{action}/{version}', $controller . '@package');
+ Route::match(['get'], $segment . '/{id}/download/{file}', $controller . '@download');
}
protected function setupDownloadDefaults()
}
}
+ protected function download($id, $file)
+ {
+ $e = explode('-', $file);
+ if ($e[1] != $id) {
+ abort(404, __('Erreur de correspondance du fichier'));
+ }
+ if (!FluidbookPublication::hasPermission($id)) {
+ abort(401, __('Ce fichier ne peut pas être téléchargée'));
+ }
+ $path = protected_path('fluidbookpublication/packager/download/' . $file);
+ if (!file_exists($path)) {
+ abort(404, __('Le fichier n\'existe pas'));
+ }
+ return XSendFileController::sendfile($path);
+ }
+
/**
* @throws \Exception
*/
- protected function download($id, $action, $version)
+ protected function package($id, $action, $version)
{
if (!in_array($action, ['download', 'install_hosting', 'install_ftp', 'scormcloud'])) {
abort(404, __('Cette action n\'est pas disponible'));
@php
$allVersions=can('fluidbook-publication:download:all-versions');
+ $base=$crud->route.'/'.$entry->id;
+ $basePackage=$base.'/package';
$actions=[
'delivery'=>
[
'label'=>__('Page de téléchargement'),
- 'url'=>$crud->route.'/'.$entry->id.'/delivery',
+ 'url'=>$base.'/delivery',
],
];
foreach (\App\Models\FluidbookPublication::getDownloadVersions() as $k=>$v) {
if($allVersions || $entry->{'download_'.$k}){
$actions['download_'.$k]=[
'label'=>$v['label'],
- 'url'=>$crud->route.'/'.$entry->id.'/download/'.$k
+ 'url'=>$basePackage.'/download/'.$k
];
}
}
$actions['sep_install']='---------';
$actions['install_hosting']=[
'label'=>__('Installer sur le serveur d\'hébergement'),
- 'url'=>$crud->route.'/'.$entry->id.'/install_hosting/online',
+ 'url'=> $basePackage.'/install_hosting/online',
];
$actions['install_ftp']=[
'label'=>__('Installer sur un serveur FTP'),
- 'url'=>$crud->route.'/'.$entry->id.'/install_ftp/online',
+ 'url'=> $basePackage.'/install_ftp/online',
];
if($entry->scorm_enable){
$actions['scormcloud']=['label'=>__('Tester sur SCORM Cloud'),
- 'url'=>$crud->route.'/'.$entry->id.'/scormcloud/scorm'
+ 'url'=> $basePackage.'/scormcloud/scorm'
];
}
}