You are here

function rules_input_evaluator_php_help in Rules 6

Returns some help for the admin using the evaluator

Related topics

1 call to rules_input_evaluator_php_help()
rules_action_custom_php_form in rules/modules/php.rules_forms.inc
Execute custom php code action configuration form.

File

rules/modules/php.rules_forms.inc, line 14
Rules configuration forms for the php module

Code

function rules_input_evaluator_php_help($variables, $save_info = FALSE) {
  $output = '<p>' . t('PHP code inside of &lt;?php ?&gt; delimiters will be evaluated and replaced by its output. E.g. &lt;? echo 1+1?&gt; will be replaced by 2.');
  $output .= ' ' . t('Furthermore you can make use of the following variables:') . '</p>';
  $headers = array(
    t('Variable'),
    t('Type'),
    t('Description'),
  );
  if ($save_info) {
    $headers[] = t('Intelligent saving');
  }
  $rows = array();
  $data_types = rules_get_data_types();
  foreach ($variables as $name => $info) {
    $row = array();
    $row[] = '$' . check_plain($name);
    $row[] = check_plain($data_types[$info['type']]['label']);
    $row[] = check_plain($info['label']);
    if ($save_info) {
      $data_type = rules_get_data_object($info);
      if ($data_type
        ->is_savable()) {
        $row[] = t('Yes');
      }
      else {
        $row[] = t('No');
      }
    }
    $rows[] = $row;
  }
  $output .= theme('table', $headers, $rows, array(
    'class' => 'rules-php-help',
  ));
  if ($save_info) {
    $output .= '<p>' . t('Note that variables are passed by reference, so you can change them.') . ' ';
    $output .= t("If you want to make the changes permanent, you can let rules intelligently save the changes when the variable's data type supports it.") . ' ' . t('To make use of "intelligent saving" just return an array of variables to save, e.g.: !code So variables are saved only once, even if modified multiple times.', array(
      '!code' => '<pre>return array("node" => $node);</pre>',
    )) . '</p>';
  }
  return $output;
}