- /**
- * Returns the scheme of the current call
- * @return string
- *
- * @deprecated 2019.06 - use BaseURL->getScheme() instead
- */
- public function getScheme()
- {
- return $this->baseURL->getScheme();
- }
-
- /**
- * Retrieves the Friendica instance base URL
- *
- * @param bool $ssl Whether to append http or https under BaseURL::SSL_POLICY_SELFSIGN
- *
- * @return string Friendica server base URL
- *
- * @deprecated 2019.06 - use BaseURL->get($ssl) instead
- */
- public function getBaseURL($ssl = false)
- {
- return $this->baseURL->get($ssl);
- }
-
- /**
- * @brief Initializes the baseurl components
- *
- * Clears the baseurl cache to prevent inconsistencies
- *
- * @param string $url
- *
- * @deprecated 2019.06 - use BaseURL->saveByURL($url) instead
- */
- public function setBaseURL($url)
- {
- $this->baseURL->saveByURL($url);
- }
-
- /**
- * Returns the current hostname
- *
- * @return string
- *
- * @deprecated 2019.06 - use BaseURL->getHostname() instead
- */
- public function getHostName()
- {
- return $this->baseURL->getHostname();
- }
-
- /**
- * Returns the sub-path of the full URL
- *
- * @return string
- *
- * @deprecated 2019.06 - use BaseURL->getUrlPath() instead
- */
- public function getURLPath()
- {
- return $this->baseURL->getUrlPath();
- }
-
- /**
- * Initializes App->page['htmlhead'].
- *
- * Includes:
- * - Page title
- * - Favicons
- * - Registered stylesheets (through App->registerStylesheet())
- * - Infinite scroll data
- * - head.tpl template
- */
- public function initHead()
- {
- $interval = ((local_user()) ? Core\PConfig::get(local_user(), 'system', 'update_interval') : 40000);
-
- // If the update is 'deactivated' set it to the highest integer number (~24 days)
- if ($interval < 0) {
- $interval = 2147483647;
- }
-
- if ($interval < 10000) {
- $interval = 40000;
- }
-
- // Default title: current module called
- if (empty($this->page['title']) && $this->module) {
- $this->page['title'] = ucfirst($this->module);
- }
-
- // Prepend the sitename to the page title
- $this->page['title'] = $this->config->get('config', 'sitename', '') . (!empty($this->page['title']) ? ' | ' . $this->page['title'] : '');
-
- if (!empty(Core\Renderer::$theme['stylesheet'])) {
- $stylesheet = Core\Renderer::$theme['stylesheet'];
- } else {
- $stylesheet = $this->getCurrentThemeStylesheetPath();
- }
-
- $this->registerStylesheet($stylesheet);
-
- $shortcut_icon = $this->config->get('system', 'shortcut_icon');
- if ($shortcut_icon == '') {
- $shortcut_icon = 'images/friendica-32.png';
- }
-
- $touch_icon = $this->config->get('system', 'touch_icon');
- if ($touch_icon == '') {
- $touch_icon = 'images/friendica-128.png';
- }
-
- Core\Hook::callAll('head', $this->page['htmlhead']);
-
- $tpl = Core\Renderer::getMarkupTemplate('head.tpl');
- /* put the head template at the beginning of page['htmlhead']
- * since the code added by the modules frequently depends on it
- * being first
- */
- $this->page['htmlhead'] = Core\Renderer::replaceMacros($tpl, [
- '$baseurl' => $this->getBaseURL(),
- '$local_user' => local_user(),
- '$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION,
- '$delitem' => Core\L10n::t('Delete this item?'),
- '$update_interval' => $interval,
- '$shortcut_icon' => $shortcut_icon,
- '$touch_icon' => $touch_icon,
- '$block_public' => intval($this->config->get('system', 'block_public')),
- '$stylesheets' => $this->stylesheets,
- ]) . $this->page['htmlhead'];
- }
-
- /**
- * Initializes App->page['footer'].
- *
- * Includes:
- * - Javascript homebase
- * - Mobile toggle link
- * - Registered footer scripts (through App->registerFooterScript())
- * - footer.tpl template
- */
- public function initFooter()
- {
- // If you're just visiting, let javascript take you home
- if (!empty($_SESSION['visitor_home'])) {
- $homebase = $_SESSION['visitor_home'];
- } elseif (local_user()) {
- $homebase = 'profile/' . $this->user['nickname'];
- }
-
- if (isset($homebase)) {
- $this->page['footer'] .= '<script>var homebase="' . $homebase . '";</script>' . "\n";
- }
-
- /*
- * Add a "toggle mobile" link if we're using a mobile device
- */
- if ($this->is_mobile || $this->is_tablet) {
- if (isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
- $link = 'toggle_mobile?address=' . urlencode(curPageURL());
- } else {
- $link = 'toggle_mobile?off=1&address=' . urlencode(curPageURL());
- }
- $this->page['footer'] .= Core\Renderer::replaceMacros(Core\Renderer::getMarkupTemplate("toggle_mobile_footer.tpl"), [
- '$toggle_link' => $link,
- '$toggle_text' => Core\L10n::t('toggle mobile')
- ]);
- }
-
- Core\Hook::callAll('footer', $this->page['footer']);
-
- $tpl = Core\Renderer::getMarkupTemplate('footer.tpl');
- $this->page['footer'] = Core\Renderer::replaceMacros($tpl, [
- '$baseurl' => $this->getBaseURL(),
- '$footerScripts' => $this->footerScripts,
- ]) . $this->page['footer'];
- }
-
- /**
- * @brief Removes the base url from an url. This avoids some mixed content problems.
- *
- * @param string $origURL
- *
- * @return string The cleaned url
- * @throws InternalServerErrorException
- */
- public function removeBaseURL($origURL)
- {
- // Remove the hostname from the url if it is an internal link
- $nurl = Util\Strings::normaliseLink($origURL);
- $base = Util\Strings::normaliseLink($this->getBaseURL());
- $url = str_replace($base . '/', '', $nurl);
-
- // if it is an external link return the orignal value
- if ($url == Util\Strings::normaliseLink($origURL)) {
- return $origURL;
- } else {
- return $url;
- }
- }
-