diff --git a/core/modules/image/image.module b/core/modules/image/image.module
index 2cc6f6b..00f21b6 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -693,10 +693,9 @@ function image_style_transform_dimensions($style_name, array &$dimensions) {
* An image style array.
*/
function image_style_flush($style) {
- // Delete the style directory in each registered wrapper.
- $wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE);
- foreach ($wrappers as $wrapper => $wrapper_data) {
- file_unmanaged_delete_recursive($wrapper . '://styles/' . $style->id());
+ $style_directory = drupal_realpath(file_default_scheme() . '://styles/' . $style->id());
+ if (is_dir($style_directory)) {
+ file_unmanaged_delete_recursive($style_directory);
}
// Let other modules update as necessary on flush.
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageStyleFlushTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageStyleFlushTest.php
deleted file mode 100644
index 298819a..0000000
--- a/core/modules/image/lib/Drupal/image/Tests/ImageStyleFlushTest.php
+++ /dev/null
@@ -1,118 +0,0 @@
- 'Image style flushing',
- 'description' => 'Tests flushing of image styles.',
- 'group' => 'Image',
- );
- }
-
- /**
- * Given an image style and a wrapper, generate an image.
- */
- function createSampleImage($style, $wrapper) {
- static $file;
-
- if (!isset($file)) {
- $files = $this->drupalGetTestFiles('image');
- $file = reset($files);
- }
-
- // Make sure we have an image in our wrapper testing file directory.
- $source_uri = file_unmanaged_copy($file->uri, $wrapper . '://');
- // Build the derivative image.
- $derivative_uri = image_style_path($style->id(), $source_uri);
- $derivative = image_style_create_derivative($style, $source_uri, $derivative_uri);
-
- return $derivative ? $derivative_uri : FALSE;
- }
-
- /**
- * Count the number of images currently created for a style in a wrapper.
- */
- function getImageCount($style, $wrapper) {
- return count(file_scan_directory($wrapper . '://styles/' . $style->id(), '/.*/'));
- }
-
- /**
- * General test to flush a style.
- */
- function testFlush() {
-
- // Setup a style to be created and effects to add to it.
- $style_name = strtolower($this->randomName(10));
- $style_label = $this->randomString();
- $style_path = 'admin/config/media/image-styles/manage/' . $style_name;
- $effect_edits = array(
- 'image_resize' => array(
- 'data[width]' => 100,
- 'data[height]' => 101,
- ),
- 'image_scale' => array(
- 'data[width]' => 110,
- 'data[height]' => 111,
- 'data[upscale]' => 1,
- ),
- );
-
- // Add style form.
- $edit = array(
- 'name' => $style_name,
- 'label' => $style_label,
- );
- $this->drupalPost('admin/config/media/image-styles/add', $edit, t('Create new style'));
-
- // Add each sample effect to the style.
- foreach ($effect_edits as $effect => $edit) {
- // Add the effect.
- $this->drupalPost($style_path, array('new' => $effect), t('Add'));
- if (!empty($edit)) {
- $this->drupalPost(NULL, $edit, t('Add effect'));
- }
- }
-
- // Load the saved image style.
- $style = entity_load('image_style', $style_name);
-
- // Create an image for the 'public' wrapper.
- $image_path = $this->createSampleImage($style, 'public');
- // Expecting to find 2 images, one is the sample.png image shown in
- // image style preview.
- $this->assertEqual($this->getImageCount($style, 'public'), 2, format_string('Image style %style image %file successfully generated.', array('%style' => $style->label(), '%file' => $image_path)));
-
- // Create an image for the 'private' wrapper.
- $image_path = $this->createSampleImage($style, 'private');
- $this->assertEqual($this->getImageCount($style, 'private'), 1, format_string('Image style %style image %file successfully generated.', array('%style' => $style->label(), '%file' => $image_path)));
-
- // Remove the 'image_scale' effect and updates the style, which in turn
- // forces an image style flush.
- $style_path = 'admin/config/media/image-styles/manage/' . $style->id();
- $ieids = array();
- foreach ($style->effects as $ieid => $effect) {
- $ieids[$effect['name']] = $ieid;
- }
- $this->drupalPost($style_path . '/effects/' . $ieids['image_scale'] . '/delete', array(), t('Delete'));
- $this->assertResponse(200);
- $this->drupalPost($style_path, array(), t('Update style'));
- $this->assertResponse(200);
-
- // Post flush, expected 1 image in the 'public' wrapper (sample.png).
- $this->assertEqual($this->getImageCount($style, 'public'), 1, format_string('Image style %style flushed correctly for %wrapper wrapper.', array('%style' => $style->label(), '%wrapper' => 'public')));
-
- // Post flush, expected no image in the 'private' wrapper.
- $this->assertEqual($this->getImageCount($style, 'private'), 0, format_string('Image style %style flushed correctly for %wrapper wrapper.', array('%style' => $style->label(), '%wrapper' => 'private')));
- }
-}
diff --git a/core/modules/update/templates/update-last-check.html.twig b/core/modules/update/templates/update-last-check.html.twig
new file mode 100644
index 0000000..0dfe6d8
--- /dev/null
+++ b/core/modules/update/templates/update-last-check.html.twig
@@ -0,0 +1,24 @@
+{#
+/**
+ * @file
+ * Default theme display for last time the site checked for updated data.
+ *
+ * Available variables:
+ * - last_checked: A boolean when the site last checked for available updates.
+ * - time: The time the site last checked for updates.
+ * - link: A link to check for updates manually.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_update_last_check()
+ *
+ * @ingroup themeable
+ */
+#}
+
+ {% if last_checked %}
+ {{ 'Last checked: @time ago'|t({'@time': time}) }}
+ {% else %}
+ {{ 'Last checked: never'|t }}
+ {% endif %}
+ ({{ link }})
+
diff --git a/core/modules/update/templates/update-report.html.twig b/core/modules/update/templates/update-report.html.twig
new file mode 100644
index 0000000..2f75740
--- /dev/null
+++ b/core/modules/update/templates/update-report.html.twig
@@ -0,0 +1,104 @@
+{#
+/**
+ * @file
+ * Default theme implementation for the project status report.
+ *
+ * Available variables:
+ * - update_last_check: The last date/time the system checked for updates
+ * for the installed projects.
+ * - project_types: A list of product types.
+ * - label: The product type label.
+ * - projects: Data about each project's status.
+ * - title: The project tile.
+ * - attributes: HTML attributes for the product row.
+ * - status_label: The project status label.
+ * - 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 (i.e. dev).
+ * - datestamp: The date/time of a project versions release.
+ * - extra: 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 project.
+ * - base_themes: The base theme declared for the project.
+ * - sub_themes: The sub themes declared for the project.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_update_report()
+ *
+ * @ingroup themeable
+ */
+#}
+{{ update_last_check }}
+
+{% for project_type in project_types %}
+ {{ project_type.label }}
+
+
+ {% for project in project_type.projects %}
+
+
+ {% spaceless %}
+
+ {{- project.status_label|default(project.reason) -}}
+ {{ project.icon }}
+
+ {% endspaceless %}
+
+ {{ project.title }} {{ project.existing_version }}
+ {% if project.install_type == 'dev' and project.datestamp %}
+ ({{ project.datestamp }})
+ {% endif %}
+
+
+ {% if project.versions %}
+
+ {% for version in project.versions %}
+ {{ version }}
+ {% endfor %}
+
+ {% endif %}
+
+
+ {% if project.extra %}
+
+ {% endif %}
+
+ {% if project.disabled %}
+ {{ 'Includes:'|t }}
+
+ - {{ 'Enabled: %includes'|t({'%includes': project.includes|join(', ')}) }}
+ - {{ 'Disabled: %disabled'|t({'%disabled': project.disabled|join(', ')}) }}
+
+ {% else %}
+ {{ 'Includes: %includes'|t({'%includes': project.includes|join(', ')}) }}
+ {% endif %}
+
+
+ {% if project.base_themes %}
+
+ {{ 'Depends on: !basethemes'|t({'!basethemes': project.base_themes|join(', ')}) }}
+
+ {% endif %}
+
+ {% if project.sub_themes %}
+
+ {{ 'Required by: %subthemes'|t({'%subthemes': project.sub_themes|join(', ')}) }}
+
+ {% endif %}
+
+ |
+
+ {% endfor %}
+
+
+{% endfor %}
diff --git a/core/modules/update/templates/update-status-label.html.twig b/core/modules/update/templates/update-status-label.html.twig
new file mode 100644
index 0000000..43c8512
--- /dev/null
+++ b/core/modules/update/templates/update-status-label.html.twig
@@ -0,0 +1,21 @@
+{#
+/**
+ * @file
+ * Default theme implementation for an update status label.
+ *
+ * Available variables:
+ * - text: The status label text.
+ * - attributes: Remaining HTML attributes for the element.
+ * - class: HTML classes that can be used to style contextually through CSS.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_update_status_label()
+ *
+ * @ingroup themeable
+ */
+#}
+{% spaceless %}
+ {% if text %}
+ {{ text|t }}
+ {% endif %}
+{% endspaceless %}
diff --git a/core/modules/update/templates/update-version.html.twig b/core/modules/update/templates/update-version.html.twig
new file mode 100644
index 0000000..119a781
--- /dev/null
+++ b/core/modules/update/templates/update-version.html.twig
@@ -0,0 +1,30 @@
+{#
+/**
+ * @file
+ * Default theme implementation for the version display of a project.
+ *
+ * Available variables:
+ * - attributes: HTML attributes for the update versions table.
+ * - version_link: @todo.
+ * - version_date: The date of the release.
+ * - version_links: @todo.
+ * - tag: The title of the project.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_update_version()
+ *
+ * @ingroup themeable
+ */
+#}
+
+
+ {{ tag }} |
+
+ {{ version_link }}
+ ({{ version_date }})
+ |
+
+ {{ version_links }}
+ |
+
+
diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc
index bc84058..84cd47e 100644
--- a/core/modules/update/update.manager.inc
+++ b/core/modules/update/update.manager.inc
@@ -67,7 +67,11 @@ function update_manager_update_form($form, $form_state = array(), $context) {
return $form;
}
- $form['#theme'] = 'update_manager_update_form';
+ $last = state()->get('update.last_check') ?: 0;
+ $form['update_last_check'] = array(
+ '#theme' => 'update_last_check',
+ '#last' => $last,
+ );
$available = update_get_available(TRUE);
if (empty($available)) {
@@ -268,23 +272,6 @@ function update_manager_update_form($form, $form_state = array(), $context) {
}
/**
- * Returns HTML for the first page in the process of updating projects.
- *
- * @param $variables
- * An associative array containing:
- * - form: A render element representing the form.
- *
- * @ingroup themeable
- */
-function theme_update_manager_update_form($variables) {
- $form = $variables['form'];
- $last = state()->get('update.last_check') ?: 0;
- $output = theme('update_last_check', array('last' => $last));
- $output .= drupal_render_children($form);
- return $output;
-}
-
-/**
* Form validation handler for update_manager_update_form().
*
* Ensures that at least one project is selected.
diff --git a/core/modules/update/update.module b/core/modules/update/update.module
index ddbc398..2f33674 100644
--- a/core/modules/update/update.module
+++ b/core/modules/update/update.module
@@ -255,24 +255,24 @@ function update_manager_access() {
*/
function update_theme() {
return array(
- 'update_manager_update_form' => array(
- 'render element' => 'form',
- 'file' => 'update.manager.inc',
- ),
'update_last_check' => array(
'variables' => array('last' => NULL),
+ 'template' => 'update-last-check',
),
'update_report' => array(
'variables' => array('data' => NULL),
'file' => 'update.report.inc',
+ 'template' => 'update-report',
),
'update_version' => array(
'variables' => array('version' => NULL, 'tag' => NULL, 'class' => array()),
'file' => 'update.report.inc',
+ 'template' => 'update-version',
),
'update_status_label' => array(
'variables' => array('status' => NULL),
'file' => 'update.report.inc',
+ 'template' => 'update-status-label',
),
);
}
@@ -626,13 +626,11 @@ function _update_project_status_sort($a, $b) {
* @see theme_update_available_updates_form()
* @ingroup themeable
*/
-function theme_update_last_check($variables) {
+function template_preprocess_update_last_check(&$variables) {
$last = $variables['last'];
- $output = '';
- $output .= $last ? t('Last checked: @time ago', array('@time' => format_interval(REQUEST_TIME - $last))) : t('Last checked: never');
- $output .= ' (' . l(t('Check manually'), 'admin/reports/updates/check', array('query' => drupal_get_destination())) . ')';
- $output .= "
\n";
- return $output;
+ $variables['last_checked'] = ($last != NULL);
+ $variables['time'] = format_interval(REQUEST_TIME - $last);
+ $variables['link'] = l(t('Check manually'), 'admin/reports/updates/check', array('query' => drupal_get_destination()));
}
/**
diff --git a/core/modules/update/update.report.inc b/core/modules/update/update.report.inc
index 35677d8..a42cc8c 100644
--- a/core/modules/update/update.report.inc
+++ b/core/modules/update/update.report.inc
@@ -1,33 +1,64 @@
get('update.last_check') ?: 0;
- $output = theme('update_last_check', array('last' => $last));
+ $build['last_check'] = array(
+ '#theme' => 'update_last_check',
+ '#last' => $last,
+ );
+ if ($available = update_get_available(TRUE)) {
+ module_load_include('inc', 'update', 'update.compare');
+ $data = update_calculate_project_data($available);
+ }
+ else {
+ $data = _update_no_data();
+ }
if (!is_array($data)) {
- $output .= '' . $data . '
';
- return $output;
+ $build['data'] = array(
+ '#markup' => $data,
+ '#prefix' => '',
+ '#suffix' => '
',
+ );
+ return $build;
}
- $header = array();
+ $build['report'] = array(
+ '#theme' => 'update_report',
+ '#data' => $data,
+ );
+ return $build;
+}
+
+/**
+ * Prepares variables the project status report.
+ *
+ * Default template: update-report.html.twig.
+ *
+ * @param array $variables
+ * An associative array containing:
+ * - data: An array of data about each project's status.
+ */
+function template_preprocess_update_report(&$variables) {
+ $data = $variables['data'];
$rows = array();
+ $last = state()->get('update.last_check') ?: 0;
+ $variables['update_last_check'] = theme('update_last_check', array('last' => $last));
+
$notification_level = config('update.settings')->get('notification.threshold');
// Create an array of status values keyed by module or theme name, since
@@ -43,53 +74,97 @@ 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')));
+ $icon = array(
+ '#theme' => 'image',
+ '#uri' => 'core/misc/watchdog-ok.png',
+ '#width' => 18,
+ '#height' => 18,
+ '#alt' => t('ok'),
+ '#title' => 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')));
+ $icon = array(
+ '#theme' => 'image',
+ '#uri' => 'core/misc/watchdog-warning.png',
+ '#width' => 18,
+ '#height' => 18,
+ '#alt' => t('warning'),
+ '#title' => 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')));
+ $icon = array(
+ '#theme' => 'image',
+ '#uri' => 'core/misc/watchdog-error.png',
+ '#width' => 18,
+ '#height' => 18,
+ '#alt' => t('error'),
+ '#title' => 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')));
+ $icon = array(
+ '#theme' => 'image',
+ '#uri' => 'core/misc/watchdog-warning.png',
+ '#width' => 18,
+ '#height' => 18,
+ '#alt' => t('warning'),
+ '#title' => t('warning'),
+ );
break;
}
- $row = '';
- $status_label = theme('update_status_label', array('status' => $project['status']));
- $row .= !empty($status_label) ? $status_label : check_plain($project['reason']);
- $row .= '' . $icon . '';
- $row .= "
\n";
+ // Used to collect the project values.
+ $row = array();
+ $row['attributes'] = new Attribute(array('class' => $class));
+ $row['icon'] = $icon;
+
+ // Rendered status label here because we can't check that a TwigReference
+ // is empty in the twig file.
+ $status_label = array(
+ '#theme' => 'update_status_label',
+ '#status' => $project['status'],
+ );
+ $row['status_label'] = drupal_render($status_label);
- $row .= '';
+ if (!empty($project['reason'])) {
+ $row['reason'] = check_plain($project['reason']);
+ }
+ else {
+ $row['reason'] = '';
+ }
+
+ // Set the project title.
if (isset($project['title'])) {
if (isset($project['link'])) {
- $row .= l($project['title'], $project['link']);
+ $row['title'] = l($project['title'], $project['link']);
}
else {
- $row .= check_plain($project['title']);
+ $row['title'] = check_plain($project['title']);
}
}
else {
- $row .= check_plain($project['name']);
+ $row['title'] = check_plain($project['name']);
}
- $row .= ' ' . check_plain($project['existing_version']);
+
+ // Clean up the version for twig.
+ $row['existing_version'] = check_plain($project['existing_version']);
+
if ($project['install_type'] == 'dev' && !empty($project['datestamp'])) {
- $row .= ' (' . format_date($project['datestamp'], 'custom', 'Y-M-d') . ')';
+ $row['datestamp'] = format_date($project['datestamp'], 'custom', 'Y-M-d');
}
- $row .= "
\n";
- $versions_inner = '';
+ $versions_inner = array();
$security_class = array();
$version_class = array();
if (isset($project['recommended'])) {
@@ -99,7 +174,10 @@ function theme_update_report($variables) {
// 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,
// 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-strong';
}
@@ -118,68 +196,87 @@ 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));
+ $versions_inner[] = array(
+ '#theme' => 'update_version',
+ '#version' => $project['releases'][$project['recommended']],
+ '#tag' => t('Recommended version:'),
+ '#class' => $version_class,
+ );
}
// 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));
+ $versions_inner[] = array(
+ '#theme' => 'update_version',
+ '#version' => $security_update,
+ '#tag' => t('Security update:'),
+ '#class' => $security_class,
+ );
}
}
}
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')));
+ $versions_inner[] = array(
+ '#theme' => 'update_version',
+ '#version' => $project['releases'][$project['latest_version']],
+ '#tag' => t('Latest version:'),
+ '#class' => array('version-latest'),
+ );
}
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')));
+ $versions_inner[] = array(
+ '#theme' => 'update_version',
+ '#version' => $project['releases'][$project['dev_version']],
+ '#tag' => t('Development version:'),
+ '#class' => array('version-latest'),
+ );
}
}
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')));
+ $versions_inner[] = array(
+ '#theme' => 'update_version',
+ '#version' => $project['releases'][$also],
+ '#tag' => t('Also available:'),
+ '#class' => array('version-also-available'),
+ );
}
}
if (!empty($versions_inner)) {
- $row .= "\n" . $versions_inner . "
\n";
+ $row['versions'] = $versions_inner;
}
- $row .= "\n";
+
+ $row['extra'] = array();
if (!empty($project['extra'])) {
- $row .= '\n"; // extra div.
}
- $row .= '
';
- sort($project['includes']);
+ // Make sure we start with a clean slate for each project in the report.
+ $row['disabled'] = array();
+ $row['includes'] = array();
if (!empty($project['disabled'])) {
sort($project['disabled']);
- // Make sure we start with a clean slate for each project in the report.
- $includes_items = array();
- $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));
- }
- else {
- $row .= t('Includes: %includes', array('%includes' => implode(', ', $project['includes'])));
+ $row['disabled'] = $project['disabled'];
}
- $row .= "
\n";
+
+ sort($project['includes']);
+ $row['includes'] = $project['includes'];
if (!empty($project['base_themes'])) {
- $row .= '
';
asort($project['base_themes']);
$base_themes = array();
foreach ($project['base_themes'] as $base_key => $base_theme) {
@@ -187,34 +284,34 @@ function theme_update_report($variables) {
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]))));
+ $status_label = array(
+ '#theme' => 'update_status_label',
+ '#status' => $status[$base_key],
+ );
+ $base_themes[] = t('%base_theme (!base_label)', array(
+ '%base_theme' => $base_theme,
+ '!base_label' => drupal_render($status_label),
+ ));
break;
default:
$base_themes[] = drupal_placeholder($base_theme);
}
}
- $row .= t('Depends on: !basethemes', array('!basethemes' => implode(', ', $base_themes)));
- $row .= "
\n";
+ $row['base_themes'] = $base_themes;
}
if (!empty($project['sub_themes'])) {
- $row .= '
';
sort($project['sub_themes']);
- $row .= t('Required by: %subthemes', array('%subthemes' => implode(', ', $project['sub_themes'])));
- $row .= "
\n";
+ $row['sub_themes'] = $project['sub_themes'];
}
- $row .= "
\n"; // info div.
-
+ // Build project rows.
if (!isset($rows[$project['project_type']])) {
$rows[$project['project_type']] = array();
}
- $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($row),
- );
+ $row_key = !empty($project['title']) ? drupal_strtolower($project['title']) : drupal_strtolower($project['name']);
+ $rows[$project['project_type']][$row_key] = $row;
}
$project_types = array(
@@ -224,15 +321,17 @@ function theme_update_report($variables) {
'module-disabled' => t('Disabled modules'),
'theme-disabled' => t('Disabled themes'),
);
+ $variables['project_types'] = array();
foreach ($project_types as $type_name => $type_label) {
if (!empty($rows[$type_name])) {
ksort($rows[$type_name]);
- $output .= "\n" . $type_label . "
\n";
- $output .= theme('table', array('header' => $header, 'rows' => $rows[$type_name], 'attributes' => array('class' => array('update'))));
+ $variables['project_types'][] = array(
+ 'label' => $type_label,
+ 'projects' => $rows[$type_name],
+ );
}
}
drupal_add_css(drupal_get_path('module', 'update') . '/update.css');
- return $output;
}
/**
@@ -243,30 +342,37 @@ function theme_update_report($variables) {
* - status: The integer code for a project's current update status.
*
* @see update_calculate_project_data()
- * @ingroup themeable
*/
-function theme_update_status_label($variables) {
+function template_preprocess_update_status_label(&$variables) {
+ $variables['attributes'] = new Attribute(array('class' => array()));
switch ($variables['status']) {
case UPDATE_NOT_SECURE:
- return '' . t('Security update required!') . '';
-
+ $variables['attributes']['class'] = 'security-error';
+ $variables['text'] = 'Security update required!';
+ break;
case UPDATE_REVOKED:
- return '' . t('Revoked!') . '';
-
+ $variables['attributes']['class'] = 'revoked';
+ $variables['text'] = 'Revoked!';
+ break;
case UPDATE_NOT_SUPPORTED:
- return '' . t('Not supported!') . '';
-
+ $variables['attributes']['class'] = 'not-supported';
+ $variables['text'] = 'Not supported!';
+ break;
case UPDATE_NOT_CURRENT:
- return '' . t('Update available') . '';
-
+ $variables['attributes']['class'] = 'not-current';
+ $variables['text'] = 'Update available';
+ break;
case UPDATE_CURRENT:
- return '' . t('Up to date') . '';
-
+ $variables['attributes']['class'] = 'current';
+ $variables['text'] = 'Up to date';
+ break;
}
}
/**
- * Returns HTML for the version display of a project.
+ * Prepare variables for the version display of a project.
+ *
+ * Default template: update-version.html.twig.
*
* @param array $variables
* An associative array containing:
@@ -276,36 +382,33 @@ function theme_update_status_label($variables) {
* - date: The date of the release.
* - download_link: The URL for the downloadable file.
* - tag: The title of the project.
- * - class: A string containing extra classes for the wrapping table.
- *
- * @ingroup themeable
+ * - class: A array containing extra classes for the wrapping table.
*/
-function theme_update_version($variables) {
+function template_preprocess_update_version(&$variables) {
$version = $variables['version'];
- $tag = $variables['tag'];
- $class = implode(' ', $variables['class']);
-
- $output = '';
- $output .= '';
- $output .= '';
- $output .= '' . $tag . " | \n";
- $output .= '';
- $output .= l($version['version'], $version['release_link']);
- $output .= ' (' . format_date($version['date'], 'custom', 'Y-M-d') . ')';
- $output .= " | \n";
- $output .= '';
+
+ // Remove 'update_version' from the attributes array. This is added through
+ // template_preprocess() but we do not need it.
+ // @todo Remove after http://drupal.org/node/1938430 is resolved.
+ $attributes = array();
+ $attributes['class'] = $variables['class'];
+ $attributes['class'][] = 'version';
+ $variables['attributes'] = new Attribute($attributes);
+
+ $variables['version_link'] = l($version['version'], $version['release_link']);
+ $variables['version_date'] = format_date($version['date'], 'custom', 'Y-M-d');
+
$links = array();
- $links['update-download'] = array(
+ $links['download'] = array(
'title' => t('Download'),
'href' => $version['download_link'],
);
- $links['update-release-notes'] = array(
+ $links['release-notes'] = array(
'title' => t('Release notes'),
'href' => $version['release_link'],
);
- $output .= theme('links__update_version', array('links' => $links));
- $output .= ' | ';
- $output .= '
';
- $output .= "
\n";
- return $output;
+ $variables['version_links'] = array(
+ '#theme' => 'links__update_version',
+ '#links' => $links,
+ );
}