You are here

function patterns_list in Patterns 7

Same name and namespace in other branches
  1. 5 patterns.module \patterns_list()
  2. 6.2 patterns.module \patterns_list()
  3. 6 patterns.module \patterns_list()
  4. 7.2 patterns.module \patterns_list()

First function to be called for displaying the pattern list page.

1 string reference to 'patterns_list'
patterns_menu in ./patterns.module
Implements hook_menu().

File

./patterns.module, line 391

Code

function patterns_list() {
  $form = array();
  if (!patterns_parser_ready()) {
    $messages = t('No available patterns parser was found.</br>');
    $messages .= t(' Go to the !modules page to enable more Patterns parsers.', array(
      '!modules' => l(t('modules'), 'admin/modules'),
    ));
    drupal_set_message($messages, 'warning');
  }
  drupal_add_js('misc/ajax.js');
  drupal_add_css(drupal_get_path('module', 'patterns') . '/css/patterns.css');
  drupal_add_js(drupal_get_path('module', 'patterns') . '/js/patterns.js');
  $form['commands'] = array(
    '#type' => 'fieldset',
    '#title' => 'Commands',
  );
  $form['commands']['refresh'] = array(
    '#type' => 'button',
    '#value' => t('Refresh All'),
    '#attributes' => array(
      'style' => 'float:right',
      'id' => 'refresh-all',
    ),
  );
  $form['commands']['create'] = array(
    '#type' => 'button',
    '#value' => t('Create New'),
    '#attributes' => array(
      'style' => 'float:right',
    ),
    '#prefix' => '<a href="' . url('admin/patterns/import') . '">',
    '#suffix' => '</a>',
  );
  $form['commands']['quickrun'] = array(
    '#type' => 'button',
    '#value' => t('Quick Run'),
    '#attributes' => array(
      'style' => 'float:right',
    ),
    '#prefix' => '<a href="' . url('admin/patterns/quickrun') . '">',
    '#suffix' => '</a>',
  );
  $output = drupal_render($form);

  // Load the the pattern handlers from compontents directory
  // or from modules which implement hook_patterns().
  if (variable_get('patterns_refresh_components', TRUE)) {
    patterns_io_load_components();
  }

  // Load the patterns from database.
  $patterns = patterns_io_get_patterns(variable_get('patterns_refresh_from_fs', TRUE));
  $output .= theme('patterns_list', $patterns);
  return $output;
}