Skip to content

Commit

Permalink
Fixed issue #07236: Unable to concatenate number : join is undefined
Browse files Browse the repository at this point in the history
Dev: adding join($arg), alias of implode("",$arg)
  • Loading branch information
Shnoulle committed Feb 9, 2013
1 parent 586d0ec commit ac11270
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
13 changes: 13 additions & 0 deletions application/helpers/expressions/em_core_helper.php
Expand Up @@ -185,6 +185,7 @@ function __construct()
'is_null' => array('is_null', 'LEMis_null', $this->gT('Finds whether a variable is NULL'), 'bool is_null(var)', 'http://www.php.net/manual/en/function.is-null.php', 1),
'is_numeric' => array('is_numeric', 'LEMis_numeric', $this->gT('Finds whether a variable is a number or a numeric string'), 'bool is_numeric(var)', 'http://www.php.net/manual/en/function.is-numeric.php', 1),
'is_string' => array('is_string', 'LEMis_string', $this->gT('Find whether the type of a variable is string'), 'bool is_string(var)', 'http://www.php.net/manual/en/function.is-string.php', 1),
'join' => array('exprmgr_join', 'LEMjoin', $this->gT('Join strings, return joined string.This function is an alias of implode("",argN)'), 'string join(arg1,arg2,...,argN)', '', -1),
'list' => array('exprmgr_list', 'LEMlist', $this->gT('Return comma-separated list of values'), 'string list(arg1, arg2, ... argN)', '', -2),
'log' => array('log', 'Math.log', $this->gT('Natural logarithm'), 'number log(number)', 'http://www.php.net/manual/en/function.log.php', 1),
'ltrim' => array('ltrim', 'ltrim', $this->gT('Strip whitespace (or other characters) from the beginning of a string'), 'string ltrim(string [, charlist])', 'http://www.php.net/manual/en/function.ltrim.php', 1,2),
Expand Down Expand Up @@ -2726,6 +2727,8 @@ static function UnitTestEvaluator()
64~if((one < two),pow(2,6),pow(6,2))
H e l l o~implode(' ','H','e','l','l','o')
1|2|3|4|5~implode('|',one,two,three,four,five)
123~join(1,2,3)
123 5~join(one,2,three," ",five)
4~intval('4')
4~intval('100',2)
5~intval(5.7)
Expand Down Expand Up @@ -3378,6 +3381,16 @@ function exprmgr_list($args)
return $result;
}

/**
* Join together $args[N]
* @param <type> $args
* @return <type>
*/
function exprmgr_join($args)
{
return implode("",$args);
}

/**
* Join together $args[1-N] with $arg[0]
* @param <type> $args
Expand Down
30 changes: 28 additions & 2 deletions scripts/expressions/em_javascript.js
@@ -1,5 +1,19 @@
/* Core JavaScript functions needed by ExpressionManager
/*
* Core JavaScript functions needed by ExpressionManager
* @author Thomas M. White (TMSWhite)
* @author Denis Chenu (Shnoulle)
* Portion from php.js is copyright 2012 Kevin van Zonneveld.
* php.js is dual licensed under the MIT licenses.
*
* This file is part of 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.
*/

function LEMcount()
Expand Down Expand Up @@ -209,6 +223,18 @@ function LEMlist()
return result;
}

/**
* Returns concatenates list
*/
function LEMjoin()
{
var result="";
for (i=0;i<arguments.length;++i) {
result += arguments[i];
}
return result;
}

/**
* Returns concatenates list with first argument as the separator
*/
Expand Down Expand Up @@ -2510,4 +2536,4 @@ function time () {
// * example 1: timeStamp = time();
// * results 1: timeStamp > 1000000000 && timeStamp < 2000000000
return Math.floor(new Date().getTime() / 1000);
}
}

0 comments on commit ac11270

Please sign in to comment.