class RulesRuleUI

Rule specific UI.

Hierarchy

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

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

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
RulesContainerPluginUI::addOperations public function Gets the Add-* operations for the given element.
RulesContainerPluginUI::buildContent public function Implements RulesPluginUIInterface. Overrides RulesPluginUI::buildContent 1
RulesPluginUI::$basePath public static property The base path determines where a Rules overview UI lives.
RulesPluginUI::$element protected property
RulesPluginUI::defaultRedirect public static function Determines the default redirect target for an edited/deleted element.
RulesPluginUI::formDefaults public static function
RulesPluginUI::form_submit public function Implements RulesPluginUIInterface. Overrides RulesPluginUIInterface::form_submit
RulesPluginUI::form_validate public function Implements RulesPluginUIInterface. Overrides RulesPluginUIInterface::form_validate 2
RulesPluginUI::getDataTypeClass public function Returns the name of class for the given data type.
RulesPluginUI::getFormStateValues public static function Returns the state values for $form, possibly only a part of the whole form.
RulesPluginUI::getOptions public static function
RulesPluginUI::getParameterForm protected function Actually generates the parameter form for the given data type.
RulesPluginUI::getTags public static function
RulesPluginUI::getVariableForm public function Returns the form for configuring the info of a single variable.
RulesPluginUI::help public function Implements RulesPluginUIInterface. Overrides RulesPluginUIInterface::help
RulesPluginUI::overviewTable public static function Deprecated by the controllers overviewTable() method.
RulesPluginUI::path public static function Generates an operation path.
RulesPluginUI::settingsForm public function Adds the configuration settings form (label, tags, description, ...). 1
RulesPluginUI::settingsFormExtractValues public function 1
RulesPluginUI::settingsFormPermissionMatrix protected function Provides a matrix permission for the component based in the existing roles.
RulesPluginUI::settingsFormSubmit public function
RulesPluginUI::settingsFormValidate public function
RulesRuleUI::$conditions protected property
RulesRuleUI::$rule protected property
RulesRuleUI::form public function Implements RulesPluginUIInterface::form(). Overrides RulesActionContainerUI::form 1
RulesRuleUI::form_extract_values public function Applies the values of the form to the rule configuration. Overrides RulesContainerPluginUI::form_extract_values
RulesRuleUI::operations public function Implements RulesPluginUIInterface. Overrides RulesContainerPluginUI::operations
RulesRuleUI::__construct public function Constructs a RulesRuleUI object. Overrides RulesPluginUI::__construct