@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param string $text Text to display |
40 | 40 | */ |
41 | - static public function promptAlert($text){ |
|
41 | + static public function promptAlert($text) { |
|
42 | 42 | echo '<script>'; |
43 | - echo 'alert("',fw\Filter::escapeHtml($text),'")'; |
|
43 | + echo 'alert("', fw\Filter::escapeHtml($text), '")'; |
|
44 | 44 | echo '</script>'; |
45 | 45 | } |
46 | 46 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @return float Result of the safe division |
54 | 54 | */ |
55 | 55 | public static function safeDivision($num, $denom, $default = 0) { |
56 | - if($denom && $denom!=0){ |
|
56 | + if ($denom && $denom != 0) { |
|
57 | 57 | return $num / $denom; |
58 | 58 | } |
59 | 59 | return $default; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param float $default Default value if denominator null or 0 |
68 | 68 | * @return float Percentage |
69 | 69 | */ |
70 | - public static function getPercentage($num, $denom, $default = 0){ |
|
70 | + public static function getPercentage($num, $denom, $default = 0) { |
|
71 | 71 | return 100 * self::safeDivision($num, $denom, $default); |
72 | 72 | } |
73 | 73 | |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * @param int $target The final max width/height |
79 | 79 | * @return array array of ($width, $height). One of them must be $target |
80 | 80 | */ |
81 | - static public function getResizedImageSize($file, $target=25){ |
|
82 | - list($width, $height, , ) = getimagesize($file); |
|
81 | + static public function getResizedImageSize($file, $target = 25) { |
|
82 | + list($width, $height,,) = getimagesize($file); |
|
83 | 83 | $max = max($width, $height); |
84 | 84 | $rapp = $target / $max; |
85 | 85 | $width = intval($rapp * $width); |
@@ -109,21 +109,21 @@ discard block |
||
109 | 109 | * @param int $length Length of the token, default to 32 |
110 | 110 | * @return string Random token |
111 | 111 | */ |
112 | - public static function generateRandomToken($length=32) { |
|
112 | + public static function generateRandomToken($length = 32) { |
|
113 | 113 | $chars = str_split('abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'); |
114 | 114 | $len_chars = count($chars); |
115 | 115 | $token = ''; |
116 | 116 | |
117 | 117 | for ($i = 0; $i < $length; $i++) |
118 | - $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
118 | + $token .= $chars[mt_rand(0, $len_chars - 1)]; |
|
119 | 119 | |
120 | 120 | # Number of 32 char chunks |
121 | - $chunks = ceil( strlen($token) / 32 ); |
|
121 | + $chunks = ceil(strlen($token) / 32); |
|
122 | 122 | $md5token = ''; |
123 | 123 | |
124 | 124 | # Run each chunk through md5 |
125 | - for ( $i=1; $i<=$chunks; $i++ ) |
|
126 | - $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
125 | + for ($i = 1; $i <= $chunks; $i++) |
|
126 | + $md5token .= md5(substr($token, $i * 32 - 32, 32)); |
|
127 | 127 | |
128 | 128 | # Trim the token |
129 | 129 | return substr($md5token, 0, $length); |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | * @param string $data Text to encrypt |
146 | 146 | * @return string Encrypted and encoded text |
147 | 147 | */ |
148 | - public static function encryptToSafeBase64($data){ |
|
149 | - if(!self::isEncryptionCompatible()) |
|
148 | + public static function encryptToSafeBase64($data) { |
|
149 | + if (!self::isEncryptionCompatible()) |
|
150 | 150 | throw new \Exception('MCrypt PHP extension is required to use encryption.'); |
151 | 151 | |
152 | 152 | $key = 'STANDARDKEYIFNOSERVER'; |
153 | - if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
153 | + if (!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
154 | 154 | $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
155 | 155 | $iv = mcrypt_create_iv(self::ENCRYPTION_IV_SIZE, MCRYPT_RAND); |
156 | - $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC,$iv); |
|
156 | + $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv); |
|
157 | 157 | $encrypted = base64_encode($iv.$id); |
158 | 158 | // +, / and = are not URL-compatible |
159 | 159 | $encrypted = str_replace('+', '-', $encrypted); |
@@ -168,25 +168,25 @@ discard block |
||
168 | 168 | * @param string $encrypted Text to decrypt |
169 | 169 | * @return string Decrypted text |
170 | 170 | */ |
171 | - public static function decryptFromSafeBase64($encrypted){ |
|
172 | - if(!self::isEncryptionCompatible()) |
|
171 | + public static function decryptFromSafeBase64($encrypted) { |
|
172 | + if (!self::isEncryptionCompatible()) |
|
173 | 173 | throw new \Exception('MCrypt PHP extension is required to use encryption.'); |
174 | 174 | |
175 | 175 | $key = 'STANDARDKEYIFNOSERVER'; |
176 | - if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
176 | + if (!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
177 | 177 | $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
178 | 178 | $encrypted = str_replace('-', '+', $encrypted); |
179 | 179 | $encrypted = str_replace('_', '/', $encrypted); |
180 | 180 | $encrypted = str_replace('*', '=', $encrypted); |
181 | 181 | $encrypted = base64_decode($encrypted); |
182 | - if(!$encrypted) |
|
182 | + if (!$encrypted) |
|
183 | 183 | throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
184 | - if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
184 | + if (strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
185 | 185 | throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
186 | 186 | $iv_dec = substr($encrypted, 0, self::ENCRYPTION_IV_SIZE); |
187 | 187 | $encrypted = substr($encrypted, self::ENCRYPTION_IV_SIZE); |
188 | 188 | $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv_dec); |
189 | - return preg_replace('~(?:\\000+)$~','',$decrypted); |
|
189 | + return preg_replace('~(?:\\000+)$~', '', $decrypted); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | * @param string $string Filesystem encoded string to encode |
196 | 196 | * @return string UTF-8 encoded string |
197 | 197 | */ |
198 | - public static function encodeFileSystemToUtf8($string){ |
|
198 | + public static function encodeFileSystemToUtf8($string) { |
|
199 | 199 | if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
200 | - return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
200 | + return iconv('cp1252', 'utf-8//IGNORE', $string); |
|
201 | 201 | } |
202 | 202 | return $string; |
203 | 203 | } |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | * @param string $string UTF-8 encoded string to encode |
209 | 209 | * @return string Filesystem encoded string |
210 | 210 | */ |
211 | - public static function encodeUtf8ToFileSystem($string){ |
|
211 | + public static function encodeUtf8ToFileSystem($string) { |
|
212 | 212 | if (preg_match('//u', $string) && strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
213 | - return iconv('utf-8', 'cp1252//IGNORE' , $string); |
|
213 | + return iconv('utf-8', 'cp1252//IGNORE', $string); |
|
214 | 214 | } |
215 | 215 | return $string; |
216 | 216 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * @return boolean True if path valid |
224 | 224 | */ |
225 | 225 | public static function isValidPath($filename, $acceptfolder = FALSE) { |
226 | - if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
226 | + if (strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
227 | 227 | return false; |
228 | 228 | } |
229 | 229 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @return array Array of month short names |
236 | 236 | */ |
237 | 237 | public static function getCalendarShortMonths($calendarId = 0) { |
238 | - if(!isset(self::$calendarShortMonths[$calendarId])) { |
|
238 | + if (!isset(self::$calendarShortMonths[$calendarId])) { |
|
239 | 239 | $calendar_info = cal_info($calendarId); |
240 | 240 | self::$calendarShortMonths[$calendarId] = $calendar_info['abbrevmonths']; |
241 | 241 | } |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | * @param int $sosa Sosa number |
249 | 249 | * @return number |
250 | 250 | */ |
251 | - public static function getGeneration($sosa){ |
|
252 | - return(int)log($sosa, 2)+1; |
|
251 | + public static function getGeneration($sosa) { |
|
252 | + return(int)log($sosa, 2) + 1; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | public function handle(fw\Module\AbstractModule $module, $request) { |
50 | 50 | |
51 | 51 | $fq_modclass_name = get_class($module); |
52 | - $ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')) . '\\'; |
|
52 | + $ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')).'\\'; |
|
53 | 53 | |
54 | - $args = explode( '@', $request, 2); |
|
55 | - switch(count($args)) { |
|
54 | + $args = explode('@', $request, 2); |
|
55 | + switch (count($args)) { |
|
56 | 56 | case 1: |
57 | 57 | $ctrl_name = $args[0]; |
58 | 58 | $method = 'index'; |
@@ -64,16 +64,16 @@ discard block |
||
64 | 64 | break; |
65 | 65 | } |
66 | 66 | |
67 | - $ctrl_class = $ctrl_namespace . $ctrl_name . 'Controller'; |
|
68 | - if(class_exists($ctrl_class) |
|
67 | + $ctrl_class = $ctrl_namespace.$ctrl_name.'Controller'; |
|
68 | + if (class_exists($ctrl_class) |
|
69 | 69 | && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController') |
70 | - && $ctrl = new $ctrl_class($module) ) { |
|
71 | - if(method_exists($ctrl, $method)) { |
|
70 | + && $ctrl = new $ctrl_class($module)) { |
|
71 | + if (method_exists($ctrl, $method)) { |
|
72 | 72 | try { |
73 | 73 | call_user_func_array(array($ctrl, $method), array()); |
74 | 74 | } |
75 | 75 | catch (MvcException $ex) { |
76 | - if(!headers_sent()) { |
|
76 | + if (!headers_sent()) { |
|
77 | 77 | http_response_code($ex->getHttpCode()); |
78 | 78 | } |
79 | 79 | echo $ex->getMessage(); |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | class MvcException extends \Exception { |
18 | 18 | |
19 | 19 | /** @var int[] $VALID_HTTP List of valid HTTP codes */ |
20 | - protected static $VALID_HTTP = array( |
|
20 | + protected static $VALID_HTTP = array( |
|
21 | 21 | 100, 101, |
22 | 22 | 200, 201, 202, 203, 204, 205, 206, |
23 | 23 | 300, 301, 302, 303, 304, 305, 306, 307, |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | * @throws InvalidArgumentException Thrown if not valid Http code |
59 | 59 | */ |
60 | 60 | public function setHttpCode($http_code) { |
61 | - if(!in_array($http_code, self::$VALID_HTTP)) |
|
61 | + if (!in_array($http_code, self::$VALID_HTTP)) |
|
62 | 62 | throw new \InvalidArgumentException('Invalid HTTP code'); |
63 | - $this->http_code= $http_code; |
|
63 | + $this->http_code = $http_code; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return string List of elements |
32 | 32 | */ |
33 | 33 | public static function getListFromArray(array $array) { |
34 | - $n=count($array); |
|
34 | + $n = count($array); |
|
35 | 35 | switch ($n) { |
36 | 36 | case 0: |
37 | 37 | return ''; |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | default: |
41 | 41 | return implode( |
42 | 42 | /* I18N: list separator */ I18N::translate(', '), |
43 | - array_slice($array, 0, $n-1) |
|
44 | - ) . |
|
45 | - /* I18N: last list separator, " and " in English, " et " in French */ I18N::translate(' and ') . |
|
46 | - $array[$n-1]; |
|
43 | + array_slice($array, 0, $n - 1) |
|
44 | + ). |
|
45 | + /* I18N: last list separator, " and " in English, " et " in French */ I18N::translate(' and '). |
|
46 | + $array[$n - 1]; |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | \MyArtJaub\Webtrees\Map\MapProviderInterface $mapProvider |
60 | 60 | ) { |
61 | 61 | $place = $fact->getPlace(); |
62 | - if(!$place->isEmpty()) { |
|
63 | - $iconPlace= $mapProvider->getPlaceIcon($place); |
|
64 | - if($iconPlace && strlen($iconPlace) > 0){ |
|
65 | - return '<div class="fact_flag">'. self::htmlPlaceIcon($place, $iconPlace, 50). '</div>'; |
|
62 | + if (!$place->isEmpty()) { |
|
63 | + $iconPlace = $mapProvider->getPlaceIcon($place); |
|
64 | + if ($iconPlace && strlen($iconPlace) > 0) { |
|
65 | + return '<div class="fact_flag">'.self::htmlPlaceIcon($place, $iconPlace, 50).'</div>'; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | return ''; |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @param number $size |
77 | 77 | * @return string HTML code of the inserted flag |
78 | 78 | */ |
79 | - public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) { |
|
80 | - return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />'; |
|
79 | + public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path, $size = 50) { |
|
80 | + return '<img class="flag_gm_h'.$size.'" src="'.$icon_path.'" title="'.$place->getGedcomName().'" alt="'.$place->getGedcomName().'" />'; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $minimum = PHP_INT_MAX; |
96 | 96 | $maximum = 1; |
97 | 97 | foreach ($list as $params) { |
98 | - if(array_key_exists('count', $params)) { |
|
98 | + if (array_key_exists('count', $params)) { |
|
99 | 99 | $maximum = max($maximum, $params['count']); |
100 | 100 | $minimum = min($minimum, $params['count']); |
101 | 101 | } |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | $size = 75.0 + 125.0 * ($count - $minimum) / ($maximum - $minimum); |
114 | 114 | } |
115 | 115 | |
116 | - $html .= '<a style="font-size:' . $size . '%" href="' . $url . '">'; |
|
116 | + $html .= '<a style="font-size:'.$size.'%" href="'.$url.'">'; |
|
117 | 117 | if ($totals) { |
118 | - $html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $text . '</span>', I18N::number($count)); |
|
118 | + $html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">'.$text.'</span>', I18N::number($count)); |
|
119 | 119 | } else { |
120 | 120 | $html .= $text; |
121 | 121 | } |
122 | 122 | $html .= '</a>'; |
123 | 123 | } |
124 | - return '<div class="tag_cloud">' . $html . '</div>'; |
|
124 | + return '<div class="tag_cloud">'.$html.'</div>'; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | * @param bool $isStrong Bolden the name ? |
157 | 157 | * @return string HTML Code for individual item |
158 | 158 | */ |
159 | - public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true){ |
|
159 | + public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true) { |
|
160 | 160 | $html = ''; |
161 | 161 | $tag = 'em'; |
162 | - if($isStrong) $tag = 'strong'; |
|
163 | - if($individual && $individual->canShow()){ |
|
162 | + if ($isStrong) $tag = 'strong'; |
|
163 | + if ($individual && $individual->canShow()) { |
|
164 | 164 | $dindi = new Individual($individual); |
165 | 165 | $html = $individual->getSexImage(); |
166 | 166 | $html .= '<a class="list_item" href="'. |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $html .= '</a>'; |
176 | 176 | } |
177 | 177 | else { |
178 | - $html .= '<span class=\"list_item\"><'.$tag.'>' . I18N::translate('Private') . '</'.$tag.'></span>'; |
|
178 | + $html .= '<span class=\"list_item\"><'.$tag.'>'.I18N::translate('Private').'</'.$tag.'></span>'; |
|
179 | 179 | } |
180 | 180 | return $html; |
181 | 181 | } |
@@ -187,22 +187,22 @@ discard block |
||
187 | 187 | * @param boolean $anchor option to print a link to calendar |
188 | 188 | * @return string HTML code for short date |
189 | 189 | */ |
190 | - public static function formatFactDateShort(\Fisharebest\Webtrees\Fact $fact, $anchor=false) { |
|
190 | + public static function formatFactDateShort(\Fisharebest\Webtrees\Fact $fact, $anchor = false) { |
|
191 | 191 | global $SEARCH_SPIDER; |
192 | 192 | |
193 | - $html=''; |
|
193 | + $html = ''; |
|
194 | 194 | $date = $fact->getDate(); |
195 | - if($date->isOK()){ |
|
196 | - $html.=' '.$date->Display($anchor && !$SEARCH_SPIDER, '%Y'); |
|
195 | + if ($date->isOK()) { |
|
196 | + $html .= ' '.$date->Display($anchor && !$SEARCH_SPIDER, '%Y'); |
|
197 | 197 | } |
198 | - else{ |
|
198 | + else { |
|
199 | 199 | // 1 DEAT Y with no DATE => print YES |
200 | 200 | // 1 BIRT 2 SOUR @S1@ => print YES |
201 | 201 | // 1 DEAT N is not allowed |
202 | 202 | // It is not proper GEDCOM form to use a N(o) value with an event tag to infer that it did not happen. |
203 | 203 | $factdetail = explode(' ', trim($fact->getGedcom())); |
204 | 204 | if (isset($factdetail) && (count($factdetail) == 3 && strtoupper($factdetail[2]) == 'Y') || (count($factdetail) == 4 && $factdetail[2] == 'SOUR')) { |
205 | - $html.=I18N::translate('yes'); |
|
205 | + $html .= I18N::translate('yes'); |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | return $html; |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | * @param boolean $anchor option to print a link to placelist |
217 | 217 | * @return string HTML code for short place |
218 | 218 | */ |
219 | - public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor=false){ |
|
220 | - $html=''; |
|
219 | + public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor = false) { |
|
220 | + $html = ''; |
|
221 | 221 | |
222 | 222 | if ($fact === null) return $html; |
223 | 223 | $place = $fact->getPlace(); |
224 | - if($place){ |
|
224 | + if ($place) { |
|
225 | 225 | $dplace = new Place($place); |
226 | 226 | $html .= $dplace->htmlFormattedName($format, $anchor); |
227 | 227 | } |
@@ -239,21 +239,21 @@ discard block |
||
239 | 239 | * @param string $size CSS size for the icon. A CSS style css_$size is required |
240 | 240 | * @return string HTML code for the formatted Sosa numbers |
241 | 241 | */ |
242 | - public static function formatSosaNumbers(array $sosatab, $format = 1, $size = 'small'){ |
|
242 | + public static function formatSosaNumbers(array $sosatab, $format = 1, $size = 'small') { |
|
243 | 243 | $html = ''; |
244 | - switch($format){ |
|
244 | + switch ($format) { |
|
245 | 245 | case 1: |
246 | - if(count($sosatab)>0){ |
|
246 | + if (count($sosatab) > 0) { |
|
247 | 247 | $html = '<i class="icon-maj-sosa_'.$size.'" title="'.I18N::translate('Sosa').'"></i>'; |
248 | 248 | } |
249 | 249 | break; |
250 | 250 | case 2: |
251 | - if(count($sosatab)>0){ |
|
251 | + if (count($sosatab) > 0) { |
|
252 | 252 | ksort($sosatab); |
253 | 253 | $tmp_html = array(); |
254 | 254 | foreach ($sosatab as $sosa => $gen) { |
255 | 255 | $tmp_html[] = sprintf( |
256 | - '<i class="icon-maj-sosa_%1$s" title="'.I18N::translate('Sosa').'"></i> <strong>%2$d '.I18N::translate('(G%s)', $gen) .'</strong>', |
|
256 | + '<i class="icon-maj-sosa_%1$s" title="'.I18N::translate('Sosa').'"></i> <strong>%2$d '.I18N::translate('(G%s)', $gen).'</strong>', |
|
257 | 257 | $size, |
258 | 258 | $sosa |
259 | 259 | ); |
@@ -279,15 +279,15 @@ discard block |
||
279 | 279 | * @param string $size CSS size for the icon. A CSS style css_$size is required |
280 | 280 | * @return string HTML code for IsSourced icon |
281 | 281 | */ |
282 | - public static function formatIsSourcedIcon($sourceType, $isSourced, $tag='EVEN', $format = 1, $size='normal'){ |
|
283 | - $html=''; |
|
284 | - $image=null; |
|
285 | - $title=null; |
|
286 | - switch($format){ |
|
282 | + public static function formatIsSourcedIcon($sourceType, $isSourced, $tag = 'EVEN', $format = 1, $size = 'normal') { |
|
283 | + $html = ''; |
|
284 | + $image = null; |
|
285 | + $title = null; |
|
286 | + switch ($format) { |
|
287 | 287 | case 1: |
288 | - switch($sourceType){ |
|
288 | + switch ($sourceType) { |
|
289 | 289 | case 'E': |
290 | - switch($isSourced){ |
|
290 | + switch ($isSourced) { |
|
291 | 291 | case 0: |
292 | 292 | $image = 'event_unknown'; |
293 | 293 | $title = I18N::translate('%s not found', GedcomTag::getLabel($tag)); |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | } |
318 | 318 | break; |
319 | 319 | case 'R': |
320 | - switch($isSourced){ |
|
320 | + switch ($isSourced) { |
|
321 | 321 | case -1: |
322 | 322 | $image = 'record_notsourced'; |
323 | 323 | $title = I18N::translate('%s not sourced', GedcomTag::getLabel($tag)); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | default: |
338 | 338 | break; |
339 | 339 | } |
340 | - if($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
340 | + if ($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
341 | 341 | break; |
342 | 342 | default: |
343 | 343 | break; |
@@ -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 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 | } |
@@ -47,13 +47,13 @@ |
||
47 | 47 | <div class="value"> |
48 | 48 | <?php |
49 | 49 | $users = $this->data->get('users_settings'); |
50 | - if(count($users) == 1) { |
|
51 | - $root_indi = $users[0]['rootid']; ?> |
|
50 | + if (count($users) == 1) { |
|
51 | + $root_indi = $users[0]['rootid']; ?> |
|
52 | 52 | <label> |
53 | 53 | <input id="maj_sosa_input_userid" type="hidden" name="userid" value="<?php echo $users[0]['user']->getUserId(); ?>" /> |
54 | 54 | <?php echo $users[0]['user']->getRealNameHtml() ?> |
55 | 55 | </label> |
56 | - <?php } else if(count($users) > 1) { ?> |
|
56 | + <?php } else if (count($users) > 1) { ?> |
|
57 | 57 | <select id='maj-sosa-config-select' name="userid"> |
58 | 58 | <?php |
59 | 59 | $root_indi = $users[0]['rootid']; |
@@ -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 SQL_CACHE 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 | } |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | * @param string $period |
31 | 31 | * @param (null|int) Number of visits |
32 | 32 | */ |
33 | - private function getNumberOfVisitsPiwik($block_id, $period='year'){ |
|
33 | + private function getNumberOfVisitsPiwik($block_id, $period = 'year') { |
|
34 | 34 | |
35 | 35 | $piwik_url = $this->module->getBlockSetting($block_id, 'piwik_url'); |
36 | 36 | $piwik_siteid = $this->module->getBlockSetting($block_id, 'piwik_siteid'); |
37 | 37 | $piwik_token = $this->module->getBlockSetting($block_id, 'piwik_token'); |
38 | 38 | |
39 | - if($piwik_url && strlen($piwik_url) > 0 && |
|
40 | - $piwik_siteid && strlen($piwik_siteid) > 0 && |
|
39 | + if ($piwik_url && strlen($piwik_url) > 0 && |
|
40 | + $piwik_siteid && strlen($piwik_siteid) > 0 && |
|
41 | 41 | $piwik_token && strlen($piwik_token) |
42 | 42 | ) |
43 | 43 | { |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | $url .= '&format=PHP'; |
49 | 49 | $url .= '&token_auth='.$piwik_token; |
50 | 50 | |
51 | - if($fetched = File::fetchUrl($url)) { |
|
51 | + if ($fetched = File::fetchUrl($url)) { |
|
52 | 52 | $content = @unserialize($fetched); |
53 | - if(is_numeric($content)) return $content; |
|
53 | + if (is_numeric($content)) return $content; |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | $data->set('has_stats', false); |
73 | 73 | |
74 | 74 | $block_id = Filter::get('block_id'); |
75 | - if($block_id){ |
|
75 | + if ($block_id) { |
|
76 | 76 | $cached_item = Cache::get('piwikCountYear', $this->module); |
77 | 77 | $visitCountYear = $cached_item->get(); |
78 | - if(!$cached_item->isHit()) { |
|
78 | + if (!$cached_item->isHit()) { |
|
79 | 79 | $visitCountYear = $this->getNumberOfVisitsPiwik($block_id); |
80 | 80 | Cache::save($cached_item, $visitCountYear); |
81 | 81 | } |
82 | 82 | |
83 | - if($visitCountYear){ |
|
83 | + if ($visitCountYear) { |
|
84 | 84 | $visitCountToday = max(0, $this->getNumberOfVisitsPiwik($block_id, 'day')); |
85 | - $visitCountYear = max( 0, $visitCountYear); |
|
85 | + $visitCountYear = max(0, $visitCountYear); |
|
86 | 86 | |
87 | 87 | $data->set('has_stats', true); |
88 | 88 | $data->set('visits_today', $visitCountToday); |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * Cache component to speed up some potential data retrievals |
22 | 22 | */ |
23 | -class Cache{ |
|
23 | +class Cache { |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Underlying Cache object |
27 | 27 | * @var CacheItemPoolInterface $cache |
28 | 28 | */ |
29 | - protected $cache=null; |
|
29 | + protected $cache = null; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Defines whether the cache has been initialised |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * |
60 | 60 | */ |
61 | 61 | protected function init() { |
62 | - if(Apc::isAvailable()) { |
|
62 | + if (Apc::isAvailable()) { |
|
63 | 63 | $driver = new Apc(); |
64 | 64 | } else { |
65 | 65 | if (!is_dir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache')) { |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | * Initiliase the Cache if not done. |
84 | 84 | * |
85 | 85 | */ |
86 | - protected function checkInit(){ |
|
87 | - if(!$this->is_init) $this->init(); |
|
86 | + protected function checkInit() { |
|
87 | + if (!$this->is_init) $this->init(); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | * @param AbstractModule $mod Calling module |
95 | 95 | * @return string Cached key name |
96 | 96 | */ |
97 | - protected function getKeyName($value, AbstractModule $mod = null){ |
|
97 | + protected function getKeyName($value, AbstractModule $mod = null) { |
|
98 | 98 | $this->checkInit(); |
99 | 99 | $mod_name = 'myartjaub'; |
100 | - if($mod !== null) $mod_name = $mod->getName(); |
|
100 | + if ($mod !== null) $mod_name = $mod->getName(); |
|
101 | 101 | return $mod_name.'_'.$value; |
102 | 102 | } |
103 | 103 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param AbstractModule $mod Calling module |
109 | 109 | * @return \Psr\Cache\CacheItemInterface |
110 | 110 | */ |
111 | - public function getI($value, AbstractModule $mod = null){ |
|
111 | + public function getI($value, AbstractModule $mod = null) { |
|
112 | 112 | $this->checkInit(); |
113 | 113 | return $this->cache->getItem($this->getKeyName($value, $mod)); |
114 | 114 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @param AbstractModule $mod Calling module |
121 | 121 | * @return \Psr\Cache\CacheItemInterface |
122 | 122 | */ |
123 | - public static function get($value, AbstractModule $mod = null){ |
|
123 | + public static function get($value, AbstractModule $mod = null) { |
|
124 | 124 | return self::getInstance()->getI($value, $mod); |
125 | 125 | } |
126 | 126 | |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | * @param mixed $data Value |
132 | 132 | * @param AbstractModule $mod Calling module |
133 | 133 | */ |
134 | - public function saveI($value, $data, AbstractModule $mod = null){ |
|
134 | + public function saveI($value, $data, AbstractModule $mod = null) { |
|
135 | 135 | $this->checkInit(); |
136 | 136 | |
137 | 137 | $item = $value; |
138 | - if(!($value instanceof CacheItemInterface)) { |
|
138 | + if (!($value instanceof CacheItemInterface)) { |
|
139 | 139 | $item = new \Stash\Item(); |
140 | 140 | $item->setKey($this->getKeyName($value, $mod)); |
141 | 141 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @param mixed $data Value |
151 | 151 | * @param AbstractModule $mod Calling module |
152 | 152 | */ |
153 | - public static function save($value, $data, AbstractModule $mod = null){ |
|
153 | + public static function save($value, $data, AbstractModule $mod = null) { |
|
154 | 154 | self::getInstance()->saveI($value, $data, $mod); |
155 | 155 | } |
156 | 156 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @param AbstractModule $mod Calling module |
162 | 162 | * @return bool Deletion successful? |
163 | 163 | */ |
164 | - public function deleteI($value, AbstractModule $mod = null){ |
|
164 | + public function deleteI($value, AbstractModule $mod = null) { |
|
165 | 165 | $this->checkInit(); |
166 | 166 | return $this->cache->deleteItem($this->getKeyName($value, $mod)); |
167 | 167 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @param AbstractModule $mod Calling module |
174 | 174 | * @return bool Deletion successful? |
175 | 175 | */ |
176 | - public static function delete($value, AbstractModule $mod = null){ |
|
176 | + public static function delete($value, AbstractModule $mod = null) { |
|
177 | 177 | return self::getInstance()->deleteI($value, $mod); |
178 | 178 | } |
179 | 179 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * Clean the cache |
182 | 182 | * |
183 | 183 | */ |
184 | - public function cleanI(){ |
|
184 | + public function cleanI() { |
|
185 | 185 | $this->checkInit(); |
186 | 186 | $this->cache->clear(); |
187 | 187 | } |