Issue #1898466 by joelpittet, webthingee, lokapujya, pplantinga, lokeoke, richardj, bdragon, steveoliver, ry5n, tlattimore, Cottser, siccababes, jenlampton, evanbarter, rodrigoaguilera, W1n5t0n45, drupalmonkey, ezeedub | c4rl: Update.module - Convert theme_ functions to Twig.
parent
a91ef2b853
commit
c2e66f9e1c
|
@ -56,9 +56,6 @@ class UpdateController extends ControllerBase {
|
||||||
$this->moduleHandler()->loadInclude('update', 'compare.inc');
|
$this->moduleHandler()->loadInclude('update', 'compare.inc');
|
||||||
$build['#data'] = update_calculate_project_data($available);
|
$build['#data'] = update_calculate_project_data($available);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$build['#data'] = _update_no_data();
|
|
||||||
}
|
|
||||||
return $build;
|
return $build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
{#
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Default theme implementation for the project status report.
|
||||||
|
*
|
||||||
|
* Available variables:
|
||||||
|
* - title: The project title.
|
||||||
|
* - url: The project url.
|
||||||
|
* - status: The project status.
|
||||||
|
* - label: The project status label.
|
||||||
|
* - attributes: HTML attributes for the project status.
|
||||||
|
* - reason: The reason you should update the project.
|
||||||
|
* - icon: The project status version indicator icon.
|
||||||
|
* - existing_version: The version of the installed project.
|
||||||
|
* - versions: The available versions of the project.
|
||||||
|
* - install_type: The type of project (e.g., dev).
|
||||||
|
* - datestamp: The date/time of a project version's release.
|
||||||
|
* - extras: HTML attributes and additional information about the project.
|
||||||
|
* - attributes: HTML attributes for the extra item.
|
||||||
|
* - label: The label for an extra item.
|
||||||
|
* - data: The data about an extra item.
|
||||||
|
* - includes: The projects within the project.
|
||||||
|
* - disabled: The currently disabled projects in the project.
|
||||||
|
* - base_themes: The base themes supplied by the project.
|
||||||
|
* - sub_themes: The subthemes supplied by the project.
|
||||||
|
*
|
||||||
|
* @see template_preprocess_update_project_status()
|
||||||
|
*
|
||||||
|
* @ingroup themeable
|
||||||
|
*/
|
||||||
|
#}
|
||||||
|
<div class="version-status">
|
||||||
|
{%- if status.label -%}
|
||||||
|
<span{{ status.attributes }}>{{ status.label }}</span>
|
||||||
|
{%- else -%}
|
||||||
|
{{ status.reason }}
|
||||||
|
{%- endif %}
|
||||||
|
<span class="icon">{{ status.icon }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="project">
|
||||||
|
{%- if url -%}
|
||||||
|
<a href="{{ url }}">{{ title }}</a>
|
||||||
|
{%- else -%}
|
||||||
|
{{ title }}
|
||||||
|
{%- endif %}
|
||||||
|
{{ existing_version }}
|
||||||
|
{% if install_type == 'dev' and datestamp %}
|
||||||
|
<span class="version-date">({{ datestamp }})</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if versions %}
|
||||||
|
<div class="versions">
|
||||||
|
{% for version in versions %}
|
||||||
|
{{ version }}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="info">
|
||||||
|
{% if extras %}
|
||||||
|
<div class="extra">
|
||||||
|
{% for extra in extras %}
|
||||||
|
<div{{ extra.attributes }}>
|
||||||
|
{{ extra.label }}: {{ extra.data }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="includes">
|
||||||
|
{% set includes = includes|join(', ') %}
|
||||||
|
{% if disabled %}
|
||||||
|
{{ 'Includes:'|t }}
|
||||||
|
<ul>
|
||||||
|
<li class="first odd">
|
||||||
|
{% trans %}
|
||||||
|
Enabled: {{ includes|placeholder }}
|
||||||
|
{% endtrans %}
|
||||||
|
</li>
|
||||||
|
<li class="last even">
|
||||||
|
{% set disabled = disabled|join(', ') %}
|
||||||
|
{% trans %}
|
||||||
|
Disabled: {{ disabled|placeholder }}
|
||||||
|
{% endtrans %}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
{% trans %}
|
||||||
|
Includes: {{ includes|placeholder }}
|
||||||
|
{% endtrans %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if base_themes %}
|
||||||
|
{% set basethemes = base_themes|join(', ') %}
|
||||||
|
{# Using passthrough since placeholder is already applied in preprocess. #}
|
||||||
|
<div class="basethemes">
|
||||||
|
{% trans %}
|
||||||
|
Depends on: {{ basethemes|passthrough }}
|
||||||
|
{% endtrans %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if sub_themes %}
|
||||||
|
{% set subthemes = sub_themes|join(', ') %}
|
||||||
|
<div class="subthemes">
|
||||||
|
{% trans %}
|
||||||
|
Required by: {{ subthemes|placeholder }}
|
||||||
|
{% endtrans %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
|
@ -0,0 +1,25 @@
|
||||||
|
{#
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Default theme implementation for the project status report.
|
||||||
|
*
|
||||||
|
* Available variables:
|
||||||
|
* - last_checked: Themed last time update data was checked.
|
||||||
|
* - no_updates_message: Message when there are no project updates.
|
||||||
|
* - project_types: A list of project types.
|
||||||
|
* - label: The project type label.
|
||||||
|
* - table: The project status table.
|
||||||
|
*
|
||||||
|
* @see template_preprocess_update_report()
|
||||||
|
*
|
||||||
|
* @ingroup themeable
|
||||||
|
*/
|
||||||
|
#}
|
||||||
|
{{ last_checked }}
|
||||||
|
|
||||||
|
{% for project_type in project_types %}
|
||||||
|
<h3>{{ project_type.label }}</h3>
|
||||||
|
{{ project_type.table }}
|
||||||
|
{% else %}
|
||||||
|
<p>{{ no_updates_message }}</p>
|
||||||
|
{% endfor %}
|
|
@ -181,15 +181,17 @@ function update_theme() {
|
||||||
'update_report' => array(
|
'update_report' => array(
|
||||||
'variables' => array('data' => NULL),
|
'variables' => array('data' => NULL),
|
||||||
'file' => 'update.report.inc',
|
'file' => 'update.report.inc',
|
||||||
|
'template' => 'update-report',
|
||||||
|
),
|
||||||
|
'update_project_status' => array(
|
||||||
|
'variables' => array('project' => array(), 'includes_status' => array()),
|
||||||
|
'file' => 'update.report.inc',
|
||||||
|
'template' => 'update-project-status',
|
||||||
),
|
),
|
||||||
'update_version' => array(
|
'update_version' => array(
|
||||||
'variables' => array('version' => NULL, 'tag' => NULL, 'class' => array()),
|
'variables' => array('version' => NULL, 'tag' => NULL, 'class' => array()),
|
||||||
'file' => 'update.report.inc',
|
'file' => 'update.report.inc',
|
||||||
),
|
),
|
||||||
'update_status_label' => array(
|
|
||||||
'variables' => array('status' => NULL),
|
|
||||||
'file' => 'update.report.inc',
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
* Code required only when rendering the available updates report.
|
* Code required only when rendering the available updates report.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Drupal\Component\Utility\SafeMarkup;
|
use Drupal\Core\Template\Attribute;
|
||||||
use Drupal\Component\Utility\String;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns HTML for the project status report.
|
* Prepares variables for project status report templates.
|
||||||
|
*
|
||||||
|
* Default template: update-report.html.twig.
|
||||||
*
|
*
|
||||||
* @param array $variables
|
* @param array $variables
|
||||||
* An associative array containing:
|
* An associative array containing:
|
||||||
|
@ -17,27 +18,28 @@ use Drupal\Component\Utility\String;
|
||||||
*
|
*
|
||||||
* @ingroup themeable
|
* @ingroup themeable
|
||||||
*/
|
*/
|
||||||
function theme_update_report($variables) {
|
function template_preprocess_update_report(&$variables) {
|
||||||
$data = $variables['data'];
|
$data = $variables['data'];
|
||||||
|
|
||||||
$last = \Drupal::state()->get('update.last_check') ?: 0;
|
$last = \Drupal::state()->get('update.last_check') ?: 0;
|
||||||
$update_last_check = array(
|
|
||||||
|
$variables['last_checked'] = array(
|
||||||
'#theme' => 'update_last_check',
|
'#theme' => 'update_last_check',
|
||||||
'#last' => $last,
|
'#last' => $last,
|
||||||
|
// Attach the library to a variable that gets printed always.
|
||||||
|
'#attached' => array(
|
||||||
|
'library' => array(
|
||||||
|
'update/drupal.update.admin',
|
||||||
|
),
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$output = drupal_render($update_last_check);
|
|
||||||
|
|
||||||
if (!is_array($data)) {
|
// For no project update data, populate no data message.
|
||||||
// @todo When converting this theme function to Twig, double-check with the
|
if (empty($data)) {
|
||||||
// caller to ensure $data is not double-escaped. At present, we cannot
|
$variables['no_updates_message'] = _update_no_data();
|
||||||
// guarantee within this function that it is safe. Address in:
|
|
||||||
// https://www.drupal.org/node/1898466
|
|
||||||
$output .= '<p>' . $data . '</p>';
|
|
||||||
return SafeMarkup::set($output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$header = array();
|
$status = array();
|
||||||
$rows = array();
|
|
||||||
|
|
||||||
// Create an array of status values keyed by module or theme name, since
|
// Create an array of status values keyed by module or theme name, since
|
||||||
// we'll need this while generating the report if we have to cross reference
|
// we'll need this while generating the report if we have to cross reference
|
||||||
|
@ -48,71 +50,101 @@ function theme_update_report($variables) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$rows = array();
|
||||||
|
|
||||||
foreach ($data as $project) {
|
foreach ($data as $project) {
|
||||||
|
$project_status = array(
|
||||||
|
'#theme' => 'update_project_status',
|
||||||
|
'#project' => $project,
|
||||||
|
'#includes_status' => $status,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Build project rows.
|
||||||
|
if (!isset($rows[$project['project_type']])) {
|
||||||
|
$rows[$project['project_type']] = array(
|
||||||
|
'#type' => 'table',
|
||||||
|
'#attributes' => array('class' => array('update')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$row_key = !empty($project['title']) ? drupal_strtolower($project['title']) : drupal_strtolower($project['name']);
|
||||||
|
|
||||||
|
// Add the project status row and details.
|
||||||
|
$rows[$project['project_type']][$row_key]['status'] = $project_status;
|
||||||
|
|
||||||
|
// Add project status class attribute to the table row.
|
||||||
switch ($project['status']) {
|
switch ($project['status']) {
|
||||||
case UPDATE_CURRENT:
|
case UPDATE_CURRENT:
|
||||||
$class = 'ok';
|
$rows[$project['project_type']][$row_key]['#attributes'] = array('class' => array('ok'));
|
||||||
$uri = 'core/misc/icons/73b355/check.png';
|
|
||||||
$text = t('Ok');
|
|
||||||
break;
|
break;
|
||||||
case UPDATE_UNKNOWN:
|
case UPDATE_UNKNOWN:
|
||||||
case UPDATE_FETCH_PENDING:
|
case UPDATE_FETCH_PENDING:
|
||||||
case UPDATE_NOT_FETCHED:
|
case UPDATE_NOT_FETCHED:
|
||||||
$class = 'unknown';
|
$rows[$project['project_type']][$row_key]['#attributes'] = array('class' => array('unknown'));
|
||||||
$uri = 'core/misc/icons/e29700/warning.png';
|
|
||||||
$text = t('Warning');
|
|
||||||
break;
|
break;
|
||||||
case UPDATE_NOT_SECURE:
|
case UPDATE_NOT_SECURE:
|
||||||
case UPDATE_REVOKED:
|
case UPDATE_REVOKED:
|
||||||
case UPDATE_NOT_SUPPORTED:
|
case UPDATE_NOT_SUPPORTED:
|
||||||
$class = 'error';
|
$rows[$project['project_type']][$row_key]['#attributes'] = array('class' => array('error'));
|
||||||
$uri = 'core/misc/icons/ea2800/error.png';
|
|
||||||
$text = t('Error');
|
|
||||||
break;
|
break;
|
||||||
case UPDATE_NOT_CHECKED:
|
case UPDATE_NOT_CHECKED:
|
||||||
case UPDATE_NOT_CURRENT:
|
case UPDATE_NOT_CURRENT:
|
||||||
default:
|
default:
|
||||||
$class = 'warning';
|
$rows[$project['project_type']][$row_key]['#attributes'] = array('class' => array('warning'));
|
||||||
$uri = 'core/misc/icons/e29700/warning.png';
|
|
||||||
$text = t('Warning');
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$icon = array(
|
$project_types = array(
|
||||||
'#theme' => 'image',
|
'core' => t('Drupal core'),
|
||||||
'#width' => 18,
|
'module' => t('Modules'),
|
||||||
'#height' => 18,
|
'theme' => t('Themes'),
|
||||||
'#uri' => $uri,
|
'module-disabled' => t('Disabled modules'),
|
||||||
'#alt' => $text,
|
'theme-disabled' => t('Disabled themes'),
|
||||||
'#title' => $text,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$row = '<div class="version-status">';
|
$variables['project_types'] = array();
|
||||||
$update_status_label = array('#theme' => 'update_status_label', '#status' => $project['status']);
|
foreach ($project_types as $type_name => $type_label) {
|
||||||
$status_label = drupal_render($update_status_label);
|
if (!empty($rows[$type_name])) {
|
||||||
$row .= !empty($status_label) ? $status_label : String::checkPlain($project['reason']);
|
ksort($rows[$type_name]);
|
||||||
$row .= '<span class="icon">' . drupal_render($icon) . '</span>';
|
$variables['project_types'][] = array(
|
||||||
$row .= "</div>\n";
|
'label' => $type_label,
|
||||||
|
'table' => $rows[$type_name],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$row .= '<div class="project">';
|
/**
|
||||||
if (isset($project['title'])) {
|
* Prepares variables for update project status templates.
|
||||||
if (isset($project['link'])) {
|
*
|
||||||
$row .= l($project['title'], $project['link']);
|
* Default template: update-project-status.html.twig.
|
||||||
}
|
*
|
||||||
else {
|
* @param array $variables
|
||||||
$row .= String::checkPlain($project['title']);
|
* An associative array containing:
|
||||||
}
|
* - project: An array of information about the project.
|
||||||
}
|
* - includes_status: An array of sub-project statuses where the keys are the
|
||||||
else {
|
* shortnames of each project and the values are UPDATE_* integer constants
|
||||||
$row .= String::checkPlain($project['name']);
|
* as defined in update.module.
|
||||||
}
|
*
|
||||||
$row .= ' ' . String::checkPlain($project['existing_version']);
|
* @ingroup themeable
|
||||||
|
*/
|
||||||
|
function template_preprocess_update_project_status(&$variables) {
|
||||||
|
// Storing by reference because we are sorting the project values.
|
||||||
|
$project = &$variables['project'];
|
||||||
|
$includes_status = $variables['includes_status'];
|
||||||
|
|
||||||
|
// Set the project title and URL.
|
||||||
|
$variables['title'] = (isset($project['title'])) ? $project['title'] : $project['name'];
|
||||||
|
$variables['url'] = (isset($project['link'])) ? url($project['link']) : NULL;
|
||||||
|
|
||||||
|
$variables['install_type'] = $project['install_type'];
|
||||||
if ($project['install_type'] == 'dev' && !empty($project['datestamp'])) {
|
if ($project['install_type'] == 'dev' && !empty($project['datestamp'])) {
|
||||||
$row .= ' <span class="version-date">(' . format_date($project['datestamp'], 'custom', 'Y-M-d') . ')</span>';
|
$variables['datestamp'] = format_date($project['datestamp'], 'custom', 'Y-M-d');
|
||||||
}
|
}
|
||||||
$row .= "</div>\n";
|
|
||||||
|
|
||||||
$versions_inner = '';
|
$variables['existing_version'] = $project['existing_version'];
|
||||||
|
|
||||||
|
$versions_inner = array();
|
||||||
$security_class = array();
|
$security_class = array();
|
||||||
$version_class = array();
|
$version_class = array();
|
||||||
if (isset($project['recommended'])) {
|
if (isset($project['recommended'])) {
|
||||||
|
@ -122,7 +154,10 @@ function theme_update_report($variables) {
|
||||||
// If there's only 1 security update and it has the same version we're
|
// If there's only 1 security update and it has the same version we're
|
||||||
// recommending, give it the same CSS class as if it was recommended,
|
// recommending, give it the same CSS class as if it was recommended,
|
||||||
// but don't print out a separate "Recommended" line for this project.
|
// but don't print out a separate "Recommended" line for this project.
|
||||||
if (!empty($project['security updates']) && count($project['security updates']) == 1 && $project['security updates'][0]['version'] === $project['recommended']) {
|
if (!empty($project['security updates'])
|
||||||
|
&& count($project['security updates']) == 1
|
||||||
|
&& $project['security updates'][0]['version'] === $project['recommended']
|
||||||
|
) {
|
||||||
$security_class[] = 'version-recommended';
|
$security_class[] = 'version-recommended';
|
||||||
$security_class[] = 'version-recommended-strong';
|
$security_class[] = 'version-recommended-strong';
|
||||||
}
|
}
|
||||||
|
@ -141,206 +176,181 @@ function theme_update_report($variables) {
|
||||||
) {
|
) {
|
||||||
$version_class[] = 'version-recommended-strong';
|
$version_class[] = 'version-recommended-strong';
|
||||||
}
|
}
|
||||||
$update_version = array(
|
$versions_inner[] = array(
|
||||||
'#theme' => 'update_version',
|
'#theme' => 'update_version',
|
||||||
'#version' => $project['releases'][$project['recommended']],
|
'#version' => $project['releases'][$project['recommended']],
|
||||||
'#tag' => t('Recommended version:'),
|
'#title' => t('Recommended version:'),
|
||||||
'#class' => $version_class,
|
'#attributes' => array('class' => $version_class),
|
||||||
);
|
);
|
||||||
$versions_inner .= drupal_render($update_version);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now, print any security updates.
|
// Now, print any security updates.
|
||||||
if (!empty($project['security updates'])) {
|
if (!empty($project['security updates'])) {
|
||||||
$security_class[] = 'version-security';
|
$security_class[] = 'version-security';
|
||||||
foreach ($project['security updates'] as $security_update) {
|
foreach ($project['security updates'] as $security_update) {
|
||||||
$update_version = array(
|
$versions_inner[] = array(
|
||||||
'#theme' => 'update_version',
|
'#theme' => 'update_version',
|
||||||
'#version' => $security_update,
|
'#version' => $security_update,
|
||||||
'#tag' => t('Security update:'),
|
'#title' => t('Security update:'),
|
||||||
'#class' => $security_class,
|
'#attributes' => array('class' => $security_class),
|
||||||
);
|
);
|
||||||
$versions_inner .= drupal_render($update_version);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($project['recommended'] !== $project['latest_version']) {
|
if ($project['recommended'] !== $project['latest_version']) {
|
||||||
$update_version = array(
|
$versions_inner[] = array(
|
||||||
'#theme' => 'update_version',
|
'#theme' => 'update_version',
|
||||||
'#version' => $project['releases'][$project['latest_version']],
|
'#version' => $project['releases'][$project['latest_version']],
|
||||||
'#tag' => t('Latest version:'),
|
'#title' => t('Latest version:'),
|
||||||
'#class' => array('version-latest'),
|
'#attributes' => array('class' => array('version-latest')),
|
||||||
);
|
);
|
||||||
$versions_inner .= drupal_render($update_version);
|
|
||||||
}
|
}
|
||||||
if ($project['install_type'] == 'dev'
|
if ($project['install_type'] == 'dev'
|
||||||
&& $project['status'] != UPDATE_CURRENT
|
&& $project['status'] != UPDATE_CURRENT
|
||||||
&& isset($project['dev_version'])
|
&& isset($project['dev_version'])
|
||||||
&& $project['recommended'] !== $project['dev_version']) {
|
&& $project['recommended'] !== $project['dev_version']) {
|
||||||
$update_version = array(
|
$versions_inner[] = array(
|
||||||
'#theme' => 'update_version',
|
'#theme' => 'update_version',
|
||||||
'#version' => $project['releases'][$project['dev_version']],
|
'#version' => $project['releases'][$project['dev_version']],
|
||||||
'#tag' => t('Development version:'),
|
'#title' => t('Development version:'),
|
||||||
'#class' => array('version-latest'),
|
'#attributes' => array('class' => array('version-latest')),
|
||||||
);
|
);
|
||||||
$versions_inner .= drupal_render($update_version);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($project['also'])) {
|
if (isset($project['also'])) {
|
||||||
foreach ($project['also'] as $also) {
|
foreach ($project['also'] as $also) {
|
||||||
$update_version = array(
|
$versions_inner[] = array(
|
||||||
'#theme' => 'update_version',
|
'#theme' => 'update_version',
|
||||||
'#version' => $project['releases'][$also],
|
'#version' => $project['releases'][$also],
|
||||||
'#tag' => t('Also available:'),
|
'#title' => t('Also available:'),
|
||||||
'#class' => array('version-also-available'),
|
'#attributes' => array('class' => array('version-also-available')),
|
||||||
);
|
);
|
||||||
$versions_inner .= drupal_render($update_version);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($versions_inner)) {
|
if (!empty($versions_inner)) {
|
||||||
$row .= "<div class=\"versions\">\n" . $versions_inner . "</div>\n";
|
$variables['versions'] = $versions_inner;
|
||||||
}
|
|
||||||
$row .= "<div class=\"info\">\n";
|
|
||||||
if (!empty($project['extra'])) {
|
|
||||||
$row .= '<div class="extra">' . "\n";
|
|
||||||
foreach ($project['extra'] as $value) {
|
|
||||||
$row .= '<div class="' . implode(' ', $value['class']) . '">';
|
|
||||||
$row .= String::checkPlain($value['label']) . ': ';
|
|
||||||
$row .= drupal_placeholder($value['data']);
|
|
||||||
$row .= "</div>\n";
|
|
||||||
}
|
|
||||||
$row .= "</div>\n"; // extra div.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$row .= '<div class="includes">';
|
|
||||||
sort($project['includes']);
|
|
||||||
if (!empty($project['disabled'])) {
|
if (!empty($project['disabled'])) {
|
||||||
sort($project['disabled']);
|
sort($project['disabled']);
|
||||||
// Make sure we start with a clean slate for each project in the report.
|
$variables['disabled'] = $project['disabled'];
|
||||||
$includes_items = array();
|
}
|
||||||
$row .= t('Includes:');
|
|
||||||
$includes_items[] = t('Enabled: %includes', array('%includes' => implode(', ', $project['includes'])));
|
sort($project['includes']);
|
||||||
$includes_items[] = t('Disabled: %disabled', array('%disabled' => implode(', ', $project['disabled'])));
|
$variables['includes'] = $project['includes'];
|
||||||
$item_list = array(
|
|
||||||
'#theme' => 'item_list',
|
$variables['extras'] = array();
|
||||||
'#items' => $includes_items,
|
if (!empty($project['extra'])) {
|
||||||
);
|
foreach ($project['extra'] as $value) {
|
||||||
$row .= drupal_render($item_list);
|
$extra_item = array();
|
||||||
|
$extra_item['attributes'] = new Attribute(array('class' => $value['class']));
|
||||||
|
$extra_item['label'] = $value['label'];
|
||||||
|
$extra_item['data'] = drupal_placeholder($value['data']);
|
||||||
|
$variables['extras'][] = $extra_item;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$row .= t('Includes: %includes', array('%includes' => implode(', ', $project['includes'])));
|
|
||||||
}
|
}
|
||||||
$row .= "</div>\n";
|
|
||||||
|
|
||||||
if (!empty($project['base_themes'])) {
|
if (!empty($project['base_themes'])) {
|
||||||
$row .= '<div class="basethemes">';
|
|
||||||
asort($project['base_themes']);
|
asort($project['base_themes']);
|
||||||
$base_themes = array();
|
$base_themes = array();
|
||||||
foreach ($project['base_themes'] as $base_key => $base_theme) {
|
foreach ($project['base_themes'] as $base_key => $base_theme) {
|
||||||
$update_status_label = array(
|
switch ($includes_status[$base_key]) {
|
||||||
'#theme' => 'update_status_label',
|
|
||||||
'#status' => $status[$base_key],
|
|
||||||
);
|
|
||||||
switch ($status[$base_key]) {
|
|
||||||
case UPDATE_NOT_SECURE:
|
case UPDATE_NOT_SECURE:
|
||||||
case UPDATE_REVOKED:
|
$base_status_label = t('Security update required!');
|
||||||
case UPDATE_NOT_SUPPORTED:
|
break;
|
||||||
$base_themes[] = t('%base_theme (!base_label)', array('%base_theme' => $base_theme, '!base_label' => drupal_render($update_status_label)));
|
case UPDATE_REVOKED:
|
||||||
|
$base_status_label = t('Revoked!');
|
||||||
|
break;
|
||||||
|
case UPDATE_NOT_SUPPORTED:
|
||||||
|
$base_status_label = t('Not supported!');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
$base_status_label = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($base_status_label) {
|
||||||
|
$base_themes[] = t('%base_theme (!base_label)', array(
|
||||||
|
'%base_theme' => $base_theme,
|
||||||
|
'!base_label' => $base_status_label,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
else {
|
||||||
$base_themes[] = drupal_placeholder($base_theme);
|
$base_themes[] = drupal_placeholder($base_theme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$row .= t('Depends on: !basethemes', array('!basethemes' => implode(', ', $base_themes)));
|
$variables['base_themes'] = $base_themes;
|
||||||
$row .= "</div>\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($project['sub_themes'])) {
|
if (!empty($project['sub_themes'])) {
|
||||||
$row .= '<div class="subthemes">';
|
|
||||||
sort($project['sub_themes']);
|
sort($project['sub_themes']);
|
||||||
$row .= t('Required by: %subthemes', array('%subthemes' => implode(', ', $project['sub_themes'])));
|
$variables['sub_themes'] = $project['sub_themes'];
|
||||||
$row .= "</div>\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$row .= "</div>\n"; // info div.
|
// Set the project status details.
|
||||||
|
$status_attributes = array();
|
||||||
if (!isset($rows[$project['project_type']])) {
|
$status_label = NULL;
|
||||||
$rows[$project['project_type']] = array();
|
switch ($project['status']) {
|
||||||
}
|
|
||||||
$row_key = isset($project['title']) ? drupal_strtolower($project['title']) : drupal_strtolower($project['name']);
|
|
||||||
$rows[$project['project_type']][$row_key] = array(
|
|
||||||
'class' => array($class),
|
|
||||||
'data' => array(SafeMarkup::set($row)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$project_types = array(
|
|
||||||
'core' => t('Drupal core'),
|
|
||||||
'module' => t('Modules'),
|
|
||||||
'theme' => t('Themes'),
|
|
||||||
'module-disabled' => t('Disabled modules'),
|
|
||||||
'theme-disabled' => t('Disabled themes'),
|
|
||||||
);
|
|
||||||
foreach ($project_types as $type_name => $type_label) {
|
|
||||||
if (!empty($rows[$type_name])) {
|
|
||||||
ksort($rows[$type_name]);
|
|
||||||
$output .= "\n<h3>" . $type_label . "</h3>\n";
|
|
||||||
$table = array(
|
|
||||||
'#type' => 'table',
|
|
||||||
'#header' => $header,
|
|
||||||
'#rows' => $rows[$type_name],
|
|
||||||
'#attributes' => array(
|
|
||||||
'class' => array('update'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
$output .= drupal_render($table);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$assets = array(
|
|
||||||
'#attached' => array(
|
|
||||||
'library' => array(
|
|
||||||
'update/drupal.update.admin',
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
drupal_render($assets);
|
|
||||||
|
|
||||||
return SafeMarkup::set($output);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns HTML for a label to display for a project's update status.
|
|
||||||
*
|
|
||||||
* @param array $variables
|
|
||||||
* An associative array containing:
|
|
||||||
* - status: The integer code for a project's current update status.
|
|
||||||
*
|
|
||||||
* @see update_calculate_project_data()
|
|
||||||
* @ingroup themeable
|
|
||||||
*/
|
|
||||||
function theme_update_status_label($variables) {
|
|
||||||
switch ($variables['status']) {
|
|
||||||
case UPDATE_NOT_SECURE:
|
case UPDATE_NOT_SECURE:
|
||||||
return '<span class="security-error">' . t('Security update required!') . '</span>';
|
$status_attributes['class'][] = 'security-error';
|
||||||
|
$status_label = t('Security update required!');
|
||||||
|
break;
|
||||||
case UPDATE_REVOKED:
|
case UPDATE_REVOKED:
|
||||||
return '<span class="revoked">' . t('Revoked!') . '</span>';
|
$status_attributes['class'][] = 'revoked';
|
||||||
|
$status_label = t('Revoked!');
|
||||||
|
break;
|
||||||
case UPDATE_NOT_SUPPORTED:
|
case UPDATE_NOT_SUPPORTED:
|
||||||
return '<span class="not-supported">' . t('Not supported!') . '</span>';
|
$status_attributes['class'][] = 'not-supported';
|
||||||
|
$status_label = t('Not supported!');
|
||||||
|
break;
|
||||||
case UPDATE_NOT_CURRENT:
|
case UPDATE_NOT_CURRENT:
|
||||||
return '<span class="not-current">' . t('Update available') . '</span>';
|
$status_attributes['class'][] = 'not-current';
|
||||||
|
$status_label = t('Update available');
|
||||||
|
break;
|
||||||
case UPDATE_CURRENT:
|
case UPDATE_CURRENT:
|
||||||
return '<span class="current">' . t('Up to date') . '</span>';
|
$status_attributes['class'][] = 'current';
|
||||||
|
$status_label = t('Up to date');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
$variables['status']['label'] = $status_label;
|
||||||
|
$variables['status']['attributes'] = new Attribute($status_attributes);
|
||||||
|
$variables['status']['reason'] = (isset($project['reason'])) ? $project['reason'] : NULL;
|
||||||
|
|
||||||
|
switch ($project['status']) {
|
||||||
|
case UPDATE_CURRENT:
|
||||||
|
$uri = 'core/misc/icons/73b355/check.png';
|
||||||
|
$text = t('Ok');
|
||||||
|
break;
|
||||||
|
case UPDATE_UNKNOWN:
|
||||||
|
case UPDATE_FETCH_PENDING:
|
||||||
|
case UPDATE_NOT_FETCHED:
|
||||||
|
$uri = 'core/misc/icons/e29700/warning.png';
|
||||||
|
$text = t('Warning');
|
||||||
|
break;
|
||||||
|
case UPDATE_NOT_SECURE:
|
||||||
|
case UPDATE_REVOKED:
|
||||||
|
case UPDATE_NOT_SUPPORTED:
|
||||||
|
$uri = 'core/misc/icons/ea2800/error.png';
|
||||||
|
$text = t('Error');
|
||||||
|
break;
|
||||||
|
case UPDATE_NOT_CHECKED:
|
||||||
|
case UPDATE_NOT_CURRENT:
|
||||||
|
default:
|
||||||
|
$uri = 'core/misc/icons/e29700/warning.png';
|
||||||
|
$text = t('Warning');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$variables['status']['icon'] = array(
|
||||||
|
'#theme' => 'image',
|
||||||
|
'#width' => 18,
|
||||||
|
'#height' => 18,
|
||||||
|
'#uri' => $uri,
|
||||||
|
'#alt' => $text,
|
||||||
|
'#title' => $text,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue