------------------------------------------------------------
revno: 1158
committer: Jakub Jankiewicz <[email protected]>
branch nick: aikiframework
timestamp: Wed 2012-04-04 22:03:00 +0200
message:
Fix custom constants
modified:
libs/aiki.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/aiki.php'
--- libs/aiki.php 2012-04-04 19:09:23 +0000
+++ libs/aiki.php 2012-04-04 20:03:00 +0000
@@ -482,20 +482,26 @@
$text = preg_replace('#\[(GET|POST)\[.*\]\]#U', "", $text );
// custom [vars]
- if (preg_match_all("/\[([^\]]+)\]/", $text, $mached_vars)) {
+ if (preg_match_all("/\[([^\]]+)\](?!-)/", $text, $mached_vars)) {
$rgx = '/\$aiki\-\>(.*)\-\>(.*)\((.*?)\)\;?/Us';
foreach($mached_vars[1] as $var) {
+ if (!preg_match("/^[A-Za-z0-9_]+$/", $var)) {
+ continue;
+ }
$value = $aiki->config->get($var, null);
//value is function invocation
if (preg_match($rgx, $value, $mached_value)) {
$class = $mached_value[1];
- $method = array($aiki->$class, $mached_value[2]);
- $args = $aiki->AikiScript->mtoken($mached_value[3]);
- $value = call_user_func_array($method, $args);
- }
- if ($value !== null) {
- $text = preg_replace('/\[' . $var . '\]/', $value, $text);
- }
+ $function = $mached_value[2];
+ if ($mached_value[3] == '') {
+ $value = $aiki->$class->$function();
+ } else {
+ $method = array($aiki->$class, $function);
+ $args = $aiki->AikiScript->mtoken($mached_value[3]);
+ $value = call_user_func_array($method, $args);
+ }
+ }
+ $text = preg_replace('/\[' . $var . '\]/', $value, $text);
}
}
_______________________________________________
Mailing list: https://launchpad.net/~aikiframework-devel
Post to : [email protected]
Unsubscribe : https://launchpad.net/~aikiframework-devel
More help : https://help.launchpad.net/ListHelp