------------------------------------------------------------
revno: 922
committer: Roger Martin <[email protected]>
branch nick: aikiframework
timestamp: Mon 2011-10-24 11:39:54 +0200
message:
outer_markup added to aiki object
modified:
src/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 'src/libs/aiki.php'
--- src/libs/aiki.php 2011-10-21 14:23:18 +0000
+++ src/libs/aiki.php 2011-10-24 09:39:54 +0000
@@ -279,6 +279,55 @@
return false;
}
+ /**
+ * Search first outest block in a text.
+ * Example:
+ * outest block of ( (css((sql(good)sql))css) .. " is (css((sql(good)sql))css)";
+ *
+ * @param string $string
+ * @param string $offset
+ *
+ * @return mixed false if not found or array with 0:initial,1:lenght
+ * 2 delim
+ */
+
+ function outer_markup ( $string , $offset=0 ){
+ $i= 64; //max level of recursion.
+ $delim= "";
+
+ $temp ="";
+ if ( preg_match ('/\(([a-z]+)\(/U', $string, $temp) ){
+ $delim = $temp[1];
+ $startDelim ="($delim(";
+ $endDelim =")$delim)";
+ $temp = "";
+ } else {
+ return false;
+ }
+
+ $initial = strpos ($string, $startDelim, $offset);
+ if ( $initial === false ) {
+ return false;
+ }
+
+ $end = $initial;
+ $nested = $initial;
+
+ do {
+
+ $nested = strpos($string, $startDelim, $nested+1);
+ $end = strpos($string, $endDelim, $end+1);
+ if ( $end === false )
+ return false;
+ if ( $nested === false || $nested > $end ){
+ return array($initial, $end-$initial,$delim);
+ }
+
+ $i--;
+ } while ($i);
+ return false;
+ }
+
/**
* Eval a expression thats contains basic operators (+,-*,/),
@@ -424,4 +473,4 @@
} // end of processVars method
} // end of aiki class
-?>
\ No newline at end of file
+?>
_______________________________________________
Mailing list: https://launchpad.net/~aikiframework-devel
Post to : [email protected]
Unsubscribe : https://launchpad.net/~aikiframework-devel
More help : https://help.launchpad.net/ListHelp