}
}
- 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;
}
$m = str_replace("\r", "\n", trim($book->parametres->multilang));\r
$langs = explode("\n", $m);\r
$langNames = array();\r
+ $countryNames = array();\r
$iso = l10n::getISOcodes();\r
- $chars = '';\r
+ $chars = '()';\r
foreach ($langs as $l) {\r
list($mlang, $flag, $url) = explode(',', trim($l), 3);\r
$flex->addBitmap(cubeMedia::getFlagFile($flag), 'flag_' . $flag);\r
$n = cubeText::ucfirst($iso[$mlang]);\r
$langNames[$mlang] = $n;\r
- $chars.=$n;\r
+ $cn = cubeCountry::getCountryName($flag, $mlang);\r
+ $countryNames[$flag] = $cn;\r
+ $chars.=$n . $cn;\r
}\r
\r
$chars = preg_split('/(?<!^)(?!$)/u', $chars);\r
\r
$flex->addFont(WS_FILES . '/fonts/FluidbookMultilang.ttf', 'MultilangFont', $chars);\r
$flex->addVariable('langNames', $langNames, false, true, 'JSONObject');\r
+ $flex->addVariable('countryNames', $countryNames, false, true, 'JSONObject');\r
$flex->addVariable('lang', $book->lang);\r
}\r
\r
$this->fields['bookmark'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Activer les marques-pages'));\r
$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'));\r
$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'));\r
+ $this->fields['bookmarkCornerSize'] = array('type' => 'integer', 'default' => 10, 'editable' => true, 'label' => __("Taille des marques-pages"), 'hint' => __('Taille relative à la largeur de la page'));\r
$this->forms['bookmark'] = array('label' => __('Marques-pages'),\r
- 'fieldsnames' => array('bookmark', '|', 'bookmark_email_title', 'bookmark_email_body'));\r
+ 'fieldsnames' => array('bookmark', '|', 'bookmark_email_title', 'bookmark_email_body', '|', 'bookmarkCornerSize'));\r
\r
$this->fields['help'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Activer l'aide"));\r
$this->fields['helpStartup'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Afficher l'aide au démarrage"));\r
'fieldsnames' => array('seoVersion', 'seoRobots', 'seoDescription'));\r
\r
$this->fields['home'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __("Accueil de l'interface multibrochure"), 'grade' => 5);\r
- $this->fields['multilang'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => 'Langues');\r
+ $this->fields['multilang'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Langues'), 'hint' => __('Code langue') . ',' . __('Code pays') . ',' . __('URL'));\r
+ $this->fields['country'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Pays de la brochure'));\r
+ $this->fields['multilangDisplay'] = array('type' => 'combo', 'default' => 'lang', 'editable' => true, 'label' => __('Affichage'),\r
+ 'datas' => array(__('Langue') => 'lang',\r
+ __('Langue') . ' (' . __('Pays') . ')' => 'lang_country',\r
+ __('Pays') . ' (' . __('Langue') . ')' => 'country_lang'));\r
$this->forms['multibrochure'] = array('label' => __('Multibrochure'),\r
- 'fieldsnames' => array('home', 'multilang'));\r
+ 'fieldsnames' => array('home', 'country', 'multilangDisplay', 'multilang'));\r
\r
$this->fields['plv'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Activer le mode PLV'), 'grade' => 3);\r
$this->fields['plvTimer'] = array('type' => 'integer', 'min' => 1, 'max' => 60, 'default' => 5, 'editable' => true, 'label' => __('Temps'), 'grade' => 3);\r