2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Various checks and message functions used on index page.
6 * @package PhpMyAdmin-Setup
8 namespace PhpMyAdmin\Setup
;
10 use PhpMyAdmin\VersionInformation
;
11 use PhpMyAdmin\Sanitize
;
14 * PhpMyAdmin\Setup\Index class
16 * Various checks and message functions used on index page.
18 * @package PhpMyAdmin-Setup
23 * Initializes message list
27 public static function messagesBegin()
29 if (! isset($_SESSION['messages']) ||
!is_array($_SESSION['messages'])) {
30 $_SESSION['messages'] = array('error' => array(), 'notice' => array());
32 // reset message states
33 foreach ($_SESSION['messages'] as &$messages) {
34 foreach ($messages as &$msg) {
35 $msg['fresh'] = false;
36 $msg['active'] = false;
43 * Adds a new message to message list
45 * @param string $type one of: notice, error
46 * @param string $msgId unique message identifier
47 * @param string $title language string id (in $str array)
48 * @param string $message message text
52 public static function messagesSet($type, $msgId, $title, $message)
54 $fresh = ! isset($_SESSION['messages'][$type][$msgId]);
55 $_SESSION['messages'][$type][$msgId] = array(
59 'message' => $message);
63 * Cleans up message list
67 public static function messagesEnd()
69 foreach ($_SESSION['messages'] as &$messages) {
70 $remove_ids = array();
71 foreach ($messages as $id => &$msg) {
72 if ($msg['active'] == false) {
76 foreach ($remove_ids as $id) {
77 unset($messages[$id]);
83 * Prints message list, must be called after self::messagesEnd()
87 public static function messagesShowHtml()
89 foreach ($_SESSION['messages'] as $type => $messages) {
90 foreach ($messages as $id => $msg) {
91 if (! $msg['fresh'] && $type != 'error') {
92 $extra = ' hiddenmessage';
96 echo '<div class="' , $type, $extra , '" id="' , $id , '">'
97 , '<h4>' , $msg['title'] , '</h4>'
98 , $msg['message'] , '</div>';
104 * Checks for newest phpMyAdmin version and sets result as a new notice
108 public static function versionCheck()
110 // version check messages should always be visible so let's make
111 // a unique message id each time we run it
112 $message_id = uniqid('version_check');
115 $versionInformation = new VersionInformation();
116 $version_data = $versionInformation->getLatestVersion();
118 if (empty($version_data)) {
124 'Reading of version failed. '
125 . 'Maybe you\'re offline or the upgrade server does not respond.'
131 $releases = $version_data->releases
;
132 $latestCompatible = $versionInformation->getLatestCompatibleVersion($releases);
133 if ($latestCompatible != null) {
134 $version = $latestCompatible['version'];
135 $date = $latestCompatible['date'];
140 $version_upstream = $versionInformation->versionToInt($version);
141 if ($version_upstream === false) {
146 __('Got invalid version string from server')
151 $version_local = $versionInformation->versionToInt(
152 $GLOBALS['PMA_Config']->get('PMA_VERSION')
154 if ($version_local === false) {
159 __('Unparsable version string')
164 if ($version_upstream > $version_local) {
165 $version = htmlspecialchars($version);
166 $date = htmlspecialchars($date);
171 sprintf(__('A newer version of phpMyAdmin is available and you should consider upgrading. The newest version is %s, released on %s.'), $version, $date)
174 if ($version_local %
100 == 0) {
179 Sanitize
::sanitize(sprintf(__('You are using Git version, run [kbd]git pull[/kbd] :-)[br]The latest stable version is %s, released on %s.'), $version, $date))
186 __('No newer stable version is available')