use Illuminate\Queue\SerializesModels;
use JsonException;
-class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
-{
+class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface {
use FluidbookCompiler;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $resolutions = [150, 300];
- public function addSource($document, $start = 1, $pages = null)
- {
+ public function addSource($document, $start = 1, $pages = null) {
$source = new Source(new Document($document), $start, $pages);
$this->sources[] = $source;
foreach ($source->getRange() as $sourcePage) {
*
* @return void
*/
- public function handle()
- {
+ public function handle() {
$sync = ($this->job instanceof SyncJob);
if ($sync) {
PHP::neverStop(false);
stop_measure('Process Fluidbook');
}
- public function processPages($sync = false)
- {
+ public function processPages($sync = false) {
start_measure('Process Pages');
foreach ($this->sources as $source) {
$source->getDocument()->processPages($this->getProcessFiles(), $source->getRange(), $sync);
stop_measure('Process Pages');
}
- public function getTexts()
- {
+ public function getTexts() {
start_measure('Process texts');
foreach ($this->sources as $source) {
$source->getDocument()->processTexts();
/**
* @return ProcessFile[]
*/
- public function getProcessFiles()
- {
+ public function getProcessFiles() {
$res = [
'thumb' => new ProcessFile('jpg', 'thumb'),
'text' => new ProcessFile('svg', 150, false, true),
* @return ProcessFile
* @throws Exception
*/
- public function getProcessFile($name, $page = null)
- {
+ public function getProcessFile($name, $page = null) {
$files = $this->getProcessFiles();
if (isset($files[$name])) {
$res = $files[$name];
* @return SourcePage
* @throws Exception
*/
- public function getSourceOfPage($page)
- {
+ public function getSourceOfPage($page) {
if (isset($this->pages[$page - 1])) {
return $this->pages[$page - 1];
}
/**
* @throws JsonException
*/
- protected function compileFluidbook()
- {
+ protected function compileFluidbook() {
start_measure('Compile fluidbook');
if ($this->wdir === '') {
stop_measure('Compile fluidbook');
}
- public function prepareStub()
- {
+ public function prepareStub() {
if ($this->stub !== '') {
$this->vdir->copyDirectory($this->stub, '/');
}
}
- public function compileContents()
- {
+ public function compileContents() {
for ($i = 1; $i <= $this->getPageCount(); $i++) {
foreach ($this->resolutions as $resolution) {
}
}
- public function getPagePDFSource($page)
- {
+ public function getPagePDFSource($page) {
return $this->getProcessFile('back300', $page)->getSplittedPDFPage();
}
- public function getPageCount()
- {
+ public function getPageCount() {
$res = 0;
foreach ($this->sources as $source) {
$res += $source->getPages();
/**
* @throws \JsonException
*/
- public function compileSearch()
- {
+ public function compileSearch() {
$index = new SearchIndex();
foreach ($this->pages as $i => $page) {
/**
* @throws JsonException
*/
- public function compileConfig()
- {
+ public function compileConfig() {
$settings = mb_substr(file_get_contents($this->stub . '/data/datas.js'), 13, -2);
$this->config = json_decode($settings, false, 512, JSON_THROW_ON_ERROR);
$this->config->maxResolution = 300;
$this->vdir->file_put_contents('data/datas.js', $c);
}
- protected function compileDimensions()
- {
+ protected function compileDimensions() {
$firstPageDoc = $this->getSourceOfPage(1)->getSource()->getDocument();
$width = round($firstPageDoc->getWidth(), 8);
}
}
- protected function compilePageNumbers()
- {
+ protected function compilePageNumbers() {
$this->config->numerotation = [];
foreach ($this->sources as $source) {
}
}
- protected function compileChapters()
- {
+ protected function compileChapters() {
$this->config->chaptersPagesNumber = 'physical';
$this->config->chapters = [];
foreach ($this->sources as $source) {
}
}
- public function getBookSurface()
- {
+ public function getBookSurface() {
return $this->getWidth() * $this->getHeight();
}
- public function getWidth()
- {
+ public function getWidth() {
return $this->getSourceOfPage(1)->getSource()->getDocument()->getWidth();
}
- public function getHeight()
- {
+ public function getHeight() {
return $this->getSourceOfPage(1)->getSource()->getDocument()->getHeight();
}
- public function addVideoJs()
- {
+ public function addVideoJs() {
$this->addLess('videojs/videojs');
}
- public function addSlideshowLibrary($inline = true)
- {
+ public function addSlideshowLibrary($inline = true) {
$l = ($inline ? $this->config->inlineSlideshowLibrary : $this->config->popupSlideshowLibrary);
$this->addLess('slideshow/' . $l);
}
- public function addTriggersLink($page, $link, $delay = 0)
- {
+ public function addTriggersLink($page, $link, $delay = 0) {
// TODO: Implement addTriggersLink() method.
}
- public function addAudiodescription($link)
- {
+ public function addAudiodescription($link) {
// TODO: Implement addAudiodescription() method.
}
- public function addBookmarkGroup($link)
- {
+ public function addBookmarkGroup($link) {
// TODO: Implement addBookmarkGroup() method.
}
- public function getConfigZIP($d)
- {
+ public function getConfigZIP($d) {
// TODO: Implement getConfigZIP() method.
}
- public function addContentLock($page, $unlockConditions = '')
- {
+ public function addContentLock($page, $unlockConditions = '') {
// TODO: Implement addContentLock() method.
}
- public function source_path($path = ''): string
- {
+ public function source_path($path = ''): string {
// TODO: Implement source_path() method.
return '';
}
- public function virtualToPhysical($virtual): string|int
- {
+ public function virtualToPhysical($virtual): string|int {
// TODO: Implement virtualToPhysical() method.
return "";
}
public function pushSetting($key, $value) {
// TODO: Implement pushSetting() method.
}
+
+ public function getWidthForLinks() {
+ return $this->getWidth() / $this->getLinkScale();
+ }
+
+ public function getHeightForLinks() {
+ return $this->getHeight() / $this->getLinkScale();
+ }
}