@@ -29,89 +29,89 @@ discard block |
||
29 | 29 | */ |
30 | 30 | class AdminConfigController extends MvcController |
31 | 31 | { |
32 | - /** |
|
33 | - * Manage updates sent from the AdminConfig@index form. |
|
34 | - */ |
|
35 | - protected function update() { |
|
36 | - if(Auth::isAdmin()){ |
|
37 | - $ihooks = HookProvider::getInstance()->getInstalledHooks(); |
|
32 | + /** |
|
33 | + * Manage updates sent from the AdminConfig@index form. |
|
34 | + */ |
|
35 | + protected function update() { |
|
36 | + if(Auth::isAdmin()){ |
|
37 | + $ihooks = HookProvider::getInstance()->getInstalledHooks(); |
|
38 | 38 | |
39 | - $module_names= Database::prepare( |
|
40 | - "SELECT module_name FROM `##module` WHERE status='disabled'" |
|
41 | - )->fetchOneColumn(); |
|
39 | + $module_names= Database::prepare( |
|
40 | + "SELECT module_name FROM `##module` WHERE status='disabled'" |
|
41 | + )->fetchOneColumn(); |
|
42 | 42 | |
43 | - if($ihooks !== null){ |
|
44 | - foreach ($ihooks as $ihook => $params) { |
|
45 | - if(Filter::post('hook-' . $params['id']) === 'yes') { |
|
46 | - $array_hook = explode('#', $ihook); |
|
47 | - //Update status |
|
48 | - $new_status= Filter::postBool('status-' . $params['id']); |
|
49 | - if(in_array($array_hook[0], $module_names)) $new_status = false; |
|
50 | - $previous_status = $params['status']; |
|
51 | - if ($new_status !== null) { |
|
52 | - $new_status= $new_status ? 'enabled' : 'disabled'; |
|
53 | - if($new_status != $previous_status){ |
|
54 | - $chook = new Hook($array_hook[1], $array_hook[2]); |
|
55 | - switch($new_status){ |
|
56 | - case 'enabled': |
|
57 | - $chook->enable($array_hook[0]); |
|
58 | - break; |
|
59 | - case 'disabled': |
|
60 | - $chook->disable($array_hook[0]); |
|
61 | - break; |
|
62 | - default: |
|
63 | - break; |
|
64 | - } |
|
65 | - } |
|
66 | - } |
|
43 | + if($ihooks !== null){ |
|
44 | + foreach ($ihooks as $ihook => $params) { |
|
45 | + if(Filter::post('hook-' . $params['id']) === 'yes') { |
|
46 | + $array_hook = explode('#', $ihook); |
|
47 | + //Update status |
|
48 | + $new_status= Filter::postBool('status-' . $params['id']); |
|
49 | + if(in_array($array_hook[0], $module_names)) $new_status = false; |
|
50 | + $previous_status = $params['status']; |
|
51 | + if ($new_status !== null) { |
|
52 | + $new_status= $new_status ? 'enabled' : 'disabled'; |
|
53 | + if($new_status != $previous_status){ |
|
54 | + $chook = new Hook($array_hook[1], $array_hook[2]); |
|
55 | + switch($new_status){ |
|
56 | + case 'enabled': |
|
57 | + $chook->enable($array_hook[0]); |
|
58 | + break; |
|
59 | + case 'disabled': |
|
60 | + $chook->disable($array_hook[0]); |
|
61 | + break; |
|
62 | + default: |
|
63 | + break; |
|
64 | + } |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | - //Update priority |
|
69 | - $new_priority = Filter::postInteger("moduleorder-{$params['id']}"); |
|
70 | - $previous_priority = $params['priority']; |
|
71 | - if ($new_priority !== null) { |
|
72 | - if($new_priority != $previous_priority){ |
|
73 | - $chook = new Hook($array_hook[1], $array_hook[2]); |
|
74 | - $chook->setPriority($array_hook[0], $new_priority); |
|
75 | - } |
|
76 | - } |
|
77 | - } |
|
78 | - } |
|
79 | - } |
|
80 | - } |
|
81 | - } |
|
68 | + //Update priority |
|
69 | + $new_priority = Filter::postInteger("moduleorder-{$params['id']}"); |
|
70 | + $previous_priority = $params['priority']; |
|
71 | + if ($new_priority !== null) { |
|
72 | + if($new_priority != $previous_priority){ |
|
73 | + $chook = new Hook($array_hook[1], $array_hook[2]); |
|
74 | + $chook->setPriority($array_hook[0], $new_priority); |
|
75 | + } |
|
76 | + } |
|
77 | + } |
|
78 | + } |
|
79 | + } |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Pages |
|
85 | - */ |
|
83 | + /** |
|
84 | + * Pages |
|
85 | + */ |
|
86 | 86 | |
87 | - /** |
|
88 | - * AdminConfig@index |
|
89 | - */ |
|
90 | - public function index() { |
|
91 | - global $WT_TREE; |
|
87 | + /** |
|
88 | + * AdminConfig@index |
|
89 | + */ |
|
90 | + public function index() { |
|
91 | + global $WT_TREE; |
|
92 | 92 | |
93 | - HookProvider::getInstance()->updateHooks(); |
|
93 | + HookProvider::getInstance()->updateHooks(); |
|
94 | 94 | |
95 | - $action = Filter::post('action'); |
|
96 | - if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
95 | + $action = Filter::post('action'); |
|
96 | + if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
97 | 97 | |
98 | - Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
99 | - $ctrl = new PageController(); |
|
100 | - $ctrl |
|
101 | - ->restrictAccess(Auth::isAdmin()) |
|
102 | - ->setPageTitle($this->module->getTitle()); |
|
98 | + Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
99 | + $ctrl = new PageController(); |
|
100 | + $ctrl |
|
101 | + ->restrictAccess(Auth::isAdmin()) |
|
102 | + ->setPageTitle($this->module->getTitle()); |
|
103 | 103 | |
104 | - $table_id = 'table-installedhooks-' . Uuid::uuid4(); |
|
104 | + $table_id = 'table-installedhooks-' . Uuid::uuid4(); |
|
105 | 105 | |
106 | - $view_bag = new ViewBag(); |
|
107 | - $view_bag->set('title', $ctrl->getPageTitle()); |
|
108 | - $view_bag->set('table_id', $table_id); |
|
109 | - $view_bag->set('hook_list', HookProvider::getInstance()->getRawInstalledHooks()); |
|
106 | + $view_bag = new ViewBag(); |
|
107 | + $view_bag->set('title', $ctrl->getPageTitle()); |
|
108 | + $view_bag->set('table_id', $table_id); |
|
109 | + $view_bag->set('hook_list', HookProvider::getInstance()->getRawInstalledHooks()); |
|
110 | 110 | |
111 | - $ctrl |
|
112 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
113 | - ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
114 | - ->addInlineJavascript(' |
|
111 | + $ctrl |
|
112 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
113 | + ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
114 | + ->addInlineJavascript(' |
|
115 | 115 | jQuery(document).ready(function() { |
116 | 116 | jQuery("#'.$table_id.'").dataTable( { |
117 | 117 | '.I18N::datatablesI18N().', |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | }); |
132 | 132 | '); |
133 | 133 | |
134 | - ViewFactory::make('AdminConfig', $this, $ctrl, $view_bag)->render(); |
|
135 | - } |
|
134 | + ViewFactory::make('AdminConfig', $this, $ctrl, $view_bag)->render(); |
|
135 | + } |
|
136 | 136 | |
137 | 137 | } |
138 | 138 | \ No newline at end of file |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function getInstance() |
44 | 44 | { |
45 | - if (null === static::$instance) { |
|
46 | - static::$instance = new static(); |
|
47 | - } |
|
45 | + if (null === static::$instance) { |
|
46 | + static::$instance = new static(); |
|
47 | + } |
|
48 | 48 | |
49 | - return static::$instance; |
|
49 | + return static::$instance; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::get() |
55 | 55 | */ |
56 | 56 | public function get($hook_function, $hook_context = null) { |
57 | - return new Hook($hook_function, $hook_context); |
|
57 | + return new Hook($hook_function, $hook_context); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | public function getPossibleHooks() { |
73 | 73 | static $hooks=null; |
74 | 74 | if ($hooks === null) { |
75 | - $hooks = array(); |
|
76 | - foreach (glob(WT_ROOT . WT_MODULES_DIR . '*/module.php') as $file) { |
|
77 | - try { |
|
78 | - $module = include $file; |
|
79 | - if($module instanceof HookSubscriberInterface){ |
|
75 | + $hooks = array(); |
|
76 | + foreach (glob(WT_ROOT . WT_MODULES_DIR . '*/module.php') as $file) { |
|
77 | + try { |
|
78 | + $module = include $file; |
|
79 | + if($module instanceof HookSubscriberInterface){ |
|
80 | 80 | $subscribedhooks = $module->getSubscribedHooks(); |
81 | 81 | if(is_array($subscribedhooks)){ |
82 | 82 | foreach($subscribedhooks as $key => $value){ |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | } |
103 | 103 | } |
104 | 104 | } |
105 | - } catch (\Exception $ex) { |
|
106 | - // Old or invalid module? |
|
107 | - } |
|
105 | + } catch (\Exception $ex) { |
|
106 | + // Old or invalid module? |
|
107 | + } |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | return $hooks; |
@@ -146,33 +146,33 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function updateHooks() { |
148 | 148 | |
149 | - if(Auth::isAdmin()){ |
|
150 | - $ihooks = self::getInstalledHooks(); |
|
151 | - $phooks = self::getPossibleHooks(); |
|
149 | + if(Auth::isAdmin()){ |
|
150 | + $ihooks = self::getInstalledHooks(); |
|
151 | + $phooks = self::getPossibleHooks(); |
|
152 | 152 | |
153 | - // Insert hooks not existing yet in the DB |
|
154 | - if($phooks !== null){ |
|
155 | - foreach($phooks as $phook => $priority){ |
|
156 | - $array_hook = explode('#', $phook); |
|
157 | - if($ihooks === null || !array_key_exists($phook, $ihooks)){ |
|
158 | - $chook = new Hook($array_hook[1], $array_hook[2]); |
|
159 | - $chook->subscribe($array_hook[0]); |
|
160 | - $chook->setPriority($array_hook[0], $priority); |
|
161 | - } |
|
162 | - } |
|
163 | - } |
|
153 | + // Insert hooks not existing yet in the DB |
|
154 | + if($phooks !== null){ |
|
155 | + foreach($phooks as $phook => $priority){ |
|
156 | + $array_hook = explode('#', $phook); |
|
157 | + if($ihooks === null || !array_key_exists($phook, $ihooks)){ |
|
158 | + $chook = new Hook($array_hook[1], $array_hook[2]); |
|
159 | + $chook->subscribe($array_hook[0]); |
|
160 | + $chook->setPriority($array_hook[0], $priority); |
|
161 | + } |
|
162 | + } |
|
163 | + } |
|
164 | 164 | |
165 | - //Remove hooks not existing any more in the file system |
|
166 | - if($ihooks !== null){ |
|
167 | - foreach($ihooks as $ihook => $status){ |
|
168 | - $array_hook = explode('#', $ihook); |
|
169 | - if($phooks === null || !array_key_exists($ihook, $phooks)){ |
|
170 | - $chook = new Hook($array_hook[1], $array_hook[2]); |
|
171 | - $chook->remove($array_hook[0]); |
|
172 | - } |
|
173 | - } |
|
174 | - } |
|
175 | - } |
|
165 | + //Remove hooks not existing any more in the file system |
|
166 | + if($ihooks !== null){ |
|
167 | + foreach($ihooks as $ihook => $status){ |
|
168 | + $array_hook = explode('#', $ihook); |
|
169 | + if($phooks === null || !array_key_exists($ihook, $phooks)){ |
|
170 | + $chook = new Hook($array_hook[1], $array_hook[2]); |
|
171 | + $chook->remove($array_hook[0]); |
|
172 | + } |
|
173 | + } |
|
174 | + } |
|
175 | + } |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | } |
179 | 179 | \ No newline at end of file |
@@ -16,51 +16,51 @@ |
||
16 | 16 | */ |
17 | 17 | interface HookProviderInterface { |
18 | 18 | |
19 | - /** |
|
20 | - * Return an instance of the hook linked to the specifed function / context |
|
21 | - * |
|
22 | - * @param string $hook_function |
|
23 | - * @param string $hook_context |
|
24 | - * @return Hook |
|
25 | - */ |
|
26 | - public function get($hook_function, $hook_context = null); |
|
19 | + /** |
|
20 | + * Return an instance of the hook linked to the specifed function / context |
|
21 | + * |
|
22 | + * @param string $hook_function |
|
23 | + * @param string $hook_context |
|
24 | + * @return Hook |
|
25 | + */ |
|
26 | + public function get($hook_function, $hook_context = null); |
|
27 | 27 | |
28 | - /** |
|
29 | - * Return whether the Hook module is active and the table has been created. |
|
30 | - * |
|
31 | - * @uses \MyArtJaub\Webtrees\Module\ModuleManager to check if the module is operational |
|
32 | - * @return bool True if module active and table created, false otherwise |
|
33 | - */ |
|
34 | - public function isModuleOperational(); |
|
28 | + /** |
|
29 | + * Return whether the Hook module is active and the table has been created. |
|
30 | + * |
|
31 | + * @uses \MyArtJaub\Webtrees\Module\ModuleManager to check if the module is operational |
|
32 | + * @return bool True if module active and table created, false otherwise |
|
33 | + */ |
|
34 | + public function isModuleOperational(); |
|
35 | 35 | |
36 | - /** |
|
37 | - * Get the list of possible hooks in the list of modules files. |
|
38 | - * A hook will be registered: |
|
39 | - * - for all modules already registered in Webtrees |
|
40 | - * - if the module implements HookSubscriberInterface |
|
41 | - * - if the method exist within the module |
|
42 | - * |
|
43 | - * @return Array List of possible hooks, with the priority |
|
44 | - */ |
|
45 | - public function getPossibleHooks(); |
|
36 | + /** |
|
37 | + * Get the list of possible hooks in the list of modules files. |
|
38 | + * A hook will be registered: |
|
39 | + * - for all modules already registered in Webtrees |
|
40 | + * - if the module implements HookSubscriberInterface |
|
41 | + * - if the method exist within the module |
|
42 | + * |
|
43 | + * @return Array List of possible hooks, with the priority |
|
44 | + */ |
|
45 | + public function getPossibleHooks(); |
|
46 | 46 | |
47 | - /** |
|
48 | - * Get the list of hooks intalled in webtrees, with their id, status and priority. |
|
49 | - * |
|
50 | - * @return array List of installed hooks |
|
51 | - */ |
|
52 | - public function getRawInstalledHooks(); |
|
47 | + /** |
|
48 | + * Get the list of hooks intalled in webtrees, with their id, status and priority. |
|
49 | + * |
|
50 | + * @return array List of installed hooks |
|
51 | + */ |
|
52 | + public function getRawInstalledHooks(); |
|
53 | 53 | |
54 | - /** |
|
55 | - * Get the list of hooks intalled in webtrees, with their id, status and priority. |
|
56 | - * |
|
57 | - * @return Array List of installed hooks, with id, status and priority |
|
58 | - */ |
|
59 | - public function getInstalledHooks(); |
|
54 | + /** |
|
55 | + * Get the list of hooks intalled in webtrees, with their id, status and priority. |
|
56 | + * |
|
57 | + * @return Array List of installed hooks, with id, status and priority |
|
58 | + */ |
|
59 | + public function getInstalledHooks(); |
|
60 | 60 | |
61 | - /** |
|
62 | - * Update the list of hooks, identifying missing ones and removed ones. |
|
63 | - */ |
|
64 | - public function updateHooks(); |
|
61 | + /** |
|
62 | + * Update the list of hooks, identifying missing ones and removed ones. |
|
63 | + */ |
|
64 | + public function updateHooks(); |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | \ No newline at end of file |
@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | * {@inhericDoc} |
30 | 30 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
31 | 31 | */ |
32 | - protected function renderContent() { |
|
33 | - ?> |
|
32 | + protected function renderContent() { |
|
33 | + ?> |
|
34 | 34 | <div id="maj-sosa-missing-page" class="center"> |
35 | 35 | <h2><?php echo $this->data->get('title'); ?></h2> |
36 | 36 | |
37 | 37 | <?php if($this->data->get('is_setup')) { |
38 | - $this->renderSosaHeader(); |
|
39 | - if($this->data->get('has_missing', false)) { |
|
40 | - $table_id = $this->data->get('table_id'); |
|
41 | - ?> |
|
38 | + $this->renderSosaHeader(); |
|
39 | + if($this->data->get('has_missing', false)) { |
|
40 | + $table_id = $this->data->get('table_id'); |
|
41 | + ?> |
|
42 | 42 | <div id="sosa-indi-missing" class="smissing-list"> |
43 | 43 | <table id="<?php echo $table_id;?>"> |
44 | 44 | <thead> |
@@ -109,44 +109,44 @@ discard block |
||
109 | 109 | <tbody> |
110 | 110 | |
111 | 111 | <?php foreach($this->data->get('missing_list') as $missing_tab) { |
112 | - $person = $missing_tab['indi']; |
|
112 | + $person = $missing_tab['indi']; |
|
113 | 113 | |
114 | - /** @var \Fisharebest\Webtrees\Individual $person */ |
|
115 | - if ($person->isPendingAddtion()) { |
|
116 | - $class = ' class="new"'; |
|
117 | - } elseif ($person->isPendingDeletion()) { |
|
118 | - $class = ' class="old"'; |
|
119 | - } else { |
|
120 | - $class = ''; |
|
121 | - } |
|
122 | - $dperson = new \MyArtJaub\Webtrees\Individual($person); |
|
123 | - ?> |
|
114 | + /** @var \Fisharebest\Webtrees\Individual $person */ |
|
115 | + if ($person->isPendingAddtion()) { |
|
116 | + $class = ' class="new"'; |
|
117 | + } elseif ($person->isPendingDeletion()) { |
|
118 | + $class = ' class="old"'; |
|
119 | + } else { |
|
120 | + $class = ''; |
|
121 | + } |
|
122 | + $dperson = new \MyArtJaub\Webtrees\Individual($person); |
|
123 | + ?> |
|
124 | 124 | <tr <?php echo $class?>> |
125 | 125 | <td class="transparent"><?php echo $missing_tab['sosa']; ?></td> |
126 | 126 | <td class="transparent"><?php echo $person->getXref(); ?></td> |
127 | 127 | <td colspan="2"> |
128 | 128 | <?php foreach ($person->getAllNames() as $num=>$name) { |
129 | - if ($name['type']=='NAME') { |
|
130 | - $title=''; |
|
131 | - } else { |
|
132 | - $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $person)).'"'; |
|
133 | - } |
|
134 | - if ($num==$person->getPrimaryName()) { |
|
135 | - $class=' class="name2"'; |
|
136 | - $sex_image=$person->getSexImage(); |
|
137 | - list($surn, $givn)=explode(',', $name['sort']); |
|
138 | - } else { |
|
139 | - $class=''; |
|
140 | - $sex_image=''; |
|
141 | - } ?> |
|
129 | + if ($name['type']=='NAME') { |
|
130 | + $title=''; |
|
131 | + } else { |
|
132 | + $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $person)).'"'; |
|
133 | + } |
|
134 | + if ($num==$person->getPrimaryName()) { |
|
135 | + $class=' class="name2"'; |
|
136 | + $sex_image=$person->getSexImage(); |
|
137 | + list($surn, $givn)=explode(',', $name['sort']); |
|
138 | + } else { |
|
139 | + $class=''; |
|
140 | + $sex_image=''; |
|
141 | + } ?> |
|
142 | 142 | <a <?php echo $title.' '.$class; ?> href="<?php echo $person->getHtmlUrl(); ?>"> |
143 | 143 | <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']); ?> |
144 | 144 | </a> |
145 | 145 | <?php echo $sex_image.FunctionsPrint::formatSosaNumbers($dperson->getSosaNumbers(), 1, 'smaller'); ?> |
146 | 146 | <br/> |
147 | 147 | <?php } |
148 | - echo $person->getPrimaryParentsNames('parents details1', 'none'); |
|
149 | - ?> |
|
148 | + echo $person->getPrimaryParentsNames('parents details1', 'none'); |
|
149 | + ?> |
|
150 | 150 | </td> |
151 | 151 | <td style="display:none;"></td> |
152 | 152 | <td> |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | <?php echo Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)); ?> |
157 | 157 | </td> |
158 | 158 | <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { |
159 | - $isISourced = $dperson->isSourced(); ?> |
|
159 | + $isISourced = $dperson->isSourced(); ?> |
|
160 | 160 | <td><?php echo FunctionsPrint::formatIsSourcedIcon('R', $isISourced, 'INDI', 1, 'medium'); ?></td> |
161 | 161 | <td><?php echo $isISourced; ?></td> |
162 | 162 | <?php } else { ?> |
@@ -167,34 +167,34 @@ discard block |
||
167 | 167 | <td><?php echo $missing_tab['has_mother'] ? ' ' : 'X';?></td> |
168 | 168 | <td> |
169 | 169 | <?php |
170 | - if ($birth_dates=$person->getAllBirthDates()) { |
|
171 | - foreach ($birth_dates as $num=>$birth_date) { |
|
172 | - if ($num) { ?><br/><?php } ?> |
|
170 | + if ($birth_dates=$person->getAllBirthDates()) { |
|
171 | + foreach ($birth_dates as $num=>$birth_date) { |
|
172 | + if ($num) { ?><br/><?php } ?> |
|
173 | 173 | <?php echo $birth_date->display(true); |
174 | - } |
|
175 | - } else { |
|
176 | - $birth_date=$person->getEstimatedBirthDate(); |
|
177 | - if ($person->getTree()->getPreference('SHOW_EST_LIST_DATES')) { |
|
178 | - $birth_date->display(true); |
|
179 | - } else { |
|
180 | - echo ' '; |
|
181 | - } |
|
182 | - $birth_dates[0] = new Date(''); |
|
183 | - } |
|
184 | - ?> |
|
174 | + } |
|
175 | + } else { |
|
176 | + $birth_date=$person->getEstimatedBirthDate(); |
|
177 | + if ($person->getTree()->getPreference('SHOW_EST_LIST_DATES')) { |
|
178 | + $birth_date->display(true); |
|
179 | + } else { |
|
180 | + echo ' '; |
|
181 | + } |
|
182 | + $birth_dates[0] = new Date(''); |
|
183 | + } |
|
184 | + ?> |
|
185 | 185 | </td> |
186 | 186 | <td><?php echo $birth_date->julianDay();?></td> |
187 | 187 | <td> |
188 | 188 | <?php foreach ($person->getAllBirthPlaces() as $n => $birth_place) { |
189 | - $tmp = new \Fisharebest\Webtrees\Place($birth_place, $person->getTree()); |
|
190 | - if ($n) { ?><br><?php } ?> |
|
189 | + $tmp = new \Fisharebest\Webtrees\Place($birth_place, $person->getTree()); |
|
190 | + if ($n) { ?><br><?php } ?> |
|
191 | 191 | <a href="'<?php echo $tmp->getURL(); ?>" title="<?php echo strip_tags($tmp->getFullName()); ?>"> |
192 | 192 | <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName()); ?> |
193 | 193 | </a> |
194 | 194 | <?php } ?> |
195 | 195 | </td> |
196 | 196 | <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { |
197 | - $isBSourced = $dperson->isBirthSourced(); ?> |
|
197 | + $isBSourced = $dperson->isBirthSourced(); ?> |
|
198 | 198 | <td><?php echo FunctionsPrint::formatIsSourcedIcon('E', $isBSourced, 'BIRT', 1, 'medium'); ?></td> |
199 | 199 | <td><?php echo $isBSourced; ?></td> |
200 | 200 | <?php } else { ?> |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | <?php } else { ?> |
222 | 222 | <p><?php echo I18N::translate('No ancestors are missing for this generation. Generation complete at %s.', I18N::percentage($this->data->get('perc_sosa'), 2)); ?></p> |
223 | 223 | <?php } |
224 | - } else { ?> |
|
224 | + } else { ?> |
|
225 | 225 | <p class="warning"><?php echo I18N::translate('The list could not be displayed. Reasons might be:'); ?><br/> |
226 | 226 | <ul> |
227 | 227 | <li><?php echo I18N::translate('No Sosa root individual has been defined.'); ?></li> |
@@ -232,6 +232,6 @@ discard block |
||
232 | 232 | <?php } ?> |
233 | 233 | </div> |
234 | 234 | <?php |
235 | - } |
|
235 | + } |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | \ No newline at end of file |
@@ -19,116 +19,116 @@ |
||
19 | 19 | */ |
20 | 20 | class SosaCalculator { |
21 | 21 | |
22 | - /** |
|
23 | - * Maximium size for the temporary Sosa table |
|
24 | - * @var int TMP_SOSA_TABLE_LIMIT |
|
25 | - */ |
|
26 | - const TMP_SOSA_TABLE_LIMIT = 1000; |
|
22 | + /** |
|
23 | + * Maximium size for the temporary Sosa table |
|
24 | + * @var int TMP_SOSA_TABLE_LIMIT |
|
25 | + */ |
|
26 | + const TMP_SOSA_TABLE_LIMIT = 1000; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Reference user |
|
30 | - * @var Fisharebest\Webtrees\User $user |
|
31 | - */ |
|
32 | - protected $user; |
|
28 | + /** |
|
29 | + * Reference user |
|
30 | + * @var Fisharebest\Webtrees\User $user |
|
31 | + */ |
|
32 | + protected $user; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Reference tree |
|
36 | - * @var Fisharebest\Webtrees\Tree $tree |
|
37 | - */ |
|
38 | - protected $tree; |
|
34 | + /** |
|
35 | + * Reference tree |
|
36 | + * @var Fisharebest\Webtrees\Tree $tree |
|
37 | + */ |
|
38 | + protected $tree; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Sosa Provider for the calculator |
|
42 | - * @var \MyArtJaub\Webtrees\Module\Sosa\Model\SosaCalculator $sosa_provider |
|
43 | - */ |
|
44 | - protected $sosa_provider; |
|
40 | + /** |
|
41 | + * Sosa Provider for the calculator |
|
42 | + * @var \MyArtJaub\Webtrees\Module\Sosa\Model\SosaCalculator $sosa_provider |
|
43 | + */ |
|
44 | + protected $sosa_provider; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Temporary Sosa table, used during construction |
|
48 | - * @var array $tmp_sosa_table |
|
49 | - */ |
|
50 | - protected $tmp_sosa_table; |
|
46 | + /** |
|
47 | + * Temporary Sosa table, used during construction |
|
48 | + * @var array $tmp_sosa_table |
|
49 | + */ |
|
50 | + protected $tmp_sosa_table; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Constructor for the Sosa Calculator |
|
54 | - * @param Tree $tree |
|
55 | - * @param User $user |
|
56 | - */ |
|
57 | - public function __construct(Tree $tree, User $user) { |
|
58 | - $this->tree = $tree; |
|
59 | - $this->user = $user; |
|
52 | + /** |
|
53 | + * Constructor for the Sosa Calculator |
|
54 | + * @param Tree $tree |
|
55 | + * @param User $user |
|
56 | + */ |
|
57 | + public function __construct(Tree $tree, User $user) { |
|
58 | + $this->tree = $tree; |
|
59 | + $this->user = $user; |
|
60 | 60 | |
61 | - $this->sosa_provider = new SosaProvider($this->tree, $this->user);; |
|
62 | - } |
|
61 | + $this->sosa_provider = new SosaProvider($this->tree, $this->user);; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Compute all Sosa ancestors from the user's root individual. |
|
66 | - * @return bool Result of the computation |
|
67 | - */ |
|
68 | - public function computeAll() { |
|
69 | - $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID'); |
|
70 | - $indi = Individual::getInstance($root_id, $this->tree); |
|
71 | - if($indi){ |
|
72 | - $this->sosa_provider->deleteAll(); |
|
73 | - $this->addNode($indi, 1); |
|
74 | - $this->flushTmpSosaTable(true); |
|
75 | - return true; |
|
76 | - } |
|
77 | - return false; |
|
78 | - } |
|
64 | + /** |
|
65 | + * Compute all Sosa ancestors from the user's root individual. |
|
66 | + * @return bool Result of the computation |
|
67 | + */ |
|
68 | + public function computeAll() { |
|
69 | + $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID'); |
|
70 | + $indi = Individual::getInstance($root_id, $this->tree); |
|
71 | + if($indi){ |
|
72 | + $this->sosa_provider->deleteAll(); |
|
73 | + $this->addNode($indi, 1); |
|
74 | + $this->flushTmpSosaTable(true); |
|
75 | + return true; |
|
76 | + } |
|
77 | + return false; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Compute all Sosa Ancestors from a specified Individual |
|
82 | - * @param Individual $indi |
|
83 | - * @return bool Result of the computation |
|
84 | - */ |
|
85 | - public function computeFromIndividual(Individual $indi) { |
|
86 | - $dindi = new \MyArtJaub\Webtrees\Individual($indi); |
|
87 | - $current_sosas = $dindi->getSosaNumbers(); |
|
88 | - foreach($current_sosas as $current_sosa => $gen) { |
|
89 | - $this->sosa_provider->deleteAncestors($current_sosa); |
|
90 | - $this->addNode($indi, $current_sosa); |
|
91 | - } |
|
92 | - $this->flushTmpSosaTable(true); |
|
93 | - return true; |
|
94 | - } |
|
80 | + /** |
|
81 | + * Compute all Sosa Ancestors from a specified Individual |
|
82 | + * @param Individual $indi |
|
83 | + * @return bool Result of the computation |
|
84 | + */ |
|
85 | + public function computeFromIndividual(Individual $indi) { |
|
86 | + $dindi = new \MyArtJaub\Webtrees\Individual($indi); |
|
87 | + $current_sosas = $dindi->getSosaNumbers(); |
|
88 | + foreach($current_sosas as $current_sosa => $gen) { |
|
89 | + $this->sosa_provider->deleteAncestors($current_sosa); |
|
90 | + $this->addNode($indi, $current_sosa); |
|
91 | + } |
|
92 | + $this->flushTmpSosaTable(true); |
|
93 | + return true; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Recursive method to add individual to the Sosa table, and flush it regularly |
|
98 | - * @param Individual $indi Individual to add |
|
99 | - * @param int $sosa Individual's sosa |
|
100 | - */ |
|
101 | - protected function addNode(Individual $indi, $sosa) { |
|
102 | - $birth_year = $indi->getEstimatedBirthDate()->gregorianYear(); |
|
103 | - $death_year = $indi->getEstimatedDeathDate()->gregorianYear(); |
|
96 | + /** |
|
97 | + * Recursive method to add individual to the Sosa table, and flush it regularly |
|
98 | + * @param Individual $indi Individual to add |
|
99 | + * @param int $sosa Individual's sosa |
|
100 | + */ |
|
101 | + protected function addNode(Individual $indi, $sosa) { |
|
102 | + $birth_year = $indi->getEstimatedBirthDate()->gregorianYear(); |
|
103 | + $death_year = $indi->getEstimatedDeathDate()->gregorianYear(); |
|
104 | 104 | |
105 | - $this->tmp_sosa_table[] = array( |
|
106 | - 'indi' => $indi->getXref(), |
|
107 | - 'sosa' => $sosa, |
|
108 | - 'birth_year' => $birth_year, |
|
109 | - 'death_year' => $death_year |
|
110 | - ); |
|
105 | + $this->tmp_sosa_table[] = array( |
|
106 | + 'indi' => $indi->getXref(), |
|
107 | + 'sosa' => $sosa, |
|
108 | + 'birth_year' => $birth_year, |
|
109 | + 'death_year' => $death_year |
|
110 | + ); |
|
111 | 111 | |
112 | - $this->flushTmpSosaTable(); |
|
112 | + $this->flushTmpSosaTable(); |
|
113 | 113 | |
114 | - if($fam = $indi->getPrimaryChildFamily()) { |
|
115 | - if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa); |
|
116 | - if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1); |
|
117 | - } |
|
118 | - } |
|
114 | + if($fam = $indi->getPrimaryChildFamily()) { |
|
115 | + if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa); |
|
116 | + if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1); |
|
117 | + } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Write sosas in the table, if the number of items is superior to the limit, or if forced. |
|
122 | - * |
|
123 | - * @param bool $force Should the flush be forced |
|
124 | - */ |
|
125 | - protected function flushTmpSosaTable($force = false) { |
|
126 | - if( count($this->tmp_sosa_table)> 0 && |
|
127 | - ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){ |
|
128 | - $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table); |
|
129 | - $this->tmp_sosa_table = array(); |
|
130 | - } |
|
131 | - } |
|
120 | + /** |
|
121 | + * Write sosas in the table, if the number of items is superior to the limit, or if forced. |
|
122 | + * |
|
123 | + * @param bool $force Should the flush be forced |
|
124 | + */ |
|
125 | + protected function flushTmpSosaTable($force = false) { |
|
126 | + if( count($this->tmp_sosa_table)> 0 && |
|
127 | + ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){ |
|
128 | + $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table); |
|
129 | + $this->tmp_sosa_table = array(); |
|
130 | + } |
|
131 | + } |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | 135 | \ No newline at end of file |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | */ |
30 | 30 | class HealthCheckEmailTask extends AbstractTask implements ConfigurableTaskInterface { |
31 | 31 | |
32 | - /** |
|
33 | - * {@inheritDoc} |
|
34 | - * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getTitle() |
|
35 | - */ |
|
36 | - public function getTitle() { |
|
32 | + /** |
|
33 | + * {@inheritDoc} |
|
34 | + * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getTitle() |
|
35 | + */ |
|
36 | + public function getTitle() { |
|
37 | 37 | return I18N::translate('Healthcheck Email'); |
38 | 38 | } |
39 | 39 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * {@inheritDoc} |
42 | 42 | * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getDefaultFrequency() |
43 | 43 | */ |
44 | - public function getDefaultFrequency() { |
|
44 | + public function getDefaultFrequency() { |
|
45 | 45 | return 10080; // = 1 week = 7 * 24 * 60 min |
46 | 46 | } |
47 | 47 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * {@inheritDoc} |
50 | 50 | * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::executeSteps() |
51 | 51 | */ |
52 | - protected function executeSteps() { |
|
52 | + protected function executeSteps() { |
|
53 | 53 | |
54 | 54 | $res = false; |
55 | 55 | |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | $interval = max($this->frequency, $interval_sincelast); |
64 | 64 | $nbdays = ceil($interval / (24 * 60)); |
65 | 65 | |
66 | - // Check for updates |
|
67 | - $latest_version_txt = Functions::fetchLatestVersion(); |
|
68 | - if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) { |
|
69 | - list($latest_version, , $download_url) = explode('|', $latest_version_txt); |
|
70 | - } else { |
|
71 | - // Cannot determine the latest version |
|
72 | - list($latest_version, , $download_url) = explode('|', '||'); |
|
73 | - } |
|
66 | + // Check for updates |
|
67 | + $latest_version_txt = Functions::fetchLatestVersion(); |
|
68 | + if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) { |
|
69 | + list($latest_version, , $download_url) = explode('|', $latest_version_txt); |
|
70 | + } else { |
|
71 | + // Cannot determine the latest version |
|
72 | + list($latest_version, , $download_url) = explode('|', '||'); |
|
73 | + } |
|
74 | 74 | |
75 | 75 | // Users statistics |
76 | 76 | $warnusers = 0; |
@@ -213,15 +213,15 @@ discard block |
||
213 | 213 | $html = ' |
214 | 214 | <div class="form-group"> |
215 | 215 | <label class="control-label col-sm-3"> '. |
216 | - I18N::translate('Enable healthcheck emails for') . |
|
217 | - '</label> |
|
216 | + I18N::translate('Enable healthcheck emails for') . |
|
217 | + '</label> |
|
218 | 218 | <div class="col-sm-9">'; |
219 | 219 | |
220 | 220 | foreach(Tree::getAll() as $tree){ |
221 | 221 | if(Auth::isManager($tree)){ |
222 | - $html .= '<div class="form-group row"> |
|
222 | + $html .= '<div class="form-group row"> |
|
223 | 223 | <span class="col-sm-3 control-label">' . |
224 | - $tree->getTitle() . |
|
224 | + $tree->getTitle() . |
|
225 | 225 | '</span> |
226 | 226 | <div class="col-sm-2">'; |
227 | 227 | $html .= FunctionsEdit::editFieldYesNo('HEALTHCHECK_ENABLED_' . $tree->getTreeId(), $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED', 1), 'class="radio-inline"'); |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | $html .= ' <p class="small text-muted">'. |
233 | - I18N::translate('Enable the health check emails for each of the selected trees.') . |
|
234 | - '</p> |
|
233 | + I18N::translate('Enable the health check emails for each of the selected trees.') . |
|
234 | + '</p> |
|
235 | 235 | </div> |
236 | 236 | </div>'; |
237 | 237 |
@@ -24,16 +24,16 @@ |
||
24 | 24 | */ |
25 | 25 | public function upgrade() { |
26 | 26 | Database::exec( |
27 | - 'CREATE TABLE IF NOT EXISTS `##maj_admintasks` ('. |
|
28 | - ' majat_name VARCHAR(32) NOT NULL,'. |
|
29 | - ' majat_status ENUM(\'enabled\',\'disabled\') NOT NULL DEFAULT \'disabled\','. |
|
30 | - ' majat_last_run DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\','. |
|
31 | - ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'. // 0 means error, 1 is success |
|
32 | - ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'. // In min, Default every week |
|
33 | - ' majat_nb_occur SMALLINT NOT NULL DEFAULT 0,'. |
|
34 | - ' majat_running TINYINT(1) NOT NULL DEFAULT 0,'. |
|
35 | - ' PRIMARY KEY (majat_name)'. |
|
36 | - ') COLLATE utf8_unicode_ci ENGINE=InnoDB' |
|
27 | + 'CREATE TABLE IF NOT EXISTS `##maj_admintasks` ('. |
|
28 | + ' majat_name VARCHAR(32) NOT NULL,'. |
|
29 | + ' majat_status ENUM(\'enabled\',\'disabled\') NOT NULL DEFAULT \'disabled\','. |
|
30 | + ' majat_last_run DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\','. |
|
31 | + ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'. // 0 means error, 1 is success |
|
32 | + ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'. // In min, Default every week |
|
33 | + ' majat_nb_occur SMALLINT NOT NULL DEFAULT 0,'. |
|
34 | + ' majat_running TINYINT(1) NOT NULL DEFAULT 0,'. |
|
35 | + ' PRIMARY KEY (majat_name)'. |
|
36 | + ') COLLATE utf8_unicode_ci ENGINE=InnoDB' |
|
37 | 37 | ); |
38 | 38 | } |
39 | 39 | } |
@@ -24,89 +24,89 @@ discard block |
||
24 | 24 | * {@inhericDoc} |
25 | 25 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
26 | 26 | */ |
27 | - protected function renderContent() { |
|
27 | + protected function renderContent() { |
|
28 | 28 | |
29 | - $max_details_gen = $this->data->get('max_details_gen'); |
|
30 | - $analysis_level = $this->data->get('analysis_level'); |
|
31 | - $results_by_gen = $this->data->get('results_by_generations'); |
|
32 | - $display_all_places = $this->data->get('display_all_places', true); |
|
29 | + $max_details_gen = $this->data->get('max_details_gen'); |
|
30 | + $analysis_level = $this->data->get('analysis_level'); |
|
31 | + $results_by_gen = $this->data->get('results_by_generations'); |
|
32 | + $display_all_places = $this->data->get('display_all_places', true); |
|
33 | 33 | |
34 | - $html = |
|
35 | - '<div id="geodispersion_gen"> |
|
34 | + $html = |
|
35 | + '<div id="geodispersion_gen"> |
|
36 | 36 | <table id="geodispersion_gentable" class="center">'; |
37 | 37 | |
38 | - foreach($results_by_gen as $gen => $genData){ |
|
39 | - $html .= |
|
40 | - '<tr> |
|
38 | + foreach($results_by_gen as $gen => $genData){ |
|
39 | + $html .= |
|
40 | + '<tr> |
|
41 | 41 | <td class="descriptionbox">' . |
42 | - I18N::translate("Generation %s", I18N::number($gen)). |
|
43 | - ($display_all_places ? '<br />' : ' '). |
|
44 | - I18N::translate('(%s)', I18N::percentage(Functions::safeDivision($genData['sum'] + $genData['other'], $genData['sum'] + $genData['other'] + $genData['unknown']),1)) . |
|
45 | - '</td> |
|
42 | + I18N::translate("Generation %s", I18N::number($gen)). |
|
43 | + ($display_all_places ? '<br />' : ' '). |
|
44 | + I18N::translate('(%s)', I18N::percentage(Functions::safeDivision($genData['sum'] + $genData['other'], $genData['sum'] + $genData['other'] + $genData['unknown']),1)) . |
|
45 | + '</td> |
|
46 | 46 | <td class="optionbox left">'. |
47 | - ($display_all_places ? |
|
48 | - $this->htmlGenerationAllPlacesRow($genData, $analysis_level) : |
|
49 | - $this->htmlGenerationTopPlacesRow($genData, $analysis_level) |
|
50 | - ) . |
|
51 | - '</ditdv> |
|
47 | + ($display_all_places ? |
|
48 | + $this->htmlGenerationAllPlacesRow($genData, $analysis_level) : |
|
49 | + $this->htmlGenerationTopPlacesRow($genData, $analysis_level) |
|
50 | + ) . |
|
51 | + '</ditdv> |
|
52 | 52 | </tr>'; |
53 | - } |
|
53 | + } |
|
54 | 54 | |
55 | - $html.= |
|
56 | - '</table> |
|
55 | + $html.= |
|
56 | + '</table> |
|
57 | 57 | <div class="left"> |
58 | 58 | <strong>' . I18N::translate('Interpretation help:') . '</strong> |
59 | 59 | <br />'. |
60 | - I18N::translate('<strong>Generation X (yy %%)</strong>: The percentage indicates the number of found places compared to the total number of ancestors in this generation.') . |
|
61 | - '<br />'; |
|
62 | - if(!is_null($max_details_gen) && $max_details_gen == 0){ |
|
63 | - $html .= I18N::translate('<strong><em>Place</em> or <em>Flag</em> aa (bb %%)</strong>: The first number indicates the total number of ancestors born in this place, the percentage relates this count to the total number of found places. No percentage means it is less than 10%%.').'<br />'; |
|
64 | - $html .= I18N::translate('If any, the darker area indicates the number of unknown places within the generation or places outside the analysed area, and its percentage compared to the number of ancestors. No percentage means it is less than 10%%.'); |
|
65 | - } |
|
66 | - else{ |
|
67 | - $html .= I18N::translate('<strong><em>Place</em> [aa - bb %%]</strong>: The first number indicates the total number of ancestors born in this place, the percentage compares this count to the total number of found places.').'<br />'; |
|
68 | - $html .= I18N::translate('Only the %d more frequent places for each generation are displayed.', $max_details_gen); |
|
69 | - } |
|
70 | - $html.= |
|
71 | - '</div> |
|
60 | + I18N::translate('<strong>Generation X (yy %%)</strong>: The percentage indicates the number of found places compared to the total number of ancestors in this generation.') . |
|
61 | + '<br />'; |
|
62 | + if(!is_null($max_details_gen) && $max_details_gen == 0){ |
|
63 | + $html .= I18N::translate('<strong><em>Place</em> or <em>Flag</em> aa (bb %%)</strong>: The first number indicates the total number of ancestors born in this place, the percentage relates this count to the total number of found places. No percentage means it is less than 10%%.').'<br />'; |
|
64 | + $html .= I18N::translate('If any, the darker area indicates the number of unknown places within the generation or places outside the analysed area, and its percentage compared to the number of ancestors. No percentage means it is less than 10%%.'); |
|
65 | + } |
|
66 | + else{ |
|
67 | + $html .= I18N::translate('<strong><em>Place</em> [aa - bb %%]</strong>: The first number indicates the total number of ancestors born in this place, the percentage compares this count to the total number of found places.').'<br />'; |
|
68 | + $html .= I18N::translate('Only the %d more frequent places for each generation are displayed.', $max_details_gen); |
|
69 | + } |
|
70 | + $html.= |
|
71 | + '</div> |
|
72 | 72 | </div>'; |
73 | 73 | |
74 | - return $html; |
|
75 | - } |
|
74 | + return $html; |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * Return the HTML code to display a row with all places found in a generation. |
|
80 | - * |
|
81 | - * @param array $data Data array |
|
82 | - * @param int $analysis_level Level of subdivision of analysis |
|
83 | - * @return string HTML code for all places row |
|
84 | - */ |
|
85 | - protected function htmlGenerationAllPlacesRow($data, $analysis_level) { |
|
86 | - $html = |
|
87 | - '<table class="geodispersion_bigrow"> |
|
78 | + /** |
|
79 | + * Return the HTML code to display a row with all places found in a generation. |
|
80 | + * |
|
81 | + * @param array $data Data array |
|
82 | + * @param int $analysis_level Level of subdivision of analysis |
|
83 | + * @return string HTML code for all places row |
|
84 | + */ |
|
85 | + protected function htmlGenerationAllPlacesRow($data, $analysis_level) { |
|
86 | + $html = |
|
87 | + '<table class="geodispersion_bigrow"> |
|
88 | 88 | <tr>'; |
89 | 89 | |
90 | - $sum_gen = $data['sum']; |
|
91 | - $unknownother = $data['unknown'] + $data['other']; |
|
92 | - foreach($data['places'] as $placename=> $dataplace){ |
|
93 | - $levels = array_map('trim',explode(',', $placename)); |
|
94 | - $content = ''; |
|
95 | - if(isset($dataplace['flag'])){ |
|
96 | - $content .= '<td class="geodispersion_flag">'. FunctionsPrint::htmlPlaceIcon($dataplace['place'], $dataplace['flag']) .'</td><td>'; |
|
97 | - } |
|
98 | - else{ |
|
99 | - $content .= '<td><span title="'.implode(I18N::$list_separator, array_reverse($levels)).'">'.$levels[$analysis_level-1].'</span><br/>'; |
|
100 | - } |
|
101 | - $count = $dataplace['count']; |
|
102 | - $content .= I18N::number($count); |
|
103 | - $perc = Functions::safeDivision($count, $sum_gen + $unknownother); |
|
104 | - $perc2= Functions::safeDivision($count, $sum_gen); |
|
105 | - if($perc2>=0.1) |
|
106 | - $content.= '<br/><span class="small">('.I18N::percentage($perc2, 1).')</span>'; |
|
107 | - $content .= '</td>'; |
|
90 | + $sum_gen = $data['sum']; |
|
91 | + $unknownother = $data['unknown'] + $data['other']; |
|
92 | + foreach($data['places'] as $placename=> $dataplace){ |
|
93 | + $levels = array_map('trim',explode(',', $placename)); |
|
94 | + $content = ''; |
|
95 | + if(isset($dataplace['flag'])){ |
|
96 | + $content .= '<td class="geodispersion_flag">'. FunctionsPrint::htmlPlaceIcon($dataplace['place'], $dataplace['flag']) .'</td><td>'; |
|
97 | + } |
|
98 | + else{ |
|
99 | + $content .= '<td><span title="'.implode(I18N::$list_separator, array_reverse($levels)).'">'.$levels[$analysis_level-1].'</span><br/>'; |
|
100 | + } |
|
101 | + $count = $dataplace['count']; |
|
102 | + $content .= I18N::number($count); |
|
103 | + $perc = Functions::safeDivision($count, $sum_gen + $unknownother); |
|
104 | + $perc2= Functions::safeDivision($count, $sum_gen); |
|
105 | + if($perc2>=0.1) |
|
106 | + $content.= '<br/><span class="small">('.I18N::percentage($perc2, 1).')</span>'; |
|
107 | + $content .= '</td>'; |
|
108 | 108 | |
109 | - $html .= ' |
|
109 | + $html .= ' |
|
110 | 110 | <td class="geodispersion_rowitem" width="'.max(round(100*$perc, 0),1).'%"> |
111 | 111 | <table> |
112 | 112 | <tr> |
@@ -118,46 +118,46 @@ discard block |
||
118 | 118 | </tr> |
119 | 119 | </table> |
120 | 120 | </td>'; |
121 | - } |
|
121 | + } |
|
122 | 122 | |
123 | - if($unknownother>0){ |
|
124 | - $perc= Functions::safeDivision($unknownother, $sum_gen + $unknownother); |
|
125 | - $html .='<td class="geodispersion_unknownitem left" >'.I18N::number($unknownother); |
|
126 | - if($perc>=0.1) $html.= '<br/><span class="small">('.I18N::percentage($perc, 1).')</span>'; |
|
127 | - $html .='</td>'; |
|
128 | - } |
|
123 | + if($unknownother>0){ |
|
124 | + $perc= Functions::safeDivision($unknownother, $sum_gen + $unknownother); |
|
125 | + $html .='<td class="geodispersion_unknownitem left" >'.I18N::number($unknownother); |
|
126 | + if($perc>=0.1) $html.= '<br/><span class="small">('.I18N::percentage($perc, 1).')</span>'; |
|
127 | + $html .='</td>'; |
|
128 | + } |
|
129 | 129 | |
130 | - $html .= |
|
131 | - '</tr> |
|
130 | + $html .= |
|
131 | + '</tr> |
|
132 | 132 | </table>'; |
133 | - return $html; |
|
134 | - } |
|
133 | + return $html; |
|
134 | + } |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Returns the HTML code fo display a row of the Top Places found for a generation. |
138 | 138 | * |
139 | 139 | * @param array $data Data array |
140 | - * @param int $analysis_level Level of subdivision of analysis |
|
140 | + * @param int $analysis_level Level of subdivision of analysis |
|
141 | 141 | * @return string HTML code for Top Places row |
142 | 142 | */ |
143 | - protected function htmlGenerationTopPlacesRow($data, $analysis_level) { |
|
144 | - $tmp_places = array(); |
|
145 | - $sum_gen = $data['sum']; |
|
146 | - $other = $data['other']; |
|
143 | + protected function htmlGenerationTopPlacesRow($data, $analysis_level) { |
|
144 | + $tmp_places = array(); |
|
145 | + $sum_gen = $data['sum']; |
|
146 | + $other = $data['other']; |
|
147 | 147 | |
148 | - foreach($data['places'] as $placename => $count) { |
|
149 | - if($placename != 'other'){ |
|
150 | - $levels = array_map('trim',explode(',', $placename)); |
|
151 | - $placename = '<span title="'.implode(I18N::$list_separator, array_reverse($levels)).'">'.$levels[$analysis_level-1].'</span>'; |
|
152 | - } |
|
153 | - else{ |
|
154 | - $placename = I18N::translate('Other places'); |
|
155 | - } |
|
156 | - $tmp_places[] = I18N::translate('<strong>%s</strong> [%d - %s]', $placename, $count, I18N::percentage(Functions::safeDivision($count, $sum_gen + $other), 1)); |
|
157 | - } |
|
148 | + foreach($data['places'] as $placename => $count) { |
|
149 | + if($placename != 'other'){ |
|
150 | + $levels = array_map('trim',explode(',', $placename)); |
|
151 | + $placename = '<span title="'.implode(I18N::$list_separator, array_reverse($levels)).'">'.$levels[$analysis_level-1].'</span>'; |
|
152 | + } |
|
153 | + else{ |
|
154 | + $placename = I18N::translate('Other places'); |
|
155 | + } |
|
156 | + $tmp_places[] = I18N::translate('<strong>%s</strong> [%d - %s]', $placename, $count, I18N::percentage(Functions::safeDivision($count, $sum_gen + $other), 1)); |
|
157 | + } |
|
158 | 158 | |
159 | - return implode(I18N::$list_separator, $tmp_places); |
|
160 | - } |
|
159 | + return implode(I18N::$list_separator, $tmp_places); |
|
160 | + } |
|
161 | 161 | |
162 | 162 | } |
163 | 163 | |
164 | 164 | \ No newline at end of file |
@@ -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 |