From: vincent@cubedesigners.com Date: Mon, 15 Aug 2011 18:11:54 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=38a96a44de6ea495997eb13d36eedbf3b8848b3a;p=cubeextranet.git --- diff --git a/images/ws/flash.png b/images/ws/flash.png new file mode 100644 index 000000000..117b0675a Binary files /dev/null and b/images/ws/flash.png differ diff --git a/images/ws/flashbug.png b/images/ws/flashbug.png new file mode 100644 index 000000000..15e05a8b6 Binary files /dev/null and b/images/ws/flashbug.png differ diff --git a/inc/commons/class.common.page.php b/inc/commons/class.common.page.php index 0af8d0b99..592874170 100644 --- a/inc/commons/class.common.page.php +++ b/inc/commons/class.common.page.php @@ -50,10 +50,10 @@ class commonPage { $settings = $core->user->getSettings($args[0]); $action = 'search' . ucfirst($args[0]); - $default = isset($_POST['q']) ? $_POST['q'] : __('Rechercher'); + $default = isset($_POST['q']) ? $_POST['q'] : ''; // Formulaire de recherche $res = '
'; - $res .= ''; + $res .= ''; $res .= '
'; return $res; } @@ -139,7 +139,7 @@ class commonPage { public static function bh($class = '') { $class = trim('b ' . $class); - return '
'; + return '
'; } public static function bf($max = false) { diff --git a/inc/commons/class.common.url.php b/inc/commons/class.common.url.php index 89c0d8ade..a6038e100 100644 --- a/inc/commons/class.common.url.php +++ b/inc/commons/class.common.url.php @@ -57,11 +57,11 @@ class commonUrl { $res .= commonPage::tMain(); $res .= commonPage::bh('login'); $res .= '
'; - $res .= '
'; + $res .= ''; $res .= '

' . $core->typo->Titre(__('Veuillez vous identifier')) . '

'; $res .= $message; $res .= ''; - $res .= ''; + $res .= ''; $res .= ''; $res .= ''; $res .= ''; @@ -84,7 +84,7 @@ class commonUrl { } public static function motdepasseOublie($args) { - return ''; + return ''; } public static function mesParametres($args) { diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 10770f84e..9771d7719 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -48,6 +48,7 @@ class wsUrl { $dao = new wsDAOBook($core->con); $context_download_id = is_null($dashboard) ? 'contextDownloadBook' : 'contextDashboard_Download' . $dashboard; $context_status_id = is_null($dashboard) ? 'contextStatusBook' : 'contextDashboard_Status' . $dashboard; + $context_view_id = is_null($dashboard) ? 'contextViewBook' : 'contextView_Status' . $dashboard; if (isset($settings['search']) && !is_null($settings['search'])) { $dao->setSearch($settings['search']); @@ -59,6 +60,7 @@ class wsUrl { $res .= self::contextBookDownload($context_download_id); $res .= self::contextBookStatus($context_status_id); + $res .= self::contextBookView($context_view_id); $res .= '
' . __('Votre e-mail ou login') . ' : ' . form::field('user_email', 20, 64, '') . '
' . __('Votre e-mail ou login') . ' : ' . cubeForm::email('user_email', 20, 64, '') . '
' . __('Votre mot de passe') . ' : ' . form::password('user_password', 20, 64, '') . '
' . __('Mot de passe oublié ? Cliquez ici') . '
' . $core->typo->BoutonOK('Cliquez-ici pour vous identifier') . '
' . __('Entrez votre e-mail') . ' : ' . form::field('email', 30, 128) . '
' . __('Entrez votre e-mail') . ' : ' . cubeForm::email('email', 30, 128) . '
'; $res .= ''; @@ -121,7 +123,11 @@ class wsUrl { $res.=''; } if ($book->version > 1 || $droits->admin) { - $res .= ''; + if ($droits->admin) { + $res .= ''; + } else { + $res .= ''; + } $res .= ''; } else { $res.=''; @@ -197,6 +203,25 @@ class wsUrl { return $res; } + public static function contextBookView($id) { + global $core; + + if (wsDroits::admin()) { + $viewers = array('viewer' => array('title' => __('Version Flash'), 'icon' => cubeMedia::image(IMG . '/flash.png')), + 'vieweru' => array('title' => __('Version Flash') . ' (' . __('debuggage') . ')', 'icon' => cubeMedia::image(IMG . '/flashbug.png')), + 'viewerh' => array('title' => __('Version HTML5'), 'icon' => cubeMedia::image(IMG . '/html5.png'))); + } + + $res = '
'; + $res .= '
'; + return $res; + } + public static function traductions($args) { global $core; @@ -266,8 +291,6 @@ class wsUrl { $res .= '
' . commonUrl::orderby('#', 'book_id', $settings, 'sort' . $change) . '' . $book->version . '' . $btVoir . '' . $btVoir . '' . $btVoir . '' . $btEdit . '
'; $res .= commonPage::bf(); - - $res .= commonPage::bh(); $res .= cubeLang::translationForm(array(PLAYER_SOURCES, WS_COMPILE_ASSETS . '/_html5/js/libs'), $lang_id, null, 'liste', array(), '' . $core->typo->Ajouter(__('Enregistrer')) . '', $lang->traductions); $res .= commonPage::bf(); diff --git a/inc/ws/Util/_common.php b/inc/ws/Util/_common.php index d13335f27..d3d58df23 100644 --- a/inc/ws/Util/_common.php +++ b/inc/ws/Util/_common.php @@ -9,4 +9,5 @@ $__autoload['wsSWF2HTMLParagraph'] = dirname(__FILE__) . '/class.ws.swf2html.php $__autoload['wsSWF2HTMLMatrix'] = dirname(__FILE__) . '/class.ws.swf2html.php'; $__autoload['wsSecureSWF'] = dirname(__FILE__) . '/class.ws.secure.swf.php'; $__autoload['wsTools'] = dirname(__FILE__) . '/class.ws.tools.php'; +$__autoload['wsHTML5Compiler'] = dirname(__FILE__) . '/html5/class.ws.html5.compiler.php'; ?> \ No newline at end of file diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php new file mode 100644 index 000000000..b5bafba36 --- /dev/null +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -0,0 +1,915 @@ +book_id = $book_id; + + $this->vdir = $this->dir = WS_BOOKS . '/html5/' . $book_id . '/'; + + if (!file_exists($this->dir)) { + mkdir($this->dir, 0777, true); + } + + $this->daoBook = new wsDAOBook($core->con); + $this->book = $this->daoBook->selectById($book_id); + $this->pages = $this->daoBook->getPagesOfBook($book_id); + + $daoTheme = new wsDAOTheme($core->con); + $this->theme = $daoTheme->getThemeOfBook($book_id, true); + $this->themeRoot = WS_THEMES . '/' . $this->theme->theme_id . '/'; + + foreach ($this->pages as $page => $infos) { + $file = WS_DOCS . '/' . $infos['document_id'] . '/html/p' . $infos['document_page'] . '.layout'; + if (file_exists($file)) { + $this->layouts[$page] = simplexml_load_file($file, null, LIBXML_ERR_WARNING); + } + } + + $imagesize = getimagesize(WS_DOCS . '/' . $this->pages[1]['document_id'] . '/html/h72-' . $this->pages[1]['document_page'] . '.jpg'); + $this->pdf2htmlRatio = round($imagesize[0] / $this->layouts[1]['width'], 2); + $this->scale = 4; + $this->multiply = $this->pdf2htmlRatio * $this->scale; + $this->numerotation = explode(',', $this->book->numerotation); + + $this->createHTML(); + } + + public function virtualToPhysical($virtual) { + if (!in_array($virtual, $this->numerotation)) { + return 1; + } + $p = array_search($virtual, $this->numerotation); + return $p + 1; + } + + protected function compareLines($a, $b) { + if ((float) $a['y'] > (float) $b['y']) { + return 1; + } else { + return -1; + } + } + + protected function createHTML() { + foreach ($this->layouts as $page => $layout) { + $this->div[$page] = array(); + $document_id = $this->pages[$page]['document_id']; + $lines = array(); + foreach ($layout->l as $line) { + $lines[] = $line; + } + usort($lines, array($this, 'compareLines')); + + foreach ($lines as $line) { + $this->div[$page][] = $this->addLine($line, $document_id); + } + } + mkdir($this->vdir . '/data/images', 0777, true); + mkdir($this->vdir . '/data/contents', 0777, true); + mkdir($this->vdir . '/data/background', 0777, true); + mkdir($this->vdir . '/data/thumbnails', 0777, true); + mkdir($this->vdir . '/data/style', 0777, true); + mkdir($this->vdir . '/data/links/pages', 0777, true); + mkdir($this->vdir . '/data/l10n/', 0777, true); + mkdir($this->vdir . '/swf', 0777, true); + + // Copy style folder + $from = WS_COMPILE_ASSETS . '/_html5/style'; + $to = $this->vdir; + `cp -r $from $to`; + + // Copy images folder + $from = WS_COMPILE_ASSETS . '/_html5/images'; + `cp -r $from $to`; + + // Copy swf + copy(WS_COMPILE_ASSETS . '/_html5/swf/video.swf', $this->vdir . '/swf/video.swf'); + + foreach ($this->div as $n => $page) { + file_put_contents($this->vdir . '/data/contents/p' . $n . '.html', $this->writePage($page)); + } + $this->writeFonts(); + $this->writeImages(); + $linksCSS = $this->writeLinks(); + $numCSS = $this->writeCSS($this->vdir . '/data/style/style_%d.css', $linksCSS); + $this->writeLangs(); + $this->writeJs(); + $this->writeIndex($numCSS); + } + + protected function writeIndex($numCSS) { + $html = file_get_contents(WS_COMPILE_ASSETS . '/_html5/_index.html'); + + $titre = $this->book->parametres->title; + $credits = ''; + // Google analytics + $ga = ''; + if ($this->book->parametres->googleAnalytics != '') { + $ga = cubePage::googleAnalytics($this->book->parametres->googleAnalytics); + } + // Feuilles de style + $sheets = array('style/fluidbook.css'); + for ($i = 0; $i < $numCSS; $i++) { + $sheets[] = 'data/style/style_' . $i . '.css'; + } + $style = array(); + foreach ($sheets as $sheet) { + $style[] = ''; + } + $style = implode("\n\t\t", $style); + + $vars = array('titre', 'credits', 'ga', 'style'); + foreach ($vars as $v) { + $html = str_replace('', $$v, $html); + } + file_put_contents($this->vdir . '/index.html', $html); + } + + protected function writeLangs() { + global $core; + $daoLang = new wsDAOLang($core->con); + $lang = $daoLang->selectById($this->book->lang); + $langs = $daoLang->selectAll(); + + + $traductions = (!count($this->book->traductions)) ? $lang->traductions : $this->book->traductions; + file_put_contents($this->vdir . '/data/l10n/default.json', json_encode($traductions)); + foreach ($langs as $lang) { + file_put_contents($this->vdir . '/data/l10n/' . $lang->lang_id . '.json', json_encode($lang->traductions)); + } + } + + protected function writeLinks() { + global $core; + $daoDoc = new wsDAODocument($core->con); + $daoDoc->getLinksAndRulers($this->book_id, $links, $rulers); + + $i = 0; + $pages = array(); + $css = array(); + foreach ($links as $linkData) { + $link = wsPackagerHTML5Link::getInstance($this->base62($i), $linkData, $this); + if (is_null($link)) { + continue; + } + if (!isset($pages[$link->page])) { + $pages[$link->page] = ''; + } + $pages[$link->page] .= $link->getHTMLContainer(); + $css[] = $link->getCSSContainer(); + $i++; + } + + for ($i = 0; $i <= $this->book->parametres->pages + 1; $i++) { + $c = ''; + if (isset($pages[$i])) { + $c = $pages[$i]; + } + file_put_contents($this->vdir . 'data/links/pages/p' . $i . '.html', $c); + } + return $css; + } + + protected function writeJs() { + $files = array('js/libs/modernizr.js', + 'js/libs/jquery/jquery.js', + 'js/libs/jquery/jquery.transform.js', + 'js/libs/jquery/jquery.mousewheel.js', + 'js/libs/jquery/jquery.hashchange.js', + 'js/libs/fluidbook/fluidbook.utils.js', + 'js/libs/fluidbook/fluidbook.cache.js', + 'js/libs/fluidbook/fluidbook.support.js', + 'js/libs/fluidbook/fluidbook.viewport.js', + 'js/libs/fluidbook/fluidbook.desktop.js', + 'js/libs/fluidbook/fluidbook.service.js', + 'js/libs/fluidbook/fluidbook.loader.js', + 'js/libs/fluidbook/fluidbook.l10n.js', + 'js/libs/fluidbook/fluidbook.nav.js', + 'js/libs/fluidbook/fluidbook.js', + 'js/main.js'); + + $mintime = 0; + $minimized = WS_COMPILE_ASSETS . '/_html5/js/min.js'; + if (file_exists($minimized)) { + $mintime = filemtime($minimized); + } + $reminimize = false; + foreach ($files as $file) { + if (filemtime(WS_COMPILE_ASSETS . '/_html5/' . $file) > $mintime) { + $reminimize = true; + break; + } + } + + if ($reminimize) { + $js = ''; + foreach ($files as $file) { + $js.=file_get_contents(WS_COMPILE_ASSETS . '/_html5/' . $file); + $js.="\n\n"; + } + $tmp = cubeFiles::tempnam(); + file_put_contents($tmp, $js); + + $compressor = new cubeCommandLine('yuicompressor'); + $compressor->setPath(CONVERTER_PATH); + $compressor->setArg('charset', 'UTF-8'); + $compressor->setArg('type', 'js'); + $compressor->setArg('line-break', 1024); + $compressor->setArg('o', $minimized); + $compressor->setArg(null, $tmp); + $compressor->execute(); + } + + $js = $this->writeConfig(); + $js.=file_get_contents($minimized); + file_put_contents($this->vdir . '/data/fluidbook.js', $js); + } + + protected function writeConfig() { + $config = cubeObject::merge($this->book->parametres->toStandardObject(), $this->theme->parametres->toStandardObject()); + $config->numerotation = explode(',', $this->book->numerotation); + $config->id = $this->book->book_id; + $config->cacheDate = TIME; + return 'var DATAS=' . json_encode($config) . ';' . "\n"; + } + + protected function writeFonts() { + $formats = array('ttf', 'woff', 'svg'); + + foreach ($this->cssFont as $font => $index) { + + foreach ($formats as $format) { + $fontforge = new cubeCommandLine('convert.pe'); + $fontforge->setPath(CONVERTER_PATH); + foreach ($this->fontDocs[$font] as $document_id => $dummy) { + $fontforge->setArg(null, WS_DOCS . '/' . $document_id . '/fonts/web/' . $font . '.ttf'); + } + $fontforge->setArg(null, $this->vdir . '/data/style/F' . $index . '.' . $format); + $fontforge->execute(); + } + } + } + + protected function writeIcons() { + $res = array(); + // Get the colors used to colorize graphics + if ($this->theme->parametres->colorizeIcons) { + $couleurI = '#' . $this->theme->parametres->couleurI; + } else { + $couleurI = '#FFFFFF'; + } + $arrowsColor = '#' . $this->theme->parametres->arrowsColor; + // Set the icon list with the color + $icons = array('nav-bookmark' => $couleurI, 'nav-friend' => $couleurI, 'nav-help' => $couleurI, 'nav-index' => $couleurI, 'nav-sommaire' => $couleurI, + 'next' => $arrowsColor, 'previous' => $arrowsColor, 'search' => $couleurI, 'nav-facebook' => $couleurI, 'nav-twitter' => $couleurI, + 'help-fingers' => $couleurI, 'help-mouse' => $couleurI); + + foreach ($icons as $icon => $color) { + wsTools::colorizeAndRasterizeIcon($this->theme->parametres->iconSet, $icon, $color, $this->vdir . '/data/images/', 4, $w, $h); + } + return $res; + } + + protected function writeImages() { + + foreach (self::$resolutions as $r) { + mkdir($this->vdir . '/data/background/' . $r, 0777); + } + foreach ($this->pages as $page => $infos) { + foreach (self::$resolutions as $r) { + copy(WS_DOCS . '/' . $infos['document_id'] . '/html/h' . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/p' . $page . '.jpg'); + } + copy(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', $this->vdir . '/data/thumbnails/p' . $page . '.jpg'); + } + } + + protected function writePage($page) { + $res = ''; + foreach ($page as $line) { + $res .= $this->writeLine($line); + } + return $res; + } + + protected function writeLine($line) { + $res = ''; + foreach ($line['groups'] as $group) { + $res.=$this->writeGroup($group, $line); + } + return $res; + } + + protected function writeGroup($group, $line) { + if ($group === false) { + return ''; + } + + $group['y'] = $this->getCSSY(($group['y'] + $line['y']) * $this->multiply); + $group['x'] = $this->getCSSX(($group['x']) * $this->multiply); + + $class = array('g'); + if (!is_null($group['color'])) { + $class[] = 'c' . $group['color']; + } + if (!is_null($group['size'])) { + $class[] = 's' . $group['size']; + } + if (!is_null($group['font'])) { + $class[] = 'f' . $group['font']; + } + if (!is_null($group['x'])) { + $class[] = 'x' . $group['x']; + } + if (!is_null($group['y'])) { + $class[] = 'y' . $group['y']; + } + if (!is_null($line['rotation'])) { + $class[] = 'r' . $line['rotation']; + } + if (!is_null($group['letterspacing'])) { + $class[] = 'l' . $group['letterspacing']; + } + if (!is_null($group['wordspacing'])) { + $class[] = 'w' . $group['wordspacing']; + } + $class = implode(' ', $class); + + $res = '
'; + foreach ($group['spans'] as $span) { + $res.=$this->writeSpan($span); + } + $res.='
'; + return $res; + } + + protected function writeSpan($span) { + if ($span === false) { + return ''; + } + + if ($span['space']) { + return $span['text']; + } else { + return self::escapeHTML($span['text']); + } + } + + protected function writeCSS($file, $links) { + $res = array(); + + // General theme + $h = $this->book->parametres->height . 'px'; + $w2 = ($this->book->parametres->width * 2) . 'px'; + $w = $this->book->parametres->width . 'px'; + $wm = ($this->book->parametres->width * $this->multiply) . 'px'; + $hm = ($this->book->parametres->height * $this->multiply) . 'px'; + + + $navTop = ($this->book->parametres->height - 40 - 100) / 2; + $res[] = '.portrait #pages,.portrait .doublePage.page,.page,.portrait #shadow,#shadow.single,.page .links{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}'; + $res[] = '.background{' . $this->writeCSSUA('transform-origin', 'top left') . ';}'; + foreach (self::$resolutions as $r) { + $ratio = round(72 / $r, 2); + $wr = $this->book->parametres->width / $ratio; + $hr = $this->book->parametres->height / $ratio; + + $br = '.background.r' . $r . '{'; + if ($ratio != 1) { + $br.=$this->writeCSSUA('transform', 'scale(' . $ratio . ')') . ';'; + } + $br.='width:' . $wr . 'px;height:' . $hr . 'px;}'; + $res[] = $br; + } + $res[] = '.doublePage,#pages,.landscape #shadow.double{width:' . $w2 . ';max-width:' . $w2 . ';height:' . $h . ';max-height:' . $h . '}'; + $res[] = '.landscape #shadow.single.right{left: ' . $w . ';}'; + $res[] = '.landscape .page.right{left:' . $w . '}'; + if ($this->theme->parametres->displayPageNumber) { + $res[] = '#pagesnumbers{top:' . $h . ';color:' . self::colorToCSS($this->theme->parametres->colorPageNumber) . '}'; + $res[] = '#pagesnumbers div{width:' . $w . '}'; + } else { + $res[] = '#pagesnumbers{display:none;}'; + } + + $texts = '.texts{' . $this->writeCSSUA('transform-origin', 'top left') . ';'; + $texts.=$this->writeCSSUA('transform', 'scale(' . round(1 / $this->multiply, 2) . ')') . ';'; + $texts.='width:' . $wm . '; max-width:' . $wm . ';'; + $texts.='height:' . $hm . '; max-height:' . $hm . ';'; + $texts.='}'; + $res[] = $texts; + + // Theme + // Background + $body = '#deviceView{'; + $body.='background-color:#' . $this->theme->parametres->backgroundColor . ';'; + switch ($this->theme->parametres->repeat) { + case wsTheme::REPEAT: + $body.='background-repeat:repeat;'; + break; + case wsTheme::NONE: + $body.='background-repeat:no-repeat;'; + break; + case wsTheme::RATIO: + $body.='background-repeat:no-repeat;'; + break; + case wsTheme::STRETCH: + $body.='background-repeat:no-repeat;'; + $body.='background-size:100% 100%;'; + break; + } + if ($this->theme->parametres->backgroundImage != '') { + copy($this->themeRoot . '/' . $this->theme->parametres->backgroundImage, $this->vdir . '/data/images/' . $this->theme->parametres->backgroundImage); + $body.='background-image:url(../images/' . $this->theme->parametres->backgroundImage . ');'; + $body.='background-position:'; + + + switch ($this->theme->parametres->backgroundVAlign) { + case wsTheme::TOP: + $body.='top'; + break; + case wsTheme::MIDDLE: + $body.='center'; + break; + case wsTheme::BOTTOM: + $body.='bottom'; + break; + } + $body.=' '; + switch ($this->theme->parametres->backgroundHAlign) { + case wsTheme::LEFT: + $body.='left'; + break; + case wsTheme::CENTER: + $body.='center'; + break; + case wsTheme::RIGHT: + $body.='right'; + break; + } + $body.=';'; + } + + $body.='}'; + $res[] = $body; + + // Header + $header = '#header{'; + $header.='height:' . $this->theme->parametres->menuHeight . 'px;'; + $header.='background-color:' . self::colorToCSS($this->theme->parametres->menuColor) . ';'; + if ($this->theme->parametres->menuImage != '') { + copy($this->themeRoot . '/' . $this->theme->parametres->menuImage, $this->vdir . '/data/images/' . $this->theme->parametres->menuImage); + $header.='background-image:url(../images/' . $this->theme->parametres->menuImage . ');'; + $header.='background-repeat:no-repeat;'; + $header.='background-size:100% ' . $this->theme->parametres->menuHeight . 'px;'; + } + $header.='}'; + $res[] = $header; + + //Icons + $res = array_merge($res, $this->writeIcons()); + + // Logo + $logo = '#logo{'; + if ($this->theme->parametres->logo) { + copy($this->themeRoot . '/' . $this->theme->parametres->logo, $this->vdir . '/data/images/' . $this->theme->parametres->logo); + $dim = getimagesize($this->vdir . '/data/images/' . $this->theme->parametres->logo); + $logo.='background-image:url(../images/' . $this->theme->parametres->logo . ');width:' . $dim[0] . 'px;height:' . $dim[1] . 'px;'; + } + $logo.='}'; + $res[] = $logo; + + // Credits + $res[] = '#credits,#credits a{color:' . self::colorToCSS($this->theme->parametres->creditsColor) . ';}'; + + // Arrows + $res[] = '#next,#previous{background-color:' . self::colorToCSS($this->theme->parametres->couleurA) . ';}'; + // Book shadow + $shadowColor = self::colorToCSS($this->theme->parametres->bookShadeColor); + if ($shadowColor != 'transparent') { + $res[] = '#shadow{' . $this->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) . ';}'; + + // Menus + # View + $res[] = '.portrait #view{width:' . $w . ';min-height:' . $h . '}'; + $res[] = '.landscape #view{width:' . $w2 . ';min-height:' . $h . '}'; + $res[] = '#view{background-color:' . self::colorToCSS($this->theme->parametres->couleurB) . ';color:' . self::colorToCSS($this->theme->parametres->subTextColor) . ';}'; + # Index + $ratio = $this->book->parametres->width / $this->book->parametres->height; + $thumbh = round(100 / $ratio); + $res[] = '#index .thumb img{width:100px;height:' . $thumbh . 'px;}'; + $res[] = '#index .doubleThumb{height:' . $thumbh . 'px;' . $this->writeCSSUA('box-shadow', '0 0 3px ' . $shadowColor) . '}'; + $res[] = '#index .doubleThumb .overlay{height:' . $thumbh . 'px;}'; + $res[] = '#index .doubleThumb .hits.yes{background-color:' . self::colorToCSS($this->theme->parametres->subSelectColor) . ';color:' . self::colorToCSS($this->theme->parametres->subTextSelectColor) . '}'; + + // Pages styles + foreach ($this->cssColor as $color => $index) { + $res[] = '.c' . $index . '{color:#' . $color . '}'; + } + + foreach ($this->cssSize as $size => $index) { + $res[] = '.s' . $index . '{font-size:' . $size . 'px}'; + } + + foreach ($this->cssLetterSpacing as $letterspacing => $index) { + $res[] = '.l' . $index . '{letter-spacing:' . $letterspacing . 'em}'; + } + + foreach ($this->cssWordSpacing as $wordspacing => $index) { + $res[] = '.w' . $index . '{word-spacing:' . $wordspacing . 'em}'; + } + + foreach ($this->cssX as $x => $index) { + $res[] = '.x' . $index . '{left:' . $x . 'px}'; + } + + foreach ($this->cssY as $y => $index) { + $res[] = '.y' . $index . '{top:' . $y . 'px}'; + } + + foreach ($this->cssRotation as $rotation => $index) { + $rotation*= - 1; + + + $to = 'transform-origin:left top;'; + + $css = '.r' . $index . '{'; + $css.=self::writeCSSUA('transform', 'rotate(' . $rotation . 'deg)') . ';'; + $css.=self::writeCSSUA('transform-origin', 'left top') . ';'; + $css.='margin-top:' . round(cos(deg2rad($rotation)) * -1, 2) . 'em !important;'; + $css.='margin-left:' . round(sin(deg2rad($rotation)), 2) . 'em !important;'; + $css.='}'; + $res[] = $css; + } + + foreach ($this->cssFont as $font => $index) { + $res[] = "@font-face{font-family:F" . $index . ";src:url('F" . $index . ".woff') format('woff'),url('F" . $index . ".ttf') format('truetype'),url('F" . $index . ".svg#" . $font . "') format('svg')}"; + $res[] = '.f' . $index . '{font-family:F' . $index . ',Arial,Helvetica}'; + } + + $res = array_chunk($res, 3500); + foreach ($res as $k => $css) { + file_put_contents(sprintf($file, $k), implode("\n", $css)); + } + return count($res); + } + + protected function writeCSSUA($property, $value) { + $res = array(); + foreach (self::$uaPrefixes as $prefix) { + $res[] = $prefix . $property . ':' . $value; + } + return implode(';', $res); + } + + protected function addLine($line, $document_id) { + $res = array(); + foreach ($line->a as $group) { + $res = array_merge($res, $this->addGroup($group, $document_id)); + } + return array( + 'y' => $this->normalizeFloatValue($line['y']), + 'rotation' => $this->getCSSRotation($this->normalizeFloatValue($line['rotation'], 0)), + "groups" => $res); + } + + protected function addGroup($group, $document_id) { + $alpha = intval(substr($group['color'], 1, 2), 16); + if ($alpha == 0) { + return false; + } + + $first = true; + $letterSpacing = 0; + $letterCount = 0; + $wordSpacing = 0; + $wordCount = 0; + + $res = array(); + $spans = array(); + + foreach ($group->s as $span) { + if ($first && trim((string) $span) == '') { + continue; + } + if ($first) { + $pos = $x = $span['x']; + $pos+=$span['width']; + $first = false; + } else { + if ((float) $span['x'] < (float) $newSpan['x']) { + // On change de groupe + $ls = $ws = 0; + if ($letterCount > 0) { + $ls = $letterSpacing / $letterCount; + } + if ($wordCount > 0) { + $ws = $wordSpacing / $wordCount; + } + + $res[] = array( + 'color' => $this->getCSSColor($group['color']), + 'size' => $this->getCSSSize($group['size']), + 'font' => $this->getCSSFont((string) $group['font'], $document_id), + 'letterspacing' => $this->getCSSLetterSpacing($ls), + 'wordspacing' => $this->getCSSLetterSpacing($ws), + 'y' => 0, + 'x' => $x, + 'spans' => $spans); + + $spans = array(); + $pos = $x = $span['x']; + $pos+=$span['width']; + } else { + + $diff = $span['x'] - $pos; + if ($diff > $group['size'] / 4) { + $space = round($diff / $group['size'], 4); + if ($space > 2) { + // On change de groupe + $ls = $ws = 0; + if ($letterCount > 0) { + $ls = $letterSpacing / $letterCount; + } + if ($wordCount > 0) { + $ws = $wordSpacing / $wordCount; + } + $res[] = array( + 'color' => $this->getCSSColor($group['color']), + 'size' => $this->getCSSSize($group['size']), + 'font' => $this->getCSSFont($group['font'], $document_id), + 'letterspacing' => $this->getCSSLetterSpacing($ls), + 'wordspacing' => $this->getCSSLetterSpacing($ws), + 'y' => 0, + 'x' => $x, + 'spans' => $spans); + + $spans = array(); + $pos = $x = $span['x']; + $pos+=$span['width']; + } else { + + $newSpan = $this->addSpan(' ', true); + array_push($spans, $newSpan); + } + } + } + } + + + $newSpan = $this->addSpan($span); + $pos = $span['x'] + $span['width']; + + array_push($spans, $newSpan); + $copy = (string) $span; + $len = mb_strlen($copy); + str_replace(' ', '-', $copy, $w); + $l = $len - $w; + + $letterCount+=$l; + $wordCount+=$w; + + $letterSpacing+=$l * (float) $span['letterspacing']; + $wordSpacing+=$w * (float) $span['wordspacing']; + } + + if (count($spans)) { + $ls = $ws = 0; + if ($letterCount > 0) { + $ls = $letterSpacing / $letterCount; + } + if ($wordCount > 0) { + $ws = $wordSpacing / $wordCount; + } + + $res[] = array( + 'color' => $this->getCSSColor($group['color']), + 'size' => $this->getCSSSize($group['size']), + 'font' => $this->getCSSFont($group['font'], $document_id), + 'letterspacing' => $this->getCSSLetterSpacing($ls), + 'wordspacing' => $this->getCSSLetterSpacing($ws), + 'y' => 0, + 'x' => $x, + 'spans' => $spans); + } + + return $res; + } + + protected function addSpan($span, $space=false) { + $text = (string) $span; + return array('text' => $text, 'space' => $space, 'x' => $span['x']); + } + + protected function getCSSSize($size) { + $size = $this->normalizeFloatValue($size); + $size*=$this->multiply; + return $this->getIndex($size, $this->cssSize); + } + + protected function getCSSFont($font, $document_id) { + $font = (string) $font; + if (!isset($this->fontDocs[$font])) { + $this->fontDocs[$font] = array(); + } + $this->fontDocs[$font][$document_id] = true; + + return $this->getIndex($font, $this->cssFont); + } + + protected function getCSSColor($color) { + $color = trim($color, '#'); + if (strlen($color) > 6) { + $color = substr($color, 2, 6); + } + if ($color == '000000') { + return null; + } + return $this->getIndex($color, $this->cssColor); + } + + protected function getCSSLetterSpacing($letterspacing) { + + $letterspacing = $this->normalizeFloatValue($letterspacing, 4); + + if ($letterspacing == 0) { + return null; + } + return $this->getIndex($letterspacing, $this->cssLetterSpacing); + } + + protected function getCSSWordSpacing($wordspacing) { + $wordspacing = $this->normalizeFloatValue($wordspacing, 4); + + if ($wordspacing == 0) { + return null; + } + return $this->getIndex($wordspacing, $this->cssWordSpacing); + } + + protected function getCSSRotation($rotation) { + $rotation = $this->normalizeFloatValue($rotation, 0); + if ($rotation == 0) { + return null; + } + return $this->getIndex($rotation, $this->cssRotation); + } + + protected function getCSSX($x) { + $x = round($x); + if ($x == 0) { + return null; + } + return $this->getIndex($x, $this->cssX); + } + + protected function getCSSY($y) { + $y = round($y); + if ($y == 0) { + return null; + } + return $this->getIndex($y, $this->cssY); + } + + protected function getIndex($value, &$tab) { + $value = (string) $value; + if (isset($tab[$value])) { + return $tab[$value]; + } + $res = $this->base62(count($tab)); + $tab[$value] = $res; + return $res; + } + + protected function normalizeFloatValue($value, $round=3) { + $value = str_replace(',', '.', $value); + $value = (float) $value; + $value = round($value, $round); + return $value; + } + + protected function base62($val) { + $chars = '0123456789abcdefghijklmnopqrstuvwxyz'; + $base = strlen($chars); + $str = ''; + do { + $i = $val % $base; + $str = $chars[$i] . $str; + $val = ($val - $i) / $base; + } while ($val > 0); + return $str; + } + + public function copyLinkFile($source, $dest, $video=false) { + // TODO delete that return; + //return; + $origDir = WS_BOOKS . '/working/' . $this->book_id . '/'; + $types = array('mp4', 'ogv', 'webm', 'jpg'); + if ($video) { + return; + wsTools::encodeWebVideos($origDir . $source, null, false); + $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 = $origDir . $so; + if (file_exists($s)) { + $d = $this->vdir . '/' . $dest . '/' . $so; + if (!file_exists(dirname($d))) { + mkdir(dirname($d), 0777, true); + } + copy($s, $d); + } + } + } + + public static function escapeHTML($in) { + $in = htmlentities($in, ENT_NOQUOTES, "UTF-8"); + $in = str_replace(' ', '', $in); + + return $in; + } + + public function __destruct() { + + } + + public static function colorToCSS($color, $forceAlpha=null) { + + if (!is_null($forceAlpha)) { + $a = $forceAlpha * 255; + $a = base_convert($a, 10, 16); + if (strlen($color) == 6) { + $color = $a . $color; + } else { + $color = $a . substr($color, 2, 6); + } + } + + if (strlen($color) == 6) { + return '#' . $color; + } else { + $alpha = substr($color, 0, 2); + $red = substr($color, 2, 2); + $green = substr($color, 4, 2); + $blue = substr($color, 6, 2); + + $components = array('alpha', 'red', 'green', 'blue'); + foreach ($components as $k => $name) { + $hex = substr($color, $k * 2, 2); + $$name = intval($hex, 16); + } + $alpha/=255; + if ($alpha == 0) { + return 'transparent'; + } elseif ($alpha == 1) { + return '#' . substr($color, 2, 6); + } + return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')'; + } + } + +} +?> \ No newline at end of file diff --git a/inc/ws/Util/html5/class.ws.html5.links.php b/inc/ws/Util/html5/class.ws.html5.links.php new file mode 100644 index 000000000..e47b0f47f --- /dev/null +++ b/inc/ws/Util/html5/class.ws.html5.links.php @@ -0,0 +1,334 @@ + $v) { + $this->$k = $v; + } + $this->id = $id; + $this->packager = $packager; + } + + public function getHTMLContainer() { + return ''; + } + + public function getHTMLContent() { + return ''; + } + + public function copyExternalFile($file, $video=false) { + $this->packager->copyLinkFile($file, 'data/links/', $video); + } + + public function getCSSContainer() { + $css = '#link' . $this->id . '{'; + $css.='left:' . $this->left . 'px;top:' . $this->top . 'px;'; + $css.='width:' . $this->width . 'px;height:' . $this->height . 'px;'; + $css.=$this->getCSS(); + $css.='}'; + return $css; + } + + public function getCSS() { + return ''; + } + + public static function getUniversalLocation($loc, $css=false) { + $datas = parse_url($loc); + + if (isset($datas['scheme']) && !is_null($datas['scheme'])) { + return $loc; + } else { + if ($css) { + return '../links/' . $loc; + } else { + return 'data/links/' . $loc; + } + } + } + +} + +class normalLink extends wsPackagerHTML5Link { + + public function getHTMLContent() { + $class = array(); + if ($this->display_area) { + $class[] = 'displayArea'; + } + $c = ''; + if (count($class)) { + $c = ' class="' . implode(' ', $class) . '"'; + } + return ''; + } + + public function getURL() { + return '#'; + } + + public function getTarget() { + return '_self'; + } + +} + +class contentLink extends wsPackagerHTML5Link { + +} + +class webLink extends normalLink { + + public function getURL() { + return wsPackagerHTML5Link::getUniversalLocation($this->to); + } + + public function getTarget() { + return $this->target; + } + + public function getCSS() { + + } + +} + +class mailLink extends normalLink { + + public function getURL() { + return 'mailto:' . $this->to; + } + + public function getTarget() { + return '_self'; + } + +} + +class internalLink extends normalLink { + + public function getURL() { + return '#/page/' . $this->getPage(); + } + + public function getPage() { + if ($this->numerotation == 'physical') { + return $this->to; + } else { + return $this->packager->virtualToPhysical($this->to); + } + } + +} + +class videoLink extends wsPackagerHTML5Link { + + public function getHTMLContent() { + $file = $this->to; + $e = explode('.', $file); + $ext = array_pop($e); + $basename = implode('.', $e); + $w = round($this->width); + $h = round($this->height); + + $res = ''; + return $res; + } + +} + +class webVideoLink extends videoLink { + + public function getHTMLContent() { + return $this->getEmbed(); + } + + public function getEmbed() { + return ''; + } + + public function getEmbedURL() { + if ($this->video_service == 0) { + $url = 'http://www.youtube.com/embed/' . $this->to . '?html5=1'; + } else { + $url = 'http://www.dailymotion.com/embed/video/' . $this->to; + } + return $url; + } + +} + +class actionLink extends internalLink { + + public function getURL() { + return '#' . $to; + } + +} + +class basketLink extends wsPackagerHTML5Link { + +} + +class colorLink extends contentLink { + + public function getCSS() { + return 'background-color:' . wsPackagerHTML5::colorToCSS($this->to) . ';'; + } + +} + +class imageLink extends contentLink { + + public function getCSS() { + $this->copyExternalFile($this->to); + return 'background-image:url(' . wsPackagerHTML5Link::getUniversalLocation($this->to, true) . ');background-size:100% 100%;background-repeat:no-repeat;'; + } + +} + +class fileLink extends normalLink { + + public function getURL() { + $this->copyExternalFile($this->to); + return wsPackagerHTML5Link::getUniversalLocation($this->to); + } + + public function getTarget() { + return '_blank'; + } + +} + +class multimediaLink extends wsPackagerHTML5Link { + + public function getHTMLContent() { + return cubeMedia::flashObject(wsPackagerHTML5Link::getUniversalLocation($this->to), $this->width, $this->height, array(), '', '', 9, '#ffffff', '', 'true', 'noscale', 'transparent'); + } + +} + +class videoPopupLink extends normalLink { + + public function getURL() { + $this->copyExternalFile($this->to, true); + return '#/video/' . $this->to; + } + +} + +class webVideoPopupLink extends videoPopupLink { + + public function getURL() { + if ($this->video_service == 0) { + $service = 'youtube'; + } elseif ($this->video_service == 1) { + $service = 'dailymotion'; + } + return '#/webvideo/' . $service . '/' . $this->to; + } + +} + +?> diff --git a/inc/ws/Util/packager/class.ws.packager.php b/inc/ws/Util/packager/class.ws.packager.php index 5258b68f1..78702703e 100644 --- a/inc/ws/Util/packager/class.ws.packager.php +++ b/inc/ws/Util/packager/class.ws.packager.php @@ -13,8 +13,7 @@ class wsPackager { protected $daoBook; public static function package($book_id, $version) { - //cubePHP::neverStop(); - set_time_limit(10); + cubePHP::neverStop(); if ($version == 'html') { $packager = new wsPackagerHTML($book_id); } elseif ($version == 'win-exe') { diff --git a/inc/ws/Util/packager/html5/class.ws.packager.html5.links.php b/inc/ws/Util/packager/html5/class.ws.packager.html5.links.php deleted file mode 100644 index e47b0f47f..000000000 --- a/inc/ws/Util/packager/html5/class.ws.packager.html5.links.php +++ /dev/null @@ -1,334 +0,0 @@ - $v) { - $this->$k = $v; - } - $this->id = $id; - $this->packager = $packager; - } - - public function getHTMLContainer() { - return ''; - } - - public function getHTMLContent() { - return ''; - } - - public function copyExternalFile($file, $video=false) { - $this->packager->copyLinkFile($file, 'data/links/', $video); - } - - public function getCSSContainer() { - $css = '#link' . $this->id . '{'; - $css.='left:' . $this->left . 'px;top:' . $this->top . 'px;'; - $css.='width:' . $this->width . 'px;height:' . $this->height . 'px;'; - $css.=$this->getCSS(); - $css.='}'; - return $css; - } - - public function getCSS() { - return ''; - } - - public static function getUniversalLocation($loc, $css=false) { - $datas = parse_url($loc); - - if (isset($datas['scheme']) && !is_null($datas['scheme'])) { - return $loc; - } else { - if ($css) { - return '../links/' . $loc; - } else { - return 'data/links/' . $loc; - } - } - } - -} - -class normalLink extends wsPackagerHTML5Link { - - public function getHTMLContent() { - $class = array(); - if ($this->display_area) { - $class[] = 'displayArea'; - } - $c = ''; - if (count($class)) { - $c = ' class="' . implode(' ', $class) . '"'; - } - return ''; - } - - public function getURL() { - return '#'; - } - - public function getTarget() { - return '_self'; - } - -} - -class contentLink extends wsPackagerHTML5Link { - -} - -class webLink extends normalLink { - - public function getURL() { - return wsPackagerHTML5Link::getUniversalLocation($this->to); - } - - public function getTarget() { - return $this->target; - } - - public function getCSS() { - - } - -} - -class mailLink extends normalLink { - - public function getURL() { - return 'mailto:' . $this->to; - } - - public function getTarget() { - return '_self'; - } - -} - -class internalLink extends normalLink { - - public function getURL() { - return '#/page/' . $this->getPage(); - } - - public function getPage() { - if ($this->numerotation == 'physical') { - return $this->to; - } else { - return $this->packager->virtualToPhysical($this->to); - } - } - -} - -class videoLink extends wsPackagerHTML5Link { - - public function getHTMLContent() { - $file = $this->to; - $e = explode('.', $file); - $ext = array_pop($e); - $basename = implode('.', $e); - $w = round($this->width); - $h = round($this->height); - - $res = ''; - return $res; - } - -} - -class webVideoLink extends videoLink { - - public function getHTMLContent() { - return $this->getEmbed(); - } - - public function getEmbed() { - return ''; - } - - public function getEmbedURL() { - if ($this->video_service == 0) { - $url = 'http://www.youtube.com/embed/' . $this->to . '?html5=1'; - } else { - $url = 'http://www.dailymotion.com/embed/video/' . $this->to; - } - return $url; - } - -} - -class actionLink extends internalLink { - - public function getURL() { - return '#' . $to; - } - -} - -class basketLink extends wsPackagerHTML5Link { - -} - -class colorLink extends contentLink { - - public function getCSS() { - return 'background-color:' . wsPackagerHTML5::colorToCSS($this->to) . ';'; - } - -} - -class imageLink extends contentLink { - - public function getCSS() { - $this->copyExternalFile($this->to); - return 'background-image:url(' . wsPackagerHTML5Link::getUniversalLocation($this->to, true) . ');background-size:100% 100%;background-repeat:no-repeat;'; - } - -} - -class fileLink extends normalLink { - - public function getURL() { - $this->copyExternalFile($this->to); - return wsPackagerHTML5Link::getUniversalLocation($this->to); - } - - public function getTarget() { - return '_blank'; - } - -} - -class multimediaLink extends wsPackagerHTML5Link { - - public function getHTMLContent() { - return cubeMedia::flashObject(wsPackagerHTML5Link::getUniversalLocation($this->to), $this->width, $this->height, array(), '', '', 9, '#ffffff', '', 'true', 'noscale', 'transparent'); - } - -} - -class videoPopupLink extends normalLink { - - public function getURL() { - $this->copyExternalFile($this->to, true); - return '#/video/' . $this->to; - } - -} - -class webVideoPopupLink extends videoPopupLink { - - public function getURL() { - if ($this->video_service == 0) { - $service = 'youtube'; - } elseif ($this->video_service == 1) { - $service = 'dailymotion'; - } - return '#/webvideo/' . $service . '/' . $this->to; - } - -} - -?> diff --git a/inc/ws/Util/packager/html5/class.ws.packager.html5.php b/inc/ws/Util/packager/html5/class.ws.packager.html5.php deleted file mode 100644 index ebb1b6dce..000000000 --- a/inc/ws/Util/packager/html5/class.ws.packager.html5.php +++ /dev/null @@ -1,904 +0,0 @@ -version = 'html5'; - } - - protected function preparePackage() { - parent::preparePackage(); - - foreach ($this->pages as $page => $infos) { - $file = WS_DOCS . '/' . $infos['document_id'] . '/html/p' . $infos['document_page'] . '.layout'; - if (file_exists($file)) { - $this->layouts[$page] = simplexml_load_file($file, null, LIBXML_ERR_WARNING); - } - } - - $imagesize = getimagesize(WS_DOCS . '/' . $this->pages[1]['document_id'] . '/html/h72-' . $this->pages[1]['document_page'] . '.jpg'); - $this->pdf2htmlRatio = round($imagesize[0] / $this->layouts[1]['width'], 2); - $this->scale = 4; - $this->multiply = $this->pdf2htmlRatio * $this->scale; - $this->numerotation = explode(',', $this->book->numerotation); - - $this->createHTML(); - } - - public function makePackage() { - parent::makePackage(); - return $this->zip(); - } - - public function virtualToPhysical($virtual) { - if (!in_array($virtual, $this->numerotation)) { - return 1; - } - $p = array_search($virtual, $this->numerotation); - return $p + 1; - } - - protected function compareLines($a, $b) { - if ((float) $a['y'] > (float) $b['y']) { - return 1; - } else { - return -1; - } - } - - protected function createHTML() { - foreach ($this->layouts as $page => $layout) { - $this->div[$page] = array(); - $document_id = $this->pages[$page]['document_id']; - $lines = array(); - foreach ($layout->l as $line) { - $lines[] = $line; - } - usort($lines, array($this, 'compareLines')); - - foreach ($lines as $line) { - $this->div[$page][] = $this->addLine($line, $document_id); - } - } - mkdir($this->vdir . '/data/images', 0777, true); - mkdir($this->vdir . '/data/contents', 0777, true); - mkdir($this->vdir . '/data/background', 0777, true); - mkdir($this->vdir . '/data/thumbnails', 0777, true); - mkdir($this->vdir . '/data/style', 0777, true); - mkdir($this->vdir . '/data/links/pages', 0777, true); - mkdir($this->vdir . '/data/l10n/', 0777, true); - mkdir($this->vdir . '/swf', 0777, true); - - // Copy style folder - $from = WS_COMPILE_ASSETS . '/_html5/style'; - $to = $this->vdir; - `cp -r $from $to`; - - // Copy images folder - $from = WS_COMPILE_ASSETS . '/_html5/images'; - `cp -r $from $to`; - - // Copy swf - copy(WS_COMPILE_ASSETS . '/_html5/swf/video.swf', $this->vdir . '/swf/video.swf'); - - foreach ($this->div as $n => $page) { - file_put_contents($this->vdir . '/data/contents/p' . $n . '.html', $this->writePage($page)); - } - $this->writeFonts(); - $this->writeImages(); - $linksCSS = $this->writeLinks(); - $numCSS = $this->writeCSS($this->vdir . '/data/style/style_%d.css', $linksCSS); - $this->writeLangs(); - $this->writeJs(); - $this->writeIndex($numCSS); - } - - protected function writeIndex($numCSS) { - $html = file_get_contents(WS_COMPILE_ASSETS . '/_html5/_index.html'); - - $titre = $this->book->parametres->title; - $credits = ''; - // Google analytics - $ga = ''; - if ($this->book->parametres->googleAnalytics != '') { - $ga = cubePage::googleAnalytics($this->book->parametres->googleAnalytics); - } - // Feuilles de style - $sheets = array('style/fluidbook.css'); - for ($i = 0; $i < $numCSS; $i++) { - $sheets[] = 'data/style/style_' . $i . '.css'; - } - $style = array(); - foreach ($sheets as $sheet) { - $style[] = ''; - } - $style = implode("\n\t\t", $style); - - $vars = array('titre', 'credits', 'ga', 'style'); - foreach ($vars as $v) { - $html = str_replace('', $$v, $html); - } - file_put_contents($this->vdir . '/index.html', $html); - } - - protected function writeLangs() { - global $core; - $daoLang = new wsDAOLang($core->con); - $lang = $daoLang->selectById($this->book->lang); - $langs = $daoLang->selectAll(); - - - $traductions = (!count($this->book->traductions)) ? $lang->traductions : $this->book->traductions; - file_put_contents($this->vdir . '/data/l10n/default.json', json_encode($traductions)); - foreach ($langs as $lang) { - file_put_contents($this->vdir . '/data/l10n/' . $lang->lang_id . '.json', json_encode($lang->traductions)); - } - } - - protected function writeLinks() { - global $core; - $daoDoc = new wsDAODocument($core->con); - $daoDoc->getLinksAndRulers($this->book_id, $links, $rulers); - - $i = 0; - $pages = array(); - $css = array(); - foreach ($links as $linkData) { - $link = wsPackagerHTML5Link::getInstance($this->base62($i), $linkData, $this); - if (is_null($link)) { - continue; - } - if (!isset($pages[$link->page])) { - $pages[$link->page] = ''; - } - $pages[$link->page] .= $link->getHTMLContainer(); - $css[] = $link->getCSSContainer(); - $i++; - } - - for ($i = 0; $i <= $this->book->parametres->pages + 1; $i++) { - $c = ''; - if (isset($pages[$i])) { - $c = $pages[$i]; - } - file_put_contents($this->vdir . 'data/links/pages/p' . $i . '.html', $c); - } - return $css; - } - - protected function writeJs() { - $files = array('js/libs/modernizr.js', - 'js/libs/sylvester.js', - 'js/libs/jquery/jquery.js', - 'js/libs/jquery/jquery.transform.js', - 'js/libs/jquery/jquery.mousewheel.js', - 'js/libs/jquery/jquery.hashchange.js', - 'js/libs/fluidbook/fluidbook.utils.js', - 'js/libs/fluidbook/fluidbook.cache.js', - 'js/libs/fluidbook/fluidbook.support.js', - 'js/libs/fluidbook/fluidbook.viewport.js', - 'js/libs/fluidbook/fluidbook.desktop.js', - 'js/libs/fluidbook/fluidbook.service.js', - 'js/libs/fluidbook/fluidbook.loader.js', - 'js/libs/fluidbook/fluidbook.l10n.js', - 'js/libs/fluidbook/fluidbook.nav.js', - 'js/libs/fluidbook/fluidbook.js', - 'js/main.js'); - - $mintime = 0; - $minimized = WS_COMPILE_ASSETS . '/_html5/js/min.js'; - if (file_exists($minimized)) { - $mintime = filemtime($minimized); - } - $reminimize = false; - foreach ($files as $file) { - if (filemtime(WS_COMPILE_ASSETS . '/_html5/' . $file) > $mintime) { - $reminimize = true; - break; - } - } - - if ($reminimize) { - $js = ''; - foreach ($files as $file) { - $js.=file_get_contents(WS_COMPILE_ASSETS . '/_html5/' . $file); - $js.="\n\n"; - } - $tmp = cubeFiles::tempnam(); - file_put_contents($tmp, $js); - - $compressor = new cubeCommandLine('yuicompressor'); - $compressor->setPath(CONVERTER_PATH); - $compressor->setArg('charset', 'UTF-8'); - $compressor->setArg('type', 'js'); - $compressor->setArg('line-break', 1024); - $compressor->setArg('o', $minimized); - $compressor->setArg(null, $tmp); - $compressor->execute(); - } - - $js = $this->writeConfig(); - $js.=file_get_contents($minimized); - file_put_contents($this->vdir . '/data/fluidbook.js', $js); - } - - protected function writeConfig() { - $config = cubeObject::merge($this->book->parametres->toStandardObject(), $this->theme->parametres->toStandardObject()); - $config->numerotation = explode(',', $this->book->numerotation); - $config->id = $this->book->book_id; - $config->cacheDate = TIME; - return 'var DATAS=' . json_encode($config) . ';' . "\n"; - } - - protected function writeFonts() { - $formats = array('ttf', 'woff', 'svg'); - - foreach ($this->cssFont as $font => $index) { - - foreach ($formats as $format) { - $fontforge = new cubeCommandLine('convert.pe'); - $fontforge->setPath(CONVERTER_PATH); - foreach ($this->fontDocs[$font] as $document_id => $dummy) { - $fontforge->setArg(null, WS_DOCS . '/' . $document_id . '/fonts/web/' . $font . '.ttf'); - } - $fontforge->setArg(null, $this->vdir . '/data/style/F' . $index . '.' . $format); - $fontforge->execute(); - } - } - } - - protected function writeIcons() { - $res = array(); - // Get the colors used to colorize graphics - if ($this->theme->parametres->colorizeIcons) { - $couleurI = '#' . $this->theme->parametres->couleurI; - } else { - $couleurI = '#FFFFFF'; - } - $arrowsColor = '#' . $this->theme->parametres->arrowsColor; - // Set the icon list with the color - $icons = array('nav-bookmark' => $couleurI, 'nav-friend' => $couleurI, 'nav-help' => $couleurI, 'nav-index' => $couleurI, 'nav-sommaire' => $couleurI, - 'next' => $arrowsColor, 'previous' => $arrowsColor, 'search' => $couleurI, 'nav-facebook' => $couleurI, 'nav-twitter' => $couleurI, - 'help-fingers' => $couleurI, 'help-mouse' => $couleurI); - - foreach ($icons as $icon => $color) { - wsTools::colorizeAndRasterizeIcon($this->theme->parametres->iconSet, $icon, $color, $this->vdir . '/data/images/', 4, $w, $h); - } - return $res; - } - - protected function writeImages() { - - foreach (self::$resolutions as $r) { - mkdir($this->vdir . '/data/background/' . $r, 0777); - } - foreach ($this->pages as $page => $infos) { - foreach (self::$resolutions as $r) { - copy(WS_DOCS . '/' . $infos['document_id'] . '/html/h' . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/p' . $page . '.jpg'); - } - copy(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', $this->vdir . '/data/thumbnails/p' . $page . '.jpg'); - } - } - - protected function writePage($page) { - $res = ''; - foreach ($page as $line) { - $res .= $this->writeLine($line); - } - return $res; - } - - protected function writeLine($line) { - $res = ''; - foreach ($line['groups'] as $group) { - $res.=$this->writeGroup($group, $line); - } - return $res; - } - - protected function writeGroup($group, $line) { - if ($group === false) { - return ''; - } - - $group['y'] = $this->getCSSY(($group['y'] + $line['y']) * $this->multiply); - $group['x'] = $this->getCSSX(($group['x']) * $this->multiply); - - $class = array('g'); - if (!is_null($group['color'])) { - $class[] = 'c' . $group['color']; - } - if (!is_null($group['size'])) { - $class[] = 's' . $group['size']; - } - if (!is_null($group['font'])) { - $class[] = 'f' . $group['font']; - } - if (!is_null($group['x'])) { - $class[] = 'x' . $group['x']; - } - if (!is_null($group['y'])) { - $class[] = 'y' . $group['y']; - } - if (!is_null($line['rotation'])) { - $class[] = 'r' . $line['rotation']; - } - if (!is_null($group['letterspacing'])) { - $class[] = 'l' . $group['letterspacing']; - } - if (!is_null($group['wordspacing'])) { - $class[] = 'w' . $group['wordspacing']; - } - $class = implode(' ', $class); - - $res = '
'; - foreach ($group['spans'] as $span) { - $res.=$this->writeSpan($span); - } - $res.='
'; - return $res; - } - - protected function writeSpan($span) { - if ($span === false) { - return ''; - } - - if ($span['space']) { - return $span['text']; - } else { - return self::escapeHTML($span['text']); - } - } - - protected function writeCSS($file, $links) { - $res = array(); - - // General theme - $h = $this->book->parametres->height . 'px'; - $w2 = ($this->book->parametres->width * 2) . 'px'; - $w = $this->book->parametres->width . 'px'; - $wm = ($this->book->parametres->width * $this->multiply) . 'px'; - $hm = ($this->book->parametres->height * $this->multiply) . 'px'; - - - $navTop = ($this->book->parametres->height - 40 - 100) / 2; - $res[] = '.portrait #pages,.portrait .doublePage.page,.page,.portrait #shadow,#shadow.single,.page .links{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}'; - $res[] = '.background{' . $this->writeCSSUA('transform-origin', 'top left') . ';}'; - foreach (self::$resolutions as $r) { - $ratio = round(72 / $r, 2); - $wr = $this->book->parametres->width / $ratio; - $hr = $this->book->parametres->height / $ratio; - - $br = '.background.r' . $r . '{'; - if ($ratio != 1) { - $br.=$this->writeCSSUA('transform', 'scale(' . $ratio . ')') . ';'; - } - $br.='width:' . $wr . 'px;height:' . $hr . 'px;}'; - $res[] = $br; - } - $res[] = '.doublePage,#pages,.landscape #shadow.double{width:' . $w2 . ';max-width:' . $w2 . ';height:' . $h . ';max-height:' . $h . '}'; - $res[] = '.landscape #shadow.single.right{left: ' . $w . ';}'; - $res[] = '.landscape .page.right{left:' . $w . '}'; - if ($this->theme->parametres->displayPageNumber) { - $res[] = '#pagesnumbers{top:' . $h . ';color:' . self::colorToCSS($this->theme->parametres->colorPageNumber) . '}'; - $res[] = '#pagesnumbers div{width:' . $w . '}'; - } else { - $res[] = '#pagesnumbers{display:none;}'; - } - - $texts = '.texts{' . $this->writeCSSUA('transform-origin', 'top left') . ';'; - $texts.=$this->writeCSSUA('transform', 'scale(' . round(1 / $this->multiply, 2) . ')') . ';'; - $texts.='width:' . $wm . '; max-width:' . $wm . ';'; - $texts.='height:' . $hm . '; max-height:' . $hm . ';'; - $texts.='}'; - $res[] = $texts; - - // Theme - // Background - $body = '#deviceView{'; - $body.='background-color:#' . $this->theme->parametres->backgroundColor . ';'; - switch ($this->theme->parametres->repeat) { - case wsTheme::REPEAT: - $body.='background-repeat:repeat;'; - break; - case wsTheme::NONE: - $body.='background-repeat:no-repeat;'; - break; - case wsTheme::RATIO: - $body.='background-repeat:no-repeat;'; - break; - case wsTheme::STRETCH: - $body.='background-repeat:no-repeat;'; - $body.='background-size:100% 100%;'; - break; - } - if ($this->theme->parametres->backgroundImage != '') { - copy($this->themeRoot . '/' . $this->theme->parametres->backgroundImage, $this->vdir . '/data/images/' . $this->theme->parametres->backgroundImage); - $body.='background-image:url(../images/' . $this->theme->parametres->backgroundImage . ');'; - $body.='background-position:'; - - - switch ($this->theme->parametres->backgroundVAlign) { - case wsTheme::TOP: - $body.='top'; - break; - case wsTheme::MIDDLE: - $body.='center'; - break; - case wsTheme::BOTTOM: - $body.='bottom'; - break; - } - $body.=' '; - switch ($this->theme->parametres->backgroundHAlign) { - case wsTheme::LEFT: - $body.='left'; - break; - case wsTheme::CENTER: - $body.='center'; - break; - case wsTheme::RIGHT: - $body.='right'; - break; - } - $body.=';'; - } - - $body.='}'; - $res[] = $body; - - // Header - $header = '#header{'; - $header.='height:' . $this->theme->parametres->menuHeight . 'px;'; - $header.='background-color:' . self::colorToCSS($this->theme->parametres->menuColor) . ';'; - if ($this->theme->parametres->menuImage != '') { - copy($this->themeRoot . '/' . $this->theme->parametres->menuImage, $this->vdir . '/data/images/' . $this->theme->parametres->menuImage); - $header.='background-image:url(../images/' . $this->theme->parametres->menuImage . ');'; - $header.='background-repeat:no-repeat;'; - $header.='background-size:100% ' . $this->theme->parametres->menuHeight . 'px;'; - } - $header.='}'; - $res[] = $header; - - //Icons - $res = array_merge($res, $this->writeIcons()); - - // Logo - $logo = '#logo{'; - if ($this->theme->parametres->logo) { - copy($this->themeRoot . '/' . $this->theme->parametres->logo, $this->vdir . '/data/images/' . $this->theme->parametres->logo); - $dim = getimagesize($this->vdir . '/data/images/' . $this->theme->parametres->logo); - $logo.='background-image:url(../images/' . $this->theme->parametres->logo . ');width:' . $dim[0] . 'px;height:' . $dim[1] . 'px;'; - } - $logo.='}'; - $res[] = $logo; - - // Credits - $res[] = '#credits,#credits a{color:' . self::colorToCSS($this->theme->parametres->creditsColor) . ';}'; - - // Arrows - $res[] = '#next,#previous{background-color:' . self::colorToCSS($this->theme->parametres->couleurA) . ';}'; - // Book shadow - $shadowColor = self::colorToCSS($this->theme->parametres->bookShadeColor); - if ($shadowColor != 'transparent') { - $res[] = '#shadow{' . $this->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) . ';}'; - - // Menus - # View - $res[] = '.portrait #view{width:' . $w . ';min-height:' . $h . '}'; - $res[] = '.landscape #view{width:' . $w2 . ';min-height:' . $h . '}'; - $res[] = '#view{background-color:' . self::colorToCSS($this->theme->parametres->couleurB) . ';color:' . self::colorToCSS($this->theme->parametres->subTextColor) . ';}'; - # Index - $ratio = $this->book->parametres->width / $this->book->parametres->height; - $thumbh = round(100 / $ratio); - $res[] = '#index .thumb img{width:100px;height:' . $thumbh . 'px;}'; - $res[] = '#index .doubleThumb{height:' . $thumbh . 'px;' . $this->writeCSSUA('box-shadow', '0 0 3px ' . $shadowColor) . '}'; - $res[] = '#index .doubleThumb .overlay{height:' . $thumbh . 'px;}'; - $res[] = '#index .doubleThumb .hits.yes{background-color:' . self::colorToCSS($this->theme->parametres->subSelectColor) . ';color:' . self::colorToCSS($this->theme->parametres->subTextSelectColor) . '}'; - - // Pages styles - foreach ($this->cssColor as $color => $index) { - $res[] = '.c' . $index . '{color:#' . $color . '}'; - } - - foreach ($this->cssSize as $size => $index) { - $res[] = '.s' . $index . '{font-size:' . $size . 'px}'; - } - - foreach ($this->cssLetterSpacing as $letterspacing => $index) { - $res[] = '.l' . $index . '{letter-spacing:' . $letterspacing . 'em}'; - } - - foreach ($this->cssWordSpacing as $wordspacing => $index) { - $res[] = '.w' . $index . '{word-spacing:' . $wordspacing . 'em}'; - } - - foreach ($this->cssX as $x => $index) { - $res[] = '.x' . $index . '{left:' . $x . 'px}'; - } - - foreach ($this->cssY as $y => $index) { - $res[] = '.y' . $index . '{top:' . $y . 'px}'; - } - - foreach ($this->cssRotation as $rotation => $index) { - $rotation*= - 1; - - - $to = 'transform-origin:left top;'; - - $css = '.r' . $index . '{'; - $css.=self::writeCSSUA('transform', 'rotate(' . $rotation . 'deg)') . ';'; - $css.=self::writeCSSUA('transform-origin', 'left top') . ';'; - $css.='margin-top:' . round(cos(deg2rad($rotation)) * -1, 2) . 'em !important;'; - $css.='margin-left:' . round(sin(deg2rad($rotation)), 2) . 'em !important;'; - $css.='}'; - $res[] = $css; - } - - foreach ($this->cssFont as $font => $index) { - $res[] = "@font-face{font-family:F" . $index . ";src:url('F" . $index . ".woff') format('woff'),url('F" . $index . ".ttf') format('truetype'),url('F" . $index . ".svg#" . $font . "') format('svg')}"; - $res[] = '.f' . $index . '{font-family:F' . $index . ',Arial,Helvetica}'; - } - - $res = array_chunk($res, 3500); - foreach ($res as $k => $css) { - file_put_contents(sprintf($file, $k), implode("\n", $css)); - } - return count($res); - } - - protected function writeCSSUA($property, $value) { - $res = array(); - foreach (self::$uaPrefixes as $prefix) { - $res[] = $prefix . $property . ':' . $value; - } - return implode(';', $res); - } - - protected function addLine($line, $document_id) { - $res = array(); - foreach ($line->a as $group) { - $res = array_merge($res, $this->addGroup($group, $document_id)); - } - return array( - 'y' => $this->normalizeFloatValue($line['y']), - 'rotation' => $this->getCSSRotation($this->normalizeFloatValue($line['rotation'], 0)), - "groups" => $res); - } - - protected function addGroup($group, $document_id) { - $alpha = intval(substr($group['color'], 1, 2), 16); - if ($alpha == 0) { - return false; - } - - $first = true; - $letterSpacing = 0; - $letterCount = 0; - $wordSpacing = 0; - $wordCount = 0; - - $res = array(); - $spans = array(); - - foreach ($group->s as $span) { - if ($first && trim((string) $span) == '') { - continue; - } - if ($first) { - $pos = $x = $span['x']; - $pos+=$span['width']; - $first = false; - } else { - if ((float) $span['x'] < (float) $newSpan['x']) { - // On change de groupe - $ls = $ws = 0; - if ($letterCount > 0) { - $ls = $letterSpacing / $letterCount; - } - if ($wordCount > 0) { - $ws = $wordSpacing / $wordCount; - } - - $res[] = array( - 'color' => $this->getCSSColor($group['color']), - 'size' => $this->getCSSSize($group['size']), - 'font' => $this->getCSSFont((string) $group['font'], $document_id), - 'letterspacing' => $this->getCSSLetterSpacing($ls), - 'wordspacing' => $this->getCSSLetterSpacing($ws), - 'y' => 0, - 'x' => $x, - 'spans' => $spans); - - $spans = array(); - $pos = $x = $span['x']; - $pos+=$span['width']; - } else { - - $diff = $span['x'] - $pos; - if ($diff > $group['size'] / 4) { - $space = round($diff / $group['size'], 4); - if ($space > 2) { - // On change de groupe - $ls = $ws = 0; - if ($letterCount > 0) { - $ls = $letterSpacing / $letterCount; - } - if ($wordCount > 0) { - $ws = $wordSpacing / $wordCount; - } - $res[] = array( - 'color' => $this->getCSSColor($group['color']), - 'size' => $this->getCSSSize($group['size']), - 'font' => $this->getCSSFont($group['font'], $document_id), - 'letterspacing' => $this->getCSSLetterSpacing($ls), - 'wordspacing' => $this->getCSSLetterSpacing($ws), - 'y' => 0, - 'x' => $x, - 'spans' => $spans); - - $spans = array(); - $pos = $x = $span['x']; - $pos+=$span['width']; - } else { - - $newSpan = $this->addSpan(' ', true); - array_push($spans, $newSpan); - } - } - } - } - - - $newSpan = $this->addSpan($span); - $pos = $span['x'] + $span['width']; - - array_push($spans, $newSpan); - $copy = (string) $span; - $len = mb_strlen($copy); - str_replace(' ', '-', $copy, $w); - $l = $len - $w; - - $letterCount+=$l; - $wordCount+=$w; - - $letterSpacing+=$l * (float) $span['letterspacing']; - $wordSpacing+=$w * (float) $span['wordspacing']; - } - - if (count($spans)) { - $ls = $ws = 0; - if ($letterCount > 0) { - $ls = $letterSpacing / $letterCount; - } - if ($wordCount > 0) { - $ws = $wordSpacing / $wordCount; - } - - $res[] = array( - 'color' => $this->getCSSColor($group['color']), - 'size' => $this->getCSSSize($group['size']), - 'font' => $this->getCSSFont($group['font'], $document_id), - 'letterspacing' => $this->getCSSLetterSpacing($ls), - 'wordspacing' => $this->getCSSLetterSpacing($ws), - 'y' => 0, - 'x' => $x, - 'spans' => $spans); - } - - return $res; - } - - protected function addSpan($span, $space=false) { - $text = (string) $span; - return array('text' => $text, 'space' => $space, 'x' => $span['x']); - } - - protected function getCSSSize($size) { - $size = $this->normalizeFloatValue($size); - $size*=$this->multiply; - return $this->getIndex($size, $this->cssSize); - } - - protected function getCSSFont($font, $document_id) { - $font = (string) $font; - if (!isset($this->fontDocs[$font])) { - $this->fontDocs[$font] = array(); - } - $this->fontDocs[$font][$document_id] = true; - - return $this->getIndex($font, $this->cssFont); - } - - protected function getCSSColor($color) { - $color = trim($color, '#'); - if (strlen($color) > 6) { - $color = substr($color, 2, 6); - } - if ($color == '000000') { - return null; - } - return $this->getIndex($color, $this->cssColor); - } - - protected function getCSSLetterSpacing($letterspacing) { - - $letterspacing = $this->normalizeFloatValue($letterspacing, 4); - - if ($letterspacing == 0) { - return null; - } - return $this->getIndex($letterspacing, $this->cssLetterSpacing); - } - - protected function getCSSWordSpacing($wordspacing) { - $wordspacing = $this->normalizeFloatValue($wordspacing, 4); - - if ($wordspacing == 0) { - return null; - } - return $this->getIndex($wordspacing, $this->cssWordSpacing); - } - - protected function getCSSRotation($rotation) { - $rotation = $this->normalizeFloatValue($rotation, 0); - if ($rotation == 0) { - return null; - } - return $this->getIndex($rotation, $this->cssRotation); - } - - protected function getCSSX($x) { - $x = round($x); - if ($x == 0) { - return null; - } - return $this->getIndex($x, $this->cssX); - } - - protected function getCSSY($y) { - $y = round($y); - if ($y == 0) { - return null; - } - return $this->getIndex($y, $this->cssY); - } - - protected function getIndex($value, &$tab) { - $value = (string) $value; - if (isset($tab[$value])) { - return $tab[$value]; - } - $res = $this->base62(count($tab)); - $tab[$value] = $res; - return $res; - } - - protected function normalizeFloatValue($value, $round=3) { - $value = str_replace(',', '.', $value); - $value = (float) $value; - $value = round($value, $round); - return $value; - } - - protected function base62($val) { - $chars = '0123456789abcdefghijklmnopqrstuvwxyz'; - $base = strlen($chars); - $str = ''; - do { - $i = $val % $base; - $str = $chars[$i] . $str; - $val = ($val - $i) / $base; - } while ($val > 0); - return $str; - } - - public function copyLinkFile($source, $dest, $video=false) { - // TODO delete that return; - //return; - $origDir = WS_BOOKS . '/working/' . $this->book_id . '/'; - $types = array('mp4', 'ogv', 'webm', 'jpg'); - if ($video) { - return; - wsTools::encodeWebVideos($origDir . $source, null, false); - $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 = $origDir . $so; - if (file_exists($s)) { - $d = $this->vdir . '/' . $dest . '/' . $so; - if (!file_exists(dirname($d))) { - mkdir(dirname($d), 0777, true); - } - copy($s, $d); - } - } - } - - public static function escapeHTML($in) { - $in = htmlentities($in, ENT_NOQUOTES, "UTF-8"); - $in = str_replace(' ', '', $in); - - return $in; - } - - public function __destruct() { - - } - - public static function colorToCSS($color, $forceAlpha=null) { - - if (!is_null($forceAlpha)) { - $a = $forceAlpha * 255; - $a = base_convert($a, 10, 16); - if (strlen($color) == 6) { - $color = $a . $color; - } else { - $color = $a . substr($color, 2, 6); - } - } - - if (strlen($color) == 6) { - return '#' . $color; - } else { - $alpha = substr($color, 0, 2); - $red = substr($color, 2, 2); - $green = substr($color, 4, 2); - $blue = substr($color, 6, 2); - - $components = array('alpha', 'red', 'green', 'blue'); - foreach ($components as $k => $name) { - $hex = substr($color, $k * 2, 2); - $$name = intval($hex, 16); - } - $alpha/=255; - if ($alpha == 0) { - return 'transparent'; - } elseif ($alpha == 1) { - return '#' . substr($color, 2, 6); - } - return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')'; - } - } - -} - -?> \ No newline at end of file diff --git a/index.php b/index.php index 66228e9d2..8ceb9b775 100644 --- a/index.php +++ b/index.php @@ -14,6 +14,8 @@ $jsvar['SITE_PATH'] = SITE_PATH; $css[] = WEBROOT . '/style/common.css'; $css[] = CSS_PATH . '/style.css'; +$meta['viewport'] = 'width=device-width, initial-scale=1, maximum-scale=1'; + $standard = 'XHTML 1.0 Transitional'; echo $core->url->getDocument(); diff --git a/js/common.js b/js/common.js index be69e81e1..7b0747e6b 100644 --- a/js/common.js +++ b/js/common.js @@ -3,6 +3,15 @@ TO_LOAD[TO_LOAD_INDEX]='load_common_extranet();'; FIRST_LOAD=true; function load_common_extranet(){ + var viewportWidth=1030; + if($("#main.big").length>0){ + $("#header").addClass('big'); + viewportWidth=1250; + } + + var is=screen.width/viewportWidth; + $('meta[name="viewport"]').attr('content','width='+viewportWidth+'px,initial-scale='+is+',maximum-scale:2.0'); + if($(".dashboard").length>=1 && $("#dash").length>=1){ $("#dash").sortable('destroy'); if(FIRST_LOAD){ @@ -11,7 +20,9 @@ function load_common_extranet(){ FIRST_LOAD=true; $.ajax({ url : SITE_PATH+'ajax/reloadDashboards', - success : function(data){MyAjax(data);} + success : function(data){ + MyAjax(data); + } }); } @@ -39,15 +50,15 @@ function load_common_extranet(){ $.ajax({ url : SITE_PATH+'ajax/saveTimereport/'+a[1]+'/'+a[2]+'/'+val, success : function(data){ - FIRST_LOAD=true; - MyAjax(data); - var td=$(f).parents('td').get(0); - if(parseFloat($(f).val())>0){ - $(td).addClass('filled'); - }else{ - $(td).removeClass('filled'); - } - } + FIRST_LOAD=true; + MyAjax(data); + var td=$(f).parents('td').get(0); + if(parseFloat($(f).val())>0){ + $(td).addClass('filled'); + }else{ + $(td).removeClass('filled'); + } + } }); }); @@ -56,7 +67,9 @@ function load_common_extranet(){ var div=$(this).parents('.dashboard').get(0); var liste=$(div).find('.liste'); - $(liste).slideToggle('fast',function(){resize();}); + $(liste).slideToggle('fast',function(){ + resize(); + }); $(this).toggleClass('close'); $.ajax({ @@ -151,7 +164,9 @@ function resize(){ function refreshFiles(){ $.ajax({ url : SITE_PATH+'ajax/refreshFichiers', - success : function(data){MyAjax(data);} + success : function(data){ + MyAjax(data); + } }); } diff --git a/style/common.css b/style/common.css index b729fddc0..4333aee83 100644 --- a/style/common.css +++ b/style/common.css @@ -1,3 +1,8 @@ +input[type="text"],input[type="password"],input[type="email"],input[type="search"],select,textarea{ + font-family:Verdana; + font-size:12px; +} + @font-face { font-family: 'UniversCondensedBold'; src: url('univers-condensedbold-webfont.eot'); diff --git a/style/extranet/style.css b/style/extranet/style.css index 27a980cc7..756b12d48 100644 --- a/style/extranet/style.css +++ b/style/extranet/style.css @@ -21,10 +21,8 @@ abbr{cursor:help;border-bottom:1px dotted #fff;} td{height:30px;color:#333;} -input[type="text"],input[type="password"],select,textarea{ +input[type="text"],input[type="password"],input[type="email"],input[type="search"],select,textarea{ color:#666; - font-family:Verdana; - font-size:12px; } .message{text-align:center;font-size:11px;color:#da4f24;background:#fff;} diff --git a/style/ws/style.css b/style/ws/style.css index 15ccfdbce..2ff19e4d6 100644 --- a/style/ws/style.css +++ b/style/ws/style.css @@ -22,10 +22,8 @@ abbr{cursor:help;border-bottom:1px dotted #797D62;} td{height:30px;} -input[type="text"],input[type="password"],select,textarea{ +input[type="text"],input[type="password"],input[type="email"],input[type="search"],select,textarea{ color:#797D62; - font-family:Verdana; - font-size:12px; } .message{text-align:center;font-size:11px;color:#da4f24;background:#fff;} @@ -361,9 +359,17 @@ input[type="text"],input[type="password"],select,textarea{ /* Menu Contextuel */ .contextMenu{border:1px solid #000;float:left;position:absolute;display:none;z-index:100000;} -.contextMenu li{border-bottom:1px solid #ccc;padding:12px;padding-left:20px;padding-right:20px;list-style-type:none;background:#fff;height:12px;} -.contextMenu li:hover{background:#ccc;} -.contextMenu li a:hover{text-decoration:none;} +.contextMenu li a{ + border-bottom:1px solid #ccc; + padding:12px; + padding-left:20px; + padding-right:20px; + background:#fff; + min-height:12px; + text-decoration:none; + display:inline-block; +} +.contextMenu li a:hover{background:#ccc;} .contextMenu li img{margin:5px;margin-right:7px;vertical-align:middle;float:none;} .contextMenu li.head{background:#666b74;font-weight:bold;color:#fff;text-align:center;border-bottom:1px solid #000;} @@ -389,7 +395,7 @@ input[type="text"],input[type="password"],select,textarea{ } .ac_results iframe{ -display:none; + display:none; } /* Traduction */ @@ -429,12 +435,12 @@ display:none; } .graphStats .legende{ - margin-top:10px; + margin-top:10px; margin-bottom:10px; } .graphStats .legende td{ - margin-top:10px; + margin-top:10px; margin-bottom:10px; }