@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | * Set the status of a specific admin task. |
33 | 33 | * The status can be enabled (true), or disabled (false). |
34 | 34 | * |
35 | - * @param AbstractTask $ga |
|
36 | 35 | * @param bool $status |
36 | + * @return void |
|
37 | 37 | */ |
38 | 38 | public function setTaskStatus(AbstractTask $task, $status); |
39 | 39 | |
@@ -49,6 +49,7 @@ discard block |
||
49 | 49 | * Delete the task from the database, in a transactional manner. |
50 | 50 | * |
51 | 51 | * @param string $task_name Task to delete |
52 | + * @return boolean |
|
52 | 53 | */ |
53 | 54 | public function deleteTask($task_name); |
54 | 55 | |
@@ -75,7 +76,7 @@ discard block |
||
75 | 76 | * Returns the list of tasks that are currently meant to run. |
76 | 77 | * Tasks to run can be forced, or can be limited to only one. |
77 | 78 | * |
78 | - * @param string|null $force Force the enabled tasks to run. |
|
79 | + * @param boolean $force Force the enabled tasks to run. |
|
79 | 80 | * @param string|null $task_name Name of the specific task to run |
80 | 81 | */ |
81 | 82 | function getTasksToRun($force = false, $task_name = null); |
@@ -37,47 +37,47 @@ |
||
37 | 37 | */ |
38 | 38 | public function setTaskStatus(AbstractTask $task, $status); |
39 | 39 | |
40 | - /** |
|
41 | - * Update an Admin Task in the database. |
|
42 | - * |
|
43 | - * @param AbstractTask $task Task to update |
|
44 | - * @return bool |
|
45 | - */ |
|
46 | - function updateTask(AbstractTask $task); |
|
40 | + /** |
|
41 | + * Update an Admin Task in the database. |
|
42 | + * |
|
43 | + * @param AbstractTask $task Task to update |
|
44 | + * @return bool |
|
45 | + */ |
|
46 | + function updateTask(AbstractTask $task); |
|
47 | 47 | |
48 | - /** |
|
49 | - * Delete the task from the database, in a transactional manner. |
|
50 | - * |
|
51 | - * @param string $task_name Task to delete |
|
52 | - */ |
|
53 | - public function deleteTask($task_name); |
|
48 | + /** |
|
49 | + * Delete the task from the database, in a transactional manner. |
|
50 | + * |
|
51 | + * @param string $task_name Task to delete |
|
52 | + */ |
|
53 | + public function deleteTask($task_name); |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Returns the number of Admin Tasks (active and inactive). |
|
58 | - * |
|
59 | - * @return int |
|
60 | - */ |
|
61 | - public function getTasksCount(); |
|
56 | + /** |
|
57 | + * Returns the number of Admin Tasks (active and inactive). |
|
58 | + * |
|
59 | + * @return int |
|
60 | + */ |
|
61 | + public function getTasksCount(); |
|
62 | 62 | |
63 | - /** |
|
64 | - * Return the list of Admin Tasks matching specified criterias. |
|
65 | - * |
|
66 | - * @param string $search Search criteria in analysis description |
|
67 | - * @param array $order_by Columns to order by |
|
68 | - * @param int $start Offset to start with (for pagination) |
|
69 | - * @param int|null $limit Max number of items to return (for pagination) |
|
70 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
71 | - */ |
|
72 | - function getFilteredTasksList($search = null, $order_by = null, $start = 0, $limit = null); |
|
63 | + /** |
|
64 | + * Return the list of Admin Tasks matching specified criterias. |
|
65 | + * |
|
66 | + * @param string $search Search criteria in analysis description |
|
67 | + * @param array $order_by Columns to order by |
|
68 | + * @param int $start Offset to start with (for pagination) |
|
69 | + * @param int|null $limit Max number of items to return (for pagination) |
|
70 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
71 | + */ |
|
72 | + function getFilteredTasksList($search = null, $order_by = null, $start = 0, $limit = null); |
|
73 | 73 | |
74 | - /** |
|
75 | - * Returns the list of tasks that are currently meant to run. |
|
76 | - * Tasks to run can be forced, or can be limited to only one. |
|
77 | - * |
|
78 | - * @param string|null $force Force the enabled tasks to run. |
|
79 | - * @param string|null $task_name Name of the specific task to run |
|
80 | - */ |
|
74 | + /** |
|
75 | + * Returns the list of tasks that are currently meant to run. |
|
76 | + * Tasks to run can be forced, or can be limited to only one. |
|
77 | + * |
|
78 | + * @param string|null $force Force the enabled tasks to run. |
|
79 | + * @param string|null $task_name Name of the specific task to run |
|
80 | + */ |
|
81 | 81 | function getTasksToRun($force = false, $task_name = null); |
82 | 82 | |
83 | 83 | /** |
@@ -15,7 +15,6 @@ |
||
15 | 15 | use Fisharebest\Webtrees\Controller\PageController; |
16 | 16 | use Fisharebest\Webtrees\Filter; |
17 | 17 | use Fisharebest\Webtrees\FlashMessages; |
18 | -use Fisharebest\Webtrees\Html; |
|
19 | 18 | use Fisharebest\Webtrees\I18N; |
20 | 19 | use Fisharebest\Webtrees\Log; |
21 | 20 | use Fisharebest\Webtrees\Module; |
@@ -35,25 +35,25 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class TaskController extends MvcController |
37 | 37 | { |
38 | - /** |
|
39 | - * Tasks Provider |
|
40 | - * @var TaskProviderInterface $provider |
|
41 | - */ |
|
42 | - protected $provider; |
|
38 | + /** |
|
39 | + * Tasks Provider |
|
40 | + * @var TaskProviderInterface $provider |
|
41 | + */ |
|
42 | + protected $provider; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Constructor for Admin Config controller |
|
46 | - * @param AbstractModule $module |
|
47 | - */ |
|
48 | - public function __construct(AbstractModule $module) { |
|
49 | - parent::__construct($module); |
|
44 | + /** |
|
45 | + * Constructor for Admin Config controller |
|
46 | + * @param AbstractModule $module |
|
47 | + */ |
|
48 | + public function __construct(AbstractModule $module) { |
|
49 | + parent::__construct($module); |
|
50 | 50 | |
51 | - $this->provider = $this->module->getProvider(); |
|
52 | - } |
|
51 | + $this->provider = $this->module->getProvider(); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Pages |
|
56 | - */ |
|
54 | + /** |
|
55 | + * Pages |
|
56 | + */ |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Task@trigger |
@@ -77,35 +77,35 @@ discard block |
||
77 | 77 | /** |
78 | 78 | * Task@setStatus |
79 | 79 | */ |
80 | - public function setStatus() { |
|
81 | - $controller = new JsonController(); |
|
80 | + public function setStatus() { |
|
81 | + $controller = new JsonController(); |
|
82 | 82 | |
83 | - $task_name = Filter::get('task'); |
|
84 | - $task = $this->provider->getTask($task_name, false); |
|
83 | + $task_name = Filter::get('task'); |
|
84 | + $task = $this->provider->getTask($task_name, false); |
|
85 | 85 | |
86 | - $controller->restrictAccess( |
|
87 | - true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
88 | - && Auth::isAdmin() |
|
89 | - && $task |
|
90 | - ); |
|
86 | + $controller->restrictAccess( |
|
87 | + true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
88 | + && Auth::isAdmin() |
|
89 | + && $task |
|
90 | + ); |
|
91 | 91 | |
92 | - $status = Filter::getBool('status'); |
|
93 | - $res = array('task' => $task->getName() , 'error' => null); |
|
94 | - try{ |
|
95 | - $this->provider->setTaskStatus($task, $status); |
|
96 | - $res['status'] = $status; |
|
92 | + $status = Filter::getBool('status'); |
|
93 | + $res = array('task' => $task->getName() , 'error' => null); |
|
94 | + try{ |
|
95 | + $this->provider->setTaskStatus($task, $status); |
|
96 | + $res['status'] = $status; |
|
97 | 97 | Log::addConfigurationLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
98 | - } |
|
99 | - catch (\Exception $ex) { |
|
100 | - $res['error'] = $ex->getMessage(); |
|
98 | + } |
|
99 | + catch (\Exception $ex) { |
|
100 | + $res['error'] = $ex->getMessage(); |
|
101 | 101 | Log::addErrorLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
102 | - } |
|
102 | + } |
|
103 | 103 | |
104 | - $controller->pageHeader(); |
|
105 | - if($res['error']) http_response_code(500); |
|
104 | + $controller->pageHeader(); |
|
105 | + if($res['error']) http_response_code(500); |
|
106 | 106 | |
107 | - echo \Zend_Json::encode($res); |
|
108 | - } |
|
107 | + echo \Zend_Json::encode($res); |
|
108 | + } |
|
109 | 109 | |
110 | 110 | /** |
111 | 111 | * Task@edit |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | public function edit() { |
114 | 114 | global $WT_TREE; |
115 | 115 | |
116 | - $task_name = Filter::get('task'); |
|
117 | - $task = $this->provider->getTask($task_name, false); |
|
116 | + $task_name = Filter::get('task'); |
|
117 | + $task = $this->provider->getTask($task_name, false); |
|
118 | 118 | |
119 | - Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
120 | - $controller = new PageController(); |
|
121 | - $controller |
|
122 | - ->restrictAccess(Auth::isAdmin() && $task) |
|
119 | + Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
120 | + $controller = new PageController(); |
|
121 | + $controller |
|
122 | + ->restrictAccess(Auth::isAdmin() && $task) |
|
123 | 123 | ->setPageTitle(I18N::translate('Edit the administrative task')) |
124 | - ->addInlineJavascript(' |
|
124 | + ->addInlineJavascript(' |
|
125 | 125 | function toggleRemainingOccurrences() { |
126 | 126 | if($("input:radio[name=\'is_limited\']:checked").val() == 1) { |
127 | 127 | $("#nb_occurences").show(); |
@@ -134,39 +134,39 @@ discard block |
||
134 | 134 | $("[name=\'is_limited\']").on("change", toggleRemainingOccurrences); |
135 | 135 | toggleRemainingOccurrences(); |
136 | 136 | ') |
137 | - ; |
|
137 | + ; |
|
138 | 138 | |
139 | 139 | |
140 | - $data = new ViewBag(); |
|
141 | - $data->set('title', $controller->getPageTitle()); |
|
140 | + $data = new ViewBag(); |
|
141 | + $data->set('title', $controller->getPageTitle()); |
|
142 | 142 | $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl()); |
143 | - $data->set('module_title', $this->module->getTitle()); |
|
143 | + $data->set('module_title', $this->module->getTitle()); |
|
144 | 144 | $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@save&ged=' . $WT_TREE->getNameUrl()); |
145 | 145 | $data->set('task', $task); |
146 | 146 | |
147 | - ViewFactory::make('TaskEdit', $this, $controller, $data)->render(); |
|
147 | + ViewFactory::make('TaskEdit', $this, $controller, $data)->render(); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
151 | 151 | * Task@save |
152 | 152 | */ |
153 | 153 | public function save() { |
154 | - $tmp_contrl = new PageController(); |
|
154 | + $tmp_contrl = new PageController(); |
|
155 | 155 | |
156 | - $tmp_contrl->restrictAccess( |
|
157 | - Auth::isAdmin() |
|
158 | - && Filter::checkCsrf() |
|
159 | - ); |
|
156 | + $tmp_contrl->restrictAccess( |
|
157 | + Auth::isAdmin() |
|
158 | + && Filter::checkCsrf() |
|
159 | + ); |
|
160 | 160 | |
161 | 161 | $task_name = Filter::post('task'); |
162 | - $frequency = Filter::postInteger('frequency'); |
|
163 | - $is_limited = Filter::postInteger('is_limited', 0, 1); |
|
164 | - $nb_occur = Filter::postInteger('nb_occur'); |
|
162 | + $frequency = Filter::postInteger('frequency'); |
|
163 | + $is_limited = Filter::postInteger('is_limited', 0, 1); |
|
164 | + $nb_occur = Filter::postInteger('nb_occur'); |
|
165 | 165 | |
166 | 166 | $task = $this->provider->getTask($task_name, false); |
167 | 167 | |
168 | - $success = false; |
|
169 | - if($task) { |
|
168 | + $success = false; |
|
169 | + if($task) { |
|
170 | 170 | $task->setFrequency($frequency); |
171 | 171 | if($is_limited == 1) { |
172 | 172 | $task->setRemainingOccurrences($nb_occur); |
@@ -198,13 +198,13 @@ discard block |
||
198 | 198 | Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'. $task->getName() .'” could not be updated. See error log.'); |
199 | 199 | } |
200 | 200 | |
201 | - } |
|
201 | + } |
|
202 | 202 | |
203 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'; |
|
204 | - if(!$success) { |
|
203 | + $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'; |
|
204 | + if(!$success) { |
|
205 | 205 | $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@edit&task='. $task->getName(); |
206 | - } |
|
207 | - header('Location: ' . WT_BASE_URL . $redirection_url); |
|
206 | + } |
|
207 | + header('Location: ' . WT_BASE_URL . $redirection_url); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | } |
211 | 211 | \ No newline at end of file |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | $tasks = $this->provider->getTasksToRun($token == $token_submitted, $task_name); |
71 | 71 | |
72 | - foreach($tasks as $task) { |
|
72 | + foreach ($tasks as $task) { |
|
73 | 73 | $task->execute(); |
74 | 74 | } |
75 | 75 | } |
@@ -90,19 +90,19 @@ discard block |
||
90 | 90 | ); |
91 | 91 | |
92 | 92 | $status = Filter::getBool('status'); |
93 | - $res = array('task' => $task->getName() , 'error' => null); |
|
94 | - try{ |
|
93 | + $res = array('task' => $task->getName(), 'error' => null); |
|
94 | + try { |
|
95 | 95 | $this->provider->setTaskStatus($task, $status); |
96 | 96 | $res['status'] = $status; |
97 | - Log::addConfigurationLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
|
97 | + Log::addConfigurationLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" has been '.($status ? 'enabled' : 'disabled').'.'); |
|
98 | 98 | } |
99 | 99 | catch (\Exception $ex) { |
100 | 100 | $res['error'] = $ex->getMessage(); |
101 | - Log::addErrorLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
|
101 | + Log::addErrorLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" could not be '.($status ? 'enabled' : 'disabled').'. Error: '.$ex->getMessage()); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | $controller->pageHeader(); |
105 | - if($res['error']) http_response_code(500); |
|
105 | + if ($res['error']) http_response_code(500); |
|
106 | 106 | |
107 | 107 | echo \Zend_Json::encode($res); |
108 | 108 | } |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | |
140 | 140 | $data = new ViewBag(); |
141 | 141 | $data->set('title', $controller->getPageTitle()); |
142 | - $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl()); |
|
142 | + $data->set('admin_config_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig&ged='.$WT_TREE->getNameUrl()); |
|
143 | 143 | $data->set('module_title', $this->module->getTitle()); |
144 | - $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@save&ged=' . $WT_TREE->getNameUrl()); |
|
144 | + $data->set('save_url', 'module.php?mod='.$this->module->getName().'&mod_action=Task@save&ged='.$WT_TREE->getNameUrl()); |
|
145 | 145 | $data->set('task', $task); |
146 | 146 | |
147 | 147 | ViewFactory::make('TaskEdit', $this, $controller, $data)->render(); |
@@ -158,17 +158,17 @@ discard block |
||
158 | 158 | && Filter::checkCsrf() |
159 | 159 | ); |
160 | 160 | |
161 | - $task_name = Filter::post('task'); |
|
162 | - $frequency = Filter::postInteger('frequency'); |
|
163 | - $is_limited = Filter::postInteger('is_limited', 0, 1); |
|
164 | - $nb_occur = Filter::postInteger('nb_occur'); |
|
161 | + $task_name = Filter::post('task'); |
|
162 | + $frequency = Filter::postInteger('frequency'); |
|
163 | + $is_limited = Filter::postInteger('is_limited', 0, 1); |
|
164 | + $nb_occur = Filter::postInteger('nb_occur'); |
|
165 | 165 | |
166 | 166 | $task = $this->provider->getTask($task_name, false); |
167 | 167 | |
168 | 168 | $success = false; |
169 | - if($task) { |
|
169 | + if ($task) { |
|
170 | 170 | $task->setFrequency($frequency); |
171 | - if($is_limited == 1) { |
|
171 | + if ($is_limited == 1) { |
|
172 | 172 | $task->setRemainingOccurrences($nb_occur); |
173 | 173 | } |
174 | 174 | else { |
@@ -177,34 +177,34 @@ discard block |
||
177 | 177 | |
178 | 178 | $res = $task->save(); |
179 | 179 | |
180 | - if($res) { |
|
181 | - if($task instanceof MyArtJaub\Webtrees\Module\AdminTasks\Model\ConfigurableTaskInterface) { |
|
180 | + if ($res) { |
|
181 | + if ($task instanceof MyArtJaub\Webtrees\Module\AdminTasks\Model\ConfigurableTaskInterface) { |
|
182 | 182 | $res = $task->saveConfig(); |
183 | 183 | |
184 | - if(!$res) { |
|
184 | + if (!$res) { |
|
185 | 185 | FlashMessages::addMessage(I18N::translate('An error occured while updating the specific settings of administrative task “%s”', $task->getTitle()), 'danger'); |
186 | - Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'. $task->getName() .'” specific settings could not be updated. See error log.'); |
|
186 | + Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'.$task->getName().'” specific settings could not be updated. See error log.'); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | - if($res) { |
|
190 | + if ($res) { |
|
191 | 191 | FlashMessages::addMessage(I18N::translate('The administrative task “%s” has been successfully updated', $task->getTitle()), 'success'); |
192 | - Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'.$task->getName() .'” has been updated.'); |
|
192 | + Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'.$task->getName().'” has been updated.'); |
|
193 | 193 | $success = true; |
194 | 194 | } |
195 | 195 | } |
196 | 196 | else { |
197 | 197 | FlashMessages::addMessage(I18N::translate('An error occured while updating the administrative task “%s”', $task->getTitle()), 'danger'); |
198 | - Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'. $task->getName() .'” could not be updated. See error log.'); |
|
198 | + Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'.$task->getName().'” could not be updated. See error log.'); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | } |
202 | 202 | |
203 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'; |
|
204 | - if(!$success) { |
|
205 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@edit&task='. $task->getName(); |
|
203 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig'; |
|
204 | + if (!$success) { |
|
205 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=Task@edit&task='.$task->getName(); |
|
206 | 206 | } |
207 | - header('Location: ' . WT_BASE_URL . $redirection_url); |
|
207 | + header('Location: '.WT_BASE_URL.$redirection_url); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | } |
211 | 211 | \ No newline at end of file |
@@ -95,14 +95,15 @@ discard block |
||
95 | 95 | $this->provider->setTaskStatus($task, $status); |
96 | 96 | $res['status'] = $status; |
97 | 97 | Log::addConfigurationLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
98 | - } |
|
99 | - catch (\Exception $ex) { |
|
98 | + } catch (\Exception $ex) { |
|
100 | 99 | $res['error'] = $ex->getMessage(); |
101 | 100 | Log::addErrorLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
102 | 101 | } |
103 | 102 | |
104 | 103 | $controller->pageHeader(); |
105 | - if($res['error']) http_response_code(500); |
|
104 | + if($res['error']) { |
|
105 | + http_response_code(500); |
|
106 | + } |
|
106 | 107 | |
107 | 108 | echo \Zend_Json::encode($res); |
108 | 109 | } |
@@ -170,8 +171,7 @@ discard block |
||
170 | 171 | $task->setFrequency($frequency); |
171 | 172 | if($is_limited == 1) { |
172 | 173 | $task->setRemainingOccurrences($nb_occur); |
173 | - } |
|
174 | - else { |
|
174 | + } else { |
|
175 | 175 | $task->setRemainingOccurrences(0); |
176 | 176 | } |
177 | 177 | |
@@ -192,8 +192,7 @@ discard block |
||
192 | 192 | Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'.$task->getName() .'” has been updated.'); |
193 | 193 | $success = true; |
194 | 194 | } |
195 | - } |
|
196 | - else { |
|
195 | + } else { |
|
197 | 196 | FlashMessages::addMessage(I18N::translate('An error occured while updating the administrative task “%s”', $task->getTitle()), 'danger'); |
198 | 197 | Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'. $task->getName() .'” could not be updated. See error log.'); |
199 | 198 | } |
@@ -13,7 +13,6 @@ |
||
13 | 13 | use Fisharebest\Webtrees\Auth; |
14 | 14 | use Fisharebest\Webtrees\Controller\PageController; |
15 | 15 | use Fisharebest\Webtrees\Filter; |
16 | -use Fisharebest\Webtrees\Html; |
|
17 | 16 | use Fisharebest\Webtrees\I18N; |
18 | 17 | use Fisharebest\Webtrees\Module; |
19 | 18 | use Fisharebest\Webtrees\Module\AbstractModule; |
@@ -33,160 +33,160 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class CertificateController extends MvcController |
35 | 35 | { |
36 | - /** |
|
37 | - * Certificate Provider |
|
38 | - * @var CertificateProviderInterface $provider |
|
39 | - */ |
|
40 | - protected $provider; |
|
36 | + /** |
|
37 | + * Certificate Provider |
|
38 | + * @var CertificateProviderInterface $provider |
|
39 | + */ |
|
40 | + protected $provider; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Constructor for Certificate controller |
|
44 | - * @param AbstractModule $module |
|
45 | - */ |
|
46 | - public function __construct(AbstractModule $module) { |
|
47 | - parent::__construct($module); |
|
48 | - |
|
49 | - $this->provider = $this->module->getProvider(); |
|
50 | - } |
|
42 | + /** |
|
43 | + * Constructor for Certificate controller |
|
44 | + * @param AbstractModule $module |
|
45 | + */ |
|
46 | + public function __construct(AbstractModule $module) { |
|
47 | + parent::__construct($module); |
|
48 | + |
|
49 | + $this->provider = $this->module->getProvider(); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * Pages |
|
55 | - */ |
|
56 | - |
|
57 | - /** |
|
58 | - * Certificate@index |
|
59 | - */ |
|
60 | - public function index() { |
|
61 | - global $WT_TREE; |
|
62 | - |
|
63 | - $controller = new PageController(); |
|
64 | - $controller |
|
65 | - ->setPageTitle(I18N::translate('Certificate')) |
|
66 | - ->restrictAccess( |
|
67 | - $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
68 | - ); |
|
69 | - |
|
70 | - $cid = Filter::get('cid'); |
|
71 | - |
|
72 | - $certificate = null; |
|
73 | - $city = ''; |
|
74 | - if($cid && strlen($cid) > 22){ |
|
75 | - $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
76 | - if($certificate) $city = $certificate->getCity(); |
|
77 | - } |
|
78 | - |
|
79 | - $data = new ViewBag(); |
|
80 | - $data->set('title', $controller->getPageTitle()); |
|
81 | - |
|
82 | - $data->set('has_certif', false); |
|
83 | - if($certificate) { |
|
84 | - $controller->restrictAccess($certificate->canShow()); |
|
85 | - $data->set('title', $certificate->getTitle()); |
|
86 | - $data->set('has_certif', true); |
|
87 | - $data->set('certificate', $certificate); |
|
53 | + /** |
|
54 | + * Pages |
|
55 | + */ |
|
56 | + |
|
57 | + /** |
|
58 | + * Certificate@index |
|
59 | + */ |
|
60 | + public function index() { |
|
61 | + global $WT_TREE; |
|
62 | + |
|
63 | + $controller = new PageController(); |
|
64 | + $controller |
|
65 | + ->setPageTitle(I18N::translate('Certificate')) |
|
66 | + ->restrictAccess( |
|
67 | + $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
68 | + ); |
|
69 | + |
|
70 | + $cid = Filter::get('cid'); |
|
71 | + |
|
72 | + $certificate = null; |
|
73 | + $city = ''; |
|
74 | + if($cid && strlen($cid) > 22){ |
|
75 | + $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
76 | + if($certificate) $city = $certificate->getCity(); |
|
77 | + } |
|
78 | + |
|
79 | + $data = new ViewBag(); |
|
80 | + $data->set('title', $controller->getPageTitle()); |
|
81 | + |
|
82 | + $data->set('has_certif', false); |
|
83 | + if($certificate) { |
|
84 | + $controller->restrictAccess($certificate->canShow()); |
|
85 | + $data->set('title', $certificate->getTitle()); |
|
86 | + $data->set('has_certif', true); |
|
87 | + $data->set('certificate', $certificate); |
|
88 | 88 | |
89 | - $data->set( |
|
90 | - 'url_certif_city', |
|
91 | - 'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . |
|
92 | - '&mod_action=Certificate@listAll' . |
|
93 | - '&ged=' . $WT_TREE->getNameUrl() . |
|
94 | - '&city=' . Functions::encryptToSafeBase64($certificate->getCity()) |
|
95 | - ); |
|
89 | + $data->set( |
|
90 | + 'url_certif_city', |
|
91 | + 'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . |
|
92 | + '&mod_action=Certificate@listAll' . |
|
93 | + '&ged=' . $WT_TREE->getNameUrl() . |
|
94 | + '&city=' . Functions::encryptToSafeBase64($certificate->getCity()) |
|
95 | + ); |
|
96 | 96 | |
97 | - $controller->addInlineJavascript(' |
|
97 | + $controller->addInlineJavascript(' |
|
98 | 98 | jQuery("#certificate-tabs").tabs(); |
99 | 99 | jQuery("#certificate-tabs").css("visibility", "visible"); |
100 | 100 | '); |
101 | 101 | |
102 | - $data->set('has_linked_indis', false); |
|
103 | - $data->set('has_linked_fams', false); |
|
102 | + $data->set('has_linked_indis', false); |
|
103 | + $data->set('has_linked_fams', false); |
|
104 | 104 | |
105 | - $linked_indis = $certificate->linkedIndividuals(); |
|
106 | - $linked_fams = $certificate->linkedFamilies(); |
|
105 | + $linked_indis = $certificate->linkedIndividuals(); |
|
106 | + $linked_fams = $certificate->linkedFamilies(); |
|
107 | 107 | |
108 | - if($linked_indis && count($linked_indis) > 0) { |
|
109 | - $data->set('has_linked_indis', true); |
|
110 | - $data->set('linked_indis', $linked_indis); |
|
111 | - } |
|
108 | + if($linked_indis && count($linked_indis) > 0) { |
|
109 | + $data->set('has_linked_indis', true); |
|
110 | + $data->set('linked_indis', $linked_indis); |
|
111 | + } |
|
112 | 112 | |
113 | - if($linked_fams && count($linked_fams) > 0) { |
|
114 | - $data->set('has_linked_fams', true); |
|
115 | - $data->set('linked_fams', $linked_fams); |
|
116 | - } |
|
117 | - } |
|
118 | - |
|
119 | - ViewFactory::make('Certificate', $this, $controller, $data)->render(); |
|
120 | - } |
|
113 | + if($linked_fams && count($linked_fams) > 0) { |
|
114 | + $data->set('has_linked_fams', true); |
|
115 | + $data->set('linked_fams', $linked_fams); |
|
116 | + } |
|
117 | + } |
|
118 | + |
|
119 | + ViewFactory::make('Certificate', $this, $controller, $data)->render(); |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Certificate@image |
|
124 | - */ |
|
125 | - public function image() { |
|
126 | - global $WT_TREE; |
|
122 | + /** |
|
123 | + * Certificate@image |
|
124 | + */ |
|
125 | + public function image() { |
|
126 | + global $WT_TREE; |
|
127 | 127 | |
128 | - $cid = Filter::get('cid'); |
|
129 | - $certificate = null; |
|
130 | - if($cid) $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
128 | + $cid = Filter::get('cid'); |
|
129 | + $certificate = null; |
|
130 | + if($cid) $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
131 | 131 | |
132 | - $imageBuilder = new ImageBuilder($certificate); |
|
132 | + $imageBuilder = new ImageBuilder($certificate); |
|
133 | 133 | |
134 | - if (Filter::get('cb')) { |
|
135 | - $imageBuilder->setExpireOffset($imageBuilder->getExpireOffset() * 7); |
|
136 | - } |
|
134 | + if (Filter::get('cb')) { |
|
135 | + $imageBuilder->setExpireOffset($imageBuilder->getExpireOffset() * 7); |
|
136 | + } |
|
137 | 137 | |
138 | - $imageBuilder |
|
139 | - ->setShowWatermark(Auth::accessLevel($WT_TREE) >= $this->module->getSetting('MAJ_SHOW_NO_WATERMARK', Auth::PRIV_HIDE)) |
|
140 | - ->setFontMaxSize($this->module->getSetting('MAJ_WM_FONT_MAXSIZE', 18)) |
|
141 | - ->setFontColor($this->module->getSetting('MAJ_WM_FONT_COLOR', '#4D6DF3')) |
|
142 | - ; |
|
138 | + $imageBuilder |
|
139 | + ->setShowWatermark(Auth::accessLevel($WT_TREE) >= $this->module->getSetting('MAJ_SHOW_NO_WATERMARK', Auth::PRIV_HIDE)) |
|
140 | + ->setFontMaxSize($this->module->getSetting('MAJ_WM_FONT_MAXSIZE', 18)) |
|
141 | + ->setFontColor($this->module->getSetting('MAJ_WM_FONT_COLOR', '#4D6DF3')) |
|
142 | + ; |
|
143 | 143 | |
144 | - $imageBuilder->render(); |
|
144 | + $imageBuilder->render(); |
|
145 | 145 | |
146 | - } |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * Certificate@listAll |
|
150 | - */ |
|
151 | - public function listAll() { |
|
152 | - global $WT_TREE; |
|
153 | - |
|
154 | - $controller = new PageController(); |
|
155 | - $controller |
|
156 | - ->setPageTitle(I18N::translate('Certificates')) |
|
157 | - ->restrictAccess( |
|
158 | - $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
159 | - ); |
|
160 | - |
|
161 | - $city = Filter::get('city'); |
|
162 | - |
|
163 | - if($city && strlen($city) > 22){ |
|
164 | - $city = Functions::decryptFromSafeBase64($city); |
|
165 | - $controller->setPageTitle(I18N::translate('Certificates for %s', $city)); |
|
166 | - } |
|
167 | - |
|
168 | - $data = new ViewBag(); |
|
169 | - $data->set('title', $controller->getPageTitle()); |
|
170 | - $data->set('url_module', $this->module->getName()); |
|
171 | - $data->set('url_action', 'Certificate@listAll'); |
|
172 | - $data->set('url_ged', $WT_TREE->getNameUrl()); |
|
173 | - |
|
174 | - $data->set('cities', $this->provider->getCitiesList()); |
|
175 | - $data->set('selected_city', $city); |
|
176 | - |
|
177 | - $data->set('has_list', false); |
|
178 | - if($city) { |
|
179 | - $table_id = 'table-certiflist-' . Uuid::uuid4(); |
|
148 | + /** |
|
149 | + * Certificate@listAll |
|
150 | + */ |
|
151 | + public function listAll() { |
|
152 | + global $WT_TREE; |
|
153 | + |
|
154 | + $controller = new PageController(); |
|
155 | + $controller |
|
156 | + ->setPageTitle(I18N::translate('Certificates')) |
|
157 | + ->restrictAccess( |
|
158 | + $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
159 | + ); |
|
160 | + |
|
161 | + $city = Filter::get('city'); |
|
162 | + |
|
163 | + if($city && strlen($city) > 22){ |
|
164 | + $city = Functions::decryptFromSafeBase64($city); |
|
165 | + $controller->setPageTitle(I18N::translate('Certificates for %s', $city)); |
|
166 | + } |
|
167 | + |
|
168 | + $data = new ViewBag(); |
|
169 | + $data->set('title', $controller->getPageTitle()); |
|
170 | + $data->set('url_module', $this->module->getName()); |
|
171 | + $data->set('url_action', 'Certificate@listAll'); |
|
172 | + $data->set('url_ged', $WT_TREE->getNameUrl()); |
|
173 | + |
|
174 | + $data->set('cities', $this->provider->getCitiesList()); |
|
175 | + $data->set('selected_city', $city); |
|
176 | + |
|
177 | + $data->set('has_list', false); |
|
178 | + if($city) { |
|
179 | + $table_id = 'table-certiflist-' . Uuid::uuid4(); |
|
180 | 180 | |
181 | - $certif_list = $this->provider->getCertificatesList($city); |
|
182 | - if($certif_list) { |
|
183 | - $data->set('has_list', true); |
|
184 | - $data->set('table_id', $table_id); |
|
185 | - $data->set('certificate_list', $certif_list); |
|
181 | + $certif_list = $this->provider->getCertificatesList($city); |
|
182 | + if($certif_list) { |
|
183 | + $data->set('has_list', true); |
|
184 | + $data->set('table_id', $table_id); |
|
185 | + $data->set('certificate_list', $certif_list); |
|
186 | 186 | |
187 | - $controller |
|
188 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
189 | - ->addInlineJavascript(' |
|
187 | + $controller |
|
188 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
189 | + ->addInlineJavascript(' |
|
190 | 190 | /* Initialise datatables */ |
191 | 191 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
192 | 192 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
@@ -213,29 +213,29 @@ discard block |
||
213 | 213 | jQuery(".certificate-list").css("visibility", "visible"); |
214 | 214 | jQuery(".loading-image").css("display", "none"); |
215 | 215 | '); |
216 | - } |
|
217 | - } |
|
216 | + } |
|
217 | + } |
|
218 | 218 | |
219 | - ViewFactory::make('CertificatesList', $this, $controller, $data)->render(); |
|
219 | + ViewFactory::make('CertificatesList', $this, $controller, $data)->render(); |
|
220 | 220 | |
221 | - } |
|
221 | + } |
|
222 | 222 | |
223 | - /** |
|
224 | - * Certificate@autocomplete |
|
225 | - */ |
|
226 | - public function autocomplete() { |
|
227 | - global $WT_TREE; |
|
223 | + /** |
|
224 | + * Certificate@autocomplete |
|
225 | + */ |
|
226 | + public function autocomplete() { |
|
227 | + global $WT_TREE; |
|
228 | 228 | |
229 | - $controller = new JsonController(); |
|
229 | + $controller = new JsonController(); |
|
230 | 230 | |
231 | - $city = Filter::get('city'); |
|
232 | - $contains = Filter::get('term'); |
|
231 | + $city = Filter::get('city'); |
|
232 | + $contains = Filter::get('term'); |
|
233 | 233 | |
234 | - $controller |
|
235 | - ->restrictAccess(Auth::isEditor($WT_TREE) && $city && $contains) |
|
236 | - ->pageHeader(); |
|
234 | + $controller |
|
235 | + ->restrictAccess(Auth::isEditor($WT_TREE) && $city && $contains) |
|
236 | + ->pageHeader(); |
|
237 | 237 | |
238 | - $listCert = $this->provider->getCertificatesListBeginWith($city, $contains); |
|
239 | - echo \Zend_Json::encode($listCert); |
|
240 | - } |
|
238 | + $listCert = $this->provider->getCertificatesListBeginWith($city, $contains); |
|
239 | + echo \Zend_Json::encode($listCert); |
|
240 | + } |
|
241 | 241 | } |
242 | 242 | \ No newline at end of file |
@@ -71,16 +71,16 @@ discard block |
||
71 | 71 | |
72 | 72 | $certificate = null; |
73 | 73 | $city = ''; |
74 | - if($cid && strlen($cid) > 22){ |
|
74 | + if ($cid && strlen($cid) > 22) { |
|
75 | 75 | $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
76 | - if($certificate) $city = $certificate->getCity(); |
|
76 | + if ($certificate) $city = $certificate->getCity(); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $data = new ViewBag(); |
80 | 80 | $data->set('title', $controller->getPageTitle()); |
81 | 81 | |
82 | 82 | $data->set('has_certif', false); |
83 | - if($certificate) { |
|
83 | + if ($certificate) { |
|
84 | 84 | $controller->restrictAccess($certificate->canShow()); |
85 | 85 | $data->set('title', $certificate->getTitle()); |
86 | 86 | $data->set('has_certif', true); |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | |
89 | 89 | $data->set( |
90 | 90 | 'url_certif_city', |
91 | - 'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . |
|
92 | - '&mod_action=Certificate@listAll' . |
|
93 | - '&ged=' . $WT_TREE->getNameUrl() . |
|
94 | - '&city=' . Functions::encryptToSafeBase64($certificate->getCity()) |
|
91 | + 'module.php?mod='.Constants::MODULE_MAJ_CERTIF_NAME. |
|
92 | + '&mod_action=Certificate@listAll'. |
|
93 | + '&ged='.$WT_TREE->getNameUrl(). |
|
94 | + '&city='.Functions::encryptToSafeBase64($certificate->getCity()) |
|
95 | 95 | ); |
96 | 96 | |
97 | 97 | $controller->addInlineJavascript(' |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | $linked_indis = $certificate->linkedIndividuals(); |
106 | 106 | $linked_fams = $certificate->linkedFamilies(); |
107 | 107 | |
108 | - if($linked_indis && count($linked_indis) > 0) { |
|
108 | + if ($linked_indis && count($linked_indis) > 0) { |
|
109 | 109 | $data->set('has_linked_indis', true); |
110 | 110 | $data->set('linked_indis', $linked_indis); |
111 | 111 | } |
112 | 112 | |
113 | - if($linked_fams && count($linked_fams) > 0) { |
|
113 | + if ($linked_fams && count($linked_fams) > 0) { |
|
114 | 114 | $data->set('has_linked_fams', true); |
115 | 115 | $data->set('linked_fams', $linked_fams); |
116 | 116 | } |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | public function image() { |
126 | 126 | global $WT_TREE; |
127 | 127 | |
128 | - $cid = Filter::get('cid'); |
|
128 | + $cid = Filter::get('cid'); |
|
129 | 129 | $certificate = null; |
130 | - if($cid) $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
130 | + if ($cid) $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
131 | 131 | |
132 | 132 | $imageBuilder = new ImageBuilder($certificate); |
133 | 133 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | $city = Filter::get('city'); |
162 | 162 | |
163 | - if($city && strlen($city) > 22){ |
|
163 | + if ($city && strlen($city) > 22) { |
|
164 | 164 | $city = Functions::decryptFromSafeBase64($city); |
165 | 165 | $controller->setPageTitle(I18N::translate('Certificates for %s', $city)); |
166 | 166 | } |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | $data->set('selected_city', $city); |
176 | 176 | |
177 | 177 | $data->set('has_list', false); |
178 | - if($city) { |
|
179 | - $table_id = 'table-certiflist-' . Uuid::uuid4(); |
|
178 | + if ($city) { |
|
179 | + $table_id = 'table-certiflist-'.Uuid::uuid4(); |
|
180 | 180 | |
181 | 181 | $certif_list = $this->provider->getCertificatesList($city); |
182 | - if($certif_list) { |
|
182 | + if ($certif_list) { |
|
183 | 183 | $data->set('has_list', true); |
184 | 184 | $data->set('table_id', $table_id); |
185 | 185 | $data->set('certificate_list', $certif_list); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | jQuery.fn.dataTableExt.oSort["num-html-desc"]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a>b) ? -1 : (a<b ? 1 : 0);}; |
195 | 195 | |
196 | 196 | jQuery("#'.$table_id.'").dataTable( { |
197 | - dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', |
|
197 | + dom: \'<"H"<"filtersH_' . $table_id.'">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\', |
|
198 | 198 | '.I18N::datatablesI18N().', |
199 | 199 | jQueryUI: true, |
200 | 200 | autoWidth: false, |
@@ -73,7 +73,9 @@ discard block |
||
73 | 73 | $city = ''; |
74 | 74 | if($cid && strlen($cid) > 22){ |
75 | 75 | $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
76 | - if($certificate) $city = $certificate->getCity(); |
|
76 | + if($certificate) { |
|
77 | + $city = $certificate->getCity(); |
|
78 | + } |
|
77 | 79 | } |
78 | 80 | |
79 | 81 | $data = new ViewBag(); |
@@ -127,7 +129,9 @@ discard block |
||
127 | 129 | |
128 | 130 | $cid = Filter::get('cid'); |
129 | 131 | $certificate = null; |
130 | - if($cid) $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
132 | + if($cid) { |
|
133 | + $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
134 | + } |
|
131 | 135 | |
132 | 136 | $imageBuilder = new ImageBuilder($certificate); |
133 | 137 |
@@ -109,6 +109,7 @@ discard block |
||
109 | 109 | /** |
110 | 110 | * {@inhericDoc} |
111 | 111 | * @see \Fisharebest\Webtrees\GedcomRecord::getInstance() |
112 | + * @param string $xref |
|
112 | 113 | */ |
113 | 114 | static public function getInstance($xref, Tree $tree, $gedcom = null, CertificateProviderInterface $provider = null) { |
114 | 115 | try{ |
@@ -150,7 +151,7 @@ discard block |
||
150 | 151 | /** |
151 | 152 | * Define a source associated with the certificate |
152 | 153 | * |
153 | - * @param string|Source $xref |
|
154 | + * @param string|null $xref |
|
154 | 155 | */ |
155 | 156 | public function setSource($xref){ |
156 | 157 | if($xref instanceof Source){ |
@@ -15,7 +15,6 @@ |
||
15 | 15 | use Fisharebest\Webtrees\Media; |
16 | 16 | use MyArtJaub\Webtrees\Functions\Functions; |
17 | 17 | use Fisharebest\Webtrees\Date; |
18 | -use Fisharebest\Webtrees\File; |
|
19 | 18 | use Fisharebest\Webtrees\Log; |
20 | 19 | use Fisharebest\Webtrees\Source; |
21 | 20 | use Fisharebest\Webtrees\Tree; |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class Certificate extends Media { |
37 | 37 | |
38 | - const URL_PREFIX = 'module.php?mod=myartjaub_certificates&mod_action=Certificate&cid='; |
|
38 | + const URL_PREFIX = 'module.php?mod=myartjaub_certificates&mod_action=Certificate&cid='; |
|
39 | 39 | |
40 | - /** @var string The "TITL" value from the GEDCOM |
|
41 | - * This is a tweak to overcome the private level from the parent object... |
|
42 | - */ |
|
43 | - protected $title = ''; |
|
40 | + /** @var string The "TITL" value from the GEDCOM |
|
41 | + * This is a tweak to overcome the private level from the parent object... |
|
42 | + */ |
|
43 | + protected $title = ''; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Certificate provider |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param CertificateProviderInterface $provider |
81 | 81 | */ |
82 | 82 | public function __construct($data, Tree $tree, CertificateProviderInterface $provider) { |
83 | - $this->provider = $provider; |
|
83 | + $this->provider = $provider; |
|
84 | 84 | // Data is only the file name |
85 | 85 | $data = str_replace("\\", '/', $data); |
86 | 86 | $xref = Functions::encryptToSafeBase64($data); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @see \Fisharebest\Webtrees\Media::getTitle() |
166 | 166 | */ |
167 | 167 | public function getTitle() { |
168 | - return $this->title; |
|
168 | + return $this->title; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -241,26 +241,26 @@ discard block |
||
241 | 241 | $module = Module::getModuleByName(Constants::MODULE_MAJ_CERTIF_NAME); |
242 | 242 | |
243 | 243 | if($module) { |
244 | - $wmtext = $module->getSetting('MAJ_WM_DEFAULT', I18N::translate('This image is protected under copyright law.')); |
|
245 | - $sid= Filter::get('sid', WT_REGEX_XREF); |
|
244 | + $wmtext = $module->getSetting('MAJ_WM_DEFAULT', I18N::translate('This image is protected under copyright law.')); |
|
245 | + $sid= Filter::get('sid', WT_REGEX_XREF); |
|
246 | 246 | |
247 | - if($sid){ |
|
248 | - $this->source = Source::getInstance($sid, $this->tree); |
|
249 | - } |
|
250 | - else{ |
|
251 | - $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
|
252 | - } |
|
247 | + if($sid){ |
|
248 | + $this->source = Source::getInstance($sid, $this->tree); |
|
249 | + } |
|
250 | + else{ |
|
251 | + $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
|
252 | + } |
|
253 | 253 | |
254 | - if($this->source) { |
|
255 | - $wmtext = '©'; |
|
256 | - $repofact = $this->source->getFirstFact('REPO'); |
|
257 | - if($repofact) { |
|
258 | - $repo = $repofact->getTarget(); |
|
259 | - if($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
260 | - } |
|
261 | - $wmtext .= $this->source->getFullName(); |
|
262 | - } |
|
263 | - return $wmtext; |
|
254 | + if($this->source) { |
|
255 | + $wmtext = '©'; |
|
256 | + $repofact = $this->source->getFirstFact('REPO'); |
|
257 | + if($repofact) { |
|
258 | + $repo = $repofact->getTarget(); |
|
259 | + if($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
260 | + } |
|
261 | + $wmtext .= $this->source->getFullName(); |
|
262 | + } |
|
263 | + return $wmtext; |
|
264 | 264 | } |
265 | 265 | return ''; |
266 | 266 | } |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | ' FROM `##individuals`'. |
324 | 324 | ' WHERE i_file= :gedcom_id AND i_gedcom LIKE :gedcom') |
325 | 325 | ->execute(array( |
326 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
327 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
326 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
327 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
328 | 328 | ))->fetchAll(); |
329 | 329 | |
330 | 330 | $list = array(); |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | ' FROM `##families`'. |
348 | 348 | ' WHERE f_file= :gedcom_id AND f_gedcom LIKE :gedcom') |
349 | 349 | ->execute(array( |
350 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
351 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
350 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
351 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
352 | 352 | ))->fetchAll(); |
353 | 353 | |
354 | 354 | $list = array(); |
@@ -375,25 +375,25 @@ discard block |
||
375 | 375 | 'SELECT i_gedcom AS gedrec FROM `##individuals`'. |
376 | 376 | ' WHERE i_file=:gedcom_id AND i_gedcom LIKE :gedcom') |
377 | 377 | ->execute(array( |
378 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
379 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
378 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
379 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
380 | 380 | ))->fetchOne(); |
381 | 381 | if(!$ged){ |
382 | 382 | $ged = Database::prepare( |
383 | 383 | 'SELECT f_gedcom AS gedrec FROM `##families`'. |
384 | 384 | ' WHERE f_file=:gedcom_id AND f_gedcom LIKE :gedcom') |
385 | - ->execute(array( |
|
386 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
387 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
388 | - ))->fetchOne(); |
|
385 | + ->execute(array( |
|
386 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
387 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
388 | + ))->fetchOne(); |
|
389 | 389 | if(!$ged){ |
390 | 390 | $ged = Database::prepare( |
391 | - 'SELECT o_gedcom AS gedrec FROM `##other`'. |
|
392 | - ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom') |
|
393 | - ->execute(array( |
|
394 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
395 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
396 | - ))->fetchOne(); |
|
391 | + 'SELECT o_gedcom AS gedrec FROM `##other`'. |
|
392 | + ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom') |
|
393 | + ->execute(array( |
|
394 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
395 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
396 | + ))->fetchOne(); |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | //If a record has been found, parse it to find the source reference. |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class Certificate extends Media { |
37 | 37 | |
38 | - const URL_PREFIX = 'module.php?mod=myartjaub_certificates&mod_action=Certificate&cid='; |
|
38 | + const URL_PREFIX = 'module.php?mod=myartjaub_certificates&mod_action=Certificate&cid='; |
|
39 | 39 | |
40 | 40 | /** @var string The "TITL" value from the GEDCOM |
41 | 41 | * This is a tweak to overcome the private level from the parent object... |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | $this->title = basename($this->getFilename(), '.'.$this->extension()); |
95 | 95 | |
96 | 96 | $ct = preg_match("/(?<year>\d{1,4})(\.(?<month>\d{1,2}))?(\.(?<day>\d{1,2}))?( (?<type>[A-Z]{1,2}) )?(?<details>.*)/", $this->title, $match); |
97 | - if($ct > 0){ |
|
98 | - $monthId = (int) $match['month']; |
|
97 | + if ($ct > 0) { |
|
98 | + $monthId = (int)$match['month']; |
|
99 | 99 | $calendarShortMonths = Functions::getCalendarShortMonths(); |
100 | 100 | $monthShortName = array_key_exists($monthId, $calendarShortMonths) ? $calendarShortMonths[$monthId] : $monthId; |
101 | 101 | $this->certDate = new Date($match['day'].' '.strtoupper($monthShortName).' '.$match['year']); |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | * @see \Fisharebest\Webtrees\GedcomRecord::getInstance() |
112 | 112 | */ |
113 | 113 | static public function getInstance($xref, Tree $tree, $gedcom = null, CertificateProviderInterface $provider = null) { |
114 | - try{ |
|
114 | + try { |
|
115 | 115 | $certfile = Functions::decryptFromSafeBase64($xref); |
116 | 116 | |
117 | 117 | //NEED TO CHECK THAT !!! |
118 | - if(Functions::isValidPath($certfile, true)) { |
|
118 | + if (Functions::isValidPath($certfile, true)) { |
|
119 | 119 | return new Certificate($certfile, $tree, $provider); |
120 | 120 | } |
121 | 121 | } |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @param string|Source $xref |
154 | 154 | */ |
155 | - public function setSource($xref){ |
|
156 | - if($xref instanceof Source){ |
|
155 | + public function setSource($xref) { |
|
156 | + if ($xref instanceof Source) { |
|
157 | 157 | $this->source = $data; |
158 | 158 | } else { |
159 | 159 | $this->source = Source::getInstance($xref, $this->tree); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return Date Certificate date |
175 | 175 | */ |
176 | - public function getCertificateDate(){ |
|
176 | + public function getCertificateDate() { |
|
177 | 177 | return $this->certDate; |
178 | 178 | } |
179 | 179 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return string Certificate date |
184 | 184 | */ |
185 | - public function getCertificateType(){ |
|
185 | + public function getCertificateType() { |
|
186 | 186 | return $this->certType; |
187 | 187 | } |
188 | 188 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return string Certificate details |
193 | 193 | */ |
194 | - public function getCertificateDetails(){ |
|
194 | + public function getCertificateDetails() { |
|
195 | 195 | return $this->certDetails; |
196 | 196 | } |
197 | 197 | |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return string|NULL Certificate city |
202 | 202 | */ |
203 | - public function getCity(){ |
|
203 | + public function getCity() { |
|
204 | 204 | $chunks = explode('/', $this->getFilename(), 2); |
205 | - if(count($chunks) > 1) return $chunks[0]; |
|
205 | + if (count($chunks) > 1) return $chunks[0]; |
|
206 | 206 | return null; |
207 | 207 | } |
208 | 208 | |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | * {@inhericDoc} |
211 | 211 | * @see \Fisharebest\Webtrees\Media::getServerFilename() |
212 | 212 | */ |
213 | - public function getServerFilename($which='main') { |
|
214 | - $filename = $this->provider->getRealCertificatesDirectory() . $this->getFilename(); |
|
213 | + public function getServerFilename($which = 'main') { |
|
214 | + $filename = $this->provider->getRealCertificatesDirectory().$this->getFilename(); |
|
215 | 215 | return Functions::encodeUtf8ToFileSystem($filename); |
216 | 216 | } |
217 | 217 | |
@@ -222,11 +222,11 @@ discard block |
||
222 | 222 | public function getHtmlUrlDirect($which = 'main', $download = false) { |
223 | 223 | $sidstr = ($this->source) ? '&sid='.$this->source->getXref() : ''; |
224 | 224 | return |
225 | - 'module.php?mod='. \MyArtJaub\Webtrees\Constants::MODULE_MAJ_CERTIF_NAME . |
|
226 | - '&mod_action=Certificate@image' . |
|
227 | - '&ged='. $this->tree->getNameUrl() . |
|
228 | - '&cid=' . $this->getXref() . $sidstr . |
|
229 | - '&cb=' . $this->getEtag($which); |
|
225 | + 'module.php?mod='.\MyArtJaub\Webtrees\Constants::MODULE_MAJ_CERTIF_NAME. |
|
226 | + '&mod_action=Certificate@image'. |
|
227 | + '&ged='.$this->tree->getNameUrl(). |
|
228 | + '&cid='.$this->getXref().$sidstr. |
|
229 | + '&cb='.$this->getEtag($which); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -237,26 +237,26 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return string Watermark text |
239 | 239 | */ |
240 | - public function getWatermarkText(){ |
|
240 | + public function getWatermarkText() { |
|
241 | 241 | $module = Module::getModuleByName(Constants::MODULE_MAJ_CERTIF_NAME); |
242 | 242 | |
243 | - if($module) { |
|
243 | + if ($module) { |
|
244 | 244 | $wmtext = $module->getSetting('MAJ_WM_DEFAULT', I18N::translate('This image is protected under copyright law.')); |
245 | - $sid= Filter::get('sid', WT_REGEX_XREF); |
|
245 | + $sid = Filter::get('sid', WT_REGEX_XREF); |
|
246 | 246 | |
247 | - if($sid){ |
|
247 | + if ($sid) { |
|
248 | 248 | $this->source = Source::getInstance($sid, $this->tree); |
249 | 249 | } |
250 | - else{ |
|
251 | - $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
|
250 | + else { |
|
251 | + $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
|
252 | 252 | } |
253 | 253 | |
254 | - if($this->source) { |
|
254 | + if ($this->source) { |
|
255 | 255 | $wmtext = '©'; |
256 | 256 | $repofact = $this->source->getFirstFact('REPO'); |
257 | - if($repofact) { |
|
257 | + if ($repofact) { |
|
258 | 258 | $repo = $repofact->getTarget(); |
259 | - if($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
259 | + if ($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
260 | 260 | } |
261 | 261 | $wmtext .= $this->source->getFullName(); |
262 | 262 | } |
@@ -279,45 +279,45 @@ discard block |
||
279 | 279 | '; |
280 | 280 | |
281 | 281 | $script = ''; |
282 | - if($controller && !($controller instanceof IndividualController)){ |
|
282 | + if ($controller && !($controller instanceof IndividualController)) { |
|
283 | 283 | $controller->addInlineJavascript('$(document).ready(function() { '.$js.' });'); |
284 | 284 | } else { |
285 | - $script = '<script>' . $js . '</script>'; |
|
285 | + $script = '<script>'.$js.'</script>'; |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | if ($which == 'icon' || !file_exists($this->getServerFilename())) { |
289 | 289 | // Use an icon |
290 | 290 | $image = |
291 | - '<i dir="auto" class="icon-maj-certificate margin-h-2"' . |
|
292 | - ' title="' . strip_tags($this->getFullName()) . '"' . |
|
291 | + '<i dir="auto" class="icon-maj-certificate margin-h-2"'. |
|
292 | + ' title="'.strip_tags($this->getFullName()).'"'. |
|
293 | 293 | '></i>'; |
294 | 294 | } else { |
295 | 295 | $imgsize = getimagesize($this->getServerFilename()); |
296 | 296 | $image = |
297 | - '<img' . |
|
298 | - ' class ="'. 'certif_image' . '"' . |
|
299 | - ' dir="' . 'auto' . '"' . // For the tool-tip |
|
300 | - ' src="' . $this->getHtmlUrlDirect() . '"' . |
|
301 | - ' alt="' . strip_tags($this->getFullName()) . '"' . |
|
302 | - ' title="' . strip_tags($this->getFullName()) . '"' . |
|
303 | - $imgsize[3] . // height="yyy" width="xxx" |
|
297 | + '<img'. |
|
298 | + ' class ="'.'certif_image'.'"'. |
|
299 | + ' dir="'.'auto'.'"'.// For the tool-tip |
|
300 | + ' src="'.$this->getHtmlUrlDirect().'"'. |
|
301 | + ' alt="'.strip_tags($this->getFullName()).'"'. |
|
302 | + ' title="'.strip_tags($this->getFullName()).'"'. |
|
303 | + $imgsize[3].// height="yyy" width="xxx" |
|
304 | 304 | '>'; |
305 | 305 | } |
306 | 306 | return |
307 | - '<a' . |
|
308 | - ' class="' . 'certgallery' . '"' . |
|
309 | - ' href="' . $this->getHtmlUrlDirect() . '"' . |
|
310 | - ' type="' . $this->mimeType() . '"' . |
|
311 | - ' data-obje-url="' . $this->getHtmlUrl() . '"' . |
|
312 | - ' data-title="' . strip_tags($this->getFullName()) . '"' . |
|
313 | - '>' . $image . '</a>'.$script; |
|
307 | + '<a'. |
|
308 | + ' class="'.'certgallery'.'"'. |
|
309 | + ' href="'.$this->getHtmlUrlDirect().'"'. |
|
310 | + ' type="'.$this->mimeType().'"'. |
|
311 | + ' data-obje-url="'.$this->getHtmlUrl().'"'. |
|
312 | + ' data-title="'.strip_tags($this->getFullName()).'"'. |
|
313 | + '>'.$image.'</a>'.$script; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
317 | 317 | * {@inhericDoc} |
318 | 318 | * @see \Fisharebest\Webtrees\GedcomRecord::linkedIndividuals() |
319 | 319 | */ |
320 | - public function linkedIndividuals($link = '_ACT'){ |
|
320 | + public function linkedIndividuals($link = '_ACT') { |
|
321 | 321 | $rows = Database::prepare( |
322 | 322 | 'SELECT i_id AS xref, i_gedcom AS gedcom'. |
323 | 323 | ' FROM `##individuals`'. |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * {@inhericDoc} |
342 | 342 | * @see \Fisharebest\Webtrees\GedcomRecord::linkedFamilies() |
343 | 343 | */ |
344 | - public function linkedFamilies($link = '_ACT'){ |
|
344 | + public function linkedFamilies($link = '_ACT') { |
|
345 | 345 | $rows = Database::prepare( |
346 | 346 | 'SELECT f_id AS xref, f_gedcom AS gedcom'. |
347 | 347 | ' FROM `##families`'. |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @return Source|NULL Linked source |
368 | 368 | */ |
369 | - public function fetchALinkedSource(){ |
|
369 | + public function fetchALinkedSource() { |
|
370 | 370 | $sid = null; |
371 | 371 | |
372 | 372 | // Try to find in individual, then families, then other types of records. We are interested in the first available value. |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | 'gedcom_id' => $this->tree->getTreeId(), |
379 | 379 | 'gedcom' => '%_ACT '.$this->getFilename().'%' |
380 | 380 | ))->fetchOne(); |
381 | - if(!$ged){ |
|
381 | + if (!$ged) { |
|
382 | 382 | $ged = Database::prepare( |
383 | 383 | 'SELECT f_gedcom AS gedrec FROM `##families`'. |
384 | 384 | ' WHERE f_file=:gedcom_id AND f_gedcom LIKE :gedcom') |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | 'gedcom_id' => $this->tree->getTreeId(), |
387 | 387 | 'gedcom' => '%_ACT '.$this->getFilename().'%' |
388 | 388 | ))->fetchOne(); |
389 | - if(!$ged){ |
|
389 | + if (!$ged) { |
|
390 | 390 | $ged = Database::prepare( |
391 | 391 | 'SELECT o_gedcom AS gedrec FROM `##other`'. |
392 | 392 | ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom') |
@@ -397,28 +397,28 @@ discard block |
||
397 | 397 | } |
398 | 398 | } |
399 | 399 | //If a record has been found, parse it to find the source reference. |
400 | - if($ged){ |
|
400 | + if ($ged) { |
|
401 | 401 | $gedlines = explode("\n", $ged); |
402 | 402 | $level = 0; |
403 | 403 | $levelsource = -1; |
404 | - $sid_tmp=null; |
|
404 | + $sid_tmp = null; |
|
405 | 405 | $sourcefound = false; |
406 | - foreach($gedlines as $gedline){ |
|
406 | + foreach ($gedlines as $gedline) { |
|
407 | 407 | // Get the level |
408 | 408 | if (!$sourcefound && preg_match('~^('.WT_REGEX_INTEGER.') ~', $gedline, $match)) { |
409 | 409 | $level = $match[1]; |
410 | 410 | //If we are not any more within the context of a source, reset |
411 | - if($level <= $levelsource){ |
|
411 | + if ($level <= $levelsource) { |
|
412 | 412 | $levelsource = -1; |
413 | 413 | $sid_tmp = null; |
414 | 414 | } |
415 | 415 | // If a source, get the level and the reference |
416 | 416 | if (preg_match('~^'.$level.' SOUR @('.WT_REGEX_XREF.')@$~', $gedline, $match2)) { |
417 | 417 | $levelsource = $level; |
418 | - $sid_tmp=$match2[1]; |
|
418 | + $sid_tmp = $match2[1]; |
|
419 | 419 | } |
420 | 420 | // If the image has be found, get the source reference and exit. |
421 | - if($levelsource>=0 && $sid_tmp && preg_match('~^'.$level.' _ACT '.preg_quote($this->getFilename()).'~', $gedline, $match3)){ |
|
421 | + if ($levelsource >= 0 && $sid_tmp && preg_match('~^'.$level.' _ACT '.preg_quote($this->getFilename()).'~', $gedline, $match3)) { |
|
422 | 422 | $sid = $sid_tmp; |
423 | 423 | $sourcefound = true; |
424 | 424 | } |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | } |
427 | 427 | } |
428 | 428 | |
429 | - if($sid) $this->source = Source::getInstance($sid, $this->tree); |
|
429 | + if ($sid) $this->source = Source::getInstance($sid, $this->tree); |
|
430 | 430 | |
431 | 431 | return $this->source; |
432 | 432 | } |
@@ -118,8 +118,7 @@ discard block |
||
118 | 118 | if(Functions::isValidPath($certfile, true)) { |
119 | 119 | return new Certificate($certfile, $tree, $provider); |
120 | 120 | } |
121 | - } |
|
122 | - catch (\Exception $ex) { |
|
121 | + } catch (\Exception $ex) { |
|
123 | 122 | Log::addErrorLog('Certificate module error : > '.$ex->getMessage().' < with data > '.$xref.' <'); |
124 | 123 | } |
125 | 124 | |
@@ -202,7 +201,9 @@ discard block |
||
202 | 201 | */ |
203 | 202 | public function getCity(){ |
204 | 203 | $chunks = explode('/', $this->getFilename(), 2); |
205 | - if(count($chunks) > 1) return $chunks[0]; |
|
204 | + if(count($chunks) > 1) { |
|
205 | + return $chunks[0]; |
|
206 | + } |
|
206 | 207 | return null; |
207 | 208 | } |
208 | 209 | |
@@ -246,8 +247,7 @@ discard block |
||
246 | 247 | |
247 | 248 | if($sid){ |
248 | 249 | $this->source = Source::getInstance($sid, $this->tree); |
249 | - } |
|
250 | - else{ |
|
250 | + } else{ |
|
251 | 251 | $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
252 | 252 | } |
253 | 253 | |
@@ -256,7 +256,9 @@ discard block |
||
256 | 256 | $repofact = $this->source->getFirstFact('REPO'); |
257 | 257 | if($repofact) { |
258 | 258 | $repo = $repofact->getTarget(); |
259 | - if($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
259 | + if($repo && $repo instanceof Repository) { |
|
260 | + $wmtext .= ' '.$repo->getFullName().' - '; |
|
261 | + } |
|
260 | 262 | } |
261 | 263 | $wmtext .= $this->source->getFullName(); |
262 | 264 | } |
@@ -426,7 +428,9 @@ discard block |
||
426 | 428 | } |
427 | 429 | } |
428 | 430 | |
429 | - if($sid) $this->source = Source::getInstance($sid, $this->tree); |
|
431 | + if($sid) { |
|
432 | + $this->source = Source::getInstance($sid, $this->tree); |
|
433 | + } |
|
430 | 434 | |
431 | 435 | return $this->source; |
432 | 436 | } |
@@ -252,7 +252,7 @@ |
||
252 | 252 | /** |
253 | 253 | * Return the HTML code for custom simple tag _ACT |
254 | 254 | * |
255 | - * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
|
255 | + * @param Certificate $certificate Certificate (as per the GEDCOM) |
|
256 | 256 | * @param string|null $sid Linked Source ID, if it exists |
257 | 257 | */ |
258 | 258 | protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
@@ -30,140 +30,140 @@ discard block |
||
30 | 30 | * Certificates Module. |
31 | 31 | */ |
32 | 32 | class CertificatesModule |
33 | - extends AbstractModule |
|
34 | - implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtender, CustomSimpleTagManager |
|
33 | + extends AbstractModule |
|
34 | + implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtender, CustomSimpleTagManager |
|
35 | 35 | { |
36 | 36 | |
37 | - /** |
|
38 | - * Provider for Certificates |
|
39 | - * @var CertificateProviderInterface $provider |
|
40 | - */ |
|
41 | - protected $provider; |
|
37 | + /** |
|
38 | + * Provider for Certificates |
|
39 | + * @var CertificateProviderInterface $provider |
|
40 | + */ |
|
41 | + protected $provider; |
|
42 | 42 | |
43 | - /** |
|
44 | - * {@inhericDoc} |
|
45 | - */ |
|
46 | - public function getTitle() { |
|
47 | - return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates'); |
|
48 | - } |
|
43 | + /** |
|
44 | + * {@inhericDoc} |
|
45 | + */ |
|
46 | + public function getTitle() { |
|
47 | + return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates'); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * {@inhericDoc} |
|
52 | - */ |
|
53 | - public function getDescription() { |
|
54 | - return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.'); |
|
55 | - } |
|
50 | + /** |
|
51 | + * {@inhericDoc} |
|
52 | + */ |
|
53 | + public function getDescription() { |
|
54 | + return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.'); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * {@inhericDoc} |
|
59 | - */ |
|
60 | - public function modAction($mod_action) { |
|
61 | - \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
62 | - } |
|
57 | + /** |
|
58 | + * {@inhericDoc} |
|
59 | + */ |
|
60 | + public function modAction($mod_action) { |
|
61 | + \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * {@inhericDoc} |
|
66 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
67 | - */ |
|
68 | - public function getConfigLink() { |
|
69 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
70 | - } |
|
64 | + /** |
|
65 | + * {@inhericDoc} |
|
66 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
67 | + */ |
|
68 | + public function getConfigLink() { |
|
69 | + return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * {@inhericDoc} |
|
74 | - * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
75 | - */ |
|
76 | - public function getSubscribedHooks() { |
|
77 | - return array( |
|
78 | - 'hFactSourcePrepend' => 50, |
|
79 | - 'hGetExpectedTags' => 50, |
|
80 | - 'hHtmlSimpleTagDisplay#_ACT' => 50, |
|
81 | - 'hHtmlSimpleTagEditor#_ACT' => 50, |
|
82 | - 'hAddSimpleTag#SOUR' => 50, |
|
83 | - 'hHasHelpTextTag#_ACT' => 50, |
|
84 | - 'hGetHelpTextTag#_ACT' => 50 |
|
85 | - ); |
|
86 | - } |
|
72 | + /** |
|
73 | + * {@inhericDoc} |
|
74 | + * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
75 | + */ |
|
76 | + public function getSubscribedHooks() { |
|
77 | + return array( |
|
78 | + 'hFactSourcePrepend' => 50, |
|
79 | + 'hGetExpectedTags' => 50, |
|
80 | + 'hHtmlSimpleTagDisplay#_ACT' => 50, |
|
81 | + 'hHtmlSimpleTagEditor#_ACT' => 50, |
|
82 | + 'hAddSimpleTag#SOUR' => 50, |
|
83 | + 'hHasHelpTextTag#_ACT' => 50, |
|
84 | + 'hGetHelpTextTag#_ACT' => 50 |
|
85 | + ); |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * {@inhericDoc} |
|
90 | - * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu() |
|
91 | - */ |
|
92 | - public function getMenu(Tree $tree, $reference = null) { |
|
93 | - $tree_url = $tree ? $tree->getNameUrl() : ''; |
|
94 | - return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow')); |
|
95 | - } |
|
88 | + /** |
|
89 | + * {@inhericDoc} |
|
90 | + * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu() |
|
91 | + */ |
|
92 | + public function getMenu(Tree $tree, $reference = null) { |
|
93 | + $tree_url = $tree ? $tree->getNameUrl() : ''; |
|
94 | + return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow')); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * {@inhericDoc} |
|
99 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtender::hFactSourcePrepend() |
|
100 | - */ |
|
101 | - public function hFactSourcePrepend($srec) { |
|
102 | - global $WT_TREE; |
|
97 | + /** |
|
98 | + * {@inhericDoc} |
|
99 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtender::hFactSourcePrepend() |
|
100 | + */ |
|
101 | + public function hFactSourcePrepend($srec) { |
|
102 | + global $WT_TREE; |
|
103 | 103 | |
104 | - $html=''; |
|
105 | - $sid=null; |
|
104 | + $html=''; |
|
105 | + $sid=null; |
|
106 | 106 | |
107 | - if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){ |
|
108 | - if (!$srec || strlen($srec) == 0) return $html; |
|
107 | + if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){ |
|
108 | + if (!$srec || strlen($srec) == 0) return $html; |
|
109 | 109 | |
110 | - $certificate = null; |
|
111 | - $subrecords = explode("\n", $srec); |
|
112 | - $levelSOUR = substr($subrecords[0], 0, 1); |
|
113 | - if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) { |
|
114 | - $sid=$match[1]; |
|
115 | - }; |
|
116 | - for ($i=0; $i<count($subrecords); $i++) { |
|
117 | - $subrecords[$i] = trim($subrecords[$i]); |
|
118 | - $level = substr($subrecords[$i], 0, 1); |
|
119 | - $tag = substr($subrecords[$i], 2, 4); |
|
120 | - $text = substr($subrecords[$i], 7); |
|
121 | - if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
122 | - } |
|
110 | + $certificate = null; |
|
111 | + $subrecords = explode("\n", $srec); |
|
112 | + $levelSOUR = substr($subrecords[0], 0, 1); |
|
113 | + if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) { |
|
114 | + $sid=$match[1]; |
|
115 | + }; |
|
116 | + for ($i=0; $i<count($subrecords); $i++) { |
|
117 | + $subrecords[$i] = trim($subrecords[$i]); |
|
118 | + $level = substr($subrecords[$i], 0, 1); |
|
119 | + $tag = substr($subrecords[$i], 2, 4); |
|
120 | + $text = substr($subrecords[$i], 7); |
|
121 | + if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
122 | + } |
|
123 | 123 | |
124 | - if($certificate && $certificate->canShow()) |
|
125 | - $html = $this->getDisplay_ACT($certificate, $sid); |
|
124 | + if($certificate && $certificate->canShow()) |
|
125 | + $html = $this->getDisplay_ACT($certificate, $sid); |
|
126 | 126 | |
127 | - } |
|
128 | - return $html; |
|
129 | - } |
|
127 | + } |
|
128 | + return $html; |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * {@inhericDoc} |
|
133 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtender::hFactSourceAppend() |
|
134 | - */ |
|
135 | - public function hFactSourceAppend($srec) { } |
|
131 | + /** |
|
132 | + * {@inhericDoc} |
|
133 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtender::hFactSourceAppend() |
|
134 | + */ |
|
135 | + public function hFactSourceAppend($srec) { } |
|
136 | 136 | |
137 | - /** |
|
138 | - * {@inhericDoc} |
|
139 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManager::hGetExpectedTags() |
|
140 | - */ |
|
141 | - public function hGetExpectedTags() { |
|
142 | - return array('SOUR' => '_ACT'); |
|
143 | - } |
|
137 | + /** |
|
138 | + * {@inhericDoc} |
|
139 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManager::hGetExpectedTags() |
|
140 | + */ |
|
141 | + public function hGetExpectedTags() { |
|
142 | + return array('SOUR' => '_ACT'); |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * {@inhericDoc} |
|
147 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManager::hHtmlSimpleTagDisplay() |
|
148 | - */ |
|
149 | - public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) { |
|
150 | - $html = ''; |
|
151 | - switch($tag){ |
|
152 | - case '_ACT': |
|
153 | - if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
154 | - break; |
|
155 | - } |
|
156 | - return $html; |
|
157 | - } |
|
145 | + /** |
|
146 | + * {@inhericDoc} |
|
147 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManager::hHtmlSimpleTagDisplay() |
|
148 | + */ |
|
149 | + public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) { |
|
150 | + $html = ''; |
|
151 | + switch($tag){ |
|
152 | + case '_ACT': |
|
153 | + if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
154 | + break; |
|
155 | + } |
|
156 | + return $html; |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * {@inhericDoc} |
|
161 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManager::hHtmlSimpleTagEditor() |
|
162 | - */ |
|
163 | - public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) { |
|
164 | - global $controller, $WT_TREE; |
|
159 | + /** |
|
160 | + * {@inhericDoc} |
|
161 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManager::hHtmlSimpleTagEditor() |
|
162 | + */ |
|
163 | + public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) { |
|
164 | + global $controller, $WT_TREE; |
|
165 | 165 | |
166 | - $html = ''; |
|
166 | + $html = ''; |
|
167 | 167 | |
168 | 168 | switch($tag){ |
169 | 169 | case '_ACT': |
@@ -191,78 +191,78 @@ discard block |
||
191 | 191 | } |
192 | 192 | |
193 | 193 | return $html; |
194 | - } |
|
194 | + } |
|
195 | 195 | |
196 | - /** |
|
197 | - * {@inhericDoc} |
|
198 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManager::hAddSimpleTag() |
|
199 | - */ |
|
200 | - public function hAddSimpleTag($context, $level) { |
|
201 | - switch($context){ |
|
202 | - case 'SOUR': |
|
203 | - FunctionsEdit::addSimpleTag($level.' _ACT'); |
|
204 | - break; |
|
205 | - } |
|
206 | - } |
|
196 | + /** |
|
197 | + * {@inhericDoc} |
|
198 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManager::hAddSimpleTag() |
|
199 | + */ |
|
200 | + public function hAddSimpleTag($context, $level) { |
|
201 | + switch($context){ |
|
202 | + case 'SOUR': |
|
203 | + FunctionsEdit::addSimpleTag($level.' _ACT'); |
|
204 | + break; |
|
205 | + } |
|
206 | + } |
|
207 | 207 | |
208 | - /** |
|
209 | - * {@inhericDoc} |
|
210 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManager::hHasHelpTextTag() |
|
211 | - */ |
|
212 | - public function hHasHelpTextTag($tag) { |
|
213 | - switch($tag){ |
|
208 | + /** |
|
209 | + * {@inhericDoc} |
|
210 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManager::hHasHelpTextTag() |
|
211 | + */ |
|
212 | + public function hHasHelpTextTag($tag) { |
|
213 | + switch($tag){ |
|
214 | 214 | case '_ACT': |
215 | 215 | return true; |
216 | 216 | break; |
217 | 217 | } |
218 | 218 | return false; |
219 | - } |
|
219 | + } |
|
220 | 220 | |
221 | - /** |
|
222 | - * {@inhericDoc} |
|
223 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManager::hGetHelpTextTag() |
|
224 | - */ |
|
225 | - public function hGetHelpTextTag($tag) { |
|
226 | - switch($tag){ |
|
227 | - case '_ACT': |
|
228 | - return array( |
|
229 | - I18N::translate('Certificate'), |
|
230 | - '<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>'); |
|
231 | - default: |
|
232 | - return null; |
|
233 | - } |
|
234 | - } |
|
221 | + /** |
|
222 | + * {@inhericDoc} |
|
223 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManager::hGetHelpTextTag() |
|
224 | + */ |
|
225 | + public function hGetHelpTextTag($tag) { |
|
226 | + switch($tag){ |
|
227 | + case '_ACT': |
|
228 | + return array( |
|
229 | + I18N::translate('Certificate'), |
|
230 | + '<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>'); |
|
231 | + default: |
|
232 | + return null; |
|
233 | + } |
|
234 | + } |
|
235 | 235 | |
236 | - /** |
|
237 | - * Returns the default Certificate File Provider, as configured in the module |
|
238 | - * |
|
239 | - * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface |
|
240 | - */ |
|
241 | - public function getProvider() { |
|
242 | - global $WT_TREE; |
|
236 | + /** |
|
237 | + * Returns the default Certificate File Provider, as configured in the module |
|
238 | + * |
|
239 | + * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface |
|
240 | + */ |
|
241 | + public function getProvider() { |
|
242 | + global $WT_TREE; |
|
243 | 243 | |
244 | - if(!$this->provider) { |
|
245 | - $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/'); |
|
246 | - $this->provider = new CertificateFileProvider($root_path, $WT_TREE); |
|
247 | - } |
|
248 | - return $this->provider; |
|
249 | - } |
|
244 | + if(!$this->provider) { |
|
245 | + $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/'); |
|
246 | + $this->provider = new CertificateFileProvider($root_path, $WT_TREE); |
|
247 | + } |
|
248 | + return $this->provider; |
|
249 | + } |
|
250 | 250 | |
251 | 251 | |
252 | - /** |
|
253 | - * Return the HTML code for custom simple tag _ACT |
|
254 | - * |
|
255 | - * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
|
256 | - * @param string|null $sid Linked Source ID, if it exists |
|
257 | - */ |
|
258 | - protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
|
259 | - $html = ''; |
|
260 | - if($certificate){ |
|
261 | - $certificate->setSource($sid); |
|
262 | - $html = $certificate->displayImage('icon'); |
|
263 | - } |
|
264 | - return $html; |
|
265 | - } |
|
252 | + /** |
|
253 | + * Return the HTML code for custom simple tag _ACT |
|
254 | + * |
|
255 | + * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
|
256 | + * @param string|null $sid Linked Source ID, if it exists |
|
257 | + */ |
|
258 | + protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
|
259 | + $html = ''; |
|
260 | + if($certificate){ |
|
261 | + $certificate->setSource($sid); |
|
262 | + $html = $certificate->displayImage('icon'); |
|
263 | + } |
|
264 | + return $html; |
|
265 | + } |
|
266 | 266 | |
267 | 267 | } |
268 | 268 | |
269 | 269 | \ No newline at end of file |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
67 | 67 | */ |
68 | 68 | public function getConfigLink() { |
69 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
69 | + return 'module.php?mod='.$this->getName().'&mod_action=AdminConfig'; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function getMenu(Tree $tree, $reference = null) { |
93 | 93 | $tree_url = $tree ? $tree->getNameUrl() : ''; |
94 | - return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow')); |
|
94 | + return new Menu($this->getTitle(), 'module.php?mod='.$this->getName().'&mod_action=Certificate@listAll&ged='.$tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow')); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,27 +101,27 @@ discard block |
||
101 | 101 | public function hFactSourcePrepend($srec) { |
102 | 102 | global $WT_TREE; |
103 | 103 | |
104 | - $html=''; |
|
105 | - $sid=null; |
|
104 | + $html = ''; |
|
105 | + $sid = null; |
|
106 | 106 | |
107 | - if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){ |
|
107 | + if ($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)) { |
|
108 | 108 | if (!$srec || strlen($srec) == 0) return $html; |
109 | 109 | |
110 | 110 | $certificate = null; |
111 | 111 | $subrecords = explode("\n", $srec); |
112 | 112 | $levelSOUR = substr($subrecords[0], 0, 1); |
113 | 113 | if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) { |
114 | - $sid=$match[1]; |
|
114 | + $sid = $match[1]; |
|
115 | 115 | }; |
116 | - for ($i=0; $i<count($subrecords); $i++) { |
|
116 | + for ($i = 0; $i < count($subrecords); $i++) { |
|
117 | 117 | $subrecords[$i] = trim($subrecords[$i]); |
118 | 118 | $level = substr($subrecords[$i], 0, 1); |
119 | 119 | $tag = substr($subrecords[$i], 2, 4); |
120 | 120 | $text = substr($subrecords[$i], 7); |
121 | - if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
121 | + if ($tag == '_ACT') $certificate = new Certificate($text, $WT_TREE, $this->getProvider()); |
|
122 | 122 | } |
123 | 123 | |
124 | - if($certificate && $certificate->canShow()) |
|
124 | + if ($certificate && $certificate->canShow()) |
|
125 | 125 | $html = $this->getDisplay_ACT($certificate, $sid); |
126 | 126 | |
127 | 127 | } |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) { |
150 | 150 | $html = ''; |
151 | - switch($tag){ |
|
151 | + switch ($tag) { |
|
152 | 152 | case '_ACT': |
153 | - if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
153 | + if ($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
154 | 154 | break; |
155 | 155 | } |
156 | 156 | return $html; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | $html = ''; |
167 | 167 | |
168 | - switch($tag){ |
|
168 | + switch ($tag) { |
|
169 | 169 | case '_ACT': |
170 | 170 | $element_id = Uuid::uuid4(); |
171 | 171 | $controller |
@@ -173,14 +173,14 @@ discard block |
||
173 | 173 | ->addExternalJavascript(WT_STATIC_URL.WT_MODULES_DIR.$this->getName().'/js/autocomplete.js') |
174 | 174 | ->addExternalJavascript(WT_STATIC_URL.WT_MODULES_DIR.$this->getName().'/js/updatecertificatevalues.js'); |
175 | 175 | $certificate = null; |
176 | - if($value){ |
|
176 | + if ($value) { |
|
177 | 177 | $certificate = new Certificate($value, $WT_TREE, $this->getProvider()); |
178 | 178 | } |
179 | 179 | $tabCities = $this->getProvider()->getCitiesList(); |
180 | 180 | $html .= '<select id="certifCity'.$element_id.'" class="_CITY">'; |
181 | - foreach ($tabCities as $cities){ |
|
182 | - $selectedCity=''; |
|
183 | - if($certificate && $cities== $certificate->getCity()) $selectedCity='selected="true"'; |
|
181 | + foreach ($tabCities as $cities) { |
|
182 | + $selectedCity = ''; |
|
183 | + if ($certificate && $cities == $certificate->getCity()) $selectedCity = 'selected="true"'; |
|
184 | 184 | $html .= '<option value="'.$cities.'" '.$selectedCity.' />'.$cities.'</option>'; |
185 | 185 | } |
186 | 186 | $html .= '</select>'; |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManager::hAddSimpleTag() |
199 | 199 | */ |
200 | 200 | public function hAddSimpleTag($context, $level) { |
201 | - switch($context){ |
|
201 | + switch ($context) { |
|
202 | 202 | case 'SOUR': |
203 | 203 | FunctionsEdit::addSimpleTag($level.' _ACT'); |
204 | 204 | break; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManager::hHasHelpTextTag() |
211 | 211 | */ |
212 | 212 | public function hHasHelpTextTag($tag) { |
213 | - switch($tag){ |
|
213 | + switch ($tag) { |
|
214 | 214 | case '_ACT': |
215 | 215 | return true; |
216 | 216 | break; |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManager::hGetHelpTextTag() |
224 | 224 | */ |
225 | 225 | public function hGetHelpTextTag($tag) { |
226 | - switch($tag){ |
|
226 | + switch ($tag) { |
|
227 | 227 | case '_ACT': |
228 | 228 | return array( |
229 | 229 | I18N::translate('Certificate'), |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | public function getProvider() { |
242 | 242 | global $WT_TREE; |
243 | 243 | |
244 | - if(!$this->provider) { |
|
244 | + if (!$this->provider) { |
|
245 | 245 | $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/'); |
246 | 246 | $this->provider = new CertificateFileProvider($root_path, $WT_TREE); |
247 | 247 | } |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
256 | 256 | * @param string|null $sid Linked Source ID, if it exists |
257 | 257 | */ |
258 | - protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
|
258 | + protected function getDisplay_ACT(Certificate $certificate, $sid = null) { |
|
259 | 259 | $html = ''; |
260 | - if($certificate){ |
|
260 | + if ($certificate) { |
|
261 | 261 | $certificate->setSource($sid); |
262 | 262 | $html = $certificate->displayImage('icon'); |
263 | 263 | } |
@@ -105,7 +105,9 @@ discard block |
||
105 | 105 | $sid=null; |
106 | 106 | |
107 | 107 | if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){ |
108 | - if (!$srec || strlen($srec) == 0) return $html; |
|
108 | + if (!$srec || strlen($srec) == 0) { |
|
109 | + return $html; |
|
110 | + } |
|
109 | 111 | |
110 | 112 | $certificate = null; |
111 | 113 | $subrecords = explode("\n", $srec); |
@@ -118,11 +120,14 @@ discard block |
||
118 | 120 | $level = substr($subrecords[$i], 0, 1); |
119 | 121 | $tag = substr($subrecords[$i], 2, 4); |
120 | 122 | $text = substr($subrecords[$i], 7); |
121 | - if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
123 | + if($tag == '_ACT') { |
|
124 | + $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
125 | + } |
|
122 | 126 | } |
123 | 127 | |
124 | - if($certificate && $certificate->canShow()) |
|
125 | - $html = $this->getDisplay_ACT($certificate, $sid); |
|
128 | + if($certificate && $certificate->canShow()) { |
|
129 | + $html = $this->getDisplay_ACT($certificate, $sid); |
|
130 | + } |
|
126 | 131 | |
127 | 132 | } |
128 | 133 | return $html; |
@@ -150,7 +155,9 @@ discard block |
||
150 | 155 | $html = ''; |
151 | 156 | switch($tag){ |
152 | 157 | case '_ACT': |
153 | - if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
158 | + if($context == 'SOUR') { |
|
159 | + $html = $this->getDisplay_ACT($value, $contextid); |
|
160 | + } |
|
154 | 161 | break; |
155 | 162 | } |
156 | 163 | return $html; |
@@ -180,7 +187,9 @@ discard block |
||
180 | 187 | $html .= '<select id="certifCity'.$element_id.'" class="_CITY">'; |
181 | 188 | foreach ($tabCities as $cities){ |
182 | 189 | $selectedCity=''; |
183 | - if($certificate && $cities== $certificate->getCity()) $selectedCity='selected="true"'; |
|
190 | + if($certificate && $cities== $certificate->getCity()) { |
|
191 | + $selectedCity='selected="true"'; |
|
192 | + } |
|
184 | 193 | $html .= '<option value="'.$cities.'" '.$selectedCity.' />'.$cities.'</option>'; |
185 | 194 | } |
186 | 195 | $html .= '</select>'; |
@@ -14,7 +14,6 @@ |
||
14 | 14 | use Fisharebest\Webtrees\Controller\PageController; |
15 | 15 | use Fisharebest\Webtrees\Filter; |
16 | 16 | use Fisharebest\Webtrees\FlashMessages; |
17 | -use Fisharebest\Webtrees\Html; |
|
18 | 17 | use Fisharebest\Webtrees\I18N; |
19 | 18 | use Fisharebest\Webtrees\Log; |
20 | 19 | use Fisharebest\Webtrees\Module; |
@@ -36,59 +36,59 @@ discard block |
||
36 | 36 | */ |
37 | 37 | class AdminConfigController extends MvcController |
38 | 38 | { |
39 | - /** |
|
40 | - * GeoAnalysis Provider |
|
41 | - * @var GeoAnalysisProvider $provider |
|
42 | - */ |
|
43 | - protected $provider; |
|
39 | + /** |
|
40 | + * GeoAnalysis Provider |
|
41 | + * @var GeoAnalysisProvider $provider |
|
42 | + */ |
|
43 | + protected $provider; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Constructor for Admin Config controller |
|
47 | - * @param AbstractModule $module |
|
48 | - */ |
|
49 | - public function __construct(AbstractModule $module) { |
|
50 | - parent::__construct($module); |
|
45 | + /** |
|
46 | + * Constructor for Admin Config controller |
|
47 | + * @param AbstractModule $module |
|
48 | + */ |
|
49 | + public function __construct(AbstractModule $module) { |
|
50 | + parent::__construct($module); |
|
51 | 51 | |
52 | - $this->provider = $this->module->getProvider(); |
|
53 | - } |
|
52 | + $this->provider = $this->module->getProvider(); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Pages |
|
57 | - */ |
|
55 | + /** |
|
56 | + * Pages |
|
57 | + */ |
|
58 | 58 | |
59 | - /** |
|
60 | - * AdminConfig@index |
|
61 | - */ |
|
62 | - public function index() { |
|
63 | - global $WT_TREE; |
|
59 | + /** |
|
60 | + * AdminConfig@index |
|
61 | + */ |
|
62 | + public function index() { |
|
63 | + global $WT_TREE; |
|
64 | 64 | |
65 | - Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
66 | - $controller = new PageController(); |
|
67 | - $controller |
|
68 | - ->restrictAccess(Auth::isManager($WT_TREE)) |
|
69 | - ->setPageTitle($this->module->getTitle()); |
|
65 | + Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
66 | + $controller = new PageController(); |
|
67 | + $controller |
|
68 | + ->restrictAccess(Auth::isManager($WT_TREE)) |
|
69 | + ->setPageTitle($this->module->getTitle()); |
|
70 | 70 | |
71 | - $data = new ViewBag(); |
|
72 | - $data->set('title', $controller->getPageTitle()); |
|
73 | - $data->set('tree', $WT_TREE); |
|
71 | + $data = new ViewBag(); |
|
72 | + $data->set('title', $controller->getPageTitle()); |
|
73 | + $data->set('tree', $WT_TREE); |
|
74 | 74 | |
75 | - $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'); |
|
75 | + $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'); |
|
76 | 76 | |
77 | - $table_id = 'table-geoanalysis-' . Uuid::uuid4(); |
|
78 | - $data->set('table_id', $table_id); |
|
77 | + $table_id = 'table-geoanalysis-' . Uuid::uuid4(); |
|
78 | + $data->set('table_id', $table_id); |
|
79 | 79 | |
80 | - $other_trees = array(); |
|
81 | - foreach (Tree::getAll() as $tree) { |
|
82 | - if($tree->getTreeId() != $WT_TREE->getTreeId()) $other_trees[] = $tree; |
|
83 | - } |
|
84 | - $data->set('other_trees', $other_trees); |
|
80 | + $other_trees = array(); |
|
81 | + foreach (Tree::getAll() as $tree) { |
|
82 | + if($tree->getTreeId() != $WT_TREE->getTreeId()) $other_trees[] = $tree; |
|
83 | + } |
|
84 | + $data->set('other_trees', $other_trees); |
|
85 | 85 | |
86 | - $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
86 | + $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
87 | 87 | |
88 | - $controller |
|
89 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
90 | - ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
91 | - ->addInlineJavascript(' |
|
88 | + $controller |
|
89 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
90 | + ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
91 | + ->addInlineJavascript(' |
|
92 | 92 | //Datatable initialisation |
93 | 93 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
94 | 94 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | }); |
124 | 124 | |
125 | 125 | ') |
126 | - ->addInlineJavascript(' |
|
126 | + ->addInlineJavascript(' |
|
127 | 127 | function set_geoanalysis_status(ga_id, status, gedcom) { |
128 | 128 | jQuery.ajax({ |
129 | 129 | url: "module.php", |
@@ -167,55 +167,55 @@ discard block |
||
167 | 167 | '); |
168 | 168 | |
169 | 169 | |
170 | - ViewFactory::make('AdminConfig', $this, $controller, $data)->render(); |
|
171 | - } |
|
170 | + ViewFactory::make('AdminConfig', $this, $controller, $data)->render(); |
|
171 | + } |
|
172 | 172 | |
173 | - /** |
|
174 | - * AdminConfig@jsonGeoAnalysisList |
|
175 | - */ |
|
176 | - public function jsonGeoAnalysisList() { |
|
177 | - global $WT_TREE; |
|
173 | + /** |
|
174 | + * AdminConfig@jsonGeoAnalysisList |
|
175 | + */ |
|
176 | + public function jsonGeoAnalysisList() { |
|
177 | + global $WT_TREE; |
|
178 | 178 | |
179 | - $controller = new JsonController(); |
|
180 | - $controller |
|
181 | - ->restrictAccess(Auth::isManager($WT_TREE)); |
|
179 | + $controller = new JsonController(); |
|
180 | + $controller |
|
181 | + ->restrictAccess(Auth::isManager($WT_TREE)); |
|
182 | 182 | |
183 | - // Generate an AJAX/JSON response for datatables to load a block of rows |
|
184 | - $search = Filter::postArray('search'); |
|
185 | - if($search) $search = $search['value']; |
|
186 | - $start = Filter::postInteger('start'); |
|
187 | - $length = Filter::postInteger('length'); |
|
188 | - $order = Filter::postArray('order'); |
|
183 | + // Generate an AJAX/JSON response for datatables to load a block of rows |
|
184 | + $search = Filter::postArray('search'); |
|
185 | + if($search) $search = $search['value']; |
|
186 | + $start = Filter::postInteger('start'); |
|
187 | + $length = Filter::postInteger('length'); |
|
188 | + $order = Filter::postArray('order'); |
|
189 | 189 | |
190 | - foreach($order as $key => &$value) { |
|
191 | - switch($value['column']) { |
|
192 | - case 3: |
|
193 | - $value['column'] = 'majgd_descr'; |
|
194 | - break; |
|
195 | - case 5; |
|
196 | - $value['column'] = 'majgd_sublevel'; |
|
197 | - break; |
|
198 | - default: |
|
199 | - unset($order[$key]); |
|
200 | - } |
|
201 | - } |
|
190 | + foreach($order as $key => &$value) { |
|
191 | + switch($value['column']) { |
|
192 | + case 3: |
|
193 | + $value['column'] = 'majgd_descr'; |
|
194 | + break; |
|
195 | + case 5; |
|
196 | + $value['column'] = 'majgd_sublevel'; |
|
197 | + break; |
|
198 | + default: |
|
199 | + unset($order[$key]); |
|
200 | + } |
|
201 | + } |
|
202 | 202 | |
203 | - /** @var GeoAnalysisProvider $provider */ |
|
204 | - $provider = $this->module->getProvider(); |
|
203 | + /** @var GeoAnalysisProvider $provider */ |
|
204 | + $provider = $this->module->getProvider(); |
|
205 | 205 | |
206 | - $list = $provider->getFilteredGeoAnalysisList($search, $order, $start, $length); |
|
207 | - $recordsFiltered = count($list); |
|
208 | - $recordsTotal = $this->provider->getGeoAnalysisCount(); |
|
206 | + $list = $provider->getFilteredGeoAnalysisList($search, $order, $start, $length); |
|
207 | + $recordsFiltered = count($list); |
|
208 | + $recordsTotal = $this->provider->getGeoAnalysisCount(); |
|
209 | 209 | |
210 | - $data = array(); |
|
211 | - $place_hierarchy = $this->provider->getPlacesHierarchy(); |
|
212 | - foreach($list as $ga) { |
|
213 | - /** @var GeoAnalysis $ga */ |
|
210 | + $data = array(); |
|
211 | + $place_hierarchy = $this->provider->getPlacesHierarchy(); |
|
212 | + foreach($list as $ga) { |
|
213 | + /** @var GeoAnalysis $ga */ |
|
214 | 214 | |
215 | - $datum = array(); |
|
216 | - $options= $ga->getOptions(); |
|
215 | + $datum = array(); |
|
216 | + $options= $ga->getOptions(); |
|
217 | 217 | |
218 | - $datum[0] = ' |
|
218 | + $datum[0] = ' |
|
219 | 219 | <div class="btn-group"> |
220 | 220 | <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> |
221 | 221 | <i class="fa fa-pencil"></i><span class="caret"></span> |
@@ -239,108 +239,108 @@ discard block |
||
239 | 239 | </li> |
240 | 240 | </ul> |
241 | 241 | </div>'; |
242 | - $datum[1] = $ga->getId(); |
|
243 | - $datum[2] = $ga->isEnabled() ? |
|
242 | + $datum[1] = $ga->getId(); |
|
243 | + $datum[2] = $ga->isEnabled() ? |
|
244 | 244 | '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : |
245 | 245 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
246 | - $datum[3] = $ga->getTitle(); |
|
247 | - $analysis_level = $ga->getAnalysisLevel(); |
|
248 | - if($place_hierarchy['type'] == 'header') { |
|
249 | - $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1]; |
|
250 | - } else { |
|
251 | - $datum[4] = $analysis_level . '(' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')'; |
|
252 | - } |
|
253 | - $datum[5] = $ga->getAnalysisLevel(); |
|
254 | - $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
255 | - $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
256 | - if($ga->hasMap()) { |
|
257 | - $datum[6] = $options->getMap()->getDescription(); |
|
258 | - $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />'; |
|
259 | - $top_level = $options->getMapLevel(); |
|
260 | - if($place_hierarchy['type'] == 'header') { |
|
261 | - $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1]; |
|
262 | - } else { |
|
263 | - $datum[7] .= $top_level . '(' . $place_hierarchy['hierarchy'][$top_level - 1] . ')'; |
|
264 | - } |
|
265 | - $datum[7] .= '</span>'; |
|
266 | - } |
|
267 | - $datum[8] = $options->isUsingFlags() ? |
|
246 | + $datum[3] = $ga->getTitle(); |
|
247 | + $analysis_level = $ga->getAnalysisLevel(); |
|
248 | + if($place_hierarchy['type'] == 'header') { |
|
249 | + $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1]; |
|
250 | + } else { |
|
251 | + $datum[4] = $analysis_level . '(' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')'; |
|
252 | + } |
|
253 | + $datum[5] = $ga->getAnalysisLevel(); |
|
254 | + $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
255 | + $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
256 | + if($ga->hasMap()) { |
|
257 | + $datum[6] = $options->getMap()->getDescription(); |
|
258 | + $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />'; |
|
259 | + $top_level = $options->getMapLevel(); |
|
260 | + if($place_hierarchy['type'] == 'header') { |
|
261 | + $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1]; |
|
262 | + } else { |
|
263 | + $datum[7] .= $top_level . '(' . $place_hierarchy['hierarchy'][$top_level - 1] . ')'; |
|
264 | + } |
|
265 | + $datum[7] .= '</span>'; |
|
266 | + } |
|
267 | + $datum[8] = $options->isUsingFlags() ? |
|
268 | 268 | '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : |
269 | 269 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; |
270 | - $datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All'); |
|
270 | + $datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All'); |
|
271 | 271 | |
272 | - $data[] = $datum; |
|
273 | - } |
|
272 | + $data[] = $datum; |
|
273 | + } |
|
274 | 274 | |
275 | - $controller->pageHeader(); |
|
275 | + $controller->pageHeader(); |
|
276 | 276 | |
277 | - echo \Zend_Json::encode(array( |
|
278 | - 'draw' => Filter::getInteger('draw'), |
|
279 | - 'recordsTotal' => $recordsTotal, |
|
280 | - 'recordsFiltered' => $recordsFiltered, |
|
281 | - 'data' => $data |
|
282 | - )); |
|
277 | + echo \Zend_Json::encode(array( |
|
278 | + 'draw' => Filter::getInteger('draw'), |
|
279 | + 'recordsTotal' => $recordsTotal, |
|
280 | + 'recordsFiltered' => $recordsFiltered, |
|
281 | + 'data' => $data |
|
282 | + )); |
|
283 | 283 | |
284 | - } |
|
284 | + } |
|
285 | 285 | |
286 | - /** |
|
287 | - * AdminConfig@edit |
|
288 | - */ |
|
289 | - public function edit() { |
|
290 | - $ga_id = Filter::getInteger('ga_id'); |
|
291 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
286 | + /** |
|
287 | + * AdminConfig@edit |
|
288 | + */ |
|
289 | + public function edit() { |
|
290 | + $ga_id = Filter::getInteger('ga_id'); |
|
291 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
292 | 292 | |
293 | - $this->renderEdit($ga); |
|
294 | - } |
|
293 | + $this->renderEdit($ga); |
|
294 | + } |
|
295 | 295 | |
296 | - /** |
|
297 | - * AdminConfig@add |
|
298 | - */ |
|
299 | - public function add() { |
|
300 | - $this->renderEdit(null); |
|
301 | - } |
|
296 | + /** |
|
297 | + * AdminConfig@add |
|
298 | + */ |
|
299 | + public function add() { |
|
300 | + $this->renderEdit(null); |
|
301 | + } |
|
302 | 302 | |
303 | - /** |
|
304 | - * AdminConfig@save |
|
305 | - */ |
|
306 | - public function save() { |
|
307 | - global $WT_TREE; |
|
303 | + /** |
|
304 | + * AdminConfig@save |
|
305 | + */ |
|
306 | + public function save() { |
|
307 | + global $WT_TREE; |
|
308 | 308 | |
309 | - $tmp_contrl = new PageController(); |
|
310 | - $tmp_contrl->restrictAccess( |
|
311 | - Auth::isManager($WT_TREE) |
|
312 | - && Filter::checkCsrf() |
|
313 | - ); |
|
309 | + $tmp_contrl = new PageController(); |
|
310 | + $tmp_contrl->restrictAccess( |
|
311 | + Auth::isManager($WT_TREE) |
|
312 | + && Filter::checkCsrf() |
|
313 | + ); |
|
314 | 314 | |
315 | - $ga_id = Filter::postInteger('ga_id'); |
|
316 | - $description = Filter::post('description'); |
|
317 | - $analysislevel = Filter::postInteger('analysislevel'); |
|
318 | - $use_map = Filter::postBool('use_map'); |
|
319 | - if($use_map) { |
|
320 | - $map_file = base64_decode(Filter::post('map_file')); |
|
321 | - $map_top_level = Filter::postInteger('map_top_level'); |
|
322 | - } |
|
323 | - $use_flags = Filter::postBool('use_flags'); |
|
324 | - $gen_details = Filter::postInteger('gen_details'); |
|
315 | + $ga_id = Filter::postInteger('ga_id'); |
|
316 | + $description = Filter::post('description'); |
|
317 | + $analysislevel = Filter::postInteger('analysislevel'); |
|
318 | + $use_map = Filter::postBool('use_map'); |
|
319 | + if($use_map) { |
|
320 | + $map_file = base64_decode(Filter::post('map_file')); |
|
321 | + $map_top_level = Filter::postInteger('map_top_level'); |
|
322 | + } |
|
323 | + $use_flags = Filter::postBool('use_flags'); |
|
324 | + $gen_details = Filter::postInteger('gen_details'); |
|
325 | 325 | |
326 | - $success = false; |
|
327 | - if($ga_id) { |
|
328 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
329 | - if($ga) { |
|
330 | - $ga->setTitle($description); |
|
331 | - $ga->setAnalysisLevel($analysislevel + 1); |
|
332 | - $options = $ga->getOptions(); |
|
333 | - if($options) { |
|
334 | - $options->setIsUsingFlags($use_flags); |
|
335 | - $options->setMaxDetailsInGen($gen_details); |
|
336 | - if($use_map) { |
|
337 | - $options->setMap(new OutlineMap($map_file)); |
|
338 | - $options->setMapLevel($map_top_level + 1); |
|
339 | - } |
|
340 | - else { |
|
341 | - $options->setMap(null); |
|
342 | - } |
|
343 | - } |
|
326 | + $success = false; |
|
327 | + if($ga_id) { |
|
328 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
329 | + if($ga) { |
|
330 | + $ga->setTitle($description); |
|
331 | + $ga->setAnalysisLevel($analysislevel + 1); |
|
332 | + $options = $ga->getOptions(); |
|
333 | + if($options) { |
|
334 | + $options->setIsUsingFlags($use_flags); |
|
335 | + $options->setMaxDetailsInGen($gen_details); |
|
336 | + if($use_map) { |
|
337 | + $options->setMap(new OutlineMap($map_file)); |
|
338 | + $options->setMapLevel($map_top_level + 1); |
|
339 | + } |
|
340 | + else { |
|
341 | + $options->setMap(null); |
|
342 | + } |
|
343 | + } |
|
344 | 344 | |
345 | 345 | $res = $this->provider->updateGeoAnalysis($ga); |
346 | 346 | if($res) { |
@@ -353,8 +353,8 @@ discard block |
||
353 | 353 | FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger'); |
354 | 354 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.'); |
355 | 355 | } |
356 | - } |
|
357 | - } else { |
|
356 | + } |
|
357 | + } else { |
|
358 | 358 | $ga = $this->provider->createGeoAnalysis( |
359 | 359 | $description, |
360 | 360 | $analysislevel + 1, |
@@ -372,34 +372,34 @@ discard block |
||
372 | 372 | FlashMessages::addMessage(I18N::translate('An error occured while adding the geographical dispersion analysis “%s”', $description), 'danger'); |
373 | 373 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis “'.$description.'” could not be added. See error log.'); |
374 | 374 | } |
375 | - } |
|
375 | + } |
|
376 | 376 | |
377 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl(); |
|
378 | - if(!$success) { |
|
379 | - if($ga) { |
|
380 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $WT_TREE->getNameUrl(); |
|
381 | - } |
|
382 | - else { |
|
383 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $WT_TREE->getNameUrl(); |
|
384 | - } |
|
385 | - } |
|
386 | - header('Location: ' . WT_BASE_URL . $redirection_url); |
|
377 | + $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl(); |
|
378 | + if(!$success) { |
|
379 | + if($ga) { |
|
380 | + $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $WT_TREE->getNameUrl(); |
|
381 | + } |
|
382 | + else { |
|
383 | + $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $WT_TREE->getNameUrl(); |
|
384 | + } |
|
385 | + } |
|
386 | + header('Location: ' . WT_BASE_URL . $redirection_url); |
|
387 | 387 | |
388 | - } |
|
388 | + } |
|
389 | 389 | |
390 | 390 | /** |
391 | 391 | * Renders the edit form, whether it is an edition of an existing GeoAnalysis, or the addition of a new one. |
392 | 392 | * |
393 | 393 | * @param (GeoAnalysis!null) $ga GeoAnalysis to edit |
394 | 394 | */ |
395 | - protected function renderEdit(GeoAnalysis $ga = null) { |
|
396 | - global $WT_TREE; |
|
395 | + protected function renderEdit(GeoAnalysis $ga = null) { |
|
396 | + global $WT_TREE; |
|
397 | 397 | |
398 | - Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
399 | - $controller = new PageController(); |
|
400 | - $controller |
|
401 | - ->restrictAccess(Auth::isManager($WT_TREE)) |
|
402 | - ->addInlineJavascript(' |
|
398 | + Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
399 | + $controller = new PageController(); |
|
400 | + $controller |
|
401 | + ->restrictAccess(Auth::isManager($WT_TREE)) |
|
402 | + ->addInlineJavascript(' |
|
403 | 403 | function toggleMapOptions() { |
404 | 404 | if($("input:radio[name=\'use_map\']:checked").val() == 1) { |
405 | 405 | $("#map_options").show(); |
@@ -413,34 +413,34 @@ discard block |
||
413 | 413 | toggleMapOptions(); |
414 | 414 | '); |
415 | 415 | |
416 | - $data = new ViewBag(); |
|
417 | - if($ga) { |
|
418 | - $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis')); |
|
419 | - $data->set('geo_analysis', $ga); |
|
420 | - } else { |
|
421 | - $controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis')); |
|
422 | - } |
|
416 | + $data = new ViewBag(); |
|
417 | + if($ga) { |
|
418 | + $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis')); |
|
419 | + $data->set('geo_analysis', $ga); |
|
420 | + } else { |
|
421 | + $controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis')); |
|
422 | + } |
|
423 | 423 | |
424 | - $data->set('title', $controller->getPageTitle()); |
|
425 | - $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl()); |
|
426 | - $data->set('module_title', $this->module->getTitle()); |
|
427 | - $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $WT_TREE->getNameUrl()); |
|
428 | - $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
424 | + $data->set('title', $controller->getPageTitle()); |
|
425 | + $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl()); |
|
426 | + $data->set('module_title', $this->module->getTitle()); |
|
427 | + $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $WT_TREE->getNameUrl()); |
|
428 | + $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
429 | 429 | |
430 | - $map_list = array_map( |
|
431 | - function($map) { |
|
432 | - return $map->getDescription(); |
|
433 | - }, |
|
434 | - $this->provider->getOutlineMapsList() |
|
435 | - ); |
|
436 | - asort($map_list); |
|
437 | - $data->set('map_list', $map_list); |
|
430 | + $map_list = array_map( |
|
431 | + function($map) { |
|
432 | + return $map->getDescription(); |
|
433 | + }, |
|
434 | + $this->provider->getOutlineMapsList() |
|
435 | + ); |
|
436 | + asort($map_list); |
|
437 | + $data->set('map_list', $map_list); |
|
438 | 438 | |
439 | - $gen_details = array(0 => I18N::translate('All')); |
|
440 | - for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
441 | - $data->set('generation_details', $gen_details); |
|
439 | + $gen_details = array(0 => I18N::translate('All')); |
|
440 | + for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
441 | + $data->set('generation_details', $gen_details); |
|
442 | 442 | |
443 | - ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |
|
444 | - } |
|
443 | + ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |
|
444 | + } |
|
445 | 445 | |
446 | 446 | } |
447 | 447 | \ No newline at end of file |
@@ -72,14 +72,14 @@ discard block |
||
72 | 72 | $data->set('title', $controller->getPageTitle()); |
73 | 73 | $data->set('tree', $WT_TREE); |
74 | 74 | |
75 | - $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'); |
|
75 | + $data->set('root_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig'); |
|
76 | 76 | |
77 | - $table_id = 'table-geoanalysis-' . Uuid::uuid4(); |
|
77 | + $table_id = 'table-geoanalysis-'.Uuid::uuid4(); |
|
78 | 78 | $data->set('table_id', $table_id); |
79 | 79 | |
80 | 80 | $other_trees = array(); |
81 | 81 | foreach (Tree::getAll() as $tree) { |
82 | - if($tree->getTreeId() != $WT_TREE->getTreeId()) $other_trees[] = $tree; |
|
82 | + if ($tree->getTreeId() != $WT_TREE->getTreeId()) $other_trees[] = $tree; |
|
83 | 83 | } |
84 | 84 | $data->set('other_trees', $other_trees); |
85 | 85 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | processing: true, |
106 | 106 | serverSide : true, |
107 | 107 | ajax : { |
108 | - url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonGeoAnalysisList&ged='. $WT_TREE->getNameUrl().'", |
|
108 | + url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonGeoAnalysisList&ged='.$WT_TREE->getNameUrl().'", |
|
109 | 109 | type : "POST" |
110 | 110 | }, |
111 | 111 | columns: [ |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | url: "module.php", |
130 | 130 | type: "GET", |
131 | 131 | data: { |
132 | - mod: "' . $this->module->getName() .'", |
|
132 | + mod: "' . $this->module->getName().'", |
|
133 | 133 | mod_action: "GeoAnalysis@setStatus", |
134 | 134 | ga_id: ga_id, |
135 | 135 | ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom, |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | }, |
138 | 138 | error: function(result, stat, error) { |
139 | 139 | var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error; |
140 | - alert("' . I18N::translate('An error occured while editing this analysis:') . '" + err); |
|
140 | + alert("' . I18N::translate('An error occured while editing this analysis:').'" + err); |
|
141 | 141 | }, |
142 | 142 | complete: function(result, stat) { |
143 | 143 | geoAnalysisTable.ajax.reload(null, false); |
@@ -150,14 +150,14 @@ discard block |
||
150 | 150 | url: "module.php", |
151 | 151 | type: "GET", |
152 | 152 | data: { |
153 | - mod: "' . $this->module->getName() .'", |
|
153 | + mod: "' . $this->module->getName().'", |
|
154 | 154 | mod_action: "GeoAnalysis@delete", |
155 | 155 | ga_id: ga_id, |
156 | 156 | ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom |
157 | 157 | }, |
158 | 158 | error: function(result, stat, error) { |
159 | 159 | var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error; |
160 | - alert("' . I18N::translate('An error occured while deleting this analysis:') . '" + err); |
|
160 | + alert("' . I18N::translate('An error occured while deleting this analysis:').'" + err); |
|
161 | 161 | }, |
162 | 162 | complete: function(result, stat) { |
163 | 163 | geoAnalysisTable.ajax.reload(null, false); |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | |
183 | 183 | // Generate an AJAX/JSON response for datatables to load a block of rows |
184 | 184 | $search = Filter::postArray('search'); |
185 | - if($search) $search = $search['value']; |
|
185 | + if ($search) $search = $search['value']; |
|
186 | 186 | $start = Filter::postInteger('start'); |
187 | 187 | $length = Filter::postInteger('length'); |
188 | 188 | $order = Filter::postArray('order'); |
189 | 189 | |
190 | - foreach($order as $key => &$value) { |
|
191 | - switch($value['column']) { |
|
190 | + foreach ($order as $key => &$value) { |
|
191 | + switch ($value['column']) { |
|
192 | 192 | case 3: |
193 | 193 | $value['column'] = 'majgd_descr'; |
194 | 194 | break; |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | |
210 | 210 | $data = array(); |
211 | 211 | $place_hierarchy = $this->provider->getPlacesHierarchy(); |
212 | - foreach($list as $ga) { |
|
212 | + foreach ($list as $ga) { |
|
213 | 213 | /** @var GeoAnalysis $ga */ |
214 | 214 | |
215 | 215 | $datum = array(); |
216 | - $options= $ga->getOptions(); |
|
216 | + $options = $ga->getOptions(); |
|
217 | 217 | |
218 | 218 | $datum[0] = ' |
219 | 219 | <div class="btn-group"> |
@@ -223,50 +223,48 @@ discard block |
||
223 | 223 | <ul class="dropdown-menu" role="menu"> |
224 | 224 | <li> |
225 | 225 | <a href="#" onclick="return set_geoanalysis_status('. $ga->getId().', '.($ga->isEnabled() ? 'false' : 'true').', \''.Filter::escapeJs($WT_TREE->getName()).'\');"> |
226 | - <i class="fa fa-fw '.($ga->isEnabled() ? 'fa-times' : 'fa-check').'"></i> ' . ($ga->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')) . ' |
|
226 | + <i class="fa fa-fw '.($ga->isEnabled() ? 'fa-times' : 'fa-check').'"></i> '.($ga->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')).' |
|
227 | 227 | </a> |
228 | 228 | </li> |
229 | 229 | <li> |
230 | 230 | <a href="module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@edit&ga_id='.$ga->getId().'&ged='.$WT_TREE->getName().'"> |
231 | - <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit') . ' |
|
231 | + <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit').' |
|
232 | 232 | </a> |
233 | 233 | </li> |
234 | 234 | <li class="divider" /> |
235 | 235 | <li> |
236 | 236 | <a href="#" onclick="return delete_geoanalysis('. $ga->getId().', \''.Filter::escapeJs($WT_TREE->getName()).'\');"> |
237 | - <i class="fa fa-fw fa-trash-o"></i> ' . I18N::translate('Delete') . ' |
|
237 | + <i class="fa fa-fw fa-trash-o"></i> ' . I18N::translate('Delete').' |
|
238 | 238 | </a> |
239 | 239 | </li> |
240 | 240 | </ul> |
241 | 241 | </div>'; |
242 | 242 | $datum[1] = $ga->getId(); |
243 | 243 | $datum[2] = $ga->isEnabled() ? |
244 | - '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : |
|
245 | - '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
|
244 | + '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
|
246 | 245 | $datum[3] = $ga->getTitle(); |
247 | 246 | $analysis_level = $ga->getAnalysisLevel(); |
248 | - if($place_hierarchy['type'] == 'header') { |
|
247 | + if ($place_hierarchy['type'] == 'header') { |
|
249 | 248 | $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1]; |
250 | 249 | } else { |
251 | - $datum[4] = $analysis_level . '(' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')'; |
|
250 | + $datum[4] = $analysis_level.'('.$place_hierarchy['hierarchy'][$analysis_level - 1].')'; |
|
252 | 251 | } |
253 | 252 | $datum[5] = $ga->getAnalysisLevel(); |
254 | 253 | $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
255 | 254 | $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
256 | - if($ga->hasMap()) { |
|
255 | + if ($ga->hasMap()) { |
|
257 | 256 | $datum[6] = $options->getMap()->getDescription(); |
258 | - $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />'; |
|
257 | + $datum[7] = '<span data-toggle="tooltip" title="'.$options->getMap()->getTopLevelName().'" />'; |
|
259 | 258 | $top_level = $options->getMapLevel(); |
260 | - if($place_hierarchy['type'] == 'header') { |
|
259 | + if ($place_hierarchy['type'] == 'header') { |
|
261 | 260 | $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1]; |
262 | 261 | } else { |
263 | - $datum[7] .= $top_level . '(' . $place_hierarchy['hierarchy'][$top_level - 1] . ')'; |
|
262 | + $datum[7] .= $top_level.'('.$place_hierarchy['hierarchy'][$top_level - 1].')'; |
|
264 | 263 | } |
265 | 264 | $datum[7] .= '</span>'; |
266 | 265 | } |
267 | 266 | $datum[8] = $options->isUsingFlags() ? |
268 | - '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : |
|
269 | - '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; |
|
267 | + '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; |
|
270 | 268 | $datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All'); |
271 | 269 | |
272 | 270 | $data[] = $datum; |
@@ -316,24 +314,24 @@ discard block |
||
316 | 314 | $description = Filter::post('description'); |
317 | 315 | $analysislevel = Filter::postInteger('analysislevel'); |
318 | 316 | $use_map = Filter::postBool('use_map'); |
319 | - if($use_map) { |
|
317 | + if ($use_map) { |
|
320 | 318 | $map_file = base64_decode(Filter::post('map_file')); |
321 | - $map_top_level = Filter::postInteger('map_top_level'); |
|
319 | + $map_top_level = Filter::postInteger('map_top_level'); |
|
322 | 320 | } |
323 | 321 | $use_flags = Filter::postBool('use_flags'); |
324 | 322 | $gen_details = Filter::postInteger('gen_details'); |
325 | 323 | |
326 | 324 | $success = false; |
327 | - if($ga_id) { |
|
325 | + if ($ga_id) { |
|
328 | 326 | $ga = $this->provider->getGeoAnalysis($ga_id, false); |
329 | - if($ga) { |
|
327 | + if ($ga) { |
|
330 | 328 | $ga->setTitle($description); |
331 | 329 | $ga->setAnalysisLevel($analysislevel + 1); |
332 | 330 | $options = $ga->getOptions(); |
333 | - if($options) { |
|
331 | + if ($options) { |
|
334 | 332 | $options->setIsUsingFlags($use_flags); |
335 | 333 | $options->setMaxDetailsInGen($gen_details); |
336 | - if($use_map) { |
|
334 | + if ($use_map) { |
|
337 | 335 | $options->setMap(new OutlineMap($map_file)); |
338 | 336 | $options->setMapLevel($map_top_level + 1); |
339 | 337 | } |
@@ -343,7 +341,7 @@ discard block |
||
343 | 341 | } |
344 | 342 | |
345 | 343 | $res = $this->provider->updateGeoAnalysis($ga); |
346 | - if($res) { |
|
344 | + if ($res) { |
|
347 | 345 | FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully updated', $res->getTitle()), 'success'); |
348 | 346 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$res->getId().'” has been updated.'); |
349 | 347 | $ga = $res; |
@@ -351,7 +349,7 @@ discard block |
||
351 | 349 | } |
352 | 350 | else { |
353 | 351 | FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger'); |
354 | - Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.'); |
|
352 | + Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$ga->getId().'” could not be updated. See error log.'); |
|
355 | 353 | } |
356 | 354 | } |
357 | 355 | } else { |
@@ -363,7 +361,7 @@ discard block |
||
363 | 361 | $use_flags, |
364 | 362 | $gen_details |
365 | 363 | ); |
366 | - if($ga) { |
|
364 | + if ($ga) { |
|
367 | 365 | FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully added.', $ga->getTitle()), 'success'); |
368 | 366 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$ga->getId().'” has been added.'); |
369 | 367 | $success = true; |
@@ -374,16 +372,16 @@ discard block |
||
374 | 372 | } |
375 | 373 | } |
376 | 374 | |
377 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl(); |
|
378 | - if(!$success) { |
|
379 | - if($ga) { |
|
380 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $WT_TREE->getNameUrl(); |
|
375 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig&ged='.$WT_TREE->getNameUrl(); |
|
376 | + if (!$success) { |
|
377 | + if ($ga) { |
|
378 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@edit&ga_id='.$ga->getId().'&ged='.$WT_TREE->getNameUrl(); |
|
381 | 379 | } |
382 | 380 | else { |
383 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $WT_TREE->getNameUrl(); |
|
381 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@add&ged='.$WT_TREE->getNameUrl(); |
|
384 | 382 | } |
385 | 383 | } |
386 | - header('Location: ' . WT_BASE_URL . $redirection_url); |
|
384 | + header('Location: '.WT_BASE_URL.$redirection_url); |
|
387 | 385 | |
388 | 386 | } |
389 | 387 | |
@@ -414,7 +412,7 @@ discard block |
||
414 | 412 | '); |
415 | 413 | |
416 | 414 | $data = new ViewBag(); |
417 | - if($ga) { |
|
415 | + if ($ga) { |
|
418 | 416 | $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis')); |
419 | 417 | $data->set('geo_analysis', $ga); |
420 | 418 | } else { |
@@ -422,9 +420,9 @@ discard block |
||
422 | 420 | } |
423 | 421 | |
424 | 422 | $data->set('title', $controller->getPageTitle()); |
425 | - $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl()); |
|
423 | + $data->set('admin_config_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig&ged='.$WT_TREE->getNameUrl()); |
|
426 | 424 | $data->set('module_title', $this->module->getTitle()); |
427 | - $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $WT_TREE->getNameUrl()); |
|
425 | + $data->set('save_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@save&ged='.$WT_TREE->getNameUrl()); |
|
428 | 426 | $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
429 | 427 | |
430 | 428 | $map_list = array_map( |
@@ -437,7 +435,7 @@ discard block |
||
437 | 435 | $data->set('map_list', $map_list); |
438 | 436 | |
439 | 437 | $gen_details = array(0 => I18N::translate('All')); |
440 | - for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
438 | + for ($i = 1; $i <= 10; $i++) $gen_details[$i] = $i; |
|
441 | 439 | $data->set('generation_details', $gen_details); |
442 | 440 | |
443 | 441 | ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |
@@ -79,7 +79,9 @@ discard block |
||
79 | 79 | |
80 | 80 | $other_trees = array(); |
81 | 81 | foreach (Tree::getAll() as $tree) { |
82 | - if($tree->getTreeId() != $WT_TREE->getTreeId()) $other_trees[] = $tree; |
|
82 | + if($tree->getTreeId() != $WT_TREE->getTreeId()) { |
|
83 | + $other_trees[] = $tree; |
|
84 | + } |
|
83 | 85 | } |
84 | 86 | $data->set('other_trees', $other_trees); |
85 | 87 | |
@@ -182,7 +184,9 @@ discard block |
||
182 | 184 | |
183 | 185 | // Generate an AJAX/JSON response for datatables to load a block of rows |
184 | 186 | $search = Filter::postArray('search'); |
185 | - if($search) $search = $search['value']; |
|
187 | + if($search) { |
|
188 | + $search = $search['value']; |
|
189 | + } |
|
186 | 190 | $start = Filter::postInteger('start'); |
187 | 191 | $length = Filter::postInteger('length'); |
188 | 192 | $order = Filter::postArray('order'); |
@@ -336,8 +340,7 @@ discard block |
||
336 | 340 | if($use_map) { |
337 | 341 | $options->setMap(new OutlineMap($map_file)); |
338 | 342 | $options->setMapLevel($map_top_level + 1); |
339 | - } |
|
340 | - else { |
|
343 | + } else { |
|
341 | 344 | $options->setMap(null); |
342 | 345 | } |
343 | 346 | } |
@@ -348,8 +351,7 @@ discard block |
||
348 | 351 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$res->getId().'” has been updated.'); |
349 | 352 | $ga = $res; |
350 | 353 | $success = true; |
351 | - } |
|
352 | - else { |
|
354 | + } else { |
|
353 | 355 | FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger'); |
354 | 356 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.'); |
355 | 357 | } |
@@ -367,8 +369,7 @@ discard block |
||
367 | 369 | FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully added.', $ga->getTitle()), 'success'); |
368 | 370 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$ga->getId().'” has been added.'); |
369 | 371 | $success = true; |
370 | - } |
|
371 | - else { |
|
372 | + } else { |
|
372 | 373 | FlashMessages::addMessage(I18N::translate('An error occured while adding the geographical dispersion analysis “%s”', $description), 'danger'); |
373 | 374 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis “'.$description.'” could not be added. See error log.'); |
374 | 375 | } |
@@ -378,8 +379,7 @@ discard block |
||
378 | 379 | if(!$success) { |
379 | 380 | if($ga) { |
380 | 381 | $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $WT_TREE->getNameUrl(); |
381 | - } |
|
382 | - else { |
|
382 | + } else { |
|
383 | 383 | $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $WT_TREE->getNameUrl(); |
384 | 384 | } |
385 | 385 | } |
@@ -437,7 +437,9 @@ discard block |
||
437 | 437 | $data->set('map_list', $map_list); |
438 | 438 | |
439 | 439 | $gen_details = array(0 => I18N::translate('All')); |
440 | - for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
440 | + for($i = 1; $i <= 10 ; $i++) { |
|
441 | + $gen_details[$i] = $i; |
|
442 | + } |
|
441 | 443 | $data->set('generation_details', $gen_details); |
442 | 444 | |
443 | 445 | ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |
@@ -14,7 +14,6 @@ |
||
14 | 14 | use Fisharebest\Webtrees\Controller\BaseController; |
15 | 15 | use Fisharebest\Webtrees\Controller\PageController; |
16 | 16 | use Fisharebest\Webtrees\Filter; |
17 | -use Fisharebest\Webtrees\Html; |
|
18 | 17 | use Fisharebest\Webtrees\I18N; |
19 | 18 | use Fisharebest\Webtrees\Log; |
20 | 19 | use Fisharebest\Webtrees\Module; |
@@ -36,47 +36,47 @@ discard block |
||
36 | 36 | */ |
37 | 37 | class GeoAnalysisController extends MvcController |
38 | 38 | { |
39 | - /** |
|
40 | - * GeoAnalysis Provider |
|
41 | - * @var GeoAnalysisProvider $provider |
|
42 | - */ |
|
43 | - protected $provider; |
|
39 | + /** |
|
40 | + * GeoAnalysis Provider |
|
41 | + * @var GeoAnalysisProvider $provider |
|
42 | + */ |
|
43 | + protected $provider; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Constructor for GeoAnalysis controller |
|
47 | - * @param AbstractModule $module |
|
48 | - */ |
|
49 | - public function __construct(AbstractModule $module) { |
|
50 | - parent::__construct($module); |
|
45 | + /** |
|
46 | + * Constructor for GeoAnalysis controller |
|
47 | + * @param AbstractModule $module |
|
48 | + */ |
|
49 | + public function __construct(AbstractModule $module) { |
|
50 | + parent::__construct($module); |
|
51 | 51 | |
52 | - $this->provider = $this->module->getProvider(); |
|
53 | - } |
|
52 | + $this->provider = $this->module->getProvider(); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Pages |
|
57 | - */ |
|
55 | + /** |
|
56 | + * Pages |
|
57 | + */ |
|
58 | 58 | |
59 | - /** |
|
60 | - * GeoAnalysis@index |
|
61 | - */ |
|
62 | - public function index() { |
|
59 | + /** |
|
60 | + * GeoAnalysis@index |
|
61 | + */ |
|
62 | + public function index() { |
|
63 | 63 | |
64 | - $controller = new PageController(); |
|
65 | - $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
64 | + $controller = new PageController(); |
|
65 | + $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
66 | 66 | |
67 | - $data = new ViewBag(); |
|
68 | - $data->set('title', $controller->getPageTitle()); |
|
69 | - $data->set('has_analysis', false); |
|
67 | + $data = new ViewBag(); |
|
68 | + $data->set('title', $controller->getPageTitle()); |
|
69 | + $data->set('has_analysis', false); |
|
70 | 70 | |
71 | - $ga_id = Filter::getInteger('ga_id'); |
|
71 | + $ga_id = Filter::getInteger('ga_id'); |
|
72 | 72 | |
73 | - if($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
74 | - $data->set('has_analysis', true); |
|
75 | - $data->set('geoanalysis', $ga); |
|
73 | + if($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
74 | + $data->set('has_analysis', true); |
|
75 | + $data->set('geoanalysis', $ga); |
|
76 | 76 | |
77 | - $controller |
|
78 | - ->addExternalJavascript(Constants::WT_RAPHAEL_JS_URL()) |
|
79 | - ->addInlineJavascript(' |
|
77 | + $controller |
|
78 | + ->addExternalJavascript(Constants::WT_RAPHAEL_JS_URL()) |
|
79 | + ->addInlineJavascript(' |
|
80 | 80 | jQuery("#geodispersion-tabs").tabs(); |
81 | 81 | jQuery("#geodispersion-tabs").css("visibility", "visible"); |
82 | 82 | |
@@ -97,133 +97,133 @@ discard block |
||
97 | 97 | "json" |
98 | 98 | ); |
99 | 99 | '); |
100 | - } |
|
100 | + } |
|
101 | 101 | |
102 | - ViewFactory::make('GeoAnalysis', $this, $controller, $data)->render(); |
|
103 | - } |
|
102 | + ViewFactory::make('GeoAnalysis', $this, $controller, $data)->render(); |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * GeoAnalysis@listAll |
|
107 | - */ |
|
108 | - public function listAll() { |
|
105 | + /** |
|
106 | + * GeoAnalysis@listAll |
|
107 | + */ |
|
108 | + public function listAll() { |
|
109 | 109 | |
110 | - $controller = new PageController(); |
|
111 | - $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
110 | + $controller = new PageController(); |
|
111 | + $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
112 | 112 | |
113 | - $data = new ViewBag(); |
|
114 | - $data->set('title', $controller->getPageTitle()); |
|
115 | - $data->set('has_list', false); |
|
113 | + $data = new ViewBag(); |
|
114 | + $data->set('title', $controller->getPageTitle()); |
|
115 | + $data->set('has_list', false); |
|
116 | 116 | |
117 | - $ga_list = $this->provider->getGeoAnalysisList(); |
|
118 | - if(count($ga_list) > 0 ) { |
|
119 | - $data->set('has_list', true); |
|
120 | - $data->set('geoanalysislist', $ga_list); |
|
121 | - } |
|
117 | + $ga_list = $this->provider->getGeoAnalysisList(); |
|
118 | + if(count($ga_list) > 0 ) { |
|
119 | + $data->set('has_list', true); |
|
120 | + $data->set('geoanalysislist', $ga_list); |
|
121 | + } |
|
122 | 122 | |
123 | - ViewFactory::make('GeoAnalysisList', $this, $controller, $data)->render(); |
|
124 | - } |
|
123 | + ViewFactory::make('GeoAnalysisList', $this, $controller, $data)->render(); |
|
124 | + } |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * GeoAnalysis@setStatus |
128 | 128 | */ |
129 | - public function setStatus() { |
|
130 | - global $WT_TREE; |
|
129 | + public function setStatus() { |
|
130 | + global $WT_TREE; |
|
131 | 131 | |
132 | - $controller = new JsonController(); |
|
132 | + $controller = new JsonController(); |
|
133 | 133 | |
134 | - $ga_id = Filter::getInteger('ga_id'); |
|
135 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
134 | + $ga_id = Filter::getInteger('ga_id'); |
|
135 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
136 | 136 | |
137 | - $controller->restrictAccess( |
|
138 | - true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
139 | - && Auth::isManager($WT_TREE) |
|
140 | - && $ga |
|
141 | - ); |
|
137 | + $controller->restrictAccess( |
|
138 | + true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
139 | + && Auth::isManager($WT_TREE) |
|
140 | + && $ga |
|
141 | + ); |
|
142 | 142 | |
143 | - $status = Filter::getBool('status'); |
|
144 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
145 | - try{ |
|
146 | - $this->provider->setGeoAnalysisStatus($ga, $status); |
|
147 | - $res['status'] = $status; |
|
143 | + $status = Filter::getBool('status'); |
|
144 | + $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
145 | + try{ |
|
146 | + $this->provider->setGeoAnalysisStatus($ga, $status); |
|
147 | + $res['status'] = $status; |
|
148 | 148 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
149 | - } |
|
150 | - catch (\Exception $ex) { |
|
151 | - $res['error'] = $ex->getMessage(); |
|
149 | + } |
|
150 | + catch (\Exception $ex) { |
|
151 | + $res['error'] = $ex->getMessage(); |
|
152 | 152 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
153 | - } |
|
153 | + } |
|
154 | 154 | |
155 | - $controller->pageHeader(); |
|
156 | - if($res['error']) http_response_code(500); |
|
155 | + $controller->pageHeader(); |
|
156 | + if($res['error']) http_response_code(500); |
|
157 | 157 | |
158 | - echo \Zend_Json::encode($res); |
|
159 | - } |
|
158 | + echo \Zend_Json::encode($res); |
|
159 | + } |
|
160 | 160 | |
161 | 161 | /** |
162 | - * GeoAnalysis@delete |
|
163 | - */ |
|
164 | - public function delete() { |
|
165 | - global $WT_TREE; |
|
162 | + * GeoAnalysis@delete |
|
163 | + */ |
|
164 | + public function delete() { |
|
165 | + global $WT_TREE; |
|
166 | 166 | |
167 | - $controller = new JsonController(); |
|
167 | + $controller = new JsonController(); |
|
168 | 168 | |
169 | - $ga_id = Filter::getInteger('ga_id'); |
|
170 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
169 | + $ga_id = Filter::getInteger('ga_id'); |
|
170 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
171 | 171 | |
172 | - $controller->restrictAccess( |
|
173 | - true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
174 | - && Auth::isManager($WT_TREE) |
|
175 | - && $ga |
|
176 | - ); |
|
172 | + $controller->restrictAccess( |
|
173 | + true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
174 | + && Auth::isManager($WT_TREE) |
|
175 | + && $ga |
|
176 | + ); |
|
177 | 177 | |
178 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
179 | - try{ |
|
180 | - $this->provider->deleteGeoAnalysis($ga); |
|
178 | + $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
179 | + try{ |
|
180 | + $this->provider->deleteGeoAnalysis($ga); |
|
181 | 181 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
182 | - } |
|
183 | - catch (\Exception $ex) { |
|
184 | - $res['error'] = $ex->getMessage(); |
|
182 | + } |
|
183 | + catch (\Exception $ex) { |
|
184 | + $res['error'] = $ex->getMessage(); |
|
185 | 185 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage()); |
186 | - } |
|
186 | + } |
|
187 | 187 | |
188 | - $controller->pageHeader(); |
|
189 | - if($res['error']) http_response_code(500); |
|
188 | + $controller->pageHeader(); |
|
189 | + if($res['error']) http_response_code(500); |
|
190 | 190 | |
191 | - echo \Zend_Json::encode($res); |
|
192 | - } |
|
191 | + echo \Zend_Json::encode($res); |
|
192 | + } |
|
193 | 193 | |
194 | - /** |
|
195 | - * GeoAnalysis@dataTabs |
|
196 | - */ |
|
197 | - public function dataTabs() { |
|
198 | - global $WT_TREE; |
|
194 | + /** |
|
195 | + * GeoAnalysis@dataTabs |
|
196 | + */ |
|
197 | + public function dataTabs() { |
|
198 | + global $WT_TREE; |
|
199 | 199 | |
200 | - $controller = new JsonController(); |
|
200 | + $controller = new JsonController(); |
|
201 | 201 | |
202 | - $ga_id = Filter::getInteger('ga_id'); |
|
203 | - $ga = $this->provider->getGeoAnalysis($ga_id); |
|
204 | - $sosa_provider = new SosaProvider($WT_TREE, Auth::user()); |
|
202 | + $ga_id = Filter::getInteger('ga_id'); |
|
203 | + $ga = $this->provider->getGeoAnalysis($ga_id); |
|
204 | + $sosa_provider = new SosaProvider($WT_TREE, Auth::user()); |
|
205 | 205 | |
206 | - $controller |
|
207 | - ->restrictAccess($ga && $sosa_provider->isSetup()) |
|
208 | - ->pageHeader(); |
|
206 | + $controller |
|
207 | + ->restrictAccess($ga && $sosa_provider->isSetup()) |
|
208 | + ->pageHeader(); |
|
209 | 209 | |
210 | - $jsonArray = array(); |
|
210 | + $jsonArray = array(); |
|
211 | 211 | |
212 | - list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); |
|
212 | + list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); |
|
213 | 213 | |
214 | - $flags = array(); |
|
215 | - if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
216 | - $mapProvider = new GoogleMapsProvider(); |
|
217 | - foreach($placesDispGeneral['places'] as $place => $count) { |
|
218 | - $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $WT_TREE)); |
|
219 | - } |
|
220 | - } |
|
214 | + $flags = array(); |
|
215 | + if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
216 | + $mapProvider = new GoogleMapsProvider(); |
|
217 | + foreach($placesDispGeneral['places'] as $place => $count) { |
|
218 | + $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $WT_TREE)); |
|
219 | + } |
|
220 | + } |
|
221 | 221 | |
222 | - $jsonArray['generaltab'] = $this->htmlPlacesAnalysisGeneralTab($ga, $placesDispGeneral, $flags); |
|
223 | - $jsonArray['generationstab'] = $this->htmlPlacesAnalysisGenerationsTab($ga, $placesDispGenerations, $flags); |
|
222 | + $jsonArray['generaltab'] = $this->htmlPlacesAnalysisGeneralTab($ga, $placesDispGeneral, $flags); |
|
223 | + $jsonArray['generationstab'] = $this->htmlPlacesAnalysisGenerationsTab($ga, $placesDispGenerations, $flags); |
|
224 | 224 | |
225 | - echo \Zend_Json::encode($jsonArray); |
|
226 | - } |
|
225 | + echo \Zend_Json::encode($jsonArray); |
|
226 | + } |
|
227 | 227 | |
228 | 228 | /** |
229 | 229 | * Returns HTML code for the GeoAnalysis general tab (can be either a map or a table). |
@@ -233,73 +233,73 @@ discard block |
||
233 | 233 | * @param (null|array) $flags Array of flags |
234 | 234 | * @return string HTML code for the general tab |
235 | 235 | */ |
236 | - protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) { |
|
237 | - global $WT_TREE; |
|
236 | + protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) { |
|
237 | + global $WT_TREE; |
|
238 | 238 | |
239 | - $html = ''; |
|
240 | - if($placesGeneralResults){ |
|
241 | - $data = new ViewBag(); |
|
239 | + $html = ''; |
|
240 | + if($placesGeneralResults){ |
|
241 | + $data = new ViewBag(); |
|
242 | 242 | |
243 | - $nb_found = $placesGeneralResults['knownsum']; |
|
244 | - $nb_other = 0; |
|
245 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
246 | - $nb_unknown = $placesGeneralResults['unknown']; |
|
243 | + $nb_found = $placesGeneralResults['knownsum']; |
|
244 | + $nb_other = 0; |
|
245 | + if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
246 | + $nb_unknown = $placesGeneralResults['unknown']; |
|
247 | 247 | |
248 | - $data->set('stats_gen_nb_found', $nb_found); |
|
249 | - $data->set('stats_gen_nb_other', $nb_other); |
|
250 | - $data->set('stats_gen_nb_unknown', $nb_unknown); |
|
248 | + $data->set('stats_gen_nb_found', $nb_found); |
|
249 | + $data->set('stats_gen_nb_other', $nb_other); |
|
250 | + $data->set('stats_gen_nb_unknown', $nb_unknown); |
|
251 | 251 | |
252 | - $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags()); |
|
252 | + $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags()); |
|
253 | 253 | |
254 | - if($ga->hasMap()) { |
|
255 | - $max = $placesGeneralResults['max']; |
|
256 | - $map = $ga->getOptions()->getMap(); |
|
257 | - $maxcolor = $map->getCanvas()->max_color; |
|
258 | - $hovercolor = $map->getCanvas()->hover_color; |
|
259 | - $results_by_subdivs = $map->getSubdivisions(); |
|
260 | - $places_mappings = $map->getPlacesMappings(); |
|
261 | - foreach ($placesGeneralResults['places'] as $location => $count) { |
|
262 | - $levelvalues = array_reverse(array_map('trim',explode(',', $location))); |
|
263 | - $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel(); |
|
264 | - if($level_map >= 0 && $level_map < count($levelvalues)) { |
|
265 | - $levelref = $levelvalues[0] . '@' . $levelvalues[$level_map]; |
|
266 | - if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
267 | - } |
|
268 | - else { |
|
269 | - $levelref = $levelvalues[0]; |
|
270 | - } |
|
271 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
272 | - if(isset($results_by_subdivs[$levelref])) { |
|
273 | - $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
|
274 | - $count_subd += $count; |
|
275 | - $results_by_subdivs[$levelref]['count'] = $count_subd; |
|
276 | - $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max); |
|
277 | - if($ga->getOptions()->isUsingFlags() && $flags) { |
|
278 | - $results_by_subdivs[$levelref]['place'] = new Place($location, $WT_TREE); |
|
279 | - $results_by_subdivs[$levelref]['flag'] = $flags[$location]; |
|
280 | - } |
|
281 | - } |
|
282 | - } |
|
254 | + if($ga->hasMap()) { |
|
255 | + $max = $placesGeneralResults['max']; |
|
256 | + $map = $ga->getOptions()->getMap(); |
|
257 | + $maxcolor = $map->getCanvas()->max_color; |
|
258 | + $hovercolor = $map->getCanvas()->hover_color; |
|
259 | + $results_by_subdivs = $map->getSubdivisions(); |
|
260 | + $places_mappings = $map->getPlacesMappings(); |
|
261 | + foreach ($placesGeneralResults['places'] as $location => $count) { |
|
262 | + $levelvalues = array_reverse(array_map('trim',explode(',', $location))); |
|
263 | + $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel(); |
|
264 | + if($level_map >= 0 && $level_map < count($levelvalues)) { |
|
265 | + $levelref = $levelvalues[0] . '@' . $levelvalues[$level_map]; |
|
266 | + if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
267 | + } |
|
268 | + else { |
|
269 | + $levelref = $levelvalues[0]; |
|
270 | + } |
|
271 | + if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
272 | + if(isset($results_by_subdivs[$levelref])) { |
|
273 | + $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
|
274 | + $count_subd += $count; |
|
275 | + $results_by_subdivs[$levelref]['count'] = $count_subd; |
|
276 | + $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max); |
|
277 | + if($ga->getOptions()->isUsingFlags() && $flags) { |
|
278 | + $results_by_subdivs[$levelref]['place'] = new Place($location, $WT_TREE); |
|
279 | + $results_by_subdivs[$levelref]['flag'] = $flags[$location]; |
|
280 | + } |
|
281 | + } |
|
282 | + } |
|
283 | 283 | |
284 | - $data->set('map', $ga->getOptions()->getMap()); |
|
285 | - $data->set('results_by_subdivisions', $results_by_subdivs); |
|
284 | + $data->set('map', $ga->getOptions()->getMap()); |
|
285 | + $data->set('results_by_subdivisions', $results_by_subdivs); |
|
286 | 286 | |
287 | - $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
|
288 | - } |
|
289 | - else { |
|
290 | - $results = $placesGeneralResults['places']; |
|
291 | - arsort($results); |
|
292 | - $data->set('results', $results); |
|
293 | - $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
287 | + $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
|
288 | + } |
|
289 | + else { |
|
290 | + $results = $placesGeneralResults['places']; |
|
291 | + arsort($results); |
|
292 | + $data->set('results', $results); |
|
293 | + $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
294 | 294 | |
295 | - $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
|
296 | - } |
|
297 | - } |
|
298 | - else { |
|
299 | - $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
|
300 | - } |
|
301 | - return $html; |
|
302 | - } |
|
295 | + $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
|
296 | + } |
|
297 | + } |
|
298 | + else { |
|
299 | + $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
|
300 | + } |
|
301 | + return $html; |
|
302 | + } |
|
303 | 303 | |
304 | 304 | /** |
305 | 305 | * Returns HTML code for the GeoAnalysis generations tab. |
@@ -309,70 +309,70 @@ discard block |
||
309 | 309 | * @param (null|array) $flags Array of flags |
310 | 310 | * @return string HTML code for the generations tab |
311 | 311 | */ |
312 | - protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) { |
|
313 | - global $WT_TREE; |
|
312 | + protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) { |
|
313 | + global $WT_TREE; |
|
314 | 314 | |
315 | - $html = '<p class="warning">'.I18N::translate('No data is available for the generations analysis.').'<p>'; |
|
316 | - if($placesGenerationsResults && $ga->getOptions()){ |
|
317 | - $data = new ViewBag(); |
|
315 | + $html = '<p class="warning">'.I18N::translate('No data is available for the generations analysis.').'<p>'; |
|
316 | + if($placesGenerationsResults && $ga->getOptions()){ |
|
317 | + $data = new ViewBag(); |
|
318 | 318 | |
319 | - ksort($placesGenerationsResults); |
|
319 | + ksort($placesGenerationsResults); |
|
320 | 320 | |
321 | - $detailslevel = $ga->getOptions()->getMaxDetailsInGen(); |
|
322 | - $data->set('max_details_gen', $detailslevel); |
|
323 | - $data->set('use_flags', $ga->getOptions()->isUsingFlags()); |
|
324 | - $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
325 | - $display_all_places = !is_null($detailslevel) && $detailslevel == 0; |
|
326 | - $data->set('display_all_places', $display_all_places); |
|
321 | + $detailslevel = $ga->getOptions()->getMaxDetailsInGen(); |
|
322 | + $data->set('max_details_gen', $detailslevel); |
|
323 | + $data->set('use_flags', $ga->getOptions()->isUsingFlags()); |
|
324 | + $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
325 | + $display_all_places = !is_null($detailslevel) && $detailslevel == 0; |
|
326 | + $data->set('display_all_places', $display_all_places); |
|
327 | 327 | |
328 | - $results_by_gen = array(); |
|
329 | - foreach($placesGenerationsResults as $gen => $genData){ |
|
330 | - $sum = 0; |
|
331 | - $other = 0; |
|
332 | - $unknown = 0; |
|
333 | - if(isset($genData['sum'])) $sum = $genData['sum']; |
|
334 | - if(isset($genData['other'])) $other = $genData['other']; |
|
335 | - if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
328 | + $results_by_gen = array(); |
|
329 | + foreach($placesGenerationsResults as $gen => $genData){ |
|
330 | + $sum = 0; |
|
331 | + $other = 0; |
|
332 | + $unknown = 0; |
|
333 | + if(isset($genData['sum'])) $sum = $genData['sum']; |
|
334 | + if(isset($genData['other'])) $other = $genData['other']; |
|
335 | + if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
336 | 336 | |
337 | - if($sum > 0) { |
|
338 | - $results_by_gen[$gen]['sum'] = $sum; |
|
339 | - $results_by_gen[$gen]['other'] = $other; |
|
340 | - $results_by_gen[$gen]['unknown'] = $unknown; |
|
341 | - $results_by_gen[$gen]['places'] = array(); |
|
342 | - arsort($genData['places']); |
|
337 | + if($sum > 0) { |
|
338 | + $results_by_gen[$gen]['sum'] = $sum; |
|
339 | + $results_by_gen[$gen]['other'] = $other; |
|
340 | + $results_by_gen[$gen]['unknown'] = $unknown; |
|
341 | + $results_by_gen[$gen]['places'] = array(); |
|
342 | + arsort($genData['places']); |
|
343 | 343 | |
344 | - if($display_all_places){ |
|
345 | - foreach($genData['places'] as $placename=> $count){ |
|
346 | - $results_by_gen[$gen]['places'][$placename]['count'] = $count; |
|
347 | - $levels = array_map('trim',explode(',', $placename)); |
|
344 | + if($display_all_places){ |
|
345 | + foreach($genData['places'] as $placename=> $count){ |
|
346 | + $results_by_gen[$gen]['places'][$placename]['count'] = $count; |
|
347 | + $levels = array_map('trim',explode(',', $placename)); |
|
348 | 348 | |
349 | - if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){ |
|
350 | - $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, $WT_TREE); |
|
351 | - $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
|
352 | - } |
|
353 | - } |
|
354 | - } |
|
355 | - else { |
|
356 | - $tmp = $genData['places']; |
|
357 | - if($other > 0) { |
|
358 | - $tmp = array_slice($tmp, 0, 5, true); |
|
359 | - $tmp['other'] = $other; |
|
360 | - arsort($tmp); |
|
361 | - } |
|
362 | - $results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true); |
|
363 | - } |
|
364 | - } |
|
365 | - } |
|
349 | + if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){ |
|
350 | + $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, $WT_TREE); |
|
351 | + $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
|
352 | + } |
|
353 | + } |
|
354 | + } |
|
355 | + else { |
|
356 | + $tmp = $genData['places']; |
|
357 | + if($other > 0) { |
|
358 | + $tmp = array_slice($tmp, 0, 5, true); |
|
359 | + $tmp['other'] = $other; |
|
360 | + arsort($tmp); |
|
361 | + } |
|
362 | + $results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true); |
|
363 | + } |
|
364 | + } |
|
365 | + } |
|
366 | 366 | |
367 | - $data->set('results_by_generations', $results_by_gen); |
|
367 | + $data->set('results_by_generations', $results_by_gen); |
|
368 | 368 | |
369 | - $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
|
369 | + $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
|
370 | 370 | |
371 | - } |
|
372 | - else { |
|
373 | - $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
|
374 | - } |
|
375 | - return $html; |
|
376 | - } |
|
371 | + } |
|
372 | + else { |
|
373 | + $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
|
374 | + } |
|
375 | + return $html; |
|
376 | + } |
|
377 | 377 | |
378 | 378 | } |
379 | 379 | \ No newline at end of file |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $ga_id = Filter::getInteger('ga_id'); |
72 | 72 | |
73 | - if($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
73 | + if ($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
74 | 74 | $data->set('has_analysis', true); |
75 | 75 | $data->set('geoanalysis', $ga); |
76 | 76 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | jQuery.get( |
84 | 84 | "module.php", |
85 | 85 | { |
86 | - "mod" : "'. $this->module->getName() .'", |
|
86 | + "mod" : "'. $this->module->getName().'", |
|
87 | 87 | "mod_action": "GeoAnalysis@dataTabs", |
88 | 88 | "ga_id" : "'.$ga_id.'" |
89 | 89 | }, |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $data->set('has_list', false); |
116 | 116 | |
117 | 117 | $ga_list = $this->provider->getGeoAnalysisList(); |
118 | - if(count($ga_list) > 0 ) { |
|
118 | + if (count($ga_list) > 0) { |
|
119 | 119 | $data->set('has_list', true); |
120 | 120 | $data->set('geoanalysislist', $ga_list); |
121 | 121 | } |
@@ -141,19 +141,19 @@ discard block |
||
141 | 141 | ); |
142 | 142 | |
143 | 143 | $status = Filter::getBool('status'); |
144 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
145 | - try{ |
|
144 | + $res = array('geoanalysis' => $ga->getId(), 'error' => null); |
|
145 | + try { |
|
146 | 146 | $this->provider->setGeoAnalysisStatus($ga, $status); |
147 | 147 | $res['status'] = $status; |
148 | - Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
|
148 | + Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '.($status ? 'enabled' : 'disabled').'.'); |
|
149 | 149 | } |
150 | 150 | catch (\Exception $ex) { |
151 | 151 | $res['error'] = $ex->getMessage(); |
152 | - Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
|
152 | + Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be '.($status ? 'enabled' : 'disabled').'. Error: '.$ex->getMessage()); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | $controller->pageHeader(); |
156 | - if($res['error']) http_response_code(500); |
|
156 | + if ($res['error']) http_response_code(500); |
|
157 | 157 | |
158 | 158 | echo \Zend_Json::encode($res); |
159 | 159 | } |
@@ -175,18 +175,18 @@ discard block |
||
175 | 175 | && $ga |
176 | 176 | ); |
177 | 177 | |
178 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
179 | - try{ |
|
178 | + $res = array('geoanalysis' => $ga->getId(), 'error' => null); |
|
179 | + try { |
|
180 | 180 | $this->provider->deleteGeoAnalysis($ga); |
181 | 181 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
182 | 182 | } |
183 | 183 | catch (\Exception $ex) { |
184 | 184 | $res['error'] = $ex->getMessage(); |
185 | - Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage()); |
|
185 | + Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '.$ex->getMessage()); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | $controller->pageHeader(); |
189 | - if($res['error']) http_response_code(500); |
|
189 | + if ($res['error']) http_response_code(500); |
|
190 | 190 | |
191 | 191 | echo \Zend_Json::encode($res); |
192 | 192 | } |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); |
213 | 213 | |
214 | 214 | $flags = array(); |
215 | - if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
215 | + if ($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
216 | 216 | $mapProvider = new GoogleMapsProvider(); |
217 | - foreach($placesDispGeneral['places'] as $place => $count) { |
|
217 | + foreach ($placesDispGeneral['places'] as $place => $count) { |
|
218 | 218 | $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $WT_TREE)); |
219 | 219 | } |
220 | 220 | } |
@@ -233,16 +233,16 @@ discard block |
||
233 | 233 | * @param (null|array) $flags Array of flags |
234 | 234 | * @return string HTML code for the general tab |
235 | 235 | */ |
236 | - protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) { |
|
236 | + protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags = null) { |
|
237 | 237 | global $WT_TREE; |
238 | 238 | |
239 | 239 | $html = ''; |
240 | - if($placesGeneralResults){ |
|
240 | + if ($placesGeneralResults) { |
|
241 | 241 | $data = new ViewBag(); |
242 | 242 | |
243 | 243 | $nb_found = $placesGeneralResults['knownsum']; |
244 | 244 | $nb_other = 0; |
245 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
245 | + if (isset($placesGeneralResults['other'])) $nb_other = $placesGeneralResults['other']; |
|
246 | 246 | $nb_unknown = $placesGeneralResults['unknown']; |
247 | 247 | |
248 | 248 | $data->set('stats_gen_nb_found', $nb_found); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags()); |
253 | 253 | |
254 | - if($ga->hasMap()) { |
|
254 | + if ($ga->hasMap()) { |
|
255 | 255 | $max = $placesGeneralResults['max']; |
256 | 256 | $map = $ga->getOptions()->getMap(); |
257 | 257 | $maxcolor = $map->getCanvas()->max_color; |
@@ -259,22 +259,22 @@ discard block |
||
259 | 259 | $results_by_subdivs = $map->getSubdivisions(); |
260 | 260 | $places_mappings = $map->getPlacesMappings(); |
261 | 261 | foreach ($placesGeneralResults['places'] as $location => $count) { |
262 | - $levelvalues = array_reverse(array_map('trim',explode(',', $location))); |
|
262 | + $levelvalues = array_reverse(array_map('trim', explode(',', $location))); |
|
263 | 263 | $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel(); |
264 | - if($level_map >= 0 && $level_map < count($levelvalues)) { |
|
265 | - $levelref = $levelvalues[0] . '@' . $levelvalues[$level_map]; |
|
266 | - if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
264 | + if ($level_map >= 0 && $level_map < count($levelvalues)) { |
|
265 | + $levelref = $levelvalues[0].'@'.$levelvalues[$level_map]; |
|
266 | + if (!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
267 | 267 | } |
268 | 268 | else { |
269 | 269 | $levelref = $levelvalues[0]; |
270 | 270 | } |
271 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
272 | - if(isset($results_by_subdivs[$levelref])) { |
|
271 | + if (isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
272 | + if (isset($results_by_subdivs[$levelref])) { |
|
273 | 273 | $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
274 | - $count_subd += $count; |
|
274 | + $count_subd += $count; |
|
275 | 275 | $results_by_subdivs[$levelref]['count'] = $count_subd; |
276 | 276 | $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max); |
277 | - if($ga->getOptions()->isUsingFlags() && $flags) { |
|
277 | + if ($ga->getOptions()->isUsingFlags() && $flags) { |
|
278 | 278 | $results_by_subdivs[$levelref]['place'] = new Place($location, $WT_TREE); |
279 | 279 | $results_by_subdivs[$levelref]['flag'] = $flags[$location]; |
280 | 280 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | } |
297 | 297 | } |
298 | 298 | else { |
299 | - $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
|
299 | + $html = '<p class="warning">'.I18N::translate('No data is available for the general analysis.').'</p>'; |
|
300 | 300 | } |
301 | 301 | return $html; |
302 | 302 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | global $WT_TREE; |
314 | 314 | |
315 | 315 | $html = '<p class="warning">'.I18N::translate('No data is available for the generations analysis.').'<p>'; |
316 | - if($placesGenerationsResults && $ga->getOptions()){ |
|
316 | + if ($placesGenerationsResults && $ga->getOptions()) { |
|
317 | 317 | $data = new ViewBag(); |
318 | 318 | |
319 | 319 | ksort($placesGenerationsResults); |
@@ -326,27 +326,27 @@ discard block |
||
326 | 326 | $data->set('display_all_places', $display_all_places); |
327 | 327 | |
328 | 328 | $results_by_gen = array(); |
329 | - foreach($placesGenerationsResults as $gen => $genData){ |
|
329 | + foreach ($placesGenerationsResults as $gen => $genData) { |
|
330 | 330 | $sum = 0; |
331 | 331 | $other = 0; |
332 | 332 | $unknown = 0; |
333 | - if(isset($genData['sum'])) $sum = $genData['sum']; |
|
334 | - if(isset($genData['other'])) $other = $genData['other']; |
|
335 | - if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
333 | + if (isset($genData['sum'])) $sum = $genData['sum']; |
|
334 | + if (isset($genData['other'])) $other = $genData['other']; |
|
335 | + if (isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
336 | 336 | |
337 | - if($sum > 0) { |
|
337 | + if ($sum > 0) { |
|
338 | 338 | $results_by_gen[$gen]['sum'] = $sum; |
339 | 339 | $results_by_gen[$gen]['other'] = $other; |
340 | 340 | $results_by_gen[$gen]['unknown'] = $unknown; |
341 | 341 | $results_by_gen[$gen]['places'] = array(); |
342 | 342 | arsort($genData['places']); |
343 | 343 | |
344 | - if($display_all_places){ |
|
345 | - foreach($genData['places'] as $placename=> $count){ |
|
344 | + if ($display_all_places) { |
|
345 | + foreach ($genData['places'] as $placename=> $count) { |
|
346 | 346 | $results_by_gen[$gen]['places'][$placename]['count'] = $count; |
347 | - $levels = array_map('trim',explode(',', $placename)); |
|
347 | + $levels = array_map('trim', explode(',', $placename)); |
|
348 | 348 | |
349 | - if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){ |
|
349 | + if ($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != '') { |
|
350 | 350 | $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, $WT_TREE); |
351 | 351 | $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
352 | 352 | } |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | } |
355 | 355 | else { |
356 | 356 | $tmp = $genData['places']; |
357 | - if($other > 0) { |
|
357 | + if ($other > 0) { |
|
358 | 358 | $tmp = array_slice($tmp, 0, 5, true); |
359 | 359 | $tmp['other'] = $other; |
360 | 360 | arsort($tmp); |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | |
371 | 371 | } |
372 | 372 | else { |
373 | - $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
|
373 | + $html = '<p class="warning">'.I18N::translate('No data is available for the generations analysis.').'</p>'; |
|
374 | 374 | } |
375 | 375 | return $html; |
376 | 376 | } |
@@ -146,14 +146,15 @@ discard block |
||
146 | 146 | $this->provider->setGeoAnalysisStatus($ga, $status); |
147 | 147 | $res['status'] = $status; |
148 | 148 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
149 | - } |
|
150 | - catch (\Exception $ex) { |
|
149 | + } catch (\Exception $ex) { |
|
151 | 150 | $res['error'] = $ex->getMessage(); |
152 | 151 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
153 | 152 | } |
154 | 153 | |
155 | 154 | $controller->pageHeader(); |
156 | - if($res['error']) http_response_code(500); |
|
155 | + if($res['error']) { |
|
156 | + http_response_code(500); |
|
157 | + } |
|
157 | 158 | |
158 | 159 | echo \Zend_Json::encode($res); |
159 | 160 | } |
@@ -179,14 +180,15 @@ discard block |
||
179 | 180 | try{ |
180 | 181 | $this->provider->deleteGeoAnalysis($ga); |
181 | 182 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
182 | - } |
|
183 | - catch (\Exception $ex) { |
|
183 | + } catch (\Exception $ex) { |
|
184 | 184 | $res['error'] = $ex->getMessage(); |
185 | 185 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage()); |
186 | 186 | } |
187 | 187 | |
188 | 188 | $controller->pageHeader(); |
189 | - if($res['error']) http_response_code(500); |
|
189 | + if($res['error']) { |
|
190 | + http_response_code(500); |
|
191 | + } |
|
190 | 192 | |
191 | 193 | echo \Zend_Json::encode($res); |
192 | 194 | } |
@@ -242,7 +244,9 @@ discard block |
||
242 | 244 | |
243 | 245 | $nb_found = $placesGeneralResults['knownsum']; |
244 | 246 | $nb_other = 0; |
245 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
247 | + if(isset($placesGeneralResults['other'])) { |
|
248 | + $nb_other =$placesGeneralResults['other']; |
|
249 | + } |
|
246 | 250 | $nb_unknown = $placesGeneralResults['unknown']; |
247 | 251 | |
248 | 252 | $data->set('stats_gen_nb_found', $nb_found); |
@@ -264,11 +268,12 @@ discard block |
||
264 | 268 | if($level_map >= 0 && $level_map < count($levelvalues)) { |
265 | 269 | $levelref = $levelvalues[0] . '@' . $levelvalues[$level_map]; |
266 | 270 | if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
267 | - } |
|
268 | - else { |
|
271 | + } else { |
|
269 | 272 | $levelref = $levelvalues[0]; |
270 | 273 | } |
271 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
274 | + if(isset($places_mappings[$levelref])) { |
|
275 | + $levelref = $places_mappings[$levelref]; |
|
276 | + } |
|
272 | 277 | if(isset($results_by_subdivs[$levelref])) { |
273 | 278 | $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
274 | 279 | $count_subd += $count; |
@@ -285,8 +290,7 @@ discard block |
||
285 | 290 | $data->set('results_by_subdivisions', $results_by_subdivs); |
286 | 291 | |
287 | 292 | $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
288 | - } |
|
289 | - else { |
|
293 | + } else { |
|
290 | 294 | $results = $placesGeneralResults['places']; |
291 | 295 | arsort($results); |
292 | 296 | $data->set('results', $results); |
@@ -294,8 +298,7 @@ discard block |
||
294 | 298 | |
295 | 299 | $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
296 | 300 | } |
297 | - } |
|
298 | - else { |
|
301 | + } else { |
|
299 | 302 | $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
300 | 303 | } |
301 | 304 | return $html; |
@@ -330,9 +333,15 @@ discard block |
||
330 | 333 | $sum = 0; |
331 | 334 | $other = 0; |
332 | 335 | $unknown = 0; |
333 | - if(isset($genData['sum'])) $sum = $genData['sum']; |
|
334 | - if(isset($genData['other'])) $other = $genData['other']; |
|
335 | - if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
336 | + if(isset($genData['sum'])) { |
|
337 | + $sum = $genData['sum']; |
|
338 | + } |
|
339 | + if(isset($genData['other'])) { |
|
340 | + $other = $genData['other']; |
|
341 | + } |
|
342 | + if(isset($genData['unknown'])) { |
|
343 | + $unknown = $genData['unknown']; |
|
344 | + } |
|
336 | 345 | |
337 | 346 | if($sum > 0) { |
338 | 347 | $results_by_gen[$gen]['sum'] = $sum; |
@@ -351,8 +360,7 @@ discard block |
||
351 | 360 | $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
352 | 361 | } |
353 | 362 | } |
354 | - } |
|
355 | - else { |
|
363 | + } else { |
|
356 | 364 | $tmp = $genData['places']; |
357 | 365 | if($other > 0) { |
358 | 366 | $tmp = array_slice($tmp, 0, 5, true); |
@@ -368,8 +376,7 @@ discard block |
||
368 | 376 | |
369 | 377 | $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
370 | 378 | |
371 | - } |
|
372 | - else { |
|
379 | + } else { |
|
373 | 380 | $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
374 | 381 | } |
375 | 382 | return $html; |
@@ -11,7 +11,6 @@ |
||
11 | 11 | namespace MyArtJaub\Webtrees\Module\GeoDispersion\Model; |
12 | 12 | |
13 | 13 | use Fisharebest\Webtrees\I18N; |
14 | -use Fisharebest\Webtrees\Place; |
|
15 | 14 | use Fisharebest\Webtrees\Tree; |
16 | 15 | use MyArtJaub\Webtrees\Constants; |
17 | 16 | use MyArtJaub\Webtrees\Individual; |
@@ -25,64 +25,64 @@ discard block |
||
25 | 25 | * Geo Analysis ID |
26 | 26 | * @var int $id |
27 | 27 | */ |
28 | - protected $id; |
|
28 | + protected $id; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Geo Analysis Title |
32 | 32 | * @var string $title |
33 | 33 | */ |
34 | - protected $title; |
|
34 | + protected $title; |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Level of the Gedcom hierarchy for the analysis |
38 | 38 | * @var int $analysis_level |
39 | 39 | */ |
40 | - protected $analysis_level; |
|
40 | + protected $analysis_level; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Display options |
|
44 | - * @var GeoDisplayOptions $options |
|
45 | - */ |
|
46 | - protected $options; |
|
42 | + /** |
|
43 | + * Display options |
|
44 | + * @var GeoDisplayOptions $options |
|
45 | + */ |
|
46 | + protected $options; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Reference tree |
|
50 | - * @var Tree $tree |
|
51 | - */ |
|
52 | - protected $tree; |
|
48 | + /** |
|
49 | + * Reference tree |
|
50 | + * @var Tree $tree |
|
51 | + */ |
|
52 | + protected $tree; |
|
53 | 53 | |
54 | - /** |
|
55 | - * Is the analysis enabled |
|
56 | - * @var bool $enabled |
|
57 | - */ |
|
58 | - protected $enabled; |
|
54 | + /** |
|
55 | + * Is the analysis enabled |
|
56 | + * @var bool $enabled |
|
57 | + */ |
|
58 | + protected $enabled; |
|
59 | 59 | |
60 | - /** |
|
61 | - * Constructor for GeoAnalysis. |
|
62 | - * |
|
63 | - * @param Tree $tree Reference tree |
|
60 | + /** |
|
61 | + * Constructor for GeoAnalysis. |
|
62 | + * |
|
63 | + * @param Tree $tree Reference tree |
|
64 | 64 | * @param int $id GeoAnalysis ID |
65 | 65 | * @param string $title GeoAnalysis title |
66 | 66 | * @param int $analysis_level Analysis level |
67 | 67 | * @param (GeoDisplayOptions|null) $options Display options |
68 | 68 | * @param bool $enabled Is analysis enabled |
69 | - */ |
|
70 | - public function __construct(Tree $tree, $id, $title, $analysis_level, GeoDisplayOptions $options = null, $enabled = true) { |
|
71 | - $this->tree = $tree; |
|
72 | - $this->id = $id; |
|
73 | - $this->title = $title; |
|
74 | - $this->analysis_level = $analysis_level; |
|
75 | - $this->options = $options; |
|
76 | - $this->enabled = $enabled; |
|
77 | - } |
|
69 | + */ |
|
70 | + public function __construct(Tree $tree, $id, $title, $analysis_level, GeoDisplayOptions $options = null, $enabled = true) { |
|
71 | + $this->tree = $tree; |
|
72 | + $this->id = $id; |
|
73 | + $this->title = $title; |
|
74 | + $this->analysis_level = $analysis_level; |
|
75 | + $this->options = $options; |
|
76 | + $this->enabled = $enabled; |
|
77 | + } |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Get the analysis title |
81 | 81 | * @return string |
82 | 82 | */ |
83 | - public function getTitle() { |
|
84 | - return $this->title; |
|
85 | - } |
|
83 | + public function getTitle() { |
|
84 | + return $this->title; |
|
85 | + } |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Set the analysis title |
@@ -90,53 +90,53 @@ discard block |
||
90 | 90 | * @param string $title |
91 | 91 | * @return self Enable method-chaining |
92 | 92 | */ |
93 | - public function setTitle($title) { |
|
94 | - $this->title = $title; |
|
95 | - return $this; |
|
96 | - } |
|
93 | + public function setTitle($title) { |
|
94 | + $this->title = $title; |
|
95 | + return $this; |
|
96 | + } |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Get the analysis ID |
100 | 100 | * @return int |
101 | 101 | */ |
102 | - public function getId() { |
|
103 | - return $this->id; |
|
104 | - } |
|
102 | + public function getId() { |
|
103 | + return $this->id; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | /** |
107 | 107 | * Get the analysis status (enabled/disabled) |
108 | 108 | * @return bool |
109 | 109 | */ |
110 | - public function isEnabled() { |
|
111 | - return $this->enabled; |
|
112 | - } |
|
110 | + public function isEnabled() { |
|
111 | + return $this->enabled; |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * Get analysis options |
|
116 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions |
|
117 | - */ |
|
118 | - public function getOptions() { |
|
119 | - return $this->options; |
|
120 | - } |
|
114 | + /** |
|
115 | + * Get analysis options |
|
116 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions |
|
117 | + */ |
|
118 | + public function getOptions() { |
|
119 | + return $this->options; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | /** |
123 | - * Set analysis options |
|
123 | + * Set analysis options |
|
124 | 124 | * |
125 | - * @param \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions $options |
|
125 | + * @param \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions $options |
|
126 | 126 | * @return self Enable method-chaining |
127 | - */ |
|
128 | - public function setOptions(GeoDisplayOptions $options) { |
|
129 | - $this->options = $options; |
|
130 | - return $this; |
|
131 | - } |
|
127 | + */ |
|
128 | + public function setOptions(GeoDisplayOptions $options) { |
|
129 | + $this->options = $options; |
|
130 | + return $this; |
|
131 | + } |
|
132 | 132 | |
133 | 133 | /** |
134 | 134 | * Get analysis level |
135 | 135 | * @return int |
136 | 136 | */ |
137 | - public function getAnalysisLevel() { |
|
138 | - return $this->analysis_level; |
|
139 | - } |
|
137 | + public function getAnalysisLevel() { |
|
138 | + return $this->analysis_level; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * Get analysis level |
@@ -144,19 +144,19 @@ discard block |
||
144 | 144 | * @param int $analysis_level |
145 | 145 | * @return self Enable method-chaining |
146 | 146 | */ |
147 | - public function setAnalysisLevel($analysis_level) { |
|
148 | - $this->analysis_level = $analysis_level; |
|
149 | - return $this; |
|
150 | - } |
|
147 | + public function setAnalysisLevel($analysis_level) { |
|
148 | + $this->analysis_level = $analysis_level; |
|
149 | + return $this; |
|
150 | + } |
|
151 | 151 | |
152 | 152 | /** |
153 | 153 | * Check whether the analysis has a linked map |
154 | 154 | * |
155 | 155 | * @return bool |
156 | 156 | */ |
157 | - public function hasMap() { |
|
158 | - return $this->options && $this->options->getMap(); |
|
159 | - } |
|
157 | + public function hasMap() { |
|
158 | + return $this->options && $this->options->getMap(); |
|
159 | + } |
|
160 | 160 | |
161 | 161 | /** |
162 | 162 | * Get the URL for the GeoAnalysis. |
@@ -164,117 +164,117 @@ discard block |
||
164 | 164 | * @return string |
165 | 165 | */ |
166 | 166 | public function getHtmlUrl() { |
167 | - return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
168 | - } |
|
167 | + return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * Return the dispersion analysis tables. |
|
172 | - * Two arrays are returned : |
|
173 | - * - the General analysis, which returns the number of ancestors for each place found, plus 4 additional indicators : |
|
174 | - * - knownsum : Number of known places |
|
175 | - * - unknown : Number of unknown places |
|
176 | - * - max : Maximum count of ancestors within a place |
|
177 | - * - other : Other places (not in the top level area) |
|
178 | - * - the Generations analysis, which returns the number of ancestors for each place found for each generation, plus 3 additional indicators within each generation : |
|
179 | - * - sum : Number of known places |
|
180 | - * - unknown : Number of unknown places |
|
181 | - * - other : Other places (not in the top level area) |
|
182 | - * |
|
183 | - * @param array $sosalist List of all sosas |
|
184 | - * @return array Array of the general and generations table |
|
185 | - */ |
|
186 | - public function getAnalysisResults($sosalist) { |
|
187 | - $placesDispGeneral = null; |
|
188 | - $placesDispGenerations = null; |
|
170 | + /** |
|
171 | + * Return the dispersion analysis tables. |
|
172 | + * Two arrays are returned : |
|
173 | + * - the General analysis, which returns the number of ancestors for each place found, plus 4 additional indicators : |
|
174 | + * - knownsum : Number of known places |
|
175 | + * - unknown : Number of unknown places |
|
176 | + * - max : Maximum count of ancestors within a place |
|
177 | + * - other : Other places (not in the top level area) |
|
178 | + * - the Generations analysis, which returns the number of ancestors for each place found for each generation, plus 3 additional indicators within each generation : |
|
179 | + * - sum : Number of known places |
|
180 | + * - unknown : Number of unknown places |
|
181 | + * - other : Other places (not in the top level area) |
|
182 | + * |
|
183 | + * @param array $sosalist List of all sosas |
|
184 | + * @return array Array of the general and generations table |
|
185 | + */ |
|
186 | + public function getAnalysisResults($sosalist) { |
|
187 | + $placesDispGeneral = null; |
|
188 | + $placesDispGenerations = null; |
|
189 | 189 | |
190 | - if($sosalist && count($sosalist) > 0) { |
|
191 | - $placesDispGeneral['knownsum'] = 0; |
|
192 | - $placesDispGeneral['unknown'] = 0; |
|
193 | - $placesDispGeneral['max'] = 0; |
|
194 | - $placesDispGeneral['places'] = array(); |
|
195 | - foreach($sosalist as $sosaid => $gens) { |
|
196 | - $sosa = Individual::getIntance($sosaid, $this->tree); |
|
197 | - $place =$sosa->getSignificantPlace(); |
|
198 | - $genstab = explode(',', $gens); |
|
199 | - $isUnknown=true; |
|
200 | - if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
201 | - $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
202 | - if(count($levels)>= $this->analysis_level){ |
|
203 | - $toplevelvalues = array(); |
|
204 | - if($this->hasMap() && $toplevelvalue = $this->options->getMap()->getTopLevelName()) { |
|
205 | - $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
206 | - } |
|
207 | - if(!$this->hasMap() |
|
208 | - || is_null($this->options->getMapLevel()) |
|
209 | - || $this->options->getMap()->getTopLevelName() == '*' |
|
210 | - || ( |
|
211 | - $this->options->getMapLevel() <= $this->analysis_level |
|
212 | - && $this->options->getMapLevel() > 0 |
|
213 | - && count($levels) >= $this->options->getMapLevel() |
|
214 | - && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
215 | - ) |
|
216 | - ) { |
|
217 | - $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
|
218 | - if(isset($placesDispGeneral['places'][$placest])) { |
|
219 | - $placesDispGeneral['places'][$placest] += 1; |
|
220 | - } |
|
221 | - else { |
|
222 | - $placesDispGeneral['places'][$placest] = 1; |
|
223 | - } |
|
224 | - if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
225 | - $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
226 | - foreach($genstab as $gen) { |
|
227 | - if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
228 | - $placesDispGenerations[$gen]['places'][$placest] += 1; |
|
229 | - } |
|
230 | - else { |
|
231 | - $placesDispGenerations[$gen]['places'][$placest] = 1; |
|
232 | - } |
|
233 | - if(isset($placesDispGenerations[$gen]['sum'])) { |
|
234 | - $placesDispGenerations[$gen]['sum'] += 1; |
|
235 | - } |
|
236 | - else { |
|
237 | - $placesDispGenerations[$gen]['sum'] = 1; |
|
238 | - } |
|
239 | - } |
|
240 | - } |
|
241 | - else{ |
|
242 | - if(isset($placesDispGeneral['other'])) { |
|
243 | - $placesDispGeneral['other'] += 1; |
|
244 | - } |
|
245 | - else { |
|
246 | - $placesDispGeneral['other'] = 1; |
|
247 | - } |
|
248 | - foreach($genstab as $gen) { |
|
249 | - if(isset($placesDispGenerations[$gen]['other'])) { |
|
250 | - $placesDispGenerations[$gen]['other'] += 1; |
|
251 | - } |
|
252 | - else { |
|
253 | - $placesDispGenerations[$gen]['other'] = 1; |
|
254 | - } |
|
255 | - } |
|
256 | - } |
|
257 | - $placesDispGeneral['knownsum'] += 1; |
|
258 | - $isUnknown = false; |
|
259 | - } |
|
260 | - } |
|
261 | - if($isUnknown){ |
|
262 | - $placesDispGeneral['unknown'] += 1; |
|
263 | - foreach($genstab as $gen) { |
|
264 | - if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
265 | - $placesDispGenerations[$gen]['unknown'] += 1; |
|
266 | - } |
|
267 | - else { |
|
268 | - $placesDispGenerations[$gen]['unknown'] = 1; |
|
269 | - } |
|
270 | - } |
|
271 | - } |
|
272 | - } |
|
190 | + if($sosalist && count($sosalist) > 0) { |
|
191 | + $placesDispGeneral['knownsum'] = 0; |
|
192 | + $placesDispGeneral['unknown'] = 0; |
|
193 | + $placesDispGeneral['max'] = 0; |
|
194 | + $placesDispGeneral['places'] = array(); |
|
195 | + foreach($sosalist as $sosaid => $gens) { |
|
196 | + $sosa = Individual::getIntance($sosaid, $this->tree); |
|
197 | + $place =$sosa->getSignificantPlace(); |
|
198 | + $genstab = explode(',', $gens); |
|
199 | + $isUnknown=true; |
|
200 | + if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
201 | + $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
202 | + if(count($levels)>= $this->analysis_level){ |
|
203 | + $toplevelvalues = array(); |
|
204 | + if($this->hasMap() && $toplevelvalue = $this->options->getMap()->getTopLevelName()) { |
|
205 | + $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
206 | + } |
|
207 | + if(!$this->hasMap() |
|
208 | + || is_null($this->options->getMapLevel()) |
|
209 | + || $this->options->getMap()->getTopLevelName() == '*' |
|
210 | + || ( |
|
211 | + $this->options->getMapLevel() <= $this->analysis_level |
|
212 | + && $this->options->getMapLevel() > 0 |
|
213 | + && count($levels) >= $this->options->getMapLevel() |
|
214 | + && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
215 | + ) |
|
216 | + ) { |
|
217 | + $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
|
218 | + if(isset($placesDispGeneral['places'][$placest])) { |
|
219 | + $placesDispGeneral['places'][$placest] += 1; |
|
220 | + } |
|
221 | + else { |
|
222 | + $placesDispGeneral['places'][$placest] = 1; |
|
223 | + } |
|
224 | + if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
225 | + $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
226 | + foreach($genstab as $gen) { |
|
227 | + if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
228 | + $placesDispGenerations[$gen]['places'][$placest] += 1; |
|
229 | + } |
|
230 | + else { |
|
231 | + $placesDispGenerations[$gen]['places'][$placest] = 1; |
|
232 | + } |
|
233 | + if(isset($placesDispGenerations[$gen]['sum'])) { |
|
234 | + $placesDispGenerations[$gen]['sum'] += 1; |
|
235 | + } |
|
236 | + else { |
|
237 | + $placesDispGenerations[$gen]['sum'] = 1; |
|
238 | + } |
|
239 | + } |
|
240 | + } |
|
241 | + else{ |
|
242 | + if(isset($placesDispGeneral['other'])) { |
|
243 | + $placesDispGeneral['other'] += 1; |
|
244 | + } |
|
245 | + else { |
|
246 | + $placesDispGeneral['other'] = 1; |
|
247 | + } |
|
248 | + foreach($genstab as $gen) { |
|
249 | + if(isset($placesDispGenerations[$gen]['other'])) { |
|
250 | + $placesDispGenerations[$gen]['other'] += 1; |
|
251 | + } |
|
252 | + else { |
|
253 | + $placesDispGenerations[$gen]['other'] = 1; |
|
254 | + } |
|
255 | + } |
|
256 | + } |
|
257 | + $placesDispGeneral['knownsum'] += 1; |
|
258 | + $isUnknown = false; |
|
259 | + } |
|
260 | + } |
|
261 | + if($isUnknown){ |
|
262 | + $placesDispGeneral['unknown'] += 1; |
|
263 | + foreach($genstab as $gen) { |
|
264 | + if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
265 | + $placesDispGenerations[$gen]['unknown'] += 1; |
|
266 | + } |
|
267 | + else { |
|
268 | + $placesDispGenerations[$gen]['unknown'] = 1; |
|
269 | + } |
|
270 | + } |
|
271 | + } |
|
272 | + } |
|
273 | 273 | |
274 | - } |
|
274 | + } |
|
275 | 275 | |
276 | - return array($placesDispGeneral, $placesDispGenerations); |
|
277 | - } |
|
276 | + return array($placesDispGeneral, $placesDispGenerations); |
|
277 | + } |
|
278 | 278 | |
279 | 279 | |
280 | 280 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @return string |
165 | 165 | */ |
166 | 166 | public function getHtmlUrl() { |
167 | - return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
167 | + return 'module.php?mod='.Constants::MODULE_MAJ_GEODISP_NAME.'&mod_action=GeoAnalysis&ga_id='.$this->getId().'&ged='.$this->tree->getNameUrl(); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -187,50 +187,50 @@ discard block |
||
187 | 187 | $placesDispGeneral = null; |
188 | 188 | $placesDispGenerations = null; |
189 | 189 | |
190 | - if($sosalist && count($sosalist) > 0) { |
|
190 | + if ($sosalist && count($sosalist) > 0) { |
|
191 | 191 | $placesDispGeneral['knownsum'] = 0; |
192 | 192 | $placesDispGeneral['unknown'] = 0; |
193 | 193 | $placesDispGeneral['max'] = 0; |
194 | 194 | $placesDispGeneral['places'] = array(); |
195 | - foreach($sosalist as $sosaid => $gens) { |
|
195 | + foreach ($sosalist as $sosaid => $gens) { |
|
196 | 196 | $sosa = Individual::getIntance($sosaid, $this->tree); |
197 | - $place =$sosa->getSignificantPlace(); |
|
197 | + $place = $sosa->getSignificantPlace(); |
|
198 | 198 | $genstab = explode(',', $gens); |
199 | - $isUnknown=true; |
|
200 | - if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
201 | - $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
202 | - if(count($levels)>= $this->analysis_level){ |
|
199 | + $isUnknown = true; |
|
200 | + if ($sosa->getDerivedRecord()->canShow() && !is_null($place)) { |
|
201 | + $levels = array_reverse(array_map('trim', explode(',', $place))); |
|
202 | + if (count($levels) >= $this->analysis_level) { |
|
203 | 203 | $toplevelvalues = array(); |
204 | - if($this->hasMap() && $toplevelvalue = $this->options->getMap()->getTopLevelName()) { |
|
205 | - $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
204 | + if ($this->hasMap() && $toplevelvalue = $this->options->getMap()->getTopLevelName()) { |
|
205 | + $toplevelvalues = array_map('trim', explode(',', strtolower($toplevelvalue))); |
|
206 | 206 | } |
207 | - if(!$this->hasMap() |
|
207 | + if (!$this->hasMap() |
|
208 | 208 | || is_null($this->options->getMapLevel()) |
209 | 209 | || $this->options->getMap()->getTopLevelName() == '*' |
210 | 210 | || ( |
211 | 211 | $this->options->getMapLevel() <= $this->analysis_level |
212 | 212 | && $this->options->getMapLevel() > 0 |
213 | 213 | && count($levels) >= $this->options->getMapLevel() |
214 | - && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
214 | + && in_array(strtolower($levels[$this->options->getMapLevel() - 1]), $toplevelvalues) |
|
215 | 215 | ) |
216 | 216 | ) { |
217 | 217 | $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
218 | - if(isset($placesDispGeneral['places'][$placest])) { |
|
218 | + if (isset($placesDispGeneral['places'][$placest])) { |
|
219 | 219 | $placesDispGeneral['places'][$placest] += 1; |
220 | 220 | } |
221 | 221 | else { |
222 | 222 | $placesDispGeneral['places'][$placest] = 1; |
223 | 223 | } |
224 | - if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
224 | + if ($placesDispGeneral['places'][$placest] > $placesDispGeneral['max']) |
|
225 | 225 | $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
226 | - foreach($genstab as $gen) { |
|
227 | - if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
226 | + foreach ($genstab as $gen) { |
|
227 | + if (isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
228 | 228 | $placesDispGenerations[$gen]['places'][$placest] += 1; |
229 | 229 | } |
230 | 230 | else { |
231 | 231 | $placesDispGenerations[$gen]['places'][$placest] = 1; |
232 | 232 | } |
233 | - if(isset($placesDispGenerations[$gen]['sum'])) { |
|
233 | + if (isset($placesDispGenerations[$gen]['sum'])) { |
|
234 | 234 | $placesDispGenerations[$gen]['sum'] += 1; |
235 | 235 | } |
236 | 236 | else { |
@@ -238,15 +238,15 @@ discard block |
||
238 | 238 | } |
239 | 239 | } |
240 | 240 | } |
241 | - else{ |
|
242 | - if(isset($placesDispGeneral['other'])) { |
|
241 | + else { |
|
242 | + if (isset($placesDispGeneral['other'])) { |
|
243 | 243 | $placesDispGeneral['other'] += 1; |
244 | 244 | } |
245 | 245 | else { |
246 | 246 | $placesDispGeneral['other'] = 1; |
247 | 247 | } |
248 | - foreach($genstab as $gen) { |
|
249 | - if(isset($placesDispGenerations[$gen]['other'])) { |
|
248 | + foreach ($genstab as $gen) { |
|
249 | + if (isset($placesDispGenerations[$gen]['other'])) { |
|
250 | 250 | $placesDispGenerations[$gen]['other'] += 1; |
251 | 251 | } |
252 | 252 | else { |
@@ -258,10 +258,10 @@ discard block |
||
258 | 258 | $isUnknown = false; |
259 | 259 | } |
260 | 260 | } |
261 | - if($isUnknown){ |
|
261 | + if ($isUnknown) { |
|
262 | 262 | $placesDispGeneral['unknown'] += 1; |
263 | - foreach($genstab as $gen) { |
|
264 | - if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
263 | + foreach ($genstab as $gen) { |
|
264 | + if (isset($placesDispGenerations[$gen]['unknown'])) { |
|
265 | 265 | $placesDispGenerations[$gen]['unknown'] += 1; |
266 | 266 | } |
267 | 267 | else { |
@@ -217,39 +217,34 @@ discard block |
||
217 | 217 | $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
218 | 218 | if(isset($placesDispGeneral['places'][$placest])) { |
219 | 219 | $placesDispGeneral['places'][$placest] += 1; |
220 | - } |
|
221 | - else { |
|
220 | + } else { |
|
222 | 221 | $placesDispGeneral['places'][$placest] = 1; |
223 | 222 | } |
224 | - if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
225 | - $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
223 | + if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) { |
|
224 | + $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
225 | + } |
|
226 | 226 | foreach($genstab as $gen) { |
227 | 227 | if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
228 | 228 | $placesDispGenerations[$gen]['places'][$placest] += 1; |
229 | - } |
|
230 | - else { |
|
229 | + } else { |
|
231 | 230 | $placesDispGenerations[$gen]['places'][$placest] = 1; |
232 | 231 | } |
233 | 232 | if(isset($placesDispGenerations[$gen]['sum'])) { |
234 | 233 | $placesDispGenerations[$gen]['sum'] += 1; |
235 | - } |
|
236 | - else { |
|
234 | + } else { |
|
237 | 235 | $placesDispGenerations[$gen]['sum'] = 1; |
238 | 236 | } |
239 | 237 | } |
240 | - } |
|
241 | - else{ |
|
238 | + } else{ |
|
242 | 239 | if(isset($placesDispGeneral['other'])) { |
243 | 240 | $placesDispGeneral['other'] += 1; |
244 | - } |
|
245 | - else { |
|
241 | + } else { |
|
246 | 242 | $placesDispGeneral['other'] = 1; |
247 | 243 | } |
248 | 244 | foreach($genstab as $gen) { |
249 | 245 | if(isset($placesDispGenerations[$gen]['other'])) { |
250 | 246 | $placesDispGenerations[$gen]['other'] += 1; |
251 | - } |
|
252 | - else { |
|
247 | + } else { |
|
253 | 248 | $placesDispGenerations[$gen]['other'] = 1; |
254 | 249 | } |
255 | 250 | } |
@@ -263,8 +258,7 @@ discard block |
||
263 | 258 | foreach($genstab as $gen) { |
264 | 259 | if(isset($placesDispGenerations[$gen]['unknown'])) { |
265 | 260 | $placesDispGenerations[$gen]['unknown'] += 1; |
266 | - } |
|
267 | - else { |
|
261 | + } else { |
|
268 | 262 | $placesDispGenerations[$gen]['unknown'] = 1; |
269 | 263 | } |
270 | 264 | } |
@@ -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 |
|
93 | 93 | */ |
94 | 94 | public function getGeoAnalysisCount() { |
95 | 95 | return Database::prepare( |
@@ -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 | - ->setIsUsingFlags($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 | + ->setIsUsingFlags($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,238 +217,238 @@ 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 | - $random_place = null; |
|
385 | - $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 | + $random_place = null; |
|
385 | + $nb_levels = 0; |
|
386 | 386 | |
387 | - //Select all '2 PLAC ' tags in the file and create array |
|
388 | - $places_list=array(); |
|
389 | - $ged_data = Database::prepare( |
|
390 | - 'SELECT i_gedcom AS gedcom'. |
|
391 | - ' FROM `##individuals`'. |
|
392 | - ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. |
|
393 | - ' UNION ALL'. |
|
394 | - 'SELECT f_gedcom AS gedcom'. |
|
395 | - ' FROM `##families`'. |
|
396 | - ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' |
|
397 | - )->execute(array( |
|
398 | - 'gedcom' => '%\n2 PLAC %', |
|
399 | - 'gedcom_id' => $this->tree->getTreeId() |
|
400 | - ))->fetchOneColumn(); |
|
401 | - foreach ($ged_data as $ged_datum) { |
|
402 | - preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
|
403 | - foreach ($matches[1] as $match) { |
|
404 | - $places_list[$match]=true; |
|
405 | - } |
|
406 | - } |
|
387 | + //Select all '2 PLAC ' tags in the file and create array |
|
388 | + $places_list=array(); |
|
389 | + $ged_data = Database::prepare( |
|
390 | + 'SELECT i_gedcom AS gedcom'. |
|
391 | + ' FROM `##individuals`'. |
|
392 | + ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. |
|
393 | + ' UNION ALL'. |
|
394 | + 'SELECT f_gedcom AS gedcom'. |
|
395 | + ' FROM `##families`'. |
|
396 | + ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' |
|
397 | + )->execute(array( |
|
398 | + 'gedcom' => '%\n2 PLAC %', |
|
399 | + 'gedcom_id' => $this->tree->getTreeId() |
|
400 | + ))->fetchOneColumn(); |
|
401 | + foreach ($ged_data as $ged_datum) { |
|
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 | - $places_parts=array(); |
|
413 | - usort($places_list, array('I18N', 'strcasecmp')); |
|
414 | - $nb_places = count($places_list); |
|
411 | + //sort the array, limit to unique values, and count them |
|
412 | + $places_parts=array(); |
|
413 | + usort($places_list, array('I18N', 'strcasecmp')); |
|
414 | + $nb_places = count($places_list); |
|
415 | 415 | |
416 | - //calculate maximum no. of levels to display |
|
417 | - $has_found_good_example = false; |
|
418 | - foreach($places_list as $place){ |
|
419 | - $levels = explode(",", $place); |
|
420 | - $parts = count($levels); |
|
421 | - if ($parts >= $nb_levels){ |
|
422 | - $nb_levels = $parts; |
|
423 | - if(!$has_found_good_example){ |
|
424 | - $random_place = $$place; |
|
425 | - if(min(array_map('strlen', $levels)) > 0){ |
|
426 | - $has_found_good_example = true; |
|
427 | - } |
|
428 | - } |
|
429 | - } |
|
430 | - } |
|
416 | + //calculate maximum no. of levels to display |
|
417 | + $has_found_good_example = false; |
|
418 | + foreach($places_list as $place){ |
|
419 | + $levels = explode(",", $place); |
|
420 | + $parts = count($levels); |
|
421 | + if ($parts >= $nb_levels){ |
|
422 | + $nb_levels = $parts; |
|
423 | + if(!$has_found_good_example){ |
|
424 | + $random_place = $$place; |
|
425 | + if(min(array_map('strlen', $levels)) > 0){ |
|
426 | + $has_found_good_example = true; |
|
427 | + } |
|
428 | + } |
|
429 | + } |
|
430 | + } |
|
431 | 431 | |
432 | - return array_reverse(array_map('trim',explode(',', $randomPlace))); |
|
433 | - } |
|
432 | + return array_reverse(array_map('trim',explode(',', $randomPlace))); |
|
433 | + } |
|
434 | 434 | |
435 | - /** |
|
436 | - * Returns the list of geodispersion maps available within the maps folder. |
|
437 | - * |
|
438 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[] |
|
439 | - */ |
|
440 | - public function getOutlineMapsList() { |
|
441 | - $res = array(); |
|
442 | - $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
|
443 | - if(is_dir($root_path)){ |
|
444 | - $dir = opendir($root_path); |
|
445 | - while (($file=readdir($dir))!== false) { |
|
446 | - if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
|
447 | - $res[base64_encode($file)] = new OutlineMap($file, true); |
|
448 | - } |
|
449 | - } |
|
450 | - } |
|
451 | - return $res; |
|
452 | - } |
|
435 | + /** |
|
436 | + * Returns the list of geodispersion maps available within the maps folder. |
|
437 | + * |
|
438 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[] |
|
439 | + */ |
|
440 | + public function getOutlineMapsList() { |
|
441 | + $res = array(); |
|
442 | + $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
|
443 | + if(is_dir($root_path)){ |
|
444 | + $dir = opendir($root_path); |
|
445 | + while (($file=readdir($dir))!== false) { |
|
446 | + if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
|
447 | + $res[base64_encode($file)] = new OutlineMap($file, true); |
|
448 | + } |
|
449 | + } |
|
450 | + } |
|
451 | + return $res; |
|
452 | + } |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | \ No newline at end of file |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | ->setIsUsingFlags($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 | $id = 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 | $id = 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 | } |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | $nb_levels = 0; |
386 | 386 | |
387 | 387 | //Select all '2 PLAC ' tags in the file and create array |
388 | - $places_list=array(); |
|
388 | + $places_list = array(); |
|
389 | 389 | $ged_data = Database::prepare( |
390 | 390 | 'SELECT i_gedcom AS gedcom'. |
391 | 391 | ' FROM `##individuals`'. |
@@ -401,35 +401,35 @@ discard block |
||
401 | 401 | foreach ($ged_data as $ged_datum) { |
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 | - $places_parts=array(); |
|
412 | + $places_parts = array(); |
|
413 | 413 | usort($places_list, array('I18N', 'strcasecmp')); |
414 | 414 | $nb_places = count($places_list); |
415 | 415 | |
416 | 416 | //calculate maximum no. of levels to display |
417 | 417 | $has_found_good_example = false; |
418 | - foreach($places_list as $place){ |
|
418 | + foreach ($places_list as $place) { |
|
419 | 419 | $levels = explode(",", $place); |
420 | 420 | $parts = count($levels); |
421 | - if ($parts >= $nb_levels){ |
|
421 | + if ($parts >= $nb_levels) { |
|
422 | 422 | $nb_levels = $parts; |
423 | - if(!$has_found_good_example){ |
|
423 | + if (!$has_found_good_example) { |
|
424 | 424 | $random_place = $$place; |
425 | - if(min(array_map('strlen', $levels)) > 0){ |
|
425 | + if (min(array_map('strlen', $levels)) > 0) { |
|
426 | 426 | $has_found_good_example = true; |
427 | 427 | } |
428 | 428 | } |
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
432 | - return array_reverse(array_map('trim',explode(',', $randomPlace))); |
|
432 | + return array_reverse(array_map('trim', explode(',', $randomPlace))); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | /** |
@@ -440,9 +440,9 @@ discard block |
||
440 | 440 | public function getOutlineMapsList() { |
441 | 441 | $res = array(); |
442 | 442 | $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
443 | - if(is_dir($root_path)){ |
|
443 | + if (is_dir($root_path)) { |
|
444 | 444 | $dir = opendir($root_path); |
445 | - while (($file=readdir($dir))!== false) { |
|
445 | + while (($file = readdir($dir)) !== false) { |
|
446 | 446 | if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
447 | 447 | $res[base64_encode($file)] = new OutlineMap($file, true); |
448 | 448 | } |
@@ -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 | } |