Skip to content

Commit

Permalink
cleaner presentation of multidomain site; updates #816
Browse files Browse the repository at this point in the history
  • Loading branch information
following5 committed Sep 16, 2015
1 parent f995f49 commit 6fea17b
Show file tree
Hide file tree
Showing 62 changed files with 358 additions and 263 deletions.
6 changes: 6 additions & 0 deletions bin/dbsv-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,12 @@ function dbv_139()
sql("ALTER TABLE `user` ADD COLUMN `language_guessed` tinyint(1) NOT NULL default '0' AFTER `language`");
}

function dbv_140() // last-used user domain, for email contents
{
if (!sql_field_exists('user', 'domain'))
sql("ALTER TABLE `user` ADD COLUMN `domain` varchar(40) default NULL AFTER `language_guessed`");
}


// When adding new mutations, take care that they behave well if run multiple
// times. This improves robustness of database versioning.
Expand Down
10 changes: 5 additions & 5 deletions htdocs/config2/locale.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
$opt['locale']['EN']['page']['subtitle1'] = 'Geocaching with Opencaching';
$opt['locale']['EN']['page']['subtitle2'] = '';
$opt['locale']['EN']['page']['license_url'] = 'http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.en';
$opt['locale']['EN']['page']['license'] = '<a rel="license" href="%1"><img alt="Creative Commons License Terms" style="border-width:0" src="resource2/ocstyle/images/media/cc-by-nc-nd-small.png" /></a><div style="text-align:center; margin:8px 0 0 6px;">The Opencaching.de <a href="articles.php?page=impressum#datalicense">content</a> is licensed under Creative Commons <a rel="license" href="%1" target="_blank">BY-BC-ND 3.0 DE</a>.</div>';
$opt['locale']['EN']['page']['license'] = '<a rel="license" href="%1"><img alt="Creative Commons License Terms" style="border-width:0" src="resource2/ocstyle/images/media/cc-by-nc-nd-small.png" /></a><div style="text-align:center; margin:8px 0 0 6px;">The {site} <a href="articles.php?page=impressum#datalicense">content</a> is licensed under Creative Commons <a rel="license" href="%1" target="_blank">BY-BC-ND 3.0 DE</a>.</div>';
$opt['locale']['EN']['helpwiki'] = "http://wiki.opencaching.de/index.php/";
$opt['locale']['EN']['mostly_translated'] = true;
$opt['locale']['EN']['what3words'] = true;
Expand All @@ -138,7 +138,7 @@
$opt['locale']['DE']['page']['subtitle1'] = 'Geocaching mit Opencaching';
$opt['locale']['DE']['page']['subtitle2'] = '';
$opt['locale']['DE']['page']['license_url'] = 'http://creativecommons.org/licenses/by-nc-nd/3.0/de/';
$opt['locale']['DE']['page']['license'] = '<a rel="license" href="%1"><img alt="Creative Commons Lizenzvertrag" style="border-width:0" src="resource2/ocstyle/images/media/cc-by-nc-nd-small.png" /></a><div style="text-align:center; margin:8px 0 0 6px;">Die <a href="articles.php?page=impressum#datalicense">Inhalte</a> von Opencaching.de stehen unter der Creative-Commons-Lizenz <a rel="license" href="%1">BY-NC-ND 3.0 DE</a>.</div>';
$opt['locale']['DE']['page']['license'] = '<a rel="license" href="%1"><img alt="Creative Commons Lizenzvertrag" style="border-width:0" src="resource2/ocstyle/images/media/cc-by-nc-nd-small.png" /></a><div style="text-align:center; margin:8px 0 0 6px;">Die <a href="articles.php?page=impressum#datalicense">Inhalte</a> von {site} stehen unter der Creative-Commons-Lizenz <a rel="license" href="%1">BY-NC-ND 3.0 DE</a>.</div>';
$opt['locale']['DE']['helpwiki'] = "http://wiki.opencaching.de/index.php/";
$opt['locale']['DE']['mostly_translated'] = true;
$opt['locale']['DE']['what3words'] = true; // "beta"
Expand All @@ -159,7 +159,7 @@
$opt['locale']['IT']['page']['subtitle1'] = 'Geocaching con Opencaching';
$opt['locale']['IT']['page']['subtitle2'] = '';
$opt['locale']['IT']['page']['license_url'] = 'http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.it';
$opt['locale']['IT']['page']['license'] = '<a rel="license" href="%1" target="_blank"><img alt="Creative Commons License Terms" style="border-width:0" src="resource2/ocstyle/images/media/cc-by-nc-nd-small.png" /></a><div style="text-align:center; margin:8px 0 0 6px;">Il <a href="articles.php?page=impressum#datalicense">contenuto</a> di Opencaching.de è rilasciato sotto licenza Creative Commons <a rel="license" href="%1" target="_blank">BY-NC-ND 3.0 DE</a>.</div>';
$opt['locale']['IT']['page']['license'] = '<a rel="license" href="%1" target="_blank"><img alt="Creative Commons License Terms" style="border-width:0" src="resource2/ocstyle/images/media/cc-by-nc-nd-small.png" /></a><div style="text-align:center; margin:8px 0 0 6px;">Il <a href="articles.php?page=impressum#datalicense">contenuto</a> di {site} è rilasciato sotto licenza Creative Commons <a rel="license" href="%1" target="_blank">BY-NC-ND 3.0 DE</a>.</div>';
$opt['locale']['IT']['mostly_translated'] = true;
$opt['locale']['IT']['what3words'] = false;

Expand All @@ -179,7 +179,7 @@
$opt['locale']['ES']['page']['subtitle1'] = 'Geocaching con Opencaching';
$opt['locale']['ES']['page']['subtitle2'] = '';
$opt['locale']['ES']['page']['license_url'] = 'http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.es_ES';
$opt['locale']['ES']['page']['license'] = '<a rel="license" href="%1" target="_blank"><img alt="Creative Commons License Terms" style="border-width:0" src="resource2/ocstyle/images/media/cc-by-nc-nd-small.png" /></a><div style="text-align:center; margin:8px 0 0 6px;">El <a href="articles.php?page=impressum#datalicense">contenido</a> está disponible bajo Creative Commons <a rel="license" href="%1" target="_blank">BY-NC-ND 3.0 DE</a> licencia.</div>';
$opt['locale']['ES']['page']['license'] = '<a rel="license" href="%1" target="_blank"><img alt="Creative Commons License Terms" style="border-width:0" src="resource2/ocstyle/images/media/cc-by-nc-nd-small.png" /></a><div style="text-align:center; margin:8px 0 0 6px;">El <a href="articles.php?page=impressum#datalicense">contenido</a> de {site} está disponible bajo Creative Commons <a rel="license" href="%1" target="_blank">BY-NC-ND 3.0 DE</a> licencia.</div>';
$opt['locale']['ES']['mostly_translated'] = true;
$opt['locale']['ES']['what3words'] = true;

Expand All @@ -199,7 +199,7 @@
$opt['locale']['FR']['page']['subtitle1'] = 'Geocaching avec Opencaching';
$opt['locale']['FR']['page']['subtitle2'] = '';
$opt['locale']['FR']['page']['license_url'] = 'http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.fr';
$opt['locale']['FR']['page']['license'] = '<a rel="license" href="%1"><img alt="Creative Commons License Terms" style="border-width:0" src="resource2/ocstyle/images/media/cc-by-nc-nd-small.png" /></a><div style="text-align:center; margin:8px 0 0 6px;">Le<a href="articles.php?page=impressum#datalicense">contenu</a> de Opencaching.de sont sous licence Creative Commons <a rel="license" href="%1" target="_blank">BY-BC-ND 3.0 DE</a>.</div>';
$opt['locale']['FR']['page']['license'] = '<a rel="license" href="%1"><img alt="Creative Commons License Terms" style="border-width:0" src="resource2/ocstyle/images/media/cc-by-nc-nd-small.png" /></a><div style="text-align:center; margin:8px 0 0 6px;">Le<a href="articles.php?page=impressum#datalicense">contenu</a> de {site} sont sous licence Creative Commons <a rel="license" href="%1" target="_blank">BY-BC-ND 3.0 DE</a>.</div>';
$opt['locale']['FR']['helpwiki'] = "http://wiki.opencaching.de/index.php/";
$opt['locale']['FR']['mostly_translated'] = true;
$opt['locale']['FR']['what3words'] = true;
Expand Down
9 changes: 5 additions & 4 deletions htdocs/config2/settings-dev.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@
$opt['logic']['node']['id'] = 4;
$opt['logic']['waypoint_pool']['prefix'] = 'OC';

if (!$opt['page']['shortlink_domain'])
$opt['page']['shortlink_domain'] = 'opencaching.de';

/* server options
*
*/
set_absolute_urls($opt, $dev_baseurl, 2);
set_absolute_urls(
$opt,
$dev_baseurl,
isset($dev_shortlink_domain) ? $dev_shortlink_domain : 'opencaching.de',
2);

$opt['page']['develsystem'] = true;
$opt['page']['max_logins_per_hour'] = 1000; // for development ...
Expand Down
57 changes: 42 additions & 15 deletions htdocs/config2/settings-dist-common.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
$opt['page']['title'] = 'OPENCACHING';
$opt['page']['subtitle1'] = 'Geocaching with Opencaching';
$opt['page']['subtitle2'] = '';
$opt['page']['sitename'] = 'Opencaching.de';
$opt['page']['slogan'] = 'Opencaching.de - Geocaching in Deutschland, Oesterreich und der Schweiz';

// directory of rotator pictures and script, relative to head images dir
$opt['page']['headimagepath'] = '';
Expand Down Expand Up @@ -94,7 +96,7 @@
$opt['cms']['login'] = 'http://wiki.opencaching.de/index.php/Login_auf_Opencaching.de';

// explanation of nature protection areas
$opt['cms']['npa'] = 'http://wiki.opencaching.de/index.php/Schutzgebiete';
$opt['cms']['npa'] = 'articles.php?page=npa&wiki';

/* HTTPS settings
*
Expand Down Expand Up @@ -123,14 +125,15 @@
* $opt['page']['default_primary_url'] the default-protocol base URL of the primary domain of this site
* $opt['page']['shortlink_url'] shortlink URL of the current protocol or false
* $opt['page']['default_shortlink_url'] default-protocol shortlink URL or false
* $opt['page']['default_primary_shortlink_url'] default-protocol shortlink URL of primary domain of this site, or false
* $opt['page']['https']['active'] true if the current request is https, else false
* $opt['page']['protocol'] the protocol of the current request, 'http' or 'https'
*
* These settings allow to run a consistently multi-protocol and multi-domain OC site.
* All generated URls end on '/'.
*/

function set_absolute_urls(&$opt, $primary_site_url, $lib)
function set_absolute_urls(&$opt, $primary_site_url, $primary_shortlink_domain, $lib)
{
// $opt is passed as parameter because it is *local* in okapi_settings.php.

Expand All @@ -145,10 +148,10 @@ function set_absolute_urls(&$opt, $primary_site_url, $lib)
$primary_site_url .= '/';

if (isset($opt['domain'][$primary_domain]['https']['is_default']))
$httpsdefault = $opt['domain'][$primary_domain]['https']['is_default'];
$primary_httpsdefault = $opt['domain'][$primary_domain]['https']['is_default'];
else
$httpsdefault = $opt['page']['https']['is_default'];
if ($httpsdefault)
$primary_httpsdefault = $opt['page']['https']['is_default'];
if ($primary_httpsdefault)
$opt['page']['default_primary_url'] = 'https' . strstr($primary_site_url, '://');
else
$opt['page']['default_primary_url'] = 'http' . strstr($primary_site_url, '://');
Expand Down Expand Up @@ -191,29 +194,49 @@ function set_absolute_urls(&$opt, $primary_site_url, $lib)
$absolute_server_URI = $opt['page']['absolute_url'];

if ($opt['page']['https']['is_default'])
{
$opt['page']['default_absolute_url'] = $opt['page']['absolute_https_url'];
$opt['page']['default_protocol'] = 'https';
}
else
{
$opt['page']['default_absolute_url'] = $opt['page']['absolute_http_url'];
$opt['page']['default_protocol'] = 'http';
}

// 3. create shortlink URLs

if (isset($opt['domain'][$current_domain]['shortlink_domain']))
$opt['page']['shortlink_domain'] = $opt['domain'][$current_domain]['shortlink_domain'];

if (!isset($opt['page']['shortlink_domain']) || !$opt['page']['shortlink_domain'])
if (!$primary_shortlink_domain)
{
$opt['page']['shortlink_url'] = false;
$opt['page']['default_shortlink_url'] = false;
$opt['page']['default_primary_shortlink_url'] = false;
}
else
{
if (strpos($opt['page']['shortlink_domain'], '://') !== false)
$opt['page']['shortlink_domain'] = parse_url($opt['page']['shortlink_domain'], PHP_URL_HOST);
$opt['page']['shortlink_url'] = $opt['page']['protocol'] . '://' . $opt['page']['shortlink_domain'] . '/';
if ($opt['page']['https']['is_default'])
$opt['page']['default_shortlink_url'] = 'https://' . $opt['page']['shortlink_domain'] . '/';
if ($primary_httpsdefault)
$opt['page']['default_primary_shortlink_url'] = 'https://' . $primary_shortlink_domain . '/';
else
$opt['page']['default_primary_shortlink_url'] = 'http://' . $primary_shortlink_domain . '/';

if (isset($opt['domain'][$current_domain]['shortlink_domain']) && $opt['domain'][$current_domain]['shortlink_domain'])
{
$opt['page']['shortlink_url'] = $opt['page']['protocol'] . '://' . $opt['domain'][$current_domain]['shortlink_domain'] . '/';
$opt['page']['default_shortlink_url'] = $opt['page']['default_protocol'] . '://' . $opt['domain'][$current_domain]['shortlink_domain'] . '/';
}
else
$opt['page']['default_shortlink_url'] = 'http://' . $opt['page']['shortlink_domain'] . '/';
{
if ($current_domain == $primary_domain)
{
$opt['page']['default_shortlink_url'] = $opt['page']['default_primary_shortlink_url'];
$opt['page']['shortlink_url'] = $opt['page']['protocol'] . strstr($opt['page']['default_shortlink_url'], '://');
}
else
{
$opt['page']['shortlink_url'] = false;
$opt['page']['default_shortlink_url'] = false;
}
}
}

// 4. set location of uploaded images
Expand Down Expand Up @@ -242,13 +265,17 @@ function set_common_domain_config(&$opt)
if (isset($opt['domain'][$domain]['country']))
$opt['template']['default']['country'] = $opt['domain'][$domain]['country'];

if (isset($opt['domain'][$domain]['sitename']))
$opt['page']['sitename'] = $opt['domain'][$domain]['sitename'];
if (isset($opt['domain'][$domain]['keywords']))
$opt['page']['meta']['keywords'] = $opt['domain'][$domain]['keywords'];
if (isset($opt['domain'][$domain]['description']))
$opt['page']['meta']['description'] = $opt['domain'][$domain]['description'];

if (isset($opt['domain'][$domain]['headoverlay']))
$opt['page']['headoverlay'] = $opt['domain'][$domain]['headoverlay'];
if (isset($opt['domain'][$domain]['slogan']))
$opt['page']['slogan'] = $opt['domain'][$domain]['slogan'];
}
}

Expand Down
1 change: 0 additions & 1 deletion htdocs/config2/settings-dist.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@
*/
$opt['page']['origin_url'] = 'http://www.opencaching.de/'; // production installation for this OC site
$opt['page']['develsystem'] = false;
$opt['page']['shortlink_domain'] = false;

/*
* configure infos on 404.php
Expand Down
10 changes: 7 additions & 3 deletions htdocs/config2/settings-sample.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
*/
//$opt['domain']['www.opencaching.de']['url'] = 'http://www.opencaching.de/';
//$opt['domain']['www.opencaching.de']['shortlink_domain'] = 'opencaching.de';
//$opt['domain']['www.opencaching.de']['sitename'] = 'Opencaching.de';
//$opt['domain']['www.opencaching.de']['locale'] = 'DE';
//$opt['domain']['www.opencaching.de']['fallback_locale'] = 'EN';
//$opt['domain']['www.opencaching.de']['style'] = 'ocstyle';
Expand All @@ -127,17 +128,20 @@
//$opt['domain']['www.opencaching.de']['https']['force_login'] = true;

//$opt['domain']['www.opencaching.pl']['url'] = 'http://www.opencaching.pl/';
//$opt['domain']['www.opencaching.pl']['sitename'] = 'Opencaching.PL';
//$opt['domain']['www.opencaching.pl']['locale'] = 'PL';
//$opt['domain']['www.opencaching.de']['fallback_locale'] = 'EN';
//$opt['domain']['www.opencaching.pl']['fallback_locale'] = 'EN';
//$opt['domain']['www.opencaching.pl']['style'] = 'ocstyle';
//$opt['domain']['www.opencaching.pl']['cookiedomain'] = '.opencaching.pl';
//$opt['domain']['www.opencaching.pl']['country'] = 'PL';
//$opt['domain']['www.opencaching.pl']['keywords'] = 'geocaching, geocache, cache, poszukiwanie skarbów, GPS, wolne, GPX, koordynować, hobby, natura'; // 5-10 keywords are recommended
//$opt['domain']['www.opencaching.pl']['description'] = 'Opencaching.pl jest darmowy portal dla Geocaching, gry Treasure Hunt. Za pomocą współrzędnych GPS można znaleźć pojemniki lub obiektów.';
//$opt['domain']['www.opencaching.pl']['headoverlay'] = 'oc_head_alpha3_pl';

// Supply the site's primary URL here. Can be overriden by domain settings.
set_absolute_urls($opt, 'http://www.opencaching.de/', 2);
// Supply the site's primary URL and the shortlink domain here.
// Can be overriden by domain settings.
// Set shortlink domain to false if not available.
set_absolute_urls($opt, 'http://www.opencaching.de/', 'opencaching.de', 2);

/* The OC site's ID; see settings-dist.inc.php for known IDs.
*/
Expand Down
Loading

0 comments on commit 6fea17b

Please sign in to comment.