From 9fe782458843c96c9504e8b761fef60c1490df3b Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Sun, 17 Apr 2011 09:08:46 +0000 Subject: [PATCH] --- inc/ws/Controlleur/class.ws.stats.php | 12 +- inc/ws/Metier/class.ws.book.parametres.php | 3 +- inc/ws/Util/class.ws.swf2html.php | 1 - .../Util/packager/class.ws.packager.html5.php | 106 ++++++++++++++---- 4 files changed, 91 insertions(+), 31 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.stats.php b/inc/ws/Controlleur/class.ws.stats.php index 9a43a10dc..135e7ccef 100644 --- a/inc/ws/Controlleur/class.ws.stats.php +++ b/inc/ws/Controlleur/class.ws.stats.php @@ -447,11 +447,11 @@ class wsStats { $res .= '
' ; $res .= self::graph_mensuel($bid, $annee, $mois, $stats); $res . '
'; - $res .= self::detailJour($book, $stats); + $res .= self::detailJour($book, $annee, $mois, $stats); $res .= commonPage::bf(); // . $res .= commonPage::bh('stats_detail_pages'); - $res .= self::detailPages($book, $stats); + $res .= self::detailPages($book,$annee,$mois, $stats); $res .= commonPage::bf(); // . if ($book->parametres->search == 0) { @@ -565,7 +565,7 @@ class wsStats { return $line; } - public static function detailJour($book, $stats) + public static function detailJour($book, $annee, $mois, $stats) { $colsTitles = array(__('Jour'), __('Lieux de visite'), __('Visiteurs uniques'), __('Visites'), __('Pages vues'), __('Liens cliqués')); $lines = array(); @@ -578,11 +578,12 @@ class wsStats { $day['views'], $day['links']); } + $time_page = mktime(0, 0, 0, $mois, 15, $annee); return self::table(__('Détail par jour') . ' - ' . strftime('%B %Y', $time_page), $colsTitles, $lines, array('liste', 'max'), true); } - public static function detailPages($book, $stats) + public static function detailPages($book,$annee,$mois, $stats) { $colsTitles = array(__('Pages')); if ($book->parametres->stats_score) { @@ -629,7 +630,7 @@ class wsStats { } $lines[] = $line; } - $res .= ''; + $time_page = mktime(0, 0, 0, $mois, 15, $annee); return self::table(__('Détail par page') . ' - ' . strftime('%B %Y', $time_page), $colsTitles, $lines, array('liste', 'max')); } @@ -675,6 +676,7 @@ class wsStats { { $colsTitles = array(__('Pays'), __('Visiteurs')); $lines = array(); + $i = 0; foreach ($stats->countries->country as $country) { $pays = $country['code']; diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index d80f79f26..80baf8327 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -92,9 +92,10 @@ class wsBookParametres extends wsParametres { 'fieldsnames' => array('zoomMode', '|', 'zoom', 'zoomw')); // . $this->fields['stats'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Activer les statistiques Fluidbook'), 'grade' => 3); + $this->fields['stats_score'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Afficher les scores dans les rapports'), 'grade' => 5); $this->fields['googleAnalytics'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Code Google Analytics'), 'size' => 10); $this->forms['stats'] = array('label' => __('Statistiques'), - 'fieldsnames' => array('stats', 'googleAnalytics')); + 'fieldsnames' => array('stats', 'stats_score', '|', 'googleAnalytics')); // . $swfFilter = new stdClass(); $swfFilter->name = __('Animation SWF') . ' (*.swf)'; diff --git a/inc/ws/Util/class.ws.swf2html.php b/inc/ws/Util/class.ws.swf2html.php index f2ff41eda..6280de9a2 100644 --- a/inc/ws/Util/class.ws.swf2html.php +++ b/inc/ws/Util/class.ws.swf2html.php @@ -94,7 +94,6 @@ class wsSWF2HTMLTag { class wsSWF2HTMLFont extends wsSWF2HTMLTag { public $id = null; public $name = null; - public $chars = array(); public function __construct($line, &$converter) { diff --git a/inc/ws/Util/packager/class.ws.packager.html5.php b/inc/ws/Util/packager/class.ws.packager.html5.php index 445925059..1c180ff24 100644 --- a/inc/ws/Util/packager/class.ws.packager.html5.php +++ b/inc/ws/Util/packager/class.ws.packager.html5.php @@ -5,10 +5,11 @@ class wsPackagerHTML5 extends wsPackager { protected $cssSize = array(); protected $cssColor = array(); protected $cssOpacity = array(); - protected $cssFont = array(); + protected $fonts = array(); + protected $fontsNames = array(); + protected $fontsCount = 0; protected $div = array(); - protected $css = array(); public function __construct($book_id) { @@ -21,9 +22,7 @@ class wsPackagerHTML5 extends wsPackager { parent::preparePackage(); foreach($this->pages as $page => $infos) { - fb($infos); - $file = WS_DOCS . '/' . $infos['document_id'] . '/html/' . $infos['document_page'] . '.obj'; - fb($file); + $file = WS_DOCS . '/' . $infos['document_id'] . '/html/p' . $infos['document_page'] . '.obj'; if (file_exists($file)) { $this->layouts[$page] = unserialize(file_get_contents($file)); } @@ -32,21 +31,41 @@ class wsPackagerHTML5 extends wsPackager { $this->createHTML(); } + public function makePackage() + { + parent::makePackage(); + return $this->zip(); + } + protected function createHTML() { foreach($this->layouts as $page => $infos) { $this->div[$page] = array(); foreach($infos->tags as $tag) { if ($tag instanceof wsSWF2HTMLFont) { - $this->addFont($tag, $infos); + $this->addFont($tag, $this->pages[$page], $page); } else if ($tag instanceof wsSWF2HTMLParagraph) { - $this->addParagraph($tag, $this->div[$page]); + $this->addParagraph($tag, $this->div[$page], $page); } } } - file_put_contents($this->vdir . 'style.css', implode("\n", $this->css)); + mkdir($this->vdir . '/style', 0777, true); + mkdir($this->vdir . '/contents', 0777, true); + mkdir($this->vdir . '/images', 0777, true); + mkdir($this->vdir . '/fonts', 0777, true); + + file_put_contents($this->vdir . '/style/style.css', $this->writeCSS()); foreach($this->div as $n => $page) { - file_put_contents($this->vdir . 'p' . $n . '.html', $this->writePage($page)); + file_put_contents($this->vdir . '/contents/p' . $n . '.html', $this->writePage($page)); + } + $fext = array('ttf', 'eot', 'svg', 'svgz', 'woff'); + foreach($this->fonts as $font) { + if (!$font['embed']) { + return; + } + foreach($fext as $ext) { + copy($font['file'] . '.' . $ext, $this->vdir . '/fonts/' . $font['name'] . '.' . $ext); + } } } @@ -72,35 +91,70 @@ class wsPackagerHTML5 extends wsPackager { protected function writeSpan($span) { $res = 'cssColor as $color => $index) { + $res[] = '.c' . $index . '{color:' . $color . ';}'; + } + foreach($this->cssSize as $size => $index) { + $res[] = '.s' . $index . '{font-size:' . $size . 'px;}'; + } + + foreach($this->fonts as $id => $font) { + if ($font['embed']) { + $svg = simplexml_load_file($font['file'] . '.svg'); + foreach($svg->defs->font as $f) { + $svgid = $f['id']; + break; + } + $res[] = "@font-face{font-family:'" . $font['name'] . "';src:url('" . $font['name'] . ".eot');src:url('" . $font['name'] . ".eot?#iefix') format('eot'),url('" . $font['name'] . ".woff') format('woff'),url('" . $font['name'] . ".ttf') format('truetype'),url('" . $font['name'] . ".svgz#" . $svgid . "') format('svgz'),url('" . $font['name'] . ".svg#" . $svgid . "') format('svg');font-weight:normal;font-style:normal;}"; + $res[] = '.f' . $font['index'] . '{font-family:' . $font['name'] . ',Arial,Helvetica;}'; + } else { + $res[] = '.f' . $font['index'] . '{font-family:' . $font['realname'] . ',Arial,Helvetica;}'; + } + } + return implode("\n", $res); + } + + protected function addFont($tag, $infos, $page) + { + $this->fontsNames[$tag->id . ',' . $page] = $tag->name; + if (isset($this->fonts[$tag->name])) { + return; + } + $index = $this->fontsCount; + $file = WS_DOCS . '/' . $infos['document_id'] . '/fonts/web/' . $tag->name; + $embed = file_exists($file . '.ttf'); + $this->fonts[$tag->name] = array('index' => $index, 'realname' => $tag->name, 'name' => 'FB' . $index, 'file' => $file, 'embed' => $embed); + $this->fontsCount++; } - protected function addParagraph($tag, $div) + protected function addParagraph($tag, &$div, $page) { - $d = array('span' => array(), 'left' => $tag->left, 'right' => $tag->right); + $d = array('span' => array(), 'left' => $tag->left, 'top' => $tag->top); foreach($tag->textes as $text) { - $d['span'][] = $this->addText($text); + $d['span'][] = $this->addCSSText($text, $page); } $div[] = $d; } - protected function addCSSText($text) + protected function addCSSText($text, $page) { return array('text' => $text->text, 'color' => $this->getCSSColor($text->color), 'size' => $this->getCSSSize($text->size), - 'font' => $this->getCSSFont($text->font), - 'left' => $text->left, - 'right' => $text->right); + 'font' => $this->getCSSFont($text->font, $page), + 'left' => $text->x, + 'top' => $text->y); } protected function getCSSSize($size) @@ -110,16 +164,20 @@ class wsPackagerHTML5 extends wsPackager { protected function getCSSFont($font, $page) { - $fontname = $page->fonts[$font]->name; - return $this->getIndex($fontname, $this->cssFont); + $name = $this->fontsNames[$font . ',' . $page]; + + return $this->fonts[$name]['index']; } protected function getCSSColor($color) { + if (strlen($color) > 7) { + $color = substr($color, 0, 7); + } return $this->getIndex($color, $this->cssColor); } - protected function getIndex($value, $tab) + protected function getIndex($value, &$tab) { if (isset($tab[$value])) { return $tab[$value]; @@ -129,8 +187,8 @@ class wsPackagerHTML5 extends wsPackager { return $res; } - public function __destruct(){ - + public function __destruct() + { } } -- 2.39.5