- '/data/extranet/ftp/:/application/ftp/'
- '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/protected/fluidbookpublication/docs/'
- '/data/extranet/www/fluidbook/books/working/:/application/protected/fluidbookpublication/working/'
+ - '/data/extranet/www/fluidbook/books/links/:/application/protected/fluidbookpublication/links/'
- '/home/extranet:/home/extranet'
- '/data/extranet:/data/extranet'
- '/mnt:/mnt'
- '/data/extranet/ftp/:/application/ftp/'
- '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/protected/fluidbookpublication/docs/'
- '/data/extranet/www/fluidbook/books/working/:/application/protected/fluidbookpublication/working/'
+ - '/data/extranet/www/fluidbook/books/links/:/application/protected/fluidbookpublication/links/'
- '/home/extranet:/home/extranet'
- '/data/extranet:/data/extranet'
- '/mnt:/mnt'
--- /dev/null
+<?php
+
+namespace App\Console\Commands;
+
+use App\Fluidbook\Links;
+use App\Models\Traits\FluidbookPlayerBranches;
+use Cubist\Backpack\Console\Commands\CubistCommand;
+use Cubist\Util\PHP;
+
+class FluidbookLinksFromPDF extends CubistCommand
+{
+ protected $signature = 'fluidbook:links:importfrompdf {id}';
+ protected $description = 'Import links from PDF';
+
+ public function handle()
+ {
+ Links::addLinksFromPDF($this->argument('id'));
+ }
+
+}
$links = Link::encryptLinks($links);
}
-
self::_correctImageSpecialLinks($links);
}
}
$links[] = $link;
}
-
$i++;
}
public static function getLinksDir($book_id)
{
- return Files::mkdir('/data/extranet/www/fluidbook/books/links/' . $book_id);
+ return Files::mkdir(protected_path('fluidbookpublication/links/' . $book_id));
}
public static function getLinksVersions($book_id)
public static function addLinksFromPDF($book_id)
{
/** @var FluidbookPublication $book */
- $book = FluidbookPublication::withoutGlobalScopes()->find($book_id);
+ $book = FluidbookPublication::find($book_id);
$booleans = array('video_loop', 'video_auto_start', 'video_controls', 'video_sound_on');
$numbers = ['left', 'top', 'width', 'height'];
$links = [];
-
- $pages = $book->getComposition();
-
- foreach ($pages as $page => $doc) {
- $fp = Gzip::fopen($book->getDocument($doc[0])->path('p' . $doc[1] . '.csv'));
+ foreach ($book->composition as $page => $doc) {
+ $fp = Gzip::fopen($book->getDocument($page)->path('links/p' . $doc[1] . '.csv'));
while (true) {
$line = fgetcsv($fp, 512, ';', '"');
// End of file
}
// Commentaire || ligne vide
- if (substr($line[0], 0, 1) == '#' || is_null($line[0])) {
+ if (str_starts_with($line[0], '#') || is_null($line[0])) {
continue;
}
$k = 0;
foreach ($cols as $col => $default) {
if (isset($line[$k])) {
- if (in_array($k, $numbers)) {
+ if (in_array($col, $numbers)) {
$link[$col] = (float)str_replace(',', '.', $line[$k]);
- } else if (in_array($k, $booleans)) {
+ } else if (in_array($col, $booleans)) {
$link[$col] = ($line[$k] == '1');
} else {
$link[$col] = $line[$k];
fclose($fp);
}
- self::saveLinksInFile($book_id, backpack_user()->id, 'Links imported from PDF', $links);
+ self::saveLinksInFile($book_id, backpack_user() ? backpack_user()->id : 0, 'Links imported from PDF', $links);
}
public static function getLinksAndRulersFromExcelFile($path, &$links, &$rulers)
$characters = '0123456789abcdefghijklmnopqrstuvwxyz';
$randstring = '';
for ($i = 0; $i < 12; $i++) {
- $randstring = $characters[rand(0, 35)];
+ $randstring .= $characters[rand(0, 35)];
}
return $randstring;
}
public $z = 3;
protected $_lottieIDByHash = [];
- /**
- * @var FluidbookPublication
- */
- public $book;
public $pages;
public $theme;
public $devversion;
if ($this->fluidbookSettings->tabsHTML5 != '' && file_exists($this->wdir . '/' . $this->fluidbookSettings->tabsHTML5)) {
$ext = Files::getExtension($this->fluidbookSettings->tabsHTML5);
if ($ext === 'zip') {
- $links[] = [
+ $links['tabs'] = [
'page' => 'background',
'top' => 0,
'left' => 0,
'height' => 100,
'type' => 26,
'to' => $from,
- 'uid' => Link::generateUID()
+ 'uid' => Links::generateUID()
];
$anchorExists[$from] = $anchor;
$links[] = $anchor;
if (!isset($anchorExists[$from]) && isset($anchorExists[$to])) {
$anchor = $anchorExists[$to];
$anchor['to'] = $from;
- $anchor['uid'] = Link::generateUID();
+ $anchor['uid'] = Links::generateUID();
$anchorExists[$from] = $anchor;
$links[] = $anchor;
}
}
foreach ($linksToAdd as $lta) {
- /** @var $lta wsLink */
+ /** @var $lta Link */
// Keep this line because some properties of the link (like blend mode) are parsed with this function
$c = $lta->getHTMLContainer();
$css[] = $lta->getCSSContainer();
}
- $allpages = range(0, $this->fluidbookSettings->pages + 1);
+ $allpages = range(0, $this->getFluidbook()->getPagesNumber() + 1);
if ($this->fluidbookSettings->themeEnableAfterSearch) {
$allpages[] = 'aftersearch';
}