use Cubist\Backpack\Magic\Fields\Integer;
use Cubist\Backpack\Magic\Fields\SelectFromArray;
use Cubist\Backpack\Magic\Operations\CreateOperation;
+use Cubist\Excel\Excel;
+use Cubist\Excel\ExcelToArray;
use Cubist\Util\ArrayUtil;
use Cubist\Util\Files\Files;
use Cubist\Util\Graphics\Image;
for ($i = 1; $i <= $this->getPagesNumber(); $i++) {
$res[$i] = [];
}
+ // Get anchors from links
$this->getLinksAndRulers($links, $rulers);
foreach ($links as $link) {
if ($link['type'] !== Link::ANCHOR && $link['type'] !== Link::PAGE_LABEL) {
}
$res[$link['page']][] = $link['to'];
}
+ // Get anchors from Excel file
+ $anchors = $this->getAnchorsFromExcel();
+ foreach ($anchors as $anchor => $page) {
+ if (!isset($res[$page])) {
+ continue;
+ }
+ $res[$page][] = $anchor;
+ }
return $res;
}
- public function getPreviewURL(){
- return route('fluidbook_preview',['version'=>'online','id'=>$this->id,'hash'=>$this->hash]);
+ public function getAnchorsFromExcel()
+ {
+ $res = [];
+ if (!$this->anchors) {
+ return $res;
+ }
+ $file = $this->getAssetDir() . '/' . $this->anchors;
+ if (!file_exists($file)) {
+ return $res;
+ }
+
+ ExcelToArray::setCache(protected_path('fluidbookpublication/cache/exceltoarray'));
+ $contents = ExcelToArray::excelToArrayFirstSheet($file);
+
+ foreach ($contents as $row) {
+ $page = trim($row[0]);
+ if (!is_numeric($page)) {
+ continue;
+ }
+ $page = (int)$page;
+ $name = trim($row[1]);
+ if ($page >= 0 && $page <= $this->getPagesNumber()) {
+ $res[$name] = $page;
+ }
+ }
+ return $res;
+
+
+ }
+
+ public function getPreviewURL()
+ {
+ return route('fluidbook_preview', ['version' => 'online', 'id' => $this->id, 'hash' => $this->hash]);
}
}
$this->_audioplayer();
$this->_downloadPortions();
$this->_articles();
+ $this->_anchors();
$this->_assets();
}
]);
$this->addSettingField('facebook_image', FilesOrURL::class, $this->__('Miniature affichée'), [
'v2' => '{"type":"freefile","default":"","editable":true,"label":"\\u00a7!\\u00a7Miniature affich\\u00e9e!\\u00a7!","fileFilter":{"name":"\\u00a7!\\u00a7Images!\\u00a7! (*.jpg, *.png)","extensions":"*.jpg;*.jpeg;*.png"}}',
- 'accept' => [
- 0 => '.jpg',
- 1 => '.jpeg',
- 2 => '.png',
- ],
+ 'accept' => self::$acceptImages,
]);
$this->addSettingField('twitter_description', Textarea::class, $this->__('Contenu Partage court'), [
'v2' => '{"type":"textarea","default":"%title% : %short%","editable":true,"label":"\\u00a7!\\u00a7Contenu Partage court!\\u00a7!","hint":"\\u00a7!\\u00a7Contenu du partag\\u00e9 sur les partages courts!\\u00a7!"}',
$this->addSettingField('section_splash', FormSection::class, $this->__('Ecran de chargement'));
$this->addSettingField('splashImage', FilesOrURL::class, $this->__('Image'), [
'v2' => '{"type":"freefile","default":"","editable":true,"label":"\\u00a7!\\u00a7Image!\\u00a7!","grade":3,"fileFilter":{"name":"\\u00a7!\\u00a7Images!\\u00a7! (*.jpg, *.png)","extensions":"*.jpg;*.jpeg;*.png"}}',
- 'accept' => [
- 0 => '.jpg',
- 1 => '.jpeg',
- 2 => '.png',
- ],
+ 'accept' => self::$acceptImages,
]);
$this->addSettingField('splashURL', LongText::class, $this->__('URL'), [
'v2' => '{"type":"text","default":"","editable":true,"label":"\\u00a7!\\u00a7URL!\\u00a7!","grade":3}',
}
+ protected function _anchors()
+ {
+ $this->addSettingField('section_anchors', FormSection::class, $this->__('Ancres'));
+ $this->addSettingField('anchors', FilesOrURL::class, $this->__('Définir les ancres'), [
+ 'v2' => '{"type":"freefile","default":"","editable":true,"label":"\\u00a7!\\u00a7Ancres!\\u00a7!","fileFilter":{"name":"\\u00a7!\\u00a7Fichier Excel!\\u00a7! (.xlsx)","extensions":"*.xlsx"}}',
+ 'accept' => self::$acceptXLSX,
+ 'hint' => __('Colonne A : numéro de page physique, Colonne B : nom de l\'ancre')
+ ]);
+ }
+
protected function _archives()
{
$this->addSettingField('section_archives', FormSection::class, $this->__('Archives'));
$this->addSettingField('externalArchives', FilesOrURL::class, $this->__('Archives'), [
'v2' => '{"type":"freefile","default":"","editable":true,"label":"\\u00a7!\\u00a7Archives!\\u00a7!","grade":3,"fileFilter":{"name":"\\u00a7!\\u00a7Images!\\u00a7! (*.jpg, *.png)","extensions":"*.jpg;*.jpeg;*.png"}}',
- 'accept' => [
- 0 => '.jpg',
- 1 => '.jpeg',
- 2 => '.png',
- ],
+ 'accept' => self::$acceptImages,
]);
$this->addSettingField('archivesLabel', LongText::class, $this->__('Label'), [
'v2' => '{"type":"text","default":"","editable":true,"label":"\\u00a7!\\u00a7Label!\\u00a7!","grade":5}',
$this->addSettingField('', FormSeparator::class);
$this->addSettingField('cartHeaderImage', FilesOrURL::class, $this->__('Header panier'), [
'v2' => '{"type":"freefile","default":"","editable":true,"label":"\\u00a7!\\u00a7Header panier!\\u00a7!","grade":3,"fileFilter":{"name":"\\u00a7!\\u00a7Images!\\u00a7! (*.jpg, *.png)","extensions":"*.jpg;*.jpeg;*.png"},"dir":"commerce"}',
- 'accept' => [
- 0 => '.jpg',
- 1 => '.jpeg',
- 2 => '.png',
- ],
+ 'accept' => self::$acceptImages,
'destination' => 'commerce',
]);
$this->addSettingField('cartHeaderMobileImage', FilesOrURL::class, $this->__('Header panier (mobile)'), [
'v2' => '{"type":"freefile","default":"","editable":true,"label":"\\u00a7!\\u00a7Header panier (mobile)!\\u00a7!","grade":3,"fileFilter":{"name":"\\u00a7!\\u00a7Images!\\u00a7! (*.jpg, *.png)","extensions":"*.jpg;*.jpeg;*.png"},"dir":"commerce"}',
- 'accept' => [
- 0 => '.jpg',
- 1 => '.jpeg',
- 2 => '.png',
- ],
+ 'accept' => self::$acceptImages,
'destination' => 'commerce',
]);
$this->addSettingField('cartExtraSettings', Textarea::class, $this->__('Paramètres panier'), [