You are here

function patterns_modules_page in Patterns 6

Same name and namespace in other branches
  1. 5 patterns.module \patterns_modules_page()
  2. 6.2 patterns.module \patterns_modules_page()
  3. 7.2 theme/modules.inc \patterns_modules_page()
  4. 7 theme/modules.inc \patterns_modules_page()

List the modules used by a particular pattern

1 string reference to 'patterns_modules_page'
patterns_menu in ./patterns.module
Implementation of hook_menu().

File

./patterns.module, line 865
Enables extremely simple adding/removing features to your site with minimal to no configuration

Code

function patterns_modules_page($pid) {
  $pattern = patterns_get_pattern($pid);
  drupal_set_title($pattern->title . ' ' . t('(Pattern Modules)'));
  $modules = isset($pattern->pattern['modules']) ? $pattern->pattern['modules'] : array();
  $modules_info = module_rebuild_cache();
  $modules_list = module_list();

  // Get module name, whether its to be disabled or enabled,
  // whether the module is available or not, and whether it is
  // currently enabled or not
  foreach ($modules as $module) {
    $row = array();
    $delete = is_array($module) ? $module['delete'] : false;
    $module = is_array($module) ? $module['value'] : $module;
    $available = array_key_exists($module, $modules_info);
    $enabled = array_key_exists($module, $modules_list);
    $row[] = $module;
    $row[] = $available ? t('Yes') : '<span class="alert">' . t('No') . '</span>';
    $row[] = $enabled ? t('Yes') : '<span class="alert">' . t('No') . '</span>';
    $row[] = $delete ? t('Delete') : t('Enable');
    $rows[] = $row;
    if (!$available) {
      $not_available = true;
    }
  }
  if ($not_available) {
    drupal_set_message(t('Some modules are not availalble, please download them before running this pattern.'), 'error');
  }
  else {
    drupal_set_message(t('All modules required by this module are available. Click !here to run this pattern.', array(
      '!here' => l(t('here'), 'admin/build/patterns/enable/' . $pid),
    )));
  }
  return theme('table', array(
    t('Name'),
    t('Available'),
    t('Enabled'),
    t('Pattern Action'),
  ), $rows, t('Modules used for this pattern'));
}