<?php
class wsHTML5Compiler {
-
- public static function factory($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false) {
- if (is_null($version)) {
- global $core;
- $dao = new wsDAOBook($core->con);
- $book = $dao->selectById($book_id);
- $version = $book->parametres->mobileLVersion;
- }
-
- if ($version == 'stable') {
- $class = 'wsHTML5Compiler';
- } else {
- $class = 'wsHTML5CompilerDev';
- }
- return new $class($book_id, $version, $phonegap, $phonegapVersion, $dir, $standalone, $appcache, $home);
- }
-
protected static $resolutions = array(150, 300);
protected $maxRes = 300;
- protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', '');
+
public $jsFiles = array(
'js/libs/modernizr/modernizr.js',
'js/libs/modernizr/tests.js',
function __construct($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false) {
global $core;
- $this->phonegapVersion = self::getPhonegapVersion($phonegapVersion);
+ $this->phonegapVersion = wsHTML5::getPhonegapVersion($phonegapVersion);
$this->appcache = $appcache;
$this->multiApp = $this->home = $home;
$this->version = $version;
return $res;
}
- public static function getPhonegapVersion($v = 'latest') {
- if ($v != 'latest') {
- return $v;
- }
-
- $versions = self::getPhonegapVersions();
- return array_pop($versions);
- }
-
- public static function getPhonegapVersions() {
- $versions = array();
-
- $dr = opendir(WS_COMPILE_ASSETS . '/_html5/js/libs/phonegap');
- while ($file = readdir($dr)) {
- if ($file == '.' || $file == '..' || $file == 'plugins') {
- continue;
- }
- $versions[] = $file;
- }
- usort($versions, 'version_compare');
- return $versions;
- }
-
public function getCssScale() {
return $this->cssScale;
}
$this->config->optimalWidth = $this->optimalWidth;
$this->config->optimalHeight = $this->optimalHeight;
$this->config->chapters = $this->book->chapters;
- $this->config->coquilletteBack = $this->colorToCSS($this->theme->parametres->couleurA);
- $this->config->coquilletteFront = $this->colorToCSS($this->theme->parametres->arrowsColor);
+ $this->config->coquilletteBack = wsHTML5::colorToCSS($this->theme->parametres->couleurA);
+ $this->config->coquilletteFront = wsHTML5::colorToCSS($this->theme->parametres->arrowsColor);
$this->config->videoFormats = $this->getVideosFormats(false);
$this->config->htmlmultimedia = $this->htmlmultimedia;
$this->config->phonegap = $this->phonegap;
$res[] = '.portrait #pages,.portrait .doublePage.page,.page,.doublePage._3d,#shadow>div{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}';
$res[] = '.doublePage,#pages,#links{width:' . $w2 . ';max-width:' . $w2 . ';height:' . $h . ';max-height:' . $h . '}';
- $res[] = '.landscape .doublePage._2d.axis_x.next{' . self::writeCSSUA('transform', 'translate3d(' . $w2 . ',0,0)') . '}';
- $res[] = '.landscape .doublePage._2d.axis_x.prev{' . self::writeCSSUA('transform', 'translate3d(-' . $w2 . ',0,0)') . '}';
- $res[] = '.portrait .doublePage._2d.axis_x.next{' . self::writeCSSUA('transform', 'translate3d(' . $w . ',0,0)') . '}';
- $res[] = '.portrait .doublePage._2d.axis_x.prev{' . self::writeCSSUA('transform', 'translate3d(-' . $w . ',0,0)') . '}';
- $res[] = '.doublePage._2d.axis_y.next{' . self::writeCSSUA('transform', 'translate3d(0,' . $h . ',0)') . '}';
- $res[] = '.doublePage._2d.axis_y.prev{' . self::writeCSSUA('transform', 'translate3d(0,-' . $h . ',0)') . '}';
+ $res[] = '.landscape .doublePage._2d.axis_x.next{' . wsHTML5::writeCSSUA('transform', 'translate3d(' . $w2 . ',0,0)') . '}';
+ $res[] = '.landscape .doublePage._2d.axis_x.prev{' . wsHTML5::writeCSSUA('transform', 'translate3d(-' . $w2 . ',0,0)') . '}';
+ $res[] = '.portrait .doublePage._2d.axis_x.next{' . wsHTML5::writeCSSUA('transform', 'translate3d(' . $w . ',0,0)') . '}';
+ $res[] = '.portrait .doublePage._2d.axis_x.prev{' . wsHTML5::writeCSSUA('transform', 'translate3d(-' . $w . ',0,0)') . '}';
+ $res[] = '.doublePage._2d.axis_y.next{' . wsHTML5::writeCSSUA('transform', 'translate3d(0,' . $h . ',0)') . '}';
+ $res[] = '.doublePage._2d.axis_y.prev{' . wsHTML5::writeCSSUA('transform', 'translate3d(0,-' . $h . ',0)') . '}';
$res[] = '.doublePage._3d{left:' . $w . ';}';
$res[] = '#links.right{left:-' . $w . ';}';
$res[] = '.landscape #shadow>div.right{left: ' . $w . ';}';
$res[] = '.landscape .page.right{left:' . $w . '}';
if ($this->theme->parametres->displayPageNumber) {
- $res[] = '#pagesnumbers{font-size: ' . (12 * $this->z) . 'px;margin: ' . (5 * $this->z) . 'px 0 0 0;top:' . $h . ';color:' . self::colorToCSS($this->theme->parametres->colorPageNumber) . '}';
+ $res[] = '#pagesnumbers{font-size: ' . (12 * $this->z) . 'px;margin: ' . (5 * $this->z) . 'px 0 0 0;top:' . $h . ';color:' . wsHTML5::colorToCSS($this->theme->parametres->colorPageNumber) . '}';
$res[] = '#pagesnumbers div{width:' . $w . '}';
} else {
$res[] = '#pagesnumbers{display:none;}';
}
- $res[] = '.doublePage._2d,.doublePage._3d{' . self::writeCSSUA('transition', 'all ' . $this->book->parametres->mobileTransitionDuration . 's ease-in-out') . '}';
+ $res[] = '.doublePage._2d,.doublePage._3d{' . wsHTML5::writeCSSUA('transition', 'all ' . $this->book->parametres->mobileTransitionDuration . 's ease-in-out') . '}';
- $res[] = '.background{' . self::writeCSSUA('transform-origin', 'top left') . ';}';
+ $res[] = '.background{' . wsHTML5::writeCSSUA('transform-origin', 'top left') . ';}';
foreach ($this->getResolutions() as $r) {
$ratio = round(72 / $r, 3) * $cssScale;
$br = '.background.r' . $r . '{';
if ($ratio != 1) {
- $br .= self::writeCSSUA('transform', 'scale(' . $ratio . ')') . ';';
+ $br .= wsHTML5::writeCSSUA('transform', 'scale(' . $ratio . ')') . ';';
}
$br .= 'width:' . $wr . 'px;height:' . $hr . 'px;}';
$res[] = $br;
}
- $texts = '.texts{' . self::writeCSSUA('transform-origin', 'top left') . ';';
- $texts .= self::writeCSSUA('transform', 'scale(' . round((1 / $this->multiply) * $cssScale * $this->cssSVGScale, 3) . ')') . ';';
+ $texts = '.texts{' . wsHTML5::writeCSSUA('transform-origin', 'top left') . ';';
+ $texts .= wsHTML5::writeCSSUA('transform', 'scale(' . round((1 / $this->multiply) * $cssScale * $this->cssSVGScale, 3) . ')') . ';';
$texts .= 'width:' . ($wm / $this->cssSVGScale) . '; max-width:' . ($wm / $this->cssSVGScale) . ';';
$texts .= 'height:' . ($hm / $this->cssSVGScale) . '; max-height:' . ($hm / $this->cssSVGScale) . ';';
$texts .= '}';
// SVG
- $res[] = 'svg .fill-c-menu-back{fill:' . self::colorToCSS($this->theme->parametres->couleurB) . ';}';
- $res[] = 'svg .fill-c-menu-text{fill:' . self::colorToCSS($this->theme->parametres->subTextColor) . ';}';
+ $res[] = 'svg .fill-c-menu-back{fill:' . wsHTML5::colorToCSS($this->theme->parametres->couleurB) . ';}';
+ $res[] = 'svg .fill-c-menu-text{fill:' . wsHTML5::colorToCSS($this->theme->parametres->subTextColor) . ';}';
// Search field
- $searchColor = self::colorToCSS($this->theme->parametres->couleurS);
- $searchBackColor = self::colorToCSS($this->theme->parametres->searchFieldColor);
+ $searchColor = wsHTML5::colorToCSS($this->theme->parametres->couleurS);
+ $searchBackColor = wsHTML5::colorToCSS($this->theme->parametres->searchFieldColor);
$search = '#q{';
$search .= 'color:' . $searchColor . ';';
$search .= 'background-color:' . $searchBackColor . ';';
if ($this->theme->parametres->searchShadeAlpha > 0) {
- $search .= self::writeCSSUA('box-shadow', '1px 1px 4px rgba(0,0,0,' . ($this->theme->parametres->searchShadeAlpha / 100) . ')') . ' inset;';
+ $search .= wsHTML5::writeCSSUA('box-shadow', '1px 1px 4px rgba(0,0,0,' . ($this->theme->parametres->searchShadeAlpha / 100) . ')') . ' inset;';
}
$search .= '}';
$search .= '#searchHints,.hint{color:' . $searchColor . ';background-color:' . $searchBackColor . ';}';
// Header
$header = 'header{';
$header .= 'height:' . $this->theme->parametres->menuHeight . 'px;';
- $header .= 'background-color:' . self::colorToCSS($this->theme->parametres->menuColor) . ';';
+ $header .= 'background-color:' . wsHTML5::colorToCSS($this->theme->parametres->menuColor) . ';';
if ($this->theme->parametres->menuImage != '') {
$this->copy($this->themeRoot . '/' . $this->theme->parametres->menuImage, $this->vdir . '/data/images/' . $this->theme->parametres->menuImage);
$header .= 'background-image:url(../images/' . $this->theme->parametres->menuImage . ');';
//Icons
$res = array_merge($res, $this->writeIcons());
- $res[] = '#nav #locales{background-color:' . self::colorToCSS($this->theme->parametres->couleurI) . ';}';
+ $res[] = '#nav #locales{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->couleurI) . ';}';
// Logo
$logo = '#logo{';
$res[] = $logo;
// Credits
- $res[] = 'footer,footer a{color:' . self::colorToCSS($this->theme->parametres->creditsColor) . ';}';
+ $res[] = 'footer,footer a{color:' . wsHTML5::colorToCSS($this->theme->parametres->creditsColor) . ';}';
// Arrows
- $res[] = '#next,#previous{background-color:' . self::colorToCSS($this->theme->parametres->couleurA) . ';}';
+ $res[] = '#next,#previous{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->couleurA) . ';}';
// Audio description buttons
- $res[] = '.audio-description-button{background-color:' . self::colorToCSS($this->theme->parametres->couleurA) . ';}';
+ $res[] = '.audio-description-button{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->couleurA) . ';}';
// Book shadow
- $shadowColor = self::colorToCSS($this->theme->parametres->bookShadeColor);
+ $shadowColor = wsHTML5::colorToCSS($this->theme->parametres->bookShadeColor);
if ($shadowColor != 'transparent') {
- $res[] = '#shadow>div{' . self::writeCSSUA('box-shadow', '0 0 20px ' . $shadowColor) . '}';
+ $res[] = '#shadow>div{' . wsHTML5::writeCSSUA('box-shadow', '0 0 20px ' . $shadowColor) . '}';
}
// Links Styles
$res = array_merge($res, $links);
- $res[] = '.link a.displayArea:hover,.link a.displayArea.animating{background-color:' . self::colorToCSS($this->theme->parametres->linksColor, 0.4) . ';}';
+ $res[] = '.link a.displayArea:hover,.link a.displayArea.animating{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->linksColor, 0.4) . ';}';
$res[] = '.link a.displayArea:hover{opacity:1 !important;}';
- $res[] = '.link a.displayArea{-webkit-tap-highlight-color:' . self::colorToCSS($this->theme->parametres->linksColor, 0.4) . ';background-color:' . self::colorToCSS($this->theme->parametres->linksColor, 0.0001) . ';}';
+ $res[] = '.link a.displayArea{-webkit-tap-highlight-color:' . wsHTML5::colorToCSS($this->theme->parametres->linksColor, 0.4) . ';background-color:' . wsHTML5::colorToCSS($this->theme->parametres->linksColor, 0.0001) . ';}';
// Bookmarks
if (!isset($this->book->parametres->bookmarkCornerSize)) {
// Menus
$menuColor = new CubeIT_Graphics_Color($this->theme->parametres->couleurB);
$menuColor->setAlpha(1);
- $menuTextColor = self::colorToCSS($this->theme->parametres->subTextColor);
+ $menuTextColor = wsHTML5::colorToCSS($this->theme->parametres->subTextColor);
$menuMultiply = $menuColor->multiply($menuColor);
$menuMultiply2 = $menuMultiply->multiply($menuColor);
# Inner View
$res[] .= '#innerView>div{background-color:' . $menuColor->toCSS() . ';color:' . $menuTextColor . ';}';
- $res[] .= 'form input[type="text"],form input[type="email"]{background-color:' . self::colorToCSS($this->theme->parametres->subFieldColor) . ';color:' . self::colorToCSS($this->theme->parametres->subTextFieldColor) . ';}';
+ $res[] .= 'form input[type="text"],form input[type="email"]{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->subFieldColor) . ';color:' . wsHTML5::colorToCSS($this->theme->parametres->subTextFieldColor) . ';}';
// Archives
if ($this->book->parametres->externalArchivesBack) {
$ratio = $this->width / $this->height;
$thumbh = round(100 / $ratio);
$res[] = '#indexView .thumb img{width:100px;height:' . $thumbh . 'px;}';
- $res[] = '#indexView .doubleThumb{height:' . $thumbh . 'px;' . self::writeCSSUA('box-shadow', '0 0 3px ' . $shadowColor) . '}';
+ $res[] = '#indexView .doubleThumb{height:' . $thumbh . 'px;' . wsHTML5::writeCSSUA('box-shadow', '0 0 3px ' . $shadowColor) . '}';
$res[] = '#indexView .doubleThumb .overlay{height:' . $thumbh . 'px;}';
- $res[] = '#indexView .doubleThumb .hits.yes{background-color:' . self::colorToCSS($this->theme->parametres->subSelectColor) . ';color:' . self::colorToCSS($this->theme->parametres->subTextSelectColor) . '}';
+ $res[] = '#indexView .doubleThumb .hits.yes{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->subSelectColor) . ';color:' . wsHTML5::colorToCSS($this->theme->parametres->subTextSelectColor) . '}';
# Tooltip
- $res[] = '#tooltip{background-color:' . self::colorToCSS($this->theme->parametres->tooltipBackColor) . ';color:' . self::colorToCSS($this->theme->parametres->tooltipTextColor) . ';}';
+ $res[] = '#tooltip{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->tooltipBackColor) . ';color:' . wsHTML5::colorToCSS($this->theme->parametres->tooltipTextColor) . ';}';
# ZoomPopup close button background
- $res[] = '.zoomPopupClose {background-color:'. self::colorToCSS($this->theme->parametres->couleurB) .';}';
+ $res[] = '.zoomPopupClose {background-color:' . wsHTML5::colorToCSS($this->theme->parametres->couleurB) . ';}';
$res = array_chunk($res, 3500);
foreach ($res as $k => $css) {
}
- public static function colorToArray($color, $forceAlpha = null) {
- $color = ltrim($color, '#');
- if (strlen($color) == 6) {
- $hex = $color;
- $alpha = 1;
- } else {
- $alpha = hexdec(substr($color, 0, 2)) / 255;
- $hex = substr($color, 2, 6);
- }
-
- if (!is_null($forceAlpha)) {
- $alpha = $forceAlpha;
- }
-
- return array('hex' => strtoupper($hex), 'opacity' => number_format($alpha, 3, '.', ''));
- }
-
- public static function colorToCSS($color, $forceAlpha = null) {
- return CubeIT_Graphics_Color::colorToCSS($color, $forceAlpha);
- }
-
-}
-
-class wsHTML5CompilerDev extends wsHTML5Compiler {
-
-}
+}
\ No newline at end of file