From: vincent@cubedesigners.com Date: Fri, 7 Jan 2011 16:04:50 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=23df43103bafc5c0d05d4b07a976b56f60fbdb7a;p=cubeextranet.git --- diff --git a/inc/extranet/Controlleur/class.extranet.core.php b/inc/extranet/Controlleur/class.extranet.core.php index 374abfa2e..9a2481566 100644 --- a/inc/extranet/Controlleur/class.extranet.core.php +++ b/inc/extranet/Controlleur/class.extranet.core.php @@ -296,10 +296,8 @@ class extranetCore extends cubeCore { // $db->themes_droits->reference('fk_themes_droits_utilisateur_id', 'utilisateur_id', 'utilisateurs', 'utilisateur_id'); // Table des langues $db->langues->lang_id('varchar', 20, false); - $db->langues->nom('varchar', 256, false); - $db->langues->nsis_lang('varchar', 64, false); - $db->langues->public('integer', 1, false); - $db->langues->embeded('integer', 1, false); + $db->langues->font('varchar', 64, false); + $db->langues->charset('text', 0, false); $db->langues->traductions('text', 0, false); // Clés $db->langues->primary('pk_langues', 'lang_id'); diff --git a/inc/extranet/Controlleur/class.extranet.page.php b/inc/extranet/Controlleur/class.extranet.page.php index bdde75c3c..4d870264c 100644 --- a/inc/extranet/Controlleur/class.extranet.page.php +++ b/inc/extranet/Controlleur/class.extranet.page.php @@ -147,12 +147,16 @@ class extranetPage { return $res; } - public static function bf() + public static function bf($max=false) { $res = ''; $res .= ''; $res .= ''; - $res .= ''; + $res .= ''; + if($max){ + $res.=cubeMedia::spacer(960,1); + } + $res.=''; $res .= ''; $res .= ''; return $res; diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index c2bc4baf4..7040ca7d0 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -59,9 +59,9 @@ class wsAjax extends cubeAjax { global $core; $dao = new wsDAOBook($core->con); if ($_POST['book'] != '') { - $book = $dao->duplicate($_POST['book'], $core->user->utilisateur_id,$_POST['title']); + $book = $dao->duplicate($_POST['book'], $core->user->utilisateur_id, $_POST['title']); } else { - $book = $dao->creeEmpty($core->user->utilisateur_id, $core->user->lang,$_POST['title']); + $book = $dao->creeEmpty($core->user->utilisateur_id, $core->user->lang, $_POST['title']); } $x->addClosePopup(); @@ -82,6 +82,23 @@ class wsAjax extends cubeAjax { $x->addClosePopup(); $x->addContent('listeBooks', wsUrl::listeBooks()); } + + public static function changeLang($args, &$x) + { + $x->addContent('formLang', wsUrl::formLang($_POST['lang'])); + } + + public static function saveLang($args, &$x) + { + global $core; + $dao = new wsDAOLang($core->con); + $data['lang_id'] = $_POST['lang']; + $data['font'] = $_POST['font']; + $data['charset'] = $_POST['charset']; + $data['traductions'] = $_POST['msgid']; + $dao->sauve($data); + $x->addAlert(__('Paramètres de la langue et traductions enregistrées')); + } } ?> \ No newline at end of file diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index b9e1a0579..b75e79d00 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -89,12 +89,77 @@ class wsUrl { public static function traductions($args) { global $core; + + if (count($args) < 2) { + $args[1] = 'fr'; + } + $res = extranetPage::barre(); - $res .= extranetPage::tMain(null, true); + $res .= extranetPage::tMain(null, false); + $res .= extranetPage::bh(); - $res .= cubeLang::translationForm(FLUIDBOOK_SOURCES, 'fr' , WS_L10N); + $res .= '
'; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= '
' . __('Sélectionnez la langue à configurer') . ' : ' . form::combo('lang', array_flip(cubeLang::getCodes($core->user->lang)), $args[1]) . '
' . $core->typo->Ajouter('OK') . '
'; + $res .= '
'; $res .= extranetPage::bf(); - $res .= extranetPage::bMain(); + + $res .= '
'; + $res .= self::formLang($args[1]); + $res .= '
'; + $res .= extranetPage::bMain(true); + + return $res; + } + + public static function formLang($lang_id) + { + global $core; + $dao = new wsDAOLang($core->con); + $lang = $dao->selectById($lang_id); + if(is_null($lang)) + + $res = '
'; + + $res .= extranetPage::bh(); + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= '
' . __('Police de caractères') . ' : ' . form::hidden('lang', $lang_id) . form::combo('font', self::getFonts(), $lang->font) . '
' . __('Jeux de caractères') . ' : ' . form::combo('charset', self::getCharsets(), $lang->charset) . '
' . $core->typo->Ajouter('Valider') . '
'; + $res .= extranetPage::bf(); + + $res .= extranetPage::bh(); + $res .= cubeLang::translationForm(FLUIDBOOK_SOURCES, $lang_id , null, 'liste', array(), $core->typo->Ajouter(__('Enregistrer')), $lang->traductions); + $res .= extranetPage::bf(); + $res .= '
'; + return $res; + } + + public static function getFonts() + { + $formats = array('ttf', 'otf', 'TTF', 'OTF'); + + $dr = opendir(FONT_PATH); + $fonts = array(); + while ($file = readdir($dr)) { + if ($file == '.' || $file == '..' || !in_array(files::getExtension($file), $formats)) { + continue; + } + $fonts[$file] = $file; + } + return $fonts; + } + + protected static function getCharsets() + { + $sets = cubeFlexFontAsset::getSets(); + $res = array(); + foreach($sets as $k => $v) { + $res[$k] = $k; + } return $res; } @@ -229,7 +294,7 @@ html{height:100%}' . "\n"; { $res = '

' . __("Si votre nouvelle publication a des paramètres en commun avec une publication existante, veuillez rechercher cette publication afin d'attribuer par défaut à votre nouvelle publication les paramètres de l'existante") . '

'; $res .= '' . __('Rechercher une publication') . ' : ' . form::field('book_nom', 64, 1024) . form::hidden('book', '') . ''; - // $res .= '
'; + // $res .= '
'; $res .= '' . __('Indiquez le titre de votre nouvelle publication') . '' . form::field('title', 64, 1024) . ''; return $res; } diff --git a/inc/ws/DAO/class.ws.dao.lang.php b/inc/ws/DAO/class.ws.dao.lang.php index 9ef04b46d..fbda98d31 100644 --- a/inc/ws/DAO/class.ws.dao.lang.php +++ b/inc/ws/DAO/class.ws.dao.lang.php @@ -4,22 +4,27 @@ class wsDAOLang extends extranetDAO { { $lang = new wsLang(); $lang->lang_id = $r->lang_id; - $lang->nom = $r->nom; - $lang->nsis_lang = $r->nsis_lang; - $lang->public = $r->public; - $lang->embeded = $r->embeded; + $lang->font = $r->font; + $lang->charset = $r->charset; if ($r->traductions == '') { $lang->traductions = array(); } else { - $lang->traductions = json_decode($r->traductions); + $lang->traductions = json_decode($r->traductions, true); + } + + foreach($lang->traductions as $k => $v) { + if (is_int($k)) { + $lang->traductions = wsLang::getTraductionWithId($lang->traductions); + } + break; } return $lang; } public function selectById($lang_id) { - $r = $this->con->select('SELECT * FROM langues WHERE lang_id=\'' . $this->con->escape($lang_id).'\'' ); + $r = $this->con->select('SELECT * FROM langues WHERE lang_id=\'' . $this->con->escape($lang_id) . '\''); return $this->singleton($r); } @@ -28,6 +33,23 @@ class wsDAOLang extends extranetDAO { $r = $this->con->select('SELECT * FROM langues ORDER BY public DESC,(CHAR_LENGTH(lang_id)=2) DESC, nom ASC'); return $this->factory($r); } + + public function sauve($data) + { + $c = $this->con->openCursor('langues'); + $c->lang_id = $data['lang_id']; + $c->font = $data['font']; + $c->charset = $data['charset']; + $c->traductions = json_encode($data['traductions']); + $r = $this->con->select('SELECT * FROM langues WHERE lang_id=\'' . $this->con->escape($c->lang_id) . '\''); + if (!$r->count()) { + $c->insert(); + } else { + $c->update('WHERE lang_id=\'' . $this->con->escape($c->lang_id) . '\''); + } + + return $this->selectById($c->lang_id); + } } ?> \ No newline at end of file diff --git a/inc/ws/Metier/class.ws.lang.php b/inc/ws/Metier/class.ws.lang.php index 6ba25745a..e87db0e2d 100644 --- a/inc/ws/Metier/class.ws.lang.php +++ b/inc/ws/Metier/class.ws.lang.php @@ -63,13 +63,11 @@ class wsLang extends cubeMetier { 'printing will start automatically when pages are downloaded' => 61, 'no bookmarks added' => 62, 'functionality dont work when in fullscreen mode' => 63, - "you don't have any bookmark"=>64); + "you don't have any bookmark" => 64); protected $lang_id; - protected $nom; - protected $nsis_lang; - protected $public; - protected $embeded; + protected $font; + protected $charset; protected $traductions; public static function getTraductionWithId($traductions)