@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @see \MyArtJaub\Webtrees\Map\MapProviderInterface::getProviderPlaceId() |
26 | 26 | */ |
27 | 27 | public function getProviderPlaceId(\Fisharebest\Webtrees\Place $place) { |
28 | - if(!$place->isEmpty()) { |
|
29 | - $parent = array_reverse(explode (',', $place->getGedcomName())); |
|
28 | + if (!$place->isEmpty()) { |
|
29 | + $parent = array_reverse(explode(',', $place->getGedcomName())); |
|
30 | 30 | $place_id = 0; |
31 | 31 | $nb_levels = count($parent); |
32 | - for ($i=0; $i < $nb_levels; $i++) { |
|
32 | + for ($i = 0; $i < $nb_levels; $i++) { |
|
33 | 33 | $parent[$i] = trim($parent[$i]); |
34 | - if (empty($parent[$i])) $parent[$i]='unknown';// GoogleMap module uses "unknown" while GEDCOM uses , , |
|
35 | - $pl_id=Database::prepare('SELECT pl_id FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place') |
|
34 | + if (empty($parent[$i])) $parent[$i] = 'unknown'; // GoogleMap module uses "unknown" while GEDCOM uses , , |
|
35 | + $pl_id = Database::prepare('SELECT pl_id FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place') |
|
36 | 36 | ->execute(array($i, $place_id, $parent[$i])) |
37 | 37 | ->fetchOne(); |
38 | 38 | if (empty($pl_id)) break; |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | * @see \MyArtJaub\Webtrees\Map\MapProviderInterface::getPlaceIcon() |
49 | 49 | */ |
50 | 50 | public function getPlaceIcon(\Fisharebest\Webtrees\Place $place) { |
51 | - if(!$place->isEmpty()){ |
|
51 | + if (!$place->isEmpty()) { |
|
52 | 52 | $place_details = |
53 | 53 | Database::prepare('SELECT pl_icon FROM `##placelocation` WHERE pl_id=? ORDER BY pl_place') |
54 | 54 | ->execute(array($this->getProviderPlaceId($place))) |
55 | 55 | ->fetchOneRow(); |
56 | - if($place_details){ |
|
56 | + if ($place_details) { |
|
57 | 57 | return WT_MODULES_DIR.'googlemap/'.$place_details->pl_icon; |
58 | 58 | } |
59 | 59 | } |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public static function getInstance() |
45 | 45 | { |
46 | - if (null === static::$instance) { |
|
47 | - static::$instance = new static(); |
|
48 | - } |
|
46 | + if (null === static::$instance) { |
|
47 | + static::$instance = new static(); |
|
48 | + } |
|
49 | 49 | |
50 | - return static::$instance; |
|
50 | + return static::$instance; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::get() |
56 | 56 | */ |
57 | 57 | public function get($hook_function, $hook_context = null) { |
58 | - return new Hook($hook_function, $hook_context); |
|
58 | + return new Hook($hook_function, $hook_context); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -73,20 +73,20 @@ discard block |
||
73 | 73 | public function getPossibleHooks() { |
74 | 74 | static $hooks=null; |
75 | 75 | if ($hooks === null) { |
76 | - $hooks = array(); |
|
76 | + $hooks = array(); |
|
77 | 77 | |
78 | - // Cannot use the same logic as the core Module loading, |
|
79 | - // as this forces a new include of the module.php file. |
|
80 | - // This causes issue when classes are defined in this file. |
|
81 | - // Cannot use Module::getActiveModules as well, as this is private. |
|
82 | - $module_names = Database::prepare( |
|
83 | - 'SELECT module_name FROM `##module`' |
|
84 | - )->fetchOneColumn(); |
|
78 | + // Cannot use the same logic as the core Module loading, |
|
79 | + // as this forces a new include of the module.php file. |
|
80 | + // This causes issue when classes are defined in this file. |
|
81 | + // Cannot use Module::getActiveModules as well, as this is private. |
|
82 | + $module_names = Database::prepare( |
|
83 | + 'SELECT module_name FROM `##module`' |
|
84 | + )->fetchOneColumn(); |
|
85 | 85 | |
86 | - foreach($module_names as $module_name) { |
|
87 | - $module = Module::getModuleByName($module_name); |
|
86 | + foreach($module_names as $module_name) { |
|
87 | + $module = Module::getModuleByName($module_name); |
|
88 | 88 | |
89 | - if($module instanceof HookSubscriberInterface){ |
|
89 | + if($module instanceof HookSubscriberInterface){ |
|
90 | 90 | $subscribedhooks = $module->getSubscribedHooks(); |
91 | 91 | if(is_array($subscribedhooks)){ |
92 | 92 | foreach($subscribedhooks as $key => $value){ |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
114 | - } |
|
114 | + } |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | return $hooks; |
@@ -153,33 +153,33 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function updateHooks() { |
155 | 155 | |
156 | - if(Auth::isAdmin()){ |
|
157 | - $ihooks = self::getInstalledHooks(); |
|
158 | - $phooks = self::getPossibleHooks(); |
|
156 | + if(Auth::isAdmin()){ |
|
157 | + $ihooks = self::getInstalledHooks(); |
|
158 | + $phooks = self::getPossibleHooks(); |
|
159 | 159 | |
160 | - // Insert hooks not existing yet in the DB |
|
161 | - if($phooks !== null){ |
|
162 | - foreach($phooks as $phook => $priority){ |
|
163 | - $array_hook = explode('#', $phook); |
|
164 | - if($ihooks === null || !array_key_exists($phook, $ihooks)){ |
|
165 | - $chook = new Hook($array_hook[1], $array_hook[2]); |
|
166 | - $chook->subscribe($array_hook[0]); |
|
167 | - $chook->setPriority($array_hook[0], $priority); |
|
168 | - } |
|
169 | - } |
|
170 | - } |
|
160 | + // Insert hooks not existing yet in the DB |
|
161 | + if($phooks !== null){ |
|
162 | + foreach($phooks as $phook => $priority){ |
|
163 | + $array_hook = explode('#', $phook); |
|
164 | + if($ihooks === null || !array_key_exists($phook, $ihooks)){ |
|
165 | + $chook = new Hook($array_hook[1], $array_hook[2]); |
|
166 | + $chook->subscribe($array_hook[0]); |
|
167 | + $chook->setPriority($array_hook[0], $priority); |
|
168 | + } |
|
169 | + } |
|
170 | + } |
|
171 | 171 | |
172 | - //Remove hooks not existing any more in the file system |
|
173 | - if($ihooks !== null){ |
|
174 | - foreach(array_keys($ihooks) as $ihook){ |
|
175 | - $array_hook = explode('#', $ihook); |
|
176 | - if($phooks === null || !array_key_exists($ihook, $phooks)){ |
|
177 | - $chook = new Hook($array_hook[1], $array_hook[2]); |
|
178 | - $chook->remove($array_hook[0]); |
|
179 | - } |
|
180 | - } |
|
181 | - } |
|
182 | - } |
|
172 | + //Remove hooks not existing any more in the file system |
|
173 | + if($ihooks !== null){ |
|
174 | + foreach(array_keys($ihooks) as $ihook){ |
|
175 | + $array_hook = explode('#', $ihook); |
|
176 | + if($phooks === null || !array_key_exists($ihook, $phooks)){ |
|
177 | + $chook = new Hook($array_hook[1], $array_hook[2]); |
|
178 | + $chook->remove($array_hook[0]); |
|
179 | + } |
|
180 | + } |
|
181 | + } |
|
182 | + } |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | } |
186 | 186 | \ No newline at end of file |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getPossibleHooks() |
72 | 72 | */ |
73 | 73 | public function getPossibleHooks() { |
74 | - static $hooks=null; |
|
74 | + static $hooks = null; |
|
75 | 75 | if ($hooks === null) { |
76 | 76 | $hooks = array(); |
77 | 77 | |
@@ -83,31 +83,31 @@ discard block |
||
83 | 83 | 'SELECT module_name FROM `##module`' |
84 | 84 | )->fetchOneColumn(); |
85 | 85 | |
86 | - foreach($module_names as $module_name) { |
|
86 | + foreach ($module_names as $module_name) { |
|
87 | 87 | $module = Module::getModuleByName($module_name); |
88 | 88 | |
89 | - if($module instanceof HookSubscriberInterface){ |
|
89 | + if ($module instanceof HookSubscriberInterface) { |
|
90 | 90 | $subscribedhooks = $module->getSubscribedHooks(); |
91 | - if(is_array($subscribedhooks)){ |
|
92 | - foreach($subscribedhooks as $key => $value){ |
|
93 | - if(is_int($key)) { |
|
91 | + if (is_array($subscribedhooks)) { |
|
92 | + foreach ($subscribedhooks as $key => $value) { |
|
93 | + if (is_int($key)) { |
|
94 | 94 | $hook_item = $value; |
95 | 95 | $priority = self::DEFAULT_PRIORITY; |
96 | 96 | } |
97 | - else{ |
|
97 | + else { |
|
98 | 98 | $hook_item = explode('#', $key, 2); |
99 | 99 | $priority = $value; |
100 | 100 | } |
101 | - if($hook_item && count($hook_item) == 2){ |
|
101 | + if ($hook_item && count($hook_item) == 2) { |
|
102 | 102 | $hook_func = $hook_item[0]; |
103 | 103 | $hook_cont = $hook_item[1]; |
104 | 104 | } |
105 | - else{ |
|
105 | + else { |
|
106 | 106 | $hook_func = $hook_item[0]; |
107 | 107 | $hook_cont = 'all'; |
108 | 108 | } |
109 | - if(method_exists($module, $hook_func)){ |
|
110 | - $hooks[$module->getName().'#'.$hook_func.'#'.$hook_cont]=$priority; |
|
109 | + if (method_exists($module, $hook_func)) { |
|
110 | + $hooks[$module->getName().'#'.$hook_func.'#'.$hook_cont] = $priority; |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * {@inheritDoc} |
122 | 122 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getRawInstalledHooks() |
123 | 123 | */ |
124 | - public function getRawInstalledHooks(){ |
|
125 | - if(self::isModuleOperational()){ |
|
124 | + public function getRawInstalledHooks() { |
|
125 | + if (self::isModuleOperational()) { |
|
126 | 126 | return Database::prepare( |
127 | 127 | "SELECT majh_id AS id, majh_module_name AS module, majh_hook_function AS hook, majh_hook_context as context, majh_module_priority AS priority, majh_status AS status". |
128 | 128 | " FROM `##maj_hooks`". |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | * {@inheritDoc} |
137 | 137 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getInstalledHooks() |
138 | 138 | */ |
139 | - public function getInstalledHooks(){ |
|
140 | - static $installedhooks =null; |
|
141 | - if($installedhooks===null){ |
|
142 | - $dbhooks=self::getRawInstalledHooks(); |
|
143 | - foreach($dbhooks as $dbhook){ |
|
139 | + public function getInstalledHooks() { |
|
140 | + static $installedhooks = null; |
|
141 | + if ($installedhooks === null) { |
|
142 | + $dbhooks = self::getRawInstalledHooks(); |
|
143 | + foreach ($dbhooks as $dbhook) { |
|
144 | 144 | $installedhooks[($dbhook->module).'#'.($dbhook->hook).'#'.($dbhook->context)] = array('id' => $dbhook->id, 'status' => $dbhook->status, 'priority' => $dbhook->priority); |
145 | 145 | } |
146 | 146 | } |
@@ -153,15 +153,15 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function updateHooks() { |
155 | 155 | |
156 | - if(Auth::isAdmin()){ |
|
156 | + if (Auth::isAdmin()) { |
|
157 | 157 | $ihooks = self::getInstalledHooks(); |
158 | 158 | $phooks = self::getPossibleHooks(); |
159 | 159 | |
160 | 160 | // Insert hooks not existing yet in the DB |
161 | - if($phooks !== null){ |
|
162 | - foreach($phooks as $phook => $priority){ |
|
161 | + if ($phooks !== null) { |
|
162 | + foreach ($phooks as $phook => $priority) { |
|
163 | 163 | $array_hook = explode('#', $phook); |
164 | - if($ihooks === null || !array_key_exists($phook, $ihooks)){ |
|
164 | + if ($ihooks === null || !array_key_exists($phook, $ihooks)) { |
|
165 | 165 | $chook = new Hook($array_hook[1], $array_hook[2]); |
166 | 166 | $chook->subscribe($array_hook[0]); |
167 | 167 | $chook->setPriority($array_hook[0], $priority); |
@@ -170,10 +170,10 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | //Remove hooks not existing any more in the file system |
173 | - if($ihooks !== null){ |
|
174 | - foreach(array_keys($ihooks) as $ihook){ |
|
173 | + if ($ihooks !== null) { |
|
174 | + foreach (array_keys($ihooks) as $ihook) { |
|
175 | 175 | $array_hook = explode('#', $ihook); |
176 | - if($phooks === null || !array_key_exists($ihook, $phooks)){ |
|
176 | + if ($phooks === null || !array_key_exists($ihook, $phooks)) { |
|
177 | 177 | $chook = new Hook($array_hook[1], $array_hook[2]); |
178 | 178 | $chook->remove($array_hook[0]); |
179 | 179 | } |
@@ -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,128 +97,128 @@ 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 | - $controller = new JsonController(); |
|
129 | + public function setStatus() { |
|
130 | + $controller = new JsonController(); |
|
131 | 131 | |
132 | - $ga_id = Filter::getInteger('ga_id'); |
|
133 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
132 | + $ga_id = Filter::getInteger('ga_id'); |
|
133 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
134 | 134 | |
135 | - $controller->restrictAccess( |
|
136 | - true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
137 | - && Auth::isManager(Globals::getTree()) |
|
138 | - && $ga !== null |
|
139 | - ); |
|
135 | + $controller->restrictAccess( |
|
136 | + true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
137 | + && Auth::isManager(Globals::getTree()) |
|
138 | + && $ga !== null |
|
139 | + ); |
|
140 | 140 | |
141 | - $status = Filter::getBool('status'); |
|
142 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
143 | - try{ |
|
144 | - $this->provider->setGeoAnalysisStatus($ga, $status); |
|
145 | - $res['status'] = $status; |
|
141 | + $status = Filter::getBool('status'); |
|
142 | + $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
143 | + try{ |
|
144 | + $this->provider->setGeoAnalysisStatus($ga, $status); |
|
145 | + $res['status'] = $status; |
|
146 | 146 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
147 | - } |
|
148 | - catch (\Exception $ex) { |
|
149 | - $res['error'] = $ex->getMessage(); |
|
147 | + } |
|
148 | + catch (\Exception $ex) { |
|
149 | + $res['error'] = $ex->getMessage(); |
|
150 | 150 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
151 | - } |
|
151 | + } |
|
152 | 152 | |
153 | - $controller->pageHeader(); |
|
154 | - if($res['error']) http_response_code(500); |
|
153 | + $controller->pageHeader(); |
|
154 | + if($res['error']) http_response_code(500); |
|
155 | 155 | |
156 | - $controller->encode($res); |
|
157 | - } |
|
156 | + $controller->encode($res); |
|
157 | + } |
|
158 | 158 | |
159 | 159 | /** |
160 | - * GeoAnalysis@delete |
|
161 | - */ |
|
162 | - public function delete() { |
|
163 | - $controller = new JsonController(); |
|
160 | + * GeoAnalysis@delete |
|
161 | + */ |
|
162 | + public function delete() { |
|
163 | + $controller = new JsonController(); |
|
164 | 164 | |
165 | - $ga_id = Filter::getInteger('ga_id'); |
|
166 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
165 | + $ga_id = Filter::getInteger('ga_id'); |
|
166 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
167 | 167 | |
168 | - $controller->restrictAccess( |
|
169 | - true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
170 | - && Auth::isManager(Globals::getTree()) |
|
171 | - && $ga |
|
172 | - ); |
|
168 | + $controller->restrictAccess( |
|
169 | + true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
170 | + && Auth::isManager(Globals::getTree()) |
|
171 | + && $ga |
|
172 | + ); |
|
173 | 173 | |
174 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
175 | - try{ |
|
176 | - $this->provider->deleteGeoAnalysis($ga); |
|
174 | + $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
175 | + try{ |
|
176 | + $this->provider->deleteGeoAnalysis($ga); |
|
177 | 177 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
178 | - } |
|
179 | - catch (\Exception $ex) { |
|
180 | - $res['error'] = $ex->getMessage(); |
|
178 | + } |
|
179 | + catch (\Exception $ex) { |
|
180 | + $res['error'] = $ex->getMessage(); |
|
181 | 181 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage()); |
182 | - } |
|
182 | + } |
|
183 | 183 | |
184 | - $controller->pageHeader(); |
|
185 | - if($res['error']) http_response_code(500); |
|
184 | + $controller->pageHeader(); |
|
185 | + if($res['error']) http_response_code(500); |
|
186 | 186 | |
187 | - $controller->encode($res); |
|
188 | - } |
|
187 | + $controller->encode($res); |
|
188 | + } |
|
189 | 189 | |
190 | - /** |
|
191 | - * GeoAnalysis@dataTabs |
|
192 | - */ |
|
193 | - public function dataTabs() { |
|
194 | - $wt_tree = Globals::getTree(); |
|
195 | - $controller = new JsonController(); |
|
190 | + /** |
|
191 | + * GeoAnalysis@dataTabs |
|
192 | + */ |
|
193 | + public function dataTabs() { |
|
194 | + $wt_tree = Globals::getTree(); |
|
195 | + $controller = new JsonController(); |
|
196 | 196 | |
197 | - $ga_id = Filter::getInteger('ga_id'); |
|
198 | - $ga = $this->provider->getGeoAnalysis($ga_id); |
|
199 | - $sosa_provider = new SosaProvider($wt_tree, Auth::user()); |
|
197 | + $ga_id = Filter::getInteger('ga_id'); |
|
198 | + $ga = $this->provider->getGeoAnalysis($ga_id); |
|
199 | + $sosa_provider = new SosaProvider($wt_tree, Auth::user()); |
|
200 | 200 | |
201 | - $controller |
|
202 | - ->restrictAccess($ga && $sosa_provider->isSetup()) |
|
203 | - ->pageHeader(); |
|
201 | + $controller |
|
202 | + ->restrictAccess($ga && $sosa_provider->isSetup()) |
|
203 | + ->pageHeader(); |
|
204 | 204 | |
205 | - $jsonArray = array(); |
|
205 | + $jsonArray = array(); |
|
206 | 206 | |
207 | - list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); |
|
207 | + list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); |
|
208 | 208 | |
209 | - $flags = array(); |
|
210 | - if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
211 | - $mapProvider = new GoogleMapsProvider(); |
|
212 | - foreach($placesDispGeneral['places'] as $place => $count) { |
|
213 | - $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $wt_tree)); |
|
214 | - } |
|
215 | - } |
|
209 | + $flags = array(); |
|
210 | + if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
211 | + $mapProvider = new GoogleMapsProvider(); |
|
212 | + foreach($placesDispGeneral['places'] as $place => $count) { |
|
213 | + $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $wt_tree)); |
|
214 | + } |
|
215 | + } |
|
216 | 216 | |
217 | - $jsonArray['generaltab'] = $this->htmlPlacesAnalysisGeneralTab($ga, $placesDispGeneral, $flags); |
|
218 | - $jsonArray['generationstab'] = $this->htmlPlacesAnalysisGenerationsTab($ga, $placesDispGenerations, $flags); |
|
217 | + $jsonArray['generaltab'] = $this->htmlPlacesAnalysisGeneralTab($ga, $placesDispGeneral, $flags); |
|
218 | + $jsonArray['generationstab'] = $this->htmlPlacesAnalysisGenerationsTab($ga, $placesDispGenerations, $flags); |
|
219 | 219 | |
220 | - $controller->encode($jsonArray); |
|
221 | - } |
|
220 | + $controller->encode($jsonArray); |
|
221 | + } |
|
222 | 222 | |
223 | 223 | /** |
224 | 224 | * Returns HTML code for the GeoAnalysis general tab (can be either a map or a table). |
@@ -228,70 +228,70 @@ discard block |
||
228 | 228 | * @param (null|array) $flags Array of flags |
229 | 229 | * @return string HTML code for the general tab |
230 | 230 | */ |
231 | - protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) { |
|
232 | - if(!empty($placesGeneralResults)){ |
|
233 | - $data = new ViewBag(); |
|
231 | + protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) { |
|
232 | + if(!empty($placesGeneralResults)){ |
|
233 | + $data = new ViewBag(); |
|
234 | 234 | |
235 | - $nb_found = $placesGeneralResults['knownsum']; |
|
236 | - $nb_other = 0; |
|
237 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
238 | - $nb_unknown = $placesGeneralResults['unknown']; |
|
235 | + $nb_found = $placesGeneralResults['knownsum']; |
|
236 | + $nb_other = 0; |
|
237 | + if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
238 | + $nb_unknown = $placesGeneralResults['unknown']; |
|
239 | 239 | |
240 | - $data->set('stats_gen_nb_found', $nb_found); |
|
241 | - $data->set('stats_gen_nb_other', $nb_other); |
|
242 | - $data->set('stats_gen_nb_unknown', $nb_unknown); |
|
240 | + $data->set('stats_gen_nb_found', $nb_found); |
|
241 | + $data->set('stats_gen_nb_other', $nb_other); |
|
242 | + $data->set('stats_gen_nb_unknown', $nb_unknown); |
|
243 | 243 | |
244 | - $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags()); |
|
244 | + $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags()); |
|
245 | 245 | |
246 | - if($ga->hasMap()) { |
|
247 | - $max = $placesGeneralResults['max']; |
|
248 | - $map = $ga->getOptions()->getMap(); |
|
249 | - if($map->isLoaded()) { |
|
250 | - $results_by_subdivs = $map->getSubdivisions(); |
|
251 | - $places_mappings = $map->getPlacesMappings(); |
|
252 | - foreach ($placesGeneralResults['places'] as $location => $count) { |
|
253 | - $levelvalues = array_reverse(array_map('trim',explode(',', $location))); |
|
254 | - $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel(); |
|
255 | - if($level_map >= 0 && $level_map < count($levelvalues)) { |
|
256 | - $levelref = $levelvalues[0] . '@' . $levelvalues[$level_map]; |
|
257 | - if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
258 | - } |
|
259 | - else { |
|
260 | - $levelref = $levelvalues[0]; |
|
261 | - } |
|
262 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
263 | - if(isset($results_by_subdivs[$levelref])) { |
|
264 | - $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
|
265 | - $count_subd += $count; |
|
266 | - $results_by_subdivs[$levelref]['count'] = $count_subd; |
|
267 | - $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max); |
|
268 | - if($ga->getOptions()->isUsingFlags() && $flags) { |
|
269 | - $results_by_subdivs[$levelref]['place'] = new Place($location, Globals::getTree()); |
|
270 | - $results_by_subdivs[$levelref]['flag'] = $flags[$location]; |
|
271 | - } |
|
272 | - } |
|
273 | - } |
|
246 | + if($ga->hasMap()) { |
|
247 | + $max = $placesGeneralResults['max']; |
|
248 | + $map = $ga->getOptions()->getMap(); |
|
249 | + if($map->isLoaded()) { |
|
250 | + $results_by_subdivs = $map->getSubdivisions(); |
|
251 | + $places_mappings = $map->getPlacesMappings(); |
|
252 | + foreach ($placesGeneralResults['places'] as $location => $count) { |
|
253 | + $levelvalues = array_reverse(array_map('trim',explode(',', $location))); |
|
254 | + $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel(); |
|
255 | + if($level_map >= 0 && $level_map < count($levelvalues)) { |
|
256 | + $levelref = $levelvalues[0] . '@' . $levelvalues[$level_map]; |
|
257 | + if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
258 | + } |
|
259 | + else { |
|
260 | + $levelref = $levelvalues[0]; |
|
261 | + } |
|
262 | + if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
263 | + if(isset($results_by_subdivs[$levelref])) { |
|
264 | + $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
|
265 | + $count_subd += $count; |
|
266 | + $results_by_subdivs[$levelref]['count'] = $count_subd; |
|
267 | + $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max); |
|
268 | + if($ga->getOptions()->isUsingFlags() && $flags) { |
|
269 | + $results_by_subdivs[$levelref]['place'] = new Place($location, Globals::getTree()); |
|
270 | + $results_by_subdivs[$levelref]['flag'] = $flags[$location]; |
|
271 | + } |
|
272 | + } |
|
273 | + } |
|
274 | 274 | |
275 | - $data->set('map', $map); |
|
276 | - $data->set('results_by_subdivisions', $results_by_subdivs); |
|
277 | - } |
|
275 | + $data->set('map', $map); |
|
276 | + $data->set('results_by_subdivisions', $results_by_subdivs); |
|
277 | + } |
|
278 | 278 | |
279 | - $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
|
280 | - } |
|
281 | - else { |
|
282 | - $results = $placesGeneralResults['places']; |
|
283 | - arsort($results); |
|
284 | - $data->set('results', $results); |
|
285 | - $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
279 | + $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
|
280 | + } |
|
281 | + else { |
|
282 | + $results = $placesGeneralResults['places']; |
|
283 | + arsort($results); |
|
284 | + $data->set('results', $results); |
|
285 | + $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
286 | 286 | |
287 | - $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
|
288 | - } |
|
289 | - } |
|
290 | - else { |
|
291 | - $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
|
292 | - } |
|
293 | - return $html; |
|
294 | - } |
|
287 | + $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
|
288 | + } |
|
289 | + } |
|
290 | + else { |
|
291 | + $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
|
292 | + } |
|
293 | + return $html; |
|
294 | + } |
|
295 | 295 | |
296 | 296 | /** |
297 | 297 | * Returns HTML code for the GeoAnalysis generations tab. |
@@ -301,66 +301,66 @@ discard block |
||
301 | 301 | * @param (null|array) $flags Array of flags |
302 | 302 | * @return string HTML code for the generations tab |
303 | 303 | */ |
304 | - protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) { |
|
305 | - if(!empty($placesGenerationsResults) && $ga->getOptions()){ |
|
306 | - $data = new ViewBag(); |
|
304 | + protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) { |
|
305 | + if(!empty($placesGenerationsResults) && $ga->getOptions()){ |
|
306 | + $data = new ViewBag(); |
|
307 | 307 | |
308 | - ksort($placesGenerationsResults); |
|
308 | + ksort($placesGenerationsResults); |
|
309 | 309 | |
310 | - $detailslevel = $ga->getOptions()->getMaxDetailsInGen(); |
|
311 | - $data->set('max_details_gen', $detailslevel); |
|
312 | - $data->set('use_flags', $ga->getOptions()->isUsingFlags()); |
|
313 | - $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
314 | - $display_all_places = !is_null($detailslevel) && $detailslevel == 0; |
|
315 | - $data->set('display_all_places', $display_all_places); |
|
310 | + $detailslevel = $ga->getOptions()->getMaxDetailsInGen(); |
|
311 | + $data->set('max_details_gen', $detailslevel); |
|
312 | + $data->set('use_flags', $ga->getOptions()->isUsingFlags()); |
|
313 | + $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
314 | + $display_all_places = !is_null($detailslevel) && $detailslevel == 0; |
|
315 | + $data->set('display_all_places', $display_all_places); |
|
316 | 316 | |
317 | - $results_by_gen = array(); |
|
318 | - foreach($placesGenerationsResults as $gen => $genData){ |
|
319 | - $sum = 0; |
|
320 | - $other = 0; |
|
321 | - $unknown = 0; |
|
322 | - if(isset($genData['sum'])) $sum = $genData['sum']; |
|
323 | - if(isset($genData['other'])) $other = $genData['other']; |
|
324 | - if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
317 | + $results_by_gen = array(); |
|
318 | + foreach($placesGenerationsResults as $gen => $genData){ |
|
319 | + $sum = 0; |
|
320 | + $other = 0; |
|
321 | + $unknown = 0; |
|
322 | + if(isset($genData['sum'])) $sum = $genData['sum']; |
|
323 | + if(isset($genData['other'])) $other = $genData['other']; |
|
324 | + if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
325 | 325 | |
326 | - if($sum > 0) { |
|
327 | - $results_by_gen[$gen]['sum'] = $sum; |
|
328 | - $results_by_gen[$gen]['other'] = $other; |
|
329 | - $results_by_gen[$gen]['unknown'] = $unknown; |
|
330 | - $results_by_gen[$gen]['places'] = array(); |
|
331 | - arsort($genData['places']); |
|
326 | + if($sum > 0) { |
|
327 | + $results_by_gen[$gen]['sum'] = $sum; |
|
328 | + $results_by_gen[$gen]['other'] = $other; |
|
329 | + $results_by_gen[$gen]['unknown'] = $unknown; |
|
330 | + $results_by_gen[$gen]['places'] = array(); |
|
331 | + arsort($genData['places']); |
|
332 | 332 | |
333 | - if($display_all_places){ |
|
334 | - foreach($genData['places'] as $placename=> $count){ |
|
335 | - $results_by_gen[$gen]['places'][$placename]['count'] = $count; |
|
333 | + if($display_all_places){ |
|
334 | + foreach($genData['places'] as $placename=> $count){ |
|
335 | + $results_by_gen[$gen]['places'][$placename]['count'] = $count; |
|
336 | 336 | |
337 | - if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){ |
|
338 | - $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, Globals::getTree()); |
|
339 | - $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
|
340 | - } |
|
341 | - } |
|
342 | - } |
|
343 | - else { |
|
344 | - $tmp = $genData['places']; |
|
345 | - if($other > 0) { |
|
346 | - $tmp = array_slice($tmp, 0, 5, true); |
|
347 | - $tmp['other'] = $other; |
|
348 | - arsort($tmp); |
|
349 | - } |
|
350 | - $results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true); |
|
351 | - } |
|
352 | - } |
|
353 | - } |
|
337 | + if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){ |
|
338 | + $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, Globals::getTree()); |
|
339 | + $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
|
340 | + } |
|
341 | + } |
|
342 | + } |
|
343 | + else { |
|
344 | + $tmp = $genData['places']; |
|
345 | + if($other > 0) { |
|
346 | + $tmp = array_slice($tmp, 0, 5, true); |
|
347 | + $tmp['other'] = $other; |
|
348 | + arsort($tmp); |
|
349 | + } |
|
350 | + $results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true); |
|
351 | + } |
|
352 | + } |
|
353 | + } |
|
354 | 354 | |
355 | - $data->set('results_by_generations', $results_by_gen); |
|
355 | + $data->set('results_by_generations', $results_by_gen); |
|
356 | 356 | |
357 | - $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
|
357 | + $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
|
358 | 358 | |
359 | - } |
|
360 | - else { |
|
361 | - $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
|
362 | - } |
|
363 | - return $html; |
|
364 | - } |
|
359 | + } |
|
360 | + else { |
|
361 | + $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
|
362 | + } |
|
363 | + return $html; |
|
364 | + } |
|
365 | 365 | |
366 | 366 | } |
367 | 367 | \ 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 | } |
@@ -139,19 +139,19 @@ discard block |
||
139 | 139 | ); |
140 | 140 | |
141 | 141 | $status = Filter::getBool('status'); |
142 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
143 | - try{ |
|
142 | + $res = array('geoanalysis' => $ga->getId(), 'error' => null); |
|
143 | + try { |
|
144 | 144 | $this->provider->setGeoAnalysisStatus($ga, $status); |
145 | 145 | $res['status'] = $status; |
146 | - Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
|
146 | + Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '.($status ? 'enabled' : 'disabled').'.'); |
|
147 | 147 | } |
148 | 148 | catch (\Exception $ex) { |
149 | 149 | $res['error'] = $ex->getMessage(); |
150 | - Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
|
150 | + Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be '.($status ? 'enabled' : 'disabled').'. Error: '.$ex->getMessage()); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | $controller->pageHeader(); |
154 | - if($res['error']) http_response_code(500); |
|
154 | + if ($res['error']) http_response_code(500); |
|
155 | 155 | |
156 | 156 | $controller->encode($res); |
157 | 157 | } |
@@ -171,18 +171,18 @@ discard block |
||
171 | 171 | && $ga |
172 | 172 | ); |
173 | 173 | |
174 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
175 | - try{ |
|
174 | + $res = array('geoanalysis' => $ga->getId(), 'error' => null); |
|
175 | + try { |
|
176 | 176 | $this->provider->deleteGeoAnalysis($ga); |
177 | 177 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
178 | 178 | } |
179 | 179 | catch (\Exception $ex) { |
180 | 180 | $res['error'] = $ex->getMessage(); |
181 | - Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage()); |
|
181 | + Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '.$ex->getMessage()); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $controller->pageHeader(); |
185 | - if($res['error']) http_response_code(500); |
|
185 | + if ($res['error']) http_response_code(500); |
|
186 | 186 | |
187 | 187 | $controller->encode($res); |
188 | 188 | } |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); |
208 | 208 | |
209 | 209 | $flags = array(); |
210 | - if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
210 | + if ($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
211 | 211 | $mapProvider = new GoogleMapsProvider(); |
212 | - foreach($placesDispGeneral['places'] as $place => $count) { |
|
212 | + foreach ($placesDispGeneral['places'] as $place => $count) { |
|
213 | 213 | $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $wt_tree)); |
214 | 214 | } |
215 | 215 | } |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | * @param (null|array) $flags Array of flags |
229 | 229 | * @return string HTML code for the general tab |
230 | 230 | */ |
231 | - protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) { |
|
232 | - if(!empty($placesGeneralResults)){ |
|
231 | + protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags = null) { |
|
232 | + if (!empty($placesGeneralResults)) { |
|
233 | 233 | $data = new ViewBag(); |
234 | 234 | |
235 | 235 | $nb_found = $placesGeneralResults['knownsum']; |
236 | 236 | $nb_other = 0; |
237 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
237 | + if (isset($placesGeneralResults['other'])) $nb_other = $placesGeneralResults['other']; |
|
238 | 238 | $nb_unknown = $placesGeneralResults['unknown']; |
239 | 239 | |
240 | 240 | $data->set('stats_gen_nb_found', $nb_found); |
@@ -243,29 +243,29 @@ discard block |
||
243 | 243 | |
244 | 244 | $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags()); |
245 | 245 | |
246 | - if($ga->hasMap()) { |
|
246 | + if ($ga->hasMap()) { |
|
247 | 247 | $max = $placesGeneralResults['max']; |
248 | 248 | $map = $ga->getOptions()->getMap(); |
249 | - if($map->isLoaded()) { |
|
249 | + if ($map->isLoaded()) { |
|
250 | 250 | $results_by_subdivs = $map->getSubdivisions(); |
251 | 251 | $places_mappings = $map->getPlacesMappings(); |
252 | 252 | foreach ($placesGeneralResults['places'] as $location => $count) { |
253 | - $levelvalues = array_reverse(array_map('trim',explode(',', $location))); |
|
253 | + $levelvalues = array_reverse(array_map('trim', explode(',', $location))); |
|
254 | 254 | $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel(); |
255 | - if($level_map >= 0 && $level_map < count($levelvalues)) { |
|
256 | - $levelref = $levelvalues[0] . '@' . $levelvalues[$level_map]; |
|
257 | - if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
255 | + if ($level_map >= 0 && $level_map < count($levelvalues)) { |
|
256 | + $levelref = $levelvalues[0].'@'.$levelvalues[$level_map]; |
|
257 | + if (!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
258 | 258 | } |
259 | 259 | else { |
260 | 260 | $levelref = $levelvalues[0]; |
261 | 261 | } |
262 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
263 | - if(isset($results_by_subdivs[$levelref])) { |
|
262 | + if (isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
263 | + if (isset($results_by_subdivs[$levelref])) { |
|
264 | 264 | $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
265 | - $count_subd += $count; |
|
265 | + $count_subd += $count; |
|
266 | 266 | $results_by_subdivs[$levelref]['count'] = $count_subd; |
267 | 267 | $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max); |
268 | - if($ga->getOptions()->isUsingFlags() && $flags) { |
|
268 | + if ($ga->getOptions()->isUsingFlags() && $flags) { |
|
269 | 269 | $results_by_subdivs[$levelref]['place'] = new Place($location, Globals::getTree()); |
270 | 270 | $results_by_subdivs[$levelref]['flag'] = $flags[$location]; |
271 | 271 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | } |
289 | 289 | } |
290 | 290 | else { |
291 | - $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
|
291 | + $html = '<p class="warning">'.I18N::translate('No data is available for the general analysis.').'</p>'; |
|
292 | 292 | } |
293 | 293 | return $html; |
294 | 294 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @return string HTML code for the generations tab |
303 | 303 | */ |
304 | 304 | protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) { |
305 | - if(!empty($placesGenerationsResults) && $ga->getOptions()){ |
|
305 | + if (!empty($placesGenerationsResults) && $ga->getOptions()) { |
|
306 | 306 | $data = new ViewBag(); |
307 | 307 | |
308 | 308 | ksort($placesGenerationsResults); |
@@ -315,26 +315,26 @@ discard block |
||
315 | 315 | $data->set('display_all_places', $display_all_places); |
316 | 316 | |
317 | 317 | $results_by_gen = array(); |
318 | - foreach($placesGenerationsResults as $gen => $genData){ |
|
318 | + foreach ($placesGenerationsResults as $gen => $genData) { |
|
319 | 319 | $sum = 0; |
320 | 320 | $other = 0; |
321 | 321 | $unknown = 0; |
322 | - if(isset($genData['sum'])) $sum = $genData['sum']; |
|
323 | - if(isset($genData['other'])) $other = $genData['other']; |
|
324 | - if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
322 | + if (isset($genData['sum'])) $sum = $genData['sum']; |
|
323 | + if (isset($genData['other'])) $other = $genData['other']; |
|
324 | + if (isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
325 | 325 | |
326 | - if($sum > 0) { |
|
326 | + if ($sum > 0) { |
|
327 | 327 | $results_by_gen[$gen]['sum'] = $sum; |
328 | 328 | $results_by_gen[$gen]['other'] = $other; |
329 | 329 | $results_by_gen[$gen]['unknown'] = $unknown; |
330 | 330 | $results_by_gen[$gen]['places'] = array(); |
331 | 331 | arsort($genData['places']); |
332 | 332 | |
333 | - if($display_all_places){ |
|
334 | - foreach($genData['places'] as $placename=> $count){ |
|
333 | + if ($display_all_places) { |
|
334 | + foreach ($genData['places'] as $placename=> $count) { |
|
335 | 335 | $results_by_gen[$gen]['places'][$placename]['count'] = $count; |
336 | 336 | |
337 | - if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){ |
|
337 | + if ($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != '') { |
|
338 | 338 | $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, Globals::getTree()); |
339 | 339 | $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
340 | 340 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | } |
343 | 343 | else { |
344 | 344 | $tmp = $genData['places']; |
345 | - if($other > 0) { |
|
345 | + if ($other > 0) { |
|
346 | 346 | $tmp = array_slice($tmp, 0, 5, true); |
347 | 347 | $tmp['other'] = $other; |
348 | 348 | arsort($tmp); |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | |
359 | 359 | } |
360 | 360 | else { |
361 | - $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
|
361 | + $html = '<p class="warning">'.I18N::translate('No data is available for the generations analysis.').'</p>'; |
|
362 | 362 | } |
363 | 363 | return $html; |
364 | 364 | } |
@@ -144,14 +144,15 @@ discard block |
||
144 | 144 | $this->provider->setGeoAnalysisStatus($ga, $status); |
145 | 145 | $res['status'] = $status; |
146 | 146 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
147 | - } |
|
148 | - catch (\Exception $ex) { |
|
147 | + } catch (\Exception $ex) { |
|
149 | 148 | $res['error'] = $ex->getMessage(); |
150 | 149 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
151 | 150 | } |
152 | 151 | |
153 | 152 | $controller->pageHeader(); |
154 | - if($res['error']) http_response_code(500); |
|
153 | + if($res['error']) { |
|
154 | + http_response_code(500); |
|
155 | + } |
|
155 | 156 | |
156 | 157 | $controller->encode($res); |
157 | 158 | } |
@@ -175,14 +176,15 @@ discard block |
||
175 | 176 | try{ |
176 | 177 | $this->provider->deleteGeoAnalysis($ga); |
177 | 178 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
178 | - } |
|
179 | - catch (\Exception $ex) { |
|
179 | + } catch (\Exception $ex) { |
|
180 | 180 | $res['error'] = $ex->getMessage(); |
181 | 181 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage()); |
182 | 182 | } |
183 | 183 | |
184 | 184 | $controller->pageHeader(); |
185 | - if($res['error']) http_response_code(500); |
|
185 | + if($res['error']) { |
|
186 | + http_response_code(500); |
|
187 | + } |
|
186 | 188 | |
187 | 189 | $controller->encode($res); |
188 | 190 | } |
@@ -234,7 +236,9 @@ discard block |
||
234 | 236 | |
235 | 237 | $nb_found = $placesGeneralResults['knownsum']; |
236 | 238 | $nb_other = 0; |
237 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
239 | + if(isset($placesGeneralResults['other'])) { |
|
240 | + $nb_other =$placesGeneralResults['other']; |
|
241 | + } |
|
238 | 242 | $nb_unknown = $placesGeneralResults['unknown']; |
239 | 243 | |
240 | 244 | $data->set('stats_gen_nb_found', $nb_found); |
@@ -255,11 +259,12 @@ discard block |
||
255 | 259 | if($level_map >= 0 && $level_map < count($levelvalues)) { |
256 | 260 | $levelref = $levelvalues[0] . '@' . $levelvalues[$level_map]; |
257 | 261 | if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
258 | - } |
|
259 | - else { |
|
262 | + } else { |
|
260 | 263 | $levelref = $levelvalues[0]; |
261 | 264 | } |
262 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
265 | + if(isset($places_mappings[$levelref])) { |
|
266 | + $levelref = $places_mappings[$levelref]; |
|
267 | + } |
|
263 | 268 | if(isset($results_by_subdivs[$levelref])) { |
264 | 269 | $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
265 | 270 | $count_subd += $count; |
@@ -277,8 +282,7 @@ discard block |
||
277 | 282 | } |
278 | 283 | |
279 | 284 | $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
280 | - } |
|
281 | - else { |
|
285 | + } else { |
|
282 | 286 | $results = $placesGeneralResults['places']; |
283 | 287 | arsort($results); |
284 | 288 | $data->set('results', $results); |
@@ -286,8 +290,7 @@ discard block |
||
286 | 290 | |
287 | 291 | $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
288 | 292 | } |
289 | - } |
|
290 | - else { |
|
293 | + } else { |
|
291 | 294 | $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
292 | 295 | } |
293 | 296 | return $html; |
@@ -319,9 +322,15 @@ discard block |
||
319 | 322 | $sum = 0; |
320 | 323 | $other = 0; |
321 | 324 | $unknown = 0; |
322 | - if(isset($genData['sum'])) $sum = $genData['sum']; |
|
323 | - if(isset($genData['other'])) $other = $genData['other']; |
|
324 | - if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
325 | + if(isset($genData['sum'])) { |
|
326 | + $sum = $genData['sum']; |
|
327 | + } |
|
328 | + if(isset($genData['other'])) { |
|
329 | + $other = $genData['other']; |
|
330 | + } |
|
331 | + if(isset($genData['unknown'])) { |
|
332 | + $unknown = $genData['unknown']; |
|
333 | + } |
|
325 | 334 | |
326 | 335 | if($sum > 0) { |
327 | 336 | $results_by_gen[$gen]['sum'] = $sum; |
@@ -339,8 +348,7 @@ discard block |
||
339 | 348 | $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
340 | 349 | } |
341 | 350 | } |
342 | - } |
|
343 | - else { |
|
351 | + } else { |
|
344 | 352 | $tmp = $genData['places']; |
345 | 353 | if($other > 0) { |
346 | 354 | $tmp = array_slice($tmp, 0, 5, true); |
@@ -356,8 +364,7 @@ discard block |
||
356 | 364 | |
357 | 365 | $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
358 | 366 | |
359 | - } |
|
360 | - else { |
|
367 | + } else { |
|
361 | 368 | $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
362 | 369 | } |
363 | 370 | return $html; |
@@ -21,187 +21,187 @@ |
||
21 | 21 | * Name of the file containing the description of the map. |
22 | 22 | * @var string $filename |
23 | 23 | */ |
24 | - protected $filename; |
|
24 | + protected $filename; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Indicates whether the description has been loaded from the file. |
28 | 28 | * @var bool $is_loaded |
29 | 29 | */ |
30 | - protected $is_loaded; |
|
30 | + protected $is_loaded; |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Description/title of the map. |
34 | 34 | * @var string $description |
35 | 35 | */ |
36 | - protected $description; |
|
36 | + protected $description; |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Name(s) of the parent level(s) of the map. |
40 | 40 | * @var string $is_loaded |
41 | 41 | */ |
42 | - protected $top_level_name; |
|
43 | - |
|
44 | - /** |
|
45 | - * Map canvas |
|
46 | - * @var OutlineMapCanvas $canvas |
|
47 | - */ |
|
48 | - protected $canvas; |
|
49 | - |
|
50 | - /** |
|
51 | - * Map subdivisions |
|
52 | - * @var array $subdivisions |
|
53 | - */ |
|
54 | - protected $subdivisions; |
|
55 | - |
|
56 | - /** |
|
57 | - * Places mappings |
|
58 | - * @var array $subdivisions |
|
59 | - */ |
|
60 | - protected $mappings; |
|
61 | - |
|
62 | - /** |
|
63 | - * Constructor for GeoAnalysisMap. |
|
64 | - * |
|
65 | - * @param string $filename Outline map file name |
|
66 | - * @param bool $load Should the map be loaded immediately |
|
67 | - */ |
|
68 | - public function __construct($filename, $load = false) { |
|
69 | - $this->filename = $filename; |
|
70 | - $this->is_loaded = false; |
|
71 | - $this->subdivisions = array(); |
|
72 | - $this->mappings = array(); |
|
73 | - if($load) $this->load(); |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Load the map settings contained within its XML representation |
|
78 | - * |
|
79 | - * XML structure : |
|
80 | - * - displayName : Display name of the map |
|
81 | - * - topLevel : Values of the top level subdivisions (separated by commas, if multiple) |
|
82 | - * - canvas : all settings related to the map canvas. |
|
83 | - * - width : canvas width, in px |
|
84 | - * - height : canvas height, in px |
|
85 | - * - maxcolor : color to identify places with ancestors, RGB hexadecimal |
|
86 | - * - hovercolor : same as previous, color when mouse is hovering the place, RGB hexadecimal |
|
87 | - * - bgcolor : map background color, RGB hexadecimal |
|
88 | - * - bgstroke : map stroke color, RGB hexadecimal |
|
89 | - * - defaultcolor : default color of places, RGB hexadecimal |
|
90 | - * - defaultstroke : default stroke color, RGB hexadecimal |
|
91 | - * - subdvisions : for each subdivision : |
|
42 | + protected $top_level_name; |
|
43 | + |
|
44 | + /** |
|
45 | + * Map canvas |
|
46 | + * @var OutlineMapCanvas $canvas |
|
47 | + */ |
|
48 | + protected $canvas; |
|
49 | + |
|
50 | + /** |
|
51 | + * Map subdivisions |
|
52 | + * @var array $subdivisions |
|
53 | + */ |
|
54 | + protected $subdivisions; |
|
55 | + |
|
56 | + /** |
|
57 | + * Places mappings |
|
58 | + * @var array $subdivisions |
|
59 | + */ |
|
60 | + protected $mappings; |
|
61 | + |
|
62 | + /** |
|
63 | + * Constructor for GeoAnalysisMap. |
|
64 | + * |
|
65 | + * @param string $filename Outline map file name |
|
66 | + * @param bool $load Should the map be loaded immediately |
|
67 | + */ |
|
68 | + public function __construct($filename, $load = false) { |
|
69 | + $this->filename = $filename; |
|
70 | + $this->is_loaded = false; |
|
71 | + $this->subdivisions = array(); |
|
72 | + $this->mappings = array(); |
|
73 | + if($load) $this->load(); |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Load the map settings contained within its XML representation |
|
78 | + * |
|
79 | + * XML structure : |
|
80 | + * - displayName : Display name of the map |
|
81 | + * - topLevel : Values of the top level subdivisions (separated by commas, if multiple) |
|
82 | + * - canvas : all settings related to the map canvas. |
|
83 | + * - width : canvas width, in px |
|
84 | + * - height : canvas height, in px |
|
85 | + * - maxcolor : color to identify places with ancestors, RGB hexadecimal |
|
86 | + * - hovercolor : same as previous, color when mouse is hovering the place, RGB hexadecimal |
|
87 | + * - bgcolor : map background color, RGB hexadecimal |
|
88 | + * - bgstroke : map stroke color, RGB hexadecimal |
|
89 | + * - defaultcolor : default color of places, RGB hexadecimal |
|
90 | + * - defaultstroke : default stroke color, RGB hexadecimal |
|
91 | + * - subdvisions : for each subdivision : |
|
92 | 92 | * - id : Subdivision id, must be compatible with PHP variable constraints, and unique |
93 | - * - name: Display name for the place |
|
93 | + * - name: Display name for the place |
|
94 | 94 | * - parent: if any, describe to which parent level the place if belonging to |
95 | - * - <em>Element value<em> : SVG description of the subdvision shape |
|
95 | + * - <em>Element value<em> : SVG description of the subdvision shape |
|
96 | 96 | * - mapping : for each subdivision : |
97 | 97 | * - name : Name of the place to map |
98 | - * - mapto: Name of the place to map to |
|
98 | + * - mapto: Name of the place to map to |
|
99 | 99 | * |
100 | - */ |
|
101 | - protected function load() { |
|
102 | - if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){ |
|
103 | - $xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename); |
|
104 | - if($xml){ |
|
105 | - $this->description = trim($xml->displayName); |
|
106 | - $this->top_level_name = trim($xml->topLevel); |
|
107 | - $this->canvas = new OutlineMapCanvas( |
|
108 | - trim($xml->canvas->width), |
|
109 | - trim($xml->canvas->height), |
|
110 | - trim($xml->canvas->maxcolor), |
|
111 | - trim($xml->canvas->hovercolor), |
|
112 | - trim($xml->canvas->bgcolor), |
|
113 | - trim($xml->canvas->bgstroke), |
|
114 | - trim($xml->canvas->defaultcolor), |
|
115 | - trim($xml->canvas->defaultstroke) |
|
116 | - ); |
|
117 | - foreach($xml->subdivisions->children() as $subdivision){ |
|
118 | - $attributes = $subdivision->attributes(); |
|
119 | - $key = trim($attributes['name']); |
|
120 | - if(isset($attributes['parent'])) $key .= '@'.trim($attributes['parent']); |
|
121 | - $this->subdivisions[$key] = array( |
|
122 | - 'id' => trim($attributes['id']), |
|
123 | - 'displayname' => trim($attributes['name']), |
|
124 | - 'coord' => trim($subdivision[0]) |
|
125 | - ); |
|
126 | - } |
|
127 | - if(isset($xml->mappings)) { |
|
128 | - foreach($xml->mappings->children() as $mappings){ |
|
129 | - $attributes = $mappings->attributes(); |
|
130 | - $this->mappings[trim($attributes['name'])] = trim($attributes['mapto']); |
|
131 | - } |
|
132 | - } |
|
133 | - $this->is_loaded = true; |
|
134 | - return; |
|
135 | - } |
|
136 | - } |
|
137 | - throw new \Exception('The Outline Map could not be loaded from XML.'); |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Get the status of the map loading from the XML file. |
|
142 | - * |
|
143 | - * @return bool |
|
144 | - */ |
|
145 | - public function isLoaded() { |
|
146 | - try{ |
|
147 | - if(!$this->is_loaded) $this->load(); |
|
148 | - } |
|
149 | - catch (\Exception $ex) { } |
|
150 | - return $this->is_loaded; |
|
151 | - } |
|
100 | + */ |
|
101 | + protected function load() { |
|
102 | + if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){ |
|
103 | + $xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename); |
|
104 | + if($xml){ |
|
105 | + $this->description = trim($xml->displayName); |
|
106 | + $this->top_level_name = trim($xml->topLevel); |
|
107 | + $this->canvas = new OutlineMapCanvas( |
|
108 | + trim($xml->canvas->width), |
|
109 | + trim($xml->canvas->height), |
|
110 | + trim($xml->canvas->maxcolor), |
|
111 | + trim($xml->canvas->hovercolor), |
|
112 | + trim($xml->canvas->bgcolor), |
|
113 | + trim($xml->canvas->bgstroke), |
|
114 | + trim($xml->canvas->defaultcolor), |
|
115 | + trim($xml->canvas->defaultstroke) |
|
116 | + ); |
|
117 | + foreach($xml->subdivisions->children() as $subdivision){ |
|
118 | + $attributes = $subdivision->attributes(); |
|
119 | + $key = trim($attributes['name']); |
|
120 | + if(isset($attributes['parent'])) $key .= '@'.trim($attributes['parent']); |
|
121 | + $this->subdivisions[$key] = array( |
|
122 | + 'id' => trim($attributes['id']), |
|
123 | + 'displayname' => trim($attributes['name']), |
|
124 | + 'coord' => trim($subdivision[0]) |
|
125 | + ); |
|
126 | + } |
|
127 | + if(isset($xml->mappings)) { |
|
128 | + foreach($xml->mappings->children() as $mappings){ |
|
129 | + $attributes = $mappings->attributes(); |
|
130 | + $this->mappings[trim($attributes['name'])] = trim($attributes['mapto']); |
|
131 | + } |
|
132 | + } |
|
133 | + $this->is_loaded = true; |
|
134 | + return; |
|
135 | + } |
|
136 | + } |
|
137 | + throw new \Exception('The Outline Map could not be loaded from XML.'); |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Get the status of the map loading from the XML file. |
|
142 | + * |
|
143 | + * @return bool |
|
144 | + */ |
|
145 | + public function isLoaded() { |
|
146 | + try{ |
|
147 | + if(!$this->is_loaded) $this->load(); |
|
148 | + } |
|
149 | + catch (\Exception $ex) { } |
|
150 | + return $this->is_loaded; |
|
151 | + } |
|
152 | 152 | |
153 | 153 | /** |
154 | 154 | * Get the map file name. |
155 | 155 | * @return string |
156 | 156 | */ |
157 | - public function getFileName() { |
|
158 | - return $this->filename; |
|
159 | - } |
|
157 | + public function getFileName() { |
|
158 | + return $this->filename; |
|
159 | + } |
|
160 | 160 | |
161 | 161 | /** |
162 | 162 | * Get the map file name. |
163 | 163 | * @return string |
164 | 164 | */ |
165 | - public function getDescription() { |
|
166 | - if(!$this->is_loaded) $this->load(); |
|
167 | - return $this->description; |
|
168 | - } |
|
165 | + public function getDescription() { |
|
166 | + if(!$this->is_loaded) $this->load(); |
|
167 | + return $this->description; |
|
168 | + } |
|
169 | 169 | |
170 | 170 | /** |
171 | 171 | * Get the name of the map parent level. |
172 | 172 | * @return string |
173 | 173 | */ |
174 | - public function getTopLevelName() { |
|
175 | - if(!$this->is_loaded) $this->load(); |
|
176 | - return $this->top_level_name; |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * Get the Outline Map canvas. |
|
181 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
|
182 | - */ |
|
183 | - public function getCanvas() { |
|
184 | - if(!$this->is_loaded) $this->load(); |
|
185 | - return $this->canvas; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Get the subdivisions of the map. |
|
190 | - * @return array |
|
191 | - */ |
|
192 | - public function getSubdivisions() { |
|
193 | - if(!$this->is_loaded) $this->load(); |
|
194 | - return $this->subdivisions; |
|
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * Get the places mappings of the map. |
|
199 | - * @return array |
|
200 | - */ |
|
201 | - public function getPlacesMappings() { |
|
202 | - if(!$this->is_loaded) $this->load(); |
|
203 | - return $this->mappings; |
|
204 | - } |
|
174 | + public function getTopLevelName() { |
|
175 | + if(!$this->is_loaded) $this->load(); |
|
176 | + return $this->top_level_name; |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * Get the Outline Map canvas. |
|
181 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
|
182 | + */ |
|
183 | + public function getCanvas() { |
|
184 | + if(!$this->is_loaded) $this->load(); |
|
185 | + return $this->canvas; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Get the subdivisions of the map. |
|
190 | + * @return array |
|
191 | + */ |
|
192 | + public function getSubdivisions() { |
|
193 | + if(!$this->is_loaded) $this->load(); |
|
194 | + return $this->subdivisions; |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * Get the places mappings of the map. |
|
199 | + * @return array |
|
200 | + */ |
|
201 | + public function getPlacesMappings() { |
|
202 | + if(!$this->is_loaded) $this->load(); |
|
203 | + return $this->mappings; |
|
204 | + } |
|
205 | 205 | |
206 | 206 | } |
207 | 207 | |
208 | 208 | \ No newline at end of file |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $this->is_loaded = false; |
71 | 71 | $this->subdivisions = array(); |
72 | 72 | $this->mappings = array(); |
73 | - if($load) $this->load(); |
|
73 | + if ($load) $this->load(); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | * |
100 | 100 | */ |
101 | 101 | protected function load() { |
102 | - if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){ |
|
102 | + if (file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)) { |
|
103 | 103 | $xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename); |
104 | - if($xml){ |
|
104 | + if ($xml) { |
|
105 | 105 | $this->description = trim($xml->displayName); |
106 | 106 | $this->top_level_name = trim($xml->topLevel); |
107 | 107 | $this->canvas = new OutlineMapCanvas( |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | trim($xml->canvas->defaultcolor), |
115 | 115 | trim($xml->canvas->defaultstroke) |
116 | 116 | ); |
117 | - foreach($xml->subdivisions->children() as $subdivision){ |
|
117 | + foreach ($xml->subdivisions->children() as $subdivision) { |
|
118 | 118 | $attributes = $subdivision->attributes(); |
119 | 119 | $key = trim($attributes['name']); |
120 | - if(isset($attributes['parent'])) $key .= '@'.trim($attributes['parent']); |
|
120 | + if (isset($attributes['parent'])) $key .= '@'.trim($attributes['parent']); |
|
121 | 121 | $this->subdivisions[$key] = array( |
122 | 122 | 'id' => trim($attributes['id']), |
123 | 123 | 'displayname' => trim($attributes['name']), |
124 | 124 | 'coord' => trim($subdivision[0]) |
125 | 125 | ); |
126 | 126 | } |
127 | - if(isset($xml->mappings)) { |
|
128 | - foreach($xml->mappings->children() as $mappings){ |
|
127 | + if (isset($xml->mappings)) { |
|
128 | + foreach ($xml->mappings->children() as $mappings) { |
|
129 | 129 | $attributes = $mappings->attributes(); |
130 | 130 | $this->mappings[trim($attributes['name'])] = trim($attributes['mapto']); |
131 | 131 | } |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * @return bool |
144 | 144 | */ |
145 | 145 | public function isLoaded() { |
146 | - try{ |
|
147 | - if(!$this->is_loaded) $this->load(); |
|
146 | + try { |
|
147 | + if (!$this->is_loaded) $this->load(); |
|
148 | 148 | } |
149 | 149 | catch (\Exception $ex) { } |
150 | 150 | return $this->is_loaded; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @return string |
164 | 164 | */ |
165 | 165 | public function getDescription() { |
166 | - if(!$this->is_loaded) $this->load(); |
|
166 | + if (!$this->is_loaded) $this->load(); |
|
167 | 167 | return $this->description; |
168 | 168 | } |
169 | 169 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @return string |
173 | 173 | */ |
174 | 174 | public function getTopLevelName() { |
175 | - if(!$this->is_loaded) $this->load(); |
|
175 | + if (!$this->is_loaded) $this->load(); |
|
176 | 176 | return $this->top_level_name; |
177 | 177 | } |
178 | 178 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
182 | 182 | */ |
183 | 183 | public function getCanvas() { |
184 | - if(!$this->is_loaded) $this->load(); |
|
184 | + if (!$this->is_loaded) $this->load(); |
|
185 | 185 | return $this->canvas; |
186 | 186 | } |
187 | 187 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @return array |
191 | 191 | */ |
192 | 192 | public function getSubdivisions() { |
193 | - if(!$this->is_loaded) $this->load(); |
|
193 | + if (!$this->is_loaded) $this->load(); |
|
194 | 194 | return $this->subdivisions; |
195 | 195 | } |
196 | 196 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @return array |
200 | 200 | */ |
201 | 201 | public function getPlacesMappings() { |
202 | - if(!$this->is_loaded) $this->load(); |
|
202 | + if (!$this->is_loaded) $this->load(); |
|
203 | 203 | return $this->mappings; |
204 | 204 | } |
205 | 205 |
@@ -70,7 +70,9 @@ discard block |
||
70 | 70 | $this->is_loaded = false; |
71 | 71 | $this->subdivisions = array(); |
72 | 72 | $this->mappings = array(); |
73 | - if($load) $this->load(); |
|
73 | + if($load) { |
|
74 | + $this->load(); |
|
75 | + } |
|
74 | 76 | } |
75 | 77 | |
76 | 78 | /** |
@@ -117,7 +119,9 @@ discard block |
||
117 | 119 | foreach($xml->subdivisions->children() as $subdivision){ |
118 | 120 | $attributes = $subdivision->attributes(); |
119 | 121 | $key = trim($attributes['name']); |
120 | - if(isset($attributes['parent'])) $key .= '@'.trim($attributes['parent']); |
|
122 | + if(isset($attributes['parent'])) { |
|
123 | + $key .= '@'.trim($attributes['parent']); |
|
124 | + } |
|
121 | 125 | $this->subdivisions[$key] = array( |
122 | 126 | 'id' => trim($attributes['id']), |
123 | 127 | 'displayname' => trim($attributes['name']), |
@@ -144,9 +148,10 @@ discard block |
||
144 | 148 | */ |
145 | 149 | public function isLoaded() { |
146 | 150 | try{ |
147 | - if(!$this->is_loaded) $this->load(); |
|
148 | - } |
|
149 | - catch (\Exception $ex) { } |
|
151 | + if(!$this->is_loaded) { |
|
152 | + $this->load(); |
|
153 | + } |
|
154 | + } catch (\Exception $ex) { } |
|
150 | 155 | return $this->is_loaded; |
151 | 156 | } |
152 | 157 | |
@@ -163,7 +168,9 @@ discard block |
||
163 | 168 | * @return string |
164 | 169 | */ |
165 | 170 | public function getDescription() { |
166 | - if(!$this->is_loaded) $this->load(); |
|
171 | + if(!$this->is_loaded) { |
|
172 | + $this->load(); |
|
173 | + } |
|
167 | 174 | return $this->description; |
168 | 175 | } |
169 | 176 | |
@@ -172,7 +179,9 @@ discard block |
||
172 | 179 | * @return string |
173 | 180 | */ |
174 | 181 | public function getTopLevelName() { |
175 | - if(!$this->is_loaded) $this->load(); |
|
182 | + if(!$this->is_loaded) { |
|
183 | + $this->load(); |
|
184 | + } |
|
176 | 185 | return $this->top_level_name; |
177 | 186 | } |
178 | 187 | |
@@ -181,7 +190,9 @@ discard block |
||
181 | 190 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
182 | 191 | */ |
183 | 192 | public function getCanvas() { |
184 | - if(!$this->is_loaded) $this->load(); |
|
193 | + if(!$this->is_loaded) { |
|
194 | + $this->load(); |
|
195 | + } |
|
185 | 196 | return $this->canvas; |
186 | 197 | } |
187 | 198 | |
@@ -190,7 +201,9 @@ discard block |
||
190 | 201 | * @return array |
191 | 202 | */ |
192 | 203 | public function getSubdivisions() { |
193 | - if(!$this->is_loaded) $this->load(); |
|
204 | + if(!$this->is_loaded) { |
|
205 | + $this->load(); |
|
206 | + } |
|
194 | 207 | return $this->subdivisions; |
195 | 208 | } |
196 | 209 | |
@@ -199,7 +212,9 @@ discard block |
||
199 | 212 | * @return array |
200 | 213 | */ |
201 | 214 | public function getPlacesMappings() { |
202 | - if(!$this->is_loaded) $this->load(); |
|
215 | + if(!$this->is_loaded) { |
|
216 | + $this->load(); |
|
217 | + } |
|
203 | 218 | return $this->mappings; |
204 | 219 | } |
205 | 220 |
@@ -21,130 +21,130 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class GeoAnalysisProvider { |
23 | 23 | |
24 | - /** |
|
25 | - * Reference tree |
|
26 | - * @var Tree $tree |
|
27 | - */ |
|
28 | - protected $tree; |
|
24 | + /** |
|
25 | + * Reference tree |
|
26 | + * @var Tree $tree |
|
27 | + */ |
|
28 | + protected $tree; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Cached hierarchy of places in the Gedcom file. |
|
32 | - * |
|
33 | - * @var (array|null) $place_hierarchy |
|
34 | - */ |
|
35 | - protected $place_hierarchy; |
|
30 | + /** |
|
31 | + * Cached hierarchy of places in the Gedcom file. |
|
32 | + * |
|
33 | + * @var (array|null) $place_hierarchy |
|
34 | + */ |
|
35 | + protected $place_hierarchy; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor for GeoAnalysis Provider. |
|
39 | - * A provider is defined in relation to a specific tree. |
|
40 | - * |
|
41 | - * @param Tree $tree |
|
42 | - */ |
|
43 | - public function __construct(Tree $tree) { |
|
44 | - $this->tree = $tree; |
|
45 | - $this->place_hierarchy = null; |
|
46 | - } |
|
37 | + /** |
|
38 | + * Constructor for GeoAnalysis Provider. |
|
39 | + * A provider is defined in relation to a specific tree. |
|
40 | + * |
|
41 | + * @param Tree $tree |
|
42 | + */ |
|
43 | + public function __construct(Tree $tree) { |
|
44 | + $this->tree = $tree; |
|
45 | + $this->place_hierarchy = null; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Creates and returns a GeoAnalysis object from a data row. |
|
50 | - * The row data is expected to be an array with the indexes: |
|
51 | - * - majgd_id: geodispersion analysis ID |
|
52 | - * - majgd_descr: geodispersion analysis description/title |
|
53 | - * - majgd_sublevel: Analysis level |
|
54 | - * - majgd_useflagsgen: Use flags in places display |
|
55 | - * - majgd_detailsgen: Number of top places |
|
56 | - * - majgd_map: file name of the map |
|
57 | - * - majgd_toplevel: parent level for the map |
|
58 | - * |
|
59 | - * @param array $row |
|
60 | - * @return GeoAnalysis |
|
61 | - */ |
|
62 | - protected function loadGeoAnalysisFromRow($row) { |
|
63 | - $options = new GeoDisplayOptions(); |
|
64 | - $options |
|
65 | - ->setUsingFlags($row['majgd_useflagsgen'] == 'yes') |
|
66 | - ->setMaxDetailsInGen($row['majgd_detailsgen']); |
|
48 | + /** |
|
49 | + * Creates and returns a GeoAnalysis object from a data row. |
|
50 | + * The row data is expected to be an array with the indexes: |
|
51 | + * - majgd_id: geodispersion analysis ID |
|
52 | + * - majgd_descr: geodispersion analysis description/title |
|
53 | + * - majgd_sublevel: Analysis level |
|
54 | + * - majgd_useflagsgen: Use flags in places display |
|
55 | + * - majgd_detailsgen: Number of top places |
|
56 | + * - majgd_map: file name of the map |
|
57 | + * - majgd_toplevel: parent level for the map |
|
58 | + * |
|
59 | + * @param array $row |
|
60 | + * @return GeoAnalysis |
|
61 | + */ |
|
62 | + protected function loadGeoAnalysisFromRow($row) { |
|
63 | + $options = new GeoDisplayOptions(); |
|
64 | + $options |
|
65 | + ->setUsingFlags($row['majgd_useflagsgen'] == 'yes') |
|
66 | + ->setMaxDetailsInGen($row['majgd_detailsgen']); |
|
67 | 67 | |
68 | - if($row['majgd_map']) { |
|
69 | - $options |
|
70 | - ->setMap(new OutlineMap($row['majgd_map'])) |
|
71 | - ->setMapLevel($row['majgd_toplevel']); |
|
72 | - } |
|
68 | + if($row['majgd_map']) { |
|
69 | + $options |
|
70 | + ->setMap(new OutlineMap($row['majgd_map'])) |
|
71 | + ->setMapLevel($row['majgd_toplevel']); |
|
72 | + } |
|
73 | 73 | |
74 | - $enabled = true; |
|
75 | - if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
76 | - $enabled = false; |
|
77 | - } |
|
74 | + $enabled = true; |
|
75 | + if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
76 | + $enabled = false; |
|
77 | + } |
|
78 | 78 | |
79 | - return new GeoAnalysis( |
|
80 | - $this->tree, |
|
81 | - $row['majgd_id'], |
|
82 | - $row['majgd_descr'], |
|
83 | - $row['majgd_sublevel'], |
|
84 | - $options, |
|
85 | - $enabled |
|
86 | - ); |
|
87 | - } |
|
79 | + return new GeoAnalysis( |
|
80 | + $this->tree, |
|
81 | + $row['majgd_id'], |
|
82 | + $row['majgd_descr'], |
|
83 | + $row['majgd_sublevel'], |
|
84 | + $options, |
|
85 | + $enabled |
|
86 | + ); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Returns the number of geographical analysis (active and inactive). |
|
91 | - * |
|
92 | - * @return int |
|
93 | - */ |
|
94 | - public function getGeoAnalysisCount() { |
|
95 | - return Database::prepare( |
|
96 | - 'SELECT COUNT(majgd_id)' . |
|
97 | - ' FROM `##maj_geodispersion`' . |
|
98 | - ' WHERE majgd_file = :gedcom_id' |
|
99 | - )->execute(array( |
|
100 | - 'gedcom_id' => $this->tree->getTreeId() |
|
101 | - ))->fetchOne(); |
|
102 | - } |
|
89 | + /** |
|
90 | + * Returns the number of geographical analysis (active and inactive). |
|
91 | + * |
|
92 | + * @return int |
|
93 | + */ |
|
94 | + public function getGeoAnalysisCount() { |
|
95 | + return Database::prepare( |
|
96 | + 'SELECT COUNT(majgd_id)' . |
|
97 | + ' FROM `##maj_geodispersion`' . |
|
98 | + ' WHERE majgd_file = :gedcom_id' |
|
99 | + )->execute(array( |
|
100 | + 'gedcom_id' => $this->tree->getTreeId() |
|
101 | + ))->fetchOne(); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Get a geographical analysis by its ID. |
|
106 | - * The function can only search for only enabled analysis, or all. |
|
107 | - * |
|
108 | - * @param int $id geodispersion analysis ID |
|
109 | - * @param bool $only_enabled Search for only enabled geodispersion analysis |
|
110 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL |
|
111 | - */ |
|
112 | - public function getGeoAnalysis($id, $only_enabled = true) { |
|
113 | - $args = array ( |
|
114 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
115 | - 'ga_id' => $id |
|
116 | - ); |
|
104 | + /** |
|
105 | + * Get a geographical analysis by its ID. |
|
106 | + * The function can only search for only enabled analysis, or all. |
|
107 | + * |
|
108 | + * @param int $id geodispersion analysis ID |
|
109 | + * @param bool $only_enabled Search for only enabled geodispersion analysis |
|
110 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL |
|
111 | + */ |
|
112 | + public function getGeoAnalysis($id, $only_enabled = true) { |
|
113 | + $args = array ( |
|
114 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
115 | + 'ga_id' => $id |
|
116 | + ); |
|
117 | 117 | |
118 | - $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
119 | - ' FROM `##maj_geodispersion`' . |
|
120 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; |
|
121 | - if($only_enabled) { |
|
122 | - $sql .= ' AND majgd_status = :status'; |
|
123 | - $args['status'] = 'enabled'; |
|
124 | - } |
|
125 | - $sql .= ' ORDER BY majgd_descr'; |
|
118 | + $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
119 | + ' FROM `##maj_geodispersion`' . |
|
120 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; |
|
121 | + if($only_enabled) { |
|
122 | + $sql .= ' AND majgd_status = :status'; |
|
123 | + $args['status'] = 'enabled'; |
|
124 | + } |
|
125 | + $sql .= ' ORDER BY majgd_descr'; |
|
126 | 126 | |
127 | - $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); |
|
127 | + $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); |
|
128 | 128 | |
129 | - if($ga_array) { |
|
130 | - return $this->loadGeoAnalysisFromRow($ga_array); |
|
131 | - } |
|
129 | + if($ga_array) { |
|
130 | + return $this->loadGeoAnalysisFromRow($ga_array); |
|
131 | + } |
|
132 | 132 | |
133 | - return null; |
|
134 | - } |
|
133 | + return null; |
|
134 | + } |
|
135 | 135 | |
136 | - /** |
|
137 | - * Add a new geodispersion analysis in the database, in a transactional manner. |
|
138 | - * When successful, eturns the newly created GeoAnalysis object. |
|
139 | - * |
|
140 | - * @param string $description geodispersion analysis title |
|
141 | - * @param int $analysis_level Analysis level |
|
142 | - * @param string $map_file Filename of the map |
|
143 | - * @param int $map_top_level Parent level of the map |
|
144 | - * @param bool $use_flags Use flag in the place display |
|
145 | - * @param int $gen_details Number of top places to display |
|
146 | - * @return GeoAnalysis |
|
147 | - */ |
|
136 | + /** |
|
137 | + * Add a new geodispersion analysis in the database, in a transactional manner. |
|
138 | + * When successful, eturns the newly created GeoAnalysis object. |
|
139 | + * |
|
140 | + * @param string $description geodispersion analysis title |
|
141 | + * @param int $analysis_level Analysis level |
|
142 | + * @param string $map_file Filename of the map |
|
143 | + * @param int $map_top_level Parent level of the map |
|
144 | + * @param bool $use_flags Use flag in the place display |
|
145 | + * @param int $gen_details Number of top places to display |
|
146 | + * @return GeoAnalysis |
|
147 | + */ |
|
148 | 148 | public function createGeoAnalysis($description, $analysis_level, $map_file, $map_top_level, $use_flags, $gen_details) { |
149 | 149 | try{ |
150 | 150 | Database::beginTransaction(); |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage()); |
175 | 175 | } |
176 | 176 | return $ga; |
177 | - } |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Update a geodispersion analysis in the database, in transactional manner. |
|
181 | - * When successful, returns the updated GeoAnalysis object |
|
182 | - * |
|
183 | - * @param GeoAnalysis $ga |
|
184 | - * @return GeoAnalysis |
|
185 | - */ |
|
186 | - public function updateGeoAnalysis(GeoAnalysis $ga) { |
|
187 | - try { |
|
179 | + /** |
|
180 | + * Update a geodispersion analysis in the database, in transactional manner. |
|
181 | + * When successful, returns the updated GeoAnalysis object |
|
182 | + * |
|
183 | + * @param GeoAnalysis $ga |
|
184 | + * @return GeoAnalysis |
|
185 | + */ |
|
186 | + public function updateGeoAnalysis(GeoAnalysis $ga) { |
|
187 | + try { |
|
188 | 188 | Database::beginTransaction(); |
189 | 189 | |
190 | 190 | Database::prepare( |
@@ -217,236 +217,236 @@ discard block |
||
217 | 217 | $ga = null; |
218 | 218 | } |
219 | 219 | return $ga; |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - /** |
|
223 | - * Set the status of a specific analysis. |
|
224 | - * The status can be enabled (true), or disabled (false). |
|
225 | - * |
|
226 | - * @param GeoAnalysis $ga |
|
227 | - * @param bool $status |
|
228 | - */ |
|
229 | - public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) { |
|
230 | - Database::prepare( |
|
231 | - 'UPDATE `##maj_geodispersion`'. |
|
232 | - ' SET majgd_status = :status'. |
|
233 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
234 | - )->execute(array( |
|
235 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
236 | - 'status' => $status ? 'enabled' : 'disabled', |
|
237 | - 'ga_id' => $ga->getId() |
|
238 | - )); |
|
239 | - } |
|
222 | + /** |
|
223 | + * Set the status of a specific analysis. |
|
224 | + * The status can be enabled (true), or disabled (false). |
|
225 | + * |
|
226 | + * @param GeoAnalysis $ga |
|
227 | + * @param bool $status |
|
228 | + */ |
|
229 | + public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) { |
|
230 | + Database::prepare( |
|
231 | + 'UPDATE `##maj_geodispersion`'. |
|
232 | + ' SET majgd_status = :status'. |
|
233 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
234 | + )->execute(array( |
|
235 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
236 | + 'status' => $status ? 'enabled' : 'disabled', |
|
237 | + 'ga_id' => $ga->getId() |
|
238 | + )); |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Delete a geodispersion analysis from the database. |
|
243 | - * |
|
244 | - * @param GeoAnalysis $ga |
|
245 | - */ |
|
246 | - public function deleteGeoAnalysis(GeoAnalysis $ga) { |
|
247 | - Database::prepare( |
|
248 | - 'DELETE FROM `##maj_geodispersion`'. |
|
249 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
250 | - )->execute(array( |
|
251 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
252 | - 'ga_id' => $ga->getId() |
|
253 | - )); |
|
254 | - } |
|
241 | + /** |
|
242 | + * Delete a geodispersion analysis from the database. |
|
243 | + * |
|
244 | + * @param GeoAnalysis $ga |
|
245 | + */ |
|
246 | + public function deleteGeoAnalysis(GeoAnalysis $ga) { |
|
247 | + Database::prepare( |
|
248 | + 'DELETE FROM `##maj_geodispersion`'. |
|
249 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
250 | + )->execute(array( |
|
251 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
252 | + 'ga_id' => $ga->getId() |
|
253 | + )); |
|
254 | + } |
|
255 | 255 | |
256 | - /** |
|
257 | - * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM |
|
258 | - * |
|
259 | - * @return array List of enabled maps |
|
260 | - */ |
|
261 | - public function getGeoAnalysisList(){ |
|
262 | - $res = array(); |
|
256 | + /** |
|
257 | + * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM |
|
258 | + * |
|
259 | + * @return array List of enabled maps |
|
260 | + */ |
|
261 | + public function getGeoAnalysisList(){ |
|
262 | + $res = array(); |
|
263 | 263 | |
264 | - $list = Database::prepare( |
|
265 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . |
|
266 | - ' FROM `##maj_geodispersion`' . |
|
267 | - ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. |
|
268 | - ' ORDER BY majgd_descr' |
|
269 | - )->execute(array( |
|
270 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
271 | - 'status' => 'enabled' |
|
272 | - ))->fetchAll(\PDO::FETCH_ASSOC); |
|
264 | + $list = Database::prepare( |
|
265 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . |
|
266 | + ' FROM `##maj_geodispersion`' . |
|
267 | + ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. |
|
268 | + ' ORDER BY majgd_descr' |
|
269 | + )->execute(array( |
|
270 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
271 | + 'status' => 'enabled' |
|
272 | + ))->fetchAll(\PDO::FETCH_ASSOC); |
|
273 | 273 | |
274 | - foreach($list as $ga) { |
|
275 | - $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
276 | - } |
|
274 | + foreach($list as $ga) { |
|
275 | + $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
276 | + } |
|
277 | 277 | |
278 | - return $res; |
|
279 | - } |
|
278 | + return $res; |
|
279 | + } |
|
280 | 280 | |
281 | - /** |
|
282 | - * Return the list of geodispersion analysis matching specified criterias. |
|
283 | - * |
|
284 | - * @param string $search Search criteria in analysis description |
|
285 | - * @param array $order_by Columns to order by |
|
286 | - * @param int $start Offset to start with (for pagination) |
|
287 | - * @param int|null $limit Max number of items to return (for pagination) |
|
288 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
289 | - */ |
|
290 | - public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ |
|
291 | - $res = array(); |
|
281 | + /** |
|
282 | + * Return the list of geodispersion analysis matching specified criterias. |
|
283 | + * |
|
284 | + * @param string $search Search criteria in analysis description |
|
285 | + * @param array $order_by Columns to order by |
|
286 | + * @param int $start Offset to start with (for pagination) |
|
287 | + * @param int|null $limit Max number of items to return (for pagination) |
|
288 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
289 | + */ |
|
290 | + public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ |
|
291 | + $res = array(); |
|
292 | 292 | |
293 | - $sql = |
|
294 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
295 | - ' FROM `##maj_geodispersion`' . |
|
296 | - ' WHERE majgd_file = :gedcom_id'; |
|
293 | + $sql = |
|
294 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
295 | + ' FROM `##maj_geodispersion`' . |
|
296 | + ' WHERE majgd_file = :gedcom_id'; |
|
297 | 297 | |
298 | - $args = array('gedcom_id'=> $this->tree->getTreeId()); |
|
298 | + $args = array('gedcom_id'=> $this->tree->getTreeId()); |
|
299 | 299 | |
300 | - if($search) { |
|
301 | - $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; |
|
302 | - $args['search'] = $search; |
|
303 | - } |
|
300 | + if($search) { |
|
301 | + $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; |
|
302 | + $args['search'] = $search; |
|
303 | + } |
|
304 | 304 | |
305 | - if ($order_by) { |
|
306 | - $sql .= ' ORDER BY '; |
|
307 | - foreach ($order_by as $key => $value) { |
|
308 | - if ($key > 0) { |
|
309 | - $sql .= ','; |
|
310 | - } |
|
305 | + if ($order_by) { |
|
306 | + $sql .= ' ORDER BY '; |
|
307 | + foreach ($order_by as $key => $value) { |
|
308 | + if ($key > 0) { |
|
309 | + $sql .= ','; |
|
310 | + } |
|
311 | 311 | |
312 | - switch ($value['dir']) { |
|
313 | - case 'asc': |
|
314 | - $sql .= $value['column'] . ' ASC '; |
|
315 | - break; |
|
316 | - case 'desc': |
|
317 | - $sql .= $value['column'] . ' DESC '; |
|
318 | - break; |
|
319 | - } |
|
320 | - } |
|
321 | - } else { |
|
322 | - $sql .= ' ORDER BY majgd_descr ASC'; |
|
323 | - } |
|
312 | + switch ($value['dir']) { |
|
313 | + case 'asc': |
|
314 | + $sql .= $value['column'] . ' ASC '; |
|
315 | + break; |
|
316 | + case 'desc': |
|
317 | + $sql .= $value['column'] . ' DESC '; |
|
318 | + break; |
|
319 | + } |
|
320 | + } |
|
321 | + } else { |
|
322 | + $sql .= ' ORDER BY majgd_descr ASC'; |
|
323 | + } |
|
324 | 324 | |
325 | - if ($limit) { |
|
326 | - $sql .= " LIMIT :limit OFFSET :offset"; |
|
327 | - $args['limit'] = $limit; |
|
328 | - $args['offset'] = $start; |
|
329 | - } |
|
325 | + if ($limit) { |
|
326 | + $sql .= " LIMIT :limit OFFSET :offset"; |
|
327 | + $args['limit'] = $limit; |
|
328 | + $args['offset'] = $start; |
|
329 | + } |
|
330 | 330 | |
331 | - $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); |
|
331 | + $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); |
|
332 | 332 | |
333 | - foreach($data as $ga) { |
|
334 | - $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
335 | - } |
|
333 | + foreach($data as $ga) { |
|
334 | + $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
335 | + } |
|
336 | 336 | |
337 | - return $res; |
|
338 | - } |
|
337 | + return $res; |
|
338 | + } |
|
339 | 339 | |
340 | - /** |
|
341 | - * Returns the infered place hierarchy, determined from the Gedcom data. |
|
342 | - * Depending on the data, it can be based on the Gedcom Header description, or from a place example. |
|
343 | - * This is returned as an associative array: |
|
344 | - * - type: describe the source of the data (<em>header<em> / <em>data</em>) |
|
345 | - * - hierarchy: an array of the place hierarchy (in reverse order of the gedcom) |
|
346 | - * |
|
347 | - * @return array |
|
348 | - */ |
|
349 | - public function getPlacesHierarchy() { |
|
350 | - if(!$this->place_hierarchy) { |
|
351 | - if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
352 | - $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
|
353 | - } |
|
354 | - else { |
|
355 | - $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData()); |
|
356 | - } |
|
357 | - } |
|
358 | - return $this->place_hierarchy; |
|
359 | - } |
|
340 | + /** |
|
341 | + * Returns the infered place hierarchy, determined from the Gedcom data. |
|
342 | + * Depending on the data, it can be based on the Gedcom Header description, or from a place example. |
|
343 | + * This is returned as an associative array: |
|
344 | + * - type: describe the source of the data (<em>header<em> / <em>data</em>) |
|
345 | + * - hierarchy: an array of the place hierarchy (in reverse order of the gedcom) |
|
346 | + * |
|
347 | + * @return array |
|
348 | + */ |
|
349 | + public function getPlacesHierarchy() { |
|
350 | + if(!$this->place_hierarchy) { |
|
351 | + if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
352 | + $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
|
353 | + } |
|
354 | + else { |
|
355 | + $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData()); |
|
356 | + } |
|
357 | + } |
|
358 | + return $this->place_hierarchy; |
|
359 | + } |
|
360 | 360 | |
361 | - /** |
|
362 | - * Returns an array of the place hierarchy, as defined in the GEDCOM header. |
|
363 | - * The places are reversed compared to normal GEDCOM structure. |
|
364 | - * |
|
365 | - * @return array|null |
|
366 | - */ |
|
367 | - protected function getPlacesHierarchyFromHeader() { |
|
368 | - $head = GedcomRecord::getInstance('HEAD', $this->tree); |
|
369 | - $head_place = $head->getFirstFact('PLAC'); |
|
370 | - if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ |
|
371 | - return array_reverse(array_map('trim',explode(',', $head_place_value))); |
|
372 | - } |
|
373 | - return null; |
|
374 | - } |
|
361 | + /** |
|
362 | + * Returns an array of the place hierarchy, as defined in the GEDCOM header. |
|
363 | + * The places are reversed compared to normal GEDCOM structure. |
|
364 | + * |
|
365 | + * @return array|null |
|
366 | + */ |
|
367 | + protected function getPlacesHierarchyFromHeader() { |
|
368 | + $head = GedcomRecord::getInstance('HEAD', $this->tree); |
|
369 | + $head_place = $head->getFirstFact('PLAC'); |
|
370 | + if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ |
|
371 | + return array_reverse(array_map('trim',explode(',', $head_place_value))); |
|
372 | + } |
|
373 | + return null; |
|
374 | + } |
|
375 | 375 | |
376 | - /** |
|
377 | - * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM. |
|
378 | - * It will look for the longest hierarchy in the tree. |
|
379 | - * The places are reversed compared to normal GEDCOM structure. |
|
380 | - * |
|
381 | - * @return array |
|
382 | - */ |
|
383 | - protected function getPlacesHierarchyFromData() { |
|
384 | - $nb_levels = 0; |
|
376 | + /** |
|
377 | + * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM. |
|
378 | + * It will look for the longest hierarchy in the tree. |
|
379 | + * The places are reversed compared to normal GEDCOM structure. |
|
380 | + * |
|
381 | + * @return array |
|
382 | + */ |
|
383 | + protected function getPlacesHierarchyFromData() { |
|
384 | + $nb_levels = 0; |
|
385 | 385 | |
386 | - //Select all '2 PLAC ' tags in the file and create array |
|
387 | - $places_list=array(); |
|
388 | - $ged_data = Database::prepare( |
|
389 | - 'SELECT i_gedcom AS gedcom'. |
|
390 | - ' FROM `##individuals`'. |
|
391 | - ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. |
|
392 | - ' UNION ALL'. |
|
393 | - 'SELECT f_gedcom AS gedcom'. |
|
394 | - ' FROM `##families`'. |
|
395 | - ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' |
|
396 | - )->execute(array( |
|
397 | - 'gedcom' => '%\n2 PLAC %', |
|
398 | - 'gedcom_id' => $this->tree->getTreeId() |
|
399 | - ))->fetchOneColumn(); |
|
400 | - foreach ($ged_data as $ged_datum) { |
|
401 | - $matches = null; |
|
402 | - preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
|
403 | - foreach ($matches[1] as $match) { |
|
404 | - $places_list[$match]=true; |
|
405 | - } |
|
406 | - } |
|
386 | + //Select all '2 PLAC ' tags in the file and create array |
|
387 | + $places_list=array(); |
|
388 | + $ged_data = Database::prepare( |
|
389 | + 'SELECT i_gedcom AS gedcom'. |
|
390 | + ' FROM `##individuals`'. |
|
391 | + ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. |
|
392 | + ' UNION ALL'. |
|
393 | + 'SELECT f_gedcom AS gedcom'. |
|
394 | + ' FROM `##families`'. |
|
395 | + ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' |
|
396 | + )->execute(array( |
|
397 | + 'gedcom' => '%\n2 PLAC %', |
|
398 | + 'gedcom_id' => $this->tree->getTreeId() |
|
399 | + ))->fetchOneColumn(); |
|
400 | + foreach ($ged_data as $ged_datum) { |
|
401 | + $matches = null; |
|
402 | + preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
|
403 | + foreach ($matches[1] as $match) { |
|
404 | + $places_list[$match]=true; |
|
405 | + } |
|
406 | + } |
|
407 | 407 | |
408 | - // Unique list of places |
|
409 | - $places_list=array_keys($places_list); |
|
408 | + // Unique list of places |
|
409 | + $places_list=array_keys($places_list); |
|
410 | 410 | |
411 | - //sort the array, limit to unique values, and count them |
|
412 | - usort($places_list, array('I18N', 'strcasecmp')); |
|
411 | + //sort the array, limit to unique values, and count them |
|
412 | + usort($places_list, array('I18N', 'strcasecmp')); |
|
413 | 413 | |
414 | - //calculate maximum no. of levels to display |
|
415 | - $has_found_good_example = false; |
|
416 | - foreach($places_list as $place){ |
|
417 | - $levels = explode(",", $place); |
|
418 | - $parts = count($levels); |
|
419 | - if ($parts >= $nb_levels){ |
|
420 | - $nb_levels = $parts; |
|
421 | - if(!$has_found_good_example){ |
|
422 | - $random_place = $place; |
|
423 | - if(min(array_map('strlen', $levels)) > 0){ |
|
424 | - $has_found_good_example = true; |
|
425 | - } |
|
426 | - } |
|
427 | - } |
|
428 | - } |
|
414 | + //calculate maximum no. of levels to display |
|
415 | + $has_found_good_example = false; |
|
416 | + foreach($places_list as $place){ |
|
417 | + $levels = explode(",", $place); |
|
418 | + $parts = count($levels); |
|
419 | + if ($parts >= $nb_levels){ |
|
420 | + $nb_levels = $parts; |
|
421 | + if(!$has_found_good_example){ |
|
422 | + $random_place = $place; |
|
423 | + if(min(array_map('strlen', $levels)) > 0){ |
|
424 | + $has_found_good_example = true; |
|
425 | + } |
|
426 | + } |
|
427 | + } |
|
428 | + } |
|
429 | 429 | |
430 | - return array_reverse(array_map('trim',explode(',', $random_place))); |
|
431 | - } |
|
430 | + return array_reverse(array_map('trim',explode(',', $random_place))); |
|
431 | + } |
|
432 | 432 | |
433 | - /** |
|
434 | - * Returns the list of geodispersion maps available within the maps folder. |
|
435 | - * |
|
436 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[] |
|
437 | - */ |
|
438 | - public function getOutlineMapsList() { |
|
439 | - $res = array(); |
|
440 | - $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
|
441 | - if(is_dir($root_path)){ |
|
442 | - $dir = opendir($root_path); |
|
443 | - while (($file=readdir($dir))!== false) { |
|
444 | - if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
|
445 | - $res[base64_encode($file)] = new OutlineMap($file, true); |
|
446 | - } |
|
447 | - } |
|
448 | - } |
|
449 | - return $res; |
|
450 | - } |
|
433 | + /** |
|
434 | + * Returns the list of geodispersion maps available within the maps folder. |
|
435 | + * |
|
436 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[] |
|
437 | + */ |
|
438 | + public function getOutlineMapsList() { |
|
439 | + $res = array(); |
|
440 | + $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
|
441 | + if(is_dir($root_path)){ |
|
442 | + $dir = opendir($root_path); |
|
443 | + while (($file=readdir($dir))!== false) { |
|
444 | + if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
|
445 | + $res[base64_encode($file)] = new OutlineMap($file, true); |
|
446 | + } |
|
447 | + } |
|
448 | + } |
|
449 | + return $res; |
|
450 | + } |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | \ No newline at end of file |
@@ -24,64 +24,64 @@ discard block |
||
24 | 24 | * Geo Analysis ID |
25 | 25 | * @var int $id |
26 | 26 | */ |
27 | - protected $id; |
|
27 | + protected $id; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Geo Analysis Title |
31 | 31 | * @var string $title |
32 | 32 | */ |
33 | - protected $title; |
|
33 | + protected $title; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Level of the Gedcom hierarchy for the analysis |
37 | 37 | * @var int $analysis_level |
38 | 38 | */ |
39 | - protected $analysis_level; |
|
39 | + protected $analysis_level; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Display options |
|
43 | - * @var GeoDisplayOptions $options |
|
44 | - */ |
|
45 | - protected $options; |
|
41 | + /** |
|
42 | + * Display options |
|
43 | + * @var GeoDisplayOptions $options |
|
44 | + */ |
|
45 | + protected $options; |
|
46 | 46 | |
47 | - /** |
|
48 | - * Reference tree |
|
49 | - * @var Tree $tree |
|
50 | - */ |
|
51 | - protected $tree; |
|
47 | + /** |
|
48 | + * Reference tree |
|
49 | + * @var Tree $tree |
|
50 | + */ |
|
51 | + protected $tree; |
|
52 | 52 | |
53 | - /** |
|
54 | - * Is the analysis enabled |
|
55 | - * @var bool $enabled |
|
56 | - */ |
|
57 | - protected $enabled; |
|
53 | + /** |
|
54 | + * Is the analysis enabled |
|
55 | + * @var bool $enabled |
|
56 | + */ |
|
57 | + protected $enabled; |
|
58 | 58 | |
59 | - /** |
|
60 | - * Constructor for GeoAnalysis. |
|
61 | - * |
|
62 | - * @param Tree $tree Reference tree |
|
59 | + /** |
|
60 | + * Constructor for GeoAnalysis. |
|
61 | + * |
|
62 | + * @param Tree $tree Reference tree |
|
63 | 63 | * @param int $id GeoAnalysis ID |
64 | 64 | * @param string $title GeoAnalysis title |
65 | 65 | * @param int $analysis_level Analysis level |
66 | 66 | * @param (GeoDisplayOptions|null) $options Display options |
67 | 67 | * @param bool $enabled Is analysis enabled |
68 | - */ |
|
69 | - public function __construct(Tree $tree, $id, $title, $analysis_level, GeoDisplayOptions $options = null, $enabled = true) { |
|
70 | - $this->tree = $tree; |
|
71 | - $this->id = $id; |
|
72 | - $this->title = $title; |
|
73 | - $this->analysis_level = $analysis_level; |
|
74 | - $this->options = $options; |
|
75 | - $this->enabled = $enabled; |
|
76 | - } |
|
68 | + */ |
|
69 | + public function __construct(Tree $tree, $id, $title, $analysis_level, GeoDisplayOptions $options = null, $enabled = true) { |
|
70 | + $this->tree = $tree; |
|
71 | + $this->id = $id; |
|
72 | + $this->title = $title; |
|
73 | + $this->analysis_level = $analysis_level; |
|
74 | + $this->options = $options; |
|
75 | + $this->enabled = $enabled; |
|
76 | + } |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Get the analysis title |
80 | 80 | * @return string |
81 | 81 | */ |
82 | - public function getTitle() { |
|
83 | - return $this->title; |
|
84 | - } |
|
82 | + public function getTitle() { |
|
83 | + return $this->title; |
|
84 | + } |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Set the analysis title |
@@ -89,53 +89,53 @@ discard block |
||
89 | 89 | * @param string $title |
90 | 90 | * @return self Enable method-chaining |
91 | 91 | */ |
92 | - public function setTitle($title) { |
|
93 | - $this->title = $title; |
|
94 | - return $this; |
|
95 | - } |
|
92 | + public function setTitle($title) { |
|
93 | + $this->title = $title; |
|
94 | + return $this; |
|
95 | + } |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * Get the analysis ID |
99 | 99 | * @return int |
100 | 100 | */ |
101 | - public function getId() { |
|
102 | - return $this->id; |
|
103 | - } |
|
101 | + public function getId() { |
|
102 | + return $this->id; |
|
103 | + } |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * Get the analysis status (enabled/disabled) |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - public function isEnabled() { |
|
110 | - return $this->enabled; |
|
111 | - } |
|
109 | + public function isEnabled() { |
|
110 | + return $this->enabled; |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * Get analysis options |
|
115 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions |
|
116 | - */ |
|
117 | - public function getOptions() { |
|
118 | - return $this->options; |
|
119 | - } |
|
113 | + /** |
|
114 | + * Get analysis options |
|
115 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions |
|
116 | + */ |
|
117 | + public function getOptions() { |
|
118 | + return $this->options; |
|
119 | + } |
|
120 | 120 | |
121 | 121 | /** |
122 | - * Set analysis options |
|
122 | + * Set analysis options |
|
123 | 123 | * |
124 | - * @param \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions $options |
|
124 | + * @param \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions $options |
|
125 | 125 | * @return self Enable method-chaining |
126 | - */ |
|
127 | - public function setOptions(GeoDisplayOptions $options) { |
|
128 | - $this->options = $options; |
|
129 | - return $this; |
|
130 | - } |
|
126 | + */ |
|
127 | + public function setOptions(GeoDisplayOptions $options) { |
|
128 | + $this->options = $options; |
|
129 | + return $this; |
|
130 | + } |
|
131 | 131 | |
132 | 132 | /** |
133 | 133 | * Get analysis level |
134 | 134 | * @return int |
135 | 135 | */ |
136 | - public function getAnalysisLevel() { |
|
137 | - return $this->analysis_level; |
|
138 | - } |
|
136 | + public function getAnalysisLevel() { |
|
137 | + return $this->analysis_level; |
|
138 | + } |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Get analysis level |
@@ -143,19 +143,19 @@ discard block |
||
143 | 143 | * @param int $analysis_level |
144 | 144 | * @return self Enable method-chaining |
145 | 145 | */ |
146 | - public function setAnalysisLevel($analysis_level) { |
|
147 | - $this->analysis_level = $analysis_level; |
|
148 | - return $this; |
|
149 | - } |
|
146 | + public function setAnalysisLevel($analysis_level) { |
|
147 | + $this->analysis_level = $analysis_level; |
|
148 | + return $this; |
|
149 | + } |
|
150 | 150 | |
151 | 151 | /** |
152 | 152 | * Check whether the analysis has a linked map |
153 | 153 | * |
154 | 154 | * @return bool |
155 | 155 | */ |
156 | - public function hasMap() { |
|
157 | - return $this->options && $this->options->getMap(); |
|
158 | - } |
|
156 | + public function hasMap() { |
|
157 | + return $this->options && $this->options->getMap(); |
|
158 | + } |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * Get the URL for the GeoAnalysis. |
@@ -163,120 +163,120 @@ discard block |
||
163 | 163 | * @return string |
164 | 164 | */ |
165 | 165 | public function getHtmlUrl() { |
166 | - return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
167 | - } |
|
166 | + return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
170 | - * Return the dispersion analysis tables. |
|
171 | - * Two arrays are returned : |
|
172 | - * - the General analysis, which returns the number of ancestors for each place found, plus 4 additional indicators : |
|
173 | - * - knownsum : Number of known places |
|
174 | - * - unknown : Number of unknown places |
|
175 | - * - max : Maximum count of ancestors within a place |
|
176 | - * - other : Other places (not in the top level area) |
|
177 | - * - the Generations analysis, which returns the number of ancestors for each place found for each generation, plus 3 additional indicators within each generation : |
|
178 | - * - sum : Number of known places |
|
179 | - * - unknown : Number of unknown places |
|
180 | - * - other : Other places (not in the top level area) |
|
181 | - * |
|
182 | - * @param array $sosalist List of all sosas |
|
183 | - * @return array Array of the general and generations table |
|
184 | - */ |
|
185 | - public function getAnalysisResults($sosalist) { |
|
186 | - $placesDispGeneral = null; |
|
187 | - $placesDispGenerations = null; |
|
169 | + /** |
|
170 | + * Return the dispersion analysis tables. |
|
171 | + * Two arrays are returned : |
|
172 | + * - the General analysis, which returns the number of ancestors for each place found, plus 4 additional indicators : |
|
173 | + * - knownsum : Number of known places |
|
174 | + * - unknown : Number of unknown places |
|
175 | + * - max : Maximum count of ancestors within a place |
|
176 | + * - other : Other places (not in the top level area) |
|
177 | + * - the Generations analysis, which returns the number of ancestors for each place found for each generation, plus 3 additional indicators within each generation : |
|
178 | + * - sum : Number of known places |
|
179 | + * - unknown : Number of unknown places |
|
180 | + * - other : Other places (not in the top level area) |
|
181 | + * |
|
182 | + * @param array $sosalist List of all sosas |
|
183 | + * @return array Array of the general and generations table |
|
184 | + */ |
|
185 | + public function getAnalysisResults($sosalist) { |
|
186 | + $placesDispGeneral = null; |
|
187 | + $placesDispGenerations = null; |
|
188 | 188 | |
189 | - if($sosalist && count($sosalist) > 0) { |
|
190 | - $placesDispGeneral['knownsum'] = 0; |
|
191 | - $placesDispGeneral['unknown'] = 0; |
|
192 | - $placesDispGeneral['max'] = 0; |
|
193 | - $placesDispGeneral['places'] = array(); |
|
194 | - foreach($sosalist as $sosaid => $gens) { |
|
195 | - $sosa = Individual::getIntance($sosaid, $this->tree); |
|
196 | - $place =$sosa->getSignificantPlace(); |
|
197 | - $genstab = explode(',', $gens); |
|
198 | - $isUnknown=true; |
|
199 | - if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
200 | - $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
201 | - if(count($levels)>= $this->analysis_level){ |
|
202 | - $toplevelvalues = array(); |
|
203 | - if($this->hasMap() |
|
204 | - && $this->options->getMap()->isLoaded() |
|
205 | - && $toplevelvalue = $this->options->getMap()->getTopLevelName() |
|
206 | - ) { |
|
207 | - $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
208 | - } |
|
209 | - if(!$this->hasMap() |
|
210 | - || is_null($this->options->getMapLevel()) |
|
211 | - || ( $this->options->getMap()->isLoaded() && $this->options->getMap()->getTopLevelName() == '*') |
|
212 | - || ( |
|
213 | - $this->options->getMapLevel() <= $this->analysis_level |
|
214 | - && $this->options->getMapLevel() > 0 |
|
215 | - && count($levels) >= $this->options->getMapLevel() |
|
216 | - && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
217 | - ) |
|
218 | - ) { |
|
219 | - $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
|
220 | - if(isset($placesDispGeneral['places'][$placest])) { |
|
221 | - $placesDispGeneral['places'][$placest] += 1; |
|
222 | - } |
|
223 | - else { |
|
224 | - $placesDispGeneral['places'][$placest] = 1; |
|
225 | - } |
|
226 | - if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
227 | - $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
228 | - foreach($genstab as $gen) { |
|
229 | - if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
230 | - $placesDispGenerations[$gen]['places'][$placest] += 1; |
|
231 | - } |
|
232 | - else { |
|
233 | - $placesDispGenerations[$gen]['places'][$placest] = 1; |
|
234 | - } |
|
235 | - if(isset($placesDispGenerations[$gen]['sum'])) { |
|
236 | - $placesDispGenerations[$gen]['sum'] += 1; |
|
237 | - } |
|
238 | - else { |
|
239 | - $placesDispGenerations[$gen]['sum'] = 1; |
|
240 | - } |
|
241 | - } |
|
242 | - } |
|
243 | - else{ |
|
244 | - if(isset($placesDispGeneral['other'])) { |
|
245 | - $placesDispGeneral['other'] += 1; |
|
246 | - } |
|
247 | - else { |
|
248 | - $placesDispGeneral['other'] = 1; |
|
249 | - } |
|
250 | - foreach($genstab as $gen) { |
|
251 | - if(isset($placesDispGenerations[$gen]['other'])) { |
|
252 | - $placesDispGenerations[$gen]['other'] += 1; |
|
253 | - } |
|
254 | - else { |
|
255 | - $placesDispGenerations[$gen]['other'] = 1; |
|
256 | - } |
|
257 | - } |
|
258 | - } |
|
259 | - $placesDispGeneral['knownsum'] += 1; |
|
260 | - $isUnknown = false; |
|
261 | - } |
|
262 | - } |
|
263 | - if($isUnknown){ |
|
264 | - $placesDispGeneral['unknown'] += 1; |
|
265 | - foreach($genstab as $gen) { |
|
266 | - if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
267 | - $placesDispGenerations[$gen]['unknown'] += 1; |
|
268 | - } |
|
269 | - else { |
|
270 | - $placesDispGenerations[$gen]['unknown'] = 1; |
|
271 | - } |
|
272 | - } |
|
273 | - } |
|
274 | - } |
|
189 | + if($sosalist && count($sosalist) > 0) { |
|
190 | + $placesDispGeneral['knownsum'] = 0; |
|
191 | + $placesDispGeneral['unknown'] = 0; |
|
192 | + $placesDispGeneral['max'] = 0; |
|
193 | + $placesDispGeneral['places'] = array(); |
|
194 | + foreach($sosalist as $sosaid => $gens) { |
|
195 | + $sosa = Individual::getIntance($sosaid, $this->tree); |
|
196 | + $place =$sosa->getSignificantPlace(); |
|
197 | + $genstab = explode(',', $gens); |
|
198 | + $isUnknown=true; |
|
199 | + if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
200 | + $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
201 | + if(count($levels)>= $this->analysis_level){ |
|
202 | + $toplevelvalues = array(); |
|
203 | + if($this->hasMap() |
|
204 | + && $this->options->getMap()->isLoaded() |
|
205 | + && $toplevelvalue = $this->options->getMap()->getTopLevelName() |
|
206 | + ) { |
|
207 | + $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
208 | + } |
|
209 | + if(!$this->hasMap() |
|
210 | + || is_null($this->options->getMapLevel()) |
|
211 | + || ( $this->options->getMap()->isLoaded() && $this->options->getMap()->getTopLevelName() == '*') |
|
212 | + || ( |
|
213 | + $this->options->getMapLevel() <= $this->analysis_level |
|
214 | + && $this->options->getMapLevel() > 0 |
|
215 | + && count($levels) >= $this->options->getMapLevel() |
|
216 | + && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
217 | + ) |
|
218 | + ) { |
|
219 | + $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
|
220 | + if(isset($placesDispGeneral['places'][$placest])) { |
|
221 | + $placesDispGeneral['places'][$placest] += 1; |
|
222 | + } |
|
223 | + else { |
|
224 | + $placesDispGeneral['places'][$placest] = 1; |
|
225 | + } |
|
226 | + if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
227 | + $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
228 | + foreach($genstab as $gen) { |
|
229 | + if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
230 | + $placesDispGenerations[$gen]['places'][$placest] += 1; |
|
231 | + } |
|
232 | + else { |
|
233 | + $placesDispGenerations[$gen]['places'][$placest] = 1; |
|
234 | + } |
|
235 | + if(isset($placesDispGenerations[$gen]['sum'])) { |
|
236 | + $placesDispGenerations[$gen]['sum'] += 1; |
|
237 | + } |
|
238 | + else { |
|
239 | + $placesDispGenerations[$gen]['sum'] = 1; |
|
240 | + } |
|
241 | + } |
|
242 | + } |
|
243 | + else{ |
|
244 | + if(isset($placesDispGeneral['other'])) { |
|
245 | + $placesDispGeneral['other'] += 1; |
|
246 | + } |
|
247 | + else { |
|
248 | + $placesDispGeneral['other'] = 1; |
|
249 | + } |
|
250 | + foreach($genstab as $gen) { |
|
251 | + if(isset($placesDispGenerations[$gen]['other'])) { |
|
252 | + $placesDispGenerations[$gen]['other'] += 1; |
|
253 | + } |
|
254 | + else { |
|
255 | + $placesDispGenerations[$gen]['other'] = 1; |
|
256 | + } |
|
257 | + } |
|
258 | + } |
|
259 | + $placesDispGeneral['knownsum'] += 1; |
|
260 | + $isUnknown = false; |
|
261 | + } |
|
262 | + } |
|
263 | + if($isUnknown){ |
|
264 | + $placesDispGeneral['unknown'] += 1; |
|
265 | + foreach($genstab as $gen) { |
|
266 | + if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
267 | + $placesDispGenerations[$gen]['unknown'] += 1; |
|
268 | + } |
|
269 | + else { |
|
270 | + $placesDispGenerations[$gen]['unknown'] = 1; |
|
271 | + } |
|
272 | + } |
|
273 | + } |
|
274 | + } |
|
275 | 275 | |
276 | - } |
|
276 | + } |
|
277 | 277 | |
278 | - return array($placesDispGeneral, $placesDispGenerations); |
|
279 | - } |
|
278 | + return array($placesDispGeneral, $placesDispGenerations); |
|
279 | + } |
|
280 | 280 | |
281 | 281 | |
282 | 282 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @return string |
164 | 164 | */ |
165 | 165 | public function getHtmlUrl() { |
166 | - return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
166 | + return 'module.php?mod='.Constants::MODULE_MAJ_GEODISP_NAME.'&mod_action=GeoAnalysis&ga_id='.$this->getId().'&ged='.$this->tree->getNameUrl(); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -186,53 +186,53 @@ discard block |
||
186 | 186 | $placesDispGeneral = null; |
187 | 187 | $placesDispGenerations = null; |
188 | 188 | |
189 | - if($sosalist && count($sosalist) > 0) { |
|
189 | + if ($sosalist && count($sosalist) > 0) { |
|
190 | 190 | $placesDispGeneral['knownsum'] = 0; |
191 | 191 | $placesDispGeneral['unknown'] = 0; |
192 | 192 | $placesDispGeneral['max'] = 0; |
193 | 193 | $placesDispGeneral['places'] = array(); |
194 | - foreach($sosalist as $sosaid => $gens) { |
|
194 | + foreach ($sosalist as $sosaid => $gens) { |
|
195 | 195 | $sosa = Individual::getIntance($sosaid, $this->tree); |
196 | - $place =$sosa->getSignificantPlace(); |
|
196 | + $place = $sosa->getSignificantPlace(); |
|
197 | 197 | $genstab = explode(',', $gens); |
198 | - $isUnknown=true; |
|
199 | - if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
200 | - $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
201 | - if(count($levels)>= $this->analysis_level){ |
|
198 | + $isUnknown = true; |
|
199 | + if ($sosa->getDerivedRecord()->canShow() && !is_null($place)) { |
|
200 | + $levels = array_reverse(array_map('trim', explode(',', $place))); |
|
201 | + if (count($levels) >= $this->analysis_level) { |
|
202 | 202 | $toplevelvalues = array(); |
203 | - if($this->hasMap() |
|
203 | + if ($this->hasMap() |
|
204 | 204 | && $this->options->getMap()->isLoaded() |
205 | 205 | && $toplevelvalue = $this->options->getMap()->getTopLevelName() |
206 | 206 | ) { |
207 | - $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
207 | + $toplevelvalues = array_map('trim', explode(',', strtolower($toplevelvalue))); |
|
208 | 208 | } |
209 | - if(!$this->hasMap() |
|
209 | + if (!$this->hasMap() |
|
210 | 210 | || is_null($this->options->getMapLevel()) |
211 | - || ( $this->options->getMap()->isLoaded() && $this->options->getMap()->getTopLevelName() == '*') |
|
211 | + || ($this->options->getMap()->isLoaded() && $this->options->getMap()->getTopLevelName() == '*') |
|
212 | 212 | || ( |
213 | 213 | $this->options->getMapLevel() <= $this->analysis_level |
214 | 214 | && $this->options->getMapLevel() > 0 |
215 | 215 | && count($levels) >= $this->options->getMapLevel() |
216 | - && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
216 | + && in_array(strtolower($levels[$this->options->getMapLevel() - 1]), $toplevelvalues) |
|
217 | 217 | ) |
218 | 218 | ) { |
219 | 219 | $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
220 | - if(isset($placesDispGeneral['places'][$placest])) { |
|
220 | + if (isset($placesDispGeneral['places'][$placest])) { |
|
221 | 221 | $placesDispGeneral['places'][$placest] += 1; |
222 | 222 | } |
223 | 223 | else { |
224 | 224 | $placesDispGeneral['places'][$placest] = 1; |
225 | 225 | } |
226 | - if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
226 | + if ($placesDispGeneral['places'][$placest] > $placesDispGeneral['max']) |
|
227 | 227 | $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
228 | - foreach($genstab as $gen) { |
|
229 | - if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
228 | + foreach ($genstab as $gen) { |
|
229 | + if (isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
230 | 230 | $placesDispGenerations[$gen]['places'][$placest] += 1; |
231 | 231 | } |
232 | 232 | else { |
233 | 233 | $placesDispGenerations[$gen]['places'][$placest] = 1; |
234 | 234 | } |
235 | - if(isset($placesDispGenerations[$gen]['sum'])) { |
|
235 | + if (isset($placesDispGenerations[$gen]['sum'])) { |
|
236 | 236 | $placesDispGenerations[$gen]['sum'] += 1; |
237 | 237 | } |
238 | 238 | else { |
@@ -240,15 +240,15 @@ discard block |
||
240 | 240 | } |
241 | 241 | } |
242 | 242 | } |
243 | - else{ |
|
244 | - if(isset($placesDispGeneral['other'])) { |
|
243 | + else { |
|
244 | + if (isset($placesDispGeneral['other'])) { |
|
245 | 245 | $placesDispGeneral['other'] += 1; |
246 | 246 | } |
247 | 247 | else { |
248 | 248 | $placesDispGeneral['other'] = 1; |
249 | 249 | } |
250 | - foreach($genstab as $gen) { |
|
251 | - if(isset($placesDispGenerations[$gen]['other'])) { |
|
250 | + foreach ($genstab as $gen) { |
|
251 | + if (isset($placesDispGenerations[$gen]['other'])) { |
|
252 | 252 | $placesDispGenerations[$gen]['other'] += 1; |
253 | 253 | } |
254 | 254 | else { |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | $isUnknown = false; |
261 | 261 | } |
262 | 262 | } |
263 | - if($isUnknown){ |
|
263 | + if ($isUnknown) { |
|
264 | 264 | $placesDispGeneral['unknown'] += 1; |
265 | - foreach($genstab as $gen) { |
|
266 | - if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
265 | + foreach ($genstab as $gen) { |
|
266 | + if (isset($placesDispGenerations[$gen]['unknown'])) { |
|
267 | 267 | $placesDispGenerations[$gen]['unknown'] += 1; |
268 | 268 | } |
269 | 269 | else { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | <form class="form-horizontal" name="newform" method="post" role="form" action="<?php echo $this->data->get('save_url'); ?>" autocomplete="off"> |
46 | 46 | <?php echo Filter::getCsrf(); ?> |
47 | - <?php if(!$is_new) { ?> |
|
47 | + <?php if (!$is_new) { ?> |
|
48 | 48 | <input type="hidden" name="ga_id" value="<?php echo $ga->getId(); ?>"> |
49 | 49 | <?php } ?> |
50 | 50 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | <?php echo I18N::translate('Description'); ?> |
55 | 55 | </label> |
56 | 56 | <div class="col-sm-9"> |
57 | - <input class="form-control" type="text" id="description" name="description" required maxlength="70" <?php if(!$is_new) echo 'value="' . Filter::escapeHtml($ga->getTitle()) .'"'; ?> dir="auto"> |
|
57 | + <input class="form-control" type="text" id="description" name="description" required maxlength="70" <?php if (!$is_new) echo 'value="'.Filter::escapeHtml($ga->getTitle()).'"'; ?> dir="auto"> |
|
58 | 58 | <p class="small text-muted"> |
59 | 59 | <?php echo I18N::translate('Description to be given to the geographical dispersion analysis. It will be used as the page title for it.'); ?> |
60 | 60 | </p> |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | <?php echo I18N::translate('Map'); ?> |
98 | 98 | </label> |
99 | 99 | <div class="col-sm-9"> |
100 | - <?php echo FunctionsEdit::selectEditControl('map_file', $this->data->get('map_list') , null, ($is_new || ! $ga->hasMap()) ? '' : base64_encode($ga->getOptions()->getMap()->getFileName()), 'class="form-control"'); ?> |
|
100 | + <?php echo FunctionsEdit::selectEditControl('map_file', $this->data->get('map_list'), null, ($is_new || !$ga->hasMap()) ? '' : base64_encode($ga->getOptions()->getMap()->getFileName()), 'class="form-control"'); ?> |
|
101 | 101 | <p class="small text-muted"> |
102 | 102 | <?php echo I18N::translate('Map outline to be used for the result display.'); ?> |
103 | 103 | </p> |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | <?php echo I18N::translate('Map parent level'); ?> |
111 | 111 | </label> |
112 | 112 | <div class="col-sm-9"> |
113 | - <?php echo FunctionsEdit::selectEditControl('map_top_level', $places_hierarchy['hierarchy'], null, $is_new || ! $ga->hasMap() ? '' : $ga->getOptions()->getMapLevel() - 1, 'class="form-control"'); ?> |
|
113 | + <?php echo FunctionsEdit::selectEditControl('map_top_level', $places_hierarchy['hierarchy'], null, $is_new || !$ga->hasMap() ? '' : $ga->getOptions()->getMapLevel() - 1, 'class="form-control"'); ?> |
|
114 | 114 | <p class="small text-muted"> |
115 | 115 | <?php echo I18N::translate('Subdivision level of the parent subdivision(s) represented by the map.'); ?><br /> |
116 | 116 | <?php echo I18N::translate('For instance, if the map is intended to represent a country by county analysis, then the map parent level would be “Country”, and the analysis level would be “County”.'); ?> |
@@ -25,24 +25,24 @@ discard block |
||
25 | 25 | * {@inheritDoc} |
26 | 26 | * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisTabGeneralView::htmlAnalysisData() |
27 | 27 | */ |
28 | - protected function htmlAnalysisData() { |
|
28 | + protected function htmlAnalysisData() { |
|
29 | 29 | |
30 | - /** @var OutlineMap $map */ |
|
31 | - $map = $this->data->get('map'); |
|
30 | + /** @var OutlineMap $map */ |
|
31 | + $map = $this->data->get('map'); |
|
32 | 32 | |
33 | - if($map === null) { |
|
34 | - return '<p class="warning">' . |
|
35 | - I18N::translate('The map could not be loaded.') . |
|
36 | - '</p>'; |
|
37 | - } |
|
33 | + if($map === null) { |
|
34 | + return '<p class="warning">' . |
|
35 | + I18N::translate('The map could not be loaded.') . |
|
36 | + '</p>'; |
|
37 | + } |
|
38 | 38 | |
39 | - $canvas = $map->getCanvas(); |
|
40 | - $subdvisions_results = $this->data->get('results_by_subdivisions'); |
|
39 | + $canvas = $map->getCanvas(); |
|
40 | + $subdvisions_results = $this->data->get('results_by_subdivisions'); |
|
41 | 41 | |
42 | - $nb_found = $this->data->get('stats_gen_nb_found'); |
|
43 | - $nb_other = $this->data->get('stats_gen_nb_other'); |
|
42 | + $nb_found = $this->data->get('stats_gen_nb_found'); |
|
43 | + $nb_other = $this->data->get('stats_gen_nb_other'); |
|
44 | 44 | |
45 | - $html = '<script> |
|
45 | + $html = '<script> |
|
46 | 46 | var tip = null; |
47 | 47 | var tipText = ""; |
48 | 48 | var over = false; |
@@ -89,29 +89,29 @@ discard block |
||
89 | 89 | var map = {}; |
90 | 90 | '; |
91 | 91 | |
92 | - foreach($subdvisions_results as $name => $location){ |
|
93 | - $html.= 'map.area'.$location['id'].' = paper.path("'.$location['coord'].'").attr(attr);'; |
|
94 | - if(isset($location['transparency'])) { |
|
95 | - $textToolTip = '<strong>'.$location['displayname'].'</strong><br/>'; |
|
96 | - if($this->data->get('use_flags') && $location['flag'] != '') $textToolTip .= '<span class="geodispersion_flag">'.FunctionsPrint::htmlPlaceIcon($location['place'], $location['flag']).'</span><br/>'; |
|
97 | - $textToolTip .= I18N::translate('%d individuals', $location['count']).'<br/>'.I18N::percentage(Functions::safeDivision($location['count'], $nb_found - $nb_other), 1); |
|
98 | - $html.= 'addTip(map.area'.$location['id'].'.node, "'.Filter::escapeJs($textToolTip).'");'; |
|
99 | - $html.= 'map.area'.$location['id'].'.attr({"fill" : "'. $canvas->max_color .'", "fill-opacity" : '.$location['transparency'].' });'; |
|
100 | - $html.= 'map.area'.$location['id'].'.mouseover(function () {'. |
|
101 | - 'map.area'.$location['id'].'.stop().animate({"fill" : "'. $canvas->hover_color .'", "fill-opacity" : 1}, 100, "linear");'. |
|
102 | - '});'. |
|
103 | - 'map.area'.$location['id'].'.mouseout(function () {'. |
|
104 | - 'map.area'.$location['id'].'.stop().animate({"fill" : "'.$canvas->max_color.'", "fill-opacity" : '.$location['transparency'].'}, 100, "linear");'. |
|
105 | - '});'; |
|
106 | - } |
|
107 | - } |
|
108 | - $html .= '}); |
|
92 | + foreach($subdvisions_results as $name => $location){ |
|
93 | + $html.= 'map.area'.$location['id'].' = paper.path("'.$location['coord'].'").attr(attr);'; |
|
94 | + if(isset($location['transparency'])) { |
|
95 | + $textToolTip = '<strong>'.$location['displayname'].'</strong><br/>'; |
|
96 | + if($this->data->get('use_flags') && $location['flag'] != '') $textToolTip .= '<span class="geodispersion_flag">'.FunctionsPrint::htmlPlaceIcon($location['place'], $location['flag']).'</span><br/>'; |
|
97 | + $textToolTip .= I18N::translate('%d individuals', $location['count']).'<br/>'.I18N::percentage(Functions::safeDivision($location['count'], $nb_found - $nb_other), 1); |
|
98 | + $html.= 'addTip(map.area'.$location['id'].'.node, "'.Filter::escapeJs($textToolTip).'");'; |
|
99 | + $html.= 'map.area'.$location['id'].'.attr({"fill" : "'. $canvas->max_color .'", "fill-opacity" : '.$location['transparency'].' });'; |
|
100 | + $html.= 'map.area'.$location['id'].'.mouseover(function () {'. |
|
101 | + 'map.area'.$location['id'].'.stop().animate({"fill" : "'. $canvas->hover_color .'", "fill-opacity" : 1}, 100, "linear");'. |
|
102 | + '});'. |
|
103 | + 'map.area'.$location['id'].'.mouseout(function () {'. |
|
104 | + 'map.area'.$location['id'].'.stop().animate({"fill" : "'.$canvas->max_color.'", "fill-opacity" : '.$location['transparency'].'}, 100, "linear");'. |
|
105 | + '});'; |
|
106 | + } |
|
107 | + } |
|
108 | + $html .= '}); |
|
109 | 109 | </script> |
110 | 110 | |
111 | 111 | <div id="geodispersion_map"></div> |
112 | 112 | <div id="geodispersion_tip"></div>'; |
113 | 113 | |
114 | - return $html; |
|
115 | - } |
|
114 | + return $html; |
|
115 | + } |
|
116 | 116 | |
117 | 117 | } |
118 | 118 | \ No newline at end of file |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | /** @var OutlineMap $map */ |
31 | 31 | $map = $this->data->get('map'); |
32 | 32 | |
33 | - if($map === null) { |
|
34 | - return '<p class="warning">' . |
|
35 | - I18N::translate('The map could not be loaded.') . |
|
33 | + if ($map === null) { |
|
34 | + return '<p class="warning">'. |
|
35 | + I18N::translate('The map could not be loaded.'). |
|
36 | 36 | '</p>'; |
37 | 37 | } |
38 | 38 | |
@@ -82,23 +82,23 @@ discard block |
||
82 | 82 | } |
83 | 83 | }); |
84 | 84 | |
85 | - var paper = new Raphael(document.getElementById("geodispersion_map"), '. $canvas->width .', '. $canvas->height .'); |
|
86 | - var background = paper.rect(0, 0, ' . $canvas->width . ', '. $canvas->height . '); |
|
87 | - background.attr({"fill" : "'. $canvas->background_color .'", "stroke" : "'. $canvas->background_stroke .'", "stroke-width": 1, "stroke-linejoin": "round" }); |
|
88 | - var attr = { fill: "'. $canvas->default_color .'", stroke: "'. $canvas->default_stroke .'", "stroke-width": 1, "stroke-linejoin": "round" }; |
|
85 | + var paper = new Raphael(document.getElementById("geodispersion_map"), '. $canvas->width.', '.$canvas->height.'); |
|
86 | + var background = paper.rect(0, 0, ' . $canvas->width.', '.$canvas->height.'); |
|
87 | + background.attr({"fill" : "'. $canvas->background_color.'", "stroke" : "'.$canvas->background_stroke.'", "stroke-width": 1, "stroke-linejoin": "round" }); |
|
88 | + var attr = { fill: "'. $canvas->default_color.'", stroke: "'.$canvas->default_stroke.'", "stroke-width": 1, "stroke-linejoin": "round" }; |
|
89 | 89 | var map = {}; |
90 | 90 | '; |
91 | 91 | |
92 | - foreach($subdvisions_results as $name => $location){ |
|
93 | - $html.= 'map.area'.$location['id'].' = paper.path("'.$location['coord'].'").attr(attr);'; |
|
94 | - if(isset($location['transparency'])) { |
|
92 | + foreach ($subdvisions_results as $name => $location) { |
|
93 | + $html .= 'map.area'.$location['id'].' = paper.path("'.$location['coord'].'").attr(attr);'; |
|
94 | + if (isset($location['transparency'])) { |
|
95 | 95 | $textToolTip = '<strong>'.$location['displayname'].'</strong><br/>'; |
96 | - if($this->data->get('use_flags') && $location['flag'] != '') $textToolTip .= '<span class="geodispersion_flag">'.FunctionsPrint::htmlPlaceIcon($location['place'], $location['flag']).'</span><br/>'; |
|
96 | + if ($this->data->get('use_flags') && $location['flag'] != '') $textToolTip .= '<span class="geodispersion_flag">'.FunctionsPrint::htmlPlaceIcon($location['place'], $location['flag']).'</span><br/>'; |
|
97 | 97 | $textToolTip .= I18N::translate('%d individuals', $location['count']).'<br/>'.I18N::percentage(Functions::safeDivision($location['count'], $nb_found - $nb_other), 1); |
98 | - $html.= 'addTip(map.area'.$location['id'].'.node, "'.Filter::escapeJs($textToolTip).'");'; |
|
99 | - $html.= 'map.area'.$location['id'].'.attr({"fill" : "'. $canvas->max_color .'", "fill-opacity" : '.$location['transparency'].' });'; |
|
100 | - $html.= 'map.area'.$location['id'].'.mouseover(function () {'. |
|
101 | - 'map.area'.$location['id'].'.stop().animate({"fill" : "'. $canvas->hover_color .'", "fill-opacity" : 1}, 100, "linear");'. |
|
98 | + $html .= 'addTip(map.area'.$location['id'].'.node, "'.Filter::escapeJs($textToolTip).'");'; |
|
99 | + $html .= 'map.area'.$location['id'].'.attr({"fill" : "'.$canvas->max_color.'", "fill-opacity" : '.$location['transparency'].' });'; |
|
100 | + $html .= 'map.area'.$location['id'].'.mouseover(function () {'. |
|
101 | + 'map.area'.$location['id'].'.stop().animate({"fill" : "'.$canvas->hover_color.'", "fill-opacity" : 1}, 100, "linear");'. |
|
102 | 102 | '});'. |
103 | 103 | 'map.area'.$location['id'].'.mouseout(function () {'. |
104 | 104 | 'map.area'.$location['id'].'.stop().animate({"fill" : "'.$canvas->max_color.'", "fill-opacity" : '.$location['transparency'].'}, 100, "linear");'. |
@@ -36,58 +36,58 @@ 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 | - $wt_tree = Globals::getTree(); |
|
64 | - Theme::theme(new AdministrationTheme)->init($wt_tree); |
|
65 | - $controller = new PageController(); |
|
66 | - $controller |
|
67 | - ->restrictAccess(Auth::isManager($wt_tree)) |
|
68 | - ->setPageTitle($this->module->getTitle()); |
|
59 | + /** |
|
60 | + * AdminConfig@index |
|
61 | + */ |
|
62 | + public function index() { |
|
63 | + $wt_tree = Globals::getTree(); |
|
64 | + Theme::theme(new AdministrationTheme)->init($wt_tree); |
|
65 | + $controller = new PageController(); |
|
66 | + $controller |
|
67 | + ->restrictAccess(Auth::isManager($wt_tree)) |
|
68 | + ->setPageTitle($this->module->getTitle()); |
|
69 | 69 | |
70 | - $data = new ViewBag(); |
|
71 | - $data->set('title', $controller->getPageTitle()); |
|
72 | - $data->set('tree', $wt_tree); |
|
70 | + $data = new ViewBag(); |
|
71 | + $data->set('title', $controller->getPageTitle()); |
|
72 | + $data->set('tree', $wt_tree); |
|
73 | 73 | |
74 | - $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'); |
|
74 | + $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'); |
|
75 | 75 | |
76 | - $table_id = 'table-geoanalysis-' . Uuid::uuid4(); |
|
77 | - $data->set('table_id', $table_id); |
|
76 | + $table_id = 'table-geoanalysis-' . Uuid::uuid4(); |
|
77 | + $data->set('table_id', $table_id); |
|
78 | 78 | |
79 | - $other_trees = array(); |
|
80 | - foreach (Tree::getAll() as $tree) { |
|
81 | - if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree; |
|
82 | - } |
|
83 | - $data->set('other_trees', $other_trees); |
|
79 | + $other_trees = array(); |
|
80 | + foreach (Tree::getAll() as $tree) { |
|
81 | + if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree; |
|
82 | + } |
|
83 | + $data->set('other_trees', $other_trees); |
|
84 | 84 | |
85 | - $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
85 | + $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
86 | 86 | |
87 | - $controller |
|
88 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
89 | - ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
90 | - ->addInlineJavascript(' |
|
87 | + $controller |
|
88 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
89 | + ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
90 | + ->addInlineJavascript(' |
|
91 | 91 | jQuery.fn.dataTableExt.oSort["text-asc"] = textCompareAsc; |
92 | 92 | jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc; |
93 | 93 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | }); |
120 | 120 | |
121 | 121 | ') |
122 | - ->addInlineJavascript(' |
|
122 | + ->addInlineJavascript(' |
|
123 | 123 | function set_geoanalysis_status(ga_id, status, gedcom) { |
124 | 124 | jQuery.ajax({ |
125 | 125 | url: "module.php", |
@@ -163,54 +163,54 @@ discard block |
||
163 | 163 | '); |
164 | 164 | |
165 | 165 | |
166 | - ViewFactory::make('AdminConfig', $this, $controller, $data)->render(); |
|
167 | - } |
|
166 | + ViewFactory::make('AdminConfig', $this, $controller, $data)->render(); |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
170 | - * AdminConfig@jsonGeoAnalysisList |
|
171 | - */ |
|
172 | - public function jsonGeoAnalysisList() { |
|
173 | - $wt_tree = Globals::getTree(); |
|
174 | - $controller = new JsonController(); |
|
175 | - $controller |
|
176 | - ->restrictAccess(Auth::isManager($wt_tree)); |
|
169 | + /** |
|
170 | + * AdminConfig@jsonGeoAnalysisList |
|
171 | + */ |
|
172 | + public function jsonGeoAnalysisList() { |
|
173 | + $wt_tree = Globals::getTree(); |
|
174 | + $controller = new JsonController(); |
|
175 | + $controller |
|
176 | + ->restrictAccess(Auth::isManager($wt_tree)); |
|
177 | 177 | |
178 | - // Generate an AJAX/JSON response for datatables to load a block of rows |
|
179 | - $search = Filter::postArray('search'); |
|
180 | - if($search) $search = $search['value']; |
|
181 | - $start = Filter::postInteger('start'); |
|
182 | - $length = Filter::postInteger('length'); |
|
183 | - $order = Filter::postArray('order'); |
|
178 | + // Generate an AJAX/JSON response for datatables to load a block of rows |
|
179 | + $search = Filter::postArray('search'); |
|
180 | + if($search) $search = $search['value']; |
|
181 | + $start = Filter::postInteger('start'); |
|
182 | + $length = Filter::postInteger('length'); |
|
183 | + $order = Filter::postArray('order'); |
|
184 | 184 | |
185 | - foreach($order as $key => &$value) { |
|
186 | - switch($value['column']) { |
|
187 | - case 3: |
|
188 | - $value['column'] = 'majgd_descr'; |
|
189 | - break; |
|
190 | - case 5; |
|
191 | - $value['column'] = 'majgd_sublevel'; |
|
192 | - break; |
|
193 | - default: |
|
194 | - unset($order[$key]); |
|
195 | - } |
|
196 | - } |
|
185 | + foreach($order as $key => &$value) { |
|
186 | + switch($value['column']) { |
|
187 | + case 3: |
|
188 | + $value['column'] = 'majgd_descr'; |
|
189 | + break; |
|
190 | + case 5; |
|
191 | + $value['column'] = 'majgd_sublevel'; |
|
192 | + break; |
|
193 | + default: |
|
194 | + unset($order[$key]); |
|
195 | + } |
|
196 | + } |
|
197 | 197 | |
198 | - /** @var GeoAnalysisProvider $provider */ |
|
199 | - $provider = $this->module->getProvider(); |
|
198 | + /** @var GeoAnalysisProvider $provider */ |
|
199 | + $provider = $this->module->getProvider(); |
|
200 | 200 | |
201 | - $list = $provider->getFilteredGeoAnalysisList($search, $order, $start, $length); |
|
202 | - $recordsFiltered = count($list); |
|
203 | - $recordsTotal = $this->provider->getGeoAnalysisCount(); |
|
201 | + $list = $provider->getFilteredGeoAnalysisList($search, $order, $start, $length); |
|
202 | + $recordsFiltered = count($list); |
|
203 | + $recordsTotal = $this->provider->getGeoAnalysisCount(); |
|
204 | 204 | |
205 | - $data = array(); |
|
206 | - $place_hierarchy = $this->provider->getPlacesHierarchy(); |
|
207 | - foreach($list as $ga) { |
|
208 | - /** @var GeoAnalysis $ga */ |
|
205 | + $data = array(); |
|
206 | + $place_hierarchy = $this->provider->getPlacesHierarchy(); |
|
207 | + foreach($list as $ga) { |
|
208 | + /** @var GeoAnalysis $ga */ |
|
209 | 209 | |
210 | - $datum = array(); |
|
211 | - $options= $ga->getOptions(); |
|
210 | + $datum = array(); |
|
211 | + $options= $ga->getOptions(); |
|
212 | 212 | |
213 | - $datum[0] = ' |
|
213 | + $datum[0] = ' |
|
214 | 214 | <div class="btn-group"> |
215 | 215 | <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> |
216 | 216 | <i class="fa fa-pencil"></i><span class="caret"></span> |
@@ -234,112 +234,112 @@ discard block |
||
234 | 234 | </li> |
235 | 235 | </ul> |
236 | 236 | </div>'; |
237 | - $datum[1] = $ga->getId(); |
|
238 | - $datum[2] = $ga->isEnabled() ? |
|
237 | + $datum[1] = $ga->getId(); |
|
238 | + $datum[2] = $ga->isEnabled() ? |
|
239 | 239 | '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : |
240 | 240 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
241 | - $datum[3] = $ga->getTitle(); |
|
242 | - $analysis_level = $ga->getAnalysisLevel(); |
|
243 | - if($place_hierarchy['type'] == 'header') { |
|
244 | - $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1]; |
|
245 | - } else { |
|
246 | - $datum[4] = $analysis_level . '(' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')'; |
|
247 | - } |
|
248 | - $datum[5] = $ga->getAnalysisLevel(); |
|
249 | - $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
250 | - $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
251 | - if($ga->hasMap()) { |
|
252 | - if($options->getMap()->isLoaded()) { |
|
253 | - $datum[6] = $options->getMap()->getDescription(); |
|
254 | - $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />'; |
|
255 | - $top_level = $options->getMapLevel(); |
|
256 | - if($place_hierarchy['type'] == 'header') { |
|
257 | - $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1]; |
|
258 | - } else { |
|
259 | - $datum[7] .= $top_level . '(' . $place_hierarchy['hierarchy'][$top_level - 1] . ')'; |
|
260 | - } |
|
261 | - $datum[7] .= '</span>'; |
|
262 | - } |
|
263 | - else { |
|
264 | - $datum[6] = I18N::translate('Error when loading map.'); |
|
265 | - } |
|
266 | - } |
|
267 | - $datum[8] = $options->isUsingFlags() ? |
|
241 | + $datum[3] = $ga->getTitle(); |
|
242 | + $analysis_level = $ga->getAnalysisLevel(); |
|
243 | + if($place_hierarchy['type'] == 'header') { |
|
244 | + $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1]; |
|
245 | + } else { |
|
246 | + $datum[4] = $analysis_level . '(' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')'; |
|
247 | + } |
|
248 | + $datum[5] = $ga->getAnalysisLevel(); |
|
249 | + $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
250 | + $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
251 | + if($ga->hasMap()) { |
|
252 | + if($options->getMap()->isLoaded()) { |
|
253 | + $datum[6] = $options->getMap()->getDescription(); |
|
254 | + $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />'; |
|
255 | + $top_level = $options->getMapLevel(); |
|
256 | + if($place_hierarchy['type'] == 'header') { |
|
257 | + $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1]; |
|
258 | + } else { |
|
259 | + $datum[7] .= $top_level . '(' . $place_hierarchy['hierarchy'][$top_level - 1] . ')'; |
|
260 | + } |
|
261 | + $datum[7] .= '</span>'; |
|
262 | + } |
|
263 | + else { |
|
264 | + $datum[6] = I18N::translate('Error when loading map.'); |
|
265 | + } |
|
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 | - $controller->encode(array( |
|
278 | - 'draw' => Filter::getInteger('draw'), |
|
279 | - 'recordsTotal' => $recordsTotal, |
|
280 | - 'recordsFiltered' => $recordsFiltered, |
|
281 | - 'data' => $data |
|
282 | - )); |
|
277 | + $controller->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 | - $wt_tree = Globals::getTree(); |
|
308 | - $tmp_contrl = new PageController(); |
|
309 | - $tmp_contrl->restrictAccess( |
|
310 | - Auth::isManager($wt_tree) |
|
311 | - && Filter::checkCsrf() |
|
312 | - ); |
|
303 | + /** |
|
304 | + * AdminConfig@save |
|
305 | + */ |
|
306 | + public function save() { |
|
307 | + $wt_tree = Globals::getTree(); |
|
308 | + $tmp_contrl = new PageController(); |
|
309 | + $tmp_contrl->restrictAccess( |
|
310 | + Auth::isManager($wt_tree) |
|
311 | + && Filter::checkCsrf() |
|
312 | + ); |
|
313 | 313 | |
314 | - $ga_id = Filter::postInteger('ga_id'); |
|
315 | - $description = Filter::post('description'); |
|
316 | - $analysislevel = Filter::postInteger('analysislevel'); |
|
317 | - $use_map = Filter::postBool('use_map'); |
|
318 | - if($use_map) { |
|
319 | - $map_file = base64_decode(Filter::post('map_file')); |
|
320 | - $map_top_level = Filter::postInteger('map_top_level'); |
|
321 | - } |
|
322 | - $use_flags = Filter::postBool('use_flags'); |
|
323 | - $gen_details = Filter::postInteger('gen_details'); |
|
314 | + $ga_id = Filter::postInteger('ga_id'); |
|
315 | + $description = Filter::post('description'); |
|
316 | + $analysislevel = Filter::postInteger('analysislevel'); |
|
317 | + $use_map = Filter::postBool('use_map'); |
|
318 | + if($use_map) { |
|
319 | + $map_file = base64_decode(Filter::post('map_file')); |
|
320 | + $map_top_level = Filter::postInteger('map_top_level'); |
|
321 | + } |
|
322 | + $use_flags = Filter::postBool('use_flags'); |
|
323 | + $gen_details = Filter::postInteger('gen_details'); |
|
324 | 324 | |
325 | - $success = false; |
|
326 | - if($ga_id) { |
|
327 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
328 | - if($ga) { |
|
329 | - $ga->setTitle($description); |
|
330 | - $ga->setAnalysisLevel($analysislevel + 1); |
|
331 | - $options = $ga->getOptions(); |
|
332 | - if($options) { |
|
333 | - $options->setUsingFlags($use_flags); |
|
334 | - $options->setMaxDetailsInGen($gen_details); |
|
335 | - if($use_map) { |
|
336 | - $options->setMap(new OutlineMap($map_file)); |
|
337 | - $options->setMapLevel($map_top_level + 1); |
|
338 | - } |
|
339 | - else { |
|
340 | - $options->setMap(null); |
|
341 | - } |
|
342 | - } |
|
325 | + $success = false; |
|
326 | + if($ga_id) { |
|
327 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
328 | + if($ga) { |
|
329 | + $ga->setTitle($description); |
|
330 | + $ga->setAnalysisLevel($analysislevel + 1); |
|
331 | + $options = $ga->getOptions(); |
|
332 | + if($options) { |
|
333 | + $options->setUsingFlags($use_flags); |
|
334 | + $options->setMaxDetailsInGen($gen_details); |
|
335 | + if($use_map) { |
|
336 | + $options->setMap(new OutlineMap($map_file)); |
|
337 | + $options->setMapLevel($map_top_level + 1); |
|
338 | + } |
|
339 | + else { |
|
340 | + $options->setMap(null); |
|
341 | + } |
|
342 | + } |
|
343 | 343 | |
344 | 344 | $res = $this->provider->updateGeoAnalysis($ga); |
345 | 345 | if($res) { |
@@ -352,8 +352,8 @@ discard block |
||
352 | 352 | FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger'); |
353 | 353 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.'); |
354 | 354 | } |
355 | - } |
|
356 | - } else { |
|
355 | + } |
|
356 | + } else { |
|
357 | 357 | $ga = $this->provider->createGeoAnalysis( |
358 | 358 | $description, |
359 | 359 | $analysislevel + 1, |
@@ -371,33 +371,33 @@ discard block |
||
371 | 371 | FlashMessages::addMessage(I18N::translate('An error occured while adding the geographical dispersion analysis “%s”', $description), 'danger'); |
372 | 372 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis “'.$description.'” could not be added. See error log.'); |
373 | 373 | } |
374 | - } |
|
374 | + } |
|
375 | 375 | |
376 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl(); |
|
377 | - if(!$success) { |
|
378 | - if($ga) { |
|
379 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl(); |
|
380 | - } |
|
381 | - else { |
|
382 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl(); |
|
383 | - } |
|
384 | - } |
|
385 | - header('Location: ' . WT_BASE_URL . $redirection_url); |
|
376 | + $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl(); |
|
377 | + if(!$success) { |
|
378 | + if($ga) { |
|
379 | + $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl(); |
|
380 | + } |
|
381 | + else { |
|
382 | + $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl(); |
|
383 | + } |
|
384 | + } |
|
385 | + header('Location: ' . WT_BASE_URL . $redirection_url); |
|
386 | 386 | |
387 | - } |
|
387 | + } |
|
388 | 388 | |
389 | 389 | /** |
390 | 390 | * Renders the edit form, whether it is an edition of an existing GeoAnalysis, or the addition of a new one. |
391 | 391 | * |
392 | 392 | * @param (GeoAnalysis!null) $ga GeoAnalysis to edit |
393 | 393 | */ |
394 | - protected function renderEdit(GeoAnalysis $ga = null) { |
|
395 | - $wt_tree = Globals::getTree(); |
|
396 | - Theme::theme(new AdministrationTheme)->init($wt_tree); |
|
397 | - $controller = new PageController(); |
|
398 | - $controller |
|
399 | - ->restrictAccess(Auth::isManager($wt_tree)) |
|
400 | - ->addInlineJavascript(' |
|
394 | + protected function renderEdit(GeoAnalysis $ga = null) { |
|
395 | + $wt_tree = Globals::getTree(); |
|
396 | + Theme::theme(new AdministrationTheme)->init($wt_tree); |
|
397 | + $controller = new PageController(); |
|
398 | + $controller |
|
399 | + ->restrictAccess(Auth::isManager($wt_tree)) |
|
400 | + ->addInlineJavascript(' |
|
401 | 401 | function toggleMapOptions() { |
402 | 402 | if($("input:radio[name=\'use_map\']:checked").val() == 1) { |
403 | 403 | $("#map_options").show(); |
@@ -411,34 +411,34 @@ discard block |
||
411 | 411 | toggleMapOptions(); |
412 | 412 | '); |
413 | 413 | |
414 | - $data = new ViewBag(); |
|
415 | - if($ga) { |
|
416 | - $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis')); |
|
417 | - $data->set('geo_analysis', $ga); |
|
418 | - } else { |
|
419 | - $controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis')); |
|
420 | - } |
|
414 | + $data = new ViewBag(); |
|
415 | + if($ga) { |
|
416 | + $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis')); |
|
417 | + $data->set('geo_analysis', $ga); |
|
418 | + } else { |
|
419 | + $controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis')); |
|
420 | + } |
|
421 | 421 | |
422 | - $data->set('title', $controller->getPageTitle()); |
|
423 | - $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl()); |
|
424 | - $data->set('module_title', $this->module->getTitle()); |
|
425 | - $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $wt_tree->getNameUrl()); |
|
426 | - $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
422 | + $data->set('title', $controller->getPageTitle()); |
|
423 | + $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl()); |
|
424 | + $data->set('module_title', $this->module->getTitle()); |
|
425 | + $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $wt_tree->getNameUrl()); |
|
426 | + $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
427 | 427 | |
428 | - $map_list = array_map( |
|
429 | - function(OutlineMap $map) { |
|
430 | - return $map->getDescription(); |
|
431 | - }, |
|
432 | - $this->provider->getOutlineMapsList() |
|
433 | - ); |
|
434 | - asort($map_list); |
|
435 | - $data->set('map_list', $map_list); |
|
428 | + $map_list = array_map( |
|
429 | + function(OutlineMap $map) { |
|
430 | + return $map->getDescription(); |
|
431 | + }, |
|
432 | + $this->provider->getOutlineMapsList() |
|
433 | + ); |
|
434 | + asort($map_list); |
|
435 | + $data->set('map_list', $map_list); |
|
436 | 436 | |
437 | - $gen_details = array(0 => I18N::translate('All')); |
|
438 | - for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
439 | - $data->set('generation_details', $gen_details); |
|
437 | + $gen_details = array(0 => I18N::translate('All')); |
|
438 | + for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
439 | + $data->set('generation_details', $gen_details); |
|
440 | 440 | |
441 | - ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |
|
442 | - } |
|
441 | + ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |
|
442 | + } |
|
443 | 443 | |
444 | 444 | } |
445 | 445 | \ No newline at end of file |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | $data->set('title', $controller->getPageTitle()); |
72 | 72 | $data->set('tree', $wt_tree); |
73 | 73 | |
74 | - $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'); |
|
74 | + $data->set('root_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig'); |
|
75 | 75 | |
76 | - $table_id = 'table-geoanalysis-' . Uuid::uuid4(); |
|
76 | + $table_id = 'table-geoanalysis-'.Uuid::uuid4(); |
|
77 | 77 | $data->set('table_id', $table_id); |
78 | 78 | |
79 | 79 | $other_trees = array(); |
80 | 80 | foreach (Tree::getAll() as $tree) { |
81 | - if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree; |
|
81 | + if ($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree; |
|
82 | 82 | } |
83 | 83 | $data->set('other_trees', $other_trees); |
84 | 84 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | processing: true, |
102 | 102 | serverSide : true, |
103 | 103 | ajax : { |
104 | - url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonGeoAnalysisList&ged='. $wt_tree->getNameUrl().'", |
|
104 | + url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonGeoAnalysisList&ged='.$wt_tree->getNameUrl().'", |
|
105 | 105 | type : "POST" |
106 | 106 | }, |
107 | 107 | columns: [ |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | url: "module.php", |
126 | 126 | type: "GET", |
127 | 127 | data: { |
128 | - mod: "' . $this->module->getName() .'", |
|
128 | + mod: "' . $this->module->getName().'", |
|
129 | 129 | mod_action: "GeoAnalysis@setStatus", |
130 | 130 | ga_id: ga_id, |
131 | 131 | ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom, |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | }, |
134 | 134 | error: function(result, stat, error) { |
135 | 135 | var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error; |
136 | - alert("' . I18N::translate('An error occured while editing this analysis:') . '" + err); |
|
136 | + alert("' . I18N::translate('An error occured while editing this analysis:').'" + err); |
|
137 | 137 | }, |
138 | 138 | complete: function(result, stat) { |
139 | 139 | geoAnalysisTable.ajax.reload(null, false); |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | url: "module.php", |
147 | 147 | type: "GET", |
148 | 148 | data: { |
149 | - mod: "' . $this->module->getName() .'", |
|
149 | + mod: "' . $this->module->getName().'", |
|
150 | 150 | mod_action: "GeoAnalysis@delete", |
151 | 151 | ga_id: ga_id, |
152 | 152 | ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom |
153 | 153 | }, |
154 | 154 | error: function(result, stat, error) { |
155 | 155 | var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error; |
156 | - alert("' . I18N::translate('An error occured while deleting this analysis:') . '" + err); |
|
156 | + alert("' . I18N::translate('An error occured while deleting this analysis:').'" + err); |
|
157 | 157 | }, |
158 | 158 | complete: function(result, stat) { |
159 | 159 | geoAnalysisTable.ajax.reload(null, false); |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | |
178 | 178 | // Generate an AJAX/JSON response for datatables to load a block of rows |
179 | 179 | $search = Filter::postArray('search'); |
180 | - if($search) $search = $search['value']; |
|
180 | + if ($search) $search = $search['value']; |
|
181 | 181 | $start = Filter::postInteger('start'); |
182 | 182 | $length = Filter::postInteger('length'); |
183 | 183 | $order = Filter::postArray('order'); |
184 | 184 | |
185 | - foreach($order as $key => &$value) { |
|
186 | - switch($value['column']) { |
|
185 | + foreach ($order as $key => &$value) { |
|
186 | + switch ($value['column']) { |
|
187 | 187 | case 3: |
188 | 188 | $value['column'] = 'majgd_descr'; |
189 | 189 | break; |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | |
205 | 205 | $data = array(); |
206 | 206 | $place_hierarchy = $this->provider->getPlacesHierarchy(); |
207 | - foreach($list as $ga) { |
|
207 | + foreach ($list as $ga) { |
|
208 | 208 | /** @var GeoAnalysis $ga */ |
209 | 209 | |
210 | 210 | $datum = array(); |
211 | - $options= $ga->getOptions(); |
|
211 | + $options = $ga->getOptions(); |
|
212 | 212 | |
213 | 213 | $datum[0] = ' |
214 | 214 | <div class="btn-group"> |
@@ -218,45 +218,44 @@ discard block |
||
218 | 218 | <ul class="dropdown-menu" role="menu"> |
219 | 219 | <li> |
220 | 220 | <a href="#" onclick="return set_geoanalysis_status('. $ga->getId().', '.($ga->isEnabled() ? 'false' : 'true').', \''.Filter::escapeJs($wt_tree->getName()).'\');"> |
221 | - <i class="fa fa-fw '.($ga->isEnabled() ? 'fa-times' : 'fa-check').'"></i> ' . ($ga->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')) . ' |
|
221 | + <i class="fa fa-fw '.($ga->isEnabled() ? 'fa-times' : 'fa-check').'"></i> '.($ga->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')).' |
|
222 | 222 | </a> |
223 | 223 | </li> |
224 | 224 | <li> |
225 | 225 | <a href="module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@edit&ga_id='.$ga->getId().'&ged='.$wt_tree->getName().'"> |
226 | - <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit') . ' |
|
226 | + <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit').' |
|
227 | 227 | </a> |
228 | 228 | </li> |
229 | 229 | <li class="divider" /> |
230 | 230 | <li> |
231 | 231 | <a href="#" onclick="return delete_geoanalysis('. $ga->getId().', \''.Filter::escapeJs($wt_tree->getName()).'\');"> |
232 | - <i class="fa fa-fw fa-trash-o"></i> ' . I18N::translate('Delete') . ' |
|
232 | + <i class="fa fa-fw fa-trash-o"></i> ' . I18N::translate('Delete').' |
|
233 | 233 | </a> |
234 | 234 | </li> |
235 | 235 | </ul> |
236 | 236 | </div>'; |
237 | 237 | $datum[1] = $ga->getId(); |
238 | 238 | $datum[2] = $ga->isEnabled() ? |
239 | - '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : |
|
240 | - '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
|
239 | + '<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>'; |
|
241 | 240 | $datum[3] = $ga->getTitle(); |
242 | 241 | $analysis_level = $ga->getAnalysisLevel(); |
243 | - if($place_hierarchy['type'] == 'header') { |
|
242 | + if ($place_hierarchy['type'] == 'header') { |
|
244 | 243 | $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1]; |
245 | 244 | } else { |
246 | - $datum[4] = $analysis_level . '(' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')'; |
|
245 | + $datum[4] = $analysis_level.'('.$place_hierarchy['hierarchy'][$analysis_level - 1].')'; |
|
247 | 246 | } |
248 | 247 | $datum[5] = $ga->getAnalysisLevel(); |
249 | 248 | $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
250 | 249 | $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
251 | - if($ga->hasMap()) { |
|
252 | - if($options->getMap()->isLoaded()) { |
|
250 | + if ($ga->hasMap()) { |
|
251 | + if ($options->getMap()->isLoaded()) { |
|
253 | 252 | $datum[6] = $options->getMap()->getDescription(); |
254 | - $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />'; |
|
253 | + $datum[7] = '<span data-toggle="tooltip" title="'.$options->getMap()->getTopLevelName().'" />'; |
|
255 | 254 | $top_level = $options->getMapLevel(); |
256 | - if($place_hierarchy['type'] == 'header') { |
|
255 | + if ($place_hierarchy['type'] == 'header') { |
|
257 | 256 | $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1]; |
258 | 257 | } else { |
259 | - $datum[7] .= $top_level . '(' . $place_hierarchy['hierarchy'][$top_level - 1] . ')'; |
|
258 | + $datum[7] .= $top_level.'('.$place_hierarchy['hierarchy'][$top_level - 1].')'; |
|
260 | 259 | } |
261 | 260 | $datum[7] .= '</span>'; |
262 | 261 | } |
@@ -265,8 +264,7 @@ discard block |
||
265 | 264 | } |
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; |
@@ -315,24 +313,24 @@ discard block |
||
315 | 313 | $description = Filter::post('description'); |
316 | 314 | $analysislevel = Filter::postInteger('analysislevel'); |
317 | 315 | $use_map = Filter::postBool('use_map'); |
318 | - if($use_map) { |
|
316 | + if ($use_map) { |
|
319 | 317 | $map_file = base64_decode(Filter::post('map_file')); |
320 | - $map_top_level = Filter::postInteger('map_top_level'); |
|
318 | + $map_top_level = Filter::postInteger('map_top_level'); |
|
321 | 319 | } |
322 | 320 | $use_flags = Filter::postBool('use_flags'); |
323 | 321 | $gen_details = Filter::postInteger('gen_details'); |
324 | 322 | |
325 | 323 | $success = false; |
326 | - if($ga_id) { |
|
324 | + if ($ga_id) { |
|
327 | 325 | $ga = $this->provider->getGeoAnalysis($ga_id, false); |
328 | - if($ga) { |
|
326 | + if ($ga) { |
|
329 | 327 | $ga->setTitle($description); |
330 | 328 | $ga->setAnalysisLevel($analysislevel + 1); |
331 | 329 | $options = $ga->getOptions(); |
332 | - if($options) { |
|
330 | + if ($options) { |
|
333 | 331 | $options->setUsingFlags($use_flags); |
334 | 332 | $options->setMaxDetailsInGen($gen_details); |
335 | - if($use_map) { |
|
333 | + if ($use_map) { |
|
336 | 334 | $options->setMap(new OutlineMap($map_file)); |
337 | 335 | $options->setMapLevel($map_top_level + 1); |
338 | 336 | } |
@@ -342,7 +340,7 @@ discard block |
||
342 | 340 | } |
343 | 341 | |
344 | 342 | $res = $this->provider->updateGeoAnalysis($ga); |
345 | - if($res) { |
|
343 | + if ($res) { |
|
346 | 344 | FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully updated', $res->getTitle()), 'success'); |
347 | 345 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$res->getId().'” has been updated.'); |
348 | 346 | $ga = $res; |
@@ -350,7 +348,7 @@ discard block |
||
350 | 348 | } |
351 | 349 | else { |
352 | 350 | FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger'); |
353 | - Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.'); |
|
351 | + Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$ga->getId().'” could not be updated. See error log.'); |
|
354 | 352 | } |
355 | 353 | } |
356 | 354 | } else { |
@@ -362,7 +360,7 @@ discard block |
||
362 | 360 | $use_flags, |
363 | 361 | $gen_details |
364 | 362 | ); |
365 | - if($ga) { |
|
363 | + if ($ga) { |
|
366 | 364 | FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully added.', $ga->getTitle()), 'success'); |
367 | 365 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$ga->getId().'” has been added.'); |
368 | 366 | $success = true; |
@@ -373,16 +371,16 @@ discard block |
||
373 | 371 | } |
374 | 372 | } |
375 | 373 | |
376 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl(); |
|
377 | - if(!$success) { |
|
378 | - if($ga) { |
|
379 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl(); |
|
374 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig&ged='.$wt_tree->getNameUrl(); |
|
375 | + if (!$success) { |
|
376 | + if ($ga) { |
|
377 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@edit&ga_id='.$ga->getId().'&ged='.$wt_tree->getNameUrl(); |
|
380 | 378 | } |
381 | 379 | else { |
382 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl(); |
|
380 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@add&ged='.$wt_tree->getNameUrl(); |
|
383 | 381 | } |
384 | 382 | } |
385 | - header('Location: ' . WT_BASE_URL . $redirection_url); |
|
383 | + header('Location: '.WT_BASE_URL.$redirection_url); |
|
386 | 384 | |
387 | 385 | } |
388 | 386 | |
@@ -412,7 +410,7 @@ discard block |
||
412 | 410 | '); |
413 | 411 | |
414 | 412 | $data = new ViewBag(); |
415 | - if($ga) { |
|
413 | + if ($ga) { |
|
416 | 414 | $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis')); |
417 | 415 | $data->set('geo_analysis', $ga); |
418 | 416 | } else { |
@@ -420,9 +418,9 @@ discard block |
||
420 | 418 | } |
421 | 419 | |
422 | 420 | $data->set('title', $controller->getPageTitle()); |
423 | - $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl()); |
|
421 | + $data->set('admin_config_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig&ged='.$wt_tree->getNameUrl()); |
|
424 | 422 | $data->set('module_title', $this->module->getTitle()); |
425 | - $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $wt_tree->getNameUrl()); |
|
423 | + $data->set('save_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@save&ged='.$wt_tree->getNameUrl()); |
|
426 | 424 | $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
427 | 425 | |
428 | 426 | $map_list = array_map( |
@@ -435,7 +433,7 @@ discard block |
||
435 | 433 | $data->set('map_list', $map_list); |
436 | 434 | |
437 | 435 | $gen_details = array(0 => I18N::translate('All')); |
438 | - for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
436 | + for ($i = 1; $i <= 10; $i++) $gen_details[$i] = $i; |
|
439 | 437 | $data->set('generation_details', $gen_details); |
440 | 438 | |
441 | 439 | ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |
@@ -78,7 +78,9 @@ discard block |
||
78 | 78 | |
79 | 79 | $other_trees = array(); |
80 | 80 | foreach (Tree::getAll() as $tree) { |
81 | - if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree; |
|
81 | + if($tree->getTreeId() != $wt_tree->getTreeId()) { |
|
82 | + $other_trees[] = $tree; |
|
83 | + } |
|
82 | 84 | } |
83 | 85 | $data->set('other_trees', $other_trees); |
84 | 86 | |
@@ -177,7 +179,9 @@ discard block |
||
177 | 179 | |
178 | 180 | // Generate an AJAX/JSON response for datatables to load a block of rows |
179 | 181 | $search = Filter::postArray('search'); |
180 | - if($search) $search = $search['value']; |
|
182 | + if($search) { |
|
183 | + $search = $search['value']; |
|
184 | + } |
|
181 | 185 | $start = Filter::postInteger('start'); |
182 | 186 | $length = Filter::postInteger('length'); |
183 | 187 | $order = Filter::postArray('order'); |
@@ -259,8 +263,7 @@ discard block |
||
259 | 263 | $datum[7] .= $top_level . '(' . $place_hierarchy['hierarchy'][$top_level - 1] . ')'; |
260 | 264 | } |
261 | 265 | $datum[7] .= '</span>'; |
262 | - } |
|
263 | - else { |
|
266 | + } else { |
|
264 | 267 | $datum[6] = I18N::translate('Error when loading map.'); |
265 | 268 | } |
266 | 269 | } |
@@ -335,8 +338,7 @@ discard block |
||
335 | 338 | if($use_map) { |
336 | 339 | $options->setMap(new OutlineMap($map_file)); |
337 | 340 | $options->setMapLevel($map_top_level + 1); |
338 | - } |
|
339 | - else { |
|
341 | + } else { |
|
340 | 342 | $options->setMap(null); |
341 | 343 | } |
342 | 344 | } |
@@ -347,8 +349,7 @@ discard block |
||
347 | 349 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$res->getId().'” has been updated.'); |
348 | 350 | $ga = $res; |
349 | 351 | $success = true; |
350 | - } |
|
351 | - else { |
|
352 | + } else { |
|
352 | 353 | FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger'); |
353 | 354 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.'); |
354 | 355 | } |
@@ -366,8 +367,7 @@ discard block |
||
366 | 367 | FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully added.', $ga->getTitle()), 'success'); |
367 | 368 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$ga->getId().'” has been added.'); |
368 | 369 | $success = true; |
369 | - } |
|
370 | - else { |
|
370 | + } else { |
|
371 | 371 | FlashMessages::addMessage(I18N::translate('An error occured while adding the geographical dispersion analysis “%s”', $description), 'danger'); |
372 | 372 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis “'.$description.'” could not be added. See error log.'); |
373 | 373 | } |
@@ -377,8 +377,7 @@ discard block |
||
377 | 377 | if(!$success) { |
378 | 378 | if($ga) { |
379 | 379 | $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl(); |
380 | - } |
|
381 | - else { |
|
380 | + } else { |
|
382 | 381 | $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl(); |
383 | 382 | } |
384 | 383 | } |
@@ -435,7 +434,9 @@ discard block |
||
435 | 434 | $data->set('map_list', $map_list); |
436 | 435 | |
437 | 436 | $gen_details = array(0 => I18N::translate('All')); |
438 | - for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
437 | + for($i = 1; $i <= 10 ; $i++) { |
|
438 | + $gen_details[$i] = $i; |
|
439 | + } |
|
439 | 440 | $data->set('generation_details', $gen_details); |
440 | 441 | |
441 | 442 | ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |