class RulesRuleUI in Rules 7.2
Rule specific UI.
Hierarchy
- class \RulesPluginUI extends \FacesExtender implements RulesPluginUIInterface
- class \RulesContainerPluginUI
- class \RulesActionContainerUI
- class \RulesRuleUI
- class \RulesActionContainerUI
- class \RulesContainerPluginUI
Expanded class hierarchy of RulesRuleUI
2 string references to 'RulesRuleUI'
- hook_rules_plugin_info in ./
rules.api.php - Defines rules plugins.
- rules_rules_plugin_info in ./
rules.module - Implements hook_rules_plugin_info().
File
- ui/
ui.plugins.inc, line 11 - Contains UI for diverse plugins provided by Rules.
View source
class RulesRuleUI extends RulesActionContainerUI {
protected $rule;
protected $conditions;
/**
* Constructs a RulesRuleUI object.
*
* @param FacesExtendable $object
*/
public function __construct(FacesExtendable $object) {
parent::__construct($object);
$this->rule = $object;
$this->conditions = $this->rule
->conditionContainer();
}
public function form(&$form, &$form_state, $options = array(), $iterator = NULL) {
$form_state['rules_element'] = $this->rule;
$label = $this->element
->label();
// Automatically add a counter to unlabelled rules.
if ($label == t('unlabeled') && !$this->element
->isRoot() && !empty($options['init'])) {
$parent = $this->element
->parentElement();
$label .= ' ' . count($parent
->getIterator());
}
// Components have already a label. If used inside a rule-set add a label
// though. It's called 'Name' in the UI though.
if (!$this->element
->isRoot()) {
$form['label'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => empty($options['init']) ? $label : '',
'#required' => TRUE,
'#weight' => 5,
'#description' => t('A human-readable name shortly describing the rule.'),
);
}
$form += array(
'conditions' => array(
'#weight' => -5,
'#tree' => TRUE,
),
);
$this->conditions
->form($form['conditions'], $form_state);
unset($form['conditions']['negate']);
// Add actions form.
$iterator = new RecursiveIteratorIterator($this->rule
->actions(), RecursiveIteratorIterator::SELF_FIRST);
parent::form($form, $form_state, $options, $iterator);
// Hide nested elements during creation.
$form['elements']['#access'] = empty($options['init']);
$form['conditions']['elements']['#access'] = empty($options['init']);
$form_state['redirect'] = RulesPluginUI::path($this->element
->root()->name, 'edit', $this->element);
if (!empty($options['button'])) {
$form['submit']['#value'] = t('Save changes');
}
}
/**
* Applies the values of the form to the rule configuration.
*/
public function form_extract_values($form, &$form_state) {
$form_values = RulesPluginUI::getFormStateValues($form, $form_state);
// Run condition and action container value extraction.
if (isset($form['conditions'])) {
$this->conditions
->extender('RulesConditionContainerUI')
->form_extract_values($form['conditions'], $form_state);
}
if (!empty($form_values['label'])) {
$this->element->label = $form_values['label'];
}
parent::form_extract_values($form, $form_state);
}
public function operations() {
// When rules are listed only show the edit and delete operations.
$ops = parent::operations();
$ops['#links'] = array_intersect_key($ops['#links'], array_flip(array(
'edit',
'delete',
)));
return $ops;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RulesContainerPluginUI:: |
public | function | Gets the Add-* operations for the given element. | |
RulesContainerPluginUI:: |
public | function |
Implements RulesPluginUIInterface. Overrides RulesPluginUI:: |
1 |
RulesPluginUI:: |
public static | property | The base path determines where a Rules overview UI lives. | |
RulesPluginUI:: |
protected | property | ||
RulesPluginUI:: |
public static | function | Determines the default redirect target for an edited/deleted element. | |
RulesPluginUI:: |
public static | function | ||
RulesPluginUI:: |
public | function |
Implements RulesPluginUIInterface. Overrides RulesPluginUIInterface:: |
|
RulesPluginUI:: |
public | function |
Implements RulesPluginUIInterface. Overrides RulesPluginUIInterface:: |
2 |
RulesPluginUI:: |
public | function | Returns the name of class for the given data type. | |
RulesPluginUI:: |
public static | function | Returns the state values for $form, possibly only a part of the whole form. | |
RulesPluginUI:: |
public static | function | ||
RulesPluginUI:: |
protected | function | Actually generates the parameter form for the given data type. | |
RulesPluginUI:: |
public static | function | ||
RulesPluginUI:: |
public | function | Returns the form for configuring the info of a single variable. | |
RulesPluginUI:: |
public | function |
Implements RulesPluginUIInterface. Overrides RulesPluginUIInterface:: |
|
RulesPluginUI:: |
public static | function | Deprecated by the controllers overviewTable() method. | |
RulesPluginUI:: |
public static | function | Generates an operation path. | |
RulesPluginUI:: |
public | function | Adds the configuration settings form (label, tags, description, ...). | 1 |
RulesPluginUI:: |
public | function | 1 | |
RulesPluginUI:: |
protected | function | Provides a matrix permission for the component based in the existing roles. | |
RulesPluginUI:: |
public | function | ||
RulesPluginUI:: |
public | function | ||
RulesRuleUI:: |
protected | property | ||
RulesRuleUI:: |
protected | property | ||
RulesRuleUI:: |
public | function |
Implements RulesPluginUIInterface::form(). Overrides RulesActionContainerUI:: |
1 |
RulesRuleUI:: |
public | function |
Applies the values of the form to the rule configuration. Overrides RulesContainerPluginUI:: |
|
RulesRuleUI:: |
public | function |
Implements RulesPluginUIInterface. Overrides RulesContainerPluginUI:: |
|
RulesRuleUI:: |
public | function |
Constructs a RulesRuleUI object. Overrides RulesPluginUI:: |