You are here

function apps_preprocess_apps_app_page in Apps 7

Implements hook_preprocess_apps_app_page().

File

theme/apps.theme.inc, line 114
Provides theme functions for apps module.

Code

function apps_preprocess_apps_app_page(&$vars) {

  // First do everything we do in the teaser.
  drupal_add_css(drupal_get_path('module', 'apps') . '/theme/css/apps.css');
  apps_preprocess_apps_app_teaser($vars);

  // We need some special stuff for the logo here.
  if (!empty($vars['app']['logo']) && $vars['app']['logo']) {
    $vars['app']['logo']['style_name'] = 'apps_logo_small';
    $vars['logo'] = theme('image_style', $vars['app']['logo']);
  }
  if (isset($vars['app']['screenshots'])) {
    $vars['screenshot'] = '';
    foreach ($vars['app']['screenshots'] as $screenshot) {
      $screenshot['style_name'] = 'apps_screenshot';
      $vars['screenshot'] .= l(theme('image_style', $screenshot), file_create_url($screenshot['uri']), array(
        'html' => TRUE,
        'attributes' => array(
          'class' => 'colorbox',
        ),
      ));
    }
  }
  else {
    $vars['screenshot'] = FALSE;
  }
  $vars['description'] = $vars['app']['description'];
  $vars['name'] = $vars['app']['name'];
  $vars['author'] = l($vars['app']['author'], $vars['app']['author_url']);
  $vars['version'] = $vars['app']['version'];
  if ($vars['app']['installed_version'] && $vars['app']['version'] != $vars['app']['installed_version']) {
    $vars['version'] .= ' <span class="apps-update-needed">' . t('Installed: @installed_version', array(
      '@installed_version' => $vars['app']['installed_version'],
    )) . '</span>';
  }
  $conflicts_enabled = array();
  if ($conflicts = apps_app_find_conflicts($vars['app'])) {
    $vars['conflicts_title'] = t('Conflicts');
    $conflicts = array();
    foreach (apps_app_find_conflicts($vars['app']) as $conflict) {
      if ($conflict_app = apps_app_load($conflict['server'], $conflict['name'])) {
        $enabled = $conflict_app['status'] == APPS_ENABLED;
        $conflicts[] = l($conflict_app['name'] . ($enabled ? ' (enabled)' : ''), 'admin/apps/' . $conflict['server'] . '/' . $conflict['name']);
        if ($enabled) {
          $conflicts_enabled[] = $conflict_app['name'];
        }
      }
    }
    if ($conflicts) {
      $vars['conflicts'] = implode(', ', $conflicts);
    }
  }
  if ($vars['app']['status'] === APPS_INCOMPATIBLE) {
    $incompatible_deps = array();
    $incompatible_message = '';
    foreach ($vars['app']['dependencies'] as $dep) {
      if ($dep['status'] === APPS_INCOMPATIBLE) {
        $incompatible_deps[] = "{$dep['version']['name']} {$dep['version']['original_version']}";
      }
    }
    if (!empty($incompatible_deps)) {
      $incompatible_message = t("Incompatible - requires @deps.", array(
        '@deps' => implode(", ", $incompatible_deps),
      ));
    }
    else {

      //this should never run
      $incompatible_message = t('Incompatible with current install.');
    }
    if ($conflicts_enabled) {
      $incompatible_message = ($incompatible_message ? $incompatible_message . ' ' : '') . t('Conflicts with enabled @apps', array(
        '@apps' => implode(", ", $conflicts_enabled),
      ));
    }
    $vars['status'] = $incompatible_message;
    $vars['status_title'] = t('Status');
  }

  //Title texts for App Detail Page
  $vars['author_title'] = t('Author');
  $vars['version_title'] = t('Version');
  $vars['description_title'] = t('Description');
  $vars['app']['teaser'] = FALSE;
  if (variable_get('apps_allow_voting', FALSE)) {
    $vars['rating_title'] = t('Customer Rating');

    //Override the rating key with the full widget
    $vars['rating_caption'] = t('Average rating for this version:');
    $vars['rating'] = theme('apps_voting_widget', $vars['app']);
  }
  $vars['parent_apps'] = array();
  $vars['parent_apps_title'] = t('Depends on');
  if (!empty($vars['app']['parent_apps'])) {
    $apps = apps_apps($vars['app']['server']);
    foreach ($vars['app']['parent_apps'] as $parent_app) {
      if (!empty($apps[$parent_app])) {
        $vars['parent_apps'][] = l($apps[$parent_app]['name'], apps_app_page_path($apps[$parent_app]));
      }
    }
  }
}