------------------------------------------------------------
revno: 1092
committer: Roger Martin <[email protected]>
branch nick: aikiframework
timestamp: Mon 2012-02-13 22:24:24 +0100
message:
  engineV8 support aikiScript and view markup
modified:
  libs/AikiScript.php
  libs/Engine_v8.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/AikiScript.php'
--- libs/AikiScript.php	2012-01-05 17:17:40 +0000
+++ libs/AikiScript.php	2012-02-13 21:24:24 +0000
@@ -50,20 +50,24 @@
 	/*
 	 * Parse over text
 	 * @param	string	$text	Input text
+	 * @param   boolean Searchin. If true, text have (script( markup, else is script.
 	 * @global	aiki	$aiki	global aiki instance
 	 * @return	string. Output text.
 	 */
-	public function parser($text) {
+	public function parser($text, $searchIn= true) {
 		global $aiki;
 
 		//$text = stripslashes($text);
-		
-		if (preg_match("/\<textarea.*((\<php |\(script\().*(\)script\)|php\>)).*\<\/textarea\>/Us", $text)) {
+		if ( $searchIn ) {
+			if (preg_match("/\<textarea.*((\<php |\(script\().*(\)script\)|php\>)).*\<\/textarea\>/Us", $text)) {
 			return $text;
+			}
+			// now, we will divided the text. The array is always
+			// out of marker, in of markers, out of markers, in of markers
+			$tokens= preg_split("/\(script\(|\)script\)|<php|php>/", $text);
+		} else {
+			$tokens = array("", $text); // shortcut for engines. @TODO Must be improved
 		}
-		// now, we will divided the text. The array is always
-		// out of marker, in of markers, out of markers, in of markers
-		$tokens= preg_split("/\(script\(|\)script\)|<php|php>/", $text);
 
 		$parsed = "";
 	   		
@@ -408,12 +412,14 @@
 	 * @return	string
 	 */
 	function getinfo($what) {
+		$aiki_revision = defined("AIKI_REVISION") ? AIKI_REVISION :"" ;
+
 		switch ($what) {
 			case "version":
 			case "hidden-version":
 				return ( $what=="version" ? 
 					AIKI_VERSION : "\n<!-- aikiframework version: ". AIKI_VERSION .
-						"." . AIKI_REVISION . " -->\n" );
+						".$aiki_revision -->\n" );
 			case "queries":
 			case "hidden-queries" :
 				global $db;

=== modified file 'libs/Engine_v8.php'
--- libs/Engine_v8.php	2012-02-12 22:43:23 +0000
+++ libs/Engine_v8.php	2012-02-13 21:24:24 +0000
@@ -268,49 +268,64 @@
 		global $aiki, $page;
 
 		if ( $bufferReplace == NULL ) {
+			/* @TODO unified with aiki processVars*/
 
 			$pretty = $aiki->config->get('pretty_urls', 1);
 			$url = $aiki->config->get('url');
+
+			$current_month = date("n");
+			$current_year = date("Y");
+			$current_day = date("j");
+
 			// calculate view, prefix, route
-			$view       = $aiki->site->view();
-			$language   = $aiki->site->language();
-			$prefix     = $aiki->site->prefix();
+			$view = $aiki->site->view();
+			$language = $aiki->site->language();
+			$prefix = $aiki->site->prefix();
 			$view_prefix= $aiki->site->view_prefix();
-			$paths[]    = $url;
-
+				
+			$paths= array();
 			if ($prefix) {
 				$paths[] = $prefix;
 			}
+
 			if ($view_prefix) {
 				$paths[] = $view_prefix;
 			}
 			if ( count($aiki->site->languages()) > 1 ) {
 				$paths[] = $language;
 			}
+			$paths = implode("/",$paths);
+			
+			if ( isset($_SERVER["HTTPS"])) {
+				$url = str_replace("http://";, "https://";, $url);
+			}	
 
+			$trimedUrl = preg_replace('#/$#',"",$url); // reg: remove ending /
+							
 			$bufferReplace = array(
-				'userid'	=> $aiki->membership->userid,
-				'full_name' => $aiki->membership->full_name,
-				'username'  => $aiki->membership->username,
-				'user_group_level' => $aiki->membership->group_level,
-				'user_permissions' => $aiki->membership->permissions,
-				'language'  => $aiki->site->language(),
-				'page'	  => $page,
-				'site_name' => $aiki->site->site_name(),
-				'site'	  => $aiki->site->get_site(),
-				'view'	  => $aiki->site->view(),
-				'direction' => $aiki->languages->dir,
-				'insertedby_username' => $aiki->membership->username,
-				'insertedby_userid' => $aiki->membership->userid,
-				'current_month' => date("n"),
-				'current_year' => date("Y"),
-				'current_day' => date("j"),
-				'root'		  => $url,
-				'root-language' => $url .  "/" . $aiki->site->language(),
-				'site_prefix'   => $prefix ,
-				'view_prefix'   => $view_prefix ,
-				'route'		 => implode("/",$paths) );
-		}
+				'[$userid]'	=> $aiki->membership->userid,
+				'[$full_name]' => $aiki->membership->full_name,
+				'[$username]'  => $aiki->membership->username,
+				'[$user_group_level]' => $aiki->membership->group_level,
+				'[$user_permissions]' => $aiki->membership->permissions,			
+				'[$language]'  => $aiki->site->language(),		   
+				'[$page]'	  => $page,
+				'[$site_name]' => $aiki->site->site_name(),
+				'[$site]'	  => $aiki->site->get_site(),
+				'[$view]'	  => $aiki->site->view(),
+				'[$direction]' => $aiki->languages->dir,
+				'[$insertedby_username]' => $aiki->membership->username,
+				'[$insertedby_userid]' => $aiki->membership->userid,
+				'[$current_month]' => $current_month,
+				'[$current_year]' => $current_year,
+				'[$current_day]' => $current_day,
+				'[$root]'		  => $url,
+				'[$root-language]' => $trimedUrl .  "/" . $aiki->site->language(),
+				'[$site_prefix]'   => $prefix ,
+				'[$view_prefix]'   => $view_prefix ,
+				'[$route]'		 => $trimedUrl.  "/". $paths,
+				'[$route-local]'	 => $paths );
+			}
 
 		$token = $match[1];
 		if ( isset($bufferReplace[$token]) ){
@@ -340,12 +355,9 @@
 		return  is_null($id) ? "": $db->get_var ("SELECT widget FROM aiki_widgets WHERE id='$id'" );
 	}
 
-	function parse_script($view){
-		/*
-		 * @TODO USE AikiScript!!!
-		 */
-		
-		return "SCRIPT..PARSED" ;
+	function parse_script($code){
+		global $aiki;
+		return $aiki->AikiScript->parser($code,false);
 	}
 
 
@@ -430,14 +442,20 @@
 
 
 	function parse_view( &$text){
+		global $aiki;
 		if ( strpos($text,"||") !== false ){
 			list($filter,$content) = explode("||", $text, 2);
+			if ($trim($filter)=="") {
+				return $text;
+			}
 		} else {
 			return $text;
 		}
-
-		//* fake filter
-		if ( $filter=="dark") {
+		
+		list($view,$language)= exlode("/",$filter."/*",2);
+	
+		if  ( match_pair_one( $view, $aiki->site->view()) &&
+		      match_pair_one( $language, $aiki->site->language() )){
 			return $content;
 		}
 		return "";

_______________________________________________
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