@@ -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); |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | * @param string $data Text to encrypt |
137 | 137 | * @return string Encrypted and encoded text |
138 | 138 | */ |
139 | - public static function encryptToSafeBase64($data){ |
|
139 | + public static function encryptToSafeBase64($data) { |
|
140 | 140 | $key = 'STANDARDKEYIFNOSERVER'; |
141 | - if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
141 | + if ($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
142 | 142 | $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
143 | 143 | $iv = mcrypt_create_iv(self::ENCRYPTION_IV_SIZE, MCRYPT_RAND); |
144 | - $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC,$iv); |
|
144 | + $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv); |
|
145 | 145 | $encrypted = base64_encode($iv.$id); |
146 | 146 | // +, / and = are not URL-compatible |
147 | 147 | $encrypted = str_replace('+', '-', $encrypted); |
@@ -156,22 +156,22 @@ discard block |
||
156 | 156 | * @param string $encrypted Text to decrypt |
157 | 157 | * @return string Decrypted text |
158 | 158 | */ |
159 | - public static function decryptFromSafeBase64($encrypted){ |
|
159 | + public static function decryptFromSafeBase64($encrypted) { |
|
160 | 160 | $key = 'STANDARDKEYIFNOSERVER'; |
161 | - if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
161 | + if ($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
162 | 162 | $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
163 | 163 | $encrypted = str_replace('-', '+', $encrypted); |
164 | 164 | $encrypted = str_replace('_', '/', $encrypted); |
165 | 165 | $encrypted = str_replace('*', '=', $encrypted); |
166 | 166 | $encrypted = base64_decode($encrypted); |
167 | - if(!$encrypted) |
|
167 | + if (!$encrypted) |
|
168 | 168 | throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
169 | - if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
169 | + if (strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
170 | 170 | throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
171 | 171 | $iv_dec = substr($encrypted, 0, self::ENCRYPTION_IV_SIZE); |
172 | 172 | $encrypted = substr($encrypted, self::ENCRYPTION_IV_SIZE); |
173 | 173 | $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv_dec); |
174 | - return preg_replace('~(?:\\000+)$~','',$decrypted); |
|
174 | + return preg_replace('~(?:\\000+)$~', '', $decrypted); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | * @param string $string Filesystem encoded string to encode |
181 | 181 | * @return string UTF-8 encoded string |
182 | 182 | */ |
183 | - public static function encodeFileSystemToUtf8($string){ |
|
183 | + public static function encodeFileSystemToUtf8($string) { |
|
184 | 184 | if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
185 | - return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
185 | + return iconv('cp1252', 'utf-8//IGNORE', $string); |
|
186 | 186 | } |
187 | 187 | return $string; |
188 | 188 | } |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | * @param string $string UTF-8 encoded string to encode |
194 | 194 | * @return string Filesystem encoded string |
195 | 195 | */ |
196 | - public static function encodeUtf8ToFileSystem($string){ |
|
196 | + public static function encodeUtf8ToFileSystem($string) { |
|
197 | 197 | if (preg_match('//u', $string) && strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
198 | - return iconv('utf-8', 'cp1252//IGNORE' , $string); |
|
198 | + return iconv('utf-8', 'cp1252//IGNORE', $string); |
|
199 | 199 | } |
200 | 200 | return $string; |
201 | 201 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @return boolean True if path valid |
209 | 209 | */ |
210 | 210 | public static function isValidPath($filename, $acceptfolder = FALSE) { |
211 | - if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
211 | + if (strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
212 | 212 | return false; |
213 | 213 | } |
214 | 214 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @return array Array of month short names |
221 | 221 | */ |
222 | 222 | public static function getCalendarShortMonths($calendarId = 0) { |
223 | - if(!isset(self::$calendarShortMonths[$calendarId])) { |
|
223 | + if (!isset(self::$calendarShortMonths[$calendarId])) { |
|
224 | 224 | $calendar_info = cal_info($calendarId); |
225 | 225 | self::$calendarShortMonths[$calendarId] = $calendar_info['abbrevmonths']; |
226 | 226 | } |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @param int $sosa Sosa number |
234 | 234 | * @return number |
235 | 235 | */ |
236 | - public static function getGeneration($sosa){ |
|
237 | - return(int)log($sosa, 2)+1; |
|
236 | + public static function getGeneration($sosa) { |
|
237 | + return(int)log($sosa, 2) + 1; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 |
@@ -29,143 +29,143 @@ discard block |
||
29 | 29 | * Certificates Module. |
30 | 30 | */ |
31 | 31 | class CertificatesModule |
32 | - extends AbstractModule |
|
33 | - implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtenderInterface, CustomSimpleTagManagerInterface |
|
32 | + extends AbstractModule |
|
33 | + implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtenderInterface, CustomSimpleTagManagerInterface |
|
34 | 34 | { |
35 | - /** @var string For custom modules - link for support, upgrades, etc. */ |
|
36 | - const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
35 | + /** @var string For custom modules - link for support, upgrades, etc. */ |
|
36 | + const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Provider for Certificates |
|
40 | - * @var CertificateProviderInterface $provider |
|
41 | - */ |
|
42 | - protected $provider; |
|
38 | + /** |
|
39 | + * Provider for Certificates |
|
40 | + * @var CertificateProviderInterface $provider |
|
41 | + */ |
|
42 | + protected $provider; |
|
43 | 43 | |
44 | - /** |
|
45 | - * {@inhericDoc} |
|
46 | - */ |
|
47 | - public function getTitle() { |
|
48 | - return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates'); |
|
49 | - } |
|
44 | + /** |
|
45 | + * {@inhericDoc} |
|
46 | + */ |
|
47 | + public function getTitle() { |
|
48 | + return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates'); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * {@inhericDoc} |
|
53 | - */ |
|
54 | - public function getDescription() { |
|
55 | - return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.'); |
|
56 | - } |
|
51 | + /** |
|
52 | + * {@inhericDoc} |
|
53 | + */ |
|
54 | + public function getDescription() { |
|
55 | + return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.'); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * {@inhericDoc} |
|
60 | - */ |
|
61 | - public function modAction($mod_action) { |
|
62 | - \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
63 | - } |
|
58 | + /** |
|
59 | + * {@inhericDoc} |
|
60 | + */ |
|
61 | + public function modAction($mod_action) { |
|
62 | + \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * {@inhericDoc} |
|
67 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
68 | - */ |
|
69 | - public function getConfigLink() { |
|
70 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
71 | - } |
|
65 | + /** |
|
66 | + * {@inhericDoc} |
|
67 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
68 | + */ |
|
69 | + public function getConfigLink() { |
|
70 | + return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * {@inhericDoc} |
|
75 | - * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
76 | - */ |
|
77 | - public function getSubscribedHooks() { |
|
78 | - return array( |
|
79 | - 'hFactSourcePrepend' => 50, |
|
80 | - 'hGetExpectedTags' => 50, |
|
81 | - 'hHtmlSimpleTagDisplay#_ACT' => 50, |
|
82 | - 'hHtmlSimpleTagEditor#_ACT' => 50, |
|
83 | - 'hAddSimpleTag#SOUR' => 50, |
|
84 | - 'hHasHelpTextTag#_ACT' => 50, |
|
85 | - 'hGetHelpTextTag#_ACT' => 50 |
|
86 | - ); |
|
87 | - } |
|
73 | + /** |
|
74 | + * {@inhericDoc} |
|
75 | + * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
76 | + */ |
|
77 | + public function getSubscribedHooks() { |
|
78 | + return array( |
|
79 | + 'hFactSourcePrepend' => 50, |
|
80 | + 'hGetExpectedTags' => 50, |
|
81 | + 'hHtmlSimpleTagDisplay#_ACT' => 50, |
|
82 | + 'hHtmlSimpleTagEditor#_ACT' => 50, |
|
83 | + 'hAddSimpleTag#SOUR' => 50, |
|
84 | + 'hHasHelpTextTag#_ACT' => 50, |
|
85 | + 'hGetHelpTextTag#_ACT' => 50 |
|
86 | + ); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * {@inhericDoc} |
|
91 | - * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu() |
|
92 | - */ |
|
93 | - public function getMenu(Tree $tree, $reference = null) { |
|
94 | - $tree_url = $tree ? $tree->getNameUrl() : ''; |
|
95 | - return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow')); |
|
96 | - } |
|
89 | + /** |
|
90 | + * {@inhericDoc} |
|
91 | + * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu() |
|
92 | + */ |
|
93 | + public function getMenu(Tree $tree, $reference = null) { |
|
94 | + $tree_url = $tree ? $tree->getNameUrl() : ''; |
|
95 | + return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow')); |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * {@inhericDoc} |
|
100 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourcePrepend() |
|
101 | - */ |
|
102 | - public function hFactSourcePrepend($srec) { |
|
103 | - global $WT_TREE; |
|
98 | + /** |
|
99 | + * {@inhericDoc} |
|
100 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourcePrepend() |
|
101 | + */ |
|
102 | + public function hFactSourcePrepend($srec) { |
|
103 | + global $WT_TREE; |
|
104 | 104 | |
105 | - $html=''; |
|
106 | - $sid=null; |
|
105 | + $html=''; |
|
106 | + $sid=null; |
|
107 | 107 | |
108 | - if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){ |
|
109 | - if (!$srec || strlen($srec) == 0) return $html; |
|
108 | + if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){ |
|
109 | + if (!$srec || strlen($srec) == 0) return $html; |
|
110 | 110 | |
111 | - $certificate = null; |
|
112 | - $subrecords = explode("\n", $srec); |
|
113 | - $levelSOUR = substr($subrecords[0], 0, 1); |
|
114 | - $match = null; |
|
115 | - if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) { |
|
116 | - $sid=$match[1]; |
|
117 | - }; |
|
118 | - $nb_subrecords = count($subrecords); |
|
119 | - for ($i=0; $i < $nb_subrecords; $i++) { |
|
120 | - $subrecords[$i] = trim($subrecords[$i]); |
|
121 | - $tag = substr($subrecords[$i], 2, 4); |
|
122 | - $text = substr($subrecords[$i], 7); |
|
123 | - if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
124 | - } |
|
111 | + $certificate = null; |
|
112 | + $subrecords = explode("\n", $srec); |
|
113 | + $levelSOUR = substr($subrecords[0], 0, 1); |
|
114 | + $match = null; |
|
115 | + if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) { |
|
116 | + $sid=$match[1]; |
|
117 | + }; |
|
118 | + $nb_subrecords = count($subrecords); |
|
119 | + for ($i=0; $i < $nb_subrecords; $i++) { |
|
120 | + $subrecords[$i] = trim($subrecords[$i]); |
|
121 | + $tag = substr($subrecords[$i], 2, 4); |
|
122 | + $text = substr($subrecords[$i], 7); |
|
123 | + if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
124 | + } |
|
125 | 125 | |
126 | - if($certificate && $certificate->canShow()) |
|
127 | - $html = $this->getDisplay_ACT($certificate, $sid); |
|
126 | + if($certificate && $certificate->canShow()) |
|
127 | + $html = $this->getDisplay_ACT($certificate, $sid); |
|
128 | 128 | |
129 | - } |
|
130 | - return $html; |
|
131 | - } |
|
129 | + } |
|
130 | + return $html; |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * {@inhericDoc} |
|
135 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourceAppend() |
|
136 | - */ |
|
137 | - public function hFactSourceAppend($srec) { } |
|
133 | + /** |
|
134 | + * {@inhericDoc} |
|
135 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourceAppend() |
|
136 | + */ |
|
137 | + public function hFactSourceAppend($srec) { } |
|
138 | 138 | |
139 | - /** |
|
140 | - * {@inhericDoc} |
|
141 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetExpectedTags() |
|
142 | - */ |
|
143 | - public function hGetExpectedTags() { |
|
144 | - return array('SOUR' => '_ACT'); |
|
145 | - } |
|
139 | + /** |
|
140 | + * {@inhericDoc} |
|
141 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetExpectedTags() |
|
142 | + */ |
|
143 | + public function hGetExpectedTags() { |
|
144 | + return array('SOUR' => '_ACT'); |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * {@inhericDoc} |
|
149 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagDisplay() |
|
150 | - */ |
|
151 | - public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) { |
|
152 | - $html = ''; |
|
153 | - switch($tag){ |
|
154 | - case '_ACT': |
|
155 | - if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
156 | - break; |
|
157 | - } |
|
158 | - return $html; |
|
159 | - } |
|
147 | + /** |
|
148 | + * {@inhericDoc} |
|
149 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagDisplay() |
|
150 | + */ |
|
151 | + public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) { |
|
152 | + $html = ''; |
|
153 | + switch($tag){ |
|
154 | + case '_ACT': |
|
155 | + if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
156 | + break; |
|
157 | + } |
|
158 | + return $html; |
|
159 | + } |
|
160 | 160 | |
161 | - /** |
|
162 | - * {@inhericDoc} |
|
163 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagEditor() |
|
164 | - */ |
|
165 | - public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) { |
|
166 | - global $controller, $WT_TREE; |
|
161 | + /** |
|
162 | + * {@inhericDoc} |
|
163 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagEditor() |
|
164 | + */ |
|
165 | + public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) { |
|
166 | + global $controller, $WT_TREE; |
|
167 | 167 | |
168 | - $html = ''; |
|
168 | + $html = ''; |
|
169 | 169 | |
170 | 170 | switch($tag){ |
171 | 171 | case '_ACT': |
@@ -193,77 +193,77 @@ discard block |
||
193 | 193 | } |
194 | 194 | |
195 | 195 | return $html; |
196 | - } |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * {@inhericDoc} |
|
200 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag() |
|
201 | - */ |
|
202 | - public function hAddSimpleTag($context, $level) { |
|
203 | - switch($context){ |
|
204 | - case 'SOUR': |
|
205 | - FunctionsEdit::addSimpleTag($level.' _ACT'); |
|
206 | - break; |
|
207 | - } |
|
208 | - } |
|
198 | + /** |
|
199 | + * {@inhericDoc} |
|
200 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag() |
|
201 | + */ |
|
202 | + public function hAddSimpleTag($context, $level) { |
|
203 | + switch($context){ |
|
204 | + case 'SOUR': |
|
205 | + FunctionsEdit::addSimpleTag($level.' _ACT'); |
|
206 | + break; |
|
207 | + } |
|
208 | + } |
|
209 | 209 | |
210 | - /** |
|
211 | - * {@inhericDoc} |
|
212 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag() |
|
213 | - */ |
|
214 | - public function hHasHelpTextTag($tag) { |
|
215 | - switch($tag){ |
|
210 | + /** |
|
211 | + * {@inhericDoc} |
|
212 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag() |
|
213 | + */ |
|
214 | + public function hHasHelpTextTag($tag) { |
|
215 | + switch($tag){ |
|
216 | 216 | case '_ACT': |
217 | 217 | return true; |
218 | 218 | } |
219 | 219 | return false; |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - /** |
|
223 | - * {@inhericDoc} |
|
224 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag() |
|
225 | - */ |
|
226 | - public function hGetHelpTextTag($tag) { |
|
227 | - switch($tag){ |
|
228 | - case '_ACT': |
|
229 | - return array( |
|
230 | - I18N::translate('Certificate'), |
|
231 | - '<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>'); |
|
232 | - default: |
|
233 | - return null; |
|
234 | - } |
|
235 | - } |
|
222 | + /** |
|
223 | + * {@inhericDoc} |
|
224 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag() |
|
225 | + */ |
|
226 | + public function hGetHelpTextTag($tag) { |
|
227 | + switch($tag){ |
|
228 | + case '_ACT': |
|
229 | + return array( |
|
230 | + I18N::translate('Certificate'), |
|
231 | + '<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>'); |
|
232 | + default: |
|
233 | + return null; |
|
234 | + } |
|
235 | + } |
|
236 | 236 | |
237 | - /** |
|
238 | - * Returns the default Certificate File Provider, as configured in the module |
|
239 | - * |
|
240 | - * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface |
|
241 | - */ |
|
242 | - public function getProvider() { |
|
243 | - global $WT_TREE; |
|
237 | + /** |
|
238 | + * Returns the default Certificate File Provider, as configured in the module |
|
239 | + * |
|
240 | + * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface |
|
241 | + */ |
|
242 | + public function getProvider() { |
|
243 | + global $WT_TREE; |
|
244 | 244 | |
245 | - if(!$this->provider) { |
|
246 | - $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/'); |
|
247 | - $this->provider = new CertificateFileProvider($root_path, $WT_TREE); |
|
248 | - } |
|
249 | - return $this->provider; |
|
250 | - } |
|
245 | + if(!$this->provider) { |
|
246 | + $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/'); |
|
247 | + $this->provider = new CertificateFileProvider($root_path, $WT_TREE); |
|
248 | + } |
|
249 | + return $this->provider; |
|
250 | + } |
|
251 | 251 | |
252 | 252 | |
253 | - /** |
|
254 | - * Return the HTML code for custom simple tag _ACT |
|
255 | - * |
|
256 | - * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
|
257 | - * @param string|null $sid Linked Source ID, if it exists |
|
258 | - */ |
|
259 | - protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
|
260 | - $html = ''; |
|
261 | - if($certificate){ |
|
262 | - $certificate->setSource($sid); |
|
263 | - $html = $certificate->displayImage('icon'); |
|
264 | - } |
|
265 | - return $html; |
|
266 | - } |
|
253 | + /** |
|
254 | + * Return the HTML code for custom simple tag _ACT |
|
255 | + * |
|
256 | + * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
|
257 | + * @param string|null $sid Linked Source ID, if it exists |
|
258 | + */ |
|
259 | + protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
|
260 | + $html = ''; |
|
261 | + if($certificate){ |
|
262 | + $certificate->setSource($sid); |
|
263 | + $html = $certificate->displayImage('icon'); |
|
264 | + } |
|
265 | + return $html; |
|
266 | + } |
|
267 | 267 | |
268 | 268 | } |
269 | 269 | |
270 | 270 | \ No newline at end of file |
@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | * {@inhericDoc} |
30 | 30 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
31 | 31 | */ |
32 | - protected function renderContent() { |
|
33 | - ?> |
|
32 | + protected function renderContent() { |
|
33 | + ?> |
|
34 | 34 | <div id="maj-sosa-missing-page" class="center"> |
35 | 35 | <h2><?php echo $this->data->get('title'); ?></h2> |
36 | 36 | |
37 | 37 | <?php if($this->data->get('is_setup')) { |
38 | - $this->renderSosaHeader(); |
|
39 | - if($this->data->get('has_missing', false)) { |
|
40 | - $table_id = $this->data->get('table_id'); |
|
41 | - ?> |
|
38 | + $this->renderSosaHeader(); |
|
39 | + if($this->data->get('has_missing', false)) { |
|
40 | + $table_id = $this->data->get('table_id'); |
|
41 | + ?> |
|
42 | 42 | <div id="sosa-indi-missing" class="smissing-list"> |
43 | 43 | <table id="<?php echo $table_id;?>"> |
44 | 44 | <thead> |
@@ -109,44 +109,44 @@ discard block |
||
109 | 109 | <tbody> |
110 | 110 | |
111 | 111 | <?php foreach($this->data->get('missing_list') as $missing_tab) { |
112 | - $person = $missing_tab['indi']; |
|
112 | + $person = $missing_tab['indi']; |
|
113 | 113 | |
114 | - /** @var \Fisharebest\Webtrees\Individual $person */ |
|
115 | - if ($person->isPendingAddtion()) { |
|
116 | - $class = ' class="new"'; |
|
117 | - } elseif ($person->isPendingDeletion()) { |
|
118 | - $class = ' class="old"'; |
|
119 | - } else { |
|
120 | - $class = ''; |
|
121 | - } |
|
122 | - $dperson = new \MyArtJaub\Webtrees\Individual($person); |
|
123 | - ?> |
|
114 | + /** @var \Fisharebest\Webtrees\Individual $person */ |
|
115 | + if ($person->isPendingAddtion()) { |
|
116 | + $class = ' class="new"'; |
|
117 | + } elseif ($person->isPendingDeletion()) { |
|
118 | + $class = ' class="old"'; |
|
119 | + } else { |
|
120 | + $class = ''; |
|
121 | + } |
|
122 | + $dperson = new \MyArtJaub\Webtrees\Individual($person); |
|
123 | + ?> |
|
124 | 124 | <tr <?php echo $class?>> |
125 | 125 | <td class="transparent"><?php echo $missing_tab['sosa']; ?></td> |
126 | 126 | <td class="transparent"><?php echo $person->getXref(); ?></td> |
127 | 127 | <td colspan="2"> |
128 | 128 | <?php foreach ($person->getAllNames() as $num=>$name) { |
129 | - if ($name['type']=='NAME') { |
|
130 | - $title=''; |
|
131 | - } else { |
|
132 | - $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $person)).'"'; |
|
133 | - } |
|
134 | - if ($num==$person->getPrimaryName()) { |
|
135 | - $class=' class="name2"'; |
|
136 | - $sex_image=$person->getSexImage(); |
|
137 | - list($surn, $givn)=explode(',', $name['sort']); |
|
138 | - } else { |
|
139 | - $class=''; |
|
140 | - $sex_image=''; |
|
141 | - } ?> |
|
129 | + if ($name['type']=='NAME') { |
|
130 | + $title=''; |
|
131 | + } else { |
|
132 | + $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $person)).'"'; |
|
133 | + } |
|
134 | + if ($num==$person->getPrimaryName()) { |
|
135 | + $class=' class="name2"'; |
|
136 | + $sex_image=$person->getSexImage(); |
|
137 | + list($surn, $givn)=explode(',', $name['sort']); |
|
138 | + } else { |
|
139 | + $class=''; |
|
140 | + $sex_image=''; |
|
141 | + } ?> |
|
142 | 142 | <a <?php echo $title.' '.$class; ?> href="<?php echo $person->getHtmlUrl(); ?>"> |
143 | 143 | <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']); ?> |
144 | 144 | </a> |
145 | 145 | <?php echo $sex_image.FunctionsPrint::formatSosaNumbers($dperson->getSosaNumbers(), 1, 'smaller'); ?> |
146 | 146 | <br/> |
147 | 147 | <?php } |
148 | - echo $person->getPrimaryParentsNames('parents details1', 'none'); |
|
149 | - ?> |
|
148 | + echo $person->getPrimaryParentsNames('parents details1', 'none'); |
|
149 | + ?> |
|
150 | 150 | </td> |
151 | 151 | <td style="display:none;"></td> |
152 | 152 | <td> |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | <?php echo Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)); ?> |
157 | 157 | </td> |
158 | 158 | <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { |
159 | - $isISourced = $dperson->isSourced(); ?> |
|
159 | + $isISourced = $dperson->isSourced(); ?> |
|
160 | 160 | <td><?php echo FunctionsPrint::formatIsSourcedIcon('R', $isISourced, 'INDI', 1, 'medium'); ?></td> |
161 | 161 | <td><?php echo $isISourced; ?></td> |
162 | 162 | <?php } else { ?> |
@@ -167,34 +167,34 @@ discard block |
||
167 | 167 | <td><?php echo $missing_tab['has_mother'] ? ' ' : 'X';?></td> |
168 | 168 | <td> |
169 | 169 | <?php |
170 | - if ($birth_dates=$person->getAllBirthDates()) { |
|
171 | - foreach ($birth_dates as $num=>$birth_date) { |
|
172 | - if ($num) { ?><br/><?php } ?> |
|
170 | + if ($birth_dates=$person->getAllBirthDates()) { |
|
171 | + foreach ($birth_dates as $num=>$birth_date) { |
|
172 | + if ($num) { ?><br/><?php } ?> |
|
173 | 173 | <?php echo $birth_date->display(true); |
174 | - } |
|
175 | - } else { |
|
176 | - $birth_date=$person->getEstimatedBirthDate(); |
|
177 | - if ($person->getTree()->getPreference('SHOW_EST_LIST_DATES')) { |
|
178 | - $birth_date->display(true); |
|
179 | - } else { |
|
180 | - echo ' '; |
|
181 | - } |
|
182 | - $birth_dates[0] = new Date(''); |
|
183 | - } |
|
184 | - ?> |
|
174 | + } |
|
175 | + } else { |
|
176 | + $birth_date=$person->getEstimatedBirthDate(); |
|
177 | + if ($person->getTree()->getPreference('SHOW_EST_LIST_DATES')) { |
|
178 | + $birth_date->display(true); |
|
179 | + } else { |
|
180 | + echo ' '; |
|
181 | + } |
|
182 | + $birth_dates[0] = new Date(''); |
|
183 | + } |
|
184 | + ?> |
|
185 | 185 | </td> |
186 | 186 | <td><?php echo $birth_date->julianDay();?></td> |
187 | 187 | <td> |
188 | 188 | <?php foreach ($person->getAllBirthPlaces() as $n => $birth_place) { |
189 | - $tmp = new \Fisharebest\Webtrees\Place($birth_place, $person->getTree()); |
|
190 | - if ($n) { ?><br><?php } ?> |
|
189 | + $tmp = new \Fisharebest\Webtrees\Place($birth_place, $person->getTree()); |
|
190 | + if ($n) { ?><br><?php } ?> |
|
191 | 191 | <a href="'<?php echo $tmp->getURL(); ?>" title="<?php echo strip_tags($tmp->getFullName()); ?>"> |
192 | 192 | <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName()); ?> |
193 | 193 | </a> |
194 | 194 | <?php } ?> |
195 | 195 | </td> |
196 | 196 | <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { |
197 | - $isBSourced = $dperson->isBirthSourced(); ?> |
|
197 | + $isBSourced = $dperson->isBirthSourced(); ?> |
|
198 | 198 | <td><?php echo FunctionsPrint::formatIsSourcedIcon('E', $isBSourced, 'BIRT', 1, 'medium'); ?></td> |
199 | 199 | <td><?php echo $isBSourced; ?></td> |
200 | 200 | <?php } else { ?> |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | <?php } else { ?> |
222 | 222 | <p><?php echo I18N::translate('No ancestors are missing for this generation. Generation complete at %s.', I18N::percentage($this->data->get('perc_sosa'), 2)); ?></p> |
223 | 223 | <?php } |
224 | - } else { ?> |
|
224 | + } else { ?> |
|
225 | 225 | <p class="warning"><?php echo I18N::translate('The list could not be displayed. Reasons might be:'); ?><br/> |
226 | 226 | <ul> |
227 | 227 | <li><?php echo I18N::translate('No Sosa root individual has been defined.'); ?></li> |
@@ -232,6 +232,6 @@ discard block |
||
232 | 232 | <?php } ?> |
233 | 233 | </div> |
234 | 234 | <?php |
235 | - } |
|
235 | + } |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | \ No newline at end of file |
@@ -19,116 +19,116 @@ |
||
19 | 19 | */ |
20 | 20 | class SosaCalculator { |
21 | 21 | |
22 | - /** |
|
23 | - * Maximium size for the temporary Sosa table |
|
24 | - * @var int TMP_SOSA_TABLE_LIMIT |
|
25 | - */ |
|
26 | - const TMP_SOSA_TABLE_LIMIT = 1000; |
|
22 | + /** |
|
23 | + * Maximium size for the temporary Sosa table |
|
24 | + * @var int TMP_SOSA_TABLE_LIMIT |
|
25 | + */ |
|
26 | + const TMP_SOSA_TABLE_LIMIT = 1000; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Reference user |
|
30 | - * @var Fisharebest\Webtrees\User $user |
|
31 | - */ |
|
32 | - protected $user; |
|
28 | + /** |
|
29 | + * Reference user |
|
30 | + * @var Fisharebest\Webtrees\User $user |
|
31 | + */ |
|
32 | + protected $user; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Reference tree |
|
36 | - * @var Fisharebest\Webtrees\Tree $tree |
|
37 | - */ |
|
38 | - protected $tree; |
|
34 | + /** |
|
35 | + * Reference tree |
|
36 | + * @var Fisharebest\Webtrees\Tree $tree |
|
37 | + */ |
|
38 | + protected $tree; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Sosa Provider for the calculator |
|
42 | - * @var \MyArtJaub\Webtrees\Module\Sosa\Model\SosaCalculator $sosa_provider |
|
43 | - */ |
|
44 | - protected $sosa_provider; |
|
40 | + /** |
|
41 | + * Sosa Provider for the calculator |
|
42 | + * @var \MyArtJaub\Webtrees\Module\Sosa\Model\SosaCalculator $sosa_provider |
|
43 | + */ |
|
44 | + protected $sosa_provider; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Temporary Sosa table, used during construction |
|
48 | - * @var array $tmp_sosa_table |
|
49 | - */ |
|
50 | - protected $tmp_sosa_table; |
|
46 | + /** |
|
47 | + * Temporary Sosa table, used during construction |
|
48 | + * @var array $tmp_sosa_table |
|
49 | + */ |
|
50 | + protected $tmp_sosa_table; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Constructor for the Sosa Calculator |
|
54 | - * @param Tree $tree |
|
55 | - * @param User $user |
|
56 | - */ |
|
57 | - public function __construct(Tree $tree, User $user) { |
|
58 | - $this->tree = $tree; |
|
59 | - $this->user = $user; |
|
52 | + /** |
|
53 | + * Constructor for the Sosa Calculator |
|
54 | + * @param Tree $tree |
|
55 | + * @param User $user |
|
56 | + */ |
|
57 | + public function __construct(Tree $tree, User $user) { |
|
58 | + $this->tree = $tree; |
|
59 | + $this->user = $user; |
|
60 | 60 | |
61 | - $this->sosa_provider = new SosaProvider($this->tree, $this->user);; |
|
62 | - } |
|
61 | + $this->sosa_provider = new SosaProvider($this->tree, $this->user);; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Compute all Sosa ancestors from the user's root individual. |
|
66 | - * @return bool Result of the computation |
|
67 | - */ |
|
68 | - public function computeAll() { |
|
69 | - $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID'); |
|
70 | - $indi = Individual::getInstance($root_id, $this->tree); |
|
71 | - if($indi){ |
|
72 | - $this->sosa_provider->deleteAll(); |
|
73 | - $this->addNode($indi, 1); |
|
74 | - $this->flushTmpSosaTable(true); |
|
75 | - return true; |
|
76 | - } |
|
77 | - return false; |
|
78 | - } |
|
64 | + /** |
|
65 | + * Compute all Sosa ancestors from the user's root individual. |
|
66 | + * @return bool Result of the computation |
|
67 | + */ |
|
68 | + public function computeAll() { |
|
69 | + $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID'); |
|
70 | + $indi = Individual::getInstance($root_id, $this->tree); |
|
71 | + if($indi){ |
|
72 | + $this->sosa_provider->deleteAll(); |
|
73 | + $this->addNode($indi, 1); |
|
74 | + $this->flushTmpSosaTable(true); |
|
75 | + return true; |
|
76 | + } |
|
77 | + return false; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Compute all Sosa Ancestors from a specified Individual |
|
82 | - * @param Individual $indi |
|
83 | - * @return bool Result of the computation |
|
84 | - */ |
|
85 | - public function computeFromIndividual(Individual $indi) { |
|
86 | - $dindi = new \MyArtJaub\Webtrees\Individual($indi); |
|
87 | - $current_sosas = $dindi->getSosaNumbers(); |
|
88 | - foreach($current_sosas as $current_sosa => $gen) { |
|
89 | - $this->sosa_provider->deleteAncestors($current_sosa); |
|
90 | - $this->addNode($indi, $current_sosa); |
|
91 | - } |
|
92 | - $this->flushTmpSosaTable(true); |
|
93 | - return true; |
|
94 | - } |
|
80 | + /** |
|
81 | + * Compute all Sosa Ancestors from a specified Individual |
|
82 | + * @param Individual $indi |
|
83 | + * @return bool Result of the computation |
|
84 | + */ |
|
85 | + public function computeFromIndividual(Individual $indi) { |
|
86 | + $dindi = new \MyArtJaub\Webtrees\Individual($indi); |
|
87 | + $current_sosas = $dindi->getSosaNumbers(); |
|
88 | + foreach($current_sosas as $current_sosa => $gen) { |
|
89 | + $this->sosa_provider->deleteAncestors($current_sosa); |
|
90 | + $this->addNode($indi, $current_sosa); |
|
91 | + } |
|
92 | + $this->flushTmpSosaTable(true); |
|
93 | + return true; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Recursive method to add individual to the Sosa table, and flush it regularly |
|
98 | - * @param Individual $indi Individual to add |
|
99 | - * @param int $sosa Individual's sosa |
|
100 | - */ |
|
101 | - protected function addNode(Individual $indi, $sosa) { |
|
102 | - $birth_year = $indi->getEstimatedBirthDate()->gregorianYear(); |
|
103 | - $death_year = $indi->getEstimatedDeathDate()->gregorianYear(); |
|
96 | + /** |
|
97 | + * Recursive method to add individual to the Sosa table, and flush it regularly |
|
98 | + * @param Individual $indi Individual to add |
|
99 | + * @param int $sosa Individual's sosa |
|
100 | + */ |
|
101 | + protected function addNode(Individual $indi, $sosa) { |
|
102 | + $birth_year = $indi->getEstimatedBirthDate()->gregorianYear(); |
|
103 | + $death_year = $indi->getEstimatedDeathDate()->gregorianYear(); |
|
104 | 104 | |
105 | - $this->tmp_sosa_table[] = array( |
|
106 | - 'indi' => $indi->getXref(), |
|
107 | - 'sosa' => $sosa, |
|
108 | - 'birth_year' => $birth_year, |
|
109 | - 'death_year' => $death_year |
|
110 | - ); |
|
105 | + $this->tmp_sosa_table[] = array( |
|
106 | + 'indi' => $indi->getXref(), |
|
107 | + 'sosa' => $sosa, |
|
108 | + 'birth_year' => $birth_year, |
|
109 | + 'death_year' => $death_year |
|
110 | + ); |
|
111 | 111 | |
112 | - $this->flushTmpSosaTable(); |
|
112 | + $this->flushTmpSosaTable(); |
|
113 | 113 | |
114 | - if($fam = $indi->getPrimaryChildFamily()) { |
|
115 | - if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa); |
|
116 | - if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1); |
|
117 | - } |
|
118 | - } |
|
114 | + if($fam = $indi->getPrimaryChildFamily()) { |
|
115 | + if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa); |
|
116 | + if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1); |
|
117 | + } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Write sosas in the table, if the number of items is superior to the limit, or if forced. |
|
122 | - * |
|
123 | - * @param bool $force Should the flush be forced |
|
124 | - */ |
|
125 | - protected function flushTmpSosaTable($force = false) { |
|
126 | - if( count($this->tmp_sosa_table)> 0 && |
|
127 | - ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){ |
|
128 | - $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table); |
|
129 | - $this->tmp_sosa_table = array(); |
|
130 | - } |
|
131 | - } |
|
120 | + /** |
|
121 | + * Write sosas in the table, if the number of items is superior to the limit, or if forced. |
|
122 | + * |
|
123 | + * @param bool $force Should the flush be forced |
|
124 | + */ |
|
125 | + protected function flushTmpSosaTable($force = false) { |
|
126 | + if( count($this->tmp_sosa_table)> 0 && |
|
127 | + ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){ |
|
128 | + $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table); |
|
129 | + $this->tmp_sosa_table = array(); |
|
130 | + } |
|
131 | + } |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | 135 | \ No newline at end of file |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | */ |
30 | 30 | class HealthCheckEmailTask extends AbstractTask implements ConfigurableTaskInterface { |
31 | 31 | |
32 | - /** |
|
33 | - * {@inheritDoc} |
|
34 | - * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getTitle() |
|
35 | - */ |
|
36 | - public function getTitle() { |
|
32 | + /** |
|
33 | + * {@inheritDoc} |
|
34 | + * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getTitle() |
|
35 | + */ |
|
36 | + public function getTitle() { |
|
37 | 37 | return I18N::translate('Healthcheck Email'); |
38 | 38 | } |
39 | 39 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * {@inheritDoc} |
42 | 42 | * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getDefaultFrequency() |
43 | 43 | */ |
44 | - public function getDefaultFrequency() { |
|
44 | + public function getDefaultFrequency() { |
|
45 | 45 | return 10080; // = 1 week = 7 * 24 * 60 min |
46 | 46 | } |
47 | 47 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * {@inheritDoc} |
50 | 50 | * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::executeSteps() |
51 | 51 | */ |
52 | - protected function executeSteps() { |
|
52 | + protected function executeSteps() { |
|
53 | 53 | |
54 | 54 | $res = false; |
55 | 55 | |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | $interval = max($this->frequency, $interval_sincelast); |
64 | 64 | $nbdays = ceil($interval / (24 * 60)); |
65 | 65 | |
66 | - // Check for updates |
|
67 | - $latest_version_txt = Functions::fetchLatestVersion(); |
|
68 | - if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) { |
|
69 | - list($latest_version, , $download_url) = explode('|', $latest_version_txt); |
|
70 | - } else { |
|
71 | - // Cannot determine the latest version |
|
72 | - list($latest_version, , $download_url) = explode('|', '||'); |
|
73 | - } |
|
66 | + // Check for updates |
|
67 | + $latest_version_txt = Functions::fetchLatestVersion(); |
|
68 | + if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) { |
|
69 | + list($latest_version, , $download_url) = explode('|', $latest_version_txt); |
|
70 | + } else { |
|
71 | + // Cannot determine the latest version |
|
72 | + list($latest_version, , $download_url) = explode('|', '||'); |
|
73 | + } |
|
74 | 74 | |
75 | 75 | // Users statistics |
76 | 76 | $warnusers = 0; |
@@ -213,15 +213,15 @@ discard block |
||
213 | 213 | $html = ' |
214 | 214 | <div class="form-group"> |
215 | 215 | <label class="control-label col-sm-3"> '. |
216 | - I18N::translate('Enable healthcheck emails for') . |
|
217 | - '</label> |
|
216 | + I18N::translate('Enable healthcheck emails for') . |
|
217 | + '</label> |
|
218 | 218 | <div class="col-sm-9">'; |
219 | 219 | |
220 | 220 | foreach(Tree::getAll() as $tree){ |
221 | 221 | if(Auth::isManager($tree)){ |
222 | - $html .= '<div class="form-group row"> |
|
222 | + $html .= '<div class="form-group row"> |
|
223 | 223 | <span class="col-sm-3 control-label">' . |
224 | - $tree->getTitle() . |
|
224 | + $tree->getTitle() . |
|
225 | 225 | '</span> |
226 | 226 | <div class="col-sm-2">'; |
227 | 227 | $html .= FunctionsEdit::editFieldYesNo('HEALTHCHECK_ENABLED_' . $tree->getTreeId(), $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED', 1), 'class="radio-inline"'); |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | $html .= ' <p class="small text-muted">'. |
233 | - I18N::translate('Enable the health check emails for each of the selected trees.') . |
|
234 | - '</p> |
|
233 | + I18N::translate('Enable the health check emails for each of the selected trees.') . |
|
234 | + '</p> |
|
235 | 235 | </div> |
236 | 236 | </div>'; |
237 | 237 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getDefaultFrequency() |
43 | 43 | */ |
44 | 44 | public function getDefaultFrequency() { |
45 | - return 10080; // = 1 week = 7 * 24 * 60 min |
|
45 | + return 10080; // = 1 week = 7 * 24 * 60 min |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | |
56 | 56 | // Get the number of days to take into account, either last 7 days or since last check |
57 | 57 | $interval_sincelast = 0; |
58 | - if($this->last_updated){ |
|
58 | + if ($this->last_updated) { |
|
59 | 59 | $tmpInt = $this->last_updated->diff(new \DateTime('now'), true); |
60 | - $interval_sincelast = ( $tmpInt->days * 24 + $tmpInt->h ) * 60 + $tmpInt->i; |
|
60 | + $interval_sincelast = ($tmpInt->days * 24 + $tmpInt->h) * 60 + $tmpInt->i; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $interval = max($this->frequency, $interval_sincelast); |
@@ -66,17 +66,17 @@ discard block |
||
66 | 66 | // Check for updates |
67 | 67 | $latest_version_txt = Functions::fetchLatestVersion(); |
68 | 68 | if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) { |
69 | - list($latest_version, , $download_url) = explode('|', $latest_version_txt); |
|
69 | + list($latest_version,, $download_url) = explode('|', $latest_version_txt); |
|
70 | 70 | } else { |
71 | 71 | // Cannot determine the latest version |
72 | - list($latest_version, , $download_url) = explode('|', '||'); |
|
72 | + list($latest_version,, $download_url) = explode('|', '||'); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // Users statistics |
76 | 76 | $warnusers = 0; |
77 | 77 | $nverusers = 0; |
78 | 78 | $applusers = 0; |
79 | - foreach(User::all() as $user) { |
|
79 | + foreach (User::all() as $user) { |
|
80 | 80 | if (((date("U") - (int)$user->getPreference('reg_timestamp')) > 604800) && !$user->getPreference('verified')) { |
81 | 81 | $warnusers++; |
82 | 82 | } |
@@ -90,20 +90,20 @@ discard block |
||
90 | 90 | |
91 | 91 | // Tree specifics checks |
92 | 92 | $one_tree_done = false; |
93 | - foreach(Tree::getAll() as $tree){ |
|
93 | + foreach (Tree::getAll() as $tree) { |
|
94 | 94 | $isTreeEnabled = $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED'); |
95 | - if((is_null($isTreeEnabled) || $isTreeEnabled) && $webmaster = User::find($tree->getPreference('WEBMASTER_USER_ID'))){ |
|
95 | + if ((is_null($isTreeEnabled) || $isTreeEnabled) && $webmaster = User::find($tree->getPreference('WEBMASTER_USER_ID'))) { |
|
96 | 96 | I18N::init($webmaster->getPreference('language')); |
97 | 97 | |
98 | 98 | $subject = I18N::translate('Health Check Report').' - '.I18N::translate('Tree %s', $tree->getTitle()); |
99 | 99 | $message = |
100 | - I18N::translate('Health Check Report for the last %d days', $nbdays). Mail::EOL. Mail::EOL. |
|
100 | + I18N::translate('Health Check Report for the last %d days', $nbdays).Mail::EOL.Mail::EOL. |
|
101 | 101 | I18N::translate('Tree %s', $tree->getTitle()).Mail::EOL. |
102 | 102 | '=========================================='.Mail::EOL.Mail::EOL; |
103 | 103 | |
104 | 104 | // News |
105 | 105 | $message_version = ''; |
106 | - if($latest_version && version_compare(WT_VERSION, $latest_version)<0){ |
|
106 | + if ($latest_version && version_compare(WT_VERSION, $latest_version) < 0) { |
|
107 | 107 | $message_version = I18N::translate('News').Mail::EOL. |
108 | 108 | '-------------'.Mail::EOL. |
109 | 109 | I18N::translate('A new version of *webtrees* is available: %s. Upgrade as soon as possible.', $latest_version).Mail::EOL. |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | I18N::translate('Not verified by the user')."\t\t".$applusers.Mail::EOL. |
120 | 120 | I18N::translate('Not approved by an administrator')."\t".$nverusers.Mail::EOL. |
121 | 121 | Mail::EOL; |
122 | - $message .= $message_users; |
|
122 | + $message .= $message_users; |
|
123 | 123 | |
124 | 124 | // Statistics tree: |
125 | 125 | $stats = new Stats($tree); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | ' AND log_time >= DATE_ADD( NOW(), INTERVAL - :nb_days DAY)'. |
160 | 160 | ' GROUP BY log_message, gedcom_id'. |
161 | 161 | ' ORDER BY lastoccurred DESC'; |
162 | - $errors=Database::prepare($sql)->execute(array( |
|
162 | + $errors = Database::prepare($sql)->execute(array( |
|
163 | 163 | 'log_type' => Log::TYPE_ERROR, |
164 | 164 | 'gedcom_id' => $tree->getTreeId(), |
165 | 165 | 'nb_days' => $nbdays |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $tmp_message .= str_replace("\n", "\n\t\t\t\t\t\t", $error->log_message).Mail::EOL; |
176 | 176 | $nb_errors += $error->nblogs; |
177 | 177 | } |
178 | - if($nb_errors > 0){ |
|
178 | + if ($nb_errors > 0) { |
|
179 | 179 | $message .= I18N::translate('Errors [%d]', $nb_errors).Mail::EOL. |
180 | 180 | '-------------'.Mail::EOL. |
181 | 181 | WT_BASE_URL.'admin_site_logs.php'.Mail::EOL. |
@@ -186,12 +186,12 @@ discard block |
||
186 | 186 | str_repeat('-', $nb_char_count_title)."\t".str_repeat('-', $nb_char_type)."\t".str_repeat('-', 20)."\t".str_repeat('-', strlen(I18N::translate('Error'))).Mail::EOL. |
187 | 187 | $tmp_message.Mail::EOL; |
188 | 188 | } |
189 | - else{ |
|
189 | + else { |
|
190 | 190 | $message .= I18N::translate('No errors', $nb_errors).Mail::EOL.Mail::EOL; |
191 | 191 | } |
192 | 192 | |
193 | 193 | $tmpres = true; |
194 | - if($webmaster->getPreference('contactmethod') !== 'messaging' |
|
194 | + if ($webmaster->getPreference('contactmethod') !== 'messaging' |
|
195 | 195 | && $webmaster->getPreference('contactmethod') !== 'none') { |
196 | 196 | $tmpres = Mail::systemMessage($tree, $webmaster, $subject, $message); |
197 | 197 | } |
@@ -213,24 +213,24 @@ discard block |
||
213 | 213 | $html = ' |
214 | 214 | <div class="form-group"> |
215 | 215 | <label class="control-label col-sm-3"> '. |
216 | - I18N::translate('Enable healthcheck emails for') . |
|
216 | + I18N::translate('Enable healthcheck emails for'). |
|
217 | 217 | '</label> |
218 | 218 | <div class="col-sm-9">'; |
219 | 219 | |
220 | - foreach(Tree::getAll() as $tree){ |
|
221 | - if(Auth::isManager($tree)){ |
|
220 | + foreach (Tree::getAll() as $tree) { |
|
221 | + if (Auth::isManager($tree)) { |
|
222 | 222 | $html .= '<div class="form-group row"> |
223 | 223 | <span class="col-sm-3 control-label">' . |
224 | - $tree->getTitle() . |
|
224 | + $tree->getTitle(). |
|
225 | 225 | '</span> |
226 | 226 | <div class="col-sm-2">'; |
227 | - $html .= FunctionsEdit::editFieldYesNo('HEALTHCHECK_ENABLED_' . $tree->getTreeId(), $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED', 1), 'class="radio-inline"'); |
|
227 | + $html .= FunctionsEdit::editFieldYesNo('HEALTHCHECK_ENABLED_'.$tree->getTreeId(), $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED', 1), 'class="radio-inline"'); |
|
228 | 228 | $html .= '</div></div>'; |
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | 232 | $html .= ' <p class="small text-muted">'. |
233 | - I18N::translate('Enable the health check emails for each of the selected trees.') . |
|
233 | + I18N::translate('Enable the health check emails for each of the selected trees.'). |
|
234 | 234 | '</p> |
235 | 235 | </div> |
236 | 236 | </div>'; |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function saveConfig() { |
246 | 246 | try { |
247 | - foreach(Tree::getAll() as $tree){ |
|
248 | - if(Auth::isManager($tree)){ |
|
249 | - $tree_enabled = Filter::postInteger('HEALTHCHECK_ENABLED_' . $tree->getTreeId(), 0, 1); |
|
247 | + foreach (Tree::getAll() as $tree) { |
|
248 | + if (Auth::isManager($tree)) { |
|
249 | + $tree_enabled = Filter::postInteger('HEALTHCHECK_ENABLED_'.$tree->getTreeId(), 0, 1); |
|
250 | 250 | $tree->setPreference('MAJ_AT_'.$this->getName().'_ENABLED', $tree_enabled); |
251 | 251 | } |
252 | 252 | } |
@@ -24,16 +24,16 @@ |
||
24 | 24 | */ |
25 | 25 | public function upgrade() { |
26 | 26 | Database::exec( |
27 | - 'CREATE TABLE IF NOT EXISTS `##maj_admintasks` ('. |
|
28 | - ' majat_name VARCHAR(32) NOT NULL,'. |
|
29 | - ' majat_status ENUM(\'enabled\',\'disabled\') NOT NULL DEFAULT \'disabled\','. |
|
30 | - ' majat_last_run DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\','. |
|
31 | - ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'. // 0 means error, 1 is success |
|
32 | - ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'. // In min, Default every week |
|
33 | - ' majat_nb_occur SMALLINT NOT NULL DEFAULT 0,'. |
|
34 | - ' majat_running TINYINT(1) NOT NULL DEFAULT 0,'. |
|
35 | - ' PRIMARY KEY (majat_name)'. |
|
36 | - ') COLLATE utf8_unicode_ci ENGINE=InnoDB' |
|
27 | + 'CREATE TABLE IF NOT EXISTS `##maj_admintasks` ('. |
|
28 | + ' majat_name VARCHAR(32) NOT NULL,'. |
|
29 | + ' majat_status ENUM(\'enabled\',\'disabled\') NOT NULL DEFAULT \'disabled\','. |
|
30 | + ' majat_last_run DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\','. |
|
31 | + ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'. // 0 means error, 1 is success |
|
32 | + ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'. // In min, Default every week |
|
33 | + ' majat_nb_occur SMALLINT NOT NULL DEFAULT 0,'. |
|
34 | + ' majat_running TINYINT(1) NOT NULL DEFAULT 0,'. |
|
35 | + ' PRIMARY KEY (majat_name)'. |
|
36 | + ') COLLATE utf8_unicode_ci ENGINE=InnoDB' |
|
37 | 37 | ); |
38 | 38 | } |
39 | 39 | } |
@@ -28,8 +28,8 @@ |
||
28 | 28 | ' majat_name VARCHAR(32) NOT NULL,'. |
29 | 29 | ' majat_status ENUM(\'enabled\',\'disabled\') NOT NULL DEFAULT \'disabled\','. |
30 | 30 | ' majat_last_run DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\','. |
31 | - ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'. // 0 means error, 1 is success |
|
32 | - ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'. // In min, Default every week |
|
31 | + ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'.// 0 means error, 1 is success |
|
32 | + ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'.// In min, Default every week |
|
33 | 33 | ' majat_nb_occur SMALLINT NOT NULL DEFAULT 0,'. |
34 | 34 | ' majat_running TINYINT(1) NOT NULL DEFAULT 0,'. |
35 | 35 | ' PRIMARY KEY (majat_name)'. |
@@ -24,89 +24,89 @@ discard block |
||
24 | 24 | * {@inhericDoc} |
25 | 25 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
26 | 26 | */ |
27 | - protected function renderContent() { |
|
27 | + protected function renderContent() { |
|
28 | 28 | |
29 | - $max_details_gen = $this->data->get('max_details_gen'); |
|
30 | - $analysis_level = $this->data->get('analysis_level'); |
|
31 | - $results_by_gen = $this->data->get('results_by_generations'); |
|
32 | - $display_all_places = $this->data->get('display_all_places', true); |
|
29 | + $max_details_gen = $this->data->get('max_details_gen'); |
|
30 | + $analysis_level = $this->data->get('analysis_level'); |
|
31 | + $results_by_gen = $this->data->get('results_by_generations'); |
|
32 | + $display_all_places = $this->data->get('display_all_places', true); |
|
33 | 33 | |
34 | - $html = |
|
35 | - '<div id="geodispersion_gen"> |
|
34 | + $html = |
|
35 | + '<div id="geodispersion_gen"> |
|
36 | 36 | <table id="geodispersion_gentable" class="center">'; |
37 | 37 | |
38 | - foreach($results_by_gen as $gen => $genData){ |
|
39 | - $html .= |
|
40 | - '<tr> |
|
38 | + foreach($results_by_gen as $gen => $genData){ |
|
39 | + $html .= |
|
40 | + '<tr> |
|
41 | 41 | <td class="descriptionbox">' . |
42 | - I18N::translate("Generation %s", I18N::number($gen)). |
|
43 | - ($display_all_places ? '<br />' : ' '). |
|
44 | - I18N::translate('(%s)', I18N::percentage(Functions::safeDivision($genData['sum'] + $genData['other'], $genData['sum'] + $genData['other'] + $genData['unknown']),1)) . |
|
45 | - '</td> |
|
42 | + I18N::translate("Generation %s", I18N::number($gen)). |
|
43 | + ($display_all_places ? '<br />' : ' '). |
|
44 | + I18N::translate('(%s)', I18N::percentage(Functions::safeDivision($genData['sum'] + $genData['other'], $genData['sum'] + $genData['other'] + $genData['unknown']),1)) . |
|
45 | + '</td> |
|
46 | 46 | <td class="optionbox left">'. |
47 | - ($display_all_places ? |
|
48 | - $this->htmlGenerationAllPlacesRow($genData, $analysis_level) : |
|
49 | - $this->htmlGenerationTopPlacesRow($genData, $analysis_level) |
|
50 | - ) . |
|
51 | - '</ditdv> |
|
47 | + ($display_all_places ? |
|
48 | + $this->htmlGenerationAllPlacesRow($genData, $analysis_level) : |
|
49 | + $this->htmlGenerationTopPlacesRow($genData, $analysis_level) |
|
50 | + ) . |
|
51 | + '</ditdv> |
|
52 | 52 | </tr>'; |
53 | - } |
|
53 | + } |
|
54 | 54 | |
55 | - $html.= |
|
56 | - '</table> |
|
55 | + $html.= |
|
56 | + '</table> |
|
57 | 57 | <div class="left"> |
58 | 58 | <strong>' . I18N::translate('Interpretation help:') . '</strong> |
59 | 59 | <br />'. |
60 | - I18N::translate('<strong>Generation X (yy %%)</strong>: The percentage indicates the number of found places compared to the total number of ancestors in this generation.') . |
|
61 | - '<br />'; |
|
62 | - if(!is_null($max_details_gen) && $max_details_gen == 0){ |
|
63 | - $html .= I18N::translate('<strong><em>Place</em> or <em>Flag</em> aa (bb %%)</strong>: The first number indicates the total number of ancestors born in this place, the percentage relates this count to the total number of found places. No percentage means it is less than 10%%.').'<br />'; |
|
64 | - $html .= I18N::translate('If any, the darker area indicates the number of unknown places within the generation or places outside the analysed area, and its percentage compared to the number of ancestors. No percentage means it is less than 10%%.'); |
|
65 | - } |
|
66 | - else{ |
|
67 | - $html .= I18N::translate('<strong><em>Place</em> [aa - bb %%]</strong>: The first number indicates the total number of ancestors born in this place, the percentage compares this count to the total number of found places.').'<br />'; |
|
68 | - $html .= I18N::translate('Only the %d more frequent places for each generation are displayed.', $max_details_gen); |
|
69 | - } |
|
70 | - $html.= |
|
71 | - '</div> |
|
60 | + I18N::translate('<strong>Generation X (yy %%)</strong>: The percentage indicates the number of found places compared to the total number of ancestors in this generation.') . |
|
61 | + '<br />'; |
|
62 | + if(!is_null($max_details_gen) && $max_details_gen == 0){ |
|
63 | + $html .= I18N::translate('<strong><em>Place</em> or <em>Flag</em> aa (bb %%)</strong>: The first number indicates the total number of ancestors born in this place, the percentage relates this count to the total number of found places. No percentage means it is less than 10%%.').'<br />'; |
|
64 | + $html .= I18N::translate('If any, the darker area indicates the number of unknown places within the generation or places outside the analysed area, and its percentage compared to the number of ancestors. No percentage means it is less than 10%%.'); |
|
65 | + } |
|
66 | + else{ |
|
67 | + $html .= I18N::translate('<strong><em>Place</em> [aa - bb %%]</strong>: The first number indicates the total number of ancestors born in this place, the percentage compares this count to the total number of found places.').'<br />'; |
|
68 | + $html .= I18N::translate('Only the %d more frequent places for each generation are displayed.', $max_details_gen); |
|
69 | + } |
|
70 | + $html.= |
|
71 | + '</div> |
|
72 | 72 | </div>'; |
73 | 73 | |
74 | - return $html; |
|
75 | - } |
|
74 | + return $html; |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * Return the HTML code to display a row with all places found in a generation. |
|
80 | - * |
|
81 | - * @param array $data Data array |
|
82 | - * @param int $analysis_level Level of subdivision of analysis |
|
83 | - * @return string HTML code for all places row |
|
84 | - */ |
|
85 | - protected function htmlGenerationAllPlacesRow($data, $analysis_level) { |
|
86 | - $html = |
|
87 | - '<table class="geodispersion_bigrow"> |
|
78 | + /** |
|
79 | + * Return the HTML code to display a row with all places found in a generation. |
|
80 | + * |
|
81 | + * @param array $data Data array |
|
82 | + * @param int $analysis_level Level of subdivision of analysis |
|
83 | + * @return string HTML code for all places row |
|
84 | + */ |
|
85 | + protected function htmlGenerationAllPlacesRow($data, $analysis_level) { |
|
86 | + $html = |
|
87 | + '<table class="geodispersion_bigrow"> |
|
88 | 88 | <tr>'; |
89 | 89 | |
90 | - $sum_gen = $data['sum']; |
|
91 | - $unknownother = $data['unknown'] + $data['other']; |
|
92 | - foreach($data['places'] as $placename=> $dataplace){ |
|
93 | - $levels = array_map('trim',explode(',', $placename)); |
|
94 | - $content = ''; |
|
95 | - if(isset($dataplace['flag'])){ |
|
96 | - $content .= '<td class="geodispersion_flag">'. FunctionsPrint::htmlPlaceIcon($dataplace['place'], $dataplace['flag']) .'</td><td>'; |
|
97 | - } |
|
98 | - else{ |
|
99 | - $content .= '<td><span title="'.implode(I18N::$list_separator, array_reverse($levels)).'">'.$levels[$analysis_level-1].'</span><br/>'; |
|
100 | - } |
|
101 | - $count = $dataplace['count']; |
|
102 | - $content .= I18N::number($count); |
|
103 | - $perc = Functions::safeDivision($count, $sum_gen + $unknownother); |
|
104 | - $perc2= Functions::safeDivision($count, $sum_gen); |
|
105 | - if($perc2>=0.1) |
|
106 | - $content.= '<br/><span class="small">('.I18N::percentage($perc2, 1).')</span>'; |
|
107 | - $content .= '</td>'; |
|
90 | + $sum_gen = $data['sum']; |
|
91 | + $unknownother = $data['unknown'] + $data['other']; |
|
92 | + foreach($data['places'] as $placename=> $dataplace){ |
|
93 | + $levels = array_map('trim',explode(',', $placename)); |
|
94 | + $content = ''; |
|
95 | + if(isset($dataplace['flag'])){ |
|
96 | + $content .= '<td class="geodispersion_flag">'. FunctionsPrint::htmlPlaceIcon($dataplace['place'], $dataplace['flag']) .'</td><td>'; |
|
97 | + } |
|
98 | + else{ |
|
99 | + $content .= '<td><span title="'.implode(I18N::$list_separator, array_reverse($levels)).'">'.$levels[$analysis_level-1].'</span><br/>'; |
|
100 | + } |
|
101 | + $count = $dataplace['count']; |
|
102 | + $content .= I18N::number($count); |
|
103 | + $perc = Functions::safeDivision($count, $sum_gen + $unknownother); |
|
104 | + $perc2= Functions::safeDivision($count, $sum_gen); |
|
105 | + if($perc2>=0.1) |
|
106 | + $content.= '<br/><span class="small">('.I18N::percentage($perc2, 1).')</span>'; |
|
107 | + $content .= '</td>'; |
|
108 | 108 | |
109 | - $html .= ' |
|
109 | + $html .= ' |
|
110 | 110 | <td class="geodispersion_rowitem" width="'.max(round(100*$perc, 0),1).'%"> |
111 | 111 | <table> |
112 | 112 | <tr> |
@@ -118,46 +118,46 @@ discard block |
||
118 | 118 | </tr> |
119 | 119 | </table> |
120 | 120 | </td>'; |
121 | - } |
|
121 | + } |
|
122 | 122 | |
123 | - if($unknownother>0){ |
|
124 | - $perc= Functions::safeDivision($unknownother, $sum_gen + $unknownother); |
|
125 | - $html .='<td class="geodispersion_unknownitem left" >'.I18N::number($unknownother); |
|
126 | - if($perc>=0.1) $html.= '<br/><span class="small">('.I18N::percentage($perc, 1).')</span>'; |
|
127 | - $html .='</td>'; |
|
128 | - } |
|
123 | + if($unknownother>0){ |
|
124 | + $perc= Functions::safeDivision($unknownother, $sum_gen + $unknownother); |
|
125 | + $html .='<td class="geodispersion_unknownitem left" >'.I18N::number($unknownother); |
|
126 | + if($perc>=0.1) $html.= '<br/><span class="small">('.I18N::percentage($perc, 1).')</span>'; |
|
127 | + $html .='</td>'; |
|
128 | + } |
|
129 | 129 | |
130 | - $html .= |
|
131 | - '</tr> |
|
130 | + $html .= |
|
131 | + '</tr> |
|
132 | 132 | </table>'; |
133 | - return $html; |
|
134 | - } |
|
133 | + return $html; |
|
134 | + } |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Returns the HTML code fo display a row of the Top Places found for a generation. |
138 | 138 | * |
139 | 139 | * @param array $data Data array |
140 | - * @param int $analysis_level Level of subdivision of analysis |
|
140 | + * @param int $analysis_level Level of subdivision of analysis |
|
141 | 141 | * @return string HTML code for Top Places row |
142 | 142 | */ |
143 | - protected function htmlGenerationTopPlacesRow($data, $analysis_level) { |
|
144 | - $tmp_places = array(); |
|
145 | - $sum_gen = $data['sum']; |
|
146 | - $other = $data['other']; |
|
143 | + protected function htmlGenerationTopPlacesRow($data, $analysis_level) { |
|
144 | + $tmp_places = array(); |
|
145 | + $sum_gen = $data['sum']; |
|
146 | + $other = $data['other']; |
|
147 | 147 | |
148 | - foreach($data['places'] as $placename => $count) { |
|
149 | - if($placename != 'other'){ |
|
150 | - $levels = array_map('trim',explode(',', $placename)); |
|
151 | - $placename = '<span title="'.implode(I18N::$list_separator, array_reverse($levels)).'">'.$levels[$analysis_level-1].'</span>'; |
|
152 | - } |
|
153 | - else{ |
|
154 | - $placename = I18N::translate('Other places'); |
|
155 | - } |
|
156 | - $tmp_places[] = I18N::translate('<strong>%s</strong> [%d - %s]', $placename, $count, I18N::percentage(Functions::safeDivision($count, $sum_gen + $other), 1)); |
|
157 | - } |
|
148 | + foreach($data['places'] as $placename => $count) { |
|
149 | + if($placename != 'other'){ |
|
150 | + $levels = array_map('trim',explode(',', $placename)); |
|
151 | + $placename = '<span title="'.implode(I18N::$list_separator, array_reverse($levels)).'">'.$levels[$analysis_level-1].'</span>'; |
|
152 | + } |
|
153 | + else{ |
|
154 | + $placename = I18N::translate('Other places'); |
|
155 | + } |
|
156 | + $tmp_places[] = I18N::translate('<strong>%s</strong> [%d - %s]', $placename, $count, I18N::percentage(Functions::safeDivision($count, $sum_gen + $other), 1)); |
|
157 | + } |
|
158 | 158 | |
159 | - return implode(I18N::$list_separator, $tmp_places); |
|
160 | - } |
|
159 | + return implode(I18N::$list_separator, $tmp_places); |
|
160 | + } |
|
161 | 161 | |
162 | 162 | } |
163 | 163 | |
164 | 164 | \ No newline at end of file |