testing Comanche

This commit is contained in:
friendica 2013-09-03 01:57:11 -07:00
parent 9d262a186f
commit 0be8e4061c
4 changed files with 14 additions and 11 deletions

View File

@ -2452,10 +2452,9 @@ function construct_page(&$a) {
foreach($a->layout as $k => $v) { foreach($a->layout as $k => $v) {
if((strpos($k,'region_') === 0) && strlen($v)) { if((strpos($k,'region_') === 0) && strlen($v)) {
if(strpos($v,'$region_') !== false) { if(strpos($v,'$region_') !== false) {
$v = preg_replace_callback('/\$region_([a-zA-Z0-9]*?)/ism','comanche_replace_region',$v); $v = preg_replace_callback('/\$region_([a-zA-Z0-9]+)/ism','comanche_replace_region',$v);
} }
$a->data[substr($k,0,7)] = $v; $a->page[substr($k,7)] = $v;
} }
} }
} }

View File

@ -45,15 +45,15 @@ function pdl_selector($uid,$current="") {
function comanche_parser(&$a,$s) { function comanche_parser(&$a,$s) {
$cnt = preg_match("/\[layout\](.*?)\[\/layout\]/ism", $matches, $s); $cnt = preg_match("/\[layout\](.*?)\[\/layout\]/ism", $s, $matches);
if($cnt) if($cnt)
$a->page['template'] = trim($matches[1]); $a->page['template'] = trim($matches[1]);
$cnt = preg_match("/\[theme\](.*?)\[\/theme\]/ism", $matches, $s); $cnt = preg_match("/\[theme\](.*?)\[\/theme\]/ism", $s, $matches);
if($cnt) if($cnt)
$a->layout['theme'] = trim($matches[1]); $a->layout['theme'] = trim($matches[1]);
$cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $matches, $s, PREG_SET_ORDER); $cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) { if($cnt) {
foreach($matches as $mtch) { foreach($matches as $mtch) {
$a->layout['region_' . $mtch[1]] = comanche_region($a,$mtch[2]); $a->layout['region_' . $mtch[1]] = comanche_region($a,$mtch[2]);
@ -71,8 +71,9 @@ function comanche_menu($name) {
function comanche_replace_region($match) { function comanche_replace_region($match) {
$a = get_app(); $a = get_app();
if(array_key_exists($match[1],$a->page)) if(array_key_exists($match[1],$a->page)) {
return $a->page[$match[1]]; return $a->page[$match[1]];
}
} }
// Widgets will have to get any operational arguments from the session, // Widgets will have to get any operational arguments from the session,
@ -90,7 +91,7 @@ function comanche_widget($name,$args = null) {
function comanche_region(&$a,$s) { function comanche_region(&$a,$s) {
$cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $matches, $s, PREG_SET_ORDER); $cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) { if($cnt) {
foreach($matches as $mtch) { foreach($matches as $mtch) {
$s = str_replace($mtch[0],comanche_menu(trim($mtch[1])),$s); $s = str_replace($mtch[0],comanche_menu(trim($mtch[1])),$s);
@ -99,7 +100,7 @@ function comanche_region(&$a,$s) {
// need to modify this to accept parameters // need to modify this to accept parameters
$cnt = preg_match_all("/\[widget\](.*?)\[\/widget\]/ism", $matches, $s, PREG_SET_ORDER); $cnt = preg_match_all("/\[widget\](.*?)\[\/widget\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) { if($cnt) {
foreach($matches as $mtch) { foreach($matches as $mtch) {
$s = str_replace($mtch[0],comanche_widget(trim($mtch[1])),$s); $s = str_replace($mtch[0],comanche_widget(trim($mtch[1])),$s);

View File

@ -60,7 +60,7 @@ function page_content(&$a) {
notice( t('Item not found.') . EOL); notice( t('Item not found.') . EOL);
return; return;
} }
dbg(1);
if($r[0]['layout_mid']) { if($r[0]['layout_mid']) {
$l = q("select body from item where mid = '%s' and uid = %d limit 1", $l = q("select body from item where mid = '%s' and uid = %d limit 1",
dbesc($r[0]['layout_mid']), dbesc($r[0]['layout_mid']),
@ -72,6 +72,9 @@ function page_content(&$a) {
comanche_parser(get_app(),$l[0]['body']); comanche_parser(get_app(),$l[0]['body']);
} }
} }
dbg(0);
logger('layout: ' . print_r($a->layout,true));
// Use of widgets should be determined by Comanche, but we don't have it yet, so... // Use of widgets should be determined by Comanche, but we don't have it yet, so...

View File

@ -1 +1 @@
2013-09-02.424 2013-09-03.425