------------------------------------------------------------
revno: 1177
committer: Roger Martin <[email protected]>
branch nick: aikiframework
timestamp: Wed 2012-04-25 18:45:16 +0200
message:
parameters accepts function in as other functions parameters
modified:
libs/markup.php
--
lp:aikiframework
https://code.launchpad.net/~aikiframework-devel/aikiframework/trunk
Your team Aiki Framework Developers is subscribed to branch lp:aikiframework.
To unsubscribe from this branch go to
https://code.launchpad.net/~aikiframework-devel/aikiframework/trunk/+edit-subscription
=== modified file 'libs/markup.php'
--- libs/markup.php 2012-03-29 21:18:15 +0000
+++ libs/markup.php 2012-04-25 16:45:16 +0000
@@ -22,8 +22,6 @@
*/
if (!defined('IN_AIKI')) {
-
-
die('No direct script access allowed');
}
@@ -193,7 +191,6 @@
function extract_parameters( $string, $delimiter=',') {
-
$state= 0;
$current= false;
$end = false;
@@ -206,7 +203,7 @@
// 1 over a delimited with ' string
// 2 over a delimited with " string
// 3 over a structur begine with { or )
- // a non delimited string.
+ // 4 a non delimited string.
$prev="";
$i=0;
@@ -247,8 +244,21 @@
break;
- // a begin
- case '{':
+ // a function call?
+ case '(':
+ if ($state==4 ) { // a function call
+ $eval = extract_parameters( substr($string,$i+1) );
+ $string= $eval[1];
+ $i=0;
+ $max= strlen($string);
+ $state=0;
+ $ret[] = eval_expression( "$current(". implode(",",$eval[0]) .")");
+ $current=false;
+ }
+ break;
+
+ // array begining
+ case '{':
if ($state==0 ) {
$eval = extract_parameters( substr($string,$i+1) );
$string= $eval[1];
@@ -462,28 +472,27 @@
if ( is_null($functions) ){
// aiki recognize this functions and their alias.
$functions = array(
+ "match" => "preg_match",
+ "md5" => "md5",
+ "preg_match" => "preg_match",
+ "lower" => "strtolower",
"search" => "stripos",
+ "sha1" => "sha1",
"stripos" => "stripos",
"striptags" => "strip_tags",
- "strip_tags" => "strip_tags",
- "replace" => "str_replace",
- "str_replace"=> "str_replace",
- "lower" => "strtolower",
- "upper" => "strtoupper",
+ "strip_tags" => "strip_tags",
+ "str_replace"=> "str_replace",
"strtolower" => "strtolower",
"strtoupper" => "strtoupper",
- "trim" => "trim",
- "md5" => "md5",
- "sha1" => "sha1",
- "match" => "preg_match",
- "preg_match" => "preg_match",
"substr" => "substr",
+ "replace" => "str_replace",
+ "trim" => "trim",
+ "upper" => "strtoupper",
"urlencode" => "urlencode",
"urldecode" => "urldecode"
);
$func_regex = implode("|",array_keys($functions));
}
-
$matches = 0;
$operators= "\.\+\-\\/%\*=<>!&\|"; //quoted operators
@@ -571,13 +580,15 @@
return eval_expression ( "{$matches[1]}$op1{$matches[3]}");
// check if it's function
- } elseif (preg_match("/^({$func_regex})\((.*)\$/s", $expr, $matches)) {
- $para = extract_parameters($matches[2]);
+ } elseif (preg_match("/^({$func_regex})\((.*)\$/s", $expr, $matches)) {
+ $para = extract_parameters($matches[2]);
$value = call_user_func_array ( $functions[$matches[1]], $para[0]) ;
+
if ( !$para[1] ) {
// after functions is nothing.
return $value;
}
+
return eval_expression ( encode_expression($value).$para[1] );
_______________________________________________
Mailing list: https://launchpad.net/~aikiframework-devel
Post to : [email protected]
Unsubscribe : https://launchpad.net/~aikiframework-devel
More help : https://help.launchpad.net/ListHelp