You are here

function rules_admin_components_overview in Rules 7.2

Components overview.

2 string references to 'rules_admin_components_overview'
rules_admin_form_alter in rules_admin/rules_admin.module
Implements hook_form_alter().
rules_admin_menu in rules_admin/rules_admin.module
Implements hook_menu().

File

rules_admin/rules_admin.inc, line 84
Implements rule management and configuration screens.

Code

function rules_admin_components_overview($form, &$form_state, $base_path) {
  RulesPluginUI::formDefaults($form, $form_state);
  $collapsed = TRUE;
  if (empty($_GET['tag'])) {
    $tag = 0;
  }
  else {
    $tag = $_GET['tag'];
    $conditions['tags'] = array(
      $tag,
    );
    $collapsed = FALSE;
  }
  if (empty($_GET['plugin'])) {

    // Get the plugin name usable as component.
    $conditions['plugin'] = array_keys(rules_filter_array(rules_fetch_data('plugin_info'), 'component', TRUE));
    $plugin = 0;
  }
  else {
    $plugin = $_GET['plugin'];
    $conditions['plugin'] = $plugin;
    $collapsed = FALSE;
  }
  $form['help'] = array(
    '#markup' => t('Components are stand-alone sets of Rules configuration that can be used by Rules and other modules on your site. Components are for example useful if you want to use the same conditions, actions or rules in multiple places, or call them from your custom module. You may also export each component separately. See <a href="@url">the online documentation</a> for more information about how to use components.', array(
      '@url' => rules_external_help('components'),
    )),
  );
  $form['filter'] = array(
    '#type' => 'fieldset',
    '#title' => t('Filter'),
    '#collapsible' => TRUE,
  );
  $form['filter']['#id'] = 'rules-filter-form';
  $form['filter']['#attached']['css'][] = drupal_get_path('module', 'rules') . '/ui/rules.ui.css';
  $form['filter']['plugin'] = array(
    '#type' => 'select',
    '#title' => t('Filter by plugin'),
    '#options' => array(
      0 => t('<All>'),
    ) + rules_admin_component_options(),
    '#default_value' => $plugin,
  );
  $form['filter']['tag'] = array(
    '#type' => 'select',
    '#title' => t('Filter by tag'),
    '#options' => array(
      0 => '<All>',
    ) + RulesPluginUI::getTags(),
    '#default_value' => $tag,
  );
  $form['filter']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Filter'),
    '#name' => '',
  );
  $form['table'] = RulesPluginUI::overviewTable($conditions, array(
    'hide status op' => TRUE,
  ));
  $form['table']['#empty'] = t('There are no rule components.');
  $form['filter']['#collapsed'] = $collapsed;
  $form['#submit'][] = 'rules_form_submit_rebuild';
  $form['#method'] = 'get';
  return $form;
}