function RulesUIController::overviewTableRow
Generates the row for a single rules config.
Parameters
array $conditions: An array of conditions as needed by rules_config_load_multiple().
array $options: An array with optional options. Known keys are:
- 'hide status op': If set to TRUE, enable/disable links are not added. Defaults to FALSE.
- 'show plugin': If set to FALSE, the plugin is not shown. Defaults to TRUE.
- 'show events': If set to TRUE, the event column is shown. Defaults to TRUE if only reaction rules are listed.
- 'show execution op': If set to TRUE an operation for execution a component is shown for components, as well as a link to schedule a component if the rules scheduler module is enabled.
- 'base path': Optionally, a different base path to use instead of the currently set RulesPluginUI::$basePath. If no base path has been set yet, the current path is used by default.
1 call to RulesUIController::overviewTableRow()
- RulesUIController::overviewTable in ui/
ui.controller.inc - Generates the render array for an overview configuration table.
File
-
ui/
ui.controller.inc, line 273
Class
- RulesUIController
- Controller class for the Rules UI.
Code
protected function overviewTableRow($conditions, $name, $config, $options) {
// Build content includes the label, as well as a short overview including
// the machine name.
$row[] = array(
'data' => $config->buildContent(),
);
// Add events if the configs are assigned to events.
if ($options['show events']) {
$events = array();
if ($config instanceof RulesTriggerableInterface) {
foreach ($config->events() as $event_name) {
$event_handler = rules_get_event_handler($event_name, $config->getEventSettings($event_name));
$events[] = $event_handler->summary();
}
}
$row[] = implode(", ", $events);
}
if ($options['show plugin']) {
$plugin = $config->plugin();
$row[] = isset($this->cache['plugin_info'][$plugin]['label']) ? $this->cache['plugin_info'][$plugin]['label'] : $plugin;
}
$row[] = array(
'data' => array(
'#theme' => 'entity_status',
'#status' => $config->status,
),
);
// Add operations depending on the options and the exportable status.
if (!$config->hasStatus(ENTITY_FIXED)) {
$row[] = l(t('edit'), RulesPluginUI::path($name), array(
'attributes' => array(
'class' => array(
'edit',
'action',
),
),
));
if (module_exists('rules_i18n')) {
$row[] = l(t('translate'), RulesPluginUI::path($name, 'translate'), array(
'attributes' => array(
'class' => array(
'translate',
'action',
),
),
));
}
}
else {
$row[] = '';
if (module_exists('rules_i18n')) {
$row[] = '';
}
}
if (!$options['hide status op']) {
// Add either an enable or disable link.
$text = $config->active ? t('disable') : t('enable');
$active_class = $config->active ? 'disable' : 'enable';
$link_path = RulesPluginUI::path($name, $active_class);
$row[] = $config->hasStatus(ENTITY_FIXED) ? '' : l($text, $link_path, array(
'attributes' => array(
'class' => array(
$active_class,
'action',
),
),
'query' => drupal_get_destination(),
));
}
$row[] = l(t('clone'), RulesPluginUI::path($name, 'clone'), array(
'attributes' => array(
'class' => array(
'clone',
'action',
),
),
));
// Add execute link for for components.
if ($options['show execution op']) {
$row[] = $config instanceof RulesTriggerableInterface ? '' : l(t('execute'), RulesPluginUI::path($name, 'execute'), array(
'attributes' => array(
'class' => array(
'execute',
'action',
),
),
'query' => drupal_get_destination(),
));
if (module_exists('rules_scheduler')) {
// Add schedule link for action components only.
$row[] = $config instanceof RulesActionInterface ? l(t('schedule'), RulesPluginUI::path($name, 'schedule'), array(
'attributes' => array(
'class' => array(
'schedule',
'action',
),
),
'query' => drupal_get_destination(),
)) : '';
}
}
if (!$config->hasStatus(ENTITY_IN_CODE) && !$config->hasStatus(ENTITY_FIXED)) {
$row[] = l(t('delete'), RulesPluginUI::path($name, 'delete'), array(
'attributes' => array(
'class' => array(
'delete',
'action',
),
),
'query' => drupal_get_destination(),
));
}
elseif ($config->hasStatus(ENTITY_OVERRIDDEN) && !$config->hasStatus(ENTITY_FIXED)) {
$row[] = l(t('revert'), RulesPluginUI::path($name, 'revert'), array(
'attributes' => array(
'class' => array(
'revert',
'action',
),
),
'query' => drupal_get_destination(),
));
}
else {
$row[] = '';
}
$row[] = l(t('export'), RulesPluginUI::path($name, 'export'), array(
'attributes' => array(
'class' => array(
'export',
'action',
),
),
));
return $row;
}