use App\Models\FluidbookPublication;
use App\Models\User;
use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
+use Cubist\Excel\ExcelToArray;
use Cubist\Util\Files\Files;
use Fluidbook\Tools\FluidbookFontToWoff;
use Illuminate\Http\UploadedFile;
Route::match(['get'], $segment . '/{id}/edit/links/versions', $controller . '@getLinkVersions');
Route::match(['get'], $segment . '/{id}/edit/links/versions/export/{version}', $controller . '@exportLinks');
Route::match(['post'], $segment . '/{id}/edit/links/import/merge', $controller . '@importLinksMerge');
+ Route::match(['post'], $segment . '/{id}/edit/links/import/automatic', $controller . '@automaticLinks');
Route::match(['post'], $segment . '/{id}/edit/links/import/replace', $controller . '@importLinks');
Route::match(['get'], $segment . '/{id}/edit/links/import/pdf', $controller . '@importLinksFromPDF');
Route::match(['post'], $segment . '/{id}/edit/links/move', $controller . '@moveLinks');
return response()->json(['success' => 'ok']);
}
+ protected function automaticLinks($fluidbook_id)
+ {
+ if (!FluidbookPublication::hasPermission($fluidbook_id)) {
+ abort(401);
+ }
+
+ /** @var UploadedFile $uploadedFile */
+ $uploadedFile = request()->file('file');
+ LinksData::getLinksAndRulers($fluidbook_id, $links, $rulers);
+
+ $rules = FluidbookPublication::withoutGlobalScopes()->find($fluidbook_id)->autolinkRule;
+
+ $type = $type = \Fluidbook\Tools\Links\Link::WEB;
+ $target = '_blank';
+ $toPrefix = '';
+ $toSuffix = '';
+ switch ($rules) {
+ case 'cart':
+ $type = \Fluidbook\Tools\Links\Link::CART;
+ $target = '';
+ case 'steelite':
+ $toSuffix = '?embed';
+ $target = '_popupiframe';
+ case 'web':
+ default:
+ break;
+ }
+
+ ExcelToArray::setCache(Files::mkdir('/tmp/exceltoarray'));
+ $excel = ExcelToArray::excelToAssoc($uploadedFile->getPathname());
+ dd($type, $target, $toSuffix, $excel);
+
+ LinksData::saveLinksInFile($fluidbook_id, backpack_user()->id, __("Ajouter des liens automatiques à partir du fichier :file", ['file' => $uploadedFile->getClientOriginalName()]) . ' ', $links, $rulers, [], []);
+ return response()->json(['success' => 'ok']);
+ }
+
protected function importLinksMerge($fluidbook_id)
{
if (!FluidbookPublication::hasPermission($fluidbook_id)) {
$this->_addSettingField('', FormSeparator::class);
$this->_addSettingField('linkFilePrefix', LongText::class, $this->__('Préfixer les liens de téléchargement'));
$this->_addSettingField('', FormSeparator::class);
- $this->_addSettingField('autolinkRule', SelectFromArray::class, $this->__('Règle pour l\'ajout des liens via excel'), ['options' => ['web' => 'Lien web', 'cart' => __('Lien panier'), 'steelite' => 'Steelite']]);
+ $this->_addSettingField('autolinkRule', SelectFromArray::class, $this->__('Règle pour l\'ajout des liens via excel'), ["default" => "web", 'options' => ['web' => 'Lien web', 'cart' => __('Lien panier'), 'steelite' => 'Steelite']]);
}
protected function _multimedia()
'upload_save_message'=>__("Après l'upload d'un fichier"),
'restore_version_tooltip'=>__('Restaurer cette version'),
'export_version_tooltip'=>__('Exporter les liens au format xlsx'),
+ 'automatic_links_from_excel'=>__('Détecter des liens à partir d\'un excel'),
'delete_link'=>__('Supprimer le lien'),
'edit_image_link'=>__('Editer les liens de l\'image'),
'delete_selection'=>__('Supprimer la sélection'),
</div>
<a href="#" data-icon="import-links-pdf" data-action="links.importFromPDF"
data-tooltip="{{__('Importer les liens du PDF')}}"></a>
+ <div data-icon="automatic-links"
+ data-tooltip="{{__('Ajouter automatique des liens à partir d\'un excel')}}">
+ <form class="importExcel"
+ data-save-before-submit="{{__("Sauvegarde avant l'ajout automatique à partir d'un excel")}}"
+ action="/fluidbook-publication/{{$fbdata['id']}}/edit/links/import/automatic" method="post"
+ enctype="multipart/form-data">
+ <input type="file"
+ accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
+ name="file"/>
+ </form>
+ </div>
<a id="linkeditor-export-latest" download="links_{{$fbdata['id']}}.xlsx"
href="/fluidbook-publication/{{$fbdata['id']}}/edit/links/versions/export/latest"
data-icon="export-links" data-tooltip="Exporter les liens"></a>