/** * @return string|void */ public function generate() { $info = HelpAccess::retrieveInfos($this->label, $this->iso_lang, $this->country, $this->ps_version); $content = ''; if (array_key_exists('version', $info) && $info['version'] != '') { $last_version = HelpAccess::getVersion($this->label); $tpl_vars['button_class'] = 'process-icon-help'; if ($last_version < $info['version']) { $tpl_vars['button_class'] = 'process-icon-help-new'; } $tpl_vars['label'] = $this->label; $tpl_vars['iso_lang'] = $this->iso_lang; $tpl_vars['country'] = $this->country; $tpl_vars['version'] = $this->ps_version; $tpl_vars['doc_version'] = $info['version']; $tpl_vars['help_base_url'] = HelpAccess::URL; $tpl_vars['tooltip'] = $info['tooltip']; $this->tpl->assign($tpl_vars); $content = parent::generate(); } return $content; }
public static function retrieveInfos($label, $iso_lang, $country, $version) { $image = self::$_images[0]; $tooltip = ''; $url = HelpAccess::URL . '/documentation/renderIcon?label=' . $label . '&iso_lang=' . $iso_lang . '&country=' . $country . '&version=' . $version; $ctx = @stream_context_create(array('http' => array('timeout' => 10))); $res = @file_get_contents($url, 0, $ctx); $infos = preg_split('/\\|/', $res); if (sizeof($infos) > 0) { $version = trim($infos[0]); if (!empty($version)) { $image = self::$_images[1]; if (sizeof($infos) > 1) { $tooltip = trim('|' . $infos[1]); } } } $last_version = HelpAccess::getVersion($label); if (!empty($version) && $version != $last_version) { $image = self::$_images[2]; } return array('version' => $version, 'image' => $image, 'tooltip' => $tooltip); }