namespace Fluidbook\Tools\Compiler;
-use Cubist\Util\Files\Files;
use Cubist\Util\Files\VirtualDirectory;
use Cubist\Util\PHP;
use Exception;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\Jobs\SyncJob;
use Illuminate\Queue\SerializesModels;
+use JsonException;
use stdClass;
class Compiler implements ShouldQueue, ShouldBeUnique
*/
protected $pages = [];
+ /**
+ * @var string
+ */
+ protected $stub = '';
+
public function addSource($document, $start = 1, $pages = null)
{
$source = new Source(new Document($document), $start, $pages);
{
start_measure('Process Pages');
foreach ($this->sources as $source) {
- dd( $source->getRange());
$source->getDocument()->processPages($this->getProcessFiles(), $source->getRange(), $sync);
}
stop_measure('Process Pages');
$res = $files[$name];
if (null !== $page) {
$sourcePage = $this->getSourceOfPage($page);
- $res->setJob(new ProcessPage($sourcePage->getSource(), $sourcePage->getPage()));
+ $res->setJob(new ProcessPage($sourcePage->getSource()->getDocument(), $sourcePage->getPage()));
}
return $res;
}
start_measure('Compile fluidbook');
$this->vdir = new VirtualDirectory($this->out);
- $this->vdir->copyDirectory($this->stub, '/');
+ if ($this->stub !== '') {
+ $this->vdir->copyDirectory($this->stub, '/');
+ }
$this->compileContents();
$this->compileSearch();
protected function compileDimensions()
{
- $width = round($this->in->getWidth(), 8);
- $height = round($this->in->getHeight(), 8);
+ $firstPageDoc = $this->getSourceOfPage(1)->getSource()->getDocument();
+
+ $width = round($firstPageDoc->getWidth(), 8);
+ $height = round($firstPageDoc->getHeight(), 8);
$this->config->pageZoomFactor = 3;
$this->config->optimalWidth = 567;
$cssWidth = $width * $this->config->cssScale;
$cssHeight = $height * $this->config->cssScale;
- $this->config->pages = $this->in->getPages();
+ $this->config->pages = $firstPageDoc->getPages();
$this->config->width = $cssWidth;
$this->config->height = $cssHeight;
$this->config->thumbWidth = $thumbDimensions[0];
$this->config->thumbHeight = $thumbDimensions[1];
- for ($i = 1; $i <= $this->in->getPages(); $i++) {
+ for ($i = 1; $i <= $firstPageDoc->getPages(); $i++) {
$this->config->pagesDimensions[$i] = [$this->config->width, $this->config->height];
}
}
protected function compilePageNumbers()
{
- $this->config->numerotation = $this->in->getPageNumbers();
+
+ $this->config->numerotation = [];
+ foreach ($this->sources as $source) {
+ $this->config->numerotation += array_slice($source->getDocument()->getPageNumbers(), $source->getStart(), $source->getPages());
+ }
}
protected function compileChapters()
{
$this->config->chaptersPagesNumber = 'physical';
- $this->config->chapters = $this->in->getChapters();
+ $this->config->chapters = [];
+ foreach ($this->sources as $source) {
+ $this->config->chapters += $source->getDocument()->getChapters();
+ }
}