Skip to content
Permalink
Browse files

moved map town list to DB; corrections and translations; updates #802

  • Loading branch information...
following5 committed Sep 3, 2015
1 parent c64f15f commit afc525cff84970f1e80a2af5d020bb21dcd04aa2
@@ -568,6 +568,23 @@ function dbv_135() // move KML cache type names from search.kml.inc.php to data
sql("ALTER TABLE `cache_type` ADD COLUMN `kml_name` varchar(10) NOT NULL");
}
function dbv_136() // move main town table from settings into database
{
if (!sql_table_exists('towns'))
{
sql("
CREATE TABLE `towns` (
`country` char(2) NOT NULL,
`name` varchar(40) NOT NULL,
`trans_id` int(10) unsigned NOT NULL,
`coord_lat` double NOT NULL,
`coord_long` double NOT NULL,
`maplist` tinyint(1) NOT NULL default '0',
KEY `country` (`country`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
}
}
// When adding new mutations, take care that they behave well if run multiple
// times. This improves robustness of database versioning.
@@ -31,8 +31,8 @@
// block troublemakers
$opt['page']['banned_user_agents'] = array();
/* Main locale and style: The country and language with most content on this site.
*
/*
* Main locale and style: The country and language with most content on this site.
*/
$opt['page']['main_country'] = 'DE';
$opt['page']['main_locale'] = 'DE';
@@ -83,7 +83,8 @@
*/
$opt['html_purifier']['cache_path'] = dirname(__FILE__).'/../cache2/html_purifier/';
/* CMS links for external pages
/*
* CMS links for external pages
*/
// explanation of common login errors
@@ -579,4 +579,50 @@
$opt['httpd']['user'] = 'apache';
$opt['httpd']['group'] = 'apache';
/*
* small map town list default settings (adjusted for OC.de)
*
* set zoom to 0 to disable a town
*/
$opt['map']['towns']['enable'] = true;
$opt['map']['towns']['DE']['enable'] = true;
$opt['map']['towns']['DE']['zoom'] = 11;
$opt['map']['towns']['AT']['enable'] = true;
$opt['map']['towns']['AT']['zoom'] = 10;
$opt['map']['towns']['CH']['enable'] = true;
$opt['map']['towns']['CH']['zoom'] = 10;
$opt['map']['towns']['IT']['enable'] = true;
$opt['map']['towns']['IT']['zoom'] = 8;
$opt['map']['towns']['IT']['Bolzano']['zoom'] = 9;
$opt['map']['towns']['IT']['Udine']['zoom'] = 9;
$opt['map']['towns']['ES']['enable'] = true;
$opt['map']['towns']['ES']['zoom'] = 9;
$opt['map']['towns']['FR']['enable'] = true;
$opt['map']['towns']['FR']['zoom'] = 9;
$opt['map']['towns']['FR']['Strasbourg']['zoom'] = 10;
// example for completely overriding small-map town list for a country:
/*
$opt['map']['towns']['IT']['enable'] = false;
$mapmenu = 2001;
$menuitem[$mapmenu+0] = array('title' => 'Bologna',
'menustring' => 'Bologna',
'authlevel' => 0,
'href' => 'map2.php?mode=normalscreen&lat=44.497&lon=11.343&zoom=8',
'visible' => 1,
'sublevel' => 1,
'parent' => MNU_MAP
);
$menuitem[$mapmenu+1] = array('title' => 'Bolzano',
'menustring' => 'Bolzano',
'authlevel' => 0,
'href' => 'map2.php?lat=46.502&lon=11.354&zoom=10',
'visible' => 1,
'sublevel' => 1,
'parent' => MNU_MAP
);
$menuitem[MNU_MAP]['subitems'][] = $mapmenu+0;
$menuitem[MNU_MAP]['subitems'][] = $mapmenu+1;
*/
?>

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,11 @@
SET NAMES 'utf8';
DROP TABLE IF EXISTS `towns`;
CREATE TABLE `towns` (
`country` char(2) NOT NULL,
`name` varchar(40) NOT NULL,
`trans_id` int(10) unsigned NOT NULL,
`coord_lat` double NOT NULL,
`coord_long` double NOT NULL,
`maplist` tinyint(1) NOT NULL default '0',
KEY `country` (`country`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
@@ -21,14 +21,60 @@ class Menu
function Menu()
{
global $opt;
global $opt, $login, $build_map_towns_menu;
$this->sMenuFilename = $opt['rootpath'] . 'cache2/menu-' . $opt['template']['locale'] . '.inc.php';
if (!file_exists($this->sMenuFilename))
$this->CreateCacheFile();
// read static menu
require_once($this->sMenuFilename);
// add country-dependent town list for small map
$country = $login->getUserCountry();
if ($opt['map']['towns']['enable'] &&
isset($build_map_towns_menu) && $build_map_towns_menu && // optimization
isset($opt['map']['towns'][$country]['enable']) && $opt['map']['towns'][$country]['enable'])
{
$rsTowns = sqlf("
SELECT
IFNULL(`stt`.`text`,`towns`.`name`) AS `name`,
`towns`.`name` AS `native_name`,
coord_lat, coord_long
FROM
`towns`
LEFT JOIN `sys_trans_text` `stt` ON `stt`.`trans_id`=`towns`.`trans_id` AND `stt`.`lang`='&2'
WHERE `towns`.`country`='&1' AND `towns`.`maplist` > 0
ORDER BY `name`",
$country, $opt['template']['locale']);
$menu_map = 2001;
while ($rTown = sql_fetch_assoc($rsTowns))
{
if (isset($opt['map']['towns'][$country][$rTown['native_name']]['zoom']))
$zoom = $opt['map']['towns'][$country][$rTown['native_name']]['zoom'];
else if (isset($opt['map']['towns'][$country]['zoom']))
$zoom = $opt['map']['towns'][$country]['zoom'];
else
$zoom = 11;
if ($zoom > 0)
{
$menuitem[$menu_map] = array(
'title' => $rTown['name'],
'menustring' => $rTown['name'],
'authlevel' => 0,
'href' => 'map2.php?mode=normalscreen&lat=' . $rTown['coord_lat'] . '&lon=' . $rTown['coord_long'] .
'&zoom=' . $zoom,
'visible' => 1,
'sublevel' => 1,
'parent' => MNU_MAP);
$menuitem[MNU_MAP]['subitems'][] = $menu_map;
++$menu_map;
}
}
}
}
function CreateCacheFile()
@@ -5,6 +5,8 @@
* Unicode Reminder メモ
***************************************************************************/
$build_map_towns_menu = true;
require('./lib2/web.inc.php');
require_once('./lib2/logic/cache.class.php');
require_once('./lib2/logic/user.class.php');
@@ -5,6 +5,12 @@
* Unicode Reminder メモ
***************************************************************************/
require('./lib2/web.inc.php');
require_once('./lib2/translate.class.php');
require_once('./lib2/translationHandler.class.php');
require_once('./lib2/translate_filescan.class.php');
require_once('./lib2/translateAccess.php');
/* config section
*/
global $msDirlist;
@@ -25,16 +31,31 @@
$msDirlist[] = './util/notification';
$msDirlist[] = './util/watchlist';
$msDirlist[] = './util2/cron/modules';
$transIdCols = array(
array( 'table' => 'attribute_categories', 'text' => 'name', 'trans_id' => 'trans_id' ),
array( 'table' => 'attribute_groups', 'text' => 'name', 'trans_id' => 'trans_id' ),
array( 'table' => 'cache_attrib', 'text' => 'name', 'trans_id' => 'trans_id' ),
array( 'table' => 'cache_attrib', 'text' => 'html_desc', 'trans_id' => 'html_desc_trans_id' ),
array( 'table' => 'cache_report_reasons', 'text' => 'name', 'trans_id' => 'trans_id' ),
array( 'table' => 'cache_report_status', 'text' => 'name', 'trans_id' => 'trans_id' ),
array( 'table' => 'cache_size', 'text' => 'name', 'trans_id' => 'trans_id' ),
array( 'table' => 'cache_status', 'text' => 'name', 'trans_id' => 'trans_id' ),
array( 'table' => 'cache_type', 'text' => 'name', 'trans_id' => 'trans_id' ),
array( 'table' => 'coordinates_type', 'text' => 'name', 'trans_id' => 'trans_id' ),
array( 'table' => 'countries', 'text' => 'name', 'trans_id' => 'trans_id' ),
array( 'table' => 'languages', 'text' => 'name', 'trans_id' => 'trans_id' ),
array( 'table' => 'log_types', 'text' => 'name', 'trans_id' => 'trans_id' ),
array( 'table' => 'profile_options', 'text' => 'name', 'trans_id' => 'trans_id' ),
array( 'table' => 'statpics', 'text' => 'description', 'trans_id' => 'trans_id' ),
array( 'table' => 'sys_menu', 'text' => 'menustring', 'trans_id' => 'menustring_trans_id' ),
array( 'table' => 'sys_menu', 'text' => 'title', 'trans_id' => 'title_trans_id' ),
array( 'table' => 'towns', 'text' => 'name', 'trans_id' => 'trans_id' ),
);
// directory libse needs to be added recursive
addClassesDirecotriesToDirlist('libse');
require('./lib2/web.inc.php');
require_once('./lib2/translate.class.php');
require_once('./lib2/translationHandler.class.php');
require_once('./lib2/translate_filescan.class.php');
require_once('./lib2/translateAccess.php');
$tpl->name = 'translate';
$tpl->menuitem = MNU_ADMIN_TRANSLATE;
@@ -333,24 +354,14 @@ function useId($freeId)
function setId($oldId, $newId)
{
global $transIdCols;
sql("UPDATE `sys_trans` SET `id`='&1' WHERE `id`='&2'", $newId, $oldId);
sql("UPDATE `sys_trans_ref` SET `trans_id`='&1' WHERE `trans_id`='&2'", $newId, $oldId);
sql("UPDATE `sys_trans_text` SET `trans_id`='&1' WHERE `trans_id`='&2'", $newId, $oldId);
sql("UPDATE `countries` SET `trans_id`='&1' WHERE `trans_id`='&2'", $newId, $oldId);
sql("UPDATE `languages` SET `trans_id`='&1' WHERE `trans_id`='&2'", $newId, $oldId);
sql("UPDATE `cache_size` SET `trans_id`='&1' WHERE `trans_id`='&2'", $newId, $oldId);
sql("UPDATE `cache_status` SET `trans_id`='&1' WHERE `trans_id`='&2'", $newId, $oldId);
sql("UPDATE `cache_type` SET `trans_id`='&1' WHERE `trans_id`='&2'", $newId, $oldId);
sql("UPDATE `log_types` SET `trans_id`='&1' WHERE `trans_id`='&2'", $newId, $oldId);
sql("UPDATE `sys_menu` SET `title_trans_id`='&1' WHERE `title_trans_id`='&2'", $newId, $oldId);
sql("UPDATE `sys_menu` SET `menustring_trans_id`='&1' WHERE `menustring_trans_id`='&2'", $newId, $oldId);
sql("UPDATE `profile_options` SET `trans_id`='&1' WHERE `trans_id`='&2'", $newId, $oldId);
sql("UPDATE `attribute_categories` SET `trans_id`='&1' WHERE `trans_id`='&2'", $newId, $oldId);
sql("UPDATE `attribute_groups` SET `trans_id`='&1' WHERE `trans_id`='&2'", $newId, $oldId);
sql("UPDATE `cache_attrib` SET `trans_id`='&1' WHERE `trans_id`='&2'", $newId, $oldId);
sql("UPDATE `cache_attrib` SET `html_desc_trans_id`='&1' WHERE `html_desc_trans_id`='&2'", $newId, $oldId);
sql("UPDATE `statpics` SET `trans_id`='&1' WHERE `trans_id`='&2'", $newId, $oldId);
sql("UPDATE `coordinates_type` SET `trans_id`='&1' WHERE `trans_id`='&2'", $newId, $oldId);
foreach ($transIdCols as $col)
sql("UPDATE `".$col['table']."` SET `".$col['trans_id']."`='&1' WHERE `".$col['trans_id']."`='&2'", $newId, $oldId);
}
function export()
@@ -391,6 +402,7 @@ function export()
$stab[] = 'sys_trans';
$stab[] = 'sys_trans_ref';
$stab[] = 'sys_trans_text';
$stab[] = 'towns';
$stab[] = 'watches_waitingtypes';
sql_export_tables_to_file($opt['rootpath'] . 'doc/sql/static-data/data.sql', $stab);
@@ -452,27 +464,12 @@ function scan()
function scanStart()
{
global $translationHandler;
global $translationHandler, $transIdCols;
$translationHandler->clearReferences();
$translationHandler->importFromTable('attribute_categories', 'name', 'trans_id');
$translationHandler->importFromTable('attribute_groups', 'name', 'trans_id');
$translationHandler->importFromTable('cache_attrib', 'name', 'trans_id');
$translationHandler->importFromTable('cache_attrib', 'html_desc', 'html_desc_trans_id');
$translationHandler->importFromTable('cache_report_reasons', 'name', 'trans_id');
$translationHandler->importFromTable('cache_report_status', 'name', 'trans_id');
$translationHandler->importFromTable('cache_size', 'name', 'trans_id');
$translationHandler->importFromTable('cache_status', 'name', 'trans_id');
$translationHandler->importFromTable('cache_type', 'name', 'trans_id');
$translationHandler->importFromTable('coordinates_type', 'name', 'trans_id');
$translationHandler->importFromTable('countries', 'name', 'trans_id');
$translationHandler->importFromTable('languages', 'name', 'trans_id');
$translationHandler->importFromTable('log_types', 'name', 'trans_id');
$translationHandler->importFromTable('profile_options', 'name', 'trans_id');
$translationHandler->importFromTable('statpics', 'description', 'trans_id');
$translationHandler->importFromTable('sys_menu', 'menustring', 'menustring_trans_id');
$translationHandler->importFromTable('sys_menu', 'title', 'title_trans_id');
foreach ($transIdCols as $col)
$translationHandler->importFromTable($col['table'], $col['text'], $col['trans_id']);
}
function scanFile($filename)

0 comments on commit afc525c

Please sign in to comment.
You can’t perform that action at this time.