version_data = $version_data; $this->config = $config; $this->version_helper = $version_helper; $this->template = $template; $this->user = $user; $this->current_version = $this->config[str_replace(' ', '', $this->version_data['version'])]; } /** * Check MOD version and assign template variables for version info if not * returning current version * * @param bool $return_version Yes if current version should be returned * @return string|bool Current version if $return_version is set to true, false if not */ public function check($return_version = false) { // Set file location $this->version_helper->set_file_location($this->version_data['file'][0], $this->version_data['file'][1], $this->version_data['file'][2]); // Set current version $this->version_helper->set_current_version($this->current_version); $this->version_helper->force_stability(($this->config['extension_force_unstable'] || !$this->version_helper->is_stable($this->current_version)) ? 'unstable' : null); // Expect version_helper to throw RuntimeExceptions try { $this->update_data = $this->version_helper->get_suggested_updates(true); } catch (\RuntimeException $e) { return false; } // Return version if $return_version is set to true if ($return_version) { return $this->current_version; } $version_up_to_date = empty($this->update_data); $this->template_data = array( 'AUTHOR' => $this->version_data['author'], 'CURRENT_VERSION' => $this->current_version, 'UP_TO_DATE' => sprintf((!$version_up_to_date) ? $this->user->lang['NOT_UP_TO_DATE'] : $this->user->lang['UP_TO_DATE'], $this->version_data['title']), 'S_UP_TO_DATE' => $version_up_to_date, 'U_AUTHOR' => 'http://www.phpbb.com/community/memberlist.php?mode=viewprofile&un=' . $this->version_data['author'], 'TITLE' => (string) $this->version_data['title'], 'LATEST_VERSION' => $this->current_version, ); $this->display_update_information(); $this->template->assign_block_vars('mods', $this->template_data); return false; } /** * Display update information if updates exist */ protected function display_update_information() { if (!empty($this->update_data)) { $update = array_shift($this->update_data); $this->template_data = array_merge($this->template_data, array( 'ANNOUNCEMENT' => (string) $update['announcement'], 'DOWNLOAD' => (string) $update['download'], 'LATEST_VERSION' => $update['current'], )); } } }