<output-test url="file://$MODULE_DIR$/out/test/fluidbook_tools" />
<exclude-output />
<content url="file://$MODULE_DIR$">
- <sourceFolder url="file://$MODULE_DIR$/resources/tools/fwstk/project_resources" type="java-resource" />
- <sourceFolder url="file://$MODULE_DIR$/resources/tools/fwstk/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="Fluidbook\Tools\" />
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/brick/math" />
namespace Fluidbook\Tools\Compiler;
+use Cubist\Util\Files\Files;
use Cubist\Util\Files\VirtualDirectory;
use Cubist\Util\PHP;
use Exception;
*/
protected $pages = [];
+ /**
+ * @var string
+ */
+ public $wdir;
/**
* @var string
{
start_measure('Compile fluidbook');
+ $this->wdir = resource_path('fluidbook/working/');
+ Files::mkdir($this->wdir);
$this->vdir = new VirtualDirectory($this->out);
if ($this->stub !== '') {
$this->vdir->copyDirectory($this->stub, '/');
return $this->getSourceOfPage(1)->getSource()->getDocument()->getHeight();
}
+ public function addVideoJs()
+ {
+ }
}
use Cubist\Util\ArrayUtil;
use Fluidbook\Tools\Links\ContentLink;
use Fluidbook\Tools\Links\Link;
+use Nette\Utils\Image;
trait Links
{
$allpages[] = $linkPage;
}
- $this->config->links=[];
- $this->config->clinks=[];
- $this->config->ctlinks=[];
+ $this->config->links = [];
+ $this->config->clinks = [];
+ $this->config->ctlinks = [];
foreach ($allpages as $i) {
$this->config->links[$i] = $this->_htmlLinkList($pages[$i] ?? []);
return (float)$this->config->cssScale;
}
+ /**
+ * @throws \Exception
+ */
+ public function copyLinkDir($source, $dest)
+ {
+ $this->vdir->copyDirectory($source, $dest);
+ }
+
+ public function simpleCopyLinkFile($source, $dest, $addVdir = true)
+ {
+ if ($addVdir) {
+ $dest = $dest;
+ }
+
+ if (stripos($source, '.svg') !== false) {
+ $source = $this->_fixSVG($source);
+ }
+
+ $this->vdir->copy($source, $dest);
+ }
+
+ protected function _fixSVG($source)
+ {
+ $fixed = str_replace('.svg', '.f.svg', $source);
+ if (file_exists($fixed) && filemtime($fixed) >= filemtime($source)) {
+ return $fixed;
+ }
+ $svg = simplexml_load_string(file_get_contents($source));
+ $attr = $svg->attributes();
+ if (isset($attr['width'], $attr['height'])) {
+ copy($source, $fixed);
+ return $fixed;
+ }
+
+ $dim = Image::getimagesize($source);
+ $svg->addAttribute('preserveAspectRatio', 'none');
+ $svg->addAttribute('width', $dim[0]);
+ $svg->addAttribute('height', $dim[1]);
+ file_put_contents($fixed, $svg->asXML());
+
+ return $fixed;
+ }
+
+ public function copyLinkFile($source, $dest, $video = false)
+ {
+// $types = $this->getVideosFormats();
+// if ($video) {
+// wsTools::encodeWebVideos($origDir . $source, null, true);
+// $e = explode('.', $source);
+// array_pop($e);
+// $base = implode('.', $e);
+// $source = array();
+// foreach ($types as $type) {
+// $source[] = $base . '.' . $type;
+// }
+// }
+
+ if (!is_array($source)) {
+ $source = array($source);
+ }
+
+ foreach ($source as $so) {
+ $s = $this->wdir . $so;
+ //dd($s,$so,$dest);
+ if (file_exists($s)) {
+ $d = $dest . '/' . $so;
+ $this->simpleCopyLinkFile($s, $d, false);
+ }
+ }
+ }
}
public function getZoomAttributes()
{
- $pdf = $this->compiler->book->parametres->downloadPortionPDF;
+ $pdf = $this->compiler->config->downloadPortionPDF;
if ($pdf !== '') {
- $pdf = $this->compiler->wdir . '/' . $this->compiler->book->parametres->downloadPortionPDF;
+ $pdf = $this->compiler->wdir . '/' . $this->compiler->config->downloadPortionPDF;
}
$res = [
'id' => $this->id,
'page' => $this->page,
- 'maxzoom' => $this->compiler->book->parametres->downloadPortionZoom,
+ 'maxzoom' => $this->compiler->config->downloadPortionZoom,
'group' => '',
'group-count' => 0,
'width' => round($this->width),
{
$this->copyExternalFile($this->to);
- if ($this->compiler->book->parametres->linkFilePrefix && !Url::isDistant($this->to)) {
- return $this->compiler->book->parametres->linkFilePrefix . $this->to;
+ if ($this->compiler->config->linkFilePrefix && !Url::isDistant($this->to)) {
+ return $this->compiler->config->linkFilePrefix . $this->to;
}
-
$res = Link::getUniversalLocation($this->to);
- if (strpos($this->to, '.pdf') >= 0 && ($this->compiler->book->parametres->PDFRenderer === 'pdfjs' || $this->compiler->book->parametres->PDFRenderer === 'pdfjs-legacy')) {
+ if (strpos($this->to, '.pdf') >= 0 && ($this->compiler->config->PDFRenderer === 'pdfjs' || $this->compiler->config->PDFRenderer === 'pdfjs-legacy')) {
return 'pdfjs/web/viewer.html?file=' . rawurlencode('../../' . $res);
}
return $res;
if ($this->_config['type'] === 'oam') {
$sx = ($this->width / ($this->_config['width'])) * $this->getCssScale();
$sy = ($this->height / ($this->_config['height'])) * $this->getCssScale();
- if ($this->compiler->book->parametres->OAMChromeFactor != 1) {
+ if ($this->compiler->config->OAMChromeFactor != 1) {
$css .= '.chrome #l_' . $this->id . '{';
- $css .= 'width:' . ($this->_config['width'] * $this->compiler->book->parametres->OAMChromeFactor) . 'px;height:' . ($this->_config['height'] * $this->compiler->book->parametres->OAMChromeFactor) . 'px;';
- $css .= CSS::writeCSSUA('transform', 'scale(' . ($sx / $this->compiler->book->parametres->OAMChromeFactor) . ',' . ($sy / $this->compiler->book->parametres->OAMChromeFactor) . ')');
+ $css .= 'width:' . ($this->_config['width'] * $this->compiler->config->OAMChromeFactor) . 'px;height:' . ($this->_config['height'] * $this->compiler->config->OAMChromeFactor) . 'px;';
+ $css .= CSS::writeCSSUA('transform', 'scale(' . ($sx / $this->compiler->config->OAMChromeFactor) . ',' . ($sy / $this->compiler->config->OAMChromeFactor) . ')');
$css .= '}';
}
- if ($this->compiler->book->parametres->OAMIEFactor != 1) {
+ if ($this->compiler->config->OAMIEFactor != 1) {
$css .= '.msie #l_' . $this->id . '{';
- $css .= 'width:' . ($this->_config['width'] * $this->compiler->book->parametres->OAMIEFactor) . 'px;height:' . ($this->_config['height'] * $this->compiler->book->parametres->OAMIEFactor) . 'px;';
- $css .= CSS::writeCSSUA('transform', 'scale(' . ($sx / $this->compiler->book->parametres->OAMIEFactor) . ',' . ($sy / $this->compiler->book->parametres->OAMIEFactor) . ')');
+ $css .= 'width:' . ($this->_config['width'] * $this->compiler->config->OAMIEFactor) . 'px;height:' . ($this->_config['height'] * $this->compiler->config->OAMIEFactor) . 'px;';
+ $css .= CSS::writeCSSUA('transform', 'scale(' . ($sx / $this->compiler->config->OAMIEFactor) . ',' . ($sy / $this->compiler->config->OAMIEFactor) . ')');
$css .= '}';
}
{
public function getDepth()
{
- if ($this->compiler->book->parametres->inlineSlideshowLibrary === 'dummy') {
+ if ($this->compiler->config->inlineSlideshowLibrary === 'dummy') {
$this->defaultZIndex = 30;
}
return parent::getDepth();
$datas = parse_url($loc);
if ((isset($datas['scheme']) && !is_null($datas['scheme'])) || strpos($loc, '#') === 0) {
-
return $loc;
} else {
if ($css) {
$res .= '<div class="fb-slideshow-thumbnails splide" id="' . $slideshowID . '_thumbnails">' . $this->_slides($slides, ['show_captions' => false, 'max_height' => $this->thumbnail_height]) . '</div>';
}
- $lib = $context === 'popup' ? $this->compiler->book->parametres->popupSlideshowLibrary : $this->compiler->book->parametres->inlineSlideshowLibrary;
+ $lib = $context === 'popup' ? $this->compiler->config->popupSlideshowLibrary : $this->compiler->config->inlineSlideshowLibrary;
$res = '<div class="fb-slideshow-wrapper ' . $lib . ' fb-slideshow-' . $context . '">' . $res . '</div>';
return $res;
public function getHTMLContent()
{
- return str_replace('%tag%', $this->to, $this->compiler->book->parametres->xiti_page);
+ return str_replace('%tag%', $this->to, $this->compiler->config->xiti_page);
}
}
public static function getVideoAttributes($data, $w = null, $h = null, $compiler = null)
{
- $attr['name'] = videoPopupLink::getBasename($data->to);
+ $attr['name'] = VideoPopupLink::getBasename($data->to);
if (Url::isDistant($data->to)) {
$attr['url'] = $data->to;
}
$attr['height'] = $h;
} else if (!is_null($compiler) && Url::isLocal($data->to)) {
// Get video dimensions from thumbnail if possible (locally uploaded files)
- $path = $compiler->wdir . '/' . $data->to;
+ $path = file_exists($data->to) ? $data->to : $compiler->wdir . '/' . $data->to;
$e = explode(',', `ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 $path`);
$attr['width'] = $e[0];
$attr['height'] = $e[1];