From 378f770bb6c1cb2823d52cc119c816f8676b75a6 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Thu, 26 Jan 2012 16:03:46 +0000 Subject: [PATCH] --- inc/ws/Metier/class.ws.lang.php | 41 +++++++++++++++---- inc/ws/Util/packager/class.ws.packager.v1.php | 12 ++++++ 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/inc/ws/Metier/class.ws.lang.php b/inc/ws/Metier/class.ws.lang.php index b291a51a6..effdf1fba 100644 --- a/inc/ws/Metier/class.ws.lang.php +++ b/inc/ws/Metier/class.ws.lang.php @@ -1,5 +1,7 @@ 1, 'normal view' => 2, 'zoom in' => 3, @@ -64,32 +66,55 @@ class wsLang extends cubeMetier { 'no bookmarks added' => 62, 'functionality dont work when in fullscreen mode' => 63, "you don't have any bookmark" => 64); - protected $lang_id; protected $font; protected $charset; protected $traductions; protected $nsis; - public static function getTraductionWithId($traductions) - { + public static function getTraductionWithId($traductions) { $res = array(); - foreach($traductions as $k => $v) { + foreach ($traductions as $k => $v) { $res[array_search($k, self::$idtonew)] = $v; } return $res; } - public static function checkTranslations($traductions) - { - foreach($traductions as $k => $v) { - if (is_int($k) || intval($k)>0) { + public static function getTraductionsForV1($traductions) { + $res = array(); + $new = 100; + foreach ($traductions as $k => $v) { + if (isset(self::$idtonew[$k])) { + $res[self::$idtonew[$k]] = $v; + } else { + $res[$new] = $v; + $new++; + } + } + ksort($res); + return $res; + } + + public static function checkTranslations($traductions) { + foreach ($traductions as $k => $v) { + if (is_int($k) || intval($k) > 0) { $traductions = wsLang::getTraductionWithId($traductions); } break; } return $traductions; } + + public function getV1XML() { + $xml = simplexml_load_string(''); + + $traductions = self::getTraductionsForV1($this->traductions); + foreach ($traductions as $text) { + $xml->addChild('tradText', htmlspecialchars($text)); + } + return $xml; + } + } ?> \ No newline at end of file diff --git a/inc/ws/Util/packager/class.ws.packager.v1.php b/inc/ws/Util/packager/class.ws.packager.v1.php index bcdbb1eb6..90d8d4e36 100644 --- a/inc/ws/Util/packager/class.ws.packager.v1.php +++ b/inc/ws/Util/packager/class.ws.packager.v1.php @@ -25,6 +25,7 @@ class wsPackagerV1 extends wsPackagerHTML { $this->copyLinks(); $this->copyConfig(); $this->copyTheme(); + $this->copyLang(); } protected function copyThumbnails() { @@ -198,6 +199,17 @@ class wsPackagerV1 extends wsPackagerHTML { } + protected function copyLang() { + global $core; + $mapping = wsLang::$idtonew; + + $daoLang = new wsDAOLang($core->con); + $lang = $daoLang->selectById($this->book->lang); + + $xml = $lang->getV1XML(); + file_put_contents($this->vdir . '/data/lang.xml', $xml->asXML()); + } + protected function _copyWorkingFile($file) { $src = $this->workingDir . '/' . $file; if (file_exists($src) && is_file($src)) { -- 2.39.5