This commit is contained in:
redmatrix 2015-05-30 15:04:11 -07:00
commit cd3284d081
9 changed files with 61 additions and 31 deletions

View File

@ -193,6 +193,9 @@ function translate_design_element($type) {
case 'block': case 'block':
$ret = t('block'); $ret = t('block');
break; break;
case 'menu':
$ret = t('menu');
break;
} }
return $ret; return $ret;
@ -958,4 +961,4 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true) {
function strip_bbimage($s) { function strip_bbimage($s) {
$Text = preg_replace("/\[[zi]mg(.*?)\](.*?)\[\/[zi]mg\]/ism", '', $Text); $Text = preg_replace("/\[[zi]mg(.*?)\](.*?)\[\/[zi]mg\]/ism", '', $Text);
} }

View File

@ -28,10 +28,10 @@ function menu_element($menu) {
$arr = array(); $arr = array();
$arr['type'] = 'menu'; $arr['type'] = 'menu';
$arr['name'] = $menu['menu_name']; $arr['pagetitle'] = $menu['menu']['menu_name'];
$arr['desc'] = $menu['menu_desc']; $arr['desc'] = $menu['menu']['menu_desc'];
$arr['created'] = $menu['menu_created']; $arr['created'] = $menu['menu']['menu_created'];
$arr['edited'] = $menu['menu_edited']; $arr['edited'] = $menu['menu']['menu_edited'];
$arr['baseurl'] = z_root(); $arr['baseurl'] = z_root();
if($menu['menu_flags']) { if($menu['menu_flags']) {
@ -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) if(! $menu)
return ''; return '';
$channel_id = ((is_array(get_app()->profile)) ? get_app()->profile['profile_uid'] : 0); $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_list = menu_list($channel_id);
$menu_names = array();
foreach($menu_list as $menus) { foreach($menu_list as $menus) {
if($menus['menu_name'] != $menu['menu']['menu_name']) if($menus['menu_name'] != $menu['menu']['menu_name'])
@ -82,7 +86,7 @@ function menu_render($menu, $class='', $edit = false, $var = '') {
for($x = 0; $x < count($menu['items']); $x ++) { for($x = 0; $x < count($menu['items']); $x ++) {
if(in_array($menu['items'][$x]['mitem_link'], $menu_names)) { if(in_array($menu['items'][$x]['mitem_link'], $menu_names)) {
$m = menu_fetch($menu['items'][$x]['mitem_link'], $channel_id, 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')); $submenu = menu_render($m, 'dropdown-menu', $edit = false, array('wrap' => 'none'));
$menu['items'][$x]['submenu'] = $submenu; $menu['items'][$x]['submenu'] = $submenu;
} }
@ -124,7 +128,6 @@ function menu_fetch_id($menu_id,$channel_id) {
function menu_create($arr) { function menu_create($arr) {
$menu_name = trim(escape_tags($arr['menu_name'])); $menu_name = trim(escape_tags($arr['menu_name']));
$menu_desc = trim(escape_tags($arr['menu_desc'])); $menu_desc = trim(escape_tags($arr['menu_desc']));
$menu_flags = intval($arr['menu_flags']); $menu_flags = intval($arr['menu_flags']);
@ -287,7 +290,6 @@ function menu_delete_id($menu_id, $uid) {
function menu_add_item($menu_id, $uid, $arr) { function menu_add_item($menu_id, $uid, $arr) {
$mitem_link = escape_tags($arr['mitem_link']); $mitem_link = escape_tags($arr['mitem_link']);
$mitem_desc = escape_tags($arr['mitem_desc']); $mitem_desc = escape_tags($arr['mitem_desc']);
$mitem_order = intval($arr['mitem_order']); $mitem_order = intval($arr['mitem_order']);

View File

@ -2,6 +2,7 @@
// import page design element // import page design element
require_once('include/menu.php');
function impel_init(&$a) { function impel_init(&$a) {
@ -21,7 +22,6 @@ function impel_init(&$a) {
if(! $j) if(! $j)
json_return_and_die($ret); json_return_and_die($ret);
$channel = $a->get_channel(); $channel = $a->get_channel();
$arr = array(); $arr = array();
@ -57,10 +57,11 @@ function impel_init(&$a) {
logger('mod_impel: unrecognised element type' . print_r($j,true)); logger('mod_impel: unrecognised element type' . print_r($j,true));
break; break;
} }
if($is_menu) { if($is_menu) {
$m = array(); $m = array();
$m['menu_channel_id'] = local_channel(); $m['menu_channel_id'] = local_channel();
$m['menu_name'] = $j['name']; $m['menu_name'] = $j['pagetitle'];
$m['menu_desc'] = $j['desc']; $m['menu_desc'] = $j['desc'];
if($j['created']) if($j['created'])
$m['menu_created'] = datetime_convert($j['created']); $m['menu_created'] = datetime_convert($j['created']);
@ -75,13 +76,16 @@ function impel_init(&$a) {
$m['menu_flags'] |= MENU_SYSTEM; $m['menu_flags'] |= MENU_SYSTEM;
} }
$menu_id = $menu_create($m);
$menu_id = menu_create($m);
if($menu_id) { if($menu_id) {
if(is_array($j['items'])) { if(is_array($j['items'])) {
foreach($j['items'] as $it) { foreach($j['items'] as $it) {
$mitem = array(); $mitem = array();
$mitem['mitem_link'] = str_replace('[baseurl]',z_root(),$it['link']); $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']); $mitem['mitem_order'] = intval($it['order']);
if(is_array($it['flags'])) { if(is_array($it['flags'])) {
$mitem['mitem_flags'] = 0; $mitem['mitem_flags'] = 0;
@ -98,8 +102,8 @@ function impel_init(&$a) {
$x = q("update menu set menu_edited = '%s' where menu_id = %d and menu_channel_id = %d", $x = q("update menu set menu_edited = '%s' where menu_id = %d and menu_channel_id = %d",
dbesc(datetime_convert('UTC','UTC',$j['edited'])), dbesc(datetime_convert('UTC','UTC',$j['edited'])),
intval($menu_id), intval($menu_id),
intval(channel_id()) intval(local_channel())
); );
} }
} }
$ret['success'] = true; $ret['success'] = true;

View File

@ -102,6 +102,8 @@ function menu_content(&$a) {
'$desctitle' => t('Menu Title'), '$desctitle' => t('Menu Title'),
'$edit' => t('Edit'), '$edit' => t('Edit'),
'$drop' => t('Drop'), '$drop' => t('Drop'),
'$created' => t('Created'),
'$edited' => t('Edited'),
'$new' => t('New'), '$new' => t('New'),
'$bmark' => t('Bookmarks allowed'), '$bmark' => t('Bookmarks allowed'),
'$hintnew' => t('Create'), '$hintnew' => t('Create'),
@ -140,9 +142,9 @@ function menu_content(&$a) {
'$editcontents' => t('Edit menu contents'), '$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_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_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), '$menu_system' => (($m['menu_flags'] & MENU_SYSTEM) ? 1 : 0),
'$submit' => t('Modify') '$submit' => t('Submit and proceed')
)); ));
return $o; return $o;

View File

@ -160,8 +160,8 @@ function mitem_content(&$a) {
'$aclselect' => populate_acl($perm_defaults,false), '$aclselect' => populate_acl($perm_defaults,false),
'$mitem_desc' => array('mitem_desc', t('Link Name'), '', 'Visible name of the link','*'), '$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"'), '$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, ''), '$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,''), '$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')), '$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' => t('Submit and finish'),
'$submit_more' => t('Submit and continue'), '$submit_more' => t('Submit and continue'),
@ -231,8 +231,8 @@ function mitem_content(&$a) {
'$mitem_id' => intval(argv(2)), '$mitem_id' => intval(argv(2)),
'$mitem_desc' => array('mitem_desc', t('Link text'), $mitem['mitem_desc'], '','*'), '$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"'), '$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), ''), '$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),''), '$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')), '$mitem_order' => array('mitem_order', t('Order in list'),$mitem['mitem_order'],t('Higher numbers will sink to bottom of listing')),
'$submit' => t('Submit'), '$submit' => t('Submit'),
'$lockstate' => $lockstate, '$lockstate' => $lockstate,

View File

@ -2,7 +2,20 @@
width: 100%; 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(7),
#menu-list-table td:nth-child(7) {
padding: 7px 3px;
white-space: nowrap;
}
#menu-list-table th:nth-child(8),
#menu-list-table td:nth-child(8) {
padding: 7px 10px 7px 7px;
white-space: nowrap; white-space: nowrap;
} }

View File

@ -22,7 +22,7 @@
{{include file="field_checkbox.tpl" field=$menu_bookmark}} {{include file="field_checkbox.tpl" field=$menu_bookmark}}
<div class="menuedit-submit-wrapper form-group pull-right" > <div class="menuedit-submit-wrapper form-group pull-right" >
<button type="submit" name="submit" class="btn btn-primary">{{$submit}}</button> <button type="submit" name="submit" class="btn btn-primary">{{$submit}}&nbsp;<i class="icon-caret-right"></i></button>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</form> </form>

View File

@ -14,17 +14,23 @@
<tr> <tr>
<th width="1%"></th> <th width="1%"></th>
<th width="1%">{{$nametitle}}</th> <th width="1%">{{$nametitle}}</th>
<th width="96%">{{$desctitle}}</th> <th width="93%">{{$desctitle}}</th>
<th width="1%"></th> <th width="1%"></th>
<th width="1%"></th> <th width="1%"></th>
<th width="1%"></th>
<th width="1%" class="hidden-xs">{{$created}}</th>
<th width="1%" class="hidden-xs">{{$edited}}</th>
</tr> </tr>
{{foreach $menus as $m }} {{foreach $menus as $m }}
<tr id="menu-list-item-{{$m.menu_id}}"> <tr id="menu-list-item-{{$m.menu_id}}">
<td width="1%">{{if $m.bookmark}}<i class="icon-bookmark menu-list-tool" title="{{$bmark}}" ></i>{{/if}}</td> <td>{{if $m.bookmark}}<i class="icon-bookmark menu-list-tool" title="{{$bmark}}" ></i>{{/if}}</td>
<td width="1%"><a href="mitem/{{$m.menu_id}}{{if $sys}}?f=&sys=1{{/if}}" title="{{$hintcontent}}">{{$m.menu_name}}</a></td> <td><a href="mitem/{{$m.menu_id}}{{if $sys}}?f=&sys=1{{/if}}" title="{{$hintcontent}}">{{$m.menu_name}}</a></td>
<td width="96%">{{$m.menu_desc}}</td> <td>{{$m.menu_desc}}</td>
<td width="1%" class="menu-list-tool"><a href="menu/{{$m.menu_id}}{{if $sys}}?f=&sys=1{{/if}}" title="{{$hintedit}}"><i class="icon-pencil"></i></a></td> <td class="menu-list-tool"><a href="menu/{{$m.menu_id}}{{if $sys}}?f=&sys=1{{/if}}" title="{{$hintedit}}"><i class="icon-pencil"></i></a></td>
<td width="1%" class="menu-list-tool"><a href="#" title="{{$hintdrop}}" onclick="dropItem('menu/{{$m.menu_id}}/drop{{if $sys}}?f=&sys=1{{/if}}', '#menu-list-item-{{$m.menu_id}}'); return false;"><i class="icon-trash drop-icons"></i></a></td> <td class="menu-list-tool"><a href="rpost?attachment={{$m.element}}" title="{{$share}}"><i class="icon-share"></i></a></td>
<td class="menu-list-tool"><a href="#" title="{{$hintdrop}}" onclick="dropItem('menu/{{$m.menu_id}}/drop{{if $sys}}?f=&sys=1{{/if}}', '#menu-list-item-{{$m.menu_id}}'); return false;"><i class="icon-trash drop-icons"></i></a></td>
<td class="hidden-xs">{{$m.menu_created}}</td>
<td class="hidden-xs">{{$m.menu_edited}}</td>
</tr> </tr>
{{/foreach}} {{/foreach}}
</table> </table>

View File

@ -21,13 +21,13 @@
{{include file="field_input.tpl" field=$mitem_order}} {{include file="field_input.tpl" field=$mitem_order}}
{{include file="field_checkbox.tpl" field=$usezid}} {{include file="field_checkbox.tpl" field=$usezid}}
{{include file="field_checkbox.tpl" field=$newwin}} {{include file="field_checkbox.tpl" field=$newwin}}
<div class="pull-right btn-group form-group"> <div class="pull-right form-group">
<div class="btn-group"> <div class="btn-group">
<button id="dbtn-acl" class="btn btn-default btn-sm" data-toggle="modal" data-target="#aclModal" onclick="return false;"> <button id="dbtn-acl" class="btn btn-default btn-sm" data-toggle="modal" data-target="#aclModal" onclick="return false;">
<i id="jot-perms-icon" class="icon-{{$lockstate}}"></i> <i id="jot-perms-icon" class="icon-{{$lockstate}}"></i>
</button> </button>
{{if $submit_more}} {{if $submit_more}}
<button class="btn btn-primary btn-sm" type="submit" name="submit-more" value="{{$submit_more}}">{{$submit_more}}&nbsp;<i id="jot-perms-icon" class="icon-caret-right"></i></button> <button class="btn btn-primary btn-sm" type="submit" name="submit-more" value="{{$submit_more}}">{{$submit_more}}&nbsp;<i class="icon-caret-right"></i></button>
{{/if}} {{/if}}
<button class="btn btn-primary btn-sm" type="submit" name="submit" value="{{$submit}}">{{$submit}}</button> <button class="btn btn-primary btn-sm" type="submit" name="submit" value="{{$submit}}">{{$submit}}</button>
</div> </div>