diff options
Diffstat (limited to 'code/links.inc.php')
-rw-r--r-- | code/links.inc.php | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/code/links.inc.php b/code/links.inc.php index 39a1ae2..2e8d551 100644 --- a/code/links.inc.php +++ b/code/links.inc.php @@ -2,33 +2,59 @@ if(!defined('LINKS_INC')) { define('LINKS_INC', 1); + include('code/user.inc.php'); + class Links { function GetNeonLink($page) { - if($GLOBALS['pages']->HasAccess($page)) + if($GLOBALS['pages']->HasAccess($page, 'c')) { + if($GLOBALS['user']->GetLoginType() == 'url') + return 'index.php?page=' . $page . '&login=' . $GLOBALS['user']->GetLoginKey(); + return 'index.php?page=' . $page; + } + return ''; } function GetExternalLink($link) { - return $link; + return $link; } function GetMailtoLink($address) { - return 'mailto:' . $address; + return 'mailto:' . $address; + } + + function GetNavPage($page) { + if($GLOBALS['pages']->HasAccess($page, 'n')) { + $page = $GLOBALS['pages']->Get($page, 'n'); + return $page['content']; + } + + return ''; } - function ParseNavLink($link) { - if(!$link) return ''; + function ParseNavLink($text, $link) { + if(!$link) return $text; switch($link[0]) { case ':': - return $this->GetNeonLink(substr($link, 1)); + $ret = $this->GetNeonLink(substr($link, 1)); + + if($ret) + return '<a href="' . $ret . '">' . $text . '</a>'; + + return $text; case '@': - return $this->GetMailtoLink(substr($link, 1)); + return '<a href="' . $this->GetMailtoLink(substr($link, 1)) . '">' . $text . '</a>'; case '!': - return ''; + $ret = $this->GetNavPage(substr($link, 1)); + + if($ret) + return $ret; + + return $text; default: - return $this->GetExternalLink($link); + return '<a href="' . $this->GetExternalLink($link) . '">' . $text . '</a>'; } } } |