Commit 53731f9e authored by alexpott's avatar alexpott

Issue #2048933 by plopesc, cconrad, pplantinga: Replace theme() with...

Issue #2048933 by plopesc, cconrad, pplantinga: Replace theme() with drupal_render() in update module.
parent cb5397f2
......@@ -258,7 +258,9 @@ function update_manager_update_form($form, $form_state = array(), $context) {
$prefix = '<h2>' . t('Manual updates required') . '</h2>';
$prefix .= '<p>' . t('Updates of Drupal core are not supported at this time.') . '</p>';
$form['manual_updates'] = array(
'#markup' => theme('table', array('header' => $headers, 'rows' => $projects['manual'])),
'#theme' => 'table',
'#header' => $headers,
'#rows' => $projects['manual'],
'#prefix' => $prefix,
'#weight' => 120,
);
......@@ -279,7 +281,11 @@ function update_manager_update_form($form, $form_state = array(), $context) {
function theme_update_manager_update_form($variables) {
$form = $variables['form'];
$last = Drupal::state()->get('update.last_check') ?: 0;
$output = theme('update_last_check', array('last' => $last));
$update_last_check = array(
'#theme' => 'update_last_check',
'#last' => $last,
);
$output = drupal_render($update_last_check);
$output .= drupal_render_children($form);
return $output;
}
......@@ -347,11 +353,12 @@ function update_manager_update_form_submit($form, &$form_state) {
*/
function update_manager_download_batch_finished($success, $results) {
if (!empty($results['errors'])) {
$error_list = array(
'title' => t('Downloading updates failed:'),
'items' => $results['errors'],
$item_list = array(
'#theme' => 'item_list',
'#title' => t('Downloading updates failed:'),
'#items' => $results['errors'],
);
drupal_set_message(theme('item_list', $error_list), 'error');
drupal_set_message(drupal_render($item_list), 'error');
}
elseif ($success) {
drupal_set_message(t('Updates downloaded successfully.'));
......
......@@ -18,7 +18,11 @@ function theme_update_report($variables) {
$data = $variables['data'];
$last = Drupal::state()->get('update.last_check') ?: 0;
$output = theme('update_last_check', array('last' => $last));
$update_last_check = array(
'#theme' => 'update_last_check',
'#last' => $last,
);
$output = drupal_render($update_last_check);
if (!is_array($data)) {
$output .= '<p>' . $data . '</p>';
......@@ -43,32 +47,46 @@ function theme_update_report($variables) {
switch ($project['status']) {
case UPDATE_CURRENT:
$class = 'ok';
$icon = theme('image', array('uri' => 'core/misc/watchdog-ok.png', 'width' => 18, 'height' => 18, 'alt' => t('ok'), 'title' => t('ok')));
$uri = 'core/misc/watchdog-ok.png';
$text = t('ok');
break;
case UPDATE_UNKNOWN:
case UPDATE_FETCH_PENDING:
case UPDATE_NOT_FETCHED:
$class = 'unknown';
$icon = theme('image', array('uri' => 'core/misc/watchdog-warning.png', 'width' => 18, 'height' => 18, 'alt' => t('warning'), 'title' => t('warning')));
$uri = 'core/misc/watchdog-warning.png';
$text = t('warning');
break;
case UPDATE_NOT_SECURE:
case UPDATE_REVOKED:
case UPDATE_NOT_SUPPORTED:
$class = 'error';
$icon = theme('image', array('uri' => 'core/misc/watchdog-error.png', 'width' => 18, 'height' => 18, 'alt' => t('error'), 'title' => t('error')));
$uri = 'core/misc/watchdog-error.png';
$text = t('error');
break;
case UPDATE_NOT_CHECKED:
case UPDATE_NOT_CURRENT:
default:
$class = 'warning';
$icon = theme('image', array('uri' => 'core/misc/watchdog-warning.png', 'width' => 18, 'height' => 18, 'alt' => t('warning'), 'title' => t('warning')));
$uri = 'core/misc/watchdog-warning.png';
$text = t('warning');
break;
}
$icon = array(
'#theme' => 'image',
'#width' => 18,
'#height' => 18,
'#uri' => $uri,
'#alt' => $text,
'#title' => $text,
);
$row = '<div class="version-status">';
$status_label = theme('update_status_label', array('status' => $project['status']));
$update_status_label = array('#theme' => 'update_status_label', '#status' => $project['status']);
$status_label = drupal_render($update_status_label);
$row .= !empty($status_label) ? $status_label : check_plain($project['reason']);
$row .= '<span class="icon">' . $icon . '</span>';
$row .= '<span class="icon">' . drupal_render($icon) . '</span>';
$row .= "</div>\n";
$row .= '<div class="project">';
......@@ -118,32 +136,62 @@ function theme_update_report($variables) {
) {
$version_class[] = 'version-recommended-strong';
}
$versions_inner .= theme('update_version', array('version' => $project['releases'][$project['recommended']], 'tag' => t('Recommended version:'), 'class' => $version_class));
$update_version = array(
'#theme' => 'update_version',
'#version' => $project['releases'][$project['recommended']],
'#tag' => t('Recommended version:'),
'#class' => $version_class,
);
$versions_inner .= drupal_render($update_version);
}
// Now, print any security updates.
if (!empty($project['security updates'])) {
$security_class[] = 'version-security';
foreach ($project['security updates'] as $security_update) {
$versions_inner .= theme('update_version', array('version' => $security_update, 'tag' => t('Security update:'), 'class' => $security_class));
$update_version = array(
'#theme' => 'update_version',
'#version' => $security_update,
'#tag' => t('Security update:'),
'#class' => $security_class,
);
$versions_inner .= drupal_render($update_version);
}
}
}
if ($project['recommended'] !== $project['latest_version']) {
$versions_inner .= theme('update_version', array('version' => $project['releases'][$project['latest_version']], 'tag' => t('Latest version:'), 'class' => array('version-latest')));
$update_version = array(
'#theme' => 'update_version',
'#version' => $project['releases'][$project['latest_version']],
'#tag' => t('Latest version:'),
'#class' => array('version-latest'),
);
$versions_inner .= drupal_render($update_version);
}
if ($project['install_type'] == 'dev'
&& $project['status'] != UPDATE_CURRENT
&& isset($project['dev_version'])
&& $project['recommended'] !== $project['dev_version']) {
$versions_inner .= theme('update_version', array('version' => $project['releases'][$project['dev_version']], 'tag' => t('Development version:'), 'class' => array('version-latest')));
$update_version = array(
'#theme' => 'update_version',
'#version' => $project['releases'][$project['dev_version']],
'#tag' => t('Development version:'),
'#class' => array('version-latest'),
);
$versions_inner .= drupal_render($update_version);
}
}
if (isset($project['also'])) {
foreach ($project['also'] as $also) {
$versions_inner .= theme('update_version', array('version' => $project['releases'][$also], 'tag' => t('Also available:'), 'class' => array('version-also-available')));
$update_version = array(
'#theme' => 'update_version',
'#version' => $project['releases'][$also],
'#tag' => t('Also available:'),
'#class' => array('version-also-available'),
);
$versions_inner .= drupal_render($update_version);
}
}
......@@ -171,7 +219,11 @@ function theme_update_report($variables) {
$row .= t('Includes:');
$includes_items[] = t('Enabled: %includes', array('%includes' => implode(', ', $project['includes'])));
$includes_items[] = t('Disabled: %disabled', array('%disabled' => implode(', ', $project['disabled'])));
$row .= theme('item_list', array('items' => $includes_items));
$item_list = array(
'#theme' => 'item_list',
'#items' => $includes_items,
);
$row .= drupal_render($item_list);
}
else {
$row .= t('Includes: %includes', array('%includes' => implode(', ', $project['includes'])));
......@@ -183,11 +235,15 @@ function theme_update_report($variables) {
asort($project['base_themes']);
$base_themes = array();
foreach ($project['base_themes'] as $base_key => $base_theme) {
$update_status_label = array(
'#theme' => 'update_status_label',
'#status' => $status[$base_key],
);
switch ($status[$base_key]) {
case UPDATE_NOT_SECURE:
case UPDATE_REVOKED:
case UPDATE_NOT_SUPPORTED:
$base_themes[] = t('%base_theme (!base_label)', array('%base_theme' => $base_theme, '!base_label' => theme('update_status_label', array('status' => $status[$base_key]))));
$base_themes[] = t('%base_theme (!base_label)', array('%base_theme' => $base_theme, '!base_label' => drupal_render($update_status_label)));
break;
default:
......@@ -228,7 +284,15 @@ function theme_update_report($variables) {
if (!empty($rows[$type_name])) {
ksort($rows[$type_name]);
$output .= "\n<h3>" . $type_label . "</h3>\n";
$output .= theme('table', array('header' => $header, 'rows' => $rows[$type_name], 'attributes' => array('class' => array('update'))));
$table = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows[$type_name],
'#attributes' => array(
'class' => array('update'),
),
);
$output .= drupal_render($table);
}
}
drupal_add_css(drupal_get_path('module', 'update') . '/css/update.admin.css');
......@@ -303,7 +367,11 @@ function theme_update_version($variables) {
'title' => t('Release notes'),
'href' => $version['release_link'],
);
$output .= theme('links__update_version', array('links' => $links));
$links__update_version = array(
'#theme' => 'links__update_version',
'#links' => $links,
);
$output .= drupal_render($links__update_version);
$output .= '</td>';
$output .= '</tr>';
$output .= "</table>\n";
......
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