From 52bac42984a664a06523eda19e8e95ec07b8a28e Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 19 Dec 2012 13:32:59 +0000 Subject: [PATCH] --- inc/commons/class.common.tools.php | 13 +++++++------ inc/ws/DAO/class.ws.dao.book.php | 8 ++++++-- inc/ws/Metier/class.ws.book.parametres.php | 12 +++++++++--- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/inc/commons/class.common.tools.php b/inc/commons/class.common.tools.php index fc0de7928..ea454eea0 100644 --- a/inc/commons/class.common.tools.php +++ b/inc/commons/class.common.tools.php @@ -663,32 +663,33 @@ class commonTools { } } - protected function searchGoogle($q, $cx, $key) { + protected static function searchGoogle($q, $cx, $key) { global $core; - $url = 'https://www.googleapis.com/customsearch/v1?key=' . $key . '&q=' . rawurlencode($q) . '&cx=' . $cx; + $url = 'https://www.googleapis.com/customsearch/v1?q=' . rawurlencode($q) . '&cx=' . $cx; $limit = TIME - (3600 * 24 * 10); // Cache de 10j - $r = $core->con->select('SELECT response FROM google_search_api WHERE request=\'' . $core->con->escape($request) . '\''); + $r = $core->con->select('SELECT date,response FROM google_search_api WHERE request=\'' . $core->con->escape($url) . '\''); if ($r->count()) { $cached = $r->response; if ($r->date > $limit) { + fb('got cache'); return json_decode($cached, true); } } - $j = file_get_contents($url); + $j = file_get_contents($url . '&key=' . $key); $json = json_decode($j, true); if (isset($json['items'][0]['link'])) { $c = $core->con->openCursor('google_search_api'); $c->request = $url; - $c->response = $json; + $c->response = $j; $c->date = TIME; try { $c->insert(); } catch (Exception $e) { - $c->update('WHERE url=\'' . $core->con->escape($url) . '\''); + $c->update('WHERE request=\'' . $core->con->escape($url) . '\''); } return $json; } diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index ee216bcf2..84956a743 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -1164,14 +1164,17 @@ class wsDAOBook extends commonDAO { $m = str_replace("\r", "\n", trim($book->parametres->multilang)); $langs = explode("\n", $m); $langNames = array(); + $countryNames = array(); $iso = l10n::getISOcodes(); - $chars = ''; + $chars = '()'; foreach ($langs as $l) { list($mlang, $flag, $url) = explode(',', trim($l), 3); $flex->addBitmap(cubeMedia::getFlagFile($flag), 'flag_' . $flag); $n = cubeText::ucfirst($iso[$mlang]); $langNames[$mlang] = $n; - $chars.=$n; + $cn = cubeCountry::getCountryName($flag, $mlang); + $countryNames[$flag] = $cn; + $chars.=$n . $cn; } $chars = preg_split('/(?addFont(WS_FILES . '/fonts/FluidbookMultilang.ttf', 'MultilangFont', $chars); $flex->addVariable('langNames', $langNames, false, true, 'JSONObject'); + $flex->addVariable('countryNames', $countryNames, false, true, 'JSONObject'); $flex->addVariable('lang', $book->lang); } diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index 4487dff59..57249694e 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -95,8 +95,9 @@ class wsBookParametres extends wsParametres { $this->fields['bookmark'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Activer les marques-pages')); $this->fields['bookmark_email_title'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __("Titre de l'email") . ' "' . __('Envoyer à un ami') . '"', 'hint' => __('Laisser vide pour utiliser la valeur par défaut')); $this->fields['bookmark_email_body'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __("Corps de l'email") . ' "' . __('Envoyer à un ami') . '"', 'hint' => __('Laisser vide pour utiliser la valeur par défaut')); + $this->fields['bookmarkCornerSize'] = array('type' => 'integer', 'default' => 10, 'editable' => true, 'label' => __("Taille des marques-pages"), 'hint' => __('Taille relative à la largeur de la page')); $this->forms['bookmark'] = array('label' => __('Marques-pages'), - 'fieldsnames' => array('bookmark', '|', 'bookmark_email_title', 'bookmark_email_body')); + 'fieldsnames' => array('bookmark', '|', 'bookmark_email_title', 'bookmark_email_body', '|', 'bookmarkCornerSize')); $this->fields['help'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Activer l'aide")); $this->fields['helpStartup'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Afficher l'aide au démarrage")); @@ -290,9 +291,14 @@ class wsBookParametres extends wsParametres { 'fieldsnames' => array('seoVersion', 'seoRobots', 'seoDescription')); $this->fields['home'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __("Accueil de l'interface multibrochure"), 'grade' => 5); - $this->fields['multilang'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => 'Langues'); + $this->fields['multilang'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Langues'), 'hint' => __('Code langue') . ',' . __('Code pays') . ',' . __('URL')); + $this->fields['country'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Pays de la brochure')); + $this->fields['multilangDisplay'] = array('type' => 'combo', 'default' => 'lang', 'editable' => true, 'label' => __('Affichage'), + 'datas' => array(__('Langue') => 'lang', + __('Langue') . ' (' . __('Pays') . ')' => 'lang_country', + __('Pays') . ' (' . __('Langue') . ')' => 'country_lang')); $this->forms['multibrochure'] = array('label' => __('Multibrochure'), - 'fieldsnames' => array('home', 'multilang')); + 'fieldsnames' => array('home', 'country', 'multilangDisplay', 'multilang')); $this->fields['plv'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Activer le mode PLV'), 'grade' => 3); $this->fields['plvTimer'] = array('type' => 'integer', 'min' => 1, 'max' => 60, 'default' => 5, 'editable' => true, 'label' => __('Temps'), 'grade' => 3); -- 2.39.5