------------------------------------------------------------
revno: 1142
committer: Roger Martin <[email protected]>
branch nick: aikiframework
timestamp: Wed 2012-03-14 22:46:05 +0100
message:
  fixed nested (sql
modified:
  libs/SqlMarkup.php
  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/SqlMarkup.php'
--- libs/SqlMarkup.php	2012-03-13 22:46:15 +0000
+++ libs/SqlMarkup.php	2012-03-14 21:46:05 +0000
@@ -41,12 +41,14 @@
 	 *
 	 * @todo need a serious security review
 	 */
-	public function sql($text) {	
-		$pattern = '/\(sql\((.*)\)sql\)/s';
-		
+	public function sql($text) {			
+		global $aiki;
 		// in each step replace the outer (sql(..)sql)
-		while ( preg_match( $pattern, $text) ){
-			$text= preg_replace_callback($pattern, array($this,"sql_query"), $text);
+		while ( $position = $aiki->outer_markup ($text,0,"sql" )){
+			$text = str_replace(
+				substr($text, $position[0],$position[1]+5),
+			    $this->sql_query(substr($text, $position[0]+5,$position[1]-5) ),
+			    $text);
 	    }
 	    return $text;		 
 	}
@@ -68,7 +70,7 @@
 			$check= $matchRaw;
 		}
 						
-		if ( !preg_match_all('/\((((?>[^()]+)|(?R))*)\)/', $check, $matches) ){
+		if ( !preg_match_all('/\((((?>[^()]+)|(?R))*)\)/s', $check, $matches) ){
 			return $check;		
 		}
 		
@@ -115,6 +117,7 @@
 				}// if results
 			} // if query		
 		} // loop
+				
 		return $output;
 	} // end of function
 } // end of class

=== modified file 'libs/aiki.php'
--- libs/aiki.php	2012-03-08 15:55:32 +0000
+++ libs/aiki.php	2012-03-14 21:46:05 +0000
@@ -296,12 +296,12 @@
 	 *                2 delim
 	 */
 		
-	function outer_markup($string, $offset=0 ){
+	function outer_markup($string, $offset=0, $tag="[a-z_]*" ){
         $i = 64; //max level of recursion.
         $delim = "";
         
 		$temp = "";
-		if (preg_match('/\(([a-z_]*)\(/U', $string, $temp)) {
+		if (preg_match("/\(($tag)\(/U", $string, $temp)) {
 			$delim = $temp[1];
 			$startDelim = "($delim(";
 			$endDelim = ")$delim)";

_______________________________________________
Mailing list: https://launchpad.net/~aikiframework-devel
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~aikiframework-devel
More help   : https://help.launchpad.net/ListHelp

Reply via email to