mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 00:55:19 +00:00
add a few more path macros to portable menu elements (channelurl, pageurl, storeurl and baseurl)
This commit is contained in:
parent
86eb923f29
commit
9b9621e10d
5 changed files with 25 additions and 15 deletions
|
@ -88,7 +88,11 @@ class Impel extends \Zotlabs\Web\Controller {
|
|||
foreach($j['items'] as $it) {
|
||||
$mitem = array();
|
||||
|
||||
$mitem['mitem_link'] = str_replace('[channelurl]',z_root() . '/channel/' . $channel['channel_address'],$it['link']);
|
||||
$mitem['mitem_link'] = str_replace('[pageurl]',z_root() . '/page/' . $channel['channel_address'],$it['link']);
|
||||
$mitem['mitem_link'] = str_replace('[storeurl]',z_root() . '/store/' . $channel['channel_address'],$it['link']);
|
||||
$mitem['mitem_link'] = str_replace('[baseurl]',z_root(),$it['link']);
|
||||
|
||||
$mitem['mitem_desc'] = escape_tags($it['desc']);
|
||||
$mitem['mitem_order'] = intval($it['order']);
|
||||
if(is_array($it['flags'])) {
|
||||
|
|
|
@ -65,7 +65,7 @@ class Menu extends \Zotlabs\Web\Controller {
|
|||
|
||||
|
||||
|
||||
function get() {
|
||||
function get() {
|
||||
|
||||
$uid = local_channel();
|
||||
|
||||
|
@ -81,7 +81,7 @@ class Menu extends \Zotlabs\Web\Controller {
|
|||
|
||||
if(argc() == 1) {
|
||||
|
||||
|
||||
$channel = (($sys) ? $sys : \App::get_channel());
|
||||
|
||||
// list menus
|
||||
$x = menu_list($uid);
|
||||
|
@ -89,7 +89,7 @@ class Menu extends \Zotlabs\Web\Controller {
|
|||
for($y = 0; $y < count($x); $y ++) {
|
||||
$m = menu_fetch($x[$y]['menu_name'],$uid,get_observer_hash());
|
||||
if($m)
|
||||
$x[$y]['element'] = '[element]' . base64url_encode(json_encode(menu_element($m))) . '[/element]';
|
||||
$x[$y]['element'] = '[element]' . base64url_encode(json_encode(menu_element($channel,$m))) . '[/element]';
|
||||
$x[$y]['bookmark'] = (($x[$y]['menu_flags'] & MENU_BOOKMARK) ? true : false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -640,19 +640,10 @@ function identity_basic_export($channel_id, $items = false) {
|
|||
for($y = 0; $y < count($x); $y ++) {
|
||||
$m = menu_fetch($x[$y]['menu_name'],$channel_id,$ret['channel']['channel_hash']);
|
||||
if($m)
|
||||
$ret['menu'][] = menu_element($m);
|
||||
$ret['menu'][] = menu_element($ret['channel'],$m);
|
||||
}
|
||||
}
|
||||
|
||||
$x = menu_list($channel_id);
|
||||
if($x) {
|
||||
$ret['menu'] = array();
|
||||
for($y = 0; $y < count($x); $y ++) {
|
||||
$m = menu_fetch($x[$y]['menu_name'],$channel_id,$ret['channel']['channel_hash']);
|
||||
if($m)
|
||||
$ret['menu'][] = menu_element($m);
|
||||
}
|
||||
}
|
||||
|
||||
$addon = array('channel_id' => $channel_id,'data' => $ret);
|
||||
call_hooks('identity_basic_export',$addon);
|
||||
|
|
|
@ -784,7 +784,11 @@ function import_menus($channel,$menus) {
|
|||
foreach($menu['items'] as $it) {
|
||||
$mitem = array();
|
||||
|
||||
$mitem['mitem_link'] = str_replace('[channelurl]',z_root() . '/channel/' . $channel['channel_address'],$it['link']);
|
||||
$mitem['mitem_link'] = str_replace('[pageurl]',z_root() . '/page/' . $channel['channel_address'],$it['link']);
|
||||
$mitem['mitem_link'] = str_replace('[storeurl]',z_root() . '/store/' . $channel['channel_address'],$it['link']);
|
||||
$mitem['mitem_link'] = str_replace('[baseurl]',z_root(),$it['link']);
|
||||
|
||||
$mitem['mitem_desc'] = escape_tags($it['desc']);
|
||||
$mitem['mitem_order'] = intval($it['order']);
|
||||
if(is_array($it['flags'])) {
|
||||
|
@ -864,7 +868,12 @@ function sync_menus($channel,$menus) {
|
|||
foreach($menu['items'] as $it) {
|
||||
$mitem = array();
|
||||
|
||||
|
||||
$mitem['mitem_link'] = str_replace('[channelurl]',z_root() . '/channel/' . $channel['channel_address'],$it['link']);
|
||||
$mitem['mitem_link'] = str_replace('[pageurl]',z_root() . '/page/' . $channel['channel_address'],$it['link']);
|
||||
$mitem['mitem_link'] = str_replace('[storeurl]',z_root() . '/store/' . $channel['channel_address'],$it['link']);
|
||||
$mitem['mitem_link'] = str_replace('[baseurl]',z_root(),$it['link']);
|
||||
|
||||
$mitem['mitem_desc'] = escape_tags($it['desc']);
|
||||
$mitem['mitem_order'] = intval($it['order']);
|
||||
if(is_array($it['flags'])) {
|
||||
|
|
|
@ -25,7 +25,7 @@ function menu_fetch($name,$uid,$observer_xchan) {
|
|||
return null;
|
||||
}
|
||||
|
||||
function menu_element($menu) {
|
||||
function menu_element($channel,$menu) {
|
||||
|
||||
$arr = array();
|
||||
$arr['type'] = 'menu';
|
||||
|
@ -46,7 +46,12 @@ function menu_element($menu) {
|
|||
$arr['items'] = array();
|
||||
foreach($menu['items'] as $it) {
|
||||
$entry = array();
|
||||
|
||||
$entry['link'] = str_replace(z_root() . '/channel/' . $channel['channel_address'],'[channelurl]',$it['mitem_link']);
|
||||
$entry['link'] = str_replace(z_root() . '/page/' . $channel['channel_address'],'[pageurl]',$it['mitem_link']);
|
||||
$entry['link'] = str_replace(z_root() . '/store/' . $channel['channel_address'],'[storeurl]',$it['mitem_link']);
|
||||
$entry['link'] = str_replace(z_root(),'[baseurl]',$it['mitem_link']);
|
||||
|
||||
$entry['desc'] = $it['mitem_desc'];
|
||||
$entry['order'] = $it['mitem_order'];
|
||||
if($it['mitem_flags']) {
|
||||
|
@ -389,12 +394,13 @@ function menu_del_item($menu_id,$uid,$item_id) {
|
|||
|
||||
function menu_sync_packet($uid,$observer_hash,$menu_id,$delete = false) {
|
||||
$r = menu_fetch_id($menu_id,$uid);
|
||||
$c = channelx_by_n($uid);
|
||||
if($r) {
|
||||
$m = menu_fetch($r['menu_name'],$uid,$observer_hash);
|
||||
if($m) {
|
||||
if($delete)
|
||||
$m['menu_delete'] = 1;
|
||||
build_sync_packet($uid,array('menu' => array(menu_element($m))));
|
||||
build_sync_packet($uid,array('menu' => array(menu_element($c,$m))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue