function ctools_math_expr::__construct
Public constructor.
File
-
includes/
math-expr.inc, line 144
Class
- ctools_math_expr
- ctools_math_expr Class.
Code
public function __construct() {
$this->userfuncs = array();
$this->simplefuncs = array(
'sin',
'sinh',
'asin',
'asinh',
'cos',
'cosh',
'acos',
'acosh',
'tan',
'tanh',
'atan',
'atanh',
'exp',
'sqrt',
'abs',
'log',
'ceil',
'floor',
'round',
);
$this->ops = array(
'+' => array(
'precedence' => 0,
),
'-' => array(
'precedence' => 0,
),
'*' => array(
'precedence' => 1,
),
'/' => array(
'precedence' => 1,
),
'^' => array(
'precedence' => 2,
'right' => TRUE,
),
'_' => array(
'precedence' => 1,
),
'==' => array(
'precedence' => -1,
),
'!=' => array(
'precedence' => -1,
),
'>=' => array(
'precedence' => -1,
),
'<=' => array(
'precedence' => -1,
),
'>' => array(
'precedence' => -1,
),
'<' => array(
'precedence' => -1,
),
);
$this->binaryops = array(
'+',
'-',
'*',
'/',
'^',
'==',
'!=',
'<',
'<=',
'>=',
'>',
);
$this->funcs = array(
'ln' => array(
'function' => 'log',
'arguments' => 1,
),
'arcsin' => array(
'function' => 'asin',
'arguments' => 1,
),
'arcsinh' => array(
'function' => 'asinh',
'arguments' => 1,
),
'arccos' => array(
'function' => 'acos',
'arguments' => 1,
),
'arccosh' => array(
'function' => 'acosh',
'arguments' => 1,
),
'arctan' => array(
'function' => 'atan',
'arguments' => 1,
),
'arctanh' => array(
'function' => 'atanh',
'arguments' => 1,
),
'min' => array(
'function' => 'min',
'arguments' => 2,
'max arguments' => 99,
),
'max' => array(
'function' => 'max',
'arguments' => 2,
'max arguments' => 99,
),
'pow' => array(
'function' => 'pow',
'arguments' => 2,
),
'if' => array(
'function' => 'ctools_math_expr_if',
'arguments' => 2,
'max arguments' => 3,
),
'number' => array(
'function' => 'ctools_math_expr_number',
'arguments' => 1,
),
'time' => array(
'function' => 'time',
'arguments' => 0,
),
);
// Allow modules to add custom functions.
$context = array(
'final' => &$this->funcs,
);
drupal_alter('ctools_math_expression_functions', $this->simplefuncs, $context);
// Set up the initial constants and mark them read-only.
$this->vars = array(
'e' => exp(1),
'pi' => pi(),
);
drupal_alter('ctools_math_expression_constants', $this->vars);
$this->constvars = array_keys($this->vars);
// Translate the older, simpler style into the newer, richer style.
foreach ($this->simplefuncs as $function) {
$this->funcs[$function] = array(
'function' => $function,
'arguments' => 1,
);
}
}