Commit 0e6bb109 by Scott

Merge branch 'pr/461' into 1.8

parents 1fd92d35 2e578079
......@@ -134,9 +134,9 @@ function qa_admin_click(target)
return false;
}
function qa_version_check(uri, version, elem)
function qa_version_check(uri, version, elem, isCore)
{
var params={uri:uri, version:version};
var params={uri:uri, version:version, isCore:isCore};
qa_ajax_post('version', params,
function (lines) {
......
......@@ -30,41 +30,53 @@
$uri = qa_post_text('uri');
$version = qa_post_text('version');
$isCore = qa_post_text('isCore') === "true";
if ($isCore) {
$contents = qa_retrieve_url($uri);
if (strlen($contents) > 0) {
if (qa_qa_version_below($contents)) {
$response =
'<a href="https://github.com/q2a/question2answer/releases" style="color:#d00;">' .
qa_lang_html_sub('admin/version_get_x', qa_html('v' . $contents)) .
'</a>';
} else {
$response = qa_html($contents); // Output the current version number
}
} else {
$response = qa_lang_html('admin/version_latest_unknown');
}
} else {
$metadataUtil = new Q2A_Util_Metadata();
$metadata = $metadataUtil->fetchFromUrl($uri);
if (strlen(@$metadata['version'])) {
if (strlen(@$metadata['version']) > 0) {
if (strcmp($metadata['version'], $version)) {
if (qa_qa_version_below(@$metadata['min_q2a'])) {
$response = strtr(qa_lang_html('admin/version_requires_q2a'), array(
'^1' => qa_html('v'.$metadata['version']),
'^1' => qa_html('v' . $metadata['version']),
'^2' => qa_html($metadata['min_q2a']),
));
}
elseif (qa_php_version_below(@$metadata['min_php'])) {
} elseif (qa_php_version_below(@$metadata['min_php'])) {
$response = strtr(qa_lang_html('admin/version_requires_php'), array(
'^1' => qa_html('v'.$metadata['version']),
'^1' => qa_html('v' . $metadata['version']),
'^2' => qa_html($metadata['min_php']),
));
}
} else {
$response = qa_lang_html_sub('admin/version_get_x', qa_html('v' . $metadata['version']));
else {
$response = qa_lang_html_sub('admin/version_get_x', qa_html('v'.$metadata['version']));
if (strlen(@$metadata['uri']))
$response = '<a href="'.qa_html($metadata['uri']).'" style="color:#d00;">'.$response.'</a>';
if (strlen(@$metadata['uri'])){
$response = '<a href="' . qa_html($metadata['uri']) . '" style="color:#d00;">' . $response . '</a>';
}
}
else
} else {
$response = qa_lang_html('admin/version_latest');
}
else
} else {
$response = qa_lang_html('admin/version_latest_unknown');
}
}
echo "QA_AJAX_RESPONSE\n1\n".$response;
......
......@@ -1075,7 +1075,7 @@ foreach ($showoptions as $optionname) {
$updatehtml = '(<span id="' . $elementid . '">...</span>)';
$qa_content['script_onloads'][] = array(
"qa_version_check(" . qa_js($metadata['update_uri']) . ", " . qa_js($metadata['version'], true) . ", " . qa_js($elementid) . ");"
"qa_version_check(" . qa_js($metadata['update_uri']) . ", " . qa_js($metadata['version'], true) . ", " . qa_js($elementid) . ", false);"
);
}
......
......@@ -153,7 +153,7 @@ if (!empty($pluginfiles)) {
$updatehtml = '(<span id="' . $elementid . '">...</span>)';
$qa_content['script_onloads'][] = array(
"qa_version_check(" . qa_js($metadata['update_uri']) . ", " . qa_js($metadata['version'], true) . ", " . qa_js($elementid) . ");"
"qa_version_check(" . qa_js($metadata['update_uri']) . ", " . qa_js($metadata['version'], true) . ", " . qa_js($elementid) . ", false);"
);
}
else
......
......@@ -74,8 +74,7 @@ $qa_content['form'] = array(
'q2a_latest' => array(
'label' => qa_lang_html('admin/q2a_latest_version'),
'type' => 'custom',
'html' => '<iframe src="http://www.question2answer.org/question2answer-latest.php?version=' . urlencode(QA_VERSION) . '&language=' . urlencode(qa_opt('site_language')) .
'" width="100" height="16" style="vertical-align:middle; border:0; background:transparent;" allowTransparency="true" scrolling="no" frameborder="0"></iframe>',
'html' => '<span id="q2a-version">...</span>',
),
'break0' => array(
......@@ -274,6 +273,10 @@ if (defined('QA_BLOBS_DIRECTORY')) {
$qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
$qa_content['script_var']['qa_warning_recalc'] = qa_lang('admin/stop_recalc_warning');
$qa_content['script_onloads'][] = array(
"qa_version_check('https://raw.githubusercontent.com/q2a/question2answer/master/VERSION.txt', " . qa_js(qa_html(QA_VERSION), true) . ", 'q2a-version', true);"
);
$qa_content['navigation']['sub'] = qa_admin_sub_navigation();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment