]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 8 Feb 2011 13:09:48 +0000 (13:09 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 8 Feb 2011 13:09:48 +0000 (13:09 +0000)
inc/ws/Controlleur/packager/_common.php
inc/ws/Controlleur/packager/class.ws.packager.html.php
inc/ws/Controlleur/packager/class.ws.packager.php
inc/ws/Controlleur/packager/class.ws.packager.win.cd.php [new file with mode: 0644]
inc/ws/Controlleur/packager/class.ws.packager.win.exe.php [new file with mode: 0644]

index 99b8a68901b7047b51cb453bd5ba2c74bcac4713..de7a2c8f6cb4cd0c968e81a7f39bd7cda008a8a8 100644 (file)
@@ -1,5 +1,7 @@
 <?php\r
 $__autoload['wsPackager'] = dirname(__FILE__) . '/class.ws.packager.php';\r
 $__autoload['wsPackagerHTML'] = dirname(__FILE__) . '/class.ws.packager.html.php';\r
+$__autoload['wsPackagerWinEXE'] = dirname(__FILE__) . '/class.ws.packager.win.exe.php';\r
+$__autoload['wsPackagerWinCD'] = dirname(__FILE__) . '/class.ws.packager.win.cd.php';\r
 \r
 ?>
\ No newline at end of file
index 6e4d0fca4ba9f008a2ee25b8e89acba13f0e6505..83cf17c8da1b4eaacee7a8c9f892ffe3eecef255 100644 (file)
@@ -8,9 +8,9 @@ class wsPackagerHTML extends wsPackager {
                $this->version = 'html';\r
        }\r
 \r
-       public function makePackage()\r
+       protected function preparePackage()\r
        {\r
-               parent::makePackage();\r
+               parent::preparePackage();\r
 \r
                $this->copyFluidbookFiles();\r
                $this->copyOtherFiles(array('fluidbook.js', 'getflash.gif', 'index.html', 'index.swf', 'player.swf', 'style.css'));\r
@@ -46,12 +46,14 @@ class wsPackagerHTML extends wsPackager {
 \r
                foreach($this->pages as $page => $infos) {\r
                        $pathToIndex = 'index.swf';\r
+                       $pathToGetflash = 'getflash.gif';\r
                        $redirectScript = '';\r
                        if ($page == 1) {\r
                                $dest = 'index.html';\r
                        } else {\r
                                $dest = 'pages/page' . $page . '.html';\r
                                $pathToIndex = '../index.swf';\r
+                               $pathToGetflash = '../getflash.gif';\r
                                $redirectScript = '<script type="text/javascript">window.location=\'../index.html#/' . $page . '\';</script>';\r
                        }\r
                        $alt = '';\r
@@ -79,11 +81,15 @@ class wsPackagerHTML extends wsPackager {
 \r
                        $data = str_replace('$alt', $alt , $this->origHTML);\r
                        $data = str_replace('$pathToIndex', $pathToIndex, $data);\r
+                       $data = str_replace('$pathToGetflash', $pathToGetflash, $data);\r
                        $data = str_replace('$redirectScript', $redirectScript, $data);\r
 \r
                        file_put_contents($this->vdir . $dest, $data);\r
                }\r
+       }\r
 \r
+       public function makePackage()\r
+       {\r
                return $this->zip();\r
        }\r
 \r
@@ -125,14 +131,7 @@ class wsPackagerHTML extends wsPackager {
 \r
        protected function replaceHTML($toReplace)\r
        {\r
-               $res = $this->origHTML;\r
-               foreach($toReplace as $k => $v) {\r
-                       if (is_null($v)) {\r
-                               return;\r
-                       }\r
-                       $res = str_replace('$' . $k, $v, $res);\r
-               }\r
-               return $res;\r
+               return $this->replaceContents($this->origHTML, $toReplace);\r
        }\r
 }\r
 \r
index 452707ec6ffe62d3bafc24e5669ecc5b52b61e41..8cccff59bc1f60ae6c78b995b546fbda5d092cec 100644 (file)
@@ -11,6 +11,8 @@ class wsPackager {
        {\r
                if ($version == 'html') {\r
                        $packager = new wsPackagerHTML($book_id);\r
+               } elseif ($version == 'win-exe') {\r
+                       $packager = new wsPackagerWinEXE($book_id);\r
                }\r
 \r
                return $packager->makePackage();\r
@@ -34,11 +36,27 @@ class wsPackager {
                $this->theme = $daoTheme->getThemeOfBook($book_id, true);\r
        }\r
 \r
-       public function makePackage()\r
+       protected function preparePackage()\r
        {\r
                $this->initTempDir();\r
        }\r
 \r
+       public function makePackage(){\r
+               $this->preparePackage();\r
+       }\r
+\r
+       protected function replaceContents($str, $toReplace)\r
+       {\r
+               $res = $str;\r
+               foreach($toReplace as $k => $v) {\r
+                       if (is_null($v)) {\r
+                               return;\r
+                       }\r
+                       $res = str_replace('$' . $k, $v, $res);\r
+               }\r
+               return $res;\r
+       }\r
+\r
        protected function copyFluidbookFiles()\r
        {\r
                // Copie du FB vers un rĂ©pertoire temporaire\r
@@ -51,8 +69,12 @@ class wsPackager {
 \r
        protected function copyOtherFiles($files)\r
        {\r
-               foreach($files as $f) {\r
-                       copy(WS_COMPILE_ASSETS . '/' . $f, $this->vdir . $f);\r
+               foreach($files as $source => $dest) {\r
+                       if (is_int($source)) {\r
+                               $source = $dest;\r
+                       }\r
+\r
+                       copy(WS_COMPILE_ASSETS . '/' . $source, $this->vdir . $dest);\r
                }\r
        }\r
 \r
diff --git a/inc/ws/Controlleur/packager/class.ws.packager.win.cd.php b/inc/ws/Controlleur/packager/class.ws.packager.win.cd.php
new file mode 100644 (file)
index 0000000..9ea107a
--- /dev/null
@@ -0,0 +1,26 @@
+<?php\r
+class wsPackagerWinCD extends wsPackagerWinEXE {\r
+       public function __construct($book_id)\r
+       {\r
+               parent::__construct($book_id);\r
+               $this->version = 'win-cd';\r
+       }\r
+\r
+       public function preparePackage()\r
+       {\r
+               parent::preparePackage();\r
+\r
+               $this->copyOtherFiles(array('fluidbook.ico', 'autorun.inf'));\r
+               $this->replaceAutorun();\r
+       }\r
+\r
+       public function replaceAutorun()\r
+       {\r
+               $inf = file_get_contents($this->vdir . 'autorun.inf');\r
+               $toReplace = array('title' => $this->book->parametres->title, 'exe' => $this->exeName);\r
+               $inf = $this->replaceContents($inf, $toReplace);\r
+               file_put_contents($this->vdir . 'autorun.inf', $inf);\r
+       }\r
+}\r
+\r
+?>
\ No newline at end of file
diff --git a/inc/ws/Controlleur/packager/class.ws.packager.win.exe.php b/inc/ws/Controlleur/packager/class.ws.packager.win.exe.php
new file mode 100644 (file)
index 0000000..fc63d06
--- /dev/null
@@ -0,0 +1,27 @@
+<?php\r
+class wsPackagerWinEXE extends wsPackager {\r
+       protected $exeName;\r
+\r
+       public function __construct($book_id)\r
+       {\r
+               parent::__construct($book_id);\r
+               $this->version = 'win-exe';\r
+\r
+               $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->title, 0, 16));\r
+       }\r
+\r
+       public function preparePackage()\r
+       {\r
+               parent::preparePackage();\r
+\r
+               $this->copyFluidbookFiles();\r
+               $this->copyOtherFiles(array('Fluidbook.exe' => $this->exeName));\r
+       }\r
+\r
+       public function makePackage()\r
+       {\r
+               return $this->zip();\r
+       }\r
+}\r
+\r
+?>
\ No newline at end of file