From 9391f6f9052ae16c9789e04a2a96b8aa96adb220 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 6 May 2015 10:53:26 +0200 Subject: allow blocks to have custom classes and add a new template called zen which gives you an empty page to work with --- include/comanche.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/comanche.php b/include/comanche.php index c1a98ed6c..7115b5635 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -133,10 +133,11 @@ function comanche_get_channel_id() { return $channel_id; } -function comanche_block($s) { +function comanche_block($s, $class = '') { $var = array(); $matches = array(); $name = $s; + $class = (($class) ? $class : 'bblock widget'); $cnt = preg_match_all("/\[var=(.*?)\](.*?)\[\/var\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { @@ -155,7 +156,7 @@ function comanche_block($s) { dbesc($name) ); if($r) { - $o .= (($var['wrap'] == 'none') ? '' : '
'); + $o .= (($var['wrap'] == 'none') ? '' : '
'); if($r[0]['title']) $o .= '

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

'; @@ -238,6 +239,13 @@ function comanche_region(&$a, $s) { } } + $cnt = preg_match_all("/\[block=(.*?)\](.*?)\[\/block\]/ism", $s, $matches, PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $s = str_replace($mtch[0],comanche_block(trim($mtch[2]),trim($mtch[1])),$s); + } + } + // need to modify this to accept parameters $cnt = preg_match_all("/\[widget=(.*?)\](.*?)\[\/widget\]/ism", $s, $matches, PREG_SET_ORDER); -- cgit v1.2.3 From 8ca10dcbab6c645f6a2c791ea0d062c25d5d842e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 7 May 2015 10:35:22 +0200 Subject: adjust icon size --- include/nav.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index 1134d1b48..77287c021 100644 --- a/include/nav.php +++ b/include/nav.php @@ -124,7 +124,7 @@ EOT; if($observer) { $userinfo = array( - 'icon' => $observer['xchan_photo_s'], + 'icon' => $observer['xchan_photo_m'], 'name' => $observer['xchan_addr'], ); } -- cgit v1.2.3 From 4f235de3c5a642d538da19b43b4ff4c01c2aa916 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 7 May 2015 13:26:14 +0200 Subject: provide a possibility to include js/css libs --- include/comanche.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'include') diff --git a/include/comanche.php b/include/comanche.php index 7115b5635..630c4f655 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -168,6 +168,33 @@ function comanche_block($s, $class = '') { return $o; } +function comanche_js($s) { + + switch($s) { + case 'jquery': + $path = 'view/js/jquery.js'; + break; + case 'bootstrap': + $path = 'library/bootstrap/js/bootstrap.min.js'; + break; + } + + return ''; + +} + +function comanche_css($s) { + + switch($s) { + case 'bootstrap': + $path = 'library/bootstrap/css/bootstrap.min.css'; + break; + } + + return ''; + +} + // This doesn't really belong in Comanche, but it could also be argued that it is the perfect place. // We need to be able to select what kind of template and decoration to use for the webpage at the heart of our content. // For now we'll allow an '[authored]' element which defaults to name and date, or 'none' to remove these, and perhaps @@ -246,6 +273,19 @@ function comanche_region(&$a, $s) { } } + $cnt = preg_match_all("/\[js\](.*?)\[\/js\]/ism", $s, $matches, PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $s = str_replace($mtch[0],comanche_js(trim($mtch[1])),$s); + } + } + + $cnt = preg_match_all("/\[css\](.*?)\[\/css\]/ism", $s, $matches, PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $s = str_replace($mtch[0],comanche_css(trim($mtch[1])),$s); + } + } // need to modify this to accept parameters $cnt = preg_match_all("/\[widget=(.*?)\](.*?)\[\/widget\]/ism", $s, $matches, PREG_SET_ORDER); -- cgit v1.2.3 From cd8ecb86499c7b1fdaff44653cf3771c60ee2454 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 7 May 2015 23:02:14 +0200 Subject: provide wrap variable for comanche menus --- include/comanche.php | 15 +++++++++++++-- include/menu.php | 7 +++++-- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/comanche.php b/include/comanche.php index 630c4f655..f385f3c5a 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -101,11 +101,22 @@ function comanche_parser(&$a, $s, $pass = 0) { } -function comanche_menu($name, $class = '') { +function comanche_menu($s, $class = '') { + $channel_id = comanche_get_channel_id(); + $name = $s; + + $cnt = preg_match_all("/\[var=(.*?)\](.*?)\[\/var\]/ism", $s, $matches, PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $var[$mtch[1]] = $mtch[2]; + $name = str_replace($mtch[0], '', $name); + } + } + if($channel_id) { $m = menu_fetch($name,$channel_id, get_observer_hash()); - return menu_render($m, $class); + return menu_render($m, $class, $edit = false, $var); } } diff --git a/include/menu.php b/include/menu.php index b4f4555a5..a2e91f7ed 100644 --- a/include/menu.php +++ b/include/menu.php @@ -24,7 +24,7 @@ function menu_fetch($name,$uid,$observer_xchan) { return null; } -function menu_render($menu, $class='', $edit = false) { +function menu_render($menu, $class='', $edit = false, $var = '') { if(! $menu) return ''; @@ -37,12 +37,15 @@ function menu_render($menu, $class='', $edit = false) { $menu['items'][$x]['mitem_desc'] = bbcode($menu['items'][$x]['mitem_desc']); } + $wrap = (($var['wrap'] === 'none') ? false : true); + return replace_macros(get_markup_template('usermenu.tpl'),array( '$menu' => $menu['menu'], '$class' => $class, '$edit' => (($edit) ? t("Edit") : ''), '$id' => $menu['menu']['menu_id'], - '$items' => $menu['items'] + '$items' => $menu['items'], + '$wrap' => $wrap )); } -- cgit v1.2.3 From 616338c17e9eabc6355e27694c9e49f1f4586055 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 10 May 2015 15:00:18 +0200 Subject: provide ability to create submenus --- include/menu.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/menu.php b/include/menu.php index a2e91f7ed..84ea78f00 100644 --- a/include/menu.php +++ b/include/menu.php @@ -29,17 +29,33 @@ function menu_render($menu, $class='', $edit = false, $var = '') { if(! $menu) return ''; + $uid = local_channel(); + $menu_list = menu_list($uid); + + foreach($menu_list as $menus) { + if($menus['menu_name'] != $menu['menu']['menu_name']) + $menu_names[] = $menus['menu_name']; + } + for($x = 0; $x < count($menu['items']); $x ++) { + if(in_array($menu['items'][$x]['mitem_link'], $menu_names)) { + $m = menu_fetch($menu['items'][$x]['mitem_link'],local_channel(), get_observer_hash()); + $submenu = menu_render($m, 'dropdown-menu', $edit = false, $var = array('wrap' => 'none')); + $menu['items'][$x]['submenu'] = $submenu; + } + if($menu['items'][$x]['mitem_flags'] & MENU_ITEM_ZID) $menu['items'][$x]['mitem_link'] = zid($menu['items'][$x]['mitem_link']); + if($menu['items'][$x]['mitem_flags'] & MENU_ITEM_NEWWIN) $menu['items'][$x]['newwin'] = '1'; + $menu['items'][$x]['mitem_desc'] = bbcode($menu['items'][$x]['mitem_desc']); } $wrap = (($var['wrap'] === 'none') ? false : true); - return replace_macros(get_markup_template('usermenu.tpl'),array( + $ret = replace_macros(get_markup_template('usermenu.tpl'),array( '$menu' => $menu['menu'], '$class' => $class, '$edit' => (($edit) ? t("Edit") : ''), @@ -47,6 +63,8 @@ function menu_render($menu, $class='', $edit = false, $var = '') { '$items' => $menu['items'], '$wrap' => $wrap )); + + return $ret; } -- cgit v1.2.3 From 70e5bf04e160bf1e3f2673f4405ac6a6adecb485 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 10 May 2015 21:52:48 +0200 Subject: uid > channel id to make submenus visible for observers --- include/menu.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/menu.php b/include/menu.php index 84ea78f00..5c0811437 100644 --- a/include/menu.php +++ b/include/menu.php @@ -29,8 +29,8 @@ function menu_render($menu, $class='', $edit = false, $var = '') { if(! $menu) return ''; - $uid = local_channel(); - $menu_list = menu_list($uid); + $channel_id = ((is_array(get_app()->profile)) ? get_app()->profile['profile_uid'] : 0); + $menu_list = menu_list($channel_id); foreach($menu_list as $menus) { if($menus['menu_name'] != $menu['menu']['menu_name']) @@ -39,7 +39,7 @@ function menu_render($menu, $class='', $edit = false, $var = '') { for($x = 0; $x < count($menu['items']); $x ++) { if(in_array($menu['items'][$x]['mitem_link'], $menu_names)) { - $m = menu_fetch($menu['items'][$x]['mitem_link'],local_channel(), get_observer_hash()); + $m = menu_fetch($menu['items'][$x]['mitem_link'], $channel_id, get_observer_hash()); $submenu = menu_render($m, 'dropdown-menu', $edit = false, $var = array('wrap' => 'none')); $menu['items'][$x]['submenu'] = $submenu; } -- cgit v1.2.3