------------------------------------------------------------
revno: 1154
committer: Roger Martin <[email protected]>
branch nick: aikiframework
timestamp: Thu 2012-03-29 23:18:15 +0200
message:
  parse template and widgets added to enginev2
modified:
  libs/Engine_v2.php
  libs/markup.php
  tests/engines/engineV2.sql
  tests/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/Engine_v2.php'
--- libs/Engine_v2.php	2012-03-28 20:28:55 +0000
+++ libs/Engine_v2.php	2012-03-29 21:18:15 +0000
@@ -75,7 +75,7 @@
 		$this->markup_codes    = aiki_get_markup_codes ($markup ) ;
 
 		// must convert widgets?
-		if  (isset($parmameter['convert-widgets'] )) {
+		if  (isset($parameters['convert-widgets'] )) {
 			$this->convert_widgets = 1;
 			$this->markup          = 'aiki';
 		}
@@ -85,7 +85,6 @@
 		$this->parsers = array (
 		    ""            => "parse_vars",
 		    "widget"      => "parse_widget",
-		    "template"    => "parse_template",
 			"permission"  => "parse_permission",
 			"view"        => "parse_view",
 			"noaiki"      => "parse_noaiki",
@@ -94,6 +93,7 @@
 			"t"			  => "parse_t",
 			"nl2p"        => "parse_nl2p",
 			"nl2br"       => "parse_nl2br",
+			"hits"        => "parse_hits",
 			"get"         => "parse_get",
 			"post"        => "parse_post",
 			"repeat"      => "parse_repeat",
@@ -158,10 +158,7 @@
 		// @TODO make a structure.
 
 		$Parsers = array (
-		    // preparsers
-		    '/\(\([a-z0-9_]\)\)/i'                    => array( $this, "parse_vars"),
-		    '/\[GET\[([a-z0-9]+)\]\]/i'				   => array( $this, "parse_get"),
-		    '/\[POST\[([a-z0-9]+)\]\]/i'			   => array( $this, "parse_post"),
+		    // preparsers		 
 		    "/\(template\(([a-z0-9_]*)\)template\)/Ui" => array( $this, "parse_template"),
 
 		    // here we call the parse
@@ -262,21 +259,44 @@
 
 
 	/*
-	 * Parse template
+	 * Template is a pre-parser
+	 * 
+	 * arg os generated by a preg_replace call
 	 */
-	function parse_template($arg, $true, $false){
-		global $aiki;
-		$widget= $aiki->widgets->get_widget($arg[0]);
-		return  ( is_null($widget) ? "": $wiget->widget );
-	}
+	function parse_template($arg){
+		global $aiki;
+		$widget= isset($arg[1]) && $arg[1] ? $aiki->widgets->get_widget($arg[1]): NULL;
+		return  ( is_null($widget) ? "": $widget->widget );
+	}
+
+
+	function parse_widget( $arg, $true, $false ){
+		global $aiki;
+		
+		if ( !isset($arg[0]) && !$arg[0] ){
+			return is_debug_on() ? t("No widget given") : "" ;
+		}
+			
+		$widget=  $aiki->widgets->get_widget($arg[0]);
+		if ( !is_null($widget) ){			
+			if ( isset($arg[1]) && $arg[1]) {				
+				return $this->parse_sql( array($arg[1]), $widget->widget, (isset($arg[2]) ? $arg[2] : NULL));
+			} else {			
+				return $this->parse($widget->widget);
+			}
+		} elseif ( is_debug_on() ){
+			return sprintf( t("Widget %s not found"), $arg[0] );
+		}	
+		return "";		
+	}
+
 
 
 	/*
 	 * Parse script
 	 */
 	function parse_script($cond,$trueblock,$elseblock){
-		global $aiki;
-		
+		global $aiki;		
 		return $aiki->AikiScript->parser($trueblock,false);
 	}
 
@@ -376,8 +396,6 @@
 		// Special modes
 		$SQL = $parameters["SQL"];
 
-
-
 		if ( !is_null($prevPaginations) ){
 			// this markus accepts a third syntax sql(key,store-in)
 			$store = !is_array( $para[0] ) && isset($para[1]) ? $para[1] : $parameters["store"];
@@ -405,7 +423,6 @@
 			return t("Not valid SQL. Must be SELECT, SHOW, DESCRIBE, or retrieve a value for a previuos query");
 		}
 
-
 		$pagination = (bool) $parameters["pagination"];
 		if ($pagination ){
 			$page = isset($_GET[ $parameters["pagination-var"]]) ?
@@ -473,6 +490,7 @@
 				foreach ( $row as $field=>$value ){
 					$fields[ "(($field))" ]= $value;
 				}
+												
 				$html .= ( $col  ? sprintf("<{$colTag} class='col-%d' >", $i % $col) : "").
 				         ( $tag=="" || $tag=="none" ? "" : "<$tag>").
 				           strtr( $ifData, $fields).
@@ -504,9 +522,7 @@
 						$parameters["pagination-template"]);
 				}
 			}
-
-
-
+			
 		} else {
 			$page=false;
 			$records=0;
@@ -533,18 +549,11 @@
 					" SET {$hit[2]}={$hit[2]}+1".
 					" WHERE {$hit[1]}");
 		} elseif (is_debug_on() ) {
-				return sprintf( t("BAD HITS PARAMETERS: 3 expected, %d  given"), len($hit) );
+			return sprintf( t("BAD HITS PARAMETERS: 3 expected, %d  given"), count($hit) );
 		}
 		return "";
 	}
 
-
-	function parse_widget( $cond, $true, $false ){
-		//@TODO
-		//return  $this->parse($widgetId, $select);
-	}
-
-
 	function parse_view( $selectors, $trueBlock, $falseBlock){
 		global $aiki;
 
@@ -588,7 +597,7 @@
 		return nl2br( $this->parse($text));
 	}
 
-	function parse_nl2p ( $text){
+	function parse_nl2p ($text){
 		global $aiki;
 		return $aiki->text->nl2p($this->parse($text));
 	}

=== modified file 'libs/markup.php'
--- libs/markup.php	2012-03-25 20:58:04 +0000
+++ libs/markup.php	2012-03-29 21:18:15 +0000
@@ -524,9 +524,10 @@
 		} elseif (preg_match('/^"([^"]*)"$/', $expr, $matches)) {
 			return $matches[1];
 
-		// check if it is a var
-		} elseif (preg_match('/^([a-z_]+[a-z_0-9]*)$/i', $expr, $matches)) {
-			return ( isset($aiki_space_vars[$matches[1]]) ? $aiki_space_vars[$matches[1]] : 0);
+		// check if it is a var or a non quoted string.
+		} elseif (preg_match('/^([a-z_]+[a-z_0-9]*)$/i', $expr, $matches)) {			
+			return ( isset($aiki_space_vars[$matches[1]]) ? $aiki_space_vars[$matches[1]] : $matches[1]);
+			// important: if var if not found also a 0 can returned.
 
 		// check if it is a $aiki reference
 		} elseif (preg_match('/^\$aiki->([^-]*)->([^\(]*)\((.*)$/i', $expr, $matches)) {

=== modified file 'tests/engines/engineV2.sql'
--- tests/engines/engineV2.sql	2012-03-25 20:58:04 +0000
+++ tests/engines/engineV2.sql	2012-03-29 21:18:15 +0000
@@ -1,22 +1,66 @@
-
-INSERT INTO `aiki_sites` (`site_id`, `site_name`, `site_shortcut`, `is_active`, `if_closed_output`, `site_default_language`, `site_languages`, `widget_language`, `site_prefix`, `site_default_view`, `site_engine`, `site_engine_parameters`) VALUES
+-- phpMyAdmin SQL Dump
+-- version 3.3.10deb1
+-- http://www.phpmyadmin.net
+--
+-- Servidor: localhost
+-- Tiempo de generación: 29-03-2012 a las 23:03:17
+-- Versión del servidor: 5.1.54
+-- Versión de PHP: 5.3.5-1ubuntu7.4
+
+SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
+
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+
+
+INSERT IGNORE INTO `aiki_sites` (`site_id`, `site_name`, `site_shortcut`, `is_active`, `if_closed_output`, `site_default_language`, `site_languages`, `widget_language`, `site_prefix`, `site_default_view`, `site_engine`, `site_engine_parameters`) VALUES
 (5, 'engine2', 'engine2', 1, '', 'en', 'es,de', 'es', 'engine2', '', 'v2', '');
 
-INSERT INTO `aiki_widgets` (`id`, `app_id`, `widget_name`, `widget_site`, `widget_target`, `widget_type`, `display_order`, `style_id`, `is_father`, `father_widget`, `parent_widget`, `display_urls`, `kill_urls`, `normal_select`, `authorized_select`, `if_no_results`, `widget`, `css`, `nogui_widget`, `display_in_row_of`, `records_in_page`, `link_example`, `pagetitle`, `is_admin`, `if_authorized`, `permissions`, `remove_container`, `widget_cache_timeout`, `custom_output`, `custom_header`, `is_active`, `widget_owner`, `widget_privilege`, `last_change`) VALUES
+
+INSERT IGNORE INTO `aiki_views` (`view_id`, `view_name`, `view_site`, `view_active`, `view_prefix`, `view_use_prefix`, `view_url`, `view_short_description`, `view_description`) VALUES
+(3, 'dark', 'engine2', 1, 'dark', 1, '', '', ''),
+(4, 'mobil', 'engine2', 1, 'mobil', 1, '', '', '');
+
+
+DELETE FROM `aiki_widgets` WHERE widget_site='engine2';
+
+INSERT IGNORE INTO `aiki_widgets` (`id`, `app_id`, `widget_name`, `widget_site`, `widget_target`, `widget_type`, `display_order`, `style_id`, `is_father`, `father_widget`, `parent_widget`, `display_urls`, `kill_urls`, `normal_select`, `authorized_select`, `if_no_results`, `widget`, `css`, `nogui_widget`, `display_in_row_of`, `records_in_page`, `link_example`, `pagetitle`, `is_admin`, `if_authorized`, `permissions`, `remove_container`, `widget_cache_timeout`, `custom_output`, `custom_header`, `is_active`, `widget_owner`, `widget_privilege`, `last_change`) VALUES
 (10018, 0, 'about-children', 'betadmin', 'body', 'div', 0, '', 0, 1045, '', 'about', '', '', '', '', '', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
-(10016, 0, 'main', 'engine2', 'body', '', 0, '', 1, 0, '', '*|homepage|forms|forms2|vars|markup|sql|sql2|php|if|for|about|print|form3|repeat|script', '', '', '', '', '<div id="main">\r\n<div id="header">\r\n <h1>Testing engine - version 2.</h1>\r\n\r\n<ul id="nav">\r\n<li><a href="((route))/vars">vars</a></li>\r\n<li><a href="((route))/print">print</a></li>\r\n<li><a href="((route))/markup">markup</a></li>\r\n<li><a href="((route))/forms">forms</a></li>\r\n<li><a href="((route))/forms2">forms 2</a></li>\r\n<li><a href="((route))/sql">sql</a></li>\r\n<li><a href="((route))/sql2">sql2</a></li>\r\n<li><a href="((route))/script">Script</a></li>\r\n<li><a href="((route))/repeat">Repeat</a></li>\r\n<li><a href="((route))/if">if</a></li>\r\n<li><a href="((route))/about">about</a></li>\r\n</ul>\r\n\r\n</div>\r\n<div id="body">', 'td,th,input,select,textarea,p,dt,dd,li,a,h1,h2,h3,h4,h5,h6,\r\nbody {\r\nfont: normal normal normal  13px/15px Helvetica,"Free Sans",Arial;}\r\n\r\nh1 { font-size: 26px;line-height:30px;}\r\nh2 { font-size: 19.5px;line-height:30px; padding:15px 0 0 0px; margin:0;}\r\nh3 { font-size: 16px;line-height:20px;}\r\n\r\nbody {\r\nbackground-color: #f0f0f0;\r\nmargin: 10px 5%;}\r\n\r\n#main {\r\nbackground-color: #fff;\r\nborder-radius:8px 54px 8px 8px;\r\nmin-height:400px;\r\nborder:1px solid #aaa;\r\nbox-shadow: 0px 0px 4px #999;\r\npadding: 5px 15px;}\r\n\r\n#header {\r\npadding:12px 0px;}\r\n\r\n#nav    { background-color:#666; padding: 6px 12px;\r\n;box-shadow: 2px 2px 4px #ccc; overflow:auto;}\r\n#nav li { display: block; float: left; text-transform:uppercase;padding:6px 8px 4px  8px }\r\n#nav li + li { border-left: 1px solid #fff; padding-left:0.5em; }\r\n#nav a { text-decoration:none;color: #fff; } \r\n#nav a:hover { color: orange }\r\n\r\n\r\n#f_user {\r\nborder:1px solid #ddd; \r\nbox-shadow: 0px 0px 6px #ccc;\r\nmargin: 20px 10%;\r\npadding: 10px 20px;}', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
+(10016, 0, 'main', 'engine2', 'body', '', 0, '', 1, 0, '', '*|homepage|views|forms|forms2|vars|markup|sql|sql2|php|if|for|about|print|form3|template|script|permissions', '', '', '', '', '<div id="main">\r\n<div id="header">\r\n <h1>Testing engine <em>version 2</em></h1>\r\n\r\n<ul id="nav">\r\n<li><a href="((route))/vars">vars</a></li>\r\n<li><a href="((route))/views">views</a></li>\r\n<li><a href="((route))/permissions">permissions</a></li>\r\n<li><a href="((route))/print">print</a></li>\r\n<li><a href="((route))/markup">markup</a></li>\r\n<li><a href="((route))/forms">forms</a></li>\r\n<li><a href="((route))/forms2">forms 2</a></li>\r\n<li><a href="((route))/sql">sql</a></li>\r\n<li><a href="((route))/sql2">sql2</a></li>\r\n<li><a href="((route))/script">Script</a></li>\r\n<li><a href="((route))/if">if/repeat</a></li>\r\n<li><a href="((route))/template">Template  & Widgets</a></li>\r\n<li><a href="((route))/about">about</a></li>\r\n</ul>\r\n\r\n</div>\r\n<div id="body">', 'td,th,input,select,textarea,p,dt,dd,li,a,h1,h2,h3,h4,h5,h6,\r\n\r\n\r\nbody {\r\ncolor: #444;\r\nfont: normal normal normal  13px/15px Helvetica,"Free Sans",Arial;}\r\n\r\n\r\nh1 { font-size: 26px;line-height:30px;}\r\nh1 em { color: #999; font-size:13px; line-height:13px;display:block;font-style:normal; text-transform: uppercase;}\r\nh2 { font-size: 19.5px;line-height:30px; padding:15px 0 0 0px; margin:0;}\r\nh3 { font-size: 16px;line-height:20px;}\r\n\r\nbody {\r\n(css( dark: \r\nbackground-color: #333 !important;\r\n)css)\r\nbackground-color: #f0f0f0;\r\n(css(!mobil:\r\nmargin: 10px 5%;\r\n)css)}\r\n\r\na { color: orange; text-decoration:none; font-weight:bold }\r\na:hover { color: #333}\r\n\r\n(css( !mobil:\r\n#main {\r\nbackground-color: #fff;\r\nborder-radius:8px;\r\nmin-height:400px;\r\nborder:1px solid #aaa;\r\nbox-shadow: 0px 0px 4px #999;\r\npadding: 5px 15px 30px 15px;}\r\n)css)\r\n\r\n(css(mobil:\r\nul { padding:0}\r\nbody { background: #333;}\r\n#main { width:470px; padding:5px; margin:0 auto; background-color: #fff; color: #333}\r\n* { font-size:12px;line-height:14px}\r\n)css)\r\n\r\n(css(!mobil:\r\n#header {\r\npadding:12px 0px;}\r\n\r\n#nav    { background-color:#666; padding: 6px 12px;\r\n;box-shadow: 2px 2px 4px #ccc; overflow:auto;}\r\n#nav li { display: block; float: left; text-transform:uppercase;padding:6px 6px 4px  6px }\r\n#nav li + li { border-left: 1px solid #fff; padding-left:6px; }\r\n#nav a { text-decoration:none;color: #fff; } \r\n#nav a:hover { color: orange }\r\n)css)\r\n\r\n\r\n(css(mobil:\r\n#nav li { display: inline; }\r\n#nav li + li { border-left: 1px solid #333; padding-left:0.5em; }\r\n)css)\r\n\r\n\r\n#f_user {\r\nborder:1px solid #ddd; \r\nbox-shadow: 0px 0px 6px #ccc;\r\nmargin: 20px 10%;\r\npadding: 10px 20px;}\r\n\r\ncode { display:block; margin: 7px 15px; background-color: #f0f5f0;\r\npadding: 5px 10px; white-space:pre}\r\n\r\ndiv.record + div.record { \r\nborder-top:1px dotted #333; padding-top:7px; margin-top:7px;}\r\n\r\n', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
 (10017, 0, 'homepage', 'purephp', 'body', '', 0, '', 1, 0, '', 'homepage', '', '', '', '', 'echo "hello world. Now is ",date(''Y-m-d'');', 'body { color: red;}', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
 (10019, 0, 'markup', 'engine2', 'body', '', 0, '', 0, 10016, '', 'markup', '', '', '', '', '<h2>No Aiki</h2>\r\n\r\n\r\n(noaiki(  ((file.size)/(1024/1024))  )noaiki)\r\n\r\n(noaiki(    ((site))   )noaiki)\r\n\r\n\r\n\r\n\r\n<h2>nl2br</h2>\r\nWithout nl2br\r\n1\r\n2\r\n3\r\n\r\nwith nl2br\r\n(nl2br(\r\n1\r\n2\r\n3\r\n)nl2br)\r\n\r\n\r\n\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
 (10025, 0, 'forms2', 'engine2', 'body', '', 0, '', 1, 10016, '', 'forms2', '', '', '', '', '<h1>Testing forms with fieldset</h1>\r\n\r\n(form( {"1d": "f_foo", "class": "testing important", "layout": "p-br","pkey": "1", "table":"foo", "pkeyfield":"id","submit":"send form", "reset":"reset data", "save":"submit"} , \r\n{"type":"fieldset", "legend":"Personal data"},\r\n{"type":"text", "name":"text_foo" , "size": "50", "max-length":"30","placeholder":"your name"},\r\n{"type":"textarea", "name":"textarea_foo","label":"your coments"},\r\n{"type":"fieldset", "legend":"Direction"},\r\n{"type":"text", "name":"Street" },\r\n{"type":"text", "name":"CP" , "size": "5" }  \r\n)form)\r\n', 'form.testing {\r\nborder:1px solid #ddd; \r\nbox-shadow: 0px 0px 6px #ccc;\r\nmargin: 20px 10%;\r\npadding: 10px 20px;}\r\n\r\nform span.additional { color: #767; display:block}\r\n\r\nform span.tooltip { display:none;position:absolute;}\r\n\r\nform input:hover + span.tooltip,\r\nform input:focus + span.tooltip { display:block;background:#fce94f;\r\npadding:4px 10px; margin: 6px 0px 0px 50px}', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
-(10023, 0, 'vars', 'engine2', 'body', '', 0, '', 0, 10016, '', 'vars', '', '', '', '', '<h2>Site,root y routes</h2>\r\nSite: ((site))<br>\r\nroot:((root)) <br>\r\nroute:((route)) <br>\r\nroute-local:((route-local))<br>\r\nRoot-language:((root-language))<br>\r\nsite-prefix:((site_prefix))<br>\r\nview: ((view))<br>\r\nview-prefix: ((view_prefix))<br>\r\n\r\n<h2>User</h2>\r\nuserid: ((userid))<br>\r\nfull_name:((full_name))<br>\r\nusername:((username))<br>\r\nuser_group_level((user_group_level))<br>\r\nuser_permissions((user_permissions))<br>\r\n\r\n<h2>Date</h2>\r\ncurrent_day: ((current_day))<br>\r\ncurrent_month: ((current_month))<br>\r\ncurrent_year: ((current_year))<br>\r\n\r\n\r\n<h2>Language</h2>\r\nlanguage: ((language))<br>\r\ndirection ((direction))<br>\r\n\r\n<h2>URL </h2>\r\nurl: ((url))<br>\r\n\r\n\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
+(10023, 0, 'vars', 'engine2', 'body', '', 0, '', 0, 10016, '', 'vars', '', '', '', '', '<h2>Site,root y routes</h2>\r\nSite: ((site))<br>\r\nroot:((root)) <br>\r\nroute:((route)) <br>\r\nroute-local:((route-local))<br>\r\nRoot-language:((root-language))<br>\r\nsite-prefix:((site_prefix))<br>\r\nview: ((view))<br>\r\nview-prefix: ((view_prefix))<br>\r\n\r\n<h2>User</h2>\r\nuserid: ((userid))<br>\r\nfull_name:((full_name))<br>\r\nusername:((username))<br>\r\nuser_group_level((user_group_level))<br>\r\nuser_permissions((user_permissions))<br>\r\n\r\n<h2>Date</h2>\r\ncurrent_day: ((current_day))<br>\r\ncurrent_month: ((current_month))<br>\r\ncurrent_year: ((current_year))<br>\r\n\r\n\r\n<h2>Language</h2>\r\nlanguage: ((language))<br>\r\ndirection ((direction))<br>\r\n\r\n<h2>URL </h2>\r\nurl: ((url))<br>\r\n\r\n<h2>GET and POST</h2>\r\nis there a get called foo?<br>\r\n<a href="((route))/vars/?foo=<strong>hello </strong> world">Test</a>\r\n\r\n<p>\r\nclean: (get("foo", "clean")get)<br>\r\nraw:(get("foo", "raw")get)<br>\r\nurlencode:(get("foo", "urlencode")get)<br>\r\nquerystring:(get("foo", "querystring")get)<br>\r\n</p>\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
 (10020, 0, 'error_404-2', 'default', 'body', 'div', 0, '', 0, 0, '', 'error_404', '', '', '', '', 'igual podemos buscar algo mas', '', '', 0, 0, '', 'Aikiframework', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
 (10022, 0, 'footer', 'engine2', 'body', '', 2, '', 1, 0, '', '*', '', '', '', '', '</div><!-- body -->\r\n\r\n</div><!--main -->\r\n\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
 (10024, 0, 'sql', 'engine2', 'body', '', 0, '', 0, 10016, '', 'sql', '', '', '', '', '<h1>A simple sql as parameters</h1>\r\n\r\n<h2>show aiki_sites as a table.</h2>\r\n<strong>(noaiki((sql("SELECT * FROM aiki_sites", true, "table")sql))noaiki)</strong>\r\n(sql("SELECT * FROM aiki_sites", true, "table")sql)   \r\n  \r\n<h2>show the counts.</h2>\r\n (sql("SELECT count(site_id) FROM aiki_sites",false)sql)             \r\n\r\n<h2>With a block if-data-block</h2>\r\n(sql("SELECT * FROM aiki_widgets"){ \r\n<br>\r\n((widget_name)),  ((widget_site)) , ((widget_target))  }sql)\r\n\r\n\r\n<h2>With a block if-not-data-block</h2>\r\n(sql("SELECT * FROM aiki_widgets WHERE 0"){ \r\n<br>\r\n((widget_name)),  ((widget_site)) , ((widget_target))  }else{ Sorry, no data found}sql)\r\n\r\n\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
 (10021, 0, 'forms', 'engine2', 'body', '', 0, '', 1, 10016, '', 'forms', '', '', '', '', '<h1>Testing forms LAYOUTS</h1>\r\n\r\n\r\nFORM with loading data\r\n\r\n(form(\r\n{"id":"f_foo", "class": "testing important", "layout": "p-br","pkey": "1", "table":"foo" , "SQL": "SELECT * FROM foo WHERE id=''$PKEY'' ","pkeyfield":"id",\r\n"submit":"send form", "reset":"reset data", "save":"submit"},\r\n\r\n{"type":"text", "name":"text_foo" , "size": "50" , "max-length":"30", "placeholder":"your name"},\r\n{"type":"textarea", "name":"textarea_foo","label":"your coments"},\r\n\r\n)form)\r\n\r\n\r\nFORM with p-br\r\n\r\n(form(\r\n{"id":"f_user1", "class": "testing important", "layout": "p-br"},\r\n{"type":"text", "name":"username" , "size": "15" , "max-length":"30", "placeholder":"your name"},\r\n{"type":"text", "name":"other","label":"your name, please", "tooltip":"separe with ," } ,\r\n{"type":"radios", "name":"radios", "list": "yes|no|always" }\r\n\r\n\r\n)form)\r\n\r\nFORM with DL\r\n\r\n(form(\r\n{"class": "important", "layout": "dl"},\r\n{"type":"text", "name":"username","additional": "more info"} \r\n)form)\r\n\r\nHTML 5 FORM\r\n(form(\r\n{"id":"f_user"},\r\n{"type": "checkbox" , "name":"checkbox"},\r\n{"type": "color"        , "name":"color"},\r\n{"type": "date"        , "name":"date"},\r\n{"type": "datetime", "name":"datetime"},\r\n{"type": "datetime-local" ,  "name":"datetime"},\r\n{"type": "email" , "name":"email"},\r\n{"type": "file",    "name":"file"},\r\n{"type": "hidden"  , "name":"hidden"}\r\n{"type": "image"  , "name":"image"}\r\n{"type": "month"  , "name":"month"}\r\n{"type": "number"  , "name":"number"}\r\n{"type": "password"  , "name":"password"}\r\n{"type": "radio"  , "name":"radio"}\r\n{"type": "range"  , "name":"range"}\r\n{"type": "reset"  , "name":"reset"}\r\n{"type": "search"  , "name":"search"}\r\n{"type": "submit"  , "name":"submit"}\r\n{"type": "tel"  , "name":"tel"}\r\n{"type": "text"  , "name":"text"}\r\n{"type": "time"  , "name":"time"}\r\n{"type": "url"  , "name":"url"}\r\n{"type": "week"  , "name":"week"}\r\n\r\n)form)\r\n', 'form.testing {\r\nborder:1px solid #ddd; \r\nbox-shadow: 0px 0px 6px #ccc;\r\nmargin: 20px 10%;\r\npadding: 10px 20px;}\r\n\r\nform span.additional { color: #767; display:block}\r\n\r\nform span.tooltip { display:none;position:absolute;}\r\n\r\nform input:hover + span.tooltip,\r\nform input:focus + span.tooltip { display:block;background:#fce94f;\r\npadding:4px 10px; margin: 6px 0px 0px 50px}', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
 (10028, 0, 'forms3', 'engine2', 'body', '', 0, '', 1, 10016, '', 'forms3', '', '', '', '', '<h1>Testing forms with fieldset</h1>\r\n\r\n(form(\r\n{"id": "f_foo", "class": "testing important", "layout": "p-br","pkey": "1", "table":"foo" , "pkeyfield":"id","submit":"send form", "reset":"reset data", "save":"submit"},\r\n{"type":"fieldset", "legend":"Personal data"},\r\n{"type":"text", "name":"text_foo" , "size": "50" , "max-length":"30","placeholder":"your name"},\r\n{"type":"textarea", "name":"textarea_foo","label":"your coments"},\r\n{"type":"fieldset", "legend":"Direction"},\r\n{"type":"text", "name":"Street" },\r\n{"type":"text", "name":"CP" , "size": "5" }  \r\n)form)\r\n', 'form.testing {\r\nborder:1px solid #ddd; \r\nbox-shadow: 0px 0px 6px #ccc;\r\nmargin: 20px 10%;\r\npadding: 10px 20px;}\r\n\r\nform span.additional { color: #767; display:block}\r\n\r\nform span.tooltip { display:none;position:absolute;}\r\n\r\nform input:hover + span.tooltip,\r\nform input:focus + span.tooltip { display:block;background:#fce94f;\r\npadding:4px 10px; margin: 6px 0px 0px 50px}', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
-(10026, 0, 'if', 'engine2', 'body', '', 0, '', 0, 10016, '', 'if', '', '', '', '', '<h1>IF</h1>\r\n\r\n\r\n(nl2br(\r\n<h2>Values</h2>\r\n\r\nempty (if(  ){ true }else{false}if)\r\n\r\n0 (if( 0  ){ true }else{false}if)\r\n\r\nfalse (if( 0  ){ true }else{false}if)\r\n\r\n1 (if( 1  ){ true }else{false} )if)\r\n\r\nfoo  (if( foo  ){ true }else{false}if)\r\n\r\n''foo''  (if(''foo''  ){ true }else{false}if)\r\n\r\n<h2>Expression</h2>\r\n2>1\r\n(if( 2>1  ){ true }else{false}if)\r\n\r\n2<1\r\n(if( 2<1  ){ true }else{false}if)\r\n\r\n)nl2br)', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
-(10027, 0, 'about', 'engine2', 'body', '', 0, '', 0, 10016, '', 'about', '', '', '', '', '<h1>about thist test site</h1>\r\n\r\n<p>Written by Roger Martin (rg1024) to test engine v2.</p>\r\n\r\n\r\n<h2>Next releases</h2>\r\n<ul>\r\n<li>for or repeat markup</li>\r\n<li>html helpers</li>\r\n<li>operator  ?  as condition ? if-true; if-false \r\n</ul>\r\n\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
-(10032, 0, 'script', 'engine2', 'body', '', 0, '', 0, 10016, '', 'script', '', '', '', '', '<h1>Script</h1>\r\n\r\n(script(){counter()}script)\r\n\r\n\r\n(script(){counter()}script)\r\n\r\n(script(){counter()}script)\r\n\r\n(script(){counter()}script)', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
+(10026, 0, 'if', 'engine2', 'body', '', 0, '', 0, 10016, '', 'if', '', '', '', '', '<h1>IF</h1>\r\n\r\n<code>(noaiki((if( 0  ){ true }else{false}if)\r\n(if( 0  ){ true }else{false}if)\r\n(if( 1  ){ true }else{false} )if)\r\n (if(''foo''  ){ true }else{false}if)\r\n(if( 2>1  ){ true }else{false}if)\r\n(if( 2<1  ){ true }else{false}if)\r\n)noaiki)</code>\r\n\r\nResults:\r\n(nl2br(\r\n(if( 0  ){ if-true }else{if-cero-false}if)\r\nfalse (if( 0  ){ true }else{false}if)\r\n(if( 1  ){ true }else{false} )if)\r\n(if( 2>1  ){ 2 > 1..sure }else{ else}if)\r\n(if( 2<1  ){ true }else{false}if)\r\n)nl2br)\r\n\r\n<h1>Repeat</h1>\r\n<code>(noaiki((repeat(5){Hi friends}repeat))noaiki)</code>\r\n\r\n<p>Results: <br>\r\n(repeat(5){Hi friends}repeat)\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
+(10027, 0, 'about', 'engine2', 'body', '', 0, '', 0, 10016, '', 'about', '', '', '', '', '<h1>about this test site</h1>\r\n\r\n<p>Written by Roger Martin (rg1024) to test engine v2.</p>\r\n\r\n\r\n<h2>Next releases</h2>\r\n<ul>\r\n<li>for markup</li>\r\n<li>html helpers</li>\r\n<li>operator  ?  as condition ? if-true; if-false \r\n</ul>\r\n\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
+(10032, 0, 'script', 'engine2', 'body', '', 0, '', 0, 10016, '', 'script', '', '', '', '', '<h1>Script</h1>\r\n\r\n(noaiki( (script(){counter()}script) )noaiki) :  (script(){counter()}script)<br>\r\n(noaiki( (script(){counter()}script) )noaiki) :  (script(){counter()}script)<br>\r\n(noaiki( (script(){counter()}script) )noaiki) :  (script(){counter()}script)<br>\r\n(noaiki( (script(){counter()}script) )noaiki) :  (script(){counter()}script)<br>\r\n\r\n\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
 (10029, 0, 'sql2', 'engine2', 'body', '', 0, '', 0, 10016, '', 'sql2', '', '', '', '', '<h1>SQL with JSON similar</h1>\r\n\r\n\r\n<h2>Using blocks</h2>\r\nnote the problem of pagination:\r\n<table>\r\n (sql( {"SQL": "SELECT * FROM aiki_users", "pagination": true, "record-per-page":25,   "pagination-template": "<div class=''link''>[previous-next-links]</div>"} ){  <tr><td>((username))</td><td>((full_name))  }sql)\r\n</table>\r\n\r\n\r\n<h2>Using blocks</h2>\r\nHere is solvde\r\n<table>\r\n (sql( {"SQL": "SELECT * FROM aiki_users", "pagination": true, "record-per-page":25,   "pagination-add": false} ){  <tr><td>((username))</td><td>((full_name))  }sql)\r\n</table>\r\n(sql("previous-link")sql) (sql("next-link")sql)\r\n\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
-(10030, 0, 'vars', 'engine2', 'body', '', 0, '', 0, 10016, '', 'print', '', '', '', '', '<h2>print</h2>\r\n\r\n(nl2br(\r\n(print(2+2)print)\r\n(print(2>1)print)\r\n\r\n(print("hello"," world")print)\r\n\r\n(print(trim( " hi  friend " ) )print)\r\n\r\n(print(md5( "hi  friend" ) )print)\r\n\r\n)nl2br)\r\n\r\n\r\n\r\n<h2>sprintf</h2>\r\n\r\n(sprintf("hello, this is %s in %s",site,language)sprintf)\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
-(10031, 0, 'repeat', 'engine2', 'body', '', 0, '', 0, 10016, '', 'repeat', '', '', '', '', '<h1>Repeat</h1>\r\n\r\n(repeat(5){Hi friends}repeat)\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0);
+(10030, 0, 'print', 'engine2', 'body', '', 0, '', 0, 10016, '', 'print', '', '', '', '', '<h2>print</h2>\r\n\r\n(nl2br(\r\n\r\n<strong>operator</strong>\r\n7+2*5= (print(7+2*5)print)\r\n2> 1= (print(2>1)print)\r\n1>2 OR 2==2 = (print( 1>2 OR 2==2)print)\r\nhello .world =(print("hello"," world")print)\r\n\r\n<strong>Functions:</strong>\r\nlower: (print(lower( "Engine v2" ) )print)\r\nupper: (print(upper( "Engine v2" ) )print)\r\ntrim : (print(trim( " hi  friend " ) )print)\r\nmd5: (print(md5( "hi  friend" ) )print)\r\nurlencode: (print(urlencode("hello wordl") )print)\r\n\r\n\r\nFunction names can be PHP: str_replace, strtolower,  stripos, or more friendly as replace. lower, match, search.\r\n\r\n)nl2br)\r\n\r\n<p>All this expressions can be used as arguments in all markup</p>\r\n\r\n\r\n<h2>sprintf</h2>\r\n\r\n(sprintf("hello, this is %s in %s",site,language)sprintf)\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
+(10031, 0, 'template', 'engine2', 'body', '', 0, '', 0, 10016, '', 'template', '', '', '', '', '<h1>template</h1>\r\n\r\n<div class="explain"><p>With <em>template</em> you can insert other widget content in current widgets. Engine v2 insert the templates before process any markup.</p></div>\r\n\r\n<code>\r\ntemplate(exampletemplate)template\r\n</code>\r\n(template(exampletemplate)template)\r\n\r\n\r\n<h1>Wigdets</h1>\r\n\r\n<div class="explain"><p>Insert a widget, but accepts dynamic args list with: wigdet id or name, sql parameters (optional), if-data-not- found(optional)</div>\r\n\r\n\r\n<code>\r\n(noaiki((widget(''exampletemplate''))widget))noaiki)\r\n</code>\r\n\r\n(widget(''exampletemplate'')widget)\r\n\r\n\r\n(widget("userdata", "SELECT * FROM aiki_users")widget)\r\n\r\n<h2>Template vs Widgets</h2>\r\n<p>In a sql loop, template is more efficient that widgets, because template don''t require a sql extra query. </p>\r\n\r\n<p>Example\r\n\r\n<code>\r\nOnly one query must done.\r\n(noaiki( (sql( "SELECT..:")  {template(user)template)}sql)  )noaiki)\r\n\r\nThis requires a extra query for every record.\r\n(noaiki( (sql( "SELECT.:")  { widget("user", "SELECT  where id=((user_id))" )widget)   }sql) )noaiki)\r\n</code>\r\n\r\n\r\n\r\n\r\n\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
+(10033, 0, 'view', 'engine2', 'body', '', 0, '', 0, 10016, '', 'views', '', '', '', '', '<h2>view: ((view))</h2>\r\n\r\n(view( "dark" ){\r\n<blockquote>\r\n"By the dim light of an accidental lamp, tall, antique, worm-eaten, wooden tenements were seen tottering to their fall, in directions so many and capricious, that scarce the semblance of a passage was discernible between them."\r\n\r\n<cite> from "The Man of the Crowd"</cite>\r\n</blockquote>\r\n}view)\r\n\r\n(view( "mobil"){\r\nThis is the mobil version of you web. You can use a different css, and add filter to you widget\r\n\r\n}view)\r\n\r\n\r\n<h3>Vars and view</h3>\r\n\r\nSite: ((site))<br>\r\nroot:((root)) <br>\r\nroute:((route)) <br>\r\n\r\nroute-local:((route-local))<br>\r\n\r\nview: ((view))<br>\r\nview-prefix: ((view_prefix))<br>\r\n\r\n\r\n<h3>Change view</h3>\r\n<ul>\r\n<li><a href="((root))((site))/views">To normal view</a></li>\r\n<li><a href="((root))((site))/dark/views">Dark view</a></li>\r\n<li><a href="((root))((site))/mobil/views">Mobil view</a></li>\r\n</ul>\r\n\r\n\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
+(10034, 0, 'permissions', 'engine2', 'body', '', 0, '', 0, 10016, '', 'permissions', '', '', '', '', '<h2>Permission</h2>\r\n\r\n(permission( "SystemGod" ){\r\nHi, root\r\n}else{\r\nups..your are not root, but seems a nice guy!!\r\n}permission)\r\n\r\n\r\n\r\n\r\n', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
+(10035, 0, 'userdata', 'engine2', 'body', '', 0, '', 0, 0, '', '', '', '', '', '', '<div class="record">\r\n<p><strong>Username: </strong>((username))</p>\r\n<P><strong>Fullname:</strong> ((full_name)) </p>\r\n</div>', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0),
+(10036, 0, 'exampletemplate', 'engine2', 'body', '', 0, '', 0, 0, '', '', '', '', '', '', '<p>I''m a template with some markups like print.<br>\r\nFor ((site)) <br>\r\nView ((view)) <br> </p>', '', '', 0, 0, '', '', 0, '', '', 0, 0, 0, '', 1, 2, 'w', 0);
+
+
+CREATE TABLE IF NOT EXISTS `foo` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `text_foo` varchar(120) NOT NULL,
+  `textarea_foo` text NOT NULL,
+  PRIMARY KEY (`id`)
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
+
+--
+-- Volcar la base de datos para la tabla `foo`
+--
+
+INSERT INTO `foo` (`id`, `text_foo`, `textarea_foo`) VALUES
+(1, 'Here''s some text that should (hopefully) all be called and displayed when aiki pulls it in.', 'Heres some t''''ext that should (hopefully) all be called and displayed when aiki pulls it in.');

=== modified file 'tests/libs/markup.php'
--- tests/libs/markup.php	2012-03-25 20:58:04 +0000
+++ tests/libs/markup.php	2012-03-29 21:18:15 +0000
@@ -74,7 +74,7 @@
 			// primitive values
 			"'hello'"  => "hello",
 			'"hello"'  => "hello",
-			"Joes"     => 0,
+			"Joes"     => "Joes",
 			"2"=>2,
 			"false"=>false,
 			"true" =>true,
@@ -103,7 +103,7 @@
 			// vars
 			"x"=> 5,
 			// non existants variable.			
-			"z"=> 0,			
+			"z"=> "z",			
 			"x + 1"=> 6,
 			"9 - y" => 2,
 			
@@ -210,7 +210,7 @@
 				=> array("","TAG",array(false),"true-block",false ,false),
 			
 			"(TAG(COND){}TAG)"
-				=> array("","TAG",array(0),false,false ,false),
+				=> array("","TAG",array("COND"),false,false ,false),
 			
 			"begin(if('ok'){true-block}else{false-block}if)end"
 				=> array("begin","if",array("ok"),"true-block","false-block" ,"end"),
@@ -299,11 +299,11 @@
 			"  1,  2  "
 				=> array(array(1,2),false),
 			" 1, 2, aaa , 'bb' , \"cc\" " 
-				=> array(array(1,2,0,'bb', 'cc'),false),
+				=> array(array(1,2,'aaa','bb', 'cc'),false),
 			"true,false, {1,2,3}" 
 				=> array(array( true,false,array(1,2,3)),false),
 			"a, 'ba' , {1,2,{1,2"
-				=> array(array(0,'ba', array(1,2,array(1,2))),false),
+				=> array(array('a','ba', array(1,2,array(1,2))),false),
 			"5 > 2 "
 				=> array(array(true),false),
 			"2> 5 "
@@ -314,7 +314,10 @@
 			
 			"13,2,{  'dos'=>'bi', 'tres'=>'hiru'}"
 				=> array(array(13,2,array('dos'=>'bi','tres'=>'hiru')),false),	
-				
+			
+			"13,2,{  dos=>'bi', tres=>'hiru'}"
+				=> array(array(13,2,array('dos'=>'bi','tres'=>'hiru')),false),		
+								
 			"{2:'bi','sql':'hiru', 'abc': 'otro'}"
 				=> array( array(array(2=>'bi','sql'=>'hiru','abc'=>'otro')),false),
 				

_______________________________________________
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