Forums / Developer / PHPOperators accept only ONE argument. Make them accept more than one

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

PHPOperators accept only ONE argument. Make them accept more than one

Author Message

Plamen Petkov

Saturday 01 May 2004 4:16:33 am

Suggesting the following code change:

--- lib/eztemplate/classes/eztemplatephpoperator.php.original Sat May 1 13:43:13 2004
+++ lib/eztemplate/classes/eztemplatephpoperator.php Sat May 1 19:30:39 2004
@@ -83,7 +83,16 @@
function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$value )
{
$phpname = $this->PHPNames[$operatorName];
- $value = $phpname( $value );
+ if ( ! is_array($value) )
+ $arguments = "\"$value\"";
+ else
+ {
+ $arguments_array = array();
+ while ( list($key,$val)=each($value) ) $arguments_array[]= "\"" . $val . "\"";
+ $arguments = implode($arguments_array,",");
+ }
+ $code = "\$value = $phpname($arguments);";
+ eval($code);
}

Usage Example ("random", "uniqueid", "explodearray" operators are registered in settings/override/template.ini):

{array(1,100)|random}

{array("ID_", true())|uniqueid}

{let test=array(",", "v1,v2,v3")|explodearray}
{$test[0] $test[1] $test[2]}
{/let}

Paul Forsyth

Saturday 01 May 2004 6:38:03 am

Lovely, yes this is needed.

Can you add this patch as a bug in the bug reports? It has a better chance of being accepted that way.

paul

--
http://www.visionwt.com