diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/markdown.php | 37 | ||||
-rw-r--r-- | include/nav.php | 32 |
2 files changed, 57 insertions, 12 deletions
diff --git a/include/markdown.php b/include/markdown.php index b4656f769..7afdc6c54 100644 --- a/include/markdown.php +++ b/include/markdown.php @@ -110,6 +110,39 @@ function diaspora_mention_callback($matches) { } +function diaspora_mention_callback2($matches) { + + $webbie = $matches[1] . '@' . $matches[2]; + $link = ''; + if($webbie) { + $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash where hubloc_addr = '%s' limit 1", + dbesc($webbie) + ); + if(! $r) { + $x = discover_by_webbie($webbie); + if($x) { + $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash where hubloc_addr = '%s' limit 1", + dbesc($webbie) + ); + } + } + if($r) + $link = $r[0]['xchan_url']; + } + + $name = (($r) ? $r[0]['xchan_name'] : $matches[1]); + + if(! $link) + $link = 'https://' . $matches[2] . '/u/' . $matches[1]; + + if($r && $r[0]['hubloc_network'] === 'zot') + return '@[zrl=' . $link . ']' . trim($name) . ((substr($matches[0],-1,1) === '+') ? '+' : '') . '[/zrl]' ; + else + return '@[url=' . $link . ']' . trim($name) . ((substr($matches[0],-1,1) === '+') ? '+' : '') . '[/url]' ; + +} + + /** * @brief @@ -141,9 +174,11 @@ function markdown_to_bb($s, $use_zrl = false) { // first try plustags $s = preg_replace_callback('/\@\{(.+?)\; (.+?)\@(.+?)\}\+/','diaspora_mention_callback',$s); - $s = preg_replace_callback('/\@\{(.+?)\; (.+?)\@(.+?)\}/','diaspora_mention_callback',$s); + $s = preg_replace_callback('/\@\{(.+?)\@(.+?)\}\+/','diaspora_mention_callback2',$s); + $s = preg_replace_callback('/\@\{(.+?)\@(.+?)\}/','diaspora_mention_callback2',$s); + // Escaping the hash tags - doesn't always seem to work // $s = preg_replace('/\#([^\s\#])/','\\#$1',$s); // This seems to work diff --git a/include/nav.php b/include/nav.php index 356c0643b..3c97d42da 100644 --- a/include/nav.php +++ b/include/nav.php @@ -76,6 +76,20 @@ EOT; $userinfo = null; $nav['loginmenu']=array(); + if($observer) { + $userinfo = array( + 'icon' => $observer['xchan_photo_m'], + 'name' => $observer['xchan_addr'], + ); + } + + elseif(! $_SESSION['authenticated']) { + $nav['remote_login'] = remote_login(); + $nav['loginmenu'][] = Array('rmagic',t('Remote authentication'),'',t('Click to authenticate to your home hub'),'rmagic_nav_btn'); + } + + + if(local_channel()) { @@ -114,6 +128,13 @@ EOT; if(! get_account_id()) { $nav['login'] = login(true,'main-login',false,false); $nav['loginmenu'][] = Array('login',t('Login'),'',t('Sign in'),'login_nav_btn'); + App::$page['content'] .= replace_macros(get_markup_template('nav_login.tpl'), + [ + '$nav' => $nav, + 'userinfo' => $userinfo + ] + ); + } else $nav['alogout'] = Array('logout',t('Logout'), "", t('End this session'),'logout_nav_btn'); @@ -121,17 +142,6 @@ EOT; } - if($observer) { - $userinfo = array( - 'icon' => $observer['xchan_photo_m'], - 'name' => $observer['xchan_addr'], - ); - } - - elseif(! $_SESSION['authenticated']) { - $nav['remote_login'] = remote_login(); - $nav['loginmenu'][] = Array('rmagic',t('Remote authentication'),'',t('Click to authenticate to your home hub'),'rmagic_nav_btn'); - } $homelink = get_my_url(); if(! $homelink) { |