Completed
Push — master ( 960061...3603f5 )
by Jonathan
01:43
created
src/Webtrees/Module/GeoDispersion/Model/OutlineMap.php 3 patches
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -22,187 +22,187 @@
 block discarded – undo
22 22
 	 * Name of the file containing the description of the map.
23 23
 	 * @var string $filename
24 24
 	 */
25
-    protected $filename;
25
+	protected $filename;
26 26
     
27 27
 	/**
28 28
 	 * Indicates whether the description has been loaded from the file.
29 29
 	 * @var bool $is_loaded
30 30
 	 */
31
-    protected $is_loaded;
31
+	protected $is_loaded;
32 32
     
33 33
 	/**
34 34
 	 * Description/title of the map.
35 35
 	 * @var string $description
36 36
 	 */
37
-    protected $description;
37
+	protected $description;
38 38
     
39 39
 	/**
40 40
 	 * Name(s) of the parent level(s) of the map.
41 41
 	 * @var string $is_loaded
42 42
 	 */
43
-    protected $top_level_name;
44
-    
45
-    /**
46
-     * Map canvas
47
-     * @var OutlineMapCanvas $canvas
48
-     */
49
-    protected $canvas;
50
-    
51
-    /**
52
-     * Map subdivisions
53
-     * @var array $subdivisions
54
-     */
55
-    protected $subdivisions;
56
-    
57
-    /**
58
-     * Places mappings
59
-     * @var array $subdivisions
60
-     */
61
-    protected $mappings;
62
-    
63
-    /**
64
-     * Constructor for GeoAnalysisMap.
65
-     *
66
-     * @param string $filename Outline map file name
67
-     * @param bool $load Should the map be loaded immediately
68
-     */
69
-    public function __construct($filename, $load = false) {
70
-        $this->filename = $filename;
71
-        $this->is_loaded = false;
72
-        $this->subdivisions = array();
73
-        $this->mappings = array();
74
-        if($load) $this->load();
75
-    }
76
-    
77
-    /**
78
-     * Load the map settings contained within its XML representation
79
-     *
80
-     * XML structure :
81
-     * 	- displayName : Display name of the map
82
-     * 	- topLevel : Values of the top level subdivisions (separated by commas, if multiple)
83
-     * 	- canvas : all settings related to the map canvas.
84
-     * 		- width : canvas width, in px
85
-     * 		- height : canvas height, in px
86
-     * 		- maxcolor : color to identify places with ancestors, RGB hexadecimal
87
-     * 		- hovercolor : same as previous, color when mouse is hovering the place, RGB hexadecimal
88
-     * 		- bgcolor : map background color, RGB hexadecimal
89
-     * 		- bgstroke : map stroke color, RGB hexadecimal
90
-     * 		- defaultcolor : default color of places, RGB hexadecimal
91
-     * 		- defaultstroke : default stroke color, RGB hexadecimal
92
-     * 	- subdvisions : for each subdivision :
43
+	protected $top_level_name;
44
+    
45
+	/**
46
+	 * Map canvas
47
+	 * @var OutlineMapCanvas $canvas
48
+	 */
49
+	protected $canvas;
50
+    
51
+	/**
52
+	 * Map subdivisions
53
+	 * @var array $subdivisions
54
+	 */
55
+	protected $subdivisions;
56
+    
57
+	/**
58
+	 * Places mappings
59
+	 * @var array $subdivisions
60
+	 */
61
+	protected $mappings;
62
+    
63
+	/**
64
+	 * Constructor for GeoAnalysisMap.
65
+	 *
66
+	 * @param string $filename Outline map file name
67
+	 * @param bool $load Should the map be loaded immediately
68
+	 */
69
+	public function __construct($filename, $load = false) {
70
+		$this->filename = $filename;
71
+		$this->is_loaded = false;
72
+		$this->subdivisions = array();
73
+		$this->mappings = array();
74
+		if($load) $this->load();
75
+	}
76
+    
77
+	/**
78
+	 * Load the map settings contained within its XML representation
79
+	 *
80
+	 * XML structure :
81
+	 * 	- displayName : Display name of the map
82
+	 * 	- topLevel : Values of the top level subdivisions (separated by commas, if multiple)
83
+	 * 	- canvas : all settings related to the map canvas.
84
+	 * 		- width : canvas width, in px
85
+	 * 		- height : canvas height, in px
86
+	 * 		- maxcolor : color to identify places with ancestors, RGB hexadecimal
87
+	 * 		- hovercolor : same as previous, color when mouse is hovering the place, RGB hexadecimal
88
+	 * 		- bgcolor : map background color, RGB hexadecimal
89
+	 * 		- bgstroke : map stroke color, RGB hexadecimal
90
+	 * 		- defaultcolor : default color of places, RGB hexadecimal
91
+	 * 		- defaultstroke : default stroke color, RGB hexadecimal
92
+	 * 	- subdvisions : for each subdivision :
93 93
 	 *		- id : Subdivision id, must be compatible with PHP variable constraints, and unique
94
-     * 		- name: Display name for the place
94
+	 * 		- name: Display name for the place
95 95
 	 *		- parent: if any, describe to which parent level the place if belonging to
96
-     * 		- <em>Element value<em> : SVG description of the subdvision shape
96
+	 * 		- <em>Element value<em> : SVG description of the subdvision shape
97 97
 	 *	- mapping : for each subdivision :
98 98
 	 *		- name : Name of the place to map
99
-     * 		- mapto: Name of the place to map to
99
+	 * 		- mapto: Name of the place to map to
100 100
 	 * 
101
-     */
102
-    protected function load() {
103
-        if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){
104
-            $xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename);
105
-            if($xml){
106
-                $this->description = trim($xml->displayName);
107
-                $this->top_level_name = trim($xml->topLevel);
108
-                $this->canvas = new OutlineMapCanvas(
109
-                    trim($xml->canvas->width),
110
-                    trim($xml->canvas->height), 
111
-                    trim($xml->canvas->maxcolor), 
112
-                    trim($xml->canvas->hovercolor), 
113
-                    trim($xml->canvas->bgcolor),
114
-                    trim($xml->canvas->bgstroke),
115
-                    trim($xml->canvas->defaultcolor), 
116
-                    trim($xml->canvas->defaultstroke)
117
-                );
118
-                foreach($xml->subdivisions->children() as $subdivision){
119
-                    $attributes = $subdivision->attributes();
120
-                    $key = I18N::strtolower(trim($attributes['name']));
121
-                    if(isset($attributes['parent'])) $key .= '@'. I18N::strtolower(trim($attributes['parent']));
122
-                    $this->subdivisions[$key] = array(
123
-                        'id' => trim($attributes['id']),
124
-                        'displayname' => trim($attributes['name']),
125
-                        'coord' => trim($subdivision[0])
126
-                    );
127
-                }
128
-                if(isset($xml->mappings)) {
129
-                    foreach($xml->mappings->children() as $mappings){
130
-                        $attributes = $mappings->attributes();
131
-                        $this->mappings[I18N::strtolower(trim($attributes['name']))] = I18N::strtolower(trim($attributes['mapto']));
132
-                    }
133
-                }
134
-                $this->is_loaded = true;
135
-                return;
136
-            }
137
-        }
138
-        throw new \Exception('The Outline Map could not be loaded from XML.');
139
-    }
140
-    
141
-    /**
142
-     * Get the status of the map loading from the XML file.
143
-     * 
144
-     * @return bool
145
-     */
146
-    public function isLoaded() {
147
-        try{
148
-            if(!$this->is_loaded) $this->load();
149
-        }
150
-        catch (\Exception $ex) { }
151
-        return $this->is_loaded;
152
-    }
101
+	 */
102
+	protected function load() {
103
+		if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){
104
+			$xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename);
105
+			if($xml){
106
+				$this->description = trim($xml->displayName);
107
+				$this->top_level_name = trim($xml->topLevel);
108
+				$this->canvas = new OutlineMapCanvas(
109
+					trim($xml->canvas->width),
110
+					trim($xml->canvas->height), 
111
+					trim($xml->canvas->maxcolor), 
112
+					trim($xml->canvas->hovercolor), 
113
+					trim($xml->canvas->bgcolor),
114
+					trim($xml->canvas->bgstroke),
115
+					trim($xml->canvas->defaultcolor), 
116
+					trim($xml->canvas->defaultstroke)
117
+				);
118
+				foreach($xml->subdivisions->children() as $subdivision){
119
+					$attributes = $subdivision->attributes();
120
+					$key = I18N::strtolower(trim($attributes['name']));
121
+					if(isset($attributes['parent'])) $key .= '@'. I18N::strtolower(trim($attributes['parent']));
122
+					$this->subdivisions[$key] = array(
123
+						'id' => trim($attributes['id']),
124
+						'displayname' => trim($attributes['name']),
125
+						'coord' => trim($subdivision[0])
126
+					);
127
+				}
128
+				if(isset($xml->mappings)) {
129
+					foreach($xml->mappings->children() as $mappings){
130
+						$attributes = $mappings->attributes();
131
+						$this->mappings[I18N::strtolower(trim($attributes['name']))] = I18N::strtolower(trim($attributes['mapto']));
132
+					}
133
+				}
134
+				$this->is_loaded = true;
135
+				return;
136
+			}
137
+		}
138
+		throw new \Exception('The Outline Map could not be loaded from XML.');
139
+	}
140
+    
141
+	/**
142
+	 * Get the status of the map loading from the XML file.
143
+	 * 
144
+	 * @return bool
145
+	 */
146
+	public function isLoaded() {
147
+		try{
148
+			if(!$this->is_loaded) $this->load();
149
+		}
150
+		catch (\Exception $ex) { }
151
+		return $this->is_loaded;
152
+	}
153 153
     
154 154
 	/**
155 155
 	 * Get the map file name.
156 156
 	 * @return string
157 157
 	 */
158
-    public function getFileName() {
159
-        return $this->filename;
160
-    }
158
+	public function getFileName() {
159
+		return $this->filename;
160
+	}
161 161
     
162 162
 	/**
163 163
 	 * Get the map file name.
164 164
 	 * @return string
165 165
 	 */
166
-    public function getDescription() {
167
-        if(!$this->is_loaded) $this->load();
168
-        return $this->description;
169
-    }
166
+	public function getDescription() {
167
+		if(!$this->is_loaded) $this->load();
168
+		return $this->description;
169
+	}
170 170
     
171 171
 	/**
172 172
 	 * Get the name of the map parent level. 
173 173
 	 * @return string
174 174
 	 */
175
-    public function getTopLevelName() {
176
-        if(!$this->is_loaded) $this->load();
177
-        return $this->top_level_name;
178
-    }    
179
-    
180
-    /**
181
-     * Get the Outline Map canvas.
182
-     * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas
183
-     */
184
-    public function getCanvas() {
185
-        if(!$this->is_loaded) $this->load();
186
-        return $this->canvas;
187
-    }
188
-    
189
-	/**
190
-     * Get the subdivisions of the map.
191
-     * @return array
192
-     */
193
-    public function getSubdivisions() {
194
-        if(!$this->is_loaded) $this->load();
195
-        return $this->subdivisions;
196
-    }
197
-    
198
-	/**
199
-     * Get the places mappings of the map.
200
-     * @return array
201
-     */
202
-    public function getPlacesMappings() {
203
-        if(!$this->is_loaded) $this->load();
204
-        return $this->mappings;
205
-    }
175
+	public function getTopLevelName() {
176
+		if(!$this->is_loaded) $this->load();
177
+		return $this->top_level_name;
178
+	}    
179
+    
180
+	/**
181
+	 * Get the Outline Map canvas.
182
+	 * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas
183
+	 */
184
+	public function getCanvas() {
185
+		if(!$this->is_loaded) $this->load();
186
+		return $this->canvas;
187
+	}
188
+    
189
+	/**
190
+	 * Get the subdivisions of the map.
191
+	 * @return array
192
+	 */
193
+	public function getSubdivisions() {
194
+		if(!$this->is_loaded) $this->load();
195
+		return $this->subdivisions;
196
+	}
197
+    
198
+	/**
199
+	 * Get the places mappings of the map.
200
+	 * @return array
201
+	 */
202
+	public function getPlacesMappings() {
203
+		if(!$this->is_loaded) $this->load();
204
+		return $this->mappings;
205
+	}
206 206
     
207 207
 }
208 208
  
209 209
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         $this->is_loaded = false;
72 72
         $this->subdivisions = array();
73 73
         $this->mappings = array();
74
-        if($load) $this->load();
74
+        if ($load) $this->load();
75 75
     }
76 76
     
77 77
     /**
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 	 * 
101 101
      */
102 102
     protected function load() {
103
-        if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){
103
+        if (file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)) {
104 104
             $xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename);
105
-            if($xml){
105
+            if ($xml) {
106 106
                 $this->description = trim($xml->displayName);
107 107
                 $this->top_level_name = trim($xml->topLevel);
108 108
                 $this->canvas = new OutlineMapCanvas(
@@ -115,18 +115,18 @@  discard block
 block discarded – undo
115 115
                     trim($xml->canvas->defaultcolor), 
116 116
                     trim($xml->canvas->defaultstroke)
117 117
                 );
118
-                foreach($xml->subdivisions->children() as $subdivision){
118
+                foreach ($xml->subdivisions->children() as $subdivision) {
119 119
                     $attributes = $subdivision->attributes();
120 120
                     $key = I18N::strtolower(trim($attributes['name']));
121
-                    if(isset($attributes['parent'])) $key .= '@'. I18N::strtolower(trim($attributes['parent']));
121
+                    if (isset($attributes['parent'])) $key .= '@'.I18N::strtolower(trim($attributes['parent']));
122 122
                     $this->subdivisions[$key] = array(
123 123
                         'id' => trim($attributes['id']),
124 124
                         'displayname' => trim($attributes['name']),
125 125
                         'coord' => trim($subdivision[0])
126 126
                     );
127 127
                 }
128
-                if(isset($xml->mappings)) {
129
-                    foreach($xml->mappings->children() as $mappings){
128
+                if (isset($xml->mappings)) {
129
+                    foreach ($xml->mappings->children() as $mappings) {
130 130
                         $attributes = $mappings->attributes();
131 131
                         $this->mappings[I18N::strtolower(trim($attributes['name']))] = I18N::strtolower(trim($attributes['mapto']));
132 132
                     }
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
      * @return bool
145 145
      */
146 146
     public function isLoaded() {
147
-        try{
148
-            if(!$this->is_loaded) $this->load();
147
+        try {
148
+            if (!$this->is_loaded) $this->load();
149 149
         }
150 150
         catch (\Exception $ex) { }
151 151
         return $this->is_loaded;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 * @return string
165 165
 	 */
166 166
     public function getDescription() {
167
-        if(!$this->is_loaded) $this->load();
167
+        if (!$this->is_loaded) $this->load();
168 168
         return $this->description;
169 169
     }
170 170
     
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 * @return string
174 174
 	 */
175 175
     public function getTopLevelName() {
176
-        if(!$this->is_loaded) $this->load();
176
+        if (!$this->is_loaded) $this->load();
177 177
         return $this->top_level_name;
178 178
     }    
179 179
     
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas
183 183
      */
184 184
     public function getCanvas() {
185
-        if(!$this->is_loaded) $this->load();
185
+        if (!$this->is_loaded) $this->load();
186 186
         return $this->canvas;
187 187
     }
188 188
     
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
      * @return array
192 192
      */
193 193
     public function getSubdivisions() {
194
-        if(!$this->is_loaded) $this->load();
194
+        if (!$this->is_loaded) $this->load();
195 195
         return $this->subdivisions;
196 196
     }
197 197
     
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      * @return array
201 201
      */
202 202
     public function getPlacesMappings() {
203
-        if(!$this->is_loaded) $this->load();
203
+        if (!$this->is_loaded) $this->load();
204 204
         return $this->mappings;
205 205
     }
206 206
     
Please login to merge, or discard this patch.
Braces   +25 added lines, -10 removed lines patch added patch discarded remove patch
@@ -71,7 +71,9 @@  discard block
 block discarded – undo
71 71
         $this->is_loaded = false;
72 72
         $this->subdivisions = array();
73 73
         $this->mappings = array();
74
-        if($load) $this->load();
74
+        if($load) {
75
+        	$this->load();
76
+        }
75 77
     }
76 78
     
77 79
     /**
@@ -118,7 +120,9 @@  discard block
 block discarded – undo
118 120
                 foreach($xml->subdivisions->children() as $subdivision){
119 121
                     $attributes = $subdivision->attributes();
120 122
                     $key = I18N::strtolower(trim($attributes['name']));
121
-                    if(isset($attributes['parent'])) $key .= '@'. I18N::strtolower(trim($attributes['parent']));
123
+                    if(isset($attributes['parent'])) {
124
+                    	$key .= '@'. I18N::strtolower(trim($attributes['parent']));
125
+                    }
122 126
                     $this->subdivisions[$key] = array(
123 127
                         'id' => trim($attributes['id']),
124 128
                         'displayname' => trim($attributes['name']),
@@ -145,9 +149,10 @@  discard block
 block discarded – undo
145 149
      */
146 150
     public function isLoaded() {
147 151
         try{
148
-            if(!$this->is_loaded) $this->load();
149
-        }
150
-        catch (\Exception $ex) { }
152
+            if(!$this->is_loaded) {
153
+            	$this->load();
154
+            }
155
+        } catch (\Exception $ex) { }
151 156
         return $this->is_loaded;
152 157
     }
153 158
     
@@ -164,7 +169,9 @@  discard block
 block discarded – undo
164 169
 	 * @return string
165 170
 	 */
166 171
     public function getDescription() {
167
-        if(!$this->is_loaded) $this->load();
172
+        if(!$this->is_loaded) {
173
+        	$this->load();
174
+        }
168 175
         return $this->description;
169 176
     }
170 177
     
@@ -173,7 +180,9 @@  discard block
 block discarded – undo
173 180
 	 * @return string
174 181
 	 */
175 182
     public function getTopLevelName() {
176
-        if(!$this->is_loaded) $this->load();
183
+        if(!$this->is_loaded) {
184
+        	$this->load();
185
+        }
177 186
         return $this->top_level_name;
178 187
     }    
179 188
     
@@ -182,7 +191,9 @@  discard block
 block discarded – undo
182 191
      * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas
183 192
      */
184 193
     public function getCanvas() {
185
-        if(!$this->is_loaded) $this->load();
194
+        if(!$this->is_loaded) {
195
+        	$this->load();
196
+        }
186 197
         return $this->canvas;
187 198
     }
188 199
     
@@ -191,7 +202,9 @@  discard block
 block discarded – undo
191 202
      * @return array
192 203
      */
193 204
     public function getSubdivisions() {
194
-        if(!$this->is_loaded) $this->load();
205
+        if(!$this->is_loaded) {
206
+        	$this->load();
207
+        }
195 208
         return $this->subdivisions;
196 209
     }
197 210
     
@@ -200,7 +213,9 @@  discard block
 block discarded – undo
200 213
      * @return array
201 214
      */
202 215
     public function getPlacesMappings() {
203
-        if(!$this->is_loaded) $this->load();
216
+        if(!$this->is_loaded) {
217
+        	$this->load();
218
+        }
204 219
         return $this->mappings;
205 220
     }
206 221
     
Please login to merge, or discard this patch.
src/Webtrees/Module/GeoDispersion/GeoAnalysisController.php 3 patches
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -36,47 +36,47 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,71 +228,71 @@  discard block
 block discarded – undo
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 = I18N::strtolower($levelvalues[0] . '@' . $levelvalues[$level_map]);
257
-                            if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; }
258
-                        }
259
-                        else {
260
-                            $levelref = $levelvalues[0];
261
-                        }
262
-                        $levelref = I18N::strtolower($levelref);
263
-                        if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref];
264
-                        if(isset($results_by_subdivs[$levelref])) {
265
-                            $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0;
266
-                            $count_subd  += $count;
267
-                            $results_by_subdivs[$levelref]['count'] = $count_subd;   
268
-                            $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max);
269
-                            if($ga->getOptions()->isUsingFlags() && $flags) {
270
-                                $results_by_subdivs[$levelref]['place'] = new Place($location, Globals::getTree());
271
-                                $results_by_subdivs[$levelref]['flag'] = $flags[$location];
272
-                            }
273
-                        }
274
-                    }             
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 = I18N::strtolower($levelvalues[0] . '@' . $levelvalues[$level_map]);
257
+							if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; }
258
+						}
259
+						else {
260
+							$levelref = $levelvalues[0];
261
+						}
262
+						$levelref = I18N::strtolower($levelref);
263
+						if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref];
264
+						if(isset($results_by_subdivs[$levelref])) {
265
+							$count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0;
266
+							$count_subd  += $count;
267
+							$results_by_subdivs[$levelref]['count'] = $count_subd;   
268
+							$results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max);
269
+							if($ga->getOptions()->isUsingFlags() && $flags) {
270
+								$results_by_subdivs[$levelref]['place'] = new Place($location, Globals::getTree());
271
+								$results_by_subdivs[$levelref]['flag'] = $flags[$location];
272
+							}
273
+						}
274
+					}             
275 275
                 
276
-                    $data->set('map', $map);
277
-                    $data->set('results_by_subdivisions', $results_by_subdivs);
278
-                }
276
+					$data->set('map', $map);
277
+					$data->set('results_by_subdivisions', $results_by_subdivs);
278
+				}
279 279
                 
280
-                $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial();
281
-            }
282
-            else {
283
-                $results = $placesGeneralResults['places'];
284
-                arsort($results);
285
-                $data->set('results', $results);
286
-                $data->set('analysis_level', $ga->getAnalysisLevel());
280
+				$html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial();
281
+			}
282
+			else {
283
+				$results = $placesGeneralResults['places'];
284
+				arsort($results);
285
+				$data->set('results', $results);
286
+				$data->set('analysis_level', $ga->getAnalysisLevel());
287 287
                 
288
-                $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial();
289
-            }
290
-        }
291
-        else {
292
-            $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>';
293
-        }
294
-        return $html;
295
-    }
288
+				$html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial();
289
+			}
290
+		}
291
+		else {
292
+			$html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>';
293
+		}
294
+		return $html;
295
+	}
296 296
     
297 297
 	/**
298 298
 	 * Returns HTML code for the GeoAnalysis generations tab.
@@ -302,66 +302,66 @@  discard block
 block discarded – undo
302 302
 	 * @param (null|array) $flags Array of flags
303 303
 	 * @return string HTML code for the generations tab
304 304
 	 */
305
-    protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) {        
306
-        if(!empty($placesGenerationsResults) && $ga->getOptions()){
307
-            $data = new ViewBag();
305
+	protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) {        
306
+		if(!empty($placesGenerationsResults) && $ga->getOptions()){
307
+			$data = new ViewBag();
308 308
             
309
-            ksort($placesGenerationsResults);
309
+			ksort($placesGenerationsResults);
310 310
             
311
-            $detailslevel = $ga->getOptions()->getMaxDetailsInGen();
312
-            $data->set('max_details_gen', $detailslevel);    
313
-            $data->set('use_flags', $ga->getOptions()->isUsingFlags());
314
-            $data->set('analysis_level', $ga->getAnalysisLevel());
315
-            $display_all_places = !is_null($detailslevel) && $detailslevel == 0;
316
-            $data->set('display_all_places', $display_all_places);
311
+			$detailslevel = $ga->getOptions()->getMaxDetailsInGen();
312
+			$data->set('max_details_gen', $detailslevel);    
313
+			$data->set('use_flags', $ga->getOptions()->isUsingFlags());
314
+			$data->set('analysis_level', $ga->getAnalysisLevel());
315
+			$display_all_places = !is_null($detailslevel) && $detailslevel == 0;
316
+			$data->set('display_all_places', $display_all_places);
317 317
             
318
-            $results_by_gen = array();
319
-            foreach($placesGenerationsResults as $gen => $genData){
320
-                $sum = 0;
321
-                $other = 0;
322
-                $unknown = 0;
323
-                if(isset($genData['sum'])) $sum = $genData['sum'];
324
-                if(isset($genData['other'])) $other = $genData['other'];
325
-                if(isset($genData['unknown'])) $unknown = $genData['unknown'];
318
+			$results_by_gen = array();
319
+			foreach($placesGenerationsResults as $gen => $genData){
320
+				$sum = 0;
321
+				$other = 0;
322
+				$unknown = 0;
323
+				if(isset($genData['sum'])) $sum = $genData['sum'];
324
+				if(isset($genData['other'])) $other = $genData['other'];
325
+				if(isset($genData['unknown'])) $unknown = $genData['unknown'];
326 326
                 
327
-                if($sum > 0) {                
328
-                    $results_by_gen[$gen]['sum'] = $sum;
329
-                    $results_by_gen[$gen]['other'] = $other;
330
-                    $results_by_gen[$gen]['unknown'] = $unknown;
331
-                    $results_by_gen[$gen]['places'] = array();                    
332
-                    arsort($genData['places']);
327
+				if($sum > 0) {                
328
+					$results_by_gen[$gen]['sum'] = $sum;
329
+					$results_by_gen[$gen]['other'] = $other;
330
+					$results_by_gen[$gen]['unknown'] = $unknown;
331
+					$results_by_gen[$gen]['places'] = array();                    
332
+					arsort($genData['places']);
333 333
                     
334
-                    if($display_all_places){
335
-                        foreach($genData['places'] as $placename=> $count){
336
-                            $results_by_gen[$gen]['places'][$placename]['count'] = $count;
334
+					if($display_all_places){
335
+						foreach($genData['places'] as $placename=> $count){
336
+							$results_by_gen[$gen]['places'][$placename]['count'] = $count;
337 337
                             
338
-                            if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){
339
-                                $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, Globals::getTree());
340
-                                $results_by_gen[$gen]['places'][$placename]['flag'] = $flag;
341
-                            }
342
-                        }
343
-                    }
344
-                    else {
345
-                        $tmp = $genData['places'];
346
-                        if($other > 0) {
347
-                            $tmp = array_slice($tmp, 0, 5, true);
348
-                            $tmp['other'] = $other;
349
-                            arsort($tmp);  
350
-                        }                      
351
-                        $results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true);                        
352
-                    }
353
-                }
354
-            }
338
+							if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){
339
+								$results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, Globals::getTree());
340
+								$results_by_gen[$gen]['places'][$placename]['flag'] = $flag;
341
+							}
342
+						}
343
+					}
344
+					else {
345
+						$tmp = $genData['places'];
346
+						if($other > 0) {
347
+							$tmp = array_slice($tmp, 0, 5, true);
348
+							$tmp['other'] = $other;
349
+							arsort($tmp);  
350
+						}                      
351
+						$results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true);                        
352
+					}
353
+				}
354
+			}
355 355
             
356
-            $data->set('results_by_generations', $results_by_gen);
356
+			$data->set('results_by_generations', $results_by_gen);
357 357
             
358
-            $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial();
358
+			$html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial();
359 359
             
360
-        }
361
-        else {
362
-            $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>';
363
-        }
364
-        return $html;
365
-    }
360
+		}
361
+		else {
362
+			$html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>';
363
+		}
364
+		return $html;
365
+	}
366 366
         
367 367
 }
368 368
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,30 +243,30 @@  discard block
 block discarded – undo
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 = I18N::strtolower($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 = I18N::strtolower($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 262
                         $levelref = I18N::strtolower($levelref);
263
-                        if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref];
264
-                        if(isset($results_by_subdivs[$levelref])) {
263
+                        if (isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref];
264
+                        if (isset($results_by_subdivs[$levelref])) {
265 265
                             $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0;
266
-                            $count_subd  += $count;
266
+                            $count_subd += $count;
267 267
                             $results_by_subdivs[$levelref]['count'] = $count_subd;   
268 268
                             $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max);
269
-                            if($ga->getOptions()->isUsingFlags() && $flags) {
269
+                            if ($ga->getOptions()->isUsingFlags() && $flags) {
270 270
                                 $results_by_subdivs[$levelref]['place'] = new Place($location, Globals::getTree());
271 271
                                 $results_by_subdivs[$levelref]['flag'] = $flags[$location];
272 272
                             }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
             }
290 290
         }
291 291
         else {
292
-            $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>';
292
+            $html = '<p class="warning">'.I18N::translate('No data is available for the general analysis.').'</p>';
293 293
         }
294 294
         return $html;
295 295
     }
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 	 * @return string HTML code for the generations tab
304 304
 	 */
305 305
     protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) {        
306
-        if(!empty($placesGenerationsResults) && $ga->getOptions()){
306
+        if (!empty($placesGenerationsResults) && $ga->getOptions()) {
307 307
             $data = new ViewBag();
308 308
             
309 309
             ksort($placesGenerationsResults);
@@ -316,26 +316,26 @@  discard block
 block discarded – undo
316 316
             $data->set('display_all_places', $display_all_places);
317 317
             
318 318
             $results_by_gen = array();
319
-            foreach($placesGenerationsResults as $gen => $genData){
319
+            foreach ($placesGenerationsResults as $gen => $genData) {
320 320
                 $sum = 0;
321 321
                 $other = 0;
322 322
                 $unknown = 0;
323
-                if(isset($genData['sum'])) $sum = $genData['sum'];
324
-                if(isset($genData['other'])) $other = $genData['other'];
325
-                if(isset($genData['unknown'])) $unknown = $genData['unknown'];
323
+                if (isset($genData['sum'])) $sum = $genData['sum'];
324
+                if (isset($genData['other'])) $other = $genData['other'];
325
+                if (isset($genData['unknown'])) $unknown = $genData['unknown'];
326 326
                 
327
-                if($sum > 0) {                
327
+                if ($sum > 0) {                
328 328
                     $results_by_gen[$gen]['sum'] = $sum;
329 329
                     $results_by_gen[$gen]['other'] = $other;
330 330
                     $results_by_gen[$gen]['unknown'] = $unknown;
331 331
                     $results_by_gen[$gen]['places'] = array();                    
332 332
                     arsort($genData['places']);
333 333
                     
334
-                    if($display_all_places){
335
-                        foreach($genData['places'] as $placename=> $count){
334
+                    if ($display_all_places) {
335
+                        foreach ($genData['places'] as $placename=> $count) {
336 336
                             $results_by_gen[$gen]['places'][$placename]['count'] = $count;
337 337
                             
338
-                            if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){
338
+                            if ($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != '') {
339 339
                                 $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, Globals::getTree());
340 340
                                 $results_by_gen[$gen]['places'][$placename]['flag'] = $flag;
341 341
                             }
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
                     }
344 344
                     else {
345 345
                         $tmp = $genData['places'];
346
-                        if($other > 0) {
346
+                        if ($other > 0) {
347 347
                             $tmp = array_slice($tmp, 0, 5, true);
348 348
                             $tmp['other'] = $other;
349 349
                             arsort($tmp);  
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             
360 360
         }
361 361
         else {
362
-            $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>';
362
+            $html = '<p class="warning">'.I18N::translate('No data is available for the generations analysis.').'</p>';
363 363
         }
364 364
         return $html;
365 365
     }
Please login to merge, or discard this patch.
Braces   +28 added lines, -21 removed lines patch added patch discarded remove patch
@@ -144,14 +144,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,12 +259,13 @@  discard block
 block discarded – undo
255 259
                         if($level_map >= 0 && $level_map < count($levelvalues)) {
256 260
                             $levelref = I18N::strtolower($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 265
                         $levelref = I18N::strtolower($levelref);
263
-                        if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref];
266
+                        if(isset($places_mappings[$levelref])) {
267
+                        	$levelref = $places_mappings[$levelref];
268
+                        }
264 269
                         if(isset($results_by_subdivs[$levelref])) {
265 270
                             $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0;
266 271
                             $count_subd  += $count;
@@ -278,8 +283,7 @@  discard block
 block discarded – undo
278 283
                 }
279 284
                 
280 285
                 $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial();
281
-            }
282
-            else {
286
+            } else {
283 287
                 $results = $placesGeneralResults['places'];
284 288
                 arsort($results);
285 289
                 $data->set('results', $results);
@@ -287,8 +291,7 @@  discard block
 block discarded – undo
287 291
                 
288 292
                 $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial();
289 293
             }
290
-        }
291
-        else {
294
+        } else {
292 295
             $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>';
293 296
         }
294 297
         return $html;
@@ -320,9 +323,15 @@  discard block
 block discarded – undo
320 323
                 $sum = 0;
321 324
                 $other = 0;
322 325
                 $unknown = 0;
323
-                if(isset($genData['sum'])) $sum = $genData['sum'];
324
-                if(isset($genData['other'])) $other = $genData['other'];
325
-                if(isset($genData['unknown'])) $unknown = $genData['unknown'];
326
+                if(isset($genData['sum'])) {
327
+                	$sum = $genData['sum'];
328
+                }
329
+                if(isset($genData['other'])) {
330
+                	$other = $genData['other'];
331
+                }
332
+                if(isset($genData['unknown'])) {
333
+                	$unknown = $genData['unknown'];
334
+                }
326 335
                 
327 336
                 if($sum > 0) {                
328 337
                     $results_by_gen[$gen]['sum'] = $sum;
@@ -340,8 +349,7 @@  discard block
 block discarded – undo
340 349
                                 $results_by_gen[$gen]['places'][$placename]['flag'] = $flag;
341 350
                             }
342 351
                         }
343
-                    }
344
-                    else {
352
+                    } else {
345 353
                         $tmp = $genData['places'];
346 354
                         if($other > 0) {
347 355
                             $tmp = array_slice($tmp, 0, 5, true);
@@ -357,8 +365,7 @@  discard block
 block discarded – undo
357 365
             
358 366
             $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial();
359 367
             
360
-        }
361
-        else {
368
+        } else {
362 369
             $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>';
363 370
         }
364 371
         return $html;
Please login to merge, or discard this patch.