namespace App\Fluidbook;
+use App\Models\FluidbookPublication;
use App\Models\User;
use App\Util\wsDAOBook;
use App\Util\wsDocument;
use Cubist\Util\ArrayUtil;
use Cubist\Util\Files\Files;
+use Cubist\Util\Gzip;
use Cubist\Util\Str;
use Fluidbook\Tools\Links\Link;
use PhpOffice\PhpSpreadsheet\Cell\DataType;
public static function addLinksFromPDF($book_id)
{
- global $core;
-
- $daoBook = new wsDAOBook($core->con);
- $pages = $daoBook->getPagesOfBook($book_id);
+ /** @var FluidbookPublication $book */
+ $book = FluidbookPublication::withoutGlobalScopes()->find($book_id);
$booleans = array('video_loop', 'video_auto_start', 'video_controls', 'video_sound_on');
$numbers = ['left', 'top', 'width', 'height'];
$links = [];
- foreach ($pages as $page => $info) {
- $csv = wsDocument::getDir($info['document_id']) . '/p' . $info['document_page'] . '.csv';
- if (!file_exists($csv) && file_exists($csv . '.gz')) {
- $csv = 'compress.zlib://' . $csv . '.gz';
- } elseif (!file_exists($csv)) {
- continue;
- }
-
- $newformat = (filemtime($csv) > 1363685416);
-
- $fp = fopen($csv, 'rb');
+ $pages = $book->getComposition();
+ foreach ($pages as $page => $doc) {
+ $fp = Gzip::fopen($book->getDocument($doc[0])->path('p' . $doc[1] . '.csv'));
while (true) {
$line = fgetcsv($fp, 512, ';', '"');
// End of file
}
$link = [];
- if ($newformat) {
- $cols = array('page' => '', 'left' => '', 'top' => '', 'width' => '', 'height' => '', 'type' => '', 'to' => '', 'target' => '_blank', 'video_loop' => true, 'video_auto_start' => true, 'video_controls' => true, 'video_sound_on' => true, 'infobulle' => '', 'numerotation' => 'physical', "inline" => true);
- } else {
- $cols = array('page' => '', 'type' => '', 'to' => '', 'left' => '', 'top' => '', 'width' => '', 'height' => '', 'target' => '_blank', 'video_loop' => true, 'video_auto_start' => true, 'video_controls' => true, 'video_sound_on' => true, 'infobulle' => '', 'numerotation' => 'physical');
- }
-
-
+ $cols = array('page' => '', 'left' => '', 'top' => '', 'width' => '', 'height' => '', 'type' => '', 'to' => '', 'target' => '_blank', 'video_loop' => true, 'video_auto_start' => true, 'video_controls' => true, 'video_sound_on' => true, 'infobulle' => '', 'numerotation' => 'physical', "inline" => true);
$k = 0;
foreach ($cols as $col => $default) {
if (isset($line[$k])) {
} else if (in_array($k, $booleans)) {
$link[$col] = ($line[$k] == '1');
} else {
- $link[$col] = utf8_encode($line[$k]);
+ $link[$col] = $line[$k];
}
} else {
$link[$col] = $default;
$link['display_area'] = '1';
$link['page'] = $page;
+ $link['uid'] = self::generateUID();
$links[] = $link;
}
-
+ fclose($fp);
}
- self::saveLinksInFile($book_id, $core->user->utilisateur_id, 'Links imported from PDF', $links, []);
+ self::saveLinksInFile($book_id, backpack_user()->id, 'Links imported from PDF', $links);
}
public static function getLinksAndRulersFromExcelFile($path, &$links, &$rulers)
"source": {
"type": "git",
"url": "git://git.cubedesigners.com/cubist_util.git",
- "reference": "8ca0e77316c93612593605ede9b457208fe1ae1f"
+ "reference": "9c379ada28a41672fdaeae328c5d4ab1d1579ddc"
},
"dist": {
"type": "tar",
- "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-dc542c.tar",
- "reference": "8ca0e77316c93612593605ede9b457208fe1ae1f",
- "shasum": "e61ff95f8167d578a732deeae83f8117cdbe11a6"
+ "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-54b85e.tar",
+ "reference": "9c379ada28a41672fdaeae328c5d4ab1d1579ddc",
+ "shasum": "8c7bf70c044f4493e179137292b0f59d79d57fcd"
},
"require": {
"cubist/net": "dev-master",
}
],
"description": "Utilities class",
- "time": "2023-01-30T10:26:43+00:00"
+ "time": "2023-02-10T13:34:52+00:00"
},
{
"name": "cviebrock/eloquent-sluggable",