/** * Generates the URL to the group page * @return the link to display the page. */ public static function getDisplayUrlFromHash($pParamHash = NULL) { global $gBitSystem; $ret = NULL; if (!empty($pParamHash['title'])) { $groupName = $pParamHash['title']; } // @TODO even better would be to pass a name param in url instead of group_id if (!empty($pParamHash['group_id']) || !empty($this->mGroupId)) { $groupId = $pParamHash['group_id']; } if (!empty($groupName) && $gBitSystem->isFeatureActive('pretty_urls') || $gBitSystem->isFeatureActive('pretty_urls_extended')) { // let people add any old f*****g char they want - not sure what kind of disaster this might be but we'll find out - 2/19/09 wjames5 $prettyGroupName = preg_replace('/ /', '+', $groupName); $ret = GROUP_PKG_URL . $prettyGroupName; } elseif (!empty($groupId)) { $ret = GROUP_PKG_URL . "index.php?group_id=" . $groupId; } // if all else fails try to get a value from a content id if (empty($ret)) { $contentId = !empty($pContentId) ? $pContentId : (!empty($this->mContentId) ? $this->mContentId : NULL); $ret = LibertyContent::getDisplayUrlFromHash($pParamHash); } return $ret; }
/** * Pure virtual function that returns link to display a piece of content * * @param string $pLinkText Text for the link unless overriden by object title * @param array $pMixed different possibilities depending on derived class * @param string $pAnchor anchor string e.g.: #comment_123 * @return string Formated html the link to display the page. */ function getDisplayLink($pLinkText = NULL, $pMixed = NULL, $pAnchor = NULL) { global $gBitSmarty; $ret = ''; if (empty($pMixed) && !empty($this->mInfo)) { $pMixed =& $this->mInfo; } if (empty($pLinkText)) { if (!empty($pMixed['title'])) { $pLinkText = $pMixed['title']; } elseif (!empty($pMixed['content_name'])) { $pLinkText = "[ " . $pMixed['content_name'] . " ]"; } } if (empty($pLinkText)) { $pLinkText = "[ " . tra("No Title") . " ]"; } // we add some more info to the title of the link if (!empty($pMixed['created'])) { $gBitSmarty->loadPlugin('smarty_modifier_bit_short_date'); $linkTitle = tra('Created') . ': ' . smarty_modifier_bit_short_date($pMixed['created']); } else { $linkTitle = $pLinkText; } // finally we are ready to create the full link if (!empty($pMixed['content_id'])) { $ret = '<a title="' . htmlspecialchars($linkTitle) . '" href="' . LibertyContent::getDisplayUrlFromHash($pMixed) . $pAnchor . '">' . htmlspecialchars($pLinkText) . '</a>'; } return $ret; }
function smarty_modifier_displayUrl($pMixed, $lib = '') { global $gLibertySystem; if (is_string($pMixed)) { if (empty($lib)) { $lib = 'BitPage'; } if (smarty_modifier_displayUrl_findLib($lib)) { $call = array($lib, 'getDisplayUrl'); if (is_callable($call)) { return call_user_func($call, $pMixed); } $i = $lib(); if (method_exists($i, 'getDisplayUrl')) { return $i->getDisplayUrl($pMixed); } } } elseif (is_object($pMixed)) { if (!empty($lib)) { if (smarty_modifier_displayUrl_findLib($lib)) { $i = $lib(); return $i->getDisplayUrl($pMixed); } } if (method_exists($pMixed, 'getDisplayUrl')) { return $pMixed->getDisplayUrl(); } } elseif (is_array($pMixed)) { if (!empty($lib)) { if (smarty_modifier_displayUrl_findLib($lib)) { $i = new $lib(); return $i->getDisplayUrl($pMixed); } } if (!empty($pMixed['display_url'])) { return $pMixed['display_url']; } if (!empty($pMixed['content_type_guid'])) { $type = $gLibertySystem->mContentTypes[$pContentType]; if (!empty($type)) { $lib = $type['handler_class']; smarty_modifier_displayUrl_loadLib($type); $i = new $lib(); return $i->getDisplayUrl($pMixed); } } if (!empty($pMixed['handler_class'])) { $lib = $pMixed['handler_class']; if (smarty_modifier_displayUrl_findLib($lib, true)) { $i = $lib(); return $i->getDisplayUrl($pMixed); } } } return LibertyContent::getDisplayUrlFromHash($pMixed); }