1 installer.theme.inc | template_preprocess_installer_browser_project(&$variables) |
Add some variables for the project theme.
Parameters
$variables: An associative array containing:
- project : associative array of project variables.
File
- core/
modules/ installer/ installer.theme.inc, line 148 - Project Installer theme pages.
Code
function template_preprocess_installer_browser_project(&$variables) {
module_load_include('inc', 'installer', 'installer.browser');
$project = $variables['project'];
$dialog_attributes = array(
'class' => array('use-ajax'),
'id' => 'title-ajax',
'data-dialog' => 'true',
'data-dialog-options' => json_encode(array('width' => 700, 'dialogClass' => 'project-dialog')),
);
// If the project has an image, render it.
$variables['image'] = FALSE;
if ($project['type'] == 'theme') {
if (!empty($project['image'])) {
$image = theme('image', array(
'path' => $project['image'],
'alt' => $project['title'],
));
}
else {
// Add an element with a solid color a la google contacts.
$letter = mb_substr($project['title'], 0, 1);
$image = '<div class="placeholder">' . $letter . '</div>';
}
$variables['image'] = l($image,
'admin/installer/project/' . $project['name'],
array('attributes' => $dialog_attributes, 'html' => TRUE));
}
$variables['title'] = l(
$project['title'],
'admin/installer/project/' . $project['name'],
array('attributes' => $dialog_attributes));
$variables['description'] = theme('installer_browser_project_description', array('project' => $project));
$variables['last_updated'] = ($project['last updated']) ? t('Last Updated: @date', array('@date' => format_date($project['last updated'], 'long'))) : '';
$extras = array();
if ($project['maintenance status']) {
$extras[] = check_plain($project['maintenance status']);
}
if ($project['development status']) {
// We are not showing this because it isn't a good indicator right now.
// $extras[] = check_plain($project['development status']);
}
if ($project['usage'] && is_numeric($project['usage'])) {
$extras[] = format_plural($project['usage'], '1 Installation', '@count Installations');
}
if ($project['rating']) {
$extras[] = check_plain($project['rating']);
}
$variables['extras'] = implode(' | ', $extras);
// Check if the project is installed.
$found = backdrop_get_filename($project['type'], $project['name']);
if (_installer_browser_is_project_enabled($project['type'], $project['name'])) {
$variables['status'] = '<div class="install-disabled">Already enabled</div>';
$variables['install'] = '';
}
elseif ($found) {
$variables['status'] = '<div class="install-disabled">Already downloaded</div>';
$variables['install'] = '';
}
else {
$variables['status'] = '';
$variables['install'] = installer_browser_add_remove_queue_link($project['name']);
}
}