public static selfUrl ( boolean $script_params = false, boolean $nocache = true, boolean $full = false, boolean $force_ssl = false ) : Horde_Url | ||
$script_params | boolean | Include script parameters like QUERY_STRING and PATH_INFO? (Deprecated: use Horde::selfUrlParams() instead.) |
$nocache | boolean | Include a cache-buster parameter in the URL? |
$full | boolean | Return a full URL? |
$force_ssl | boolean | Ignore $conf['use_ssl'] and force creation of a SSL URL? |
return | Horde_Url | The requested URL. |
public static function selfUrl($script_params = false, $nocache = true, $full = false, $force_ssl = false)
{
if (!strncmp(PHP_SAPI, 'cgi', 3)) {
// When using CGI PHP, SCRIPT_NAME may contain the path to
// the PHP binary instead of the script being run; use
// PHP_SELF instead.
$url = $_SERVER['PHP_SELF'];
} else {
$url = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : $_SERVER['PHP_SELF'];
}
if (isset($_SERVER['REQUEST_URI'])) {
$url = Horde_String::common($_SERVER['REQUEST_URI'], $url);
}
if (substr($url, -9) == 'index.php') {
$url = substr($url, 0, -9);
}
if ($script_params) {
if ($pathInfo = Horde_Util::getPathInfo()) {
if (substr($url, -1) == '/') {
$pathInfo = substr($pathInfo, 1);
}
$url .= $pathInfo;
}
if (!empty($_SERVER['QUERY_STRING'])) {
$url .= '?' . $_SERVER['QUERY_STRING'];
}
}
$url = self::url($url, $full, array('force_ssl' => $force_ssl));
return $nocache && $GLOBALS['browser']->hasQuirk('cache_same_url') ? $url->unique() : $url;
}
/** */ protected function _content() { /* Return empty if we don't have a thread set. */ if (empty($this->_params['thread_id'])) { return ''; } /* Set up the message object. */ list($forum_id, $message_id) = explode('.', $this->_params['thread_id']); $messages = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create('agora', $forum_id); /* Check if valid thread, otherwise show forum list. */ if ($messages instanceof PEAR_Error || empty($messages)) { throw new Horde_Exception(_("Unable to fetch selected thread.")); } /* Get the sorting. */ $sort_by = Agora::getSortBy('threads'); $sort_dir = Agora::getSortDir('threads'); $view_bodies = $GLOBALS['prefs']->getValue('thread_view_bodies'); /* Get the message array and the sorted thread list. */ $threads_list = $messages->getThreads($messages->getThreadRoot($message_id), true, $sort_by, $sort_dir, $view_bodies, Horde::selfUrl()); /* Set up the column headers. */ $col_headers = array(array('message_thread' => _("Thread"), 'message_subject' => _("Subject")), 'message_author' => _("Posted by"), 'message_timestamp' => _("Date")); $col_headers = Agora::formatColumnHeaders($col_headers, $sort_by, $sort_dir, 'threads'); /* Set up the template tags. */ $view = new Agora_View(); $view->col_headers = $col_headers; $view->threads_list = $threads_list; $view->threads_list_header = _("Thread List"); $view->thread_view_bodies = $view_bodies; return $view->render('block/thread'); }