Completed
Push — master ( 95506d...0f93c5 )
by Jonathan
07:55
created
src/Webtrees/Map/GoogleMapsProvider.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
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 = explode (',', $place->getGedcomName());
28
+		if (!$place->isEmpty()) {
29
+			$parent = 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
 block discarded – undo
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 SQL_CACHE 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
 		}
Please login to merge, or discard this patch.
src/Webtrees/Hook/HookProvider.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -61,34 +61,34 @@  discard block
 block discarded – undo
61 61
 	 * @return Array List of possible hooks, with the priority
62 62
 	 */
63 63
 	static public function getPossibleHooks() {
64
-		static $hooks=null;
64
+		static $hooks = null;
65 65
 		if ($hooks === null) {
66 66
 		    $hooks = array();
67
-		    foreach (glob(WT_ROOT . WT_MODULES_DIR . '*/module.php') as $file) {
67
+		    foreach (glob(WT_ROOT.WT_MODULES_DIR.'*/module.php') as $file) {
68 68
 		        try {
69 69
 		            $module = include $file;
70
-		            if($module instanceof HookSubscriberInterface){
70
+		            if ($module instanceof HookSubscriberInterface) {
71 71
 						$subscribedhooks = $module->getSubscribedHooks();
72
-						if(is_array($subscribedhooks)){
73
-							foreach($subscribedhooks as $key => $value){
74
-								if(is_int($key)) {
72
+						if (is_array($subscribedhooks)) {
73
+							foreach ($subscribedhooks as $key => $value) {
74
+								if (is_int($key)) {
75 75
 									$hook_item = $value;
76 76
 									$priority = self::DEFAULT_PRIORITY;
77 77
 								}
78
-								else{
78
+								else {
79 79
 									$hook_item = explode('#', $key, 2);
80 80
 									$priority = $value;
81 81
 								}
82
-								if($hook_item && count($hook_item) == 2){
82
+								if ($hook_item && count($hook_item) == 2) {
83 83
 									$hook_func = $hook_item[0];
84 84
 									$hook_cont = $hook_item[1];
85 85
 								}
86
-								else{
86
+								else {
87 87
 									$hook_func = $hook_item[0];
88 88
 									$hook_cont = 'all';
89 89
 								}
90
-								if(method_exists($module, $hook_func)){
91
-									$hooks[$module->getName().'#'.$hook_func.'#'.$hook_cont]=$priority;
90
+								if (method_exists($module, $hook_func)) {
91
+									$hooks[$module->getName().'#'.$hook_func.'#'.$hook_cont] = $priority;
92 92
 								}
93 93
 							}
94 94
 						}
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @return array List of installed hooks
108 108
 	 */
109
-	static public function getRawInstalledHooks(){
110
-		if(self::isModuleOperational()){
109
+	static public function getRawInstalledHooks() {
110
+		if (self::isModuleOperational()) {
111 111
 			return fw\Database::prepare(
112 112
 					"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".
113 113
 					" FROM `##maj_hooks`".
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return Array List of installed hooks, with id, status and priority
124 124
 	 */
125
-	static public function getInstalledHooks(){
126
-		static $installedhooks =null;
127
-		if($installedhooks===null){
128
-			$dbhooks=self::getRawInstalledHooks();
129
-			foreach($dbhooks as $dbhook){
125
+	static public function getInstalledHooks() {
126
+		static $installedhooks = null;
127
+		if ($installedhooks === null) {
128
+			$dbhooks = self::getRawInstalledHooks();
129
+			foreach ($dbhooks as $dbhook) {
130 130
 				$installedhooks[($dbhook->module).'#'.($dbhook->hook).'#'.($dbhook->context)] = array('id' => $dbhook->id, 'status' => $dbhook->status, 'priority' => $dbhook->priority);
131 131
 			}
132 132
 		}
@@ -138,15 +138,15 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	static public function updateHooks() {
140 140
 	    
141
-	    if(Auth::isAdmin()){
141
+	    if (Auth::isAdmin()) {
142 142
 	        $ihooks = self::getInstalledHooks();
143 143
 	        $phooks = self::getPossibleHooks();
144 144
 	        	
145 145
 	        // Insert hooks not existing yet in the DB
146
-	        if($phooks !== null){
147
-	            foreach($phooks as $phook => $priority){
146
+	        if ($phooks !== null) {
147
+	            foreach ($phooks as $phook => $priority) {
148 148
 	                $array_hook = explode('#', $phook);
149
-	                if($ihooks === null || !array_key_exists($phook, $ihooks)){
149
+	                if ($ihooks === null || !array_key_exists($phook, $ihooks)) {
150 150
 	                    $chook = new Hook($array_hook[1], $array_hook[2]);
151 151
 	                    $chook->subscribe($array_hook[0]);
152 152
 	                    $chook->setPriority($array_hook[0], $priority);
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
 	        }
156 156
 	        	
157 157
 	        //Remove hooks not existing any more in the file system
158
-	        if($ihooks !== null){
159
-	            foreach($ihooks as $ihook => $status){
158
+	        if ($ihooks !== null) {
159
+	            foreach ($ihooks as $ihook => $status) {
160 160
 	                $array_hook = explode('#', $ihook);
161
-	                if($phooks === null || !array_key_exists($ihook, $phooks)){
161
+	                if ($phooks === null || !array_key_exists($ihook, $phooks)) {
162 162
 	                    $chook = new Hook($array_hook[1], $array_hook[2]);
163 163
 	                    $chook->remove($array_hook[0]);
164 164
 	                }
Please login to merge, or discard this patch.
src/Webtrees/Functions/FunctionsPrint.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * @return string List of elements
33 33
 	 */
34 34
 	static public function getListFromArray(array $array) {
35
-		$n=count($array);
35
+		$n = count($array);
36 36
 		switch ($n) {
37 37
 			case 0:
38 38
 				return '';
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
 			default:
42 42
 				return implode(
43 43
 						/* I18N: list separator */ I18N::translate(', '), 
44
-						array_slice($array, 0, $n-1)
45
-					) .
46
-					/* I18N: last list separator, " and " in English, " et " in French  */ I18N::translate(' and ') . 
47
-					$array[$n-1];
44
+						array_slice($array, 0, $n - 1)
45
+					).
46
+					/* I18N: last list separator, " and " in English, " et " in French  */ I18N::translate(' and '). 
47
+					$array[$n - 1];
48 48
 		}
49 49
 	}
50 50
 
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 			\Fisharebest\Webtrees\Fact $fact,
60 60
 			\MyArtJaub\Webtrees\Map\MapProviderInterface $mapProvider
61 61
 	) {
62
-		$html='';
63
-		if($place = $fact->getPlace()) {
64
-			$iconPlace= $mapProvider->getPlaceIcon($place);	
65
-			if($iconPlace && strlen($iconPlace) > 0){
66
-				$html.=	'<div class="fact_flag">'. self::htmlPlaceIcon($place, $iconPlace, 50). '</div>';
62
+		$html = '';
63
+		if ($place = $fact->getPlace()) {
64
+			$iconPlace = $mapProvider->getPlaceIcon($place);	
65
+			if ($iconPlace && strlen($iconPlace) > 0) {
66
+				$html .= '<div class="fact_flag">'.self::htmlPlaceIcon($place, $iconPlace, 50).'</div>';
67 67
 			}
68 68
 		}
69 69
 		return $html;
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 	 * @param number $size
78 78
 	 * @return string HTML code of the inserted flag
79 79
 	 */
80
-	public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) {
81
-	    return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />';
80
+	public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path, $size = 50) {
81
+	    return '<img class="flag_gm_h'.$size.'" src="'.$icon_path.'" title="'.$place->getGedcomName().'" alt="'.$place->getGedcomName().'" />';
82 82
 	}
83 83
 	
84 84
 	/**
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		$minimum = PHP_INT_MAX;
97 97
 		$maximum = 1;
98 98
 		foreach ($list as $item => $params) {
99
-			if(array_key_exists('count', $params)) {
99
+			if (array_key_exists('count', $params)) {
100 100
 				$maximum = max($maximum, $params['count']);
101 101
 				$minimum = min($minimum, $params['count']);
102 102
 			}
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
 				$size = 75.0 + 125.0 * ($count - $minimum) / ($maximum - $minimum);
115 115
 			}
116 116
 			
117
-			$html .= '<a style="font-size:' . $size . '%" href="' . $url . '">';
117
+			$html .= '<a style="font-size:'.$size.'%" href="'.$url.'">';
118 118
 			if ($totals) {
119
-				$html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $text . '</span>', I18N::number($count));
119
+				$html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">'.$text.'</span>', I18N::number($count));
120 120
 			} else {
121 121
 				$html .= $text;
122 122
 			}
123 123
 			$html .= '</a>';
124 124
 		}
125
-		return '<div class="tag_cloud">' . $html . '</div>';
125
+		return '<div class="tag_cloud">'.$html.'</div>';
126 126
 	}
127 127
 	
128 128
 
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 	 * @param bool $isStrong Bolden the name ?
158 158
 	 * @return string HTML Code for individual item
159 159
 	 */
160
-	public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true){
160
+	public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true) {
161 161
 		$html = '';
162 162
 		$tag = 'em';
163
-		if($isStrong) $tag = 'strong';
164
-		if($individual && $individual->canShow()){
163
+		if ($isStrong) $tag = 'strong';
164
+		if ($individual && $individual->canShow()) {
165 165
 			$dindi = new Individual($individual);
166 166
 			$html = $individual->getSexImage();
167 167
 			$html .= '<a class="list_item" href="'.
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 			$html .= '</a>';
177 177
 		}
178 178
 		else {
179
-			$html .= '<span class=\"list_item\"><'.$tag.'>' . I18N::translate('Private') . '</'.$tag.'></span>';
179
+			$html .= '<span class=\"list_item\"><'.$tag.'>'.I18N::translate('Private').'</'.$tag.'></span>';
180 180
 		}
181 181
 		return $html;
182 182
 	}
@@ -188,22 +188,22 @@  discard block
 block discarded – undo
188 188
 	 * @param boolean $anchor option to print a link to calendar
189 189
 	 * @return string HTML code for short date
190 190
 	 */
191
-	public static function formatFactDateShort(\Fisharebest\Webtrees\Fact $fact, $anchor=false) {
191
+	public static function formatFactDateShort(\Fisharebest\Webtrees\Fact $fact, $anchor = false) {
192 192
 		global $SEARCH_SPIDER;
193 193
 
194
-		$html='';
194
+		$html = '';
195 195
 		$date = $fact->getDate();
196
-		if($date->isOK()){
197
-			$html.=' '.$date->Display($anchor && !$SEARCH_SPIDER, '%Y');
196
+		if ($date->isOK()) {
197
+			$html .= ' '.$date->Display($anchor && !$SEARCH_SPIDER, '%Y');
198 198
 		}
199
-		else{
199
+		else {
200 200
 			// 1 DEAT Y with no DATE => print YES
201 201
 			// 1 BIRT 2 SOUR @S1@ => print YES
202 202
 			// 1 DEAT N is not allowed
203 203
 			// It is not proper GEDCOM form to use a N(o) value with an event tag to infer that it did not happen.
204 204
 			$factdetail = explode(' ', trim($fact->getGedcom()));
205 205
 			if (isset($factdetail) && (count($factdetail) == 3 && strtoupper($factdetail[2]) == 'Y') || (count($factdetail) == 4 && $factdetail[2] == 'SOUR')) {
206
-				$html.=I18N::translate('yes');
206
+				$html .= I18N::translate('yes');
207 207
 			}
208 208
 		}
209 209
 		return $html;
@@ -217,12 +217,12 @@  discard block
 block discarded – undo
217 217
 	 * @param boolean $anchor option to print a link to placelist
218 218
 	 * @return string HTML code for short place
219 219
 	 */
220
-	public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor=false){
221
-		$html='';
220
+	public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor = false) {
221
+		$html = '';
222 222
 		
223 223
 		if ($fact === null) return $html;
224 224
 		$place = $fact->getPlace();
225
-		if($place){
225
+		if ($place) {
226 226
 			$dplace = new Place($place);
227 227
 			$html .= $dplace->htmlFormattedName($format, $anchor);
228 228
 		}
@@ -240,21 +240,21 @@  discard block
 block discarded – undo
240 240
 	 * @param string $size CSS size for the icon. A CSS style css_$size is required
241 241
 	 * @return string HTML code for the formatted Sosa numbers
242 242
 	 */
243
-	public static function formatSosaNumbers(array $sosatab, $format = 1, $size = 'small'){
243
+	public static function formatSosaNumbers(array $sosatab, $format = 1, $size = 'small') {
244 244
 		$html = '';
245
-		switch($format){
245
+		switch ($format) {
246 246
 			case 1:
247
-				if(count($sosatab)>0){
247
+				if (count($sosatab) > 0) {
248 248
 					$html = '<i class="icon-maj-sosa_'.$size.'" title="'.I18N::translate('Sosa').'"></i>';
249 249
 				}
250 250
 				break;
251 251
 			case 2:
252
-				if(count($sosatab)>0){
252
+				if (count($sosatab) > 0) {
253 253
 					ksort($sosatab);
254 254
 					$tmp_html = array();
255 255
 					foreach ($sosatab as $sosa => $gen) {
256 256
 						$tmp_html[] = sprintf(
257
-								'<i class="icon-maj-sosa_%1$s" title="'.I18N::translate('Sosa').'"></i>&nbsp;<strong>%2$d&nbsp;'.I18N::translate('(G%s)', $gen) .'</strong>',
257
+								'<i class="icon-maj-sosa_%1$s" title="'.I18N::translate('Sosa').'"></i>&nbsp;<strong>%2$d&nbsp;'.I18N::translate('(G%s)', $gen).'</strong>',
258 258
 								$size,
259 259
 								$sosa
260 260
 							);
@@ -280,15 +280,15 @@  discard block
 block discarded – undo
280 280
 	 * @param string $size CSS size for the icon. A CSS style css_$size is required
281 281
 	 * @return string HTML code for IsSourced icon
282 282
 	 */
283
-	public static function formatIsSourcedIcon($sourceType, $isSourced, $tag='EVEN', $format = 1, $size='normal'){
284
-		$html='';
285
-		$image=null;
286
-		$title=null;
287
-		switch($format){
283
+	public static function formatIsSourcedIcon($sourceType, $isSourced, $tag = 'EVEN', $format = 1, $size = 'normal') {
284
+		$html = '';
285
+		$image = null;
286
+		$title = null;
287
+		switch ($format) {
288 288
 			case 1:
289
-				switch($sourceType){
289
+				switch ($sourceType) {
290 290
 					case 'E':
291
-						switch($isSourced){
291
+						switch ($isSourced) {
292 292
 							case 0:
293 293
 								$image = 'event_unknown';
294 294
 								$title = I18N::translate('%s not found', GedcomTag::getLabel($tag));
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 						}
319 319
 						break;
320 320
 					case 'R':
321
-						switch($isSourced){
321
+						switch ($isSourced) {
322 322
 							case -1:
323 323
 								$image = 'record_notsourced';
324 324
 								$title = I18N::translate('%s not sourced', GedcomTag::getLabel($tag));
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 					default:
340 340
 						break;
341 341
 				}
342
-				if($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>';
342
+				if ($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>';
343 343
 				break;
344 344
 			default:
345 345
 				break;
Please login to merge, or discard this patch.