LimeSurvey API - Master branch

em_core_helper.php

LimeSurvey Copyright (C) 2007-2013 The LimeSurvey Project Team / Carsten Schmitz All rights reserved.

License: GNU/GPL License v2 or later, see LICENSE.php LimeSurvey is free software. This version may have been modified pursuant to the GNU General Public License, and as distributed it includes or is derivative of works licensed under the GNU General Public License or other free or open source software licenses. See COPYRIGHT.php for copyright notices and details.

Table of Contents

Classes

ExpressionManager
Description of ExpressionManager (1) Does safe evaluation of PHP expressions. Only registered Functions, and known Variables are allowed.

Functions

cmpErrorTokens()  : int
Used by usort() to order Error tokens by their position within the string This must be outside of the class in order to work in PHP 5.2
cmpWarningTokens()  : int
exprmgr_count()  : int
Count the number of answered questions (non-empty)
exprmgr_countif()  : int
Count the number of answered questions (non-empty) which match the first argument
exprmgr_countifop()  : int
Count the number of answered questions (non-empty) which meet the criteria (arg op value)
exprmgr_stripos()  : int|false
Find position of first occurrence of unicode string in a unicode string, case insensitive
exprmgr_stristr()  : string|false
Finds first occurrence of a unicode string within another, case-insensitive
exprmgr_strlen()  : int
Get unicode string length
exprmgr_strpos()  : int|false
Find position of first occurrence of unicode string in a unicode string
exprmgr_strstr()  : string|false
Finds first occurrence of a unicode string within another
exprmgr_strtolower()  : string
Make an unicode string lowercase
exprmgr_strtoupper()  : string
Make an unicode string uppercase
exprmgr_substr()  : string
Get part of unicode string
exprmgr_sumifop()  : int
Sum of values of answered questions which meet the criteria (arg op value)
exprmgr_checkdate()  : bool
Validate a Gregorian date
exprmgr_convert_value()  : int|null
Find the closest matching Numerical input values in a list an replace it by the corresponding value within another list
exprmgr_date()  : string|false
Return format a local time/date Need to test if timestamp is numeric (else E_WARNING with debug>0)
exprmgr_abs()  : mixed
exprmgr_if()  : mixed
If $test is true, return $iftrue, else return $iffalse
exprmgr_int()  : int
Return true if the variable is an integer for LimeSurvey Allow usage of numeric answercode as int Can not use is_int due to SQL DECIMAL system.
exprmgr_list()  : string
Join together $args[0-N] with ', '
exprmgr_listifop()  : string
Implementation of listifop( $cmpAttr, $op, $value, $retAttr, $glue, $sgqa1, ..., sgqaN ) Return a list of retAttr from sgqa1...sgqaN which pass the critiera (cmpAttr op value)
exprmgr_log()  : float
return log($arg[0],$arg[1]=e)
exprmgr_mktime()  : int|bool
Get Unix timestamp for a date : false if parameters is invalid.
exprmgr_join()  : string
Join together $args[N]
exprmgr_implode()  : string
Join together $args[1-N] with $arg[0]
exprmgr_empty()  : bool
Return true if the variable is NULL or blank.
exprmgr_stddev()  : float
Compute the Sample Standard Deviation of a set of numbers ($args[0-N])
expr_mgr_htmlspecialchars()  : string
Javascript equivalent does not cope well with ENT_QUOTES and related PHP constants, so set default to ENT_QUOTES
expr_mgr_htmlspecialchars_decode()  : string
Javascript equivalent does not cope well with ENT_QUOTES and related PHP constants, so set default to ENT_QUOTES
exprmgr_regexMatch()  : bool
Return true if $input matches the regular expression $pattern
geterrors_exprmgr_regexMatch()  : string|null
Return error information from pattern of regular expression $pattern
exprmgr_fixnum()  : string
Display number with comma as radix separator, if needed
exprmgr_unique()  : bool
Returns true if all non-empty values are unique

Functions

cmpErrorTokens()

Used by usort() to order Error tokens by their position within the string This must be outside of the class in order to work in PHP 5.2

cmpErrorTokens(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
$a : array<string|int, mixed>
$b : array<string|int, mixed>
Return values
int

exprmgr_count()

Count the number of answered questions (non-empty)

exprmgr_count(array<string|int, mixed> $args) : int
Parameters
$args : array<string|int, mixed>
Return values
int

exprmgr_countif()

Count the number of answered questions (non-empty) which match the first argument

exprmgr_countif(array<string|int, mixed> $args) : int
Parameters
$args : array<string|int, mixed>
Return values
int

exprmgr_countifop()

Count the number of answered questions (non-empty) which meet the criteria (arg op value)

exprmgr_countifop(array<string|int, mixed> $args) : int
Parameters
$args : array<string|int, mixed>
Return values
int

exprmgr_stripos()

Find position of first occurrence of unicode string in a unicode string, case insensitive

exprmgr_stripos(string $haystack, string $needle[,  $offset = 0 ]) : int|false
Parameters
$haystack : string

: checked string

$needle : string

: string to find

$offset : = 0

: offset

Return values
int|false

: position or false if not found

exprmgr_stristr()

Finds first occurrence of a unicode string within another, case-insensitive

exprmgr_stristr(string $haystack, string $needle[, bool $before_needle = false ]) : string|false
Parameters
$haystack : string

: checked string

$needle : string

: string to find

$before_needle : bool = false

: portion to return

Return values
string|false

exprmgr_strlen()

Get unicode string length

exprmgr_strlen(string $string) : int
Parameters
$string : string
Return values
int

exprmgr_strpos()

Find position of first occurrence of unicode string in a unicode string

exprmgr_strpos(string $haystack, string $needle[, int $offset = 0 ]) : int|false
Parameters
$haystack : string

: checked string

$needle : string

: string to find

$offset : int = 0

: offset

Return values
int|false

: position or false if not found

exprmgr_strstr()

Finds first occurrence of a unicode string within another

exprmgr_strstr(string $haystack, string $needle[, bool $before_needle = false ]) : string|false
Parameters
$haystack : string

: checked string

$needle : string

: string to find

$before_needle : bool = false

: portion to return

Return values
string|false

exprmgr_strtolower()

Make an unicode string lowercase

exprmgr_strtolower(string $string) : string
Parameters
$string : string
Return values
string

exprmgr_strtoupper()

Make an unicode string uppercase

exprmgr_strtoupper(string $string) : string
Parameters
$string : string
Return values
string

exprmgr_substr()

Get part of unicode string

exprmgr_substr(string $string, int $start[, int $end = null ]) : string
Parameters
$string : string
$start : int
$end : int = null
Return values
string

exprmgr_sumifop()

Sum of values of answered questions which meet the criteria (arg op value)

exprmgr_sumifop(array<string|int, mixed> $args) : int
Parameters
$args : array<string|int, mixed>
Return values
int

exprmgr_checkdate()

Validate a Gregorian date

exprmgr_checkdate(mixed $month, mixed $day, mixed $year) : bool
Parameters
$month : mixed
$day : mixed
$year : mixed
Tags
see
https://www.php.net/checkdate

Check if all params are valid before send it to PHP checkdate to avoid PHP Warning

Return values
bool

exprmgr_convert_value()

Find the closest matching Numerical input values in a list an replace it by the corresponding value within another list

exprmgr_convert_value(float $fValueToReplace, int $iStrict, string $sTranslateFromList, string $sTranslateToList) : int|null
Parameters
$fValueToReplace : float
$iStrict : int
  • 1 for exact matches only otherwise interpolation the closest value should be returned
$sTranslateFromList : string
  • comma seperated list of numeric values to translate from
$sTranslateToList : string
  • comma seperated list of numeric values to translate to
Tags
author

Johannes Weberhofer, 2013

Return values
int|null

exprmgr_date()

Return format a local time/date Need to test if timestamp is numeric (else E_WARNING with debug>0)

exprmgr_date(string $format[, int $timestamp = null ]) : string|false
Parameters
$format : string
$timestamp : int = null
Tags
link
http://php.net/function.date.php
Return values
string|false

exprmgr_abs()

exprmgr_abs(mixed $num) : mixed
Parameters
$num : mixed

exprmgr_if()

If $test is true, return $iftrue, else return $iffalse

exprmgr_if(mixed $testDone, mixed $iftrue[, mixed $iffalse = '' ]) : mixed
Parameters
$testDone : mixed
$iftrue : mixed
$iffalse : mixed = ''

exprmgr_int()

Return true if the variable is an integer for LimeSurvey Allow usage of numeric answercode as int Can not use is_int due to SQL DECIMAL system.

exprmgr_int(string $arg) : int
Parameters
$arg : string
Tags
link
http://php.net/is_int#82857
Return values
int

exprmgr_list()

Join together $args[0-N] with ', '

exprmgr_list(array<string|int, mixed> $args) : string
Parameters
$args : array<string|int, mixed>
Return values
string

exprmgr_listifop()

Implementation of listifop( $cmpAttr, $op, $value, $retAttr, $glue, $sgqa1, ..., sgqaN ) Return a list of retAttr from sgqa1...sgqaN which pass the critiera (cmpAttr op value)

exprmgr_listifop(array<string|int, mixed> $args) : string
Parameters
$args : array<string|int, mixed>
Return values
string

exprmgr_log()

return log($arg[0],$arg[1]=e)

exprmgr_log(array<string|int, mixed> $args) : float
Parameters
$args : array<string|int, mixed>
Return values
float

exprmgr_mktime()

Get Unix timestamp for a date : false if parameters is invalid.

exprmgr_mktime([int $hour = null ][, int $minute = null ][, int $second = null ][, int $month = null ][, int $day = null ][, int $year = null ]) : int|bool

Get default value for unset (or null) value E_NOTICE if arguments are not numeric (debug>0), then test it before

Parameters
$hour : int = null
$minute : int = null
$second : int = null
$month : int = null
$day : int = null
$year : int = null
Return values
int|bool

exprmgr_join()

Join together $args[N]

exprmgr_join(array<string|int, mixed> $args) : string
Parameters
$args : array<string|int, mixed>
Return values
string

exprmgr_implode()

Join together $args[1-N] with $arg[0]

exprmgr_implode(array<string|int, mixed> $args) : string
Parameters
$args : array<string|int, mixed>
Return values
string

exprmgr_empty()

Return true if the variable is NULL or blank.

exprmgr_empty(null|string|bool $arg) : bool
Parameters
$arg : null|string|bool
Return values
bool

exprmgr_stddev()

Compute the Sample Standard Deviation of a set of numbers ($args[0-N])

exprmgr_stddev(array<string|int, mixed> $args) : float
Parameters
$args : array<string|int, mixed>
Return values
float

expr_mgr_htmlspecialchars()

Javascript equivalent does not cope well with ENT_QUOTES and related PHP constants, so set default to ENT_QUOTES

expr_mgr_htmlspecialchars(string $string) : string
Parameters
$string : string
Return values
string

expr_mgr_htmlspecialchars_decode()

Javascript equivalent does not cope well with ENT_QUOTES and related PHP constants, so set default to ENT_QUOTES

expr_mgr_htmlspecialchars_decode(string $string) : string
Parameters
$string : string
Return values
string

exprmgr_regexMatch()

Return true if $input matches the regular expression $pattern

exprmgr_regexMatch(string $pattern, string $input) : bool
Parameters
$pattern : string
$input : string
Return values
bool

geterrors_exprmgr_regexMatch()

Return error information from pattern of regular expression $pattern

geterrors_exprmgr_regexMatch(string $pattern, string $input) : string|null
Parameters
$pattern : string
$input : string
Return values
string|null

exprmgr_fixnum()

Display number with comma as radix separator, if needed

exprmgr_fixnum(string $value) : string
Parameters
$value : string
Return values
string

exprmgr_unique()

Returns true if all non-empty values are unique

exprmgr_unique(array<string|int, mixed> $args) : bool
Parameters
$args : array<string|int, mixed>
Return values
bool

        
On this page

Search results