diff --git a/css/l10n_update.admin-rtl.css b/css/l10n_update.admin-rtl.css
new file mode 100644
index 0000000..b37baa6
--- /dev/null
+++ b/css/l10n_update.admin-rtl.css
@@ -0,0 +1,25 @@
+/* Expand/collapse image for project title */
+html.js .l10n-update-wrapper .project-legend {
+ padding-right: 10px;
+}
+html.js .l10n-update-wrapper.collapsed .project-legend {
+ background: url("../images/menu-collapsed-rtl.png") right 50% no-repeat;
+}
+
+html.js .l10n-update-wrapper .project-legend a {
+ margin-right: -10px;
+ padding-right: 10px;
+}
+
+/* Translation update status data */
+html.js .l10n-update-wrapper.collapsed .project .version-status {
+ float: left;
+}
+
+.l10n-update .version-status {
+ float: left;
+}
+
+.l10n-update .version-links {
+ float: left;
+}
diff --git a/css/l10n_update.admin.css b/css/l10n_update.admin.css
new file mode 100644
index 0000000..c42dca3
--- /dev/null
+++ b/css/l10n_update.admin.css
@@ -0,0 +1,46 @@
+html.js .l10n-update-wrapper.collapsed .fieldset-wrapper {
+ display: none;
+}
+
+.l10n-update-wrapper .project .version-status {
+ display: none;
+}
+
+/* Expand/collapse image for project title */
+html.js .l10n-update-wrapper .project-title {
+ background: url("../images/menu-expanded.png") left 65% no-repeat;
+ padding-left: 10px;
+}
+
+html.js .l10n-update-wrapper.collapsed .project-title {
+ background: url("../images/menu-collapsed.png") left 50% no-repeat;
+}
+
+html.js .l10n-update-wrapper .project-title a {
+ margin-left: -10px;
+ padding-left: 10px;
+}
+
+/* Translation update status data */
+html.js .l10n-update-wrapper.collapsed .project .version-status {
+ display: inline;
+ float: right;
+}
+
+.l10n-update .project-server {
+ margin: 0 10px;
+ font-size: 90%;
+ font-weight: normal
+}
+
+.l10n-update .version-status {
+ float: right;
+ font-size: 90%;
+ font-weight: normal;
+}
+
+.l10n-update .version-links {
+ float: right;
+ padding-right: 1em;
+
+}
diff --git a/images/menu-collapsed-rtl.png b/images/menu-collapsed-rtl.png
new file mode 100644
index 0000000..dc8d0b8
Binary files /dev/null and b/images/menu-collapsed-rtl.png differ
diff --git a/images/menu-collapsed.png b/images/menu-collapsed.png
new file mode 100644
index 0000000..91f3fd4
Binary files /dev/null and b/images/menu-collapsed.png differ
diff --git a/images/menu-expanded.png b/images/menu-expanded.png
new file mode 100644
index 0000000..46f39ec
Binary files /dev/null and b/images/menu-expanded.png differ
diff --git a/js/l10n_update.js b/js/l10n_update.js
new file mode 100644
index 0000000..b557f6e
--- /dev/null
+++ b/js/l10n_update.js
@@ -0,0 +1,22 @@
+(function ($) {
+
+Drupal.behaviors.l10nUpdateCollapse = {
+ attach: function (context, settings) {
+ $('.l10n-update .l10n-update-wrapper', context).once('l10nupdatecollapse', function () {
+ var wrapper = $(this);
+
+ // Turn the project title into a clickable link.
+ // Add an event to toggle the content visibiltiy.
+ var $legend = $('.project-title', this);
+ var $link = $('')
+ .prepend($legend.contents())
+ .appendTo($legend)
+ .click(function () {
+ Drupal.toggleFieldset(wrapper);
+ return false;
+ });
+ });
+ }
+};
+
+})(jQuery);
diff --git a/l10n_update.admin.inc b/l10n_update.admin.inc
index 5c84131..582f7dc 100644
--- a/l10n_update.admin.inc
+++ b/l10n_update.admin.inc
@@ -42,18 +42,27 @@ function l10n_update_admin_overview() {
// For now we get package information provided by modules.
$projects = l10n_update_get_projects();
$languages = l10n_update_language_list('name');
- $output = array();
+
+ $build = array();
if ($projects && $languages) {
$history = l10n_update_get_history();
$available = l10n_update_available_releases();
$updates = l10n_update_build_updates($history, $available);
- $output[] = array('#markup' => theme('l10n_update_project_status', array('projects' => $projects, 'languages' => $languages, 'history' => $history, 'available' => $available, 'updates' => $updates)));
- $output[] = drupal_get_form('l10n_update_admin_import_form', $projects, $updates);
+ $build['project_status'] = array(
+ '#theme' => 'l10n_update_project_status',
+ '#projects' => $projects,
+ '#languages' => $languages,
+ '#history' => $history,
+ '#available' => $available,
+ '#updates' => $updates,
+ );
+ $build['admin_import_form'] = drupal_get_form('l10n_update_admin_import_form', $projects, $updates);
}
else {
- $output[] = array('#markup' => t('No projects or languages to update.'));
+ $build['no_projects'] = array('#markup' => t('No projects or languages to update.'));
}
- return $output;
+
+ return $build;
}
/**
@@ -241,118 +250,243 @@ function _l10n_update_admin_check_options() {
/**
* Format project update status.
*
- * @params array $projects
- * Projects listed.
- * @params array $languages
- * Languages listed.
- * @params array $history
- * Project translation history.
- * @params array $available
- * Available translation releases.
- * @params array $updates
- * Applicable translation updates.
+ * @param $variables
+ * An associative array containing:
+ * - projects: An array containing all enabled projects.
+ * - languages: An array of all enabled languages.
+ * - history: An array of the current translations per project.
+ * - available: An array of translation sources per project.
+ * - updates: An array of available translation updates per project.
+ * Only recommended translations are listed.
*
* @return string
* HTML output.
*/
-function theme_l10n_update_project_status($vars) {
-
- // We use the core update module CSS
- drupal_add_css(drupal_get_path('module', 'update') . '/update.css');
- $output = '';
- //$header = array(t('Project'), t('Current version'), t('Available update'), '');
+function theme_l10n_update_project_status($variables) {
$header = $rows = array();
- foreach ($vars['projects'] as $name => $project) {
- $row = '
';
- if (empty($vars['available'][$name])) {
+ // Get module and theme data for the project title.
+ $projects = system_rebuild_module_data();
+ $projects += system_rebuild_theme_data();
+
+ foreach ($variables['projects'] as $name => $project) {
+ if (empty($variables['available'][$name])) {
// Remote information not checked
- $class = 'unknown';
- $status = 'unknown';
+ $project_class = 'unknown';
+ $project_status = 'unknown';
}
- elseif (empty($vars['updates'][$name])) {
+ elseif (empty($variables['updates'][$name])) {
// No updates available
- $class = 'ok';
- $status = 'ok';
+ $project_class = 'ok';
+ $project_status = 'ok';
}
else {
// Update available
- $status = 'update';
- $class = 'messages warning';
+ $project_status = 'update';
+ // @todo: changes class(es) and add custom css.
+ $project_class = 'warning';
}
- $row = theme('l10n_update_version_status', array('status' => $status));
+ // Get the project title.
+ $project->title = isset($projects[$name]->info['name']) ? $projects[$name]->info['name'] : '';
- $row .= "
";
- $title = isset($project->title) ? $project->title : $project->name;
- $row .= check_plain($title);
- $row .= ' ' . check_plain($project->version);
- if ($server = l10n_update_server($project->l10n_server)) {
- $row .= ' ' . l($server['name'], $server['link']);
- }
- $row .= "
\n";
-
- $row .= "
\n";
- $versions = array();
- foreach ($vars['languages'] as $lang => $language) {
- $current = isset($vars['history'][$name][$lang]) ? $vars['history'][$name][$lang] : NULL;
- $update = isset($vars['updates'][$name][$lang]) ? $vars['updates'][$name][$lang] : NULL;
- if ($update) {
- $status = 'update';
- $class = 'messages warning';
- }
- elseif ($current) {
- $status = $class = 'ok';
- }
- else {
- $status = $class = 'unknown';
- }
- $version = array(
+ // Project with related language states.
+ $row = theme('l10n_update_single_project_wrapper', array(
+ 'project' => $project,
+ 'project_status' => $project_status,
+ 'languages' => $variables['languages'],
+ 'history' => $variables['history'],
+ 'updates' => $variables['updates'],
+ ));
+
+ $rows[$project->project_type][] = array(
+ 'data' => array(
array(
- 'data' => $language,
- 'class' => 'version-title',
+ 'data' => $row,
+ 'class' => 'l10n-update-wrapper collapsed',
),
- $current ? theme('l10n_update_release', array('release' => $current)) : '',
- $update ? theme('l10n_update_release', array('release' => $update)) : '',
- theme('l10n_update_version_status', array('status' => $status, 'type' => $update ? $update->type : NULL)),
- );
- $versions[] = array(
- 'data' => $version,
- 'class' => array($class),
- );
+ ),
+ 'class' => array($project_class),
+ );
+ }
+
+ // Build tables of update states grouped by project type. Similar to the
+ // status report by the Update module.
+ $output = '';
+ $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
" . $type_label . "
\n";
+ $output .= theme('table', array('header' => $header, 'rows' => $rows[$type_name], 'attributes' => array('class' => array('update l10n-update'))));
+ }
+ }
+
+ // We use the core update module CSS to re-use the color definitions.
+ // Plus add our own css and js.
+ drupal_add_css(drupal_get_path('module', 'update') . '/update.css');
+ drupal_add_css(drupal_get_path('module', 'l10n_update') . '/css/l10n_update.admin.css');
+ drupal_add_js(drupal_get_path('module', 'l10n_update') . '/js/l10n_update.js');
+
+ return $output;
+}
+
+/**
+ * Format project translation state with states per language.
+ *
+ * @param $variables
+ * An associative array containing:
+ * - project: Project data object
+ * - project_status: Project status
+ * - languages: Available languages.
+ * @return string
+ * HTML output.
+ */
+function theme_l10n_update_single_project_wrapper($variables) {
+ $project = $variables['project'];
+ $name = $project->name;
+ $project_status = $variables['project_status'];
+ $languages = $variables['languages'];
+ $history = $variables['history'];
+ $updates = $variables['updates'];
+
+ // Output project title and project summary status.
+ $output = theme('l10n_update_single_project_status', array(
+ 'project' => $project,
+ 'server' => l10n_update_server($project->l10n_server),
+ 'status' => $project_status,
+ ));
+
+ // Translation status per language is displayed in a table, one language per row.
+ // For each language the current translation is listed. And optionally the
+ // most recent update.
+ $rows = array();
+ foreach ($languages as $lang => $language) {
+ // Determine current translation status and update status.
+ $current = isset($history[$name][$lang]) ? $history[$name][$lang] : NULL;
+ $update = isset($updates[$name][$lang]) ? $updates[$name][$lang] : NULL;
+ if ($update) {
+ $status = 'update';
+ $class = 'messages warning';
+ }
+ elseif ($current) {
+ $status = 'ok';
+ $class = 'ok';
+ }
+ else {
+ $status = 'unknown';
+ $class = 'unknown';
+ }
+
+ // The current translation version.
+ $row = theme('l10n_update_current_release', array('language' => $language, 'release' => $current, 'status' => $status));
+
+ // If an update is available, add it.
+ if ($update) {
+ $row .= theme('l10n_update_available_release', array('release' => $update));
}
- $row .= theme('table', array('header' => array(), 'rows' => $versions));
- $row .= "\n";
- $rows[] = array($row);
+
+ $rows[] = array(
+ 'data' => array($row),
+ 'class' => array($class),
+ );
+ }
+
+ // Output tables with translation status per language.
+ $output .= '
' . "\n";
+ $output .= theme('table', array('header' => array(), 'rows' => $rows));
+ $output .= "
\n";
+
+ return $output;
+}
+
+/**
+ * Format a single project translation state.
+ *
+ * @param $variables
+ * An associative array containing:
+ * - project: project data object.
+ * - server: (optional) remote server data object.
+ * - status: project summary status.
+ * @return string
+ * HTML output.
+ */
+function theme_l10n_update_single_project_status($variables) {
+ $project = $variables['project'];
+ $server = $variables['server'];
+ $title = $project->title ? $project->title : $project->name;
+
+ $output = '
';
+ $output .= '' . check_plain($title) . '' . ' ' . check_plain($project->version) ;
+ if ($server = l10n_update_server($project->l10n_server)) {
+ $output .= '' . t('(translation source: !server)', array('!server' => l($server['name'], $server['link']))) . '';
}
- $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('class' => array('update'))));
+ $output .= theme('l10n_update_version_status', array('status' => $variables['status']));
+ $output .= "
\n";
+
return $output;
}
/**
- * Format tag and release date.
+ * Format current translation version.
+ *
+ * @param $variables
+ * An associative array containing:
+ * - language: Language name.
+ * - release: Current file data.
+ * - status: Release status.
+ * @return string
+ * HTML output.
+ */
+function theme_l10n_update_current_release($variables) {
+ if (isset($variables['release'])) {
+ $date = $variables['release']->timestamp;
+ $version = $variables['release']->version;
+ $text = t('@language: @version (!date)', array('@language' => $variables['language'], '@version' => $version, '!date' => format_date($date, 'custom', 'Y-M-d')));
+ }
+ else {
+ $text = t('@language:
Unknown translation version', array('@language' => $variables['language']));
+ }
+
+ $output = '
';
+ $output .= $text;
+ $output .= theme('l10n_update_version_status', $variables);
+ $output .= "
\n";
+
+ return $output;
+}
+
+/**
+ * Format current translation version.
*
* @param object $release
- * Source file data.
+ * Update file data.
* @return string
* HTML output.
*/
-function theme_l10n_update_release($vars) {
- $name = $vars['release']->filename;
- $date = $vars['release']->timestamp;
- if (!empty($vars['release']->fileurl)) {
+function theme_l10n_update_available_release($variables) {
+ $date = $variables['release']->timestamp;
+ $version = $variables['release']->version;
+ if (!empty($variables['release']->fileurl)) {
// Remote file, straight link
- $link = l($name, $vars['release']->fileurl);
+ $link = l(t('Download'), $variables['release']->fileurl);
}
- elseif (!empty($vars['release']->uri)) {
+ elseif (!empty($variables['release']->uri)) {
// Local file, try something
- $link = l($name, $vars['release']->uri, array('absolute' => TRUE));
+ $link = l(t('Download'), $variables['release']->uri, array('absolute' => TRUE));
}
- else {
- // No link
- $link = "
$name";
- }
- return $link . '
' . format_date($date, 'short') . '';
+
+ $output = '
';
+ $output .= t('Recommended version: @version (!date)', array('@version' => $version, '!date' => format_date($date, 'custom', 'Y-M-d')));
+ $output .= '' . $link . '';
+ $output .= "
\n";
+ return $output;
}
/**
@@ -366,25 +500,28 @@ function theme_l10n_update_release($vars) {
* @return sting
* HTML output.
*/
-function theme_l10n_update_version_status($vars) {
- $output = '
';
- switch ($vars['status']) {
+function theme_l10n_update_version_status($variables) {
+ $icon = '';
+ $msg = '';
+
+ switch ($variables['status']) {
case 'ok':
$icon = theme('image', array('path' => 'misc/watchdog-ok.png', 'alt' => t('ok'), 'title' => t('ok')));
$msg = '
' . t('Up to date') . '';
break;
case 'update':
$icon = theme('image', array('path' => 'misc/watchdog-warning.png', 'alt' => t('warning'), 'title' => t('warning')));
- $txt = (isset($vars['type']) && ($vars['type'] == 'download')) ? t('Remote update available') : t('Local update available');
+ $txt = t('Update available');
$msg = '
' . $txt . '';
break;
case 'unknown':
$icon = theme('image', array('path' => 'misc/watchdog-warning.png', 'alt' => t('warning'), 'title' => t('warning')));
- $msg = '
' . t('No information') . '';
+ $msg = '
' . t('No available translations found') . '';
break;
}
+ $output = '
';
$output .= $msg;
$output .= '' . $icon . '';
- $output .= "
";
+ $output .= "
\n";
return $output;
}
diff --git a/l10n_update.module b/l10n_update.module
index e72673c..cf8a983 100644
--- a/l10n_update.module
+++ b/l10n_update.module
@@ -429,7 +429,19 @@ function l10n_update_theme() {
'variables' => array('projects' => NULL, 'languages' => NULL, 'history' => NULL, 'available' => NULL, 'updates' => NULL),
'file' => 'l10n_update.admin.inc',
),
- 'l10n_update_release' => array(
+ 'l10n_update_single_project_wrapper' => array(
+ 'project' => array('project' => NULL, 'project_status' => NULL, 'languages' => NULL, 'history' => NULL, 'updates' => NULL),
+ 'file' => 'l10n_update.admin.inc',
+ ),
+ 'l10n_update_single_project_status' => array(
+ 'variables' => array('project' => NULL, 'server' => NULL, 'status' => NULL),
+ 'file' => 'l10n_update.admin.inc',
+ ),
+ 'l10n_update_current_release' => array(
+ 'variables' => array('language' => NULL, 'release' => NULL, 'status' => NULL),
+ 'file' => 'l10n_update.admin.inc',
+ ),
+ 'l10n_update_available_release' => array(
'variables' => array('release' => NULL),
'file' => 'l10n_update.admin.inc',
),