Skip to content

Commit

Permalink
added workaround for menu on https pages; updates #343
Browse files Browse the repository at this point in the history
  • Loading branch information
following5 committed Apr 22, 2016
1 parent efdcded commit d6ad7a6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions okapi/services/caches/geocaches.php
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,11 @@ public static function get_cache_attribution_note(
$cache_id, $lang, array $langpref, $owner, $type
) {
$site_url = Settings::get('SITE_URL');

# Note that $site_url will either start with http:// or https://,
# depending on the current request. This applies also to the cronjob
# which replicates geocaches!

$site_name = Okapi::get_normalized_site_name();
$cache_url = $site_url."viewcache.php?cacheid=$cache_id";

Expand Down
16 changes: 15 additions & 1 deletion okapi/views/menu.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,22 @@ public static function get_installations()
{
$installations = OkapiServiceRunner::call("services/apisrv/installations",
new OkapiInternalRequest(new OkapiInternalConsumer(), null, array()));

# The installations list currently knows only http URLs.
# If we are running an https request, we replace the installations URL
# of this site by the https URL, so that the menu will work properly.

$site_url = Settings::get('SITE_URL');
$http_site_url = preg_replace("/^https:\/\//", "http://", $site_url);
foreach ($installations as &$inst_ref)
$inst_ref['selected'] = ($inst_ref['site_url'] == Settings::get('SITE_URL'));
{
if ($inst_ref['site_url'] == $http_site_url)
{
$inst_ref['site_url'] = $site_url;
$inst_ref['okapi_base_url'] = $site_url . 'okapi/';
}
$inst_ref['selected'] = ($inst_ref['site_url'] == $site_url);
}
return $installations;
}
}

0 comments on commit d6ad7a6

Please sign in to comment.