From 364fc9f1638e67dad2c289b4d365753a5d06ac05 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 25 Feb 2014 20:58:20 -0800 Subject: comanche: provide an option to add a menu class for different theming choices on some menus (e.g. horizontal, tabbed, etc.) --- include/comanche.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'include/comanche.php') diff --git a/include/comanche.php b/include/comanche.php index 7d7e0e70c..f02190ee5 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -79,10 +79,10 @@ function comanche_parser(&$a,$s) { } -function comanche_menu($name) { +function comanche_menu($name,$class = '') { $a = get_app(); $m = menu_fetch($name,$a->profile['profile_uid'],get_observer_hash()); - return menu_render($m); + return menu_render($m,$class); } function comanche_replace_region($match) { @@ -152,13 +152,22 @@ function comanche_widget($name,$text) { function comanche_region(&$a,$s) { - $cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { $s = str_replace($mtch[0],comanche_menu(trim($mtch[1])),$s); } } + + // menu class e.g. [menu=horizontal]my_menu[/menu] or [menu=tabbed]my_menu[/menu] + // allows different menu renderings to be applied + + $cnt = preg_match_all("/\[menu=(.*?)\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $s = str_replace($mtch[0],comanche_menu(trim($mtch[2]),$match[1]),$s); + } + } $cnt = preg_match_all("/\[block\](.*?)\[\/block\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { -- cgit v1.2.3 From 102521844b3d6f31d0d801b0d0c89241c2c621af Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 27 Feb 2014 20:48:10 -0800 Subject: put schemas in Comanche (this requires theme support (!)) --- include/comanche.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/comanche.php') diff --git a/include/comanche.php b/include/comanche.php index f02190ee5..0c81b0ed3 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -57,6 +57,13 @@ function comanche_parser(&$a,$s) { if($cnt) $a->page['template'] = trim($matches[1]); + + $cnt = preg_match("/\[theme=(.*?)\](.*?)\[\/theme\]/ism", $s, $matches); + if($cnt) { + $a->layout['schema'] = trim($matches[1]); + $a->layout['theme'] = trim($matches[2]); + } + $cnt = preg_match("/\[theme\](.*?)\[\/theme\]/ism", $s, $matches); if($cnt) $a->layout['theme'] = trim($matches[1]); -- cgit v1.2.3 From 247cb85c94c0214c6d60158e0429931a2f8479a0 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 1 Mar 2014 17:49:28 -0800 Subject: it's unfortunate that we use the term "layout" to refer both to a template file and to Comanche .PDL files. I think we should probably refer to the template file as "template" just to avoid confusion. For the moment we'll provide both, since the 'layout' is already in the wild. But please use "template" going forward. --- include/comanche.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/comanche.php') diff --git a/include/comanche.php b/include/comanche.php index 0c81b0ed3..3cf5e72a5 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -57,6 +57,10 @@ function comanche_parser(&$a,$s) { if($cnt) $a->page['template'] = trim($matches[1]); + $cnt = preg_match("/\[template\](.*?)\[\/template\]/ism", $s, $matches); + if($cnt) + $a->page['template'] = trim($matches[1]); + $cnt = preg_match("/\[theme=(.*?)\](.*?)\[\/theme\]/ism", $s, $matches); if($cnt) { -- cgit v1.2.3 From bf401a5afaca8f96606b22e219bd595646ac9dab Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 2 Mar 2014 00:24:29 -0800 Subject: allow templates to have multiple styles - this would be a bit like having a schema for a template file. At first you'll think this is insane and overly complicated, you'll just have to wait and see what I'm up to. Then it will start to make sense. --- include/comanche.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'include/comanche.php') diff --git a/include/comanche.php b/include/comanche.php index 3cf5e72a5..4af081740 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -57,10 +57,16 @@ function comanche_parser(&$a,$s) { if($cnt) $a->page['template'] = trim($matches[1]); + $cnt = preg_match("/\[template=(.*?)\](.*?)\[\/template\]/ism", $s, $matches); + if($cnt) { + $a->page['template'] = trim($matches[2]); + $a->page['template_style'] = trim($matches[2]) . '_' . $matches[1]; + } + $cnt = preg_match("/\[template\](.*?)\[\/template\]/ism", $s, $matches); - if($cnt) + if($cnt) { $a->page['template'] = trim($matches[1]); - + } $cnt = preg_match("/\[theme=(.*?)\](.*?)\[\/theme\]/ism", $s, $matches); if($cnt) { -- cgit v1.2.3 From e931af830701fdacc64e2cc014aa0057dc91e093 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 2 Mar 2014 15:47:01 -0800 Subject: first cut at choklet template --- include/comanche.php | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) (limited to 'include/comanche.php') diff --git a/include/comanche.php b/include/comanche.php index 4af081740..83e9af438 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -97,9 +97,11 @@ function comanche_parser(&$a,$s) { function comanche_menu($name,$class = '') { - $a = get_app(); - $m = menu_fetch($name,$a->profile['profile_uid'],get_observer_hash()); - return menu_render($m,$class); + $channel_id = comanche_get_channel_id(); + if($channel_id) { + $m = menu_fetch($name,$channel_id,get_observer_hash()); + return menu_render($m,$class); + } } function comanche_replace_region($match) { @@ -109,20 +111,37 @@ function comanche_replace_region($match) { } } +/** + * @function comanche_get_channel_id() + * Returns the channel_id of the profile owner of the page, or the local_user if there is no profile owner. + * Otherwise returns 0 + */ + +function comanche_get_channel_id() { + $channel_id = ((is_array(get_app()->profile)) ? get_app()->profile['profile_uid'] : 0); + if((! $channel_id) && (local_user())) + $channel_id = local_user(); + return $channel_id; +} + function comanche_block($name) { + + $channel_id = comanche_get_channel_id(); - $o = ''; - $r = q("select * from item inner join item_id on iid = item.id and item_id.uid = item.uid and item.uid = %d and service = 'BUILDBLOCK' and sid = '%s' limit 1", - intval(get_app()->profile['profile_uid']), - dbesc($name) - ); - if($r) { - $o = '
'; - if($r[0]['title']) - $o .= '

' . $r[0]['title'] . '

'; - $o .= prepare_text($r[0]['body'],$r[0]['mimetype']); - $o .= '
'; + if($channel_id) { + $o = ''; + $r = q("select * from item inner join item_id on iid = item.id and item_id.uid = item.uid and item.uid = %d and service = 'BUILDBLOCK' and sid = '%s' limit 1", + intval($channel_id), + dbesc($name) + ); + if($r) { + $o = '
'; + if($r[0]['title']) + $o .= '

' . $r[0]['title'] . '

'; + $o .= prepare_text($r[0]['body'],$r[0]['mimetype']); + $o .= '
'; + } } return $o; } -- cgit v1.2.3 From d16324685ac04b8c06f19285ae8db9e1ab1c7f96 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 3 Mar 2014 15:21:43 -0800 Subject: implement horizontal menu class in redbasic --- include/comanche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/comanche.php') diff --git a/include/comanche.php b/include/comanche.php index 83e9af438..13146ded4 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -201,7 +201,7 @@ function comanche_region(&$a,$s) { $cnt = preg_match_all("/\[menu=(.*?)\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { - $s = str_replace($mtch[0],comanche_menu(trim($mtch[2]),$match[1]),$s); + $s = str_replace($mtch[0],comanche_menu(trim($mtch[2]),$mtch[1]),$s); } } $cnt = preg_match_all("/\[block\](.*?)\[\/block\]/ism", $s, $matches, PREG_SET_ORDER); -- cgit v1.2.3