updated rules
This commit is contained in:
@@ -81,7 +81,7 @@ Drupal.rules = Drupal.rules || {};
|
||||
|
||||
this.jqObject.bind("autocompleteselect", function(event, ui) {
|
||||
// If a group was selected then set the groupSelected to true for the
|
||||
// overriden close function from jquery autocomplete.
|
||||
// overridden close function from jquery autocomplete.
|
||||
if (ui.item.value.substring(ui.item.value.length - 1, ui.item.value.length) == ":") {
|
||||
instance.groupSelected = true;
|
||||
}
|
||||
@@ -180,7 +180,7 @@ Drupal.rules = Drupal.rules || {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Toogle the autcomplete window.
|
||||
* Toggle the autocomplete window.
|
||||
*/
|
||||
Drupal.rules.autocomplete.prototype.toggle = function() {
|
||||
if (this.jqObject.autocomplete("widget").is(":visible")) {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
@CHARSET "UTF-8";
|
||||
@charset "utf-8";
|
||||
|
||||
.rules-show-js, html.js .rules-hide-js {
|
||||
.rules-show-js,
|
||||
html.js .rules-hide-js {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.rules-hide-js, html.js .rules-show-js {
|
||||
.rules-hide-js,
|
||||
html.js .rules-show-js {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@@ -58,7 +60,8 @@ ul.rules-operations-add li {
|
||||
right: 0px;
|
||||
}
|
||||
|
||||
.rules-elements-table caption, .rules-overview-table caption {
|
||||
.rules-elements-table caption,
|
||||
.rules-overview-table caption {
|
||||
font-size: 110%;
|
||||
font-weight: bold;
|
||||
padding-bottom: 0.5em;
|
||||
@@ -85,8 +88,7 @@ ul.rules-operations-add li {
|
||||
.rules-debug-collapsible-link {
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
|
||||
/* The span element with the icon which opens the log, has a whitepsace.
|
||||
/* The span element with the icon which opens the log, has a whitespace.
|
||||
Since we don't want the user to mark this white space, we prevent this
|
||||
using the this code.*/
|
||||
-moz-user-select: -moz-none;
|
||||
@@ -191,6 +193,6 @@ ul.rules-autocomplete .ui-corner-all {
|
||||
}
|
||||
|
||||
/* IE 6 hack for max-height. */
|
||||
* html ul.rule-autocomplete{
|
||||
* html ul.rule-autocomplete {
|
||||
height: 23em;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file Contains the UI controller for Rules.
|
||||
* @file
|
||||
* Contains the UI controller for Rules.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -35,8 +36,8 @@ class RulesUIController {
|
||||
);
|
||||
$items[$base_path . '/manage/%rules_config/add/%rules_element'] = array(
|
||||
// Adding another part to the path would hit the menu path-part-limit
|
||||
// for base paths like admin/config/workflow/rules. Therefor we have to
|
||||
// use this fugly way for setting the title.
|
||||
// for base paths like admin/config/workflow/rules. Therefore we have to
|
||||
// use this ugly way for setting the title.
|
||||
'title callback' => 'rules_menu_add_element_title',
|
||||
// Wrap the integer in an array, so it is passed as is.
|
||||
'title arguments' => array(array($base_count + 4)),
|
||||
@@ -60,7 +61,7 @@ class RulesUIController {
|
||||
'file path' => drupal_get_path('module', 'rules'),
|
||||
);
|
||||
$items[$base_path . '/manage/%rules_config/delete/event'] = array(
|
||||
//@todo: improve title.
|
||||
// @todo Improve title.
|
||||
'title' => 'Remove event',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('rules_ui_remove_event', $base_count + 1, $base_count + 4, $base_path),
|
||||
@@ -157,8 +158,10 @@ class RulesUIController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the render array for a overview configuration table for arbitrary
|
||||
* rule configs that match the given conditions.
|
||||
* Generates the render array for an overview configuration table.
|
||||
*
|
||||
* Generates the render array for an overview configuration table for
|
||||
* arbitrary rule configs that match the given conditions.
|
||||
*
|
||||
* Note: The generated overview table contains multiple links for editing the
|
||||
* rule configurations. For the links to properly work use
|
||||
@@ -182,7 +185,7 @@ class RulesUIController {
|
||||
* currently set RulesPluginUI::$basePath. If no base path has been set
|
||||
* yet, the current path is used by default.
|
||||
*
|
||||
* @return Array
|
||||
* @return array
|
||||
* A renderable array.
|
||||
*/
|
||||
public function overviewTable($conditions = array(), $options = array()) {
|
||||
@@ -199,7 +202,7 @@ class RulesUIController {
|
||||
if (!empty($options['base path'])) {
|
||||
RulesPluginUI::$basePath = $options['base path'];
|
||||
}
|
||||
else if (!isset(RulesPluginUI::$basePath)) {
|
||||
elseif (!isset(RulesPluginUI::$basePath)) {
|
||||
// Default to the current path, only if no path has been set yet.
|
||||
RulesPluginUI::$basePath = current_path();
|
||||
}
|
||||
@@ -241,7 +244,7 @@ class RulesUIController {
|
||||
$table['#attributes']['class'][] = 'rules-overview-table';
|
||||
$table['#attached']['css'][] = drupal_get_path('module', 'rules') . '/ui/rules.ui.css';
|
||||
|
||||
// TODO: hide configs where access() is FALSE.
|
||||
// @todo Hide configs where access() is FALSE.
|
||||
return $table;
|
||||
}
|
||||
|
||||
@@ -279,9 +282,9 @@ class RulesUIController {
|
||||
|
||||
// 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'))));
|
||||
$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'))));
|
||||
$row[] = l(t('translate'), RulesPluginUI::path($name, 'translate'), array('attributes' => array('class' => array('translate', 'action'))));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -321,4 +324,5 @@ class RulesUIController {
|
||||
$row[] = l(t('export'), RulesPluginUI::path($name, 'export'), array('attributes' => array('class' => array('export', 'action'))));
|
||||
return $row;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file Contains core ui functions.
|
||||
* @file
|
||||
* Contains core Rules UI functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -10,9 +11,10 @@
|
||||
interface RulesPluginUIInterface {
|
||||
|
||||
/**
|
||||
* Adds the whole configuration form of this rules configuration. For rule
|
||||
* elements that are part of a configuration this method just adds the
|
||||
* elements configuration form.
|
||||
* Adds the whole configuration form of this rules configuration.
|
||||
*
|
||||
* For rule elements that are part of a configuration this method just adds
|
||||
* the elements configuration form.
|
||||
*
|
||||
* @param $form
|
||||
* The form array where to add the form.
|
||||
@@ -37,8 +39,7 @@ interface RulesPluginUIInterface {
|
||||
* - 'restrict events': Optionally set an array of event names to restrict
|
||||
* the events that are available for adding.
|
||||
*
|
||||
* @todo
|
||||
* Implement the 'restrict *' options.
|
||||
* @todo Implement the 'restrict *' options.
|
||||
*/
|
||||
public function form(&$form, &$form_state, $options = array());
|
||||
|
||||
@@ -51,6 +52,8 @@ interface RulesPluginUIInterface {
|
||||
public function form_validate($form, &$form_state);
|
||||
|
||||
/**
|
||||
* Form submit handler for the element configuration form.
|
||||
*
|
||||
* Submit the configuration form of this rule element. This makes sure to
|
||||
* put the updated configuration in the form state. For saving changes
|
||||
* permanently, just call $config->save() afterwards.
|
||||
@@ -135,11 +138,13 @@ class RulesElementMap {
|
||||
}
|
||||
return isset($this->index[$id]) ? $this->index[$id] : FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Faces UI extender for all kind of Rules plugins. Provides various useful
|
||||
* methods for any rules UI.
|
||||
* Faces UI extender for all kind of Rules plugins.
|
||||
*
|
||||
* Provides various useful methods for any rules UI.
|
||||
*/
|
||||
class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
|
||||
@@ -149,10 +154,11 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
protected $element;
|
||||
|
||||
/**
|
||||
* The base path determines where a Rules overview UI lives. All forms that
|
||||
* want to display Rules (overview) forms need to set this variable. This is
|
||||
* necessary in order to get correct operation links, paths, redirects, bread
|
||||
* crumbs etc. for the form() and overviewTable() methods.
|
||||
* The base path determines where a Rules overview UI lives.
|
||||
*
|
||||
* All forms that want to display Rules (overview) forms need to set this
|
||||
* variable. This is necessary in order to get correct operation links,
|
||||
* paths, redirects, breadcrumbs etc. for the form() and overviewTable() methods.
|
||||
*
|
||||
* @see RulesUIController
|
||||
* @see rules_admin_reaction_overview()
|
||||
@@ -193,8 +199,7 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements RulesPluginUIInterface.
|
||||
* Generates the element edit form.
|
||||
* Implements RulesPluginUIInterface. Generates the element edit form.
|
||||
*
|
||||
* Note: Make sure that you set RulesPluginUI::$basePath before using this
|
||||
* method, otherwise paths, links, redirects etc. won't be correct.
|
||||
@@ -257,7 +262,7 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
);
|
||||
}
|
||||
if (!empty($form['provides'])) {
|
||||
$help = '<div class="description">' . t('Adjust the names and labels of provided variables, but note that renaming of already utilizied variables invalidates the existing uses.') . '</div>';
|
||||
$help = '<div class="description">' . t('Adjust the names and labels of provided variables, but note that renaming of already utilized variables invalidates the existing uses.') . '</div>';
|
||||
$form['provides'] += array(
|
||||
'#tree' => TRUE,
|
||||
'#prefix' => '<h4 class="rules-form-heading">' . t('Provided variables') . '</h4>' . $help,
|
||||
@@ -304,8 +309,8 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
}
|
||||
|
||||
// For translatable parameters, pre-populate an internal translation source
|
||||
// key so data type forms or input evaluators (i18n) may produce suiting
|
||||
// help.
|
||||
// key so data type forms or input evaluators (i18n) may show a suitable
|
||||
// help message.
|
||||
if (drupal_multilingual() && !empty($info['translatable'])) {
|
||||
$parameter = $this->element->pluginParameterInfo();
|
||||
$info['custom translation language'] = !empty($parameter['language']);
|
||||
@@ -320,7 +325,7 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
}
|
||||
|
||||
// Add a link for switching the input mode when JS is enabled and a button
|
||||
// to switch it without javascript, in case switching is possible.
|
||||
// to switch it without JavaScript, in case switching is possible.
|
||||
if ($supports_input_mode && empty($info['restriction'])) {
|
||||
$value = $mode == 'selector' ? t('Switch to the direct input mode') : t('Switch to data selection');
|
||||
|
||||
@@ -420,7 +425,7 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
'#required' => TRUE,
|
||||
'#weight' => -5,
|
||||
);
|
||||
// @todo: For Drupal 8 use "owner" for generating machine names and
|
||||
// @todo For Drupal 8 use "owner" for generating machine names and
|
||||
// module only for the modules providing default configurations.
|
||||
if (!empty($this->element->module) && !empty($this->element->name) && $this->element->module == 'rules' && strpos($this->element->name, 'rules_') === 0) {
|
||||
// Remove the Rules module prefix from the machine name.
|
||||
@@ -457,7 +462,7 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
$description = t('The variables used by the component. They can not be edited for configurations that are provided in code.');
|
||||
}
|
||||
else {
|
||||
$description = t('Variables are normally input <em>parameters</em> for the component – data that should be available for the component to act on. Additionaly, action components may <em>provide</em> variables back to the caller. Each variable must have a specified data type, a label and a unique machine readable name containing only lowercase alphanumeric characters and underscores. See <a href="@url">the online documentation</a> for more information about variables.',
|
||||
$description = t('Variables are normally input <em>parameters</em> for the component – data that should be available for the component to act on. Additionally, action components may <em>provide</em> variables back to the caller. Each variable must have a specified data type, a label and a unique machine readable name containing only lowercase alphanumeric characters and underscores. See <a href="@url">the online documentation</a> for more information about variables.',
|
||||
array('@url' => rules_external_help('variables'))
|
||||
);
|
||||
}
|
||||
@@ -502,7 +507,7 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Configure access for using this component with a permission.'),
|
||||
'#default_value' => !empty($this->element->access_exposed),
|
||||
'#description' => t('By default, the @plugin-type for using this component may be only used by users that have access to configure the component. If checked, access is determined by a permission instead.', array('@plugin-type' => $plugin_type))
|
||||
'#description' => t('By default, the @plugin-type for using this component may be only used by users that have access to configure the component. If checked, access is determined by a permission instead.', array('@plugin-type' => $plugin_type)),
|
||||
);
|
||||
$form['settings']['access']['permissions'] = array(
|
||||
'#type' => 'container',
|
||||
@@ -516,7 +521,7 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Attach field form thus description.
|
||||
// @todo Attach field form thus description.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -567,7 +572,7 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
$form_values = RulesPluginUI::getFormStateValues($form['settings'], $form_state);
|
||||
$this->element->label = $form_values['label'];
|
||||
// If the name was changed we have to redirect to the URL that contains
|
||||
// the new name, instead of rebuilding on the old URL with the old name
|
||||
// the new name, instead of rebuilding on the old URL with the old name.
|
||||
if ($form['settings']['name']['#default_value'] != $form_values['name']) {
|
||||
$module = isset($this->element->module) ? $this->element->module : 'rules';
|
||||
$this->element->name = $module . '_' . $form_values['name'];
|
||||
@@ -669,7 +674,7 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
* Returns the name of class for the given data type.
|
||||
*
|
||||
* @param $data_type
|
||||
* The name of the data typ
|
||||
* The name of the data type
|
||||
* @param $parameter_info
|
||||
* (optional) An array of info about the to be configured parameter. If
|
||||
* given, this array is complemented with data type defaults also.
|
||||
@@ -689,7 +694,8 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
|
||||
/**
|
||||
* Implements RulesPluginUIInterface.
|
||||
* Show a preview of the configuration settings.
|
||||
*
|
||||
* Shows a preview of the configuration settings.
|
||||
*/
|
||||
public function buildContent() {
|
||||
$config_name = $this->element->root()->name;
|
||||
@@ -698,7 +704,7 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
'#title' => $this->element->label(),
|
||||
'#href' => $this->element->isRoot() ? RulesPluginUI::path($config_name) : RulesPluginUI::path($config_name, 'edit', $this->element),
|
||||
'#prefix' => '<div class="rules-element-label">',
|
||||
'#suffix' => '</div>'
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
// Put the elements below in a "description" div.
|
||||
$content['description'] = array(
|
||||
@@ -712,14 +718,14 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
$element = array();
|
||||
if (!empty($this->element->settings[$name . ':select'])) {
|
||||
$element['content'] = array(
|
||||
'#markup' => '[' . $this->element->settings[$name . ':select'] . ']',
|
||||
'#markup' => '[' . $this->element->settings[$name . ':select'] . ']',
|
||||
);
|
||||
}
|
||||
elseif (isset($this->element->settings[$name]) && (!isset($parameter['default value']) || $parameter['default value'] != $this->element->settings[$name])) {
|
||||
$class = $this->getDataTypeClass($parameter['type'], $parameter);
|
||||
$method = empty($parameter['options list']) ? 'render' : 'renderOptionsLabel';
|
||||
// We cannot use method_exists() here as it would trigger a PHP bug,
|
||||
// @see http://drupal.org/node/1258284
|
||||
// We cannot use method_exists() here as it would trigger a PHP bug.
|
||||
// @see https://www.drupal.org/node/1258284
|
||||
$element = call_user_func(array($class, $method), $this->element->settings[$name], $name, $parameter, $this->element);
|
||||
}
|
||||
// Only add parameters that are really configured / not default.
|
||||
@@ -802,7 +808,6 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
*/
|
||||
public function help() {}
|
||||
|
||||
|
||||
/**
|
||||
* Deprecated by the controllers overviewTable() method.
|
||||
*/
|
||||
@@ -811,6 +816,8 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an operation path.
|
||||
*
|
||||
* Generates a path using the given operation for the element with the given
|
||||
* id of the configuration with the given name.
|
||||
*/
|
||||
@@ -824,12 +831,19 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
else {
|
||||
$base_path = isset($element) && $element instanceof RulesTriggerableInterface ? 'admin/config/workflow/rules/reaction' : 'admin/config/workflow/rules/components';
|
||||
}
|
||||
return implode('/', array_filter(array($base_path . '/manage', $name, $op, $element_id, $parameter)));
|
||||
|
||||
// Only append the '/manage' path if it is not already present.
|
||||
if (substr($base_path, -strlen('/manage')) != '/manage') {
|
||||
$base_path .= '/manage';
|
||||
}
|
||||
|
||||
return implode('/', array_filter(array($base_path, $name, $op, $element_id, $parameter)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the default redirect target for an edited/deleted element. This
|
||||
* is a parent element which is either a rule or the configuration root.
|
||||
* Determines the default redirect target for an edited/deleted element.
|
||||
*
|
||||
* This is a parent element which is either a rule or the configuration root.
|
||||
*/
|
||||
public static function defaultRedirect(RulesPlugin $element) {
|
||||
while (!$element->isRoot()) {
|
||||
@@ -879,6 +893,7 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
->fetchCol('tag');
|
||||
return drupal_map_assoc($result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -887,6 +902,8 @@ class RulesPluginUI extends FacesExtender implements RulesPluginUIInterface {
|
||||
class RulesAbstractPluginUI extends RulesPluginUI {
|
||||
|
||||
/**
|
||||
* Overrides RulesPluginUI::form().
|
||||
*
|
||||
* Overridden to invoke the abstract plugins form alter callback and to add
|
||||
* the negation checkbox for conditions.
|
||||
*/
|
||||
@@ -923,6 +940,7 @@ class RulesAbstractPluginUI extends RulesPluginUI {
|
||||
form_set_error(implode('][', $e->keys), $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -941,11 +959,11 @@ class RulesContainerPluginUI extends RulesPluginUI {
|
||||
'#tree' => TRUE,
|
||||
'#theme' => 'rules_elements',
|
||||
'#empty' => t('None'),
|
||||
'#caption' => t('Elements')
|
||||
'#caption' => t('Elements'),
|
||||
);
|
||||
$form['elements']['#attributes']['class'][] = 'rules-container-plugin';
|
||||
|
||||
// Recurse over all element childrens or use the provided iterator.
|
||||
// Recurse over all element children or use the provided iterator.
|
||||
$iterator = isset($iterator) ? $iterator : $this->element->elements();
|
||||
$root_depth = $this->element->depth();
|
||||
foreach ($iterator as $key => $child) {
|
||||
@@ -965,7 +983,7 @@ class RulesContainerPluginUI extends RulesPluginUI {
|
||||
);
|
||||
$form['elements'][$id]['parent_id'] = array(
|
||||
'#type' => 'hidden',
|
||||
// If another iterator is passed in, the childs parent may not equal
|
||||
// If another iterator is passed in, the child parent may not equal
|
||||
// the current element. Thus ask the child for its parent.
|
||||
'#default_value' => $child->parentElement()->elementId(),
|
||||
);
|
||||
@@ -1031,12 +1049,10 @@ class RulesContainerPluginUI extends RulesPluginUI {
|
||||
return $render;
|
||||
}
|
||||
|
||||
|
||||
public function buildContent() {
|
||||
$content = parent::buildContent();
|
||||
// Don't link the title for embedded container plugins, except for rules.
|
||||
if (!$this->element->isRoot() && !($this->element instanceof Rule)) {
|
||||
$content['label']['#type'] = 'markup';
|
||||
$content['label']['#markup'] = check_plain($content['label']['#title']);
|
||||
unset($content['label']['#title']);
|
||||
}
|
||||
@@ -1079,6 +1095,7 @@ class RulesContainerPluginUI extends RulesPluginUI {
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1093,7 +1110,7 @@ class RulesConditionContainerUI extends RulesContainerPluginUI {
|
||||
$form['elements']['#attributes']['class'][] = 'rules-condition-container';
|
||||
$form['elements']['#caption'] = t('Conditions');
|
||||
|
||||
// By default skip
|
||||
// By default skip.
|
||||
if (!empty($options['init']) && !$this->element->isRoot()) {
|
||||
$config = $this->element->root();
|
||||
$form['init_help'] = array(
|
||||
@@ -1124,6 +1141,7 @@ class RulesConditionContainerUI extends RulesContainerPluginUI {
|
||||
$this->element->negate($form_values['negate']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1132,12 +1150,13 @@ class RulesConditionContainerUI extends RulesContainerPluginUI {
|
||||
class RulesActionContainerUI extends RulesContainerPluginUI {
|
||||
|
||||
public function form(&$form, &$form_state, $options = array(), $iterator = NULL) {
|
||||
parent::form($form, $form_state, $options, $iterator);
|
||||
parent::form($form, $form_state, $options, $iterator);
|
||||
// Add the add-* operation links.
|
||||
$form['elements']['#add'] = self::addOperations();
|
||||
$form['elements']['#attributes']['class'][] = 'rules-action-container';
|
||||
$form['elements']['#caption'] = t('Actions');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1167,14 +1186,14 @@ class RulesUICategory {
|
||||
* (optional) Whether group labels for grouping inside a category should be
|
||||
* return. Defaults to FALSE.
|
||||
*
|
||||
* @return string|boolean
|
||||
* @return string|bool
|
||||
* The group label to use, or FALSE if none can be found.
|
||||
*/
|
||||
public static function getItemGroup($item_info, $in_category = FALSE) {
|
||||
if (isset($item_info['category']) && !$in_category) {
|
||||
return self::getCategory($item_info, 'label');
|
||||
}
|
||||
else if (!empty($item_info['group'])) {
|
||||
elseif (!empty($item_info['group'])) {
|
||||
return $item_info['group'];
|
||||
}
|
||||
return FALSE;
|
||||
@@ -1202,7 +1221,9 @@ class RulesUICategory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of options to use with a select for the items specified
|
||||
* Returns an array of options to use with a select.
|
||||
*
|
||||
* Returns an array of options to use with a selectfor the items specified
|
||||
* in the given hook.
|
||||
*
|
||||
* @param $item_type
|
||||
@@ -1211,7 +1232,7 @@ class RulesUICategory {
|
||||
* @param $items
|
||||
* (optional) An array of items to restrict the options to.
|
||||
*
|
||||
* @return
|
||||
* @return array
|
||||
* An array of options.
|
||||
*/
|
||||
public static function getOptions($item_type, $items = NULL) {
|
||||
@@ -1219,7 +1240,7 @@ class RulesUICategory {
|
||||
$ungrouped = array();
|
||||
$data = $items ? $items : rules_fetch_data($item_type . '_info');
|
||||
foreach ($data as $name => $info) {
|
||||
// Verfiy the current user has access to use it.
|
||||
// Verify the current user has access to use it.
|
||||
if (!user_access('bypass rules access') && !empty($info['access callback']) && !call_user_func($info['access callback'], $item_type, $name)) {
|
||||
continue;
|
||||
}
|
||||
@@ -1256,6 +1277,7 @@ class RulesUICategory {
|
||||
}
|
||||
return $ungrouped + $sorted_groups;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file Contains data type related forms.
|
||||
* @file
|
||||
* Contains data type related forms.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Interface for data types providing a direct input form.
|
||||
*/
|
||||
@@ -13,15 +13,15 @@ interface RulesDataDirectInputFormInterface {
|
||||
/**
|
||||
* Constructs the direct input form.
|
||||
*
|
||||
* @return Array
|
||||
* The direct input form.
|
||||
* @return array
|
||||
* The direct input form.
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element);
|
||||
|
||||
/**
|
||||
* Render the configured value.
|
||||
*
|
||||
* @return Array
|
||||
* @return array
|
||||
* A renderable array.
|
||||
*/
|
||||
public static function render($value);
|
||||
@@ -36,21 +36,22 @@ interface RulesDataInputOptionsListInterface extends RulesDataDirectInputFormInt
|
||||
/**
|
||||
* Returns the options list for the data type.
|
||||
*
|
||||
* @param RulesPlugin $element
|
||||
* The rules element to get the options for.
|
||||
* @param string $name
|
||||
* The name of the parameter for which to get options.
|
||||
*
|
||||
* For retrieving information about the used data type and parameter, the
|
||||
* helper RulesDataUI::getTypeInfo() may be used as following:
|
||||
* @code
|
||||
* list($type, $parameter_info) = RulesDataUI::getTypeInfo($element, $name);
|
||||
* @endcode
|
||||
*
|
||||
* @return
|
||||
* @param RulesPlugin $element
|
||||
* The rules element to get the options for.
|
||||
* @param string $name
|
||||
* The name of the parameter for which to get options.
|
||||
*
|
||||
* @return array
|
||||
* An array of options as used by hook_options_list().
|
||||
*/
|
||||
public static function optionsList(RulesPlugin $element, $name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,7 +139,7 @@ class RulesDataUI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the value by making use of the label if an options list is available.
|
||||
* Renders the value with a label if an options list is available.
|
||||
*
|
||||
* Used for data UI classes implementing the
|
||||
* RulesDataDirectInputFormInterface.
|
||||
@@ -181,6 +182,7 @@ class RulesDataUI {
|
||||
$parameters = $element->pluginParameterInfo();
|
||||
return array($parameters[$name]['type'], $parameters[$name]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,10 +190,16 @@ class RulesDataUI {
|
||||
*/
|
||||
class RulesDataUIText extends RulesDataUI implements RulesDataDirectInputFormInterface {
|
||||
|
||||
/**
|
||||
* Overrides RulesDataUI::getDefaultMode().
|
||||
*/
|
||||
public static function getDefaultMode() {
|
||||
return 'input';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::inputForm().
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
|
||||
if (!empty($info['options list'])) {
|
||||
// Make sure the .rules.inc of the providing module is included as the
|
||||
@@ -205,6 +213,7 @@ class RulesDataUIText extends RulesDataUI implements RulesDataDirectInputFormInt
|
||||
else {
|
||||
$form[$name] = array(
|
||||
'#type' => 'textarea',
|
||||
'#rows' => 3,
|
||||
);
|
||||
RulesDataInputEvaluator::attachForm($form, $settings, $info, $element->availableVariables());
|
||||
}
|
||||
@@ -214,17 +223,20 @@ class RulesDataUIText extends RulesDataUI implements RulesDataDirectInputFormInt
|
||||
'#default_value' => $settings[$name],
|
||||
'#required' => empty($info['optional']),
|
||||
'#after_build' => array('rules_ui_element_fix_empty_after_build'),
|
||||
'#rows' => 3,
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::render().
|
||||
*/
|
||||
public static function render($value) {
|
||||
return array(
|
||||
'content' => array('#markup' => check_plain($value)),
|
||||
'#attributes' => array('class' => array('rules-parameter-text')),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,6 +244,9 @@ class RulesDataUIText extends RulesDataUI implements RulesDataDirectInputFormInt
|
||||
*/
|
||||
class RulesDataUITextToken extends RulesDataUIText {
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::inputForm().
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
|
||||
$form = parent::inputForm($name, $info, $settings, $element);
|
||||
if ($form[$name]['#type'] == 'textarea') {
|
||||
@@ -241,6 +256,7 @@ class RulesDataUITextToken extends RulesDataUIText {
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,6 +264,9 @@ class RulesDataUITextToken extends RulesDataUIText {
|
||||
*/
|
||||
class RulesDataUITextFormatted extends RulesDataUIText {
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::inputForm().
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
|
||||
$form = parent::inputForm($name, $info, $settings, $element);
|
||||
$settings += array($name => isset($info['default value']) ? $info['default value'] : array('value' => NULL, 'format' => NULL));
|
||||
@@ -259,21 +278,26 @@ class RulesDataUITextFormatted extends RulesDataUIText {
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::render().
|
||||
*/
|
||||
public static function render($value) {
|
||||
return array(
|
||||
'content' => array('#markup' => check_plain($value['value'])),
|
||||
'#attributes' => array('class' => array('rules-parameter-text-formatted')),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* UI for decimal data.
|
||||
*/
|
||||
class RulesDataUIDecimal extends RulesDataUIText {
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::inputForm().
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
|
||||
$form = parent::inputForm($name, $info, $settings, $element);
|
||||
if (empty($info['options list'])) {
|
||||
@@ -283,6 +307,7 @@ class RulesDataUIDecimal extends RulesDataUIText {
|
||||
$form[$name]['#rows'] = 1;
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,6 +315,9 @@ class RulesDataUIDecimal extends RulesDataUIText {
|
||||
*/
|
||||
class RulesDataUIInteger extends RulesDataUIText {
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::inputForm().
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
|
||||
$form = parent::inputForm($name, $info, $settings, $element);
|
||||
if (empty($info['options list'])) {
|
||||
@@ -298,6 +326,7 @@ class RulesDataUIInteger extends RulesDataUIText {
|
||||
$form[$name]['#element_validate'][] = 'rules_ui_element_integer_validate';
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -305,6 +334,9 @@ class RulesDataUIInteger extends RulesDataUIText {
|
||||
*/
|
||||
class RulesDataUIIPAddress extends RulesDataUIText {
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::inputForm().
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
|
||||
$form = parent::inputForm($name, $info, $settings, $element);
|
||||
if (empty($info['options list'])) {
|
||||
@@ -315,6 +347,7 @@ class RulesDataUIIPAddress extends RulesDataUIText {
|
||||
$form[$name]['#rows'] = 1;
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,10 +355,16 @@ class RulesDataUIIPAddress extends RulesDataUIText {
|
||||
*/
|
||||
class RulesDataUIBoolean extends RulesDataUI implements RulesDataDirectInputFormInterface {
|
||||
|
||||
/**
|
||||
* Overrides RulesDataUI::getDefaultMode().
|
||||
*/
|
||||
public static function getDefaultMode() {
|
||||
return 'input';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::inputForm().
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
|
||||
$settings += array($name => isset($info['default value']) ? $info['default value'] : NULL);
|
||||
// Note: Due to the checkbox even optional parameter always receive a value.
|
||||
@@ -340,12 +379,16 @@ class RulesDataUIBoolean extends RulesDataUI implements RulesDataDirectInputForm
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::render().
|
||||
*/
|
||||
public static function render($value) {
|
||||
return array(
|
||||
'content' => array('#markup' => !empty($value) ? t('true') : t('false')),
|
||||
'#attributes' => array('class' => array('rules-parameter-boolean')),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,6 +396,9 @@ class RulesDataUIBoolean extends RulesDataUI implements RulesDataDirectInputForm
|
||||
*/
|
||||
class RulesDataUIDate extends RulesDataUIText {
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::inputForm().
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
|
||||
$settings += array($name => isset($info['default value']) ? $info['default value'] : (empty($info['optional']) ? gmdate('Y-m-d H:i:s', time()) : NULL));
|
||||
|
||||
@@ -369,11 +415,14 @@ class RulesDataUIDate extends RulesDataUIText {
|
||||
array('%format' => gmdate('Y-m-d H:i:s', time() + 86400),
|
||||
'!strtotime' => l('strtotime()', 'http://php.net/strtotime')));
|
||||
|
||||
//TODO: Leverage the jquery datepicker+timepicker once a module providing
|
||||
//the timpeicker is available.
|
||||
// @todo Leverage the jquery datepicker+timepicker once a module providing
|
||||
// The timepicker is available.
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::render().
|
||||
*/
|
||||
public static function render($value) {
|
||||
$value = is_numeric($value) ? format_date($value, 'short') : check_plain($value);
|
||||
return array(
|
||||
@@ -381,6 +430,7 @@ class RulesDataUIDate extends RulesDataUIText {
|
||||
'#attributes' => array('class' => array('rules-parameter-date')),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,6 +438,9 @@ class RulesDataUIDate extends RulesDataUIText {
|
||||
*/
|
||||
class RulesDataUIDuration extends RulesDataUIText {
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::inputForm().
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
|
||||
$form = parent::inputForm($name, $info, $settings, $element);
|
||||
$form[$name]['#type'] = 'rules_duration';
|
||||
@@ -395,6 +448,9 @@ class RulesDataUIDuration extends RulesDataUIText {
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::render().
|
||||
*/
|
||||
public static function render($value) {
|
||||
$value = is_numeric($value) ? format_interval($value) : check_plain($value);
|
||||
return array(
|
||||
@@ -402,6 +458,7 @@ class RulesDataUIDuration extends RulesDataUIText {
|
||||
'#attributes' => array('class' => array('rules-parameter-duration')),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -409,12 +466,16 @@ class RulesDataUIDuration extends RulesDataUIText {
|
||||
*/
|
||||
class RulesDataUIURI extends RulesDataUIText {
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::inputForm().
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
|
||||
$form = parent::inputForm($name, $info, $settings, $element);
|
||||
$form[$name]['#rows'] = 1;
|
||||
$form[$name]['#description'] = t('You may enter relative URLs like %url as well as absolute URLs like %absolute-url.', array('%url' => 'user/login?destination=node', '%absolute-url' => 'http://drupal.org'));
|
||||
$form[$name]['#description'] = t('You may enter relative URLs like %url as well as absolute URLs like %absolute-url.', array('%url' => 'user/login?destination=node', '%absolute-url' => 'https://www.drupal.org'));
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -422,11 +483,16 @@ class RulesDataUIURI extends RulesDataUIText {
|
||||
*/
|
||||
class RulesDataUIListText extends RulesDataUIText {
|
||||
|
||||
/**
|
||||
* Overrides RulesDataUI::getDefaultMode().
|
||||
*/
|
||||
public static function getDefaultMode() {
|
||||
return 'input';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::inputForm().
|
||||
*
|
||||
* @todo This does not work for inputting textual values including "\n".
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
|
||||
@@ -447,12 +513,16 @@ class RulesDataUIListText extends RulesDataUIText {
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::render().
|
||||
*/
|
||||
public static function render($value) {
|
||||
return array(
|
||||
'content' => array('#markup' => check_plain(implode(', ', $value))),
|
||||
'#attributes' => array('class' => array('rules-parameter-list')),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -460,6 +530,9 @@ class RulesDataUIListText extends RulesDataUIText {
|
||||
*/
|
||||
class RulesDataUIListInteger extends RulesDataUIListText {
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::inputForm().
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
|
||||
$settings += array($name => isset($info['default value']) ? $info['default value'] : NULL);
|
||||
$form = parent::inputForm($name, $info, $settings, $element);
|
||||
@@ -473,6 +546,7 @@ class RulesDataUIListInteger extends RulesDataUIListText {
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -480,6 +554,9 @@ class RulesDataUIListInteger extends RulesDataUIListText {
|
||||
*/
|
||||
class RulesDataUIListToken extends RulesDataUIListInteger {
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::inputForm().
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
|
||||
$form = parent::inputForm($name, $info, $settings, $element);
|
||||
|
||||
@@ -489,6 +566,7 @@ class RulesDataUIListToken extends RulesDataUIListInteger {
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -496,10 +574,16 @@ class RulesDataUIListToken extends RulesDataUIListInteger {
|
||||
*/
|
||||
class RulesDataUIEntity extends RulesDataUIText {
|
||||
|
||||
/**
|
||||
* Overrides RulesDataUI::getDefaultMode().
|
||||
*/
|
||||
public static function getDefaultMode() {
|
||||
return 'selector';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::inputForm().
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
|
||||
$form = parent::inputForm($name, $info, $settings, $element);
|
||||
if (empty($info['options list'])) {
|
||||
@@ -515,6 +599,7 @@ class RulesDataUIEntity extends RulesDataUIText {
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -522,9 +607,13 @@ class RulesDataUIEntity extends RulesDataUIText {
|
||||
*/
|
||||
class RulesDataUIEntityExportable extends RulesDataUIEntity {
|
||||
|
||||
/**
|
||||
* Overrides RulesDataUI::getDefaultMode().
|
||||
*/
|
||||
public static function getDefaultMode() {
|
||||
return 'input';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -535,6 +624,9 @@ class RulesDataUIEntityExportable extends RulesDataUIEntity {
|
||||
*/
|
||||
class RulesDataUIBundleEntity extends RulesDataUIEntity implements RulesDataInputOptionsListInterface {
|
||||
|
||||
/**
|
||||
* Overrides RulesDataUI::getDefaultMode().
|
||||
*/
|
||||
public static function getDefaultMode() {
|
||||
return 'input';
|
||||
}
|
||||
@@ -554,6 +646,7 @@ class RulesDataUIBundleEntity extends RulesDataUIEntity implements RulesDataInpu
|
||||
}
|
||||
return $bundles;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -563,6 +656,9 @@ class RulesDataUIBundleEntity extends RulesDataUIEntity implements RulesDataInpu
|
||||
*/
|
||||
class RulesDataUITaxonomyVocabulary extends RulesDataUIEntity implements RulesDataInputOptionsListInterface {
|
||||
|
||||
/**
|
||||
* Overrides RulesDataUI::getDefaultMode().
|
||||
*/
|
||||
public static function getDefaultMode() {
|
||||
return 'input';
|
||||
}
|
||||
@@ -577,6 +673,7 @@ class RulesDataUITaxonomyVocabulary extends RulesDataUIEntity implements RulesDa
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -584,6 +681,9 @@ class RulesDataUITaxonomyVocabulary extends RulesDataUIEntity implements RulesDa
|
||||
*/
|
||||
class RulesDataUIListEntity extends RulesDataUIListInteger {
|
||||
|
||||
/**
|
||||
* Implements RulesDataDirectInputFormInterface::inputForm().
|
||||
*/
|
||||
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
|
||||
$form = parent::inputForm($name, $info, $settings, $element);
|
||||
if (empty($info['options list'])) {
|
||||
@@ -598,4 +698,5 @@ class RulesDataUIListEntity extends RulesDataUIListInteger {
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file Rules UI forms
|
||||
* @file
|
||||
* Rules User Interface forms.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -35,7 +36,7 @@ function rules_ui_parameter_replace_submit($form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* General form submit handler, that rebuilds the form
|
||||
* General form submit handler, that rebuilds the form.
|
||||
*/
|
||||
function rules_form_submit_rebuild($form, &$form_state) {
|
||||
$form_state['rebuild'] = TRUE;
|
||||
@@ -54,8 +55,9 @@ function rules_ui_form_edit_rules_config($form, &$form_state, $rules_config, $ba
|
||||
}
|
||||
|
||||
/**
|
||||
* General rules configuration form validation callback. Also populates the
|
||||
* rules configuration with the form values.
|
||||
* General rules configuration form validation callback.
|
||||
*
|
||||
* Also populates the rules configuration with the form values.
|
||||
*/
|
||||
function rules_ui_form_rules_config_validate($form, &$form_state) {
|
||||
$form_state['rules_element']->form_validate($form, $form_state);
|
||||
@@ -165,13 +167,29 @@ function rules_ui_confirm_operations($op, $rules_config) {
|
||||
|
||||
switch ($op) {
|
||||
case 'enable':
|
||||
return array(t('Are you sure you want to enable the %plugin %label?', $vars), '');
|
||||
return array(
|
||||
t('Are you sure you want to enable the %plugin %label?', $vars),
|
||||
'',
|
||||
);
|
||||
|
||||
case 'disable':
|
||||
return array(t('Are you sure you want to disable the %plugin %label?', $vars), '');
|
||||
return array(
|
||||
t('Are you sure you want to disable the %plugin %label?', $vars),
|
||||
'',
|
||||
);
|
||||
|
||||
case 'revert':
|
||||
return array(t('Are you sure you want to revert the %plugin %label?', $vars), t('This action cannot be undone.'));
|
||||
return array(
|
||||
t('Are you sure you want to revert the %plugin %label?', $vars),
|
||||
t('This action cannot be undone.'),
|
||||
);
|
||||
|
||||
case 'delete':
|
||||
return array(t('Are you sure you want to delete the %plugin %label?', $vars), t('This action cannot be undone.'));
|
||||
return array(
|
||||
t('Are you sure you want to delete the %plugin %label?', $vars),
|
||||
t('This action cannot be undone.'),
|
||||
);
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
@@ -193,9 +211,10 @@ function rules_ui_form_rules_config_confirm_op($form, &$form_state, $rules_confi
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the operation and returns the message to show to the user. Also the
|
||||
* operation is logged to the watchdog. Note that the string is defined two
|
||||
* times so that the translation extractor can find it.
|
||||
* Applies the operation and returns the message to show to the user.
|
||||
*
|
||||
* The operation is also logged to the watchdog. Note that the string is
|
||||
* defined two times so that the translation extractor can find it.
|
||||
*/
|
||||
function rules_ui_confirm_operation_apply($op, $rules_config) {
|
||||
$vars = array('%plugin' => $rules_config->plugin(), '%label' => $rules_config->label());
|
||||
@@ -290,8 +309,9 @@ function rules_ui_add_element($form, &$form_state, $rules_config, $plugin_name,
|
||||
|
||||
/**
|
||||
* Add element submit callback.
|
||||
*
|
||||
* Used for "abstract plugins" to create the initial element object with the
|
||||
* given implemenation name and rebuild the form.
|
||||
* given implementation name and rebuild the form.
|
||||
*/
|
||||
function rules_ui_add_element_submit($form, &$form_state) {
|
||||
$element = rules_plugin_factory($form_state['plugin'], $form_state['values']['element_name']);
|
||||
@@ -348,7 +368,10 @@ function rules_ui_delete_element($form, &$form_state, $rules_config, $rules_elem
|
||||
}
|
||||
}
|
||||
|
||||
$confirm_question = t('Are you sure you want to delete the %element_plugin %element_name?', array('%element_plugin' => $rules_element->plugin(), '%element_name' => $rules_element->label(), '%plugin' => $rules_config->plugin(), '%label' => $rules_config->label()));
|
||||
$confirm_question = t('Are you sure you want to delete the %element_plugin %element_name?', array(
|
||||
'%element_plugin' => $rules_element->plugin(),
|
||||
'%element_name' => $rules_element->label(),
|
||||
));
|
||||
return confirm_form($form, $confirm_question, RulesPluginUI::path($rules_config->name), t('This action cannot be undone.'), t('Delete'), t('Cancel'));
|
||||
}
|
||||
|
||||
@@ -363,7 +386,6 @@ function rules_ui_delete_element_submit($form, &$form_state) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configure a rule element.
|
||||
*/
|
||||
@@ -487,7 +509,7 @@ function rules_ui_add_event_apply($form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Form to remove a event from a rule.
|
||||
* Form to remove an event from a rule.
|
||||
*/
|
||||
function rules_ui_remove_event($form, &$form_state, $rules_config, $event, $base_path) {
|
||||
RulesPluginUI::$basePath = $base_path;
|
||||
@@ -598,6 +620,7 @@ function rules_ui_import_form_submit($form, &$form_state) {
|
||||
|
||||
/**
|
||||
* FAPI process callback for the data selection widget.
|
||||
*
|
||||
* This finalises the auto completion callback path by appending the form build
|
||||
* id.
|
||||
*/
|
||||
@@ -657,12 +680,12 @@ function rules_ui_form_data_selection_auto_completion($parameter, $form_build_id
|
||||
drupal_json_output($matches);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* FAPI validation of an integer element. Copy of the private function
|
||||
* _element_validate_integer().
|
||||
* FAPI validation of an integer element.
|
||||
*
|
||||
* Copy of the core Drupal private function _element_validate_integer().
|
||||
*/
|
||||
function rules_ui_element_integer_validate($element, &$form_state) {;
|
||||
function rules_ui_element_integer_validate($element, &$form_state) {
|
||||
$value = $element['#value'];
|
||||
if (isset($value) && $value !== '' && (!is_numeric($value) || intval($value) != $value)) {
|
||||
form_error($element, t('%name must be an integer value.', array('%name' => isset($element['#title']) ? $element['#title'] : t('Element'))));
|
||||
@@ -670,8 +693,9 @@ function rules_ui_element_integer_validate($element, &$form_state) {;
|
||||
}
|
||||
|
||||
/**
|
||||
* FAPI validation of a decimal element. Improved version of the private
|
||||
* function _element_validate_number().
|
||||
* FAPI validation of a decimal element.
|
||||
*
|
||||
* Improved version of the private function _element_validate_number().
|
||||
*/
|
||||
function rules_ui_element_decimal_validate($element, &$form_state) {
|
||||
// Substitute the decimal separator ",".
|
||||
@@ -695,9 +719,11 @@ function rules_ui_element_ip_address_validate($element, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* FAPI validation of a date element. Makes sure the specified date format is
|
||||
* correct and converts date values specifiy a fixed (= non relative) date to
|
||||
* a timestamp. Relative dates are handled by the date input evaluator.
|
||||
* FAPI validation of a date element.
|
||||
*
|
||||
* Makes sure the specified date format is correct and converts date values
|
||||
* specify a fixed (= non relative) date to a timestamp. Relative dates are
|
||||
* handled by the date input evaluator.
|
||||
*/
|
||||
function rules_ui_element_date_validate($element, &$form_state) {
|
||||
$value = $element['#value'];
|
||||
@@ -766,8 +792,9 @@ function rules_ui_element_duration_multipliers() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to determine the value for a rules duration form
|
||||
* element.
|
||||
* Helper function a rules duration form element.
|
||||
*
|
||||
* Determines the value for a rules duration form element.
|
||||
*/
|
||||
function rules_ui_element_duration_value($element, $input = FALSE) {
|
||||
// This runs before child elements are processed, so we cannot calculate the
|
||||
@@ -781,6 +808,7 @@ function rules_ui_element_duration_value($element, $input = FALSE) {
|
||||
|
||||
/**
|
||||
* FAPI after build callback for the duration parameter type form.
|
||||
*
|
||||
* Fixes up the form value by applying the multiplier.
|
||||
*/
|
||||
function rules_ui_element_duration_after_build($element, &$form_state) {
|
||||
@@ -810,7 +838,6 @@ function rules_ui_element_fix_empty_after_build($element, &$form_state) {
|
||||
return $element;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* FAPI after build callback for specifying a list of values.
|
||||
*
|
||||
@@ -877,6 +904,7 @@ function rules_ui_element_machine_name_validate($element, &$form_state) {
|
||||
|
||||
/**
|
||||
* FAPI callback to validate the form for editing variable info.
|
||||
*
|
||||
* @see RulesPluginUI::getVariableForm()
|
||||
*/
|
||||
function rules_ui_element_variable_form_validate($elements, &$form_state) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file Contains UI for diverse plugins provided by Rules.
|
||||
* @file
|
||||
* Contains UI for diverse plugins provided by Rules.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -9,15 +10,21 @@
|
||||
*/
|
||||
class RulesRuleUI extends RulesActionContainerUI {
|
||||
|
||||
protected $rule, $conditions;
|
||||
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()) {
|
||||
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.
|
||||
@@ -58,7 +65,7 @@ class RulesRuleUI extends RulesActionContainerUI {
|
||||
/**
|
||||
* Applies the values of the form to the rule configuration.
|
||||
*/
|
||||
function form_extract_values($form, &$form_state) {
|
||||
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'])) {
|
||||
@@ -70,13 +77,13 @@ class RulesRuleUI extends RulesActionContainerUI {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +91,7 @@ class RulesRuleUI extends RulesActionContainerUI {
|
||||
*/
|
||||
class RulesReactionRuleUI extends RulesRuleUI {
|
||||
|
||||
public function form(&$form, &$form_state, $options = array()) {
|
||||
public function form(&$form, &$form_state, $options = array(), $iterator = NULL) {
|
||||
$form['events'] = array(
|
||||
'#type' => 'container',
|
||||
'#weight' => -10,
|
||||
@@ -94,7 +101,7 @@ class RulesReactionRuleUI extends RulesRuleUI {
|
||||
$form['events']['table'] = array(
|
||||
'#theme' => 'table',
|
||||
'#caption' => 'Events',
|
||||
'#header' => array('Event', 'Operations'),
|
||||
'#header' => array(t('Event'), t('Operations')),
|
||||
'#empty' => t('None'),
|
||||
);
|
||||
$form['events']['table']['#attributes']['class'][] = 'rules-elements-table';
|
||||
@@ -170,6 +177,7 @@ class RulesReactionRuleUI extends RulesRuleUI {
|
||||
$this->rule->active = $form_values['active'];
|
||||
$this->rule->weight = $form_values['weight'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,6 +194,7 @@ class RulesRuleSetUI extends RulesActionContainerUI {
|
||||
$form['elements']['#attributes']['class'][] = 'rules-rule-set';
|
||||
$form['elements']['#caption'] = t('Rules');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,7 +202,7 @@ class RulesRuleSetUI extends RulesActionContainerUI {
|
||||
*/
|
||||
class RulesLoopUI extends RulesActionContainerUI {
|
||||
|
||||
public function form(&$form, &$form_state, $options = array()) {
|
||||
public function form(&$form, &$form_state, $options = array(), $iterator = NULL) {
|
||||
parent::form($form, $form_state, $options);
|
||||
$settings = $this->element->settings;
|
||||
|
||||
@@ -219,7 +228,7 @@ class RulesLoopUI extends RulesActionContainerUI {
|
||||
);
|
||||
}
|
||||
|
||||
function form_extract_values($form, &$form_state) {
|
||||
public function form_extract_values($form, &$form_state) {
|
||||
parent::form_extract_values($form, $form_state);
|
||||
$form_values = RulesPluginUI::getFormStateValues($form, $form_state);
|
||||
|
||||
@@ -251,4 +260,5 @@ class RulesLoopUI extends RulesActionContainerUI {
|
||||
);
|
||||
return $content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file Rules theme functions
|
||||
* @file
|
||||
* Rules theme functions.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Themes a tree of rule elements in a draggable table.
|
||||
*
|
||||
@@ -58,13 +58,20 @@ function theme_rules_elements($variables) {
|
||||
* Themes the rules form for editing the used variables.
|
||||
*
|
||||
* @see RulesPluginUI::getVariableForm()
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_rules_ui_variable_form($variables) {
|
||||
$elements = $variables['element'];
|
||||
|
||||
$table['#theme'] = 'table';
|
||||
$table['#header'] = array(t('Data type'), t('Label'), t('Machine name'), t('Usage'), array('data' => t('Weight'), 'class' => array('tabledrag-hide')));
|
||||
$table['#header'] = array(
|
||||
t('Data type'),
|
||||
t('Label'),
|
||||
t('Machine name'),
|
||||
t('Usage'),
|
||||
array('data' => t('Weight'), 'class' => array('tabledrag-hide')),
|
||||
);
|
||||
$table['#attributes']['id'] = 'rules-' . drupal_html_id($elements['#title']) . '-id';
|
||||
|
||||
foreach (element_children($elements['items']) as $key) {
|
||||
@@ -107,6 +114,7 @@ function theme_rules_ui_variable_form($variables) {
|
||||
|
||||
/**
|
||||
* Themes a view of multiple configuration items.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_rules_content_group($variables) {
|
||||
@@ -125,6 +133,7 @@ function theme_rules_content_group($variables) {
|
||||
|
||||
/**
|
||||
* Themes the view of a single parameter configuration.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_rules_parameter_configuration($variables) {
|
||||
@@ -149,6 +158,7 @@ function theme_rules_parameter_configuration($variables) {
|
||||
|
||||
/**
|
||||
* Themes info about variables.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_rules_variable_view($variables) {
|
||||
@@ -169,6 +179,7 @@ function theme_rules_variable_view($variables) {
|
||||
|
||||
/**
|
||||
* Themes help for using the data selector.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_rules_data_selector_help($variables) {
|
||||
@@ -193,13 +204,18 @@ function theme_rules_data_selector_help($variables) {
|
||||
);
|
||||
foreach (RulesData::matchingDataSelector($variables_info, $param_info) as $selector => $info) {
|
||||
$info += array('label' => '', 'description' => '');
|
||||
$render['table']['#rows'][] = array(check_plain($selector), check_plain(drupal_ucfirst($info['label'])), check_plain($info['description']));
|
||||
$render['table']['#rows'][] = array(
|
||||
check_plain($selector),
|
||||
check_plain(drupal_ucfirst($info['label'])),
|
||||
check_plain($info['description']),
|
||||
);
|
||||
}
|
||||
return drupal_render($render);
|
||||
}
|
||||
|
||||
/**
|
||||
* Themes the rules log debug output.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_rules_log($variables) {
|
||||
@@ -230,6 +246,7 @@ function theme_rules_log($variables) {
|
||||
|
||||
/**
|
||||
* Theme rules debug log elements.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_rules_debug_element($variables) {
|
||||
@@ -248,6 +265,7 @@ function theme_rules_debug_element($variables) {
|
||||
|
||||
/**
|
||||
* Themes rules autocomplete forms.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_rules_autocomplete($variables) {
|
||||
@@ -278,6 +296,7 @@ function theme_rules_autocomplete($variables) {
|
||||
|
||||
/**
|
||||
* General theme function for displaying settings related help.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_rules_settings_help($variables) {
|
||||
|
||||
Reference in New Issue
Block a user