@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | * {@inhericDoc} |
| 26 | 26 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
| 27 | 27 | */ |
| 28 | - protected function renderContent() { |
|
| 28 | + protected function renderContent() { |
|
| 29 | 29 | |
| 30 | - $table_id = $this->data->get('table_id'); |
|
| 30 | + $table_id = $this->data->get('table_id'); |
|
| 31 | 31 | |
| 32 | - ?> |
|
| 32 | + ?> |
|
| 33 | 33 | <ol class="breadcrumb small"> |
| 34 | 34 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
| 35 | 35 | <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li> |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | </div> |
| 80 | 80 | |
| 81 | 81 | <?php |
| 82 | - } |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | \ No newline at end of file |
@@ -60,13 +60,13 @@ |
||
| 60 | 60 | ?> |
| 61 | 61 | <tr> |
| 62 | 62 | <td> |
| 63 | - <input type="hidden" name="hook-<?php echo $hook->id;?>" value="yes" > |
|
| 64 | - <?php echo FunctionsEdit::twoStateCheckbox('status-'.($hook->id), ($hook->status)=='enabled'); ?> |
|
| 63 | + <input type="hidden" name="hook-<?php echo $hook->id; ?>" value="yes" > |
|
| 64 | + <?php echo FunctionsEdit::twoStateCheckbox('status-'.($hook->id), ($hook->status) == 'enabled'); ?> |
|
| 65 | 65 | </td> |
| 66 | - <td><?php echo (($hook->status)=='enabled'); ?></td> |
|
| 66 | + <td><?php echo (($hook->status) == 'enabled'); ?></td> |
|
| 67 | 67 | <td><?php echo $hook->hook; ?></td> |
| 68 | 68 | <td><?php echo $hook->context; ?></td> |
| 69 | - <td><?php if($mod = Module::getModuleByName($hook->module)) echo $mod->getTitle(); ?></td> |
|
| 69 | + <td><?php if ($mod = Module::getModuleByName($hook->module)) echo $mod->getTitle(); ?></td> |
|
| 70 | 70 | <td><input type="text" class="center" size="2" value="<?php echo $hook->priority; ?>" name="moduleorder-<?php echo $hook->id; ?>" /></td> |
| 71 | 71 | <td><?php echo $hook->priority; ?></td> |
| 72 | 72 | </tr> |
@@ -66,7 +66,10 @@ |
||
| 66 | 66 | <td><?php echo (($hook->status)=='enabled'); ?></td> |
| 67 | 67 | <td><?php echo $hook->hook; ?></td> |
| 68 | 68 | <td><?php echo $hook->context; ?></td> |
| 69 | - <td><?php if($mod = Module::getModuleByName($hook->module)) echo $mod->getTitle(); ?></td> |
|
| 69 | + <td><?php if($mod = Module::getModuleByName($hook->module)) { |
|
| 70 | + echo $mod->getTitle(); |
|
| 71 | +} |
|
| 72 | +?></td> |
|
| 70 | 73 | <td><input type="text" class="center" size="2" value="<?php echo $hook->priority; ?>" name="moduleorder-<?php echo $hook->id; ?>" /></td> |
| 71 | 74 | <td><?php echo $hook->priority; ?></td> |
| 72 | 75 | </tr> |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
| 60 | 60 | */ |
| 61 | 61 | public function getConfigLink() { |
| 62 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
| 62 | + return 'module.php?mod='.$this->getName().'&mod_action=AdminConfig'; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -88,19 +88,19 @@ discard block |
||
| 88 | 88 | $res = ''; |
| 89 | 89 | $dindi = new Individual($ctrlIndi->getSignificantIndividual()); |
| 90 | 90 | $titles = $dindi->getTitles(); |
| 91 | - if(count($titles)>0){ |
|
| 91 | + if (count($titles) > 0) { |
|
| 92 | 92 | $res = ' |
| 93 | 93 | <dl> |
| 94 | 94 | <dt class="label">'.I18N::translate('Titles').'</dt>'; |
| 95 | - foreach($titles as $title=>$props){ |
|
| 95 | + foreach ($titles as $title=>$props) { |
|
| 96 | 96 | $res .= |
| 97 | - '<dd class="field">' . $title. ' ' . |
|
| 98 | - FunctionsPrint::getListFromArray($props) . |
|
| 97 | + '<dd class="field">'.$title.' '. |
|
| 98 | + FunctionsPrint::getListFromArray($props). |
|
| 99 | 99 | '</dd>'; |
| 100 | 100 | } |
| 101 | - $res .= '</dl>'; |
|
| 101 | + $res .= '</dl>'; |
|
| 102 | 102 | } |
| 103 | - return array( 'indi-header-titles' , $res); |
|
| 103 | + return array('indi-header-titles', $res); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | global $WT_TREE; |
| 118 | 118 | |
| 119 | 119 | $html = ''; |
| 120 | - if($this->getSetting('MAJ_ADD_HTML_HEADER', 0) == 1){ |
|
| 121 | - if(Auth::accessLevel($WT_TREE) >= $this->getSetting('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE) && !Filter::getBool('noheader')){ |
|
| 120 | + if ($this->getSetting('MAJ_ADD_HTML_HEADER', 0) == 1) { |
|
| 121 | + if (Auth::accessLevel($WT_TREE) >= $this->getSetting('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE) && !Filter::getBool('noheader')) { |
|
| 122 | 122 | $html .= $this->getSetting('MAJ_HTML_HEADER', ''); |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -133,19 +133,19 @@ discard block |
||
| 133 | 133 | global $WT_TREE; |
| 134 | 134 | |
| 135 | 135 | $html = ''; |
| 136 | - if($this->getSetting('MAJ_DISPLAY_CNIL', 0) == 1){ |
|
| 136 | + if ($this->getSetting('MAJ_DISPLAY_CNIL', 0) == 1) { |
|
| 137 | 137 | $html .= '<br/>'; |
| 138 | 138 | $html .= '<div class="center">'; |
| 139 | 139 | $cnil_ref = $this->getSetting('MAJ_CNIL_REFERENCE', ''); |
| 140 | - if($cnil_ref != ''){ |
|
| 140 | + if ($cnil_ref != '') { |
|
| 141 | 141 | $html .= I18N::translate('This site has been notified to the French National Commission for Data protection (CNIL) and registered under number %s. ', $cnil_ref); |
| 142 | 142 | } |
| 143 | 143 | $html .= I18N::translate('In accordance with the French Data protection Act (<em>Loi Informatique et Libertés</em>) of January 6th, 1978, you have the right to access, modify, rectify and delete personal information that pertains to you. To exercice this right, please contact %s, and provide your name, address and a proof of your identity.', Theme::theme()->contactLink(User::find($WT_TREE->getPreference('WEBMASTER_USER_ID')))); |
| 144 | 144 | $html .= '</div>'; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if($this->getSetting('MAJ_ADD_HTML_FOOTER', 0) == 1){ |
|
| 148 | - if(Auth::accessLevel($WT_TREE) >= $this->getSetting('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE) && !Filter::getBool('nofooter')){ |
|
| 147 | + if ($this->getSetting('MAJ_ADD_HTML_FOOTER', 0) == 1) { |
|
| 148 | + if (Auth::accessLevel($WT_TREE) >= $this->getSetting('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE) && !Filter::getBool('nofooter')) { |
|
| 149 | 149 | $html .= $this->getSetting('MAJ_HTML_FOOTER', ''); |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -30,49 +30,49 @@ discard block |
||
| 30 | 30 | class MiscExtensionsModule extends AbstractModule |
| 31 | 31 | implements HookSubscriberInterface, IndividualHeaderExtenderInterface, PageHeaderExtenderInterface, PageFooterExtenderInterface, ModuleConfigInterface |
| 32 | 32 | { |
| 33 | - /** @var string For custom modules - link for support, upgrades, etc. */ |
|
| 34 | - const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
| 33 | + /** @var string For custom modules - link for support, upgrades, etc. */ |
|
| 34 | + const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * {@inheritDoc} |
|
| 38 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::getTitle() |
|
| 39 | - */ |
|
| 40 | - public function getTitle() { |
|
| 41 | - return I18N::translate('Miscellaneous extensions'); |
|
| 42 | - } |
|
| 36 | + /** |
|
| 37 | + * {@inheritDoc} |
|
| 38 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::getTitle() |
|
| 39 | + */ |
|
| 40 | + public function getTitle() { |
|
| 41 | + return I18N::translate('Miscellaneous extensions'); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * {@inheritDoc} |
| 46 | 46 | * @see \Fisharebest\Webtrees\Module\AbstractModule::getDescription() |
| 47 | 47 | */ |
| 48 | - public function getDescription() { |
|
| 49 | - return I18N::translate('Miscellaneous extensions for <strong>webtrees</strong>.'); |
|
| 50 | - } |
|
| 48 | + public function getDescription() { |
|
| 49 | + return I18N::translate('Miscellaneous extensions for <strong>webtrees</strong>.'); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * {@inhericDoc} |
|
| 54 | - */ |
|
| 55 | - public function modAction($mod_action) { |
|
| 56 | - \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
| 57 | - } |
|
| 52 | + /** |
|
| 53 | + * {@inhericDoc} |
|
| 54 | + */ |
|
| 55 | + public function modAction($mod_action) { |
|
| 56 | + \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * {@inhericDoc} |
|
| 61 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
| 62 | - */ |
|
| 63 | - public function getConfigLink() { |
|
| 64 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
| 65 | - } |
|
| 59 | + /** |
|
| 60 | + * {@inhericDoc} |
|
| 61 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
| 62 | + */ |
|
| 63 | + public function getConfigLink() { |
|
| 64 | + return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * {@inheritDoc} |
|
| 69 | - * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
| 70 | - */ |
|
| 67 | + /** |
|
| 68 | + * {@inheritDoc} |
|
| 69 | + * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
| 70 | + */ |
|
| 71 | 71 | public function getSubscribedHooks() { |
| 72 | 72 | return array( |
| 73 | - 'hExtendIndiHeaderLeft' => 20, |
|
| 74 | - 'hPrintHeader' => 20, |
|
| 75 | - 'hPrintFooter' => 20 |
|
| 73 | + 'hExtendIndiHeaderLeft' => 20, |
|
| 74 | + 'hPrintHeader' => 20, |
|
| 75 | + 'hPrintFooter' => 20 |
|
| 76 | 76 | ); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -87,22 +87,22 @@ discard block |
||
| 87 | 87 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\IndividualHeaderExtenderInterface::hExtendIndiHeaderLeft() |
| 88 | 88 | */ |
| 89 | 89 | public function hExtendIndiHeaderLeft(IndividualController $ctrlIndi) { |
| 90 | - $res = ''; |
|
| 91 | - $dindi = new Individual($ctrlIndi->getSignificantIndividual()); |
|
| 92 | - $titles = $dindi->getTitles(); |
|
| 93 | - if(count($titles)>0){ |
|
| 94 | - $res = ' |
|
| 90 | + $res = ''; |
|
| 91 | + $dindi = new Individual($ctrlIndi->getSignificantIndividual()); |
|
| 92 | + $titles = $dindi->getTitles(); |
|
| 93 | + if(count($titles)>0){ |
|
| 94 | + $res = ' |
|
| 95 | 95 | <dl> |
| 96 | 96 | <dt class="label">'.I18N::translate('Titles').'</dt>'; |
| 97 | - foreach($titles as $title=>$props){ |
|
| 98 | - $res .= |
|
| 99 | - '<dd class="field">' . $title. ' ' . |
|
| 100 | - FunctionsPrint::getListFromArray($props) . |
|
| 101 | - '</dd>'; |
|
| 102 | - } |
|
| 103 | - $res .= '</dl>'; |
|
| 104 | - } |
|
| 105 | - return array( 'indi-header-titles' , $res); |
|
| 97 | + foreach($titles as $title=>$props){ |
|
| 98 | + $res .= |
|
| 99 | + '<dd class="field">' . $title. ' ' . |
|
| 100 | + FunctionsPrint::getListFromArray($props) . |
|
| 101 | + '</dd>'; |
|
| 102 | + } |
|
| 103 | + $res .= '</dl>'; |
|
| 104 | + } |
|
| 105 | + return array( 'indi-header-titles' , $res); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -116,15 +116,15 @@ discard block |
||
| 116 | 116 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\PageHeaderExtenderInterface::hPrintHeader() |
| 117 | 117 | */ |
| 118 | 118 | public function hPrintHeader() { |
| 119 | - global $WT_TREE; |
|
| 119 | + global $WT_TREE; |
|
| 120 | 120 | |
| 121 | - $html = ''; |
|
| 122 | - if($this->getSetting('MAJ_ADD_HTML_HEADER', 0) == 1){ |
|
| 123 | - if(Auth::accessLevel($WT_TREE) >= $this->getSetting('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE) && !Filter::getBool('noheader')){ |
|
| 124 | - $html .= $this->getSetting('MAJ_HTML_HEADER', ''); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - return $html; |
|
| 121 | + $html = ''; |
|
| 122 | + if($this->getSetting('MAJ_ADD_HTML_HEADER', 0) == 1){ |
|
| 123 | + if(Auth::accessLevel($WT_TREE) >= $this->getSetting('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE) && !Filter::getBool('noheader')){ |
|
| 124 | + $html .= $this->getSetting('MAJ_HTML_HEADER', ''); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + return $html; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -132,26 +132,26 @@ discard block |
||
| 132 | 132 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\PageFooterExtenderInterface::hPrintFooter() |
| 133 | 133 | */ |
| 134 | 134 | public function hPrintFooter() { |
| 135 | - global $WT_TREE; |
|
| 135 | + global $WT_TREE; |
|
| 136 | 136 | |
| 137 | - $html = ''; |
|
| 138 | - if($this->getSetting('MAJ_DISPLAY_CNIL', 0) == 1){ |
|
| 139 | - $html .= '<br/>'; |
|
| 140 | - $html .= '<div class="center">'; |
|
| 141 | - $cnil_ref = $this->getSetting('MAJ_CNIL_REFERENCE', ''); |
|
| 142 | - if($cnil_ref != ''){ |
|
| 143 | - $html .= I18N::translate('This site has been notified to the French National Commission for Data protection (CNIL) and registered under number %s. ', $cnil_ref); |
|
| 144 | - } |
|
| 145 | - $html .= I18N::translate('In accordance with the French Data protection Act (<em>Loi Informatique et Libertés</em>) of January 6th, 1978, you have the right to access, modify, rectify and delete personal information that pertains to you. To exercice this right, please contact %s, and provide your name, address and a proof of your identity.', Theme::theme()->contactLink(User::find($WT_TREE->getPreference('WEBMASTER_USER_ID')))); |
|
| 146 | - $html .= '</div>'; |
|
| 147 | - } |
|
| 137 | + $html = ''; |
|
| 138 | + if($this->getSetting('MAJ_DISPLAY_CNIL', 0) == 1){ |
|
| 139 | + $html .= '<br/>'; |
|
| 140 | + $html .= '<div class="center">'; |
|
| 141 | + $cnil_ref = $this->getSetting('MAJ_CNIL_REFERENCE', ''); |
|
| 142 | + if($cnil_ref != ''){ |
|
| 143 | + $html .= I18N::translate('This site has been notified to the French National Commission for Data protection (CNIL) and registered under number %s. ', $cnil_ref); |
|
| 144 | + } |
|
| 145 | + $html .= I18N::translate('In accordance with the French Data protection Act (<em>Loi Informatique et Libertés</em>) of January 6th, 1978, you have the right to access, modify, rectify and delete personal information that pertains to you. To exercice this right, please contact %s, and provide your name, address and a proof of your identity.', Theme::theme()->contactLink(User::find($WT_TREE->getPreference('WEBMASTER_USER_ID')))); |
|
| 146 | + $html .= '</div>'; |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - if($this->getSetting('MAJ_ADD_HTML_FOOTER', 0) == 1){ |
|
| 150 | - if(Auth::accessLevel($WT_TREE) >= $this->getSetting('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE) && !Filter::getBool('nofooter')){ |
|
| 151 | - $html .= $this->getSetting('MAJ_HTML_FOOTER', ''); |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - return $html; |
|
| 149 | + if($this->getSetting('MAJ_ADD_HTML_FOOTER', 0) == 1){ |
|
| 150 | + if(Auth::accessLevel($WT_TREE) >= $this->getSetting('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE) && !Filter::getBool('nofooter')){ |
|
| 151 | + $html .= $this->getSetting('MAJ_HTML_FOOTER', ''); |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + return $html; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | } |
@@ -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( |