function _patterns_pattern_build_row in Patterns 7
Same name and namespace in other branches
- 7.2 theme/theme.inc \_patterns_pattern_build_row()
Build a table row for the tables in the pattern list page.
Parameters
mixed $pid the numeric id of the pattern as in the database:
StdClass $pattern A pattern object as loaded from database:
array $extra associative array of extra parameters. Not used now.:
3 calls to _patterns_pattern_build_row()
- patterns_list_patterns_2 in theme/common.inc 
- theme_patterns_category_table in theme/theme.inc 
- theme_patterns_list in theme/theme.inc 
- Theme a list of patterns into separated fieldset ordered by category
File
- theme/theme.inc, line 252 
Code
function _patterns_pattern_build_row($pid, $pattern, $options = array()) {
  // Add in the defaults.
  $extra = array(
    'requires' => array(),
    'required_by' => array(),
    'disabled' => FALSE,
    'enabled' => FALSE,
    'links' => array(),
  );
  $form = array(
    '#tree' => TRUE,
  );
  // Set the basic properties.
  // Creating overlay div with extra info
  $title = '<span id="pid-' . $pid . '" class="pattern-title">' . $pattern->title . '</span>';
  $info = array();
  $info[] = t('Author:') . ' ' . @$pattern->info['author'];
  $info[] = t('Email:') . ' ' . @$pattern->info['author_email'];
  $info[] = t('Web:') . ' ' . @$pattern->info['author_website'];
  $author = theme('item_list', array(
    'items' => $info,
  ));
  $title .= '<div id="pid-' . $pid . '-info" class="pattern-info">' . $author . '</div>';
  $form['format'] = array(
    '#markup' => $pattern->format,
  );
  $form['name'] = array(
    '#markup' => $pattern->name,
  );
  $form['title'] = array(
    '#markup' => $title,
  );
  $form['description'] = array(
    '#markup' => $pattern->description,
  );
  $form['version'] = array(
    '#markup' => @$pattern->info['version'],
  );
  #$form['#requires'] = $extra['requires'];
  #$form['#required_by'] = $extra['required_by'];
  // Check the compatibilities.
  $compatible = TRUE;
  $status_short = '';
  $status_long = '';
  //@TODO: do some checking about pattern compatibility
  $compatible = TRUE;
  // If this module is compatible, present a checkbox indicating
  // this module may be installed. Otherwise, show a big red X.
  if ($compatible) {
    $form['enable'] = array(
      //      '#type' => 'checkbox',
      //      '#title' => t('Enable'),
      //      '#value' => $pattern->status,
      //      //'#attributes' =>  array('checked' => $pattern->status),
      //    );
      //    if ($extra['disabled']) {
      //      $form['enable']['#disabled'] = TRUE;
      //    }
      '#markup' => $pattern->status ? t('Enabled') : t('Disabled'),
    );
  }
  else {
    $form['enable'] = array(
      '#markup' => theme('image', array(
        'path' => 'misc/watchdog-error.png',
        'alt' => $status_short,
        'title' => $status_short,
      )),
    );
    $form['description']['#markup'] .= theme('system_modules_incompatible', array(
      'message' => $status_long,
    ));
  }
  $actions = patterns_get_patterns_links($pattern);
  $form['links'] = $actions;
  return $form;
}