]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 4 Apr 2011 06:37:03 +0000 (06:37 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 4 Apr 2011 06:37:03 +0000 (06:37 +0000)
.htaccess
inc/ws/Metier/class.ws.document.php
inc/ws/Util/class.ws.swf2html.php
testSWF2HTML.php [new file with mode: 0644]

index d861e72a28e96f1e7abef11820a62403585f8764..f54024048c9734d6172da49dfd80c3f4ca8178ab 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -1,40 +1,46 @@
 Options +FollowSymlinks\r
 \r
-RewriteEngine on\r
-RewriteBase /\r
+#Charset\r
+AddDefaultCharset UTF-8\r
+AddCharset UTF-8 log\r
 \r
 # Static\r
-ExpiresActive On\r
-ExpiresDefault "modification plus 1 month"\r
-#RequestHeader  edit "If-None-Match" "^(.*)-gzip$" "$1"\r
-#Header  edit "ETag" "^(.*[^g][^z][^i][^p])$" "$1-gzip"\r
-\r
-# Favicon\r
-RewriteCond %{HTTP_HOST} cubedesigners\r
-RewriteRule ^favicon.ico$ images/extranet/favicon.ico [L]\r
-\r
-RewriteCond %{HTTP_HOST} fluidbook\r
-RewriteRule ^favicon.ico$ images/ws/favicon.ico [L]\r
-\r
-# Skip\r
-RewriteRule ^phpMyAdmin - [L]\r
-#RewriteRule ^books - [L]\r
-#RewriteRule ^docs - [L]\r
-\r
-RewriteRule ^ajax/supprimeFichier/([0-9]+)/(.*)$ index.php/ajax/supprimeFichier/$1/$2 [L]\r
-RewriteRule ^telecharger/([0-9]+)/(.*)$ index.php/telecharger/$1/$2 [L]\r
-RewriteRule ^([-_a-zA-Z0-9/]+)$ index.php/$1 [L]\r
-\r
-RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.html$ viewer/$1_$2_$3/index [L]\r
-RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.swf$ fluidbook/compile/index.swf [L]\r
-RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/player.swf$ fluidbook/compile/player.swf [L]\r
-RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/final/$1/$4 [L]\r
-\r
-RewriteRule ^vieweru/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.html$ vieweru/$1_$2_$3/index [L]\r
-RewriteRule ^vieweru/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.swf$ fluidbook/compile/_unprotected/index.swf [L]\r
-RewriteRule ^vieweru/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/player.swf$ fluidbook/compile/_unprotected/player.swf [L]\r
-RewriteRule ^vieweru/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/final/$1/$4 [L]\r
-\r
-RewriteRule ^viewerp/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.html$ viewerp/$1_$2_$3/index [L]\r
-RewriteRule ^viewerp/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.swf$ fluidbook/compile/_standalone/player.swf [L]\r
-RewriteRule ^viewerp/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/final/$1/$4 [L]
\ No newline at end of file
+<IfModule mod_expires.c>\r
+       ExpiresActive On\r
+       ExpiresDefault "modification plus 1 month"\r
+</IfModule>\r
+\r
+<IfModule mod_rewrite.c>\r
+       RewriteEngine on\r
+       RewriteBase /\r
+\r
+       # Favicon\r
+       RewriteCond %{HTTP_HOST} cubedesigners\r
+       RewriteRule ^favicon.ico$ images/extranet/favicon.ico [L]\r
+\r
+       RewriteCond %{HTTP_HOST} fluidbook\r
+       RewriteRule ^favicon.ico$ images/ws/favicon.ico [L]\r
+\r
+       # Skip\r
+       RewriteRule ^phpMyAdmin - [L]\r
+       #RewriteRule ^books - [L]\r
+       #RewriteRule ^docs - [L]\r
+\r
+       RewriteRule ^ajax/supprimeFichier/([0-9]+)/(.*)$ index.php/ajax/supprimeFichier/$1/$2 [L]\r
+       RewriteRule ^telecharger/([0-9]+)/(.*)$ index.php/telecharger/$1/$2 [L]\r
+       RewriteRule ^([-_a-zA-Z0-9/]+)$ index.php/$1 [L]\r
+\r
+       RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.html$ viewer/$1_$2_$3/index [L]\r
+       RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.swf$ fluidbook/compile/index.swf [L]\r
+       RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/player.swf$ fluidbook/compile/player.swf [L]\r
+       RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/final/$1/$4 [L]\r
+\r
+       RewriteRule ^vieweru/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.html$ vieweru/$1_$2_$3/index [L]\r
+       RewriteRule ^vieweru/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.swf$ fluidbook/compile/_unprotected/index.swf [L]\r
+       RewriteRule ^vieweru/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/player.swf$ fluidbook/compile/_unprotected/player.swf [L]\r
+       RewriteRule ^vieweru/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/final/$1/$4 [L]\r
+\r
+       RewriteRule ^viewerp/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.html$ viewerp/$1_$2_$3/index [L]\r
+       RewriteRule ^viewerp/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.swf$ fluidbook/compile/_standalone/player.swf [L]\r
+       RewriteRule ^viewerp/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/final/$1/$4 [L]\r
+</IfModule>
\ No newline at end of file
index 33d947641f615e93b8ddda71d108c9c14da901c0..1b1082a8ab44d8e409c7f2be2524a76d721d7b28 100644 (file)
@@ -68,7 +68,7 @@ class wsDocument extends cubeMetier {
                }\r
                $this->cropped = $this->out . 'crop.pdf';\r
                $this->uncropped = $this->out . 'uncrop.pdf';\r
-               $this->common_log_pointer = fopen($this->log . '/commons.log', 'a');\r
+               $this->common_log_pointer = fopen($this->log . '/commons.log', 'ab');\r
                $this->pages_log_pointers = array();\r
 \r
                if (is_null($this->conversionInfos)) {\r
@@ -649,6 +649,7 @@ class wsDocument extends cubeMetier {
        {\r
                $swfdump = new cubeCommandLine('swfdump', null, true);\r
                $swfdump->setPath(CONVERTER_PATH);\r
+               $swfdump->setLang('en_US.UTF-8');\r
                $swfdump->setArg('t');\r
                $swfdump->setArg('p');\r
                $swfdump->setArg('F');\r
@@ -857,7 +858,7 @@ disablelinks                Disable links.
                        if (isset($this->pages_log_pointers[$page]) && is_resource($this->pages_log_pointers[$page])) {\r
                                $pointer = $this->pages_log_pointers[$page];\r
                        } else {\r
-                               $pointer = fopen($this->log . '/p' . $page . '.log', 'w');\r
+                               $pointer = fopen($this->log . '/p' . $page . '.log', 'wb');\r
                                $this->pages_log_pointers[$page] = $pointer;\r
                        }\r
                }\r
index 42ed1c3304f8b0c5a39f8bad6243959356f78f4e..e97a47d803b650108c84c2902f649fb407a303ec 100644 (file)
@@ -5,6 +5,7 @@ class wsSWF2HTML {
 \r
        public $lines;\r
        public $tags = array();\r
+       public $fonts = array();\r
 \r
        protected $currentTag;\r
        protected $processed = false;\r
@@ -22,6 +23,8 @@ class wsSWF2HTML {
 \r
                foreach($this->lines as $line) {\r
                        if (preg_match('|^\[([0-9A-Z]{3})\]\s+(.*)$|i', $line, $matches)) {\r
+                               $this->rangeCurrentTag();\r
+\r
                                $this->currentTag = $this->addTag($matches[1], $matches[2]);\r
                        } elseif (!is_null($this->currentTag)) {\r
                                $this->currentTag->addLine($line);\r
@@ -31,9 +34,20 @@ class wsSWF2HTML {
                $this->lines = null;\r
        }\r
 \r
+       protected function rangeCurrentTag()\r
+       {\r
+               if (is_null($this->currentTag)) {\r
+                       return;\r
+               }\r
+\r
+               if ($this->currentTag instanceof wsSWF2HTMLFont) {\r
+                       $this->fonts[$this->currentTag->id] = $this->currentTag;\r
+               }\r
+       }\r
+\r
        protected function addTag($tag, $line)\r
        {\r
-               $tag = wsSWF2HTMLTag::factory($tag, $line);\r
+               $tag = wsSWF2HTMLTag::factory($tag, $line, $this);\r
                if (!is_null($tag)) {\r
                        $this->tags[] = $tag;\r
                }\r
@@ -52,20 +66,22 @@ class wsSWF2HTML {
 }\r
 \r
 class wsSWF2HTMLTag {\r
-       public static function factory($tag, $line)\r
+       public static function factory($tag, $line, &$converter)\r
        {\r
                if ($tag == wsSWF2HTML::FONT_TAG) {\r
-                       return new wsSWF2HTMLFont($line);\r
+                       return new wsSWF2HTMLFont($line, $converter);\r
                } else if ($tag == wsSWF2HTML::TEXT_TAG) {\r
-                       return new wsSWF2HTMLParagraph($line);\r
+                       return new wsSWF2HTMLParagraph($line, $converter);\r
                } else {\r
                        return null;\r
                }\r
        }\r
        public $complete = false;\r
+       public $converter;\r
 \r
-       public function __construct($line)\r
+       public function __construct($line, &$converter)\r
        {\r
+               $this->converter = $converter;\r
                $this->addLine($line);\r
        }\r
 \r
@@ -78,34 +94,41 @@ class wsSWF2HTMLTag {
 class wsSWF2HTMLFont extends wsSWF2HTMLTag {\r
        public $id = null;\r
        public $name = null;\r
+       public $chars = array();\r
 \r
-       public function __construct($line)\r
+       public function __construct($line, &$converter)\r
        {\r
-               parent::__construct($line);\r
+               parent::__construct($line, $converter);\r
        }\r
 \r
        public function addLine($line)\r
        {\r
                $line = parent::addLine($line);\r
                $e = explode(':', $line);\r
-               if (count($e) < 2) {\r
-                       return;\r
-               }\r
+\r
                if ($e[0] == 'ID') {\r
                        $this->id = trim($e[1]);\r
-                       $this->testComplete();\r
                } elseif ($e[0] == 'name') {\r
                        $ef = explode('-', trim($e[1]));\r
                        array_pop($ef);\r
                        array_pop($ef);\r
                        $this->name = implode('-', $ef);\r
-                       $this->testComplete();\r
+               } else if (substr($e[0], 0, 2) == '==') {\r
+               fb($line);\r
+                       if (preg_match('|== Glyph \d+: advance=\d+ encoding=(\d+) \'(.*)\' ==|i', $line, $m)) {\r
+                               $this->addChar($m[1], $m[2]);\r
+                       }\r
                }\r
        }\r
 \r
-       protected function testComplete()\r
+       public function addChar($encoding, $char)\r
        {\r
-               $this->complete = !is_null($this->id) && !is_null($this->name);\r
+               $e = cubeText::uchr($encoding);\r
+               $c = $char;\r
+               if ($e == $c) {\r
+                       return;\r
+               }\r
+               $this->chars[$c] = $e;\r
        }\r
 }\r
 \r
@@ -113,17 +136,17 @@ class wsSWF2HTMLParagraph extends wsSWF2HTMLTag {
        public $matrix;\r
        public $textes = array();\r
 \r
-       public function __construct($line)\r
+       public function __construct($line, &$converter)\r
        {\r
+               parent::__construct($line, $converter);\r
                $this->matrix = new wsSWF2HTMLMatrix();\r
-               parent::__construct($line);\r
        }\r
 \r
        public function addLine($line)\r
        {\r
                $line = parent::addLine($line);\r
                if (substr($line, 0, 1) == '|') {\r
-                       if (preg_match('|\|\s([0-9.-]+)\s([0-9.-]+)\s([0-9.-]+)|i', $line, $m)) {\r
+                       if (preg_match('|\|\s+([0-9.-]+)\s+([0-9.-]+)\s+([0-9.-]+)|i', $line, $m)) {\r
                                if (is_null($this->matrix->a)) {\r
                                        $this->matrix->a = floatval($m[1]);\r
                                        $this->matrix->c = floatval($m[2]);\r
@@ -133,11 +156,9 @@ class wsSWF2HTMLParagraph extends wsSWF2HTMLTag {
                                        $this->matrix->d = floatval($m[2]);\r
                                        $this->matrix->ty = floatval($m[3]);\r
                                }\r
-                       }else{\r
-                               fb($line);\r
                        }\r
                } else if (substr($line, 0, 1) == '<') {\r
-                       $text = new wsSWF2HTMLText($line);\r
+                       $text = new wsSWF2HTMLText($line, $this->converter);\r
                        if ($text->valid) {\r
                                $this->textes[] = $text;\r
                        }\r
@@ -146,29 +167,40 @@ class wsSWF2HTMLParagraph extends wsSWF2HTMLTag {
 }\r
 \r
 class wsSWF2HTMLText {\r
+       public $converter;\r
+\r
        public $x;\r
        public $y;\r
        public $color;\r
        public $font;\r
        public $size;\r
+       public $origText;\r
        public $text;\r
+       public $readableText;\r
 \r
        public $valid = false;\r
-       public function __construct($line)\r
+       public function __construct($line, &$converter)\r
        {\r
+               $this->converter = $converter;\r
                if (preg_match('|^\<\s?\d+ glyphs in font (\d+) size (\d+), color (#[0-9a-f]+) at ([0-9.-]+),([0-9.-]+)\>\s(.*)|ui', $line, $matches)) {\r
                        $this->font = intval($matches[1]);\r
                        $this->size = intval($matches[2]);\r
                        $this->color = $matches[3];\r
                        $this->x = floatval($matches[4]);\r
                        $this->y = floatval($matches[5]);\r
-                       $this->text = $matches[6];\r
+                       $this->origText=$matches[6];\r
+                       $this->text = preg_replace_callback('|\\\\x([0-9a-f]{2})|i', array($this, 'replaceUnicode') , $matches[6]);\r
+                       $this->readableText = strtr($this->text, $this->converter->fonts[$this->font]->chars);\r
                        $this->valid = true;\r
                } else {\r
                        $this->valid = false;\r
-                       fb($line,'invalid text');\r
                }\r
        }\r
+\r
+       protected function replaceUnicode($m)\r
+       {\r
+               return cubeText::uchr(hexdec($m[1]));\r
+       }\r
 }\r
 \r
 class wsSWF2HTMLMatrix {\r
diff --git a/testSWF2HTML.php b/testSWF2HTML.php
new file mode 100644 (file)
index 0000000..16b62fc
--- /dev/null
@@ -0,0 +1,12 @@
+<?php\r
+require_once(dirname(__FILE__) . '/inc/cube/_common.php');\r
+require_once(dirname(__FILE__) . '/inc/ws/Util/_common.php');\r
+\r
+\r
+$swf2html = new wsSWF2HTML(file_get_contents(dirname(__FILE__) . '/cache/dump.txt'));\r
+$swf2html->process();\r
+\r
+echo '<pre>';\r
+print_r($swf2html);\r
+echo '</pre>';\r
+?>
\ No newline at end of file