From 5f1ae2930b5ae69e142aed84f70afe5cde8cc38f Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 29 May 2015 11:07:57 +0200 Subject: show created/edited dates for menus --- mod/menu.php | 2 ++ view/css/mod_menu.css | 15 ++++++++++++++- view/tpl/menulist.tpl | 8 ++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/mod/menu.php b/mod/menu.php index 63aeaa5e3..2f502ca17 100644 --- a/mod/menu.php +++ b/mod/menu.php @@ -102,6 +102,8 @@ function menu_content(&$a) { '$desctitle' => t('Menu Title'), '$edit' => t('Edit'), '$drop' => t('Drop'), + '$created' => t('Created'), + '$edited' => t('Edited'), '$new' => t('New'), '$bmark' => t('Bookmarks allowed'), '$hintnew' => t('Create'), diff --git a/view/css/mod_menu.css b/view/css/mod_menu.css index 930bd834d..c3edec9fe 100644 --- a/view/css/mod_menu.css +++ b/view/css/mod_menu.css @@ -2,7 +2,20 @@ width: 100%; } -#menu-list-table th:nth-child(2){ +#menu-list-table th:nth-child(2), +#menu-list-table th:nth-child(3) { + white-space: nowrap; +} + +#menu-list-table th:nth-child(6), +#menu-list-table td:nth-child(6) { + padding: 7px 3px; + white-space: nowrap; +} + +#menu-list-table th:nth-child(7), +#menu-list-table td:nth-child(7) { + padding: 7px 10px 7px 7px; white-space: nowrap; } diff --git a/view/tpl/menulist.tpl b/view/tpl/menulist.tpl index 1d3d70757..71c2a89fb 100644 --- a/view/tpl/menulist.tpl +++ b/view/tpl/menulist.tpl @@ -14,17 +14,21 @@ {{$nametitle}} - {{$desctitle}} + {{$desctitle}} + {{$created}} + {{$edited}} {{foreach $menus as $m }} {{if $m.bookmark}}{{/if}} {{$m.menu_name}} - {{$m.menu_desc}} + {{$m.menu_desc}} + {{$m.menu_created}} + {{$m.menu_edited}} {{/foreach}} -- cgit v1.2.3 From b8d328076384ff48be47f59366aea8b1e1cc04a1 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 29 May 2015 13:08:01 +0200 Subject: some fixes to make menu sharing work and expose it in the ui. --- include/bbcode.php | 3 +++ include/menu.php | 10 ++++------ mod/impel.php | 14 +++++++++----- view/css/mod_menu.css | 8 ++++---- view/tpl/menulist.tpl | 18 ++++++++++-------- 5 files changed, 30 insertions(+), 23 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index 1f5a65399..a766b6aea 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -193,6 +193,9 @@ function translate_design_element($type) { case 'block': $ret = t('block'); break; + case 'menu': + $ret = t('menu'); + break; } return $ret; diff --git a/include/menu.php b/include/menu.php index 5c078c189..ae53945ef 100644 --- a/include/menu.php +++ b/include/menu.php @@ -28,10 +28,10 @@ function menu_element($menu) { $arr = array(); $arr['type'] = 'menu'; - $arr['name'] = $menu['menu_name']; - $arr['desc'] = $menu['menu_desc']; - $arr['created'] = $menu['menu_created']; - $arr['edited'] = $menu['menu_edited']; + $arr['pagetitle'] = $menu['menu']['menu_name']; + $arr['desc'] = $menu['menu']['menu_desc']; + $arr['created'] = $menu['menu']['menu_created']; + $arr['edited'] = $menu['menu']['menu_edited']; $arr['baseurl'] = z_root(); if($menu['menu_flags']) { @@ -124,7 +124,6 @@ function menu_fetch_id($menu_id,$channel_id) { function menu_create($arr) { - $menu_name = trim(escape_tags($arr['menu_name'])); $menu_desc = trim(escape_tags($arr['menu_desc'])); $menu_flags = intval($arr['menu_flags']); @@ -287,7 +286,6 @@ function menu_delete_id($menu_id, $uid) { function menu_add_item($menu_id, $uid, $arr) { - $mitem_link = escape_tags($arr['mitem_link']); $mitem_desc = escape_tags($arr['mitem_desc']); $mitem_order = intval($arr['mitem_order']); diff --git a/mod/impel.php b/mod/impel.php index 5bc850562..813990a7d 100644 --- a/mod/impel.php +++ b/mod/impel.php @@ -2,6 +2,7 @@ // import page design element +require_once('include/menu.php'); function impel_init(&$a) { @@ -21,7 +22,6 @@ function impel_init(&$a) { if(! $j) json_return_and_die($ret); - $channel = $a->get_channel(); $arr = array(); @@ -57,10 +57,11 @@ function impel_init(&$a) { logger('mod_impel: unrecognised element type' . print_r($j,true)); break; } + if($is_menu) { $m = array(); $m['menu_channel_id'] = local_channel(); - $m['menu_name'] = $j['name']; + $m['menu_name'] = $j['pagetitle']; $m['menu_desc'] = $j['desc']; if($j['created']) $m['menu_created'] = datetime_convert($j['created']); @@ -75,13 +76,16 @@ function impel_init(&$a) { $m['menu_flags'] |= MENU_SYSTEM; } - $menu_id = $menu_create($m); + + $menu_id = menu_create($m); + if($menu_id) { if(is_array($j['items'])) { foreach($j['items'] as $it) { $mitem = array(); + $mitem['mitem_link'] = str_replace('[baseurl]',z_root(),$it['link']); - $mitem['mitem_desc'] = escapetags($it['link']); + $mitem['mitem_desc'] = escape_tags($it['desc']); $mitem['mitem_order'] = intval($it['order']); if(is_array($it['flags'])) { $mitem['mitem_flags'] = 0; @@ -98,7 +102,7 @@ function impel_init(&$a) { $x = q("update menu set menu_edited = '%s' where menu_id = %d and menu_channel_id = %d", dbesc(datetime_convert('UTC','UTC',$j['edited'])), intval($menu_id), - intval(channel_id()) + intval(local_channel()) ); } } diff --git a/view/css/mod_menu.css b/view/css/mod_menu.css index c3edec9fe..7f0f40246 100644 --- a/view/css/mod_menu.css +++ b/view/css/mod_menu.css @@ -7,14 +7,14 @@ white-space: nowrap; } -#menu-list-table th:nth-child(6), -#menu-list-table td:nth-child(6) { +#menu-list-table th:nth-child(7), +#menu-list-table td:nth-child(7) { padding: 7px 3px; white-space: nowrap; } -#menu-list-table th:nth-child(7), -#menu-list-table td:nth-child(7) { +#menu-list-table th:nth-child(8), +#menu-list-table td:nth-child(8) { padding: 7px 10px 7px 7px; white-space: nowrap; } diff --git a/view/tpl/menulist.tpl b/view/tpl/menulist.tpl index 71c2a89fb..888dc6e6d 100644 --- a/view/tpl/menulist.tpl +++ b/view/tpl/menulist.tpl @@ -14,7 +14,8 @@ {{$nametitle}} - {{$desctitle}} + {{$desctitle}} + {{$created}} @@ -22,13 +23,14 @@ {{foreach $menus as $m }} - {{if $m.bookmark}}{{/if}} - {{$m.menu_name}} - {{$m.menu_desc}} - - - {{$m.menu_created}} - {{$m.menu_edited}} + {{if $m.bookmark}}{{/if}} + {{$m.menu_name}} + {{$m.menu_desc}} + + + + {{$m.menu_created}} + {{$m.menu_edited}} {{/foreach}} -- cgit v1.2.3 From d11d130021959828a03ac67ff77f607201f525e0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 29 May 2015 15:23:51 +0200 Subject: add some yes/no labels and minor template fixes --- mod/menu.php | 4 ++-- mod/mitem.php | 8 ++++---- view/tpl/menuedit.tpl | 2 +- view/tpl/mitemedit.tpl | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mod/menu.php b/mod/menu.php index 2f502ca17..f46dc9471 100644 --- a/mod/menu.php +++ b/mod/menu.php @@ -142,9 +142,9 @@ function menu_content(&$a) { '$editcontents' => t('Edit menu contents'), '$menu_name' => array('menu_name', t('Menu name'), $m['menu_name'], t('Must be unique, only seen by you'), '*'), '$menu_desc' => array('menu_desc', t('Menu title'), $m['menu_desc'], t('Menu title as seen by others'), ''), - '$menu_bookmark' => array('menu_bookmark', t('Allow bookmarks'), (($m['menu_flags'] & MENU_BOOKMARK) ? 1 : 0), t('Menu may be used to store saved bookmarks'), ''), + '$menu_bookmark' => array('menu_bookmark', t('Allow bookmarks'), (($m['menu_flags'] & MENU_BOOKMARK) ? 1 : 0), t('Menu may be used to store saved bookmarks'), array(t('No'), t('Yes'))), '$menu_system' => (($m['menu_flags'] & MENU_SYSTEM) ? 1 : 0), - '$submit' => t('Modify') + '$submit' => t('Submit and proceed') )); return $o; diff --git a/mod/mitem.php b/mod/mitem.php index 0961e15ff..c4c293d1e 100644 --- a/mod/mitem.php +++ b/mod/mitem.php @@ -160,8 +160,8 @@ function mitem_content(&$a) { '$aclselect' => populate_acl($perm_defaults,false), '$mitem_desc' => array('mitem_desc', t('Link Name'), '', 'Visible name of the link','*'), '$mitem_link' => array('mitem_link', t('Link or Submenu Target'), '', t('Enter URL of the link or select a menu name to create a submenu'), '*', 'list="menu-names"'), - '$usezid' => array('usezid', t('Use magic-auth if available'), true, ''), - '$newwin' => array('newwin', t('Open link in new window'), false,''), + '$usezid' => array('usezid', t('Use magic-auth if available'), true, '', array(t('No'), t('Yes'))), + '$newwin' => array('newwin', t('Open link in new window'), false,'', array(t('No'), t('Yes'))), '$mitem_order' => array('mitem_order', t('Order in list'),'0',t('Higher numbers will sink to bottom of listing')), '$submit' => t('Submit and finish'), '$submit_more' => t('Submit and continue'), @@ -231,8 +231,8 @@ function mitem_content(&$a) { '$mitem_id' => intval(argv(2)), '$mitem_desc' => array('mitem_desc', t('Link text'), $mitem['mitem_desc'], '','*'), '$mitem_link' => array('mitem_link', t('Link or Submenu Target'), $mitem['mitem_link'], 'Enter URL of the link or select a menu name to create a submenu', '*', 'list="menu-names"'), - '$usezid' => array('usezid', t('Use magic-auth if available'), (($mitem['mitem_flags'] & MENU_ITEM_ZID) ? 1 : 0), ''), - '$newwin' => array('newwin', t('Open link in new window'), (($mitem['mitem_flags'] & MENU_ITEM_NEWWIN) ? 1 : 0),''), + '$usezid' => array('usezid', t('Use magic-auth if available'), (($mitem['mitem_flags'] & MENU_ITEM_ZID) ? 1 : 0), '', array(t('No'), t('Yes'))), + '$newwin' => array('newwin', t('Open link in new window'), (($mitem['mitem_flags'] & MENU_ITEM_NEWWIN) ? 1 : 0),'', array(t('No'), t('Yes'))), '$mitem_order' => array('mitem_order', t('Order in list'),$mitem['mitem_order'],t('Higher numbers will sink to bottom of listing')), '$submit' => t('Submit'), '$lockstate' => $lockstate, diff --git a/view/tpl/menuedit.tpl b/view/tpl/menuedit.tpl index da3172434..7fc17471c 100644 --- a/view/tpl/menuedit.tpl +++ b/view/tpl/menuedit.tpl @@ -22,7 +22,7 @@ {{include file="field_checkbox.tpl" field=$menu_bookmark}}
diff --git a/view/tpl/mitemedit.tpl b/view/tpl/mitemedit.tpl index 8b8afa24c..cdc022c5c 100644 --- a/view/tpl/mitemedit.tpl +++ b/view/tpl/mitemedit.tpl @@ -21,13 +21,13 @@ {{include file="field_input.tpl" field=$mitem_order}} {{include file="field_checkbox.tpl" field=$usezid}} {{include file="field_checkbox.tpl" field=$newwin}} -
+
{{if $submit_more}} - + {{/if}}
-- cgit v1.2.3 From 8516b3259ffa4f09ef3f99bde2c66e590ba0c002 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 29 May 2015 16:14:54 +0200 Subject: whitespace --- mod/impel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/impel.php b/mod/impel.php index 813990a7d..67a7a21a9 100644 --- a/mod/impel.php +++ b/mod/impel.php @@ -103,7 +103,7 @@ function impel_init(&$a) { dbesc(datetime_convert('UTC','UTC',$j['edited'])), intval($menu_id), intval(local_channel()) - ); + ); } } $ret['success'] = true; -- cgit v1.2.3 From 2514af652490ebe4d379a32c339dd23d9b321897 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 29 May 2015 17:51:50 +0200 Subject: fix menu render for menu item edit - menu preview --- include/menu.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/menu.php b/include/menu.php index ae53945ef..2b61ebd34 100644 --- a/include/menu.php +++ b/include/menu.php @@ -66,13 +66,17 @@ function menu_element($menu) { -function menu_render($menu, $class='', $edit = false, $var = '') { +function menu_render($menu, $class='', $edit = false, $var = array()) { if(! $menu) return ''; $channel_id = ((is_array(get_app()->profile)) ? get_app()->profile['profile_uid'] : 0); + if ((! $channel_id) && (local_channel())) + $channel_id = local_channel(); + $menu_list = menu_list($channel_id); + $menu_names = array(); foreach($menu_list as $menus) { if($menus['menu_name'] != $menu['menu']['menu_name']) -- cgit v1.2.3 From 504050618497d3f3f43bb44b89637ebd767557ce Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 29 May 2015 17:59:31 +0200 Subject: should not redefine $var in the function call --- include/menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/menu.php b/include/menu.php index 2b61ebd34..d20df1d6e 100644 --- a/include/menu.php +++ b/include/menu.php @@ -86,7 +86,7 @@ function menu_render($menu, $class='', $edit = false, $var = array()) { 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'], $channel_id, get_observer_hash()); - $submenu = menu_render($m, 'dropdown-menu', $edit = false, $var = array('wrap' => 'none')); + $submenu = menu_render($m, 'dropdown-menu', $edit = false, array('wrap' => 'none')); $menu['items'][$x]['submenu'] = $submenu; } -- cgit v1.2.3