@@ -54,7 +54,7 @@ |
||
54 | 54 | public function getConfigLink() { |
55 | 55 | Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
56 | 56 | |
57 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
57 | + return 'module.php?mod='.$this->getName().'&mod_action=AdminConfig'; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 |
@@ -19,59 +19,59 @@ |
||
19 | 19 | * Hooks Module. |
20 | 20 | */ |
21 | 21 | class HooksModule extends AbstractModule implements ModuleConfigInterface, DependentInterface { |
22 | - // How to update the database schema for this module |
|
23 | - const SCHEMA_TARGET_VERSION = 1; |
|
24 | - const SCHEMA_SETTING_NAME = 'MAJ_HOOKS_SCHEMA_VERSION'; |
|
25 | - const SCHEMA_MIGRATION_PREFIX = '\MyArtJaub\Webtrees\Module\Hooks\Schema'; |
|
22 | + // How to update the database schema for this module |
|
23 | + const SCHEMA_TARGET_VERSION = 1; |
|
24 | + const SCHEMA_SETTING_NAME = 'MAJ_HOOKS_SCHEMA_VERSION'; |
|
25 | + const SCHEMA_MIGRATION_PREFIX = '\MyArtJaub\Webtrees\Module\Hooks\Schema'; |
|
26 | 26 | |
27 | - /** @var string For custom modules - link for support, upgrades, etc. */ |
|
28 | - const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
27 | + /** @var string For custom modules - link for support, upgrades, etc. */ |
|
28 | + const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
29 | 29 | |
30 | - /** |
|
31 | - * {@inhericDoc} |
|
32 | - */ |
|
33 | - public function getTitle() { |
|
34 | - return /* I18N: Name of the “Hooks” module */ I18N::translate('Hooks'); |
|
35 | - } |
|
30 | + /** |
|
31 | + * {@inhericDoc} |
|
32 | + */ |
|
33 | + public function getTitle() { |
|
34 | + return /* I18N: Name of the “Hooks” module */ I18N::translate('Hooks'); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * {@inhericDoc} |
|
39 | - */ |
|
40 | - public function getDescription() { |
|
41 | - return /* I18N: Description of the “Hooks” module */ I18N::translate('Implements hooks management.'); |
|
42 | - } |
|
37 | + /** |
|
38 | + * {@inhericDoc} |
|
39 | + */ |
|
40 | + public function getDescription() { |
|
41 | + return /* I18N: Description of the “Hooks” module */ I18N::translate('Implements hooks management.'); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * {@inhericDoc} |
|
46 | - */ |
|
47 | - public function modAction($mod_action) { |
|
48 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
44 | + /** |
|
45 | + * {@inhericDoc} |
|
46 | + */ |
|
47 | + public function modAction($mod_action) { |
|
48 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
49 | 49 | |
50 | - \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
51 | - } |
|
50 | + \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * {@inhericDoc} |
|
55 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
56 | - */ |
|
57 | - public function getConfigLink() { |
|
58 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
53 | + /** |
|
54 | + * {@inhericDoc} |
|
55 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
56 | + */ |
|
57 | + public function getConfigLink() { |
|
58 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
59 | 59 | |
60 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
61 | - } |
|
60 | + return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * {@inheritDoc} |
|
65 | - * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites() |
|
66 | - */ |
|
67 | - public function validatePrerequisites() { |
|
68 | - try { |
|
69 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
70 | - return true; |
|
71 | - } |
|
72 | - catch (\Exception $ex) { } |
|
73 | - return false; |
|
74 | - } |
|
63 | + /** |
|
64 | + * {@inheritDoc} |
|
65 | + * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites() |
|
66 | + */ |
|
67 | + public function validatePrerequisites() { |
|
68 | + try { |
|
69 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
70 | + return true; |
|
71 | + } |
|
72 | + catch (\Exception $ex) { } |
|
73 | + return false; |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | 77 | } |
@@ -68,8 +68,7 @@ |
||
68 | 68 | try { |
69 | 69 | Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
70 | 70 | return true; |
71 | - } |
|
72 | - catch (\Exception $ex) { } |
|
71 | + } catch (\Exception $ex) { } |
|
73 | 72 | return false; |
74 | 73 | } |
75 | 74 |
@@ -49,62 +49,62 @@ |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | - * Protected constructor. |
|
53 | - */ |
|
54 | - protected function __construct() |
|
55 | - { |
|
56 | - $this->modules_list = array(); |
|
57 | - } |
|
52 | + * Protected constructor. |
|
53 | + */ |
|
54 | + protected function __construct() |
|
55 | + { |
|
56 | + $this->modules_list = array(); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * {@inheritDoc} |
|
61 | - * @see \MyArtJaub\Webtrees\Module\ModuleManagerInterface::isOperational() |
|
62 | - */ |
|
63 | - public function isOperational($moduleName) { |
|
64 | - if(!array_key_exists($moduleName, $this->modules_list)) { |
|
65 | - if($module = fw\Module::getModuleByName($moduleName)) { |
|
66 | - if($module instanceof DependentInterface) { |
|
67 | - if($module->validatePrerequisites()) { |
|
68 | - $this->modules_list[$moduleName] = TRUE; |
|
69 | - return true; |
|
70 | - } else { |
|
71 | - // Do not cache the result, |
|
72 | - // as they could change by the next call to the method |
|
73 | - return false; |
|
74 | - } |
|
75 | - } |
|
76 | - else { |
|
77 | - $this->modules_list[$moduleName] = TRUE; |
|
78 | - return true; |
|
79 | - } |
|
80 | - } |
|
81 | - else { |
|
82 | - $this->modules_list[$moduleName] = FALSE; |
|
83 | - } |
|
84 | - } |
|
85 | - return $this->modules_list[$moduleName]; |
|
59 | + /** |
|
60 | + * {@inheritDoc} |
|
61 | + * @see \MyArtJaub\Webtrees\Module\ModuleManagerInterface::isOperational() |
|
62 | + */ |
|
63 | + public function isOperational($moduleName) { |
|
64 | + if(!array_key_exists($moduleName, $this->modules_list)) { |
|
65 | + if($module = fw\Module::getModuleByName($moduleName)) { |
|
66 | + if($module instanceof DependentInterface) { |
|
67 | + if($module->validatePrerequisites()) { |
|
68 | + $this->modules_list[$moduleName] = TRUE; |
|
69 | + return true; |
|
70 | + } else { |
|
71 | + // Do not cache the result, |
|
72 | + // as they could change by the next call to the method |
|
73 | + return false; |
|
74 | + } |
|
75 | + } |
|
76 | + else { |
|
77 | + $this->modules_list[$moduleName] = TRUE; |
|
78 | + return true; |
|
79 | + } |
|
80 | + } |
|
81 | + else { |
|
82 | + $this->modules_list[$moduleName] = FALSE; |
|
83 | + } |
|
84 | + } |
|
85 | + return $this->modules_list[$moduleName]; |
|
86 | 86 | |
87 | - } |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * Private clone method to prevent cloning of the instance of the |
|
92 | - * *ModuleManager* instance. |
|
93 | - * |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - private function __clone() |
|
97 | - { |
|
98 | - } |
|
90 | + /** |
|
91 | + * Private clone method to prevent cloning of the instance of the |
|
92 | + * *ModuleManager* instance. |
|
93 | + * |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + private function __clone() |
|
97 | + { |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * Private unserialize method to prevent unserializing of the *ModuleManager* |
|
102 | - * instance. |
|
103 | - * |
|
104 | - * @return void |
|
105 | - */ |
|
106 | - private function __wakeup() |
|
107 | - { |
|
108 | - } |
|
100 | + /** |
|
101 | + * Private unserialize method to prevent unserializing of the *ModuleManager* |
|
102 | + * instance. |
|
103 | + * |
|
104 | + * @return void |
|
105 | + */ |
|
106 | + private function __wakeup() |
|
107 | + { |
|
108 | + } |
|
109 | 109 | |
110 | 110 | } |
@@ -61,10 +61,10 @@ |
||
61 | 61 | * @see \MyArtJaub\Webtrees\Module\ModuleManagerInterface::isOperational() |
62 | 62 | */ |
63 | 63 | public function isOperational($moduleName) { |
64 | - if(!array_key_exists($moduleName, $this->modules_list)) { |
|
65 | - if($module = fw\Module::getModuleByName($moduleName)) { |
|
66 | - if($module instanceof DependentInterface) { |
|
67 | - if($module->validatePrerequisites()) { |
|
64 | + if (!array_key_exists($moduleName, $this->modules_list)) { |
|
65 | + if ($module = fw\Module::getModuleByName($moduleName)) { |
|
66 | + if ($module instanceof DependentInterface) { |
|
67 | + if ($module->validatePrerequisites()) { |
|
68 | 68 | $this->modules_list[$moduleName] = TRUE; |
69 | 69 | return true; |
70 | 70 | } else { |
@@ -72,13 +72,11 @@ |
||
72 | 72 | // as they could change by the next call to the method |
73 | 73 | return false; |
74 | 74 | } |
75 | - } |
|
76 | - else { |
|
75 | + } else { |
|
77 | 76 | $this->modules_list[$moduleName] = TRUE; |
78 | 77 | return true; |
79 | 78 | } |
80 | - } |
|
81 | - else { |
|
79 | + } else { |
|
82 | 80 | $this->modules_list[$moduleName] = FALSE; |
83 | 81 | } |
84 | 82 | } |
@@ -28,56 +28,56 @@ |
||
28 | 28 | */ |
29 | 29 | class AdminConfigController extends MvcController |
30 | 30 | { |
31 | - /** |
|
32 | - * Manage updates sent from the AdminConfig@index form. |
|
33 | - */ |
|
34 | - protected function update() { |
|
35 | - global $WT_TREE; |
|
31 | + /** |
|
32 | + * Manage updates sent from the AdminConfig@index form. |
|
33 | + */ |
|
34 | + protected function update() { |
|
35 | + global $WT_TREE; |
|
36 | 36 | |
37 | - if(Auth::isAdmin()){ |
|
37 | + if(Auth::isAdmin()){ |
|
38 | 38 | |
39 | - $this->module->setSetting('MAJ_TITLE_PREFIX', Filter::post('MAJ_TITLE_PREFIX')); |
|
39 | + $this->module->setSetting('MAJ_TITLE_PREFIX', Filter::post('MAJ_TITLE_PREFIX')); |
|
40 | 40 | |
41 | - $this->module->setSetting('MAJ_ADD_HTML_HEADER', Filter::postInteger('MAJ_ADD_HTML_HEADER', 0, 1)); |
|
42 | - $this->module->setSetting('MAJ_SHOW_HTML_HEADER', Filter::postInteger('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE)); |
|
43 | - $this->module->setSetting('MAJ_HTML_HEADER', Filter::post('MAJ_HTML_HEADER')); |
|
41 | + $this->module->setSetting('MAJ_ADD_HTML_HEADER', Filter::postInteger('MAJ_ADD_HTML_HEADER', 0, 1)); |
|
42 | + $this->module->setSetting('MAJ_SHOW_HTML_HEADER', Filter::postInteger('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE)); |
|
43 | + $this->module->setSetting('MAJ_HTML_HEADER', Filter::post('MAJ_HTML_HEADER')); |
|
44 | 44 | |
45 | - $this->module->setSetting('MAJ_ADD_HTML_FOOTER', Filter::postInteger('MAJ_ADD_HTML_FOOTER', 0, 1)); |
|
46 | - $this->module->setSetting('MAJ_SHOW_HTML_FOOTER', Filter::postInteger('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE)); |
|
47 | - $this->module->setSetting('MAJ_HTML_FOOTER', Filter::post('MAJ_HTML_FOOTER')); |
|
45 | + $this->module->setSetting('MAJ_ADD_HTML_FOOTER', Filter::postInteger('MAJ_ADD_HTML_FOOTER', 0, 1)); |
|
46 | + $this->module->setSetting('MAJ_SHOW_HTML_FOOTER', Filter::postInteger('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE)); |
|
47 | + $this->module->setSetting('MAJ_HTML_FOOTER', Filter::post('MAJ_HTML_FOOTER')); |
|
48 | 48 | |
49 | - $this->module->setSetting('MAJ_DISPLAY_CNIL', Filter::postInteger('MAJ_DISPLAY_CNIL', 0, 1)); |
|
50 | - $this->module->setSetting('MAJ_CNIL_REFERENCE', Filter::post('MAJ_CNIL_REFERENCE')); |
|
49 | + $this->module->setSetting('MAJ_DISPLAY_CNIL', Filter::postInteger('MAJ_DISPLAY_CNIL', 0, 1)); |
|
50 | + $this->module->setSetting('MAJ_CNIL_REFERENCE', Filter::post('MAJ_CNIL_REFERENCE')); |
|
51 | 51 | |
52 | - FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success'); |
|
52 | + FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success'); |
|
53 | 53 | |
54 | - return; |
|
55 | - } |
|
56 | - } |
|
54 | + return; |
|
55 | + } |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Pages |
|
60 | - */ |
|
58 | + /** |
|
59 | + * Pages |
|
60 | + */ |
|
61 | 61 | |
62 | - /** |
|
63 | - * AdminConfig@index |
|
64 | - */ |
|
65 | - public function index() { |
|
66 | - global $WT_TREE; |
|
62 | + /** |
|
63 | + * AdminConfig@index |
|
64 | + */ |
|
65 | + public function index() { |
|
66 | + global $WT_TREE; |
|
67 | 67 | |
68 | - $action = Filter::post('action'); |
|
69 | - if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
68 | + $action = Filter::post('action'); |
|
69 | + if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
70 | 70 | |
71 | - Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
72 | - $ctrl = new PageController(); |
|
73 | - $ctrl |
|
74 | - ->restrictAccess(Auth::isAdmin()) |
|
75 | - ->setPageTitle($this->module->getTitle()); |
|
71 | + Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
72 | + $ctrl = new PageController(); |
|
73 | + $ctrl |
|
74 | + ->restrictAccess(Auth::isAdmin()) |
|
75 | + ->setPageTitle($this->module->getTitle()); |
|
76 | 76 | |
77 | - $view_bag = new ViewBag(); |
|
78 | - $view_bag->set('title', $ctrl->getPageTitle()); |
|
79 | - $view_bag->set('module', $this->module); |
|
77 | + $view_bag = new ViewBag(); |
|
78 | + $view_bag->set('title', $ctrl->getPageTitle()); |
|
79 | + $view_bag->set('module', $this->module); |
|
80 | 80 | |
81 | - ViewFactory::make('AdminConfig', $this, $ctrl, $view_bag)->render(); |
|
82 | - } |
|
81 | + ViewFactory::make('AdminConfig', $this, $ctrl, $view_bag)->render(); |
|
82 | + } |
|
83 | 83 | } |
84 | 84 | \ No newline at end of file |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | protected function update() { |
35 | 35 | global $WT_TREE; |
36 | 36 | |
37 | - if(Auth::isAdmin()){ |
|
37 | + if (Auth::isAdmin()) { |
|
38 | 38 | |
39 | 39 | $this->module->setSetting('MAJ_TITLE_PREFIX', Filter::post('MAJ_TITLE_PREFIX')); |
40 | 40 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | global $WT_TREE; |
67 | 67 | |
68 | 68 | $action = Filter::post('action'); |
69 | - if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
69 | + if ($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
70 | 70 | |
71 | 71 | Theme::theme(new AdministrationTheme)->init($WT_TREE); |
72 | 72 | $ctrl = new PageController(); |
@@ -88,7 +88,9 @@ |
||
88 | 88 | global $WT_TREE; |
89 | 89 | |
90 | 90 | $action = Filter::post('action'); |
91 | - if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
91 | + if($action == 'update' && Filter::checkCsrf()) { |
|
92 | + $this->update(); |
|
93 | + } |
|
92 | 94 | |
93 | 95 | Theme::theme(new AdministrationTheme)->init($WT_TREE); |
94 | 96 | $ctrl = new PageController(); |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | * {@inhericDoc} |
29 | 29 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
30 | 30 | */ |
31 | - protected function renderContent() { |
|
31 | + protected function renderContent() { |
|
32 | 32 | |
33 | - if (Module::getModuleByName('ckeditor')) { |
|
34 | - CkeditorModule::enableEditor($this->ctrl); |
|
35 | - } |
|
33 | + if (Module::getModuleByName('ckeditor')) { |
|
34 | + CkeditorModule::enableEditor($this->ctrl); |
|
35 | + } |
|
36 | 36 | |
37 | - /** @var AbstractModule $module */ |
|
38 | - $module = $this->data->get('module'); |
|
39 | - ?> |
|
37 | + /** @var AbstractModule $module */ |
|
38 | + $module = $this->data->get('module'); |
|
39 | + ?> |
|
40 | 40 | <ol class="breadcrumb small"> |
41 | 41 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
42 | 42 | <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li> |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | </form> |
188 | 188 | |
189 | 189 | <?php |
190 | - } |
|
190 | + } |
|
191 | 191 | |
192 | 192 | } |
193 | 193 | |
194 | 194 | \ No newline at end of file |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return (OutlineMap|null) |
46 | 46 | */ |
47 | - public function getMap(){ |
|
47 | + public function getMap() { |
|
48 | 48 | return $this->map; |
49 | 49 | } |
50 | 50 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return int |
66 | 66 | */ |
67 | - public function getMapLevel(){ |
|
67 | + public function getMapLevel() { |
|
68 | 68 | return $this->map_level; |
69 | 69 | } |
70 | 70 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | - public function isUsingFlags(){ |
|
87 | + public function isUsingFlags() { |
|
88 | 88 | return $this->use_flags; |
89 | 89 | } |
90 | 90 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return int |
106 | 106 | */ |
107 | - public function getMaxDetailsInGen(){ |
|
107 | + public function getMaxDetailsInGen() { |
|
108 | 108 | return $this->max_details_in_gen; |
109 | 109 | } |
110 | 110 |
@@ -15,58 +15,58 @@ discard block |
||
15 | 15 | */ |
16 | 16 | class GeoDisplayOptions { |
17 | 17 | |
18 | - /** |
|
18 | + /** |
|
19 | 19 | * Outline map to be used for diaplay |
20 | - * @var (null|OutlineMap) $map |
|
21 | - */ |
|
22 | - protected $map; |
|
20 | + * @var (null|OutlineMap) $map |
|
21 | + */ |
|
22 | + protected $map; |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Level in the Gedcom hierarchy of the parent level of the outline map. |
26 | 26 | * @var int $map_level |
27 | 27 | */ |
28 | - protected $map_level; |
|
28 | + protected $map_level; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Option to use flags in places display, instead of or in addition to the name. |
32 | 32 | * @var bool $use_flags |
33 | 33 | */ |
34 | - protected $use_flags; |
|
34 | + protected $use_flags; |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Option to define the number of top places to display in the generation view. |
38 | 38 | * @var int $max_details_in_gen |
39 | 39 | */ |
40 | - protected $max_details_in_gen; |
|
40 | + protected $max_details_in_gen; |
|
41 | 41 | |
42 | - /** |
|
42 | + /** |
|
43 | 43 | * Get the outline map to use for display. |
44 | 44 | * |
45 | - * @return (OutlineMap|null) |
|
46 | - */ |
|
47 | - public function getMap(){ |
|
48 | - return $this->map; |
|
49 | - } |
|
45 | + * @return (OutlineMap|null) |
|
46 | + */ |
|
47 | + public function getMap(){ |
|
48 | + return $this->map; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Set the outline map to use for display. |
53 | 53 | * |
54 | - * @param (OutlineMap|null) $map |
|
54 | + * @param (OutlineMap|null) $map |
|
55 | 55 | * @return self Enable method-chaining |
56 | - */ |
|
57 | - public function setMap(OutlineMap $map = null) { |
|
58 | - $this->map = $map; |
|
59 | - return $this; |
|
60 | - } |
|
56 | + */ |
|
57 | + public function setMap(OutlineMap $map = null) { |
|
58 | + $this->map = $map; |
|
59 | + return $this; |
|
60 | + } |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Get the level of the map parent place |
64 | 64 | * |
65 | 65 | * @return int |
66 | 66 | */ |
67 | - public function getMapLevel(){ |
|
68 | - return $this->map_level; |
|
69 | - } |
|
67 | + public function getMapLevel(){ |
|
68 | + return $this->map_level; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Set the level of the map parent place |
@@ -74,19 +74,19 @@ discard block |
||
74 | 74 | * @param int $maplevel |
75 | 75 | * @return self Enable method-chaining |
76 | 76 | */ |
77 | - public function setMapLevel($maplevel) { |
|
78 | - $this->map_level = $maplevel; |
|
79 | - return $this; |
|
80 | - } |
|
77 | + public function setMapLevel($maplevel) { |
|
78 | + $this->map_level = $maplevel; |
|
79 | + return $this; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Get whether flags should be used in places display |
84 | 84 | * |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | - public function isUsingFlags(){ |
|
88 | - return $this->use_flags; |
|
89 | - } |
|
87 | + public function isUsingFlags(){ |
|
88 | + return $this->use_flags; |
|
89 | + } |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Set whether flags should be used in places display |
@@ -94,19 +94,19 @@ discard block |
||
94 | 94 | * @param bool $use_flags |
95 | 95 | * @return self Enable method-chaining |
96 | 96 | */ |
97 | - public function setUsingFlags($use_flags) { |
|
98 | - $this->use_flags = $use_flags; |
|
99 | - return $this; |
|
100 | - } |
|
97 | + public function setUsingFlags($use_flags) { |
|
98 | + $this->use_flags = $use_flags; |
|
99 | + return $this; |
|
100 | + } |
|
101 | 101 | |
102 | 102 | /** |
103 | 103 | * Get the number of Top Places in the generation view |
104 | 104 | * |
105 | 105 | * @return int |
106 | 106 | */ |
107 | - public function getMaxDetailsInGen(){ |
|
108 | - return $this->max_details_in_gen; |
|
109 | - } |
|
107 | + public function getMaxDetailsInGen(){ |
|
108 | + return $this->max_details_in_gen; |
|
109 | + } |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Set the number of Top Places in the generation view |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | * @param int $max_details_in_gen |
115 | 115 | * @return self Enable method-chaining |
116 | 116 | */ |
117 | - public function setMaxDetailsInGen($max_details_in_gen) { |
|
118 | - $this->max_details_in_gen = $max_details_in_gen; |
|
119 | - return $this; |
|
120 | - } |
|
117 | + public function setMaxDetailsInGen($max_details_in_gen) { |
|
118 | + $this->max_details_in_gen = $max_details_in_gen; |
|
119 | + return $this; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | } |
123 | 123 | |
124 | 124 | \ No newline at end of file |
@@ -19,49 +19,49 @@ discard block |
||
19 | 19 | * Width of the map (in pixels). |
20 | 20 | * @var int $width |
21 | 21 | */ |
22 | - public $width; |
|
22 | + public $width; |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Height of the map (in pixels). |
26 | 26 | * @var int $height |
27 | 27 | */ |
28 | - public $height; |
|
28 | + public $height; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Background color for the map shapes with values (when no transparency if applied). |
32 | 32 | * @var string $max_color |
33 | 33 | */ |
34 | - public $max_color; |
|
34 | + public $max_color; |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Background color for the map shapes when hovered. |
38 | 38 | * @var string $hover_color |
39 | 39 | */ |
40 | - public $hover_color; |
|
40 | + public $hover_color; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Background color for the map. |
44 | 44 | * @var string $background_color |
45 | 45 | */ |
46 | - public $background_color; |
|
46 | + public $background_color; |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Border color for the map. |
50 | 50 | * @var string $background_stroke |
51 | 51 | */ |
52 | - public $background_stroke; |
|
52 | + public $background_stroke; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Default color for the shapes (without any value). |
56 | 56 | * @var string $default_color |
57 | 57 | */ |
58 | - public $default_color; |
|
58 | + public $default_color; |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Default border color for the shapes. |
62 | 62 | * @var string $default_stroke |
63 | 63 | */ |
64 | - public $default_stroke; |
|
64 | + public $default_stroke; |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Constructor for OutlineMapCanvas. |
@@ -75,25 +75,25 @@ discard block |
||
75 | 75 | * @param string $default_color Default background color for the shapes |
76 | 76 | * @param string $default_stroke Default border color for the shapes |
77 | 77 | */ |
78 | - public function __construct( |
|
79 | - $width, |
|
80 | - $height, |
|
81 | - $max_color, |
|
82 | - $hover_color, |
|
83 | - $background_color, |
|
84 | - $background_stroke, |
|
85 | - $default_color, |
|
86 | - $default_stroke |
|
87 | - ) { |
|
88 | - $this->width = $width; |
|
89 | - $this->height = $height; |
|
90 | - $this->max_color = $max_color; |
|
91 | - $this->hover_color = $hover_color; |
|
92 | - $this->background_color = $background_color; |
|
93 | - $this->background_stroke = $background_stroke; |
|
94 | - $this->default_color = $default_color; |
|
95 | - $this->default_stroke = $default_stroke; |
|
96 | - } |
|
78 | + public function __construct( |
|
79 | + $width, |
|
80 | + $height, |
|
81 | + $max_color, |
|
82 | + $hover_color, |
|
83 | + $background_color, |
|
84 | + $background_stroke, |
|
85 | + $default_color, |
|
86 | + $default_stroke |
|
87 | + ) { |
|
88 | + $this->width = $width; |
|
89 | + $this->height = $height; |
|
90 | + $this->max_color = $max_color; |
|
91 | + $this->hover_color = $hover_color; |
|
92 | + $this->background_color = $background_color; |
|
93 | + $this->background_stroke = $background_stroke; |
|
94 | + $this->default_color = $default_color; |
|
95 | + $this->default_stroke = $default_stroke; |
|
96 | + } |
|
97 | 97 | |
98 | 98 | |
99 | 99 | } |
@@ -167,8 +167,7 @@ discard block |
||
167 | 167 | $ga = $this->getGeoAnalysis($id, false); |
168 | 168 | |
169 | 169 | $id = Database::commit(); |
170 | - } |
|
171 | - catch(\Exception $ex) { |
|
170 | + } catch(\Exception $ex) { |
|
172 | 171 | Database::rollback(); |
173 | 172 | $ga = null; |
174 | 173 | Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage()); |
@@ -210,8 +209,7 @@ discard block |
||
210 | 209 | $ga = $this->getGeoAnalysis($ga->getId(), false); |
211 | 210 | |
212 | 211 | $id = Database::commit(); |
213 | - } |
|
214 | - catch(\Exception $ex) { |
|
212 | + } catch(\Exception $ex) { |
|
215 | 213 | Database::rollback(); |
216 | 214 | Log::addErrorLog('The Geo Analysis ID “' . $ga->getId() . '” failed to be updated. Transaction rollbacked. Exception: '.$ex->getMessage()); |
217 | 215 | $ga = null; |
@@ -350,8 +348,7 @@ discard block |
||
350 | 348 | if(!$this->place_hierarchy) { |
351 | 349 | if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
352 | 350 | $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
353 | - } |
|
354 | - else { |
|
351 | + } else { |
|
355 | 352 | $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData()); |
356 | 353 | } |
357 | 354 | } |
@@ -21,130 +21,130 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class GeoAnalysisProvider { |
23 | 23 | |
24 | - /** |
|
25 | - * Reference tree |
|
26 | - * @var Tree $tree |
|
27 | - */ |
|
28 | - protected $tree; |
|
24 | + /** |
|
25 | + * Reference tree |
|
26 | + * @var Tree $tree |
|
27 | + */ |
|
28 | + protected $tree; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Cached hierarchy of places in the Gedcom file. |
|
32 | - * |
|
33 | - * @var (array|null) $place_hierarchy |
|
34 | - */ |
|
35 | - protected $place_hierarchy; |
|
30 | + /** |
|
31 | + * Cached hierarchy of places in the Gedcom file. |
|
32 | + * |
|
33 | + * @var (array|null) $place_hierarchy |
|
34 | + */ |
|
35 | + protected $place_hierarchy; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor for GeoAnalysis Provider. |
|
39 | - * A provider is defined in relation to a specific tree. |
|
40 | - * |
|
41 | - * @param Tree $tree |
|
42 | - */ |
|
43 | - public function __construct(Tree $tree) { |
|
44 | - $this->tree = $tree; |
|
45 | - $this->place_hierarchy = null; |
|
46 | - } |
|
37 | + /** |
|
38 | + * Constructor for GeoAnalysis Provider. |
|
39 | + * A provider is defined in relation to a specific tree. |
|
40 | + * |
|
41 | + * @param Tree $tree |
|
42 | + */ |
|
43 | + public function __construct(Tree $tree) { |
|
44 | + $this->tree = $tree; |
|
45 | + $this->place_hierarchy = null; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Creates and returns a GeoAnalysis object from a data row. |
|
50 | - * The row data is expected to be an array with the indexes: |
|
51 | - * - majgd_id: geodispersion analysis ID |
|
52 | - * - majgd_descr: geodispersion analysis description/title |
|
53 | - * - majgd_sublevel: Analysis level |
|
54 | - * - majgd_useflagsgen: Use flags in places display |
|
55 | - * - majgd_detailsgen: Number of top places |
|
56 | - * - majgd_map: file name of the map |
|
57 | - * - majgd_toplevel: parent level for the map |
|
58 | - * |
|
59 | - * @param array $row |
|
60 | - * @return GeoAnalysis |
|
61 | - */ |
|
62 | - protected function loadGeoAnalysisFromRow($row) { |
|
63 | - $options = new GeoDisplayOptions(); |
|
64 | - $options |
|
65 | - ->setUsingFlags($row['majgd_useflagsgen'] == 'yes') |
|
66 | - ->setMaxDetailsInGen($row['majgd_detailsgen']); |
|
48 | + /** |
|
49 | + * Creates and returns a GeoAnalysis object from a data row. |
|
50 | + * The row data is expected to be an array with the indexes: |
|
51 | + * - majgd_id: geodispersion analysis ID |
|
52 | + * - majgd_descr: geodispersion analysis description/title |
|
53 | + * - majgd_sublevel: Analysis level |
|
54 | + * - majgd_useflagsgen: Use flags in places display |
|
55 | + * - majgd_detailsgen: Number of top places |
|
56 | + * - majgd_map: file name of the map |
|
57 | + * - majgd_toplevel: parent level for the map |
|
58 | + * |
|
59 | + * @param array $row |
|
60 | + * @return GeoAnalysis |
|
61 | + */ |
|
62 | + protected function loadGeoAnalysisFromRow($row) { |
|
63 | + $options = new GeoDisplayOptions(); |
|
64 | + $options |
|
65 | + ->setUsingFlags($row['majgd_useflagsgen'] == 'yes') |
|
66 | + ->setMaxDetailsInGen($row['majgd_detailsgen']); |
|
67 | 67 | |
68 | - if($row['majgd_map']) { |
|
69 | - $options |
|
70 | - ->setMap(new OutlineMap($row['majgd_map'])) |
|
71 | - ->setMapLevel($row['majgd_toplevel']); |
|
72 | - } |
|
68 | + if($row['majgd_map']) { |
|
69 | + $options |
|
70 | + ->setMap(new OutlineMap($row['majgd_map'])) |
|
71 | + ->setMapLevel($row['majgd_toplevel']); |
|
72 | + } |
|
73 | 73 | |
74 | - $enabled = true; |
|
75 | - if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
76 | - $enabled = false; |
|
77 | - } |
|
74 | + $enabled = true; |
|
75 | + if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
76 | + $enabled = false; |
|
77 | + } |
|
78 | 78 | |
79 | - return new GeoAnalysis( |
|
80 | - $this->tree, |
|
81 | - $row['majgd_id'], |
|
82 | - $row['majgd_descr'], |
|
83 | - $row['majgd_sublevel'], |
|
84 | - $options, |
|
85 | - $enabled |
|
86 | - ); |
|
87 | - } |
|
79 | + return new GeoAnalysis( |
|
80 | + $this->tree, |
|
81 | + $row['majgd_id'], |
|
82 | + $row['majgd_descr'], |
|
83 | + $row['majgd_sublevel'], |
|
84 | + $options, |
|
85 | + $enabled |
|
86 | + ); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Returns the number of geographical analysis (active and inactive). |
|
91 | - * |
|
92 | - * @return int |
|
93 | - */ |
|
94 | - public function getGeoAnalysisCount() { |
|
95 | - return Database::prepare( |
|
96 | - 'SELECT COUNT(majgd_id)' . |
|
97 | - ' FROM `##maj_geodispersion`' . |
|
98 | - ' WHERE majgd_file = :gedcom_id' |
|
99 | - )->execute(array( |
|
100 | - 'gedcom_id' => $this->tree->getTreeId() |
|
101 | - ))->fetchOne(); |
|
102 | - } |
|
89 | + /** |
|
90 | + * Returns the number of geographical analysis (active and inactive). |
|
91 | + * |
|
92 | + * @return int |
|
93 | + */ |
|
94 | + public function getGeoAnalysisCount() { |
|
95 | + return Database::prepare( |
|
96 | + 'SELECT COUNT(majgd_id)' . |
|
97 | + ' FROM `##maj_geodispersion`' . |
|
98 | + ' WHERE majgd_file = :gedcom_id' |
|
99 | + )->execute(array( |
|
100 | + 'gedcom_id' => $this->tree->getTreeId() |
|
101 | + ))->fetchOne(); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Get a geographical analysis by its ID. |
|
106 | - * The function can only search for only enabled analysis, or all. |
|
107 | - * |
|
108 | - * @param int $id geodispersion analysis ID |
|
109 | - * @param bool $only_enabled Search for only enabled geodispersion analysis |
|
110 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL |
|
111 | - */ |
|
112 | - public function getGeoAnalysis($id, $only_enabled = true) { |
|
113 | - $args = array ( |
|
114 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
115 | - 'ga_id' => $id |
|
116 | - ); |
|
104 | + /** |
|
105 | + * Get a geographical analysis by its ID. |
|
106 | + * The function can only search for only enabled analysis, or all. |
|
107 | + * |
|
108 | + * @param int $id geodispersion analysis ID |
|
109 | + * @param bool $only_enabled Search for only enabled geodispersion analysis |
|
110 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL |
|
111 | + */ |
|
112 | + public function getGeoAnalysis($id, $only_enabled = true) { |
|
113 | + $args = array ( |
|
114 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
115 | + 'ga_id' => $id |
|
116 | + ); |
|
117 | 117 | |
118 | - $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
119 | - ' FROM `##maj_geodispersion`' . |
|
120 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; |
|
121 | - if($only_enabled) { |
|
122 | - $sql .= ' AND majgd_status = :status'; |
|
123 | - $args['status'] = 'enabled'; |
|
124 | - } |
|
125 | - $sql .= ' ORDER BY majgd_descr'; |
|
118 | + $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
119 | + ' FROM `##maj_geodispersion`' . |
|
120 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; |
|
121 | + if($only_enabled) { |
|
122 | + $sql .= ' AND majgd_status = :status'; |
|
123 | + $args['status'] = 'enabled'; |
|
124 | + } |
|
125 | + $sql .= ' ORDER BY majgd_descr'; |
|
126 | 126 | |
127 | - $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); |
|
127 | + $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); |
|
128 | 128 | |
129 | - if($ga_array) { |
|
130 | - return $this->loadGeoAnalysisFromRow($ga_array); |
|
131 | - } |
|
129 | + if($ga_array) { |
|
130 | + return $this->loadGeoAnalysisFromRow($ga_array); |
|
131 | + } |
|
132 | 132 | |
133 | - return null; |
|
134 | - } |
|
133 | + return null; |
|
134 | + } |
|
135 | 135 | |
136 | - /** |
|
137 | - * Add a new geodispersion analysis in the database, in a transactional manner. |
|
138 | - * When successful, eturns the newly created GeoAnalysis object. |
|
139 | - * |
|
140 | - * @param string $description geodispersion analysis title |
|
141 | - * @param int $analysis_level Analysis level |
|
142 | - * @param string $map_file Filename of the map |
|
143 | - * @param int $map_top_level Parent level of the map |
|
144 | - * @param bool $use_flags Use flag in the place display |
|
145 | - * @param int $gen_details Number of top places to display |
|
146 | - * @return GeoAnalysis |
|
147 | - */ |
|
136 | + /** |
|
137 | + * Add a new geodispersion analysis in the database, in a transactional manner. |
|
138 | + * When successful, eturns the newly created GeoAnalysis object. |
|
139 | + * |
|
140 | + * @param string $description geodispersion analysis title |
|
141 | + * @param int $analysis_level Analysis level |
|
142 | + * @param string $map_file Filename of the map |
|
143 | + * @param int $map_top_level Parent level of the map |
|
144 | + * @param bool $use_flags Use flag in the place display |
|
145 | + * @param int $gen_details Number of top places to display |
|
146 | + * @return GeoAnalysis |
|
147 | + */ |
|
148 | 148 | public function createGeoAnalysis($description, $analysis_level, $map_file, $map_top_level, $use_flags, $gen_details) { |
149 | 149 | try{ |
150 | 150 | Database::beginTransaction(); |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage()); |
175 | 175 | } |
176 | 176 | return $ga; |
177 | - } |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Update a geodispersion analysis in the database, in transactional manner. |
|
181 | - * When successful, returns the updated GeoAnalysis object |
|
182 | - * |
|
183 | - * @param GeoAnalysis $ga |
|
184 | - * @return GeoAnalysis |
|
185 | - */ |
|
186 | - public function updateGeoAnalysis(GeoAnalysis $ga) { |
|
187 | - try { |
|
179 | + /** |
|
180 | + * Update a geodispersion analysis in the database, in transactional manner. |
|
181 | + * When successful, returns the updated GeoAnalysis object |
|
182 | + * |
|
183 | + * @param GeoAnalysis $ga |
|
184 | + * @return GeoAnalysis |
|
185 | + */ |
|
186 | + public function updateGeoAnalysis(GeoAnalysis $ga) { |
|
187 | + try { |
|
188 | 188 | Database::beginTransaction(); |
189 | 189 | |
190 | 190 | Database::prepare( |
@@ -217,236 +217,236 @@ discard block |
||
217 | 217 | $ga = null; |
218 | 218 | } |
219 | 219 | return $ga; |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - /** |
|
223 | - * Set the status of a specific analysis. |
|
224 | - * The status can be enabled (true), or disabled (false). |
|
225 | - * |
|
226 | - * @param GeoAnalysis $ga |
|
227 | - * @param bool $status |
|
228 | - */ |
|
229 | - public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) { |
|
230 | - Database::prepare( |
|
231 | - 'UPDATE `##maj_geodispersion`'. |
|
232 | - ' SET majgd_status = :status'. |
|
233 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
234 | - )->execute(array( |
|
235 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
236 | - 'status' => $status ? 'enabled' : 'disabled', |
|
237 | - 'ga_id' => $ga->getId() |
|
238 | - )); |
|
239 | - } |
|
222 | + /** |
|
223 | + * Set the status of a specific analysis. |
|
224 | + * The status can be enabled (true), or disabled (false). |
|
225 | + * |
|
226 | + * @param GeoAnalysis $ga |
|
227 | + * @param bool $status |
|
228 | + */ |
|
229 | + public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) { |
|
230 | + Database::prepare( |
|
231 | + 'UPDATE `##maj_geodispersion`'. |
|
232 | + ' SET majgd_status = :status'. |
|
233 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
234 | + )->execute(array( |
|
235 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
236 | + 'status' => $status ? 'enabled' : 'disabled', |
|
237 | + 'ga_id' => $ga->getId() |
|
238 | + )); |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Delete a geodispersion analysis from the database. |
|
243 | - * |
|
244 | - * @param GeoAnalysis $ga |
|
245 | - */ |
|
246 | - public function deleteGeoAnalysis(GeoAnalysis $ga) { |
|
247 | - Database::prepare( |
|
248 | - 'DELETE FROM `##maj_geodispersion`'. |
|
249 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
250 | - )->execute(array( |
|
251 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
252 | - 'ga_id' => $ga->getId() |
|
253 | - )); |
|
254 | - } |
|
241 | + /** |
|
242 | + * Delete a geodispersion analysis from the database. |
|
243 | + * |
|
244 | + * @param GeoAnalysis $ga |
|
245 | + */ |
|
246 | + public function deleteGeoAnalysis(GeoAnalysis $ga) { |
|
247 | + Database::prepare( |
|
248 | + 'DELETE FROM `##maj_geodispersion`'. |
|
249 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
250 | + )->execute(array( |
|
251 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
252 | + 'ga_id' => $ga->getId() |
|
253 | + )); |
|
254 | + } |
|
255 | 255 | |
256 | - /** |
|
257 | - * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM |
|
258 | - * |
|
259 | - * @return array List of enabled maps |
|
260 | - */ |
|
261 | - public function getGeoAnalysisList(){ |
|
262 | - $res = array(); |
|
256 | + /** |
|
257 | + * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM |
|
258 | + * |
|
259 | + * @return array List of enabled maps |
|
260 | + */ |
|
261 | + public function getGeoAnalysisList(){ |
|
262 | + $res = array(); |
|
263 | 263 | |
264 | - $list = Database::prepare( |
|
265 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . |
|
266 | - ' FROM `##maj_geodispersion`' . |
|
267 | - ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. |
|
268 | - ' ORDER BY majgd_descr' |
|
269 | - )->execute(array( |
|
270 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
271 | - 'status' => 'enabled' |
|
272 | - ))->fetchAll(\PDO::FETCH_ASSOC); |
|
264 | + $list = Database::prepare( |
|
265 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . |
|
266 | + ' FROM `##maj_geodispersion`' . |
|
267 | + ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. |
|
268 | + ' ORDER BY majgd_descr' |
|
269 | + )->execute(array( |
|
270 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
271 | + 'status' => 'enabled' |
|
272 | + ))->fetchAll(\PDO::FETCH_ASSOC); |
|
273 | 273 | |
274 | - foreach($list as $ga) { |
|
275 | - $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
276 | - } |
|
274 | + foreach($list as $ga) { |
|
275 | + $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
276 | + } |
|
277 | 277 | |
278 | - return $res; |
|
279 | - } |
|
278 | + return $res; |
|
279 | + } |
|
280 | 280 | |
281 | - /** |
|
282 | - * Return the list of geodispersion analysis matching specified criterias. |
|
283 | - * |
|
284 | - * @param string $search Search criteria in analysis description |
|
285 | - * @param array $order_by Columns to order by |
|
286 | - * @param int $start Offset to start with (for pagination) |
|
287 | - * @param int|null $limit Max number of items to return (for pagination) |
|
288 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
289 | - */ |
|
290 | - public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ |
|
291 | - $res = array(); |
|
281 | + /** |
|
282 | + * Return the list of geodispersion analysis matching specified criterias. |
|
283 | + * |
|
284 | + * @param string $search Search criteria in analysis description |
|
285 | + * @param array $order_by Columns to order by |
|
286 | + * @param int $start Offset to start with (for pagination) |
|
287 | + * @param int|null $limit Max number of items to return (for pagination) |
|
288 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
289 | + */ |
|
290 | + public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ |
|
291 | + $res = array(); |
|
292 | 292 | |
293 | - $sql = |
|
294 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
295 | - ' FROM `##maj_geodispersion`' . |
|
296 | - ' WHERE majgd_file = :gedcom_id'; |
|
293 | + $sql = |
|
294 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
295 | + ' FROM `##maj_geodispersion`' . |
|
296 | + ' WHERE majgd_file = :gedcom_id'; |
|
297 | 297 | |
298 | - $args = array('gedcom_id'=> $this->tree->getTreeId()); |
|
298 | + $args = array('gedcom_id'=> $this->tree->getTreeId()); |
|
299 | 299 | |
300 | - if($search) { |
|
301 | - $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; |
|
302 | - $args['search'] = $search; |
|
303 | - } |
|
300 | + if($search) { |
|
301 | + $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; |
|
302 | + $args['search'] = $search; |
|
303 | + } |
|
304 | 304 | |
305 | - if ($order_by) { |
|
306 | - $sql .= ' ORDER BY '; |
|
307 | - foreach ($order_by as $key => $value) { |
|
308 | - if ($key > 0) { |
|
309 | - $sql .= ','; |
|
310 | - } |
|
305 | + if ($order_by) { |
|
306 | + $sql .= ' ORDER BY '; |
|
307 | + foreach ($order_by as $key => $value) { |
|
308 | + if ($key > 0) { |
|
309 | + $sql .= ','; |
|
310 | + } |
|
311 | 311 | |
312 | - switch ($value['dir']) { |
|
313 | - case 'asc': |
|
314 | - $sql .= $value['column'] . ' ASC '; |
|
315 | - break; |
|
316 | - case 'desc': |
|
317 | - $sql .= $value['column'] . ' DESC '; |
|
318 | - break; |
|
319 | - } |
|
320 | - } |
|
321 | - } else { |
|
322 | - $sql = " ORDER BY majgd_descr ASC"; |
|
323 | - } |
|
312 | + switch ($value['dir']) { |
|
313 | + case 'asc': |
|
314 | + $sql .= $value['column'] . ' ASC '; |
|
315 | + break; |
|
316 | + case 'desc': |
|
317 | + $sql .= $value['column'] . ' DESC '; |
|
318 | + break; |
|
319 | + } |
|
320 | + } |
|
321 | + } else { |
|
322 | + $sql = " ORDER BY majgd_descr ASC"; |
|
323 | + } |
|
324 | 324 | |
325 | - if ($limit) { |
|
326 | - $sql .= " LIMIT :limit OFFSET :offset"; |
|
327 | - $args['limit'] = $limit; |
|
328 | - $args['offset'] = $start; |
|
329 | - } |
|
325 | + if ($limit) { |
|
326 | + $sql .= " LIMIT :limit OFFSET :offset"; |
|
327 | + $args['limit'] = $limit; |
|
328 | + $args['offset'] = $start; |
|
329 | + } |
|
330 | 330 | |
331 | - $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); |
|
331 | + $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); |
|
332 | 332 | |
333 | - foreach($data as $ga) { |
|
334 | - $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
335 | - } |
|
333 | + foreach($data as $ga) { |
|
334 | + $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
335 | + } |
|
336 | 336 | |
337 | - return $res; |
|
338 | - } |
|
337 | + return $res; |
|
338 | + } |
|
339 | 339 | |
340 | - /** |
|
341 | - * Returns the infered place hierarchy, determined from the Gedcom data. |
|
342 | - * Depending on the data, it can be based on the Gedcom Header description, or from a place example. |
|
343 | - * This is returned as an associative array: |
|
344 | - * - type: describe the source of the data (<em>header<em> / <em>data</em>) |
|
345 | - * - hierarchy: an array of the place hierarchy (in reverse order of the gedcom) |
|
346 | - * |
|
347 | - * @return array |
|
348 | - */ |
|
349 | - public function getPlacesHierarchy() { |
|
350 | - if(!$this->place_hierarchy) { |
|
351 | - if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
352 | - $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
|
353 | - } |
|
354 | - else { |
|
355 | - $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData()); |
|
356 | - } |
|
357 | - } |
|
358 | - return $this->place_hierarchy; |
|
359 | - } |
|
340 | + /** |
|
341 | + * Returns the infered place hierarchy, determined from the Gedcom data. |
|
342 | + * Depending on the data, it can be based on the Gedcom Header description, or from a place example. |
|
343 | + * This is returned as an associative array: |
|
344 | + * - type: describe the source of the data (<em>header<em> / <em>data</em>) |
|
345 | + * - hierarchy: an array of the place hierarchy (in reverse order of the gedcom) |
|
346 | + * |
|
347 | + * @return array |
|
348 | + */ |
|
349 | + public function getPlacesHierarchy() { |
|
350 | + if(!$this->place_hierarchy) { |
|
351 | + if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
352 | + $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
|
353 | + } |
|
354 | + else { |
|
355 | + $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData()); |
|
356 | + } |
|
357 | + } |
|
358 | + return $this->place_hierarchy; |
|
359 | + } |
|
360 | 360 | |
361 | - /** |
|
362 | - * Returns an array of the place hierarchy, as defined in the GEDCOM header. |
|
363 | - * The places are reversed compared to normal GEDCOM structure. |
|
364 | - * |
|
365 | - * @return array|null |
|
366 | - */ |
|
367 | - protected function getPlacesHierarchyFromHeader() { |
|
368 | - $head = GedcomRecord::getInstance('HEAD', $this->tree); |
|
369 | - $head_place = $head->getFirstFact('PLAC'); |
|
370 | - if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ |
|
371 | - return array_reverse(array_map('trim',explode(',', $head_place_value))); |
|
372 | - } |
|
373 | - return null; |
|
374 | - } |
|
361 | + /** |
|
362 | + * Returns an array of the place hierarchy, as defined in the GEDCOM header. |
|
363 | + * The places are reversed compared to normal GEDCOM structure. |
|
364 | + * |
|
365 | + * @return array|null |
|
366 | + */ |
|
367 | + protected function getPlacesHierarchyFromHeader() { |
|
368 | + $head = GedcomRecord::getInstance('HEAD', $this->tree); |
|
369 | + $head_place = $head->getFirstFact('PLAC'); |
|
370 | + if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ |
|
371 | + return array_reverse(array_map('trim',explode(',', $head_place_value))); |
|
372 | + } |
|
373 | + return null; |
|
374 | + } |
|
375 | 375 | |
376 | - /** |
|
377 | - * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM. |
|
378 | - * It will look for the longest hierarchy in the tree. |
|
379 | - * The places are reversed compared to normal GEDCOM structure. |
|
380 | - * |
|
381 | - * @return array |
|
382 | - */ |
|
383 | - protected function getPlacesHierarchyFromData() { |
|
384 | - $nb_levels = 0; |
|
376 | + /** |
|
377 | + * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM. |
|
378 | + * It will look for the longest hierarchy in the tree. |
|
379 | + * The places are reversed compared to normal GEDCOM structure. |
|
380 | + * |
|
381 | + * @return array |
|
382 | + */ |
|
383 | + protected function getPlacesHierarchyFromData() { |
|
384 | + $nb_levels = 0; |
|
385 | 385 | |
386 | - //Select all '2 PLAC ' tags in the file and create array |
|
387 | - $places_list=array(); |
|
388 | - $ged_data = Database::prepare( |
|
389 | - 'SELECT i_gedcom AS gedcom'. |
|
390 | - ' FROM `##individuals`'. |
|
391 | - ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. |
|
392 | - ' UNION ALL'. |
|
393 | - 'SELECT f_gedcom AS gedcom'. |
|
394 | - ' FROM `##families`'. |
|
395 | - ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' |
|
396 | - )->execute(array( |
|
397 | - 'gedcom' => '%\n2 PLAC %', |
|
398 | - 'gedcom_id' => $this->tree->getTreeId() |
|
399 | - ))->fetchOneColumn(); |
|
400 | - foreach ($ged_data as $ged_datum) { |
|
401 | - $matches = null; |
|
402 | - preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
|
403 | - foreach ($matches[1] as $match) { |
|
404 | - $places_list[$match]=true; |
|
405 | - } |
|
406 | - } |
|
386 | + //Select all '2 PLAC ' tags in the file and create array |
|
387 | + $places_list=array(); |
|
388 | + $ged_data = Database::prepare( |
|
389 | + 'SELECT i_gedcom AS gedcom'. |
|
390 | + ' FROM `##individuals`'. |
|
391 | + ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. |
|
392 | + ' UNION ALL'. |
|
393 | + 'SELECT f_gedcom AS gedcom'. |
|
394 | + ' FROM `##families`'. |
|
395 | + ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' |
|
396 | + )->execute(array( |
|
397 | + 'gedcom' => '%\n2 PLAC %', |
|
398 | + 'gedcom_id' => $this->tree->getTreeId() |
|
399 | + ))->fetchOneColumn(); |
|
400 | + foreach ($ged_data as $ged_datum) { |
|
401 | + $matches = null; |
|
402 | + preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
|
403 | + foreach ($matches[1] as $match) { |
|
404 | + $places_list[$match]=true; |
|
405 | + } |
|
406 | + } |
|
407 | 407 | |
408 | - // Unique list of places |
|
409 | - $places_list=array_keys($places_list); |
|
408 | + // Unique list of places |
|
409 | + $places_list=array_keys($places_list); |
|
410 | 410 | |
411 | - //sort the array, limit to unique values, and count them |
|
412 | - usort($places_list, array('I18N', 'strcasecmp')); |
|
411 | + //sort the array, limit to unique values, and count them |
|
412 | + usort($places_list, array('I18N', 'strcasecmp')); |
|
413 | 413 | |
414 | - //calculate maximum no. of levels to display |
|
415 | - $has_found_good_example = false; |
|
416 | - foreach($places_list as $place){ |
|
417 | - $levels = explode(",", $place); |
|
418 | - $parts = count($levels); |
|
419 | - if ($parts >= $nb_levels){ |
|
420 | - $nb_levels = $parts; |
|
421 | - if(!$has_found_good_example){ |
|
422 | - $random_place = $place; |
|
423 | - if(min(array_map('strlen', $levels)) > 0){ |
|
424 | - $has_found_good_example = true; |
|
425 | - } |
|
426 | - } |
|
427 | - } |
|
428 | - } |
|
414 | + //calculate maximum no. of levels to display |
|
415 | + $has_found_good_example = false; |
|
416 | + foreach($places_list as $place){ |
|
417 | + $levels = explode(",", $place); |
|
418 | + $parts = count($levels); |
|
419 | + if ($parts >= $nb_levels){ |
|
420 | + $nb_levels = $parts; |
|
421 | + if(!$has_found_good_example){ |
|
422 | + $random_place = $place; |
|
423 | + if(min(array_map('strlen', $levels)) > 0){ |
|
424 | + $has_found_good_example = true; |
|
425 | + } |
|
426 | + } |
|
427 | + } |
|
428 | + } |
|
429 | 429 | |
430 | - return array_reverse(array_map('trim',explode(',', $random_place))); |
|
431 | - } |
|
430 | + return array_reverse(array_map('trim',explode(',', $random_place))); |
|
431 | + } |
|
432 | 432 | |
433 | - /** |
|
434 | - * Returns the list of geodispersion maps available within the maps folder. |
|
435 | - * |
|
436 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[] |
|
437 | - */ |
|
438 | - public function getOutlineMapsList() { |
|
439 | - $res = array(); |
|
440 | - $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
|
441 | - if(is_dir($root_path)){ |
|
442 | - $dir = opendir($root_path); |
|
443 | - while (($file=readdir($dir))!== false) { |
|
444 | - if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
|
445 | - $res[base64_encode($file)] = new OutlineMap($file, true); |
|
446 | - } |
|
447 | - } |
|
448 | - } |
|
449 | - return $res; |
|
450 | - } |
|
433 | + /** |
|
434 | + * Returns the list of geodispersion maps available within the maps folder. |
|
435 | + * |
|
436 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[] |
|
437 | + */ |
|
438 | + public function getOutlineMapsList() { |
|
439 | + $res = array(); |
|
440 | + $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
|
441 | + if(is_dir($root_path)){ |
|
442 | + $dir = opendir($root_path); |
|
443 | + while (($file=readdir($dir))!== false) { |
|
444 | + if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
|
445 | + $res[base64_encode($file)] = new OutlineMap($file, true); |
|
446 | + } |
|
447 | + } |
|
448 | + } |
|
449 | + return $res; |
|
450 | + } |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | \ No newline at end of file |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | ->setUsingFlags($row['majgd_useflagsgen'] == 'yes') |
66 | 66 | ->setMaxDetailsInGen($row['majgd_detailsgen']); |
67 | 67 | |
68 | - if($row['majgd_map']) { |
|
68 | + if ($row['majgd_map']) { |
|
69 | 69 | $options |
70 | 70 | ->setMap(new OutlineMap($row['majgd_map'])) |
71 | 71 | ->setMapLevel($row['majgd_toplevel']); |
72 | 72 | } |
73 | 73 | |
74 | 74 | $enabled = true; |
75 | - if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
75 | + if (isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
76 | 76 | $enabled = false; |
77 | 77 | } |
78 | 78 | |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getGeoAnalysisCount() { |
95 | 95 | return Database::prepare( |
96 | - 'SELECT COUNT(majgd_id)' . |
|
97 | - ' FROM `##maj_geodispersion`' . |
|
96 | + 'SELECT COUNT(majgd_id)'. |
|
97 | + ' FROM `##maj_geodispersion`'. |
|
98 | 98 | ' WHERE majgd_file = :gedcom_id' |
99 | 99 | )->execute(array( |
100 | 100 | 'gedcom_id' => $this->tree->getTreeId() |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL |
111 | 111 | */ |
112 | 112 | public function getGeoAnalysis($id, $only_enabled = true) { |
113 | - $args = array ( |
|
113 | + $args = array( |
|
114 | 114 | 'gedcom_id' => $this->tree->getTreeId(), |
115 | 115 | 'ga_id' => $id |
116 | 116 | ); |
117 | 117 | |
118 | - $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
119 | - ' FROM `##maj_geodispersion`' . |
|
118 | + $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status'. |
|
119 | + ' FROM `##maj_geodispersion`'. |
|
120 | 120 | ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; |
121 | - if($only_enabled) { |
|
121 | + if ($only_enabled) { |
|
122 | 122 | $sql .= ' AND majgd_status = :status'; |
123 | 123 | $args['status'] = 'enabled'; |
124 | 124 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); |
128 | 128 | |
129 | - if($ga_array) { |
|
129 | + if ($ga_array) { |
|
130 | 130 | return $this->loadGeoAnalysisFromRow($ga_array); |
131 | 131 | } |
132 | 132 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @return GeoAnalysis |
147 | 147 | */ |
148 | 148 | public function createGeoAnalysis($description, $analysis_level, $map_file, $map_top_level, $use_flags, $gen_details) { |
149 | - try{ |
|
149 | + try { |
|
150 | 150 | Database::beginTransaction(); |
151 | 151 | |
152 | 152 | Database::prepare( |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | Database::commit(); |
170 | 170 | } |
171 | - catch(\Exception $ex) { |
|
171 | + catch (\Exception $ex) { |
|
172 | 172 | Database::rollback(); |
173 | 173 | $ga = null; |
174 | 174 | Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage()); |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | |
212 | 212 | Database::commit(); |
213 | 213 | } |
214 | - catch(\Exception $ex) { |
|
214 | + catch (\Exception $ex) { |
|
215 | 215 | Database::rollback(); |
216 | - Log::addErrorLog('The Geo Analysis ID “' . $ga->getId() . '” failed to be updated. Transaction rollbacked. Exception: '.$ex->getMessage()); |
|
216 | + Log::addErrorLog('The Geo Analysis ID “'.$ga->getId().'” failed to be updated. Transaction rollbacked. Exception: '.$ex->getMessage()); |
|
217 | 217 | $ga = null; |
218 | 218 | } |
219 | 219 | return $ga; |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return array List of enabled maps |
260 | 260 | */ |
261 | - public function getGeoAnalysisList(){ |
|
261 | + public function getGeoAnalysisList() { |
|
262 | 262 | $res = array(); |
263 | 263 | |
264 | 264 | $list = Database::prepare( |
265 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . |
|
266 | - ' FROM `##maj_geodispersion`' . |
|
265 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen'. |
|
266 | + ' FROM `##maj_geodispersion`'. |
|
267 | 267 | ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. |
268 | 268 | ' ORDER BY majgd_descr' |
269 | 269 | )->execute(array( |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | 'status' => 'enabled' |
272 | 272 | ))->fetchAll(\PDO::FETCH_ASSOC); |
273 | 273 | |
274 | - foreach($list as $ga) { |
|
274 | + foreach ($list as $ga) { |
|
275 | 275 | $res[] = $this->loadGeoAnalysisFromRow($ga); |
276 | 276 | } |
277 | 277 | |
@@ -287,17 +287,17 @@ discard block |
||
287 | 287 | * @param int|null $limit Max number of items to return (for pagination) |
288 | 288 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
289 | 289 | */ |
290 | - public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ |
|
290 | + public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null) { |
|
291 | 291 | $res = array(); |
292 | 292 | |
293 | 293 | $sql = |
294 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
295 | - ' FROM `##maj_geodispersion`' . |
|
294 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status'. |
|
295 | + ' FROM `##maj_geodispersion`'. |
|
296 | 296 | ' WHERE majgd_file = :gedcom_id'; |
297 | 297 | |
298 | 298 | $args = array('gedcom_id'=> $this->tree->getTreeId()); |
299 | 299 | |
300 | - if($search) { |
|
300 | + if ($search) { |
|
301 | 301 | $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; |
302 | 302 | $args['search'] = $search; |
303 | 303 | } |
@@ -311,10 +311,10 @@ discard block |
||
311 | 311 | |
312 | 312 | switch ($value['dir']) { |
313 | 313 | case 'asc': |
314 | - $sql .= $value['column'] . ' ASC '; |
|
314 | + $sql .= $value['column'].' ASC '; |
|
315 | 315 | break; |
316 | 316 | case 'desc': |
317 | - $sql .= $value['column'] . ' DESC '; |
|
317 | + $sql .= $value['column'].' DESC '; |
|
318 | 318 | break; |
319 | 319 | } |
320 | 320 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | |
331 | 331 | $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); |
332 | 332 | |
333 | - foreach($data as $ga) { |
|
333 | + foreach ($data as $ga) { |
|
334 | 334 | $res[] = $this->loadGeoAnalysisFromRow($ga); |
335 | 335 | } |
336 | 336 | |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | * @return array |
348 | 348 | */ |
349 | 349 | public function getPlacesHierarchy() { |
350 | - if(!$this->place_hierarchy) { |
|
351 | - if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
350 | + if (!$this->place_hierarchy) { |
|
351 | + if ($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
352 | 352 | $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
353 | 353 | } |
354 | 354 | else { |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | protected function getPlacesHierarchyFromHeader() { |
368 | 368 | $head = GedcomRecord::getInstance('HEAD', $this->tree); |
369 | 369 | $head_place = $head->getFirstFact('PLAC'); |
370 | - if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ |
|
371 | - return array_reverse(array_map('trim',explode(',', $head_place_value))); |
|
370 | + if ($head_place && $head_place_value = $head_place->getAttribute('FORM')) { |
|
371 | + return array_reverse(array_map('trim', explode(',', $head_place_value))); |
|
372 | 372 | } |
373 | 373 | return null; |
374 | 374 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | $nb_levels = 0; |
385 | 385 | |
386 | 386 | //Select all '2 PLAC ' tags in the file and create array |
387 | - $places_list=array(); |
|
387 | + $places_list = array(); |
|
388 | 388 | $ged_data = Database::prepare( |
389 | 389 | 'SELECT i_gedcom AS gedcom'. |
390 | 390 | ' FROM `##individuals`'. |
@@ -401,33 +401,33 @@ discard block |
||
401 | 401 | $matches = null; |
402 | 402 | preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
403 | 403 | foreach ($matches[1] as $match) { |
404 | - $places_list[$match]=true; |
|
404 | + $places_list[$match] = true; |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
408 | 408 | // Unique list of places |
409 | - $places_list=array_keys($places_list); |
|
409 | + $places_list = array_keys($places_list); |
|
410 | 410 | |
411 | 411 | //sort the array, limit to unique values, and count them |
412 | 412 | usort($places_list, array('I18N', 'strcasecmp')); |
413 | 413 | |
414 | 414 | //calculate maximum no. of levels to display |
415 | 415 | $has_found_good_example = false; |
416 | - foreach($places_list as $place){ |
|
416 | + foreach ($places_list as $place) { |
|
417 | 417 | $levels = explode(",", $place); |
418 | 418 | $parts = count($levels); |
419 | - if ($parts >= $nb_levels){ |
|
419 | + if ($parts >= $nb_levels) { |
|
420 | 420 | $nb_levels = $parts; |
421 | - if(!$has_found_good_example){ |
|
421 | + if (!$has_found_good_example) { |
|
422 | 422 | $random_place = $place; |
423 | - if(min(array_map('strlen', $levels)) > 0){ |
|
423 | + if (min(array_map('strlen', $levels)) > 0) { |
|
424 | 424 | $has_found_good_example = true; |
425 | 425 | } |
426 | 426 | } |
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
430 | - return array_reverse(array_map('trim',explode(',', $random_place))); |
|
430 | + return array_reverse(array_map('trim', explode(',', $random_place))); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
@@ -438,9 +438,9 @@ discard block |
||
438 | 438 | public function getOutlineMapsList() { |
439 | 439 | $res = array(); |
440 | 440 | $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
441 | - if(is_dir($root_path)){ |
|
441 | + if (is_dir($root_path)) { |
|
442 | 442 | $dir = opendir($root_path); |
443 | - while (($file=readdir($dir))!== false) { |
|
443 | + while (($file = readdir($dir)) !== false) { |
|
444 | 444 | if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
445 | 445 | $res[base64_encode($file)] = new OutlineMap($file, true); |
446 | 446 | } |
@@ -89,7 +89,7 @@ |
||
89 | 89 | /** |
90 | 90 | * Returns the number of geographical analysis (active and inactive). |
91 | 91 | * |
92 | - * @return int |
|
92 | + * @return string|null |
|
93 | 93 | */ |
94 | 94 | public function getGeoAnalysisCount() { |
95 | 95 | return Database::prepare( |
@@ -25,64 +25,64 @@ discard block |
||
25 | 25 | * Geo Analysis ID |
26 | 26 | * @var int $id |
27 | 27 | */ |
28 | - protected $id; |
|
28 | + protected $id; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Geo Analysis Title |
32 | 32 | * @var string $title |
33 | 33 | */ |
34 | - protected $title; |
|
34 | + protected $title; |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Level of the Gedcom hierarchy for the analysis |
38 | 38 | * @var int $analysis_level |
39 | 39 | */ |
40 | - protected $analysis_level; |
|
40 | + protected $analysis_level; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Display options |
|
44 | - * @var GeoDisplayOptions $options |
|
45 | - */ |
|
46 | - protected $options; |
|
42 | + /** |
|
43 | + * Display options |
|
44 | + * @var GeoDisplayOptions $options |
|
45 | + */ |
|
46 | + protected $options; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Reference tree |
|
50 | - * @var Tree $tree |
|
51 | - */ |
|
52 | - protected $tree; |
|
48 | + /** |
|
49 | + * Reference tree |
|
50 | + * @var Tree $tree |
|
51 | + */ |
|
52 | + protected $tree; |
|
53 | 53 | |
54 | - /** |
|
55 | - * Is the analysis enabled |
|
56 | - * @var bool $enabled |
|
57 | - */ |
|
58 | - protected $enabled; |
|
54 | + /** |
|
55 | + * Is the analysis enabled |
|
56 | + * @var bool $enabled |
|
57 | + */ |
|
58 | + protected $enabled; |
|
59 | 59 | |
60 | - /** |
|
61 | - * Constructor for GeoAnalysis. |
|
62 | - * |
|
63 | - * @param Tree $tree Reference tree |
|
60 | + /** |
|
61 | + * Constructor for GeoAnalysis. |
|
62 | + * |
|
63 | + * @param Tree $tree Reference tree |
|
64 | 64 | * @param int $id GeoAnalysis ID |
65 | 65 | * @param string $title GeoAnalysis title |
66 | 66 | * @param int $analysis_level Analysis level |
67 | 67 | * @param (GeoDisplayOptions|null) $options Display options |
68 | 68 | * @param bool $enabled Is analysis enabled |
69 | - */ |
|
70 | - public function __construct(Tree $tree, $id, $title, $analysis_level, GeoDisplayOptions $options = null, $enabled = true) { |
|
71 | - $this->tree = $tree; |
|
72 | - $this->id = $id; |
|
73 | - $this->title = $title; |
|
74 | - $this->analysis_level = $analysis_level; |
|
75 | - $this->options = $options; |
|
76 | - $this->enabled = $enabled; |
|
77 | - } |
|
69 | + */ |
|
70 | + public function __construct(Tree $tree, $id, $title, $analysis_level, GeoDisplayOptions $options = null, $enabled = true) { |
|
71 | + $this->tree = $tree; |
|
72 | + $this->id = $id; |
|
73 | + $this->title = $title; |
|
74 | + $this->analysis_level = $analysis_level; |
|
75 | + $this->options = $options; |
|
76 | + $this->enabled = $enabled; |
|
77 | + } |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Get the analysis title |
81 | 81 | * @return string |
82 | 82 | */ |
83 | - public function getTitle() { |
|
84 | - return $this->title; |
|
85 | - } |
|
83 | + public function getTitle() { |
|
84 | + return $this->title; |
|
85 | + } |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Set the analysis title |
@@ -90,53 +90,53 @@ discard block |
||
90 | 90 | * @param string $title |
91 | 91 | * @return self Enable method-chaining |
92 | 92 | */ |
93 | - public function setTitle($title) { |
|
94 | - $this->title = $title; |
|
95 | - return $this; |
|
96 | - } |
|
93 | + public function setTitle($title) { |
|
94 | + $this->title = $title; |
|
95 | + return $this; |
|
96 | + } |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Get the analysis ID |
100 | 100 | * @return int |
101 | 101 | */ |
102 | - public function getId() { |
|
103 | - return $this->id; |
|
104 | - } |
|
102 | + public function getId() { |
|
103 | + return $this->id; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | /** |
107 | 107 | * Get the analysis status (enabled/disabled) |
108 | 108 | * @return bool |
109 | 109 | */ |
110 | - public function isEnabled() { |
|
111 | - return $this->enabled; |
|
112 | - } |
|
110 | + public function isEnabled() { |
|
111 | + return $this->enabled; |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * Get analysis options |
|
116 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions |
|
117 | - */ |
|
118 | - public function getOptions() { |
|
119 | - return $this->options; |
|
120 | - } |
|
114 | + /** |
|
115 | + * Get analysis options |
|
116 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions |
|
117 | + */ |
|
118 | + public function getOptions() { |
|
119 | + return $this->options; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | /** |
123 | - * Set analysis options |
|
123 | + * Set analysis options |
|
124 | 124 | * |
125 | - * @param \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions $options |
|
125 | + * @param \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions $options |
|
126 | 126 | * @return self Enable method-chaining |
127 | - */ |
|
128 | - public function setOptions(GeoDisplayOptions $options) { |
|
129 | - $this->options = $options; |
|
130 | - return $this; |
|
131 | - } |
|
127 | + */ |
|
128 | + public function setOptions(GeoDisplayOptions $options) { |
|
129 | + $this->options = $options; |
|
130 | + return $this; |
|
131 | + } |
|
132 | 132 | |
133 | 133 | /** |
134 | 134 | * Get analysis level |
135 | 135 | * @return int |
136 | 136 | */ |
137 | - public function getAnalysisLevel() { |
|
138 | - return $this->analysis_level; |
|
139 | - } |
|
137 | + public function getAnalysisLevel() { |
|
138 | + return $this->analysis_level; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * Get analysis level |
@@ -144,19 +144,19 @@ discard block |
||
144 | 144 | * @param int $analysis_level |
145 | 145 | * @return self Enable method-chaining |
146 | 146 | */ |
147 | - public function setAnalysisLevel($analysis_level) { |
|
148 | - $this->analysis_level = $analysis_level; |
|
149 | - return $this; |
|
150 | - } |
|
147 | + public function setAnalysisLevel($analysis_level) { |
|
148 | + $this->analysis_level = $analysis_level; |
|
149 | + return $this; |
|
150 | + } |
|
151 | 151 | |
152 | 152 | /** |
153 | 153 | * Check whether the analysis has a linked map |
154 | 154 | * |
155 | 155 | * @return bool |
156 | 156 | */ |
157 | - public function hasMap() { |
|
158 | - return $this->options && $this->options->getMap(); |
|
159 | - } |
|
157 | + public function hasMap() { |
|
158 | + return $this->options && $this->options->getMap(); |
|
159 | + } |
|
160 | 160 | |
161 | 161 | /** |
162 | 162 | * Get the URL for the GeoAnalysis. |
@@ -164,117 +164,117 @@ discard block |
||
164 | 164 | * @return string |
165 | 165 | */ |
166 | 166 | public function getHtmlUrl() { |
167 | - return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
168 | - } |
|
167 | + return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * Return the dispersion analysis tables. |
|
172 | - * Two arrays are returned : |
|
173 | - * - the General analysis, which returns the number of ancestors for each place found, plus 4 additional indicators : |
|
174 | - * - knownsum : Number of known places |
|
175 | - * - unknown : Number of unknown places |
|
176 | - * - max : Maximum count of ancestors within a place |
|
177 | - * - other : Other places (not in the top level area) |
|
178 | - * - the Generations analysis, which returns the number of ancestors for each place found for each generation, plus 3 additional indicators within each generation : |
|
179 | - * - sum : Number of known places |
|
180 | - * - unknown : Number of unknown places |
|
181 | - * - other : Other places (not in the top level area) |
|
182 | - * |
|
183 | - * @param array $sosalist List of all sosas |
|
184 | - * @return array Array of the general and generations table |
|
185 | - */ |
|
186 | - public function getAnalysisResults($sosalist) { |
|
187 | - $placesDispGeneral = null; |
|
188 | - $placesDispGenerations = null; |
|
170 | + /** |
|
171 | + * Return the dispersion analysis tables. |
|
172 | + * Two arrays are returned : |
|
173 | + * - the General analysis, which returns the number of ancestors for each place found, plus 4 additional indicators : |
|
174 | + * - knownsum : Number of known places |
|
175 | + * - unknown : Number of unknown places |
|
176 | + * - max : Maximum count of ancestors within a place |
|
177 | + * - other : Other places (not in the top level area) |
|
178 | + * - the Generations analysis, which returns the number of ancestors for each place found for each generation, plus 3 additional indicators within each generation : |
|
179 | + * - sum : Number of known places |
|
180 | + * - unknown : Number of unknown places |
|
181 | + * - other : Other places (not in the top level area) |
|
182 | + * |
|
183 | + * @param array $sosalist List of all sosas |
|
184 | + * @return array Array of the general and generations table |
|
185 | + */ |
|
186 | + public function getAnalysisResults($sosalist) { |
|
187 | + $placesDispGeneral = null; |
|
188 | + $placesDispGenerations = null; |
|
189 | 189 | |
190 | - if($sosalist && count($sosalist) > 0) { |
|
191 | - $placesDispGeneral['knownsum'] = 0; |
|
192 | - $placesDispGeneral['unknown'] = 0; |
|
193 | - $placesDispGeneral['max'] = 0; |
|
194 | - $placesDispGeneral['places'] = array(); |
|
195 | - foreach($sosalist as $sosaid => $gens) { |
|
196 | - $sosa = Individual::getIntance($sosaid, $this->tree); |
|
197 | - $place =$sosa->getSignificantPlace(); |
|
198 | - $genstab = explode(',', $gens); |
|
199 | - $isUnknown=true; |
|
200 | - if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
201 | - $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
202 | - if(count($levels)>= $this->analysis_level){ |
|
203 | - $toplevelvalues = array(); |
|
204 | - if($this->hasMap() && $toplevelvalue = $this->options->getMap()->getTopLevelName()) { |
|
205 | - $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
206 | - } |
|
207 | - if(!$this->hasMap() |
|
208 | - || is_null($this->options->getMapLevel()) |
|
209 | - || $this->options->getMap()->getTopLevelName() == '*' |
|
210 | - || ( |
|
211 | - $this->options->getMapLevel() <= $this->analysis_level |
|
212 | - && $this->options->getMapLevel() > 0 |
|
213 | - && count($levels) >= $this->options->getMapLevel() |
|
214 | - && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
215 | - ) |
|
216 | - ) { |
|
217 | - $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
|
218 | - if(isset($placesDispGeneral['places'][$placest])) { |
|
219 | - $placesDispGeneral['places'][$placest] += 1; |
|
220 | - } |
|
221 | - else { |
|
222 | - $placesDispGeneral['places'][$placest] = 1; |
|
223 | - } |
|
224 | - if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
225 | - $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
226 | - foreach($genstab as $gen) { |
|
227 | - if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
228 | - $placesDispGenerations[$gen]['places'][$placest] += 1; |
|
229 | - } |
|
230 | - else { |
|
231 | - $placesDispGenerations[$gen]['places'][$placest] = 1; |
|
232 | - } |
|
233 | - if(isset($placesDispGenerations[$gen]['sum'])) { |
|
234 | - $placesDispGenerations[$gen]['sum'] += 1; |
|
235 | - } |
|
236 | - else { |
|
237 | - $placesDispGenerations[$gen]['sum'] = 1; |
|
238 | - } |
|
239 | - } |
|
240 | - } |
|
241 | - else{ |
|
242 | - if(isset($placesDispGeneral['other'])) { |
|
243 | - $placesDispGeneral['other'] += 1; |
|
244 | - } |
|
245 | - else { |
|
246 | - $placesDispGeneral['other'] = 1; |
|
247 | - } |
|
248 | - foreach($genstab as $gen) { |
|
249 | - if(isset($placesDispGenerations[$gen]['other'])) { |
|
250 | - $placesDispGenerations[$gen]['other'] += 1; |
|
251 | - } |
|
252 | - else { |
|
253 | - $placesDispGenerations[$gen]['other'] = 1; |
|
254 | - } |
|
255 | - } |
|
256 | - } |
|
257 | - $placesDispGeneral['knownsum'] += 1; |
|
258 | - $isUnknown = false; |
|
259 | - } |
|
260 | - } |
|
261 | - if($isUnknown){ |
|
262 | - $placesDispGeneral['unknown'] += 1; |
|
263 | - foreach($genstab as $gen) { |
|
264 | - if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
265 | - $placesDispGenerations[$gen]['unknown'] += 1; |
|
266 | - } |
|
267 | - else { |
|
268 | - $placesDispGenerations[$gen]['unknown'] = 1; |
|
269 | - } |
|
270 | - } |
|
271 | - } |
|
272 | - } |
|
190 | + if($sosalist && count($sosalist) > 0) { |
|
191 | + $placesDispGeneral['knownsum'] = 0; |
|
192 | + $placesDispGeneral['unknown'] = 0; |
|
193 | + $placesDispGeneral['max'] = 0; |
|
194 | + $placesDispGeneral['places'] = array(); |
|
195 | + foreach($sosalist as $sosaid => $gens) { |
|
196 | + $sosa = Individual::getIntance($sosaid, $this->tree); |
|
197 | + $place =$sosa->getSignificantPlace(); |
|
198 | + $genstab = explode(',', $gens); |
|
199 | + $isUnknown=true; |
|
200 | + if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
201 | + $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
202 | + if(count($levels)>= $this->analysis_level){ |
|
203 | + $toplevelvalues = array(); |
|
204 | + if($this->hasMap() && $toplevelvalue = $this->options->getMap()->getTopLevelName()) { |
|
205 | + $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
206 | + } |
|
207 | + if(!$this->hasMap() |
|
208 | + || is_null($this->options->getMapLevel()) |
|
209 | + || $this->options->getMap()->getTopLevelName() == '*' |
|
210 | + || ( |
|
211 | + $this->options->getMapLevel() <= $this->analysis_level |
|
212 | + && $this->options->getMapLevel() > 0 |
|
213 | + && count($levels) >= $this->options->getMapLevel() |
|
214 | + && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
215 | + ) |
|
216 | + ) { |
|
217 | + $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
|
218 | + if(isset($placesDispGeneral['places'][$placest])) { |
|
219 | + $placesDispGeneral['places'][$placest] += 1; |
|
220 | + } |
|
221 | + else { |
|
222 | + $placesDispGeneral['places'][$placest] = 1; |
|
223 | + } |
|
224 | + if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
225 | + $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
226 | + foreach($genstab as $gen) { |
|
227 | + if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
228 | + $placesDispGenerations[$gen]['places'][$placest] += 1; |
|
229 | + } |
|
230 | + else { |
|
231 | + $placesDispGenerations[$gen]['places'][$placest] = 1; |
|
232 | + } |
|
233 | + if(isset($placesDispGenerations[$gen]['sum'])) { |
|
234 | + $placesDispGenerations[$gen]['sum'] += 1; |
|
235 | + } |
|
236 | + else { |
|
237 | + $placesDispGenerations[$gen]['sum'] = 1; |
|
238 | + } |
|
239 | + } |
|
240 | + } |
|
241 | + else{ |
|
242 | + if(isset($placesDispGeneral['other'])) { |
|
243 | + $placesDispGeneral['other'] += 1; |
|
244 | + } |
|
245 | + else { |
|
246 | + $placesDispGeneral['other'] = 1; |
|
247 | + } |
|
248 | + foreach($genstab as $gen) { |
|
249 | + if(isset($placesDispGenerations[$gen]['other'])) { |
|
250 | + $placesDispGenerations[$gen]['other'] += 1; |
|
251 | + } |
|
252 | + else { |
|
253 | + $placesDispGenerations[$gen]['other'] = 1; |
|
254 | + } |
|
255 | + } |
|
256 | + } |
|
257 | + $placesDispGeneral['knownsum'] += 1; |
|
258 | + $isUnknown = false; |
|
259 | + } |
|
260 | + } |
|
261 | + if($isUnknown){ |
|
262 | + $placesDispGeneral['unknown'] += 1; |
|
263 | + foreach($genstab as $gen) { |
|
264 | + if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
265 | + $placesDispGenerations[$gen]['unknown'] += 1; |
|
266 | + } |
|
267 | + else { |
|
268 | + $placesDispGenerations[$gen]['unknown'] = 1; |
|
269 | + } |
|
270 | + } |
|
271 | + } |
|
272 | + } |
|
273 | 273 | |
274 | - } |
|
274 | + } |
|
275 | 275 | |
276 | - return array($placesDispGeneral, $placesDispGenerations); |
|
277 | - } |
|
276 | + return array($placesDispGeneral, $placesDispGenerations); |
|
277 | + } |
|
278 | 278 | |
279 | 279 | |
280 | 280 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @return string |
165 | 165 | */ |
166 | 166 | public function getHtmlUrl() { |
167 | - return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
167 | + return 'module.php?mod='.Constants::MODULE_MAJ_GEODISP_NAME.'&mod_action=GeoAnalysis&ga_id='.$this->getId().'&ged='.$this->tree->getNameUrl(); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -187,50 +187,50 @@ discard block |
||
187 | 187 | $placesDispGeneral = null; |
188 | 188 | $placesDispGenerations = null; |
189 | 189 | |
190 | - if($sosalist && count($sosalist) > 0) { |
|
190 | + if ($sosalist && count($sosalist) > 0) { |
|
191 | 191 | $placesDispGeneral['knownsum'] = 0; |
192 | 192 | $placesDispGeneral['unknown'] = 0; |
193 | 193 | $placesDispGeneral['max'] = 0; |
194 | 194 | $placesDispGeneral['places'] = array(); |
195 | - foreach($sosalist as $sosaid => $gens) { |
|
195 | + foreach ($sosalist as $sosaid => $gens) { |
|
196 | 196 | $sosa = Individual::getIntance($sosaid, $this->tree); |
197 | - $place =$sosa->getSignificantPlace(); |
|
197 | + $place = $sosa->getSignificantPlace(); |
|
198 | 198 | $genstab = explode(',', $gens); |
199 | - $isUnknown=true; |
|
200 | - if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
201 | - $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
202 | - if(count($levels)>= $this->analysis_level){ |
|
199 | + $isUnknown = true; |
|
200 | + if ($sosa->getDerivedRecord()->canShow() && !is_null($place)) { |
|
201 | + $levels = array_reverse(array_map('trim', explode(',', $place))); |
|
202 | + if (count($levels) >= $this->analysis_level) { |
|
203 | 203 | $toplevelvalues = array(); |
204 | - if($this->hasMap() && $toplevelvalue = $this->options->getMap()->getTopLevelName()) { |
|
205 | - $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
204 | + if ($this->hasMap() && $toplevelvalue = $this->options->getMap()->getTopLevelName()) { |
|
205 | + $toplevelvalues = array_map('trim', explode(',', strtolower($toplevelvalue))); |
|
206 | 206 | } |
207 | - if(!$this->hasMap() |
|
207 | + if (!$this->hasMap() |
|
208 | 208 | || is_null($this->options->getMapLevel()) |
209 | 209 | || $this->options->getMap()->getTopLevelName() == '*' |
210 | 210 | || ( |
211 | 211 | $this->options->getMapLevel() <= $this->analysis_level |
212 | 212 | && $this->options->getMapLevel() > 0 |
213 | 213 | && count($levels) >= $this->options->getMapLevel() |
214 | - && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
214 | + && in_array(strtolower($levels[$this->options->getMapLevel() - 1]), $toplevelvalues) |
|
215 | 215 | ) |
216 | 216 | ) { |
217 | 217 | $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
218 | - if(isset($placesDispGeneral['places'][$placest])) { |
|
218 | + if (isset($placesDispGeneral['places'][$placest])) { |
|
219 | 219 | $placesDispGeneral['places'][$placest] += 1; |
220 | 220 | } |
221 | 221 | else { |
222 | 222 | $placesDispGeneral['places'][$placest] = 1; |
223 | 223 | } |
224 | - if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
224 | + if ($placesDispGeneral['places'][$placest] > $placesDispGeneral['max']) |
|
225 | 225 | $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
226 | - foreach($genstab as $gen) { |
|
227 | - if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
226 | + foreach ($genstab as $gen) { |
|
227 | + if (isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
228 | 228 | $placesDispGenerations[$gen]['places'][$placest] += 1; |
229 | 229 | } |
230 | 230 | else { |
231 | 231 | $placesDispGenerations[$gen]['places'][$placest] = 1; |
232 | 232 | } |
233 | - if(isset($placesDispGenerations[$gen]['sum'])) { |
|
233 | + if (isset($placesDispGenerations[$gen]['sum'])) { |
|
234 | 234 | $placesDispGenerations[$gen]['sum'] += 1; |
235 | 235 | } |
236 | 236 | else { |
@@ -238,15 +238,15 @@ discard block |
||
238 | 238 | } |
239 | 239 | } |
240 | 240 | } |
241 | - else{ |
|
242 | - if(isset($placesDispGeneral['other'])) { |
|
241 | + else { |
|
242 | + if (isset($placesDispGeneral['other'])) { |
|
243 | 243 | $placesDispGeneral['other'] += 1; |
244 | 244 | } |
245 | 245 | else { |
246 | 246 | $placesDispGeneral['other'] = 1; |
247 | 247 | } |
248 | - foreach($genstab as $gen) { |
|
249 | - if(isset($placesDispGenerations[$gen]['other'])) { |
|
248 | + foreach ($genstab as $gen) { |
|
249 | + if (isset($placesDispGenerations[$gen]['other'])) { |
|
250 | 250 | $placesDispGenerations[$gen]['other'] += 1; |
251 | 251 | } |
252 | 252 | else { |
@@ -258,10 +258,10 @@ discard block |
||
258 | 258 | $isUnknown = false; |
259 | 259 | } |
260 | 260 | } |
261 | - if($isUnknown){ |
|
261 | + if ($isUnknown) { |
|
262 | 262 | $placesDispGeneral['unknown'] += 1; |
263 | - foreach($genstab as $gen) { |
|
264 | - if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
263 | + foreach ($genstab as $gen) { |
|
264 | + if (isset($placesDispGenerations[$gen]['unknown'])) { |
|
265 | 265 | $placesDispGenerations[$gen]['unknown'] += 1; |
266 | 266 | } |
267 | 267 | else { |
@@ -217,39 +217,34 @@ discard block |
||
217 | 217 | $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
218 | 218 | if(isset($placesDispGeneral['places'][$placest])) { |
219 | 219 | $placesDispGeneral['places'][$placest] += 1; |
220 | - } |
|
221 | - else { |
|
220 | + } else { |
|
222 | 221 | $placesDispGeneral['places'][$placest] = 1; |
223 | 222 | } |
224 | - if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
225 | - $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
223 | + if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) { |
|
224 | + $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
225 | + } |
|
226 | 226 | foreach($genstab as $gen) { |
227 | 227 | if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
228 | 228 | $placesDispGenerations[$gen]['places'][$placest] += 1; |
229 | - } |
|
230 | - else { |
|
229 | + } else { |
|
231 | 230 | $placesDispGenerations[$gen]['places'][$placest] = 1; |
232 | 231 | } |
233 | 232 | if(isset($placesDispGenerations[$gen]['sum'])) { |
234 | 233 | $placesDispGenerations[$gen]['sum'] += 1; |
235 | - } |
|
236 | - else { |
|
234 | + } else { |
|
237 | 235 | $placesDispGenerations[$gen]['sum'] = 1; |
238 | 236 | } |
239 | 237 | } |
240 | - } |
|
241 | - else{ |
|
238 | + } else{ |
|
242 | 239 | if(isset($placesDispGeneral['other'])) { |
243 | 240 | $placesDispGeneral['other'] += 1; |
244 | - } |
|
245 | - else { |
|
241 | + } else { |
|
246 | 242 | $placesDispGeneral['other'] = 1; |
247 | 243 | } |
248 | 244 | foreach($genstab as $gen) { |
249 | 245 | if(isset($placesDispGenerations[$gen]['other'])) { |
250 | 246 | $placesDispGenerations[$gen]['other'] += 1; |
251 | - } |
|
252 | - else { |
|
247 | + } else { |
|
253 | 248 | $placesDispGenerations[$gen]['other'] = 1; |
254 | 249 | } |
255 | 250 | } |
@@ -263,8 +258,7 @@ discard block |
||
263 | 258 | foreach($genstab as $gen) { |
264 | 259 | if(isset($placesDispGenerations[$gen]['unknown'])) { |
265 | 260 | $placesDispGenerations[$gen]['unknown'] += 1; |
266 | - } |
|
267 | - else { |
|
261 | + } else { |
|
268 | 262 | $placesDispGenerations[$gen]['unknown'] = 1; |
269 | 263 | } |
270 | 264 | } |
@@ -21,175 +21,175 @@ |
||
21 | 21 | * Name of the file containing the description of the map. |
22 | 22 | * @var string $filename |
23 | 23 | */ |
24 | - protected $filename; |
|
24 | + protected $filename; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Indicates whether the description has been loaded from the file. |
28 | 28 | * @var bool $is_loaded |
29 | 29 | */ |
30 | - protected $is_loaded; |
|
30 | + protected $is_loaded; |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Description/title of the map. |
34 | 34 | * @var string $description |
35 | 35 | */ |
36 | - protected $description; |
|
36 | + protected $description; |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Name(s) of the parent level(s) of the map. |
40 | 40 | * @var string $is_loaded |
41 | 41 | */ |
42 | - protected $top_level_name; |
|
42 | + protected $top_level_name; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Map canvas |
|
46 | - * @var OutlineMapCanvas $canvas |
|
47 | - */ |
|
48 | - protected $canvas; |
|
44 | + /** |
|
45 | + * Map canvas |
|
46 | + * @var OutlineMapCanvas $canvas |
|
47 | + */ |
|
48 | + protected $canvas; |
|
49 | 49 | |
50 | - /** |
|
51 | - * Map subdivisions |
|
52 | - * @var array $subdivisions |
|
53 | - */ |
|
54 | - protected $subdivisions; |
|
50 | + /** |
|
51 | + * Map subdivisions |
|
52 | + * @var array $subdivisions |
|
53 | + */ |
|
54 | + protected $subdivisions; |
|
55 | 55 | |
56 | - /** |
|
57 | - * Places mappings |
|
58 | - * @var array $subdivisions |
|
59 | - */ |
|
60 | - protected $mappings; |
|
56 | + /** |
|
57 | + * Places mappings |
|
58 | + * @var array $subdivisions |
|
59 | + */ |
|
60 | + protected $mappings; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Constructor for GeoAnalysisMap. |
|
64 | - * |
|
65 | - * @param string $filename Outline map file name |
|
66 | - * @param bool $load Should the map be loaded immediately |
|
67 | - */ |
|
68 | - public function __construct($filename, $load = false) { |
|
69 | - $this->filename = $filename; |
|
70 | - $this->is_loaded = false; |
|
71 | - $this->subdivisions = array(); |
|
72 | - $this->mappings = array(); |
|
73 | - if($load) $this->load(); |
|
74 | - } |
|
62 | + /** |
|
63 | + * Constructor for GeoAnalysisMap. |
|
64 | + * |
|
65 | + * @param string $filename Outline map file name |
|
66 | + * @param bool $load Should the map be loaded immediately |
|
67 | + */ |
|
68 | + public function __construct($filename, $load = false) { |
|
69 | + $this->filename = $filename; |
|
70 | + $this->is_loaded = false; |
|
71 | + $this->subdivisions = array(); |
|
72 | + $this->mappings = array(); |
|
73 | + if($load) $this->load(); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Load the map settings contained within its XML representation |
|
78 | - * |
|
79 | - * XML structure : |
|
80 | - * - displayName : Display name of the map |
|
81 | - * - topLevel : Values of the top level subdivisions (separated by commas, if multiple) |
|
82 | - * - canvas : all settings related to the map canvas. |
|
83 | - * - width : canvas width, in px |
|
84 | - * - height : canvas height, in px |
|
85 | - * - maxcolor : color to identify places with ancestors, RGB hexadecimal |
|
86 | - * - hovercolor : same as previous, color when mouse is hovering the place, RGB hexadecimal |
|
87 | - * - bgcolor : map background color, RGB hexadecimal |
|
88 | - * - bgstroke : map stroke color, RGB hexadecimal |
|
89 | - * - defaultcolor : default color of places, RGB hexadecimal |
|
90 | - * - defaultstroke : default stroke color, RGB hexadecimal |
|
91 | - * - subdvisions : for each subdivision : |
|
76 | + /** |
|
77 | + * Load the map settings contained within its XML representation |
|
78 | + * |
|
79 | + * XML structure : |
|
80 | + * - displayName : Display name of the map |
|
81 | + * - topLevel : Values of the top level subdivisions (separated by commas, if multiple) |
|
82 | + * - canvas : all settings related to the map canvas. |
|
83 | + * - width : canvas width, in px |
|
84 | + * - height : canvas height, in px |
|
85 | + * - maxcolor : color to identify places with ancestors, RGB hexadecimal |
|
86 | + * - hovercolor : same as previous, color when mouse is hovering the place, RGB hexadecimal |
|
87 | + * - bgcolor : map background color, RGB hexadecimal |
|
88 | + * - bgstroke : map stroke color, RGB hexadecimal |
|
89 | + * - defaultcolor : default color of places, RGB hexadecimal |
|
90 | + * - defaultstroke : default stroke color, RGB hexadecimal |
|
91 | + * - subdvisions : for each subdivision : |
|
92 | 92 | * - id : Subdivision id, must be compatible with PHP variable constraints, and unique |
93 | - * - name: Display name for the place |
|
93 | + * - name: Display name for the place |
|
94 | 94 | * - parent: if any, describe to which parent level the place if belonging to |
95 | - * - <em>Element value<em> : SVG description of the subdvision shape |
|
95 | + * - <em>Element value<em> : SVG description of the subdvision shape |
|
96 | 96 | * - mapping : for each subdivision : |
97 | 97 | * - name : Name of the place to map |
98 | - * - mapto: Name of the place to map to |
|
98 | + * - mapto: Name of the place to map to |
|
99 | 99 | * |
100 | - */ |
|
101 | - protected function load() { |
|
102 | - if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){ |
|
103 | - $xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename); |
|
104 | - if($xml){ |
|
105 | - $this->description = trim($xml->displayName); |
|
106 | - $this->top_level_name = trim($xml->topLevel); |
|
107 | - $this->canvas = new OutlineMapCanvas( |
|
108 | - trim($xml->canvas->width), |
|
109 | - trim($xml->canvas->height), |
|
110 | - trim($xml->canvas->maxcolor), |
|
111 | - trim($xml->canvas->hovercolor), |
|
112 | - trim($xml->canvas->bgcolor), |
|
113 | - trim($xml->canvas->bgstroke), |
|
114 | - trim($xml->canvas->defaultcolor), |
|
115 | - trim($xml->canvas->defaultstroke) |
|
116 | - ); |
|
117 | - foreach($xml->subdivisions->children() as $subdivision){ |
|
118 | - $attributes = $subdivision->attributes(); |
|
119 | - $key = trim($attributes['name']); |
|
120 | - if(isset($attributes['parent'])) $key .= '@'.trim($attributes['parent']); |
|
121 | - $this->subdivisions[$key] = array( |
|
122 | - 'id' => trim($attributes['id']), |
|
123 | - 'displayname' => trim($attributes['name']), |
|
124 | - 'coord' => trim($subdivision[0]) |
|
125 | - ); |
|
126 | - } |
|
127 | - if(isset($xml->mappings)) { |
|
128 | - foreach($xml->mappings->children() as $mappings){ |
|
129 | - $attributes = $mappings->attributes(); |
|
130 | - $this->mappings[trim($attributes['name'])] = trim($attributes['mapto']); |
|
131 | - } |
|
132 | - } |
|
133 | - $this->is_loaded = true; |
|
134 | - return; |
|
135 | - } |
|
136 | - } |
|
137 | - throw new \Exception('The Outline Map could not be loaded from XML.'); |
|
138 | - } |
|
100 | + */ |
|
101 | + protected function load() { |
|
102 | + if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){ |
|
103 | + $xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename); |
|
104 | + if($xml){ |
|
105 | + $this->description = trim($xml->displayName); |
|
106 | + $this->top_level_name = trim($xml->topLevel); |
|
107 | + $this->canvas = new OutlineMapCanvas( |
|
108 | + trim($xml->canvas->width), |
|
109 | + trim($xml->canvas->height), |
|
110 | + trim($xml->canvas->maxcolor), |
|
111 | + trim($xml->canvas->hovercolor), |
|
112 | + trim($xml->canvas->bgcolor), |
|
113 | + trim($xml->canvas->bgstroke), |
|
114 | + trim($xml->canvas->defaultcolor), |
|
115 | + trim($xml->canvas->defaultstroke) |
|
116 | + ); |
|
117 | + foreach($xml->subdivisions->children() as $subdivision){ |
|
118 | + $attributes = $subdivision->attributes(); |
|
119 | + $key = trim($attributes['name']); |
|
120 | + if(isset($attributes['parent'])) $key .= '@'.trim($attributes['parent']); |
|
121 | + $this->subdivisions[$key] = array( |
|
122 | + 'id' => trim($attributes['id']), |
|
123 | + 'displayname' => trim($attributes['name']), |
|
124 | + 'coord' => trim($subdivision[0]) |
|
125 | + ); |
|
126 | + } |
|
127 | + if(isset($xml->mappings)) { |
|
128 | + foreach($xml->mappings->children() as $mappings){ |
|
129 | + $attributes = $mappings->attributes(); |
|
130 | + $this->mappings[trim($attributes['name'])] = trim($attributes['mapto']); |
|
131 | + } |
|
132 | + } |
|
133 | + $this->is_loaded = true; |
|
134 | + return; |
|
135 | + } |
|
136 | + } |
|
137 | + throw new \Exception('The Outline Map could not be loaded from XML.'); |
|
138 | + } |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Get the map file name. |
142 | 142 | * @return string |
143 | 143 | */ |
144 | - public function getFileName() { |
|
145 | - if(!$this->is_loaded) $this->load(); |
|
146 | - return $this->filename; |
|
147 | - } |
|
144 | + public function getFileName() { |
|
145 | + if(!$this->is_loaded) $this->load(); |
|
146 | + return $this->filename; |
|
147 | + } |
|
148 | 148 | |
149 | 149 | /** |
150 | 150 | * Get the map file name. |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - public function getDescription() { |
|
154 | - if(!$this->is_loaded) $this->load(); |
|
155 | - return $this->description; |
|
156 | - } |
|
153 | + public function getDescription() { |
|
154 | + if(!$this->is_loaded) $this->load(); |
|
155 | + return $this->description; |
|
156 | + } |
|
157 | 157 | |
158 | 158 | /** |
159 | 159 | * Get the name of the map parent level. |
160 | 160 | * @return string |
161 | 161 | */ |
162 | - public function getTopLevelName() { |
|
163 | - if(!$this->is_loaded) $this->load(); |
|
164 | - return $this->top_level_name; |
|
165 | - } |
|
162 | + public function getTopLevelName() { |
|
163 | + if(!$this->is_loaded) $this->load(); |
|
164 | + return $this->top_level_name; |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * Get the Outline Map canvas. |
|
169 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
|
170 | - */ |
|
171 | - public function getCanvas() { |
|
172 | - if(!$this->is_loaded) $this->load(); |
|
173 | - return $this->canvas; |
|
174 | - } |
|
167 | + /** |
|
168 | + * Get the Outline Map canvas. |
|
169 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
|
170 | + */ |
|
171 | + public function getCanvas() { |
|
172 | + if(!$this->is_loaded) $this->load(); |
|
173 | + return $this->canvas; |
|
174 | + } |
|
175 | 175 | |
176 | 176 | /** |
177 | - * Get the subdivisions of the map. |
|
178 | - * @return array |
|
179 | - */ |
|
180 | - public function getSubdivisions() { |
|
181 | - if(!$this->is_loaded) $this->load(); |
|
182 | - return $this->subdivisions; |
|
183 | - } |
|
177 | + * Get the subdivisions of the map. |
|
178 | + * @return array |
|
179 | + */ |
|
180 | + public function getSubdivisions() { |
|
181 | + if(!$this->is_loaded) $this->load(); |
|
182 | + return $this->subdivisions; |
|
183 | + } |
|
184 | 184 | |
185 | 185 | /** |
186 | - * Get the places mappings of the map. |
|
187 | - * @return array |
|
188 | - */ |
|
189 | - public function getPlacesMappings() { |
|
190 | - if(!$this->is_loaded) $this->load(); |
|
191 | - return $this->mappings; |
|
192 | - } |
|
186 | + * Get the places mappings of the map. |
|
187 | + * @return array |
|
188 | + */ |
|
189 | + public function getPlacesMappings() { |
|
190 | + if(!$this->is_loaded) $this->load(); |
|
191 | + return $this->mappings; |
|
192 | + } |
|
193 | 193 | |
194 | 194 | } |
195 | 195 | |
196 | 196 | \ No newline at end of file |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $this->is_loaded = false; |
71 | 71 | $this->subdivisions = array(); |
72 | 72 | $this->mappings = array(); |
73 | - if($load) $this->load(); |
|
73 | + if ($load) $this->load(); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | * |
100 | 100 | */ |
101 | 101 | protected function load() { |
102 | - if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){ |
|
102 | + if (file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)) { |
|
103 | 103 | $xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename); |
104 | - if($xml){ |
|
104 | + if ($xml) { |
|
105 | 105 | $this->description = trim($xml->displayName); |
106 | 106 | $this->top_level_name = trim($xml->topLevel); |
107 | 107 | $this->canvas = new OutlineMapCanvas( |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | trim($xml->canvas->defaultcolor), |
115 | 115 | trim($xml->canvas->defaultstroke) |
116 | 116 | ); |
117 | - foreach($xml->subdivisions->children() as $subdivision){ |
|
117 | + foreach ($xml->subdivisions->children() as $subdivision) { |
|
118 | 118 | $attributes = $subdivision->attributes(); |
119 | 119 | $key = trim($attributes['name']); |
120 | - if(isset($attributes['parent'])) $key .= '@'.trim($attributes['parent']); |
|
120 | + if (isset($attributes['parent'])) $key .= '@'.trim($attributes['parent']); |
|
121 | 121 | $this->subdivisions[$key] = array( |
122 | 122 | 'id' => trim($attributes['id']), |
123 | 123 | 'displayname' => trim($attributes['name']), |
124 | 124 | 'coord' => trim($subdivision[0]) |
125 | 125 | ); |
126 | 126 | } |
127 | - if(isset($xml->mappings)) { |
|
128 | - foreach($xml->mappings->children() as $mappings){ |
|
127 | + if (isset($xml->mappings)) { |
|
128 | + foreach ($xml->mappings->children() as $mappings) { |
|
129 | 129 | $attributes = $mappings->attributes(); |
130 | 130 | $this->mappings[trim($attributes['name'])] = trim($attributes['mapto']); |
131 | 131 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @return string |
143 | 143 | */ |
144 | 144 | public function getFileName() { |
145 | - if(!$this->is_loaded) $this->load(); |
|
145 | + if (!$this->is_loaded) $this->load(); |
|
146 | 146 | return $this->filename; |
147 | 147 | } |
148 | 148 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @return string |
152 | 152 | */ |
153 | 153 | public function getDescription() { |
154 | - if(!$this->is_loaded) $this->load(); |
|
154 | + if (!$this->is_loaded) $this->load(); |
|
155 | 155 | return $this->description; |
156 | 156 | } |
157 | 157 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return string |
161 | 161 | */ |
162 | 162 | public function getTopLevelName() { |
163 | - if(!$this->is_loaded) $this->load(); |
|
163 | + if (!$this->is_loaded) $this->load(); |
|
164 | 164 | return $this->top_level_name; |
165 | 165 | } |
166 | 166 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
170 | 170 | */ |
171 | 171 | public function getCanvas() { |
172 | - if(!$this->is_loaded) $this->load(); |
|
172 | + if (!$this->is_loaded) $this->load(); |
|
173 | 173 | return $this->canvas; |
174 | 174 | } |
175 | 175 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @return array |
179 | 179 | */ |
180 | 180 | public function getSubdivisions() { |
181 | - if(!$this->is_loaded) $this->load(); |
|
181 | + if (!$this->is_loaded) $this->load(); |
|
182 | 182 | return $this->subdivisions; |
183 | 183 | } |
184 | 184 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @return array |
188 | 188 | */ |
189 | 189 | public function getPlacesMappings() { |
190 | - if(!$this->is_loaded) $this->load(); |
|
190 | + if (!$this->is_loaded) $this->load(); |
|
191 | 191 | return $this->mappings; |
192 | 192 | } |
193 | 193 |
@@ -70,7 +70,9 @@ discard block |
||
70 | 70 | $this->is_loaded = false; |
71 | 71 | $this->subdivisions = array(); |
72 | 72 | $this->mappings = array(); |
73 | - if($load) $this->load(); |
|
73 | + if($load) { |
|
74 | + $this->load(); |
|
75 | + } |
|
74 | 76 | } |
75 | 77 | |
76 | 78 | /** |
@@ -117,7 +119,9 @@ discard block |
||
117 | 119 | foreach($xml->subdivisions->children() as $subdivision){ |
118 | 120 | $attributes = $subdivision->attributes(); |
119 | 121 | $key = trim($attributes['name']); |
120 | - if(isset($attributes['parent'])) $key .= '@'.trim($attributes['parent']); |
|
122 | + if(isset($attributes['parent'])) { |
|
123 | + $key .= '@'.trim($attributes['parent']); |
|
124 | + } |
|
121 | 125 | $this->subdivisions[$key] = array( |
122 | 126 | 'id' => trim($attributes['id']), |
123 | 127 | 'displayname' => trim($attributes['name']), |
@@ -142,7 +146,9 @@ discard block |
||
142 | 146 | * @return string |
143 | 147 | */ |
144 | 148 | public function getFileName() { |
145 | - if(!$this->is_loaded) $this->load(); |
|
149 | + if(!$this->is_loaded) { |
|
150 | + $this->load(); |
|
151 | + } |
|
146 | 152 | return $this->filename; |
147 | 153 | } |
148 | 154 | |
@@ -151,7 +157,9 @@ discard block |
||
151 | 157 | * @return string |
152 | 158 | */ |
153 | 159 | public function getDescription() { |
154 | - if(!$this->is_loaded) $this->load(); |
|
160 | + if(!$this->is_loaded) { |
|
161 | + $this->load(); |
|
162 | + } |
|
155 | 163 | return $this->description; |
156 | 164 | } |
157 | 165 | |
@@ -160,7 +168,9 @@ discard block |
||
160 | 168 | * @return string |
161 | 169 | */ |
162 | 170 | public function getTopLevelName() { |
163 | - if(!$this->is_loaded) $this->load(); |
|
171 | + if(!$this->is_loaded) { |
|
172 | + $this->load(); |
|
173 | + } |
|
164 | 174 | return $this->top_level_name; |
165 | 175 | } |
166 | 176 | |
@@ -169,7 +179,9 @@ discard block |
||
169 | 179 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
170 | 180 | */ |
171 | 181 | public function getCanvas() { |
172 | - if(!$this->is_loaded) $this->load(); |
|
182 | + if(!$this->is_loaded) { |
|
183 | + $this->load(); |
|
184 | + } |
|
173 | 185 | return $this->canvas; |
174 | 186 | } |
175 | 187 | |
@@ -178,7 +190,9 @@ discard block |
||
178 | 190 | * @return array |
179 | 191 | */ |
180 | 192 | public function getSubdivisions() { |
181 | - if(!$this->is_loaded) $this->load(); |
|
193 | + if(!$this->is_loaded) { |
|
194 | + $this->load(); |
|
195 | + } |
|
182 | 196 | return $this->subdivisions; |
183 | 197 | } |
184 | 198 | |
@@ -187,7 +201,9 @@ discard block |
||
187 | 201 | * @return array |
188 | 202 | */ |
189 | 203 | public function getPlacesMappings() { |
190 | - if(!$this->is_loaded) $this->load(); |
|
204 | + if(!$this->is_loaded) { |
|
205 | + $this->load(); |
|
206 | + } |
|
191 | 207 | return $this->mappings; |
192 | 208 | } |
193 | 209 |