]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sun, 17 Apr 2011 09:08:46 +0000 (09:08 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sun, 17 Apr 2011 09:08:46 +0000 (09:08 +0000)
inc/ws/Controlleur/class.ws.stats.php
inc/ws/Metier/class.ws.book.parametres.php
inc/ws/Util/class.ws.swf2html.php
inc/ws/Util/packager/class.ws.packager.html5.php

index 9a43a10dcf6bdf0ab16f5eafb4f550abce34ec34..135e7ccefb584da4893d8aedac0548ff47b61316 100644 (file)
@@ -447,11 +447,11 @@ class wsStats {
                $res .= '<div class="center" style="width:944px;position:relative;">' ;\r
                $res .= self::graph_mensuel($bid, $annee, $mois, $stats);\r
                $res . '</div>';\r
-               $res .= self::detailJour($book, $stats);\r
+               $res .= self::detailJour($book, $annee, $mois, $stats);\r
                $res .= commonPage::bf();\r
                // .\r
                $res .= commonPage::bh('stats_detail_pages');\r
-               $res .= self::detailPages($book, $stats);\r
+               $res .= self::detailPages($book,$annee,$mois, $stats);\r
                $res .= commonPage::bf();\r
                // .\r
                if ($book->parametres->search == 0) {\r
@@ -565,7 +565,7 @@ class wsStats {
                return $line;\r
        }\r
 \r
-       public static function detailJour($book, $stats)\r
+       public static function detailJour($book, $annee, $mois, $stats)\r
        {\r
                $colsTitles = array(__('Jour'), __('Lieux de visite'), __('Visiteurs uniques'), __('Visites'), __('Pages vues'), __('Liens cliqués'));\r
                $lines = array();\r
@@ -578,11 +578,12 @@ class wsStats {
                                $day['views'],\r
                                $day['links']);\r
                }\r
+               $time_page = mktime(0, 0, 0, $mois, 15, $annee);\r
 \r
                return self::table(__('Détail par jour') . ' - ' . strftime('%B %Y', $time_page), $colsTitles, $lines, array('liste', 'max'), true);\r
        }\r
 \r
-       public static function detailPages($book, $stats)\r
+       public static function detailPages($book,$annee,$mois, $stats)\r
        {\r
                $colsTitles = array(__('Pages'));\r
                if ($book->parametres->stats_score) {\r
@@ -629,7 +630,7 @@ class wsStats {
                        }\r
                        $lines[] = $line;\r
                }\r
-               $res .= '</table>';\r
+               $time_page = mktime(0, 0, 0, $mois, 15, $annee);\r
                return self::table(__('Détail par page') . ' - ' . strftime('%B %Y', $time_page), $colsTitles, $lines, array('liste', 'max'));\r
        }\r
 \r
@@ -675,6 +676,7 @@ class wsStats {
        {\r
                $colsTitles = array(__('Pays'), __('Visiteurs'));\r
                $lines = array();\r
+               $i = 0;\r
 \r
                foreach ($stats->countries->country as $country) {\r
                        $pays = $country['code'];\r
index d80f79f26139720e749dbd9d1c2ddb1261395844..80baf83273e21e889c82bdd1b60af7a930f279c0 100644 (file)
@@ -92,9 +92,10 @@ class wsBookParametres extends wsParametres {
                        'fieldsnames' => array('zoomMode', '|', 'zoom', 'zoomw'));\r
                // .\r
                $this->fields['stats'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Activer les statistiques Fluidbook'), 'grade' => 3);\r
+               $this->fields['stats_score'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Afficher les scores dans les rapports'), 'grade' => 5);\r
                $this->fields['googleAnalytics'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Code Google Analytics'), 'size' => 10);\r
                $this->forms['stats'] = array('label' => __('Statistiques'),\r
-                       'fieldsnames' => array('stats', 'googleAnalytics'));\r
+                       'fieldsnames' => array('stats', 'stats_score', '|', 'googleAnalytics'));\r
                // .\r
                $swfFilter = new stdClass();\r
                $swfFilter->name = __('Animation SWF') . ' (*.swf)';\r
index f2ff41eda168fd980abf161292538eda0137a0a5..6280de9a2bdea0e33d4ba550b12a7d123b93299a 100644 (file)
@@ -94,7 +94,6 @@ class wsSWF2HTMLTag {
 class wsSWF2HTMLFont extends wsSWF2HTMLTag {\r
        public $id = null;\r
        public $name = null;\r
-       public $chars = array();\r
 \r
        public function __construct($line, &$converter)\r
        {\r
index 4459250598b59a51d104206bf73b2c6d2ea0ad62..1c180ff243aab6d6d5a3ce3e92d1538fe410dc5d 100644 (file)
@@ -5,10 +5,11 @@ class wsPackagerHTML5 extends wsPackager {
        protected $cssSize = array();\r
        protected $cssColor = array();\r
        protected $cssOpacity = array();\r
-       protected $cssFont = array();\r
+       protected $fonts = array();\r
+       protected $fontsNames = array();\r
+       protected $fontsCount = 0;\r
 \r
        protected $div = array();\r
-       protected $css = array();\r
 \r
        public function __construct($book_id)\r
        {\r
@@ -21,9 +22,7 @@ class wsPackagerHTML5 extends wsPackager {
                parent::preparePackage();\r
 \r
                foreach($this->pages as $page => $infos) {\r
-               fb($infos);\r
-                       $file = WS_DOCS . '/' . $infos['document_id'] . '/html/' . $infos['document_page'] . '.obj';\r
-                       fb($file);\r
+                       $file = WS_DOCS . '/' . $infos['document_id'] . '/html/p' . $infos['document_page'] . '.obj';\r
                        if (file_exists($file)) {\r
                                $this->layouts[$page] = unserialize(file_get_contents($file));\r
                        }\r
@@ -32,21 +31,41 @@ class wsPackagerHTML5 extends wsPackager {
                $this->createHTML();\r
        }\r
 \r
+       public function makePackage()\r
+       {\r
+               parent::makePackage();\r
+               return $this->zip();\r
+       }\r
+\r
        protected function createHTML()\r
        {\r
                foreach($this->layouts as $page => $infos) {\r
                        $this->div[$page] = array();\r
                        foreach($infos->tags as $tag) {\r
                                if ($tag instanceof wsSWF2HTMLFont) {\r
-                                       $this->addFont($tag, $infos);\r
+                                       $this->addFont($tag, $this->pages[$page], $page);\r
                                } else if ($tag instanceof wsSWF2HTMLParagraph) {\r
-                                       $this->addParagraph($tag, $this->div[$page]);\r
+                                       $this->addParagraph($tag, $this->div[$page], $page);\r
                                }\r
                        }\r
                }\r
-               file_put_contents($this->vdir . 'style.css', implode("\n", $this->css));\r
+               mkdir($this->vdir . '/style', 0777, true);\r
+               mkdir($this->vdir . '/contents', 0777, true);\r
+               mkdir($this->vdir . '/images', 0777, true);\r
+               mkdir($this->vdir . '/fonts', 0777, true);\r
+\r
+               file_put_contents($this->vdir . '/style/style.css', $this->writeCSS());\r
                foreach($this->div as $n => $page) {\r
-                       file_put_contents($this->vdir . 'p' . $n . '.html', $this->writePage($page));\r
+                       file_put_contents($this->vdir . '/contents/p' . $n . '.html', $this->writePage($page));\r
+               }\r
+               $fext = array('ttf', 'eot', 'svg', 'svgz', 'woff');\r
+               foreach($this->fonts as $font) {\r
+                       if (!$font['embed']) {\r
+                               return;\r
+                       }\r
+                       foreach($fext as $ext) {\r
+                               copy($font['file'] . '.' . $ext, $this->vdir . '/fonts/' . $font['name'] . '.' . $ext);\r
+                       }\r
                }\r
        }\r
 \r
@@ -72,35 +91,70 @@ class wsPackagerHTML5 extends wsPackager {
        protected function writeSpan($span)\r
        {\r
                $res = '<span ';\r
-               $res .= 'style="left:' . $span['left'] . 'px;top:' . $span['top'] . '" ';\r
+               $res .= 'style="left:' . $span['left'] . 'px;top:' . $span['top'] . 'px" ';\r
                $res .= 'class="c' . $span['color'] . ' s' . $span['size'] . ' f' . $span['font'] . '"';\r
                $res .= '>';\r
-               $res .= htmlentities($span['text']);\r
+               $res .= htmlentities($span['text'], ENT_NOQUOTES, 'UTF-8');\r
                $res .= '</span>';\r
                return $res;\r
        }\r
 \r
-       protected function addFont($tag)\r
+       protected function writeCSS()\r
        {\r
+               $res = array();\r
+               foreach($this->cssColor as $color => $index) {\r
+                       $res[] = '.c' . $index . '{color:' . $color . ';}';\r
+               }\r
+               foreach($this->cssSize as $size => $index) {\r
+                       $res[] = '.s' . $index . '{font-size:' . $size . 'px;}';\r
+               }\r
+\r
+               foreach($this->fonts as $id => $font) {\r
+                       if ($font['embed']) {\r
+                               $svg = simplexml_load_file($font['file'] . '.svg');\r
+                               foreach($svg->defs->font as $f) {\r
+                                       $svgid = $f['id'];\r
+                                       break;\r
+                               }\r
+                               $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;}";\r
+                               $res[] = '.f' . $font['index'] . '{font-family:' . $font['name'] . ',Arial,Helvetica;}';\r
+                       } else {\r
+                               $res[] = '.f' . $font['index'] . '{font-family:' . $font['realname'] . ',Arial,Helvetica;}';\r
+                       }\r
+               }\r
+               return implode("\n", $res);\r
+       }\r
+\r
+       protected function addFont($tag, $infos, $page)\r
+       {\r
+               $this->fontsNames[$tag->id . ',' . $page] = $tag->name;\r
+               if (isset($this->fonts[$tag->name])) {\r
+                       return;\r
+               }\r
+               $index = $this->fontsCount;\r
+               $file = WS_DOCS . '/' . $infos['document_id'] . '/fonts/web/' . $tag->name;\r
+               $embed = file_exists($file . '.ttf');\r
+               $this->fonts[$tag->name] = array('index' => $index, 'realname' => $tag->name, 'name' => 'FB' . $index, 'file' => $file, 'embed' => $embed);\r
+               $this->fontsCount++;\r
        }\r
 \r
-       protected function addParagraph($tag, $div)\r
+       protected function addParagraph($tag, &$div, $page)\r
        {\r
-               $d = array('span' => array(), 'left' => $tag->left, 'right' => $tag->right);\r
+               $d = array('span' => array(), 'left' => $tag->left, 'top' => $tag->top);\r
                foreach($tag->textes as $text) {\r
-                       $d['span'][] = $this->addText($text);\r
+                       $d['span'][] = $this->addCSSText($text, $page);\r
                }\r
                $div[] = $d;\r
        }\r
 \r
-       protected function addCSSText($text)\r
+       protected function addCSSText($text, $page)\r
        {\r
                return array('text' => $text->text,\r
                        'color' => $this->getCSSColor($text->color),\r
                        'size' => $this->getCSSSize($text->size),\r
-                       'font' => $this->getCSSFont($text->font),\r
-                       'left' => $text->left,\r
-                       'right' => $text->right);\r
+                       'font' => $this->getCSSFont($text->font, $page),\r
+                       'left' => $text->x,\r
+                       'top' => $text->y);\r
        }\r
 \r
        protected function getCSSSize($size)\r
@@ -110,16 +164,20 @@ class wsPackagerHTML5 extends wsPackager {
 \r
        protected function getCSSFont($font, $page)\r
        {\r
-               $fontname = $page->fonts[$font]->name;\r
-               return $this->getIndex($fontname, $this->cssFont);\r
+               $name = $this->fontsNames[$font . ',' . $page];\r
+\r
+               return $this->fonts[$name]['index'];\r
        }\r
 \r
        protected function getCSSColor($color)\r
        {\r
+               if (strlen($color) > 7) {\r
+                       $color = substr($color, 0, 7);\r
+               }\r
                return $this->getIndex($color, $this->cssColor);\r
        }\r
 \r
-       protected function getIndex($value, $tab)\r
+       protected function getIndex($value, &$tab)\r
        {\r
                if (isset($tab[$value])) {\r
                        return $tab[$value];\r
@@ -129,8 +187,8 @@ class wsPackagerHTML5 extends wsPackager {
                return $res;\r
        }\r
 \r
-       public function __destruct(){\r
-\r
+       public function __destruct()\r
+       {\r
        }\r
 }\r
 \r