@@ -32,49 +32,49 @@ discard block |
||
32 | 32 | class MiscExtensionsModule extends AbstractModule |
33 | 33 | implements HookSubscriberInterface, IndividualHeaderExtenderInterface, PageHeaderExtenderInterface, PageFooterExtenderInterface, ModuleConfigInterface |
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 | - * {@inheritDoc} |
|
40 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::getTitle() |
|
41 | - */ |
|
42 | - public function getTitle() { |
|
43 | - return I18N::translate('Miscellaneous extensions'); |
|
44 | - } |
|
38 | + /** |
|
39 | + * {@inheritDoc} |
|
40 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::getTitle() |
|
41 | + */ |
|
42 | + public function getTitle() { |
|
43 | + return I18N::translate('Miscellaneous extensions'); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * {@inheritDoc} |
48 | 48 | * @see \Fisharebest\Webtrees\Module\AbstractModule::getDescription() |
49 | 49 | */ |
50 | - public function getDescription() { |
|
51 | - return I18N::translate('Miscellaneous extensions for <strong>webtrees</strong>.'); |
|
52 | - } |
|
50 | + public function getDescription() { |
|
51 | + return I18N::translate('Miscellaneous extensions for <strong>webtrees</strong>.'); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * {@inhericDoc} |
|
56 | - */ |
|
57 | - public function modAction($mod_action) { |
|
58 | - \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
59 | - } |
|
54 | + /** |
|
55 | + * {@inhericDoc} |
|
56 | + */ |
|
57 | + public function modAction($mod_action) { |
|
58 | + \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * {@inhericDoc} |
|
63 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
64 | - */ |
|
65 | - public function getConfigLink() { |
|
66 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
67 | - } |
|
61 | + /** |
|
62 | + * {@inhericDoc} |
|
63 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
64 | + */ |
|
65 | + public function getConfigLink() { |
|
66 | + return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * {@inheritDoc} |
|
71 | - * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
72 | - */ |
|
69 | + /** |
|
70 | + * {@inheritDoc} |
|
71 | + * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
72 | + */ |
|
73 | 73 | public function getSubscribedHooks() { |
74 | 74 | return array( |
75 | - 'hExtendIndiHeaderLeft' => 20, |
|
76 | - 'hPrintHeader' => 20, |
|
77 | - 'hPrintFooter' => 20 |
|
75 | + 'hExtendIndiHeaderLeft' => 20, |
|
76 | + 'hPrintHeader' => 20, |
|
77 | + 'hPrintFooter' => 20 |
|
78 | 78 | ); |
79 | 79 | } |
80 | 80 | |
@@ -89,22 +89,22 @@ discard block |
||
89 | 89 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\IndividualHeaderExtenderInterface::hExtendIndiHeaderLeft() |
90 | 90 | */ |
91 | 91 | public function hExtendIndiHeaderLeft(IndividualController $ctrlIndi) { |
92 | - $res = ''; |
|
93 | - $dindi = new Individual($ctrlIndi->getSignificantIndividual()); |
|
94 | - $titles = $dindi->getTitles(); |
|
95 | - if(count($titles)>0){ |
|
96 | - $res = ' |
|
92 | + $res = ''; |
|
93 | + $dindi = new Individual($ctrlIndi->getSignificantIndividual()); |
|
94 | + $titles = $dindi->getTitles(); |
|
95 | + if(count($titles)>0){ |
|
96 | + $res = ' |
|
97 | 97 | <dl> |
98 | 98 | <dt class="label">'.I18N::translate('Titles').'</dt>'; |
99 | - foreach($titles as $title=>$props){ |
|
100 | - $res .= |
|
101 | - '<dd class="field">' . $title. ' ' . |
|
102 | - FunctionsPrint::getListFromArray($props) . |
|
103 | - '</dd>'; |
|
104 | - } |
|
105 | - $res .= '</dl>'; |
|
106 | - } |
|
107 | - return array( 'indi-header-titles' , $res); |
|
99 | + foreach($titles as $title=>$props){ |
|
100 | + $res .= |
|
101 | + '<dd class="field">' . $title. ' ' . |
|
102 | + FunctionsPrint::getListFromArray($props) . |
|
103 | + '</dd>'; |
|
104 | + } |
|
105 | + $res .= '</dl>'; |
|
106 | + } |
|
107 | + return array( 'indi-header-titles' , $res); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\PageHeaderExtenderInterface::hPrintHeader() |
119 | 119 | */ |
120 | 120 | public function hPrintHeader() { |
121 | - $html = ''; |
|
122 | - if($this->getSetting('MAJ_ADD_HTML_HEADER', 0) == 1){ |
|
123 | - if(Auth::accessLevel(Globals::getTree()) >= $this->getSetting('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE) && !Filter::getBool('noheader')){ |
|
124 | - $html .= $this->getSetting('MAJ_HTML_HEADER', ''); |
|
125 | - } |
|
126 | - } |
|
127 | - return $html; |
|
121 | + $html = ''; |
|
122 | + if($this->getSetting('MAJ_ADD_HTML_HEADER', 0) == 1){ |
|
123 | + if(Auth::accessLevel(Globals::getTree()) >= $this->getSetting('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE) && !Filter::getBool('noheader')){ |
|
124 | + $html .= $this->getSetting('MAJ_HTML_HEADER', ''); |
|
125 | + } |
|
126 | + } |
|
127 | + return $html; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -132,26 +132,26 @@ discard block |
||
132 | 132 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\PageFooterExtenderInterface::hPrintFooter() |
133 | 133 | */ |
134 | 134 | public function hPrintFooter() { |
135 | - $wt_tree = Globals::getTree(); |
|
136 | - $html = ''; |
|
137 | - if($this->getSetting('MAJ_DISPLAY_CNIL', 0) == 1){ |
|
138 | - $html .= '<br/>'; |
|
139 | - $html .= '<div class="center">'; |
|
140 | - $cnil_ref = $this->getSetting('MAJ_CNIL_REFERENCE', ''); |
|
141 | - if($cnil_ref != ''){ |
|
142 | - $html .= I18N::translate('This site has been notified to the French National Commission for Data protection (CNIL) and registered under number %s. ', $cnil_ref); |
|
143 | - } |
|
144 | - $html .= I18N::translate('In accordance with the French Data protection Act (<em>Loi Informatique et Libertés</em>) of January 6th, 1978, you have the right to access, modify, rectify and delete personal information that pertains to you. To exercice this right, please contact %s, and provide your name, address and a proof of your identity.', |
|
145 | - Theme::theme()->contactLink(User::find($wt_tree->getPreference('WEBMASTER_USER_ID')))); |
|
146 | - $html .= '</div>'; |
|
147 | - } |
|
135 | + $wt_tree = Globals::getTree(); |
|
136 | + $html = ''; |
|
137 | + if($this->getSetting('MAJ_DISPLAY_CNIL', 0) == 1){ |
|
138 | + $html .= '<br/>'; |
|
139 | + $html .= '<div class="center">'; |
|
140 | + $cnil_ref = $this->getSetting('MAJ_CNIL_REFERENCE', ''); |
|
141 | + if($cnil_ref != ''){ |
|
142 | + $html .= I18N::translate('This site has been notified to the French National Commission for Data protection (CNIL) and registered under number %s. ', $cnil_ref); |
|
143 | + } |
|
144 | + $html .= I18N::translate('In accordance with the French Data protection Act (<em>Loi Informatique et Libertés</em>) of January 6th, 1978, you have the right to access, modify, rectify and delete personal information that pertains to you. To exercice this right, please contact %s, and provide your name, address and a proof of your identity.', |
|
145 | + Theme::theme()->contactLink(User::find($wt_tree->getPreference('WEBMASTER_USER_ID')))); |
|
146 | + $html .= '</div>'; |
|
147 | + } |
|
148 | 148 | |
149 | - if($this->getSetting('MAJ_ADD_HTML_FOOTER', 0) == 1){ |
|
150 | - if(Auth::accessLevel($wt_tree) >= $this->getSetting('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE) && !Filter::getBool('nofooter')){ |
|
151 | - $html .= $this->getSetting('MAJ_HTML_FOOTER', ''); |
|
152 | - } |
|
153 | - } |
|
154 | - return $html; |
|
149 | + if($this->getSetting('MAJ_ADD_HTML_FOOTER', 0) == 1){ |
|
150 | + if(Auth::accessLevel($wt_tree) >= $this->getSetting('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE) && !Filter::getBool('nofooter')){ |
|
151 | + $html .= $this->getSetting('MAJ_HTML_FOOTER', ''); |
|
152 | + } |
|
153 | + } |
|
154 | + return $html; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
64 | 64 | */ |
65 | 65 | public function getConfigLink() { |
66 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
66 | + return 'module.php?mod='.$this->getName().'&mod_action=AdminConfig'; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -92,19 +92,19 @@ discard block |
||
92 | 92 | $res = ''; |
93 | 93 | $dindi = new Individual($ctrlIndi->getSignificantIndividual()); |
94 | 94 | $titles = $dindi->getTitles(); |
95 | - if(count($titles)>0){ |
|
95 | + if (count($titles) > 0) { |
|
96 | 96 | $res = ' |
97 | 97 | <dl> |
98 | 98 | <dt class="label">'.I18N::translate('Titles').'</dt>'; |
99 | - foreach($titles as $title=>$props){ |
|
99 | + foreach ($titles as $title=>$props) { |
|
100 | 100 | $res .= |
101 | - '<dd class="field">' . $title. ' ' . |
|
102 | - FunctionsPrint::getListFromArray($props) . |
|
101 | + '<dd class="field">'.$title.' '. |
|
102 | + FunctionsPrint::getListFromArray($props). |
|
103 | 103 | '</dd>'; |
104 | 104 | } |
105 | - $res .= '</dl>'; |
|
105 | + $res .= '</dl>'; |
|
106 | 106 | } |
107 | - return array( 'indi-header-titles' , $res); |
|
107 | + return array('indi-header-titles', $res); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function hPrintHeader() { |
121 | 121 | $html = ''; |
122 | - if($this->getSetting('MAJ_ADD_HTML_HEADER', 0) == 1){ |
|
123 | - if(Auth::accessLevel(Globals::getTree()) >= $this->getSetting('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE) && !Filter::getBool('noheader')){ |
|
122 | + if ($this->getSetting('MAJ_ADD_HTML_HEADER', 0) == 1) { |
|
123 | + if (Auth::accessLevel(Globals::getTree()) >= $this->getSetting('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE) && !Filter::getBool('noheader')) { |
|
124 | 124 | $html .= $this->getSetting('MAJ_HTML_HEADER', ''); |
125 | 125 | } |
126 | 126 | } |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | public function hPrintFooter() { |
135 | 135 | $wt_tree = Globals::getTree(); |
136 | 136 | $html = ''; |
137 | - if($this->getSetting('MAJ_DISPLAY_CNIL', 0) == 1){ |
|
137 | + if ($this->getSetting('MAJ_DISPLAY_CNIL', 0) == 1) { |
|
138 | 138 | $html .= '<br/>'; |
139 | 139 | $html .= '<div class="center">'; |
140 | 140 | $cnil_ref = $this->getSetting('MAJ_CNIL_REFERENCE', ''); |
141 | - if($cnil_ref != ''){ |
|
141 | + if ($cnil_ref != '') { |
|
142 | 142 | $html .= I18N::translate('This site has been notified to the French National Commission for Data protection (CNIL) and registered under number %s. ', $cnil_ref); |
143 | 143 | } |
144 | 144 | $html .= I18N::translate('In accordance with the French Data protection Act (<em>Loi Informatique et Libertés</em>) of January 6th, 1978, you have the right to access, modify, rectify and delete personal information that pertains to you. To exercice this right, please contact %s, and provide your name, address and a proof of your identity.', |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | $html .= '</div>'; |
147 | 147 | } |
148 | 148 | |
149 | - if($this->getSetting('MAJ_ADD_HTML_FOOTER', 0) == 1){ |
|
150 | - if(Auth::accessLevel($wt_tree) >= $this->getSetting('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE) && !Filter::getBool('nofooter')){ |
|
149 | + if ($this->getSetting('MAJ_ADD_HTML_FOOTER', 0) == 1) { |
|
150 | + if (Auth::accessLevel($wt_tree) >= $this->getSetting('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE) && !Filter::getBool('nofooter')) { |
|
151 | 151 | $html .= $this->getSetting('MAJ_HTML_FOOTER', ''); |
152 | 152 | } |
153 | 153 | } |
@@ -16,48 +16,48 @@ |
||
16 | 16 | */ |
17 | 17 | class Globals { |
18 | 18 | |
19 | - /** |
|
20 | - * Get global $WT_TREE variable. |
|
21 | - * |
|
22 | - * @return \Fisharebest\Webtrees\Tree |
|
23 | - */ |
|
24 | - public static function getTree() { |
|
25 | - global $WT_TREE; |
|
19 | + /** |
|
20 | + * Get global $WT_TREE variable. |
|
21 | + * |
|
22 | + * @return \Fisharebest\Webtrees\Tree |
|
23 | + */ |
|
24 | + public static function getTree() { |
|
25 | + global $WT_TREE; |
|
26 | 26 | |
27 | - return $WT_TREE; |
|
28 | - } |
|
27 | + return $WT_TREE; |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Check whether the visitor is a bot. |
|
32 | - * |
|
33 | - * @return boolean |
|
34 | - */ |
|
35 | - public static function isSearchSpider() { |
|
36 | - global $SEARCH_SPIDER; |
|
30 | + /** |
|
31 | + * Check whether the visitor is a bot. |
|
32 | + * |
|
33 | + * @return boolean |
|
34 | + */ |
|
35 | + public static function isSearchSpider() { |
|
36 | + global $SEARCH_SPIDER; |
|
37 | 37 | |
38 | - return $SEARCH_SPIDER; |
|
39 | - } |
|
38 | + return $SEARCH_SPIDER; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Get the current controller. |
|
43 | - * |
|
44 | - * @return \Fisharebest\Webtrees\BaseController |
|
45 | - */ |
|
46 | - public static function getController() { |
|
47 | - global $controller; |
|
41 | + /** |
|
42 | + * Get the current controller. |
|
43 | + * |
|
44 | + * @return \Fisharebest\Webtrees\BaseController |
|
45 | + */ |
|
46 | + public static function getController() { |
|
47 | + global $controller; |
|
48 | 48 | |
49 | - return $controller; |
|
50 | - } |
|
49 | + return $controller; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Get the global facts |
|
54 | - * |
|
55 | - * @return array |
|
56 | - */ |
|
57 | - public static function getGlobalFacts() { |
|
58 | - global $global_facts; |
|
52 | + /** |
|
53 | + * Get the global facts |
|
54 | + * |
|
55 | + * @return array |
|
56 | + */ |
|
57 | + public static function getGlobalFacts() { |
|
58 | + global $global_facts; |
|
59 | 59 | |
60 | - return $global_facts; |
|
61 | - } |
|
60 | + return $global_facts; |
|
61 | + } |
|
62 | 62 | |
63 | 63 | } |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | * @return string Encryption key |
130 | 130 | */ |
131 | 131 | protected static function getBase64EncryptionKey() { |
132 | - $key = 'STANDARDKEYIFNOSERVER'; |
|
133 | - if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
134 | - $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
|
132 | + $key = 'STANDARDKEYIFNOSERVER'; |
|
133 | + if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
134 | + $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
|
135 | 135 | |
136 | - return $key; |
|
136 | + return $key; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -172,20 +172,20 @@ discard block |
||
172 | 172 | throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
173 | 173 | |
174 | 174 | if (mb_strlen($encrypted, '8bit') < (SODIUM_CRYPTO_SECRETBOX_NONCEBYTES + SODIUM_CRYPTO_SECRETBOX_MACBYTES)) |
175 | - throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
|
175 | + throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
|
176 | 176 | |
177 | - $nonce = mb_substr($encrypted, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit'); |
|
178 | - $ciphertext = mb_substr($encrypted, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit'); |
|
177 | + $nonce = mb_substr($encrypted, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit'); |
|
178 | + $ciphertext = mb_substr($encrypted, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit'); |
|
179 | 179 | |
180 | - $decrypted = sodium_crypto_secretbox_open($ciphertext, $nonce, self::getBase64EncryptionKey()); |
|
180 | + $decrypted = sodium_crypto_secretbox_open($ciphertext, $nonce, self::getBase64EncryptionKey()); |
|
181 | 181 | |
182 | - if($decrypted === false) { |
|
183 | - throw new \InvalidArgumentException('The message has been tampered with in transit.'); |
|
184 | - } |
|
182 | + if($decrypted === false) { |
|
183 | + throw new \InvalidArgumentException('The message has been tampered with in transit.'); |
|
184 | + } |
|
185 | 185 | |
186 | - //sodium_memzero($encrypted); // Requires PHP 7.2 |
|
186 | + //sodium_memzero($encrypted); // Requires PHP 7.2 |
|
187 | 187 | |
188 | - return $decrypted; |
|
188 | + return $decrypted; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public static function encodeFileSystemToUtf8($string){ |
198 | 198 | if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
199 | - return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
199 | + return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
200 | 200 | } |
201 | 201 | return $string; |
202 | 202 | } |
@@ -261,20 +261,20 @@ discard block |
||
261 | 261 | * @return boolean|string Is supported? |
262 | 262 | */ |
263 | 263 | public static function isImageTypeSupported($reqtype) { |
264 | - $supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png'); |
|
265 | - $reqtype = strtolower($reqtype); |
|
264 | + $supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png'); |
|
265 | + $reqtype = strtolower($reqtype); |
|
266 | 266 | |
267 | - if (empty($supportByGD[$reqtype])) { |
|
268 | - return false; |
|
269 | - } |
|
267 | + if (empty($supportByGD[$reqtype])) { |
|
268 | + return false; |
|
269 | + } |
|
270 | 270 | |
271 | - $type = $supportByGD[$reqtype]; |
|
271 | + $type = $supportByGD[$reqtype]; |
|
272 | 272 | |
273 | - if (function_exists('imagecreatefrom'.$type) && function_exists('image'.$type)) { |
|
274 | - return $type; |
|
275 | - } |
|
273 | + if (function_exists('imagecreatefrom'.$type) && function_exists('image'.$type)) { |
|
274 | + return $type; |
|
275 | + } |
|
276 | 276 | |
277 | - return false; |
|
277 | + return false; |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | } |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @param string $text Text to display |
34 | 34 | */ |
35 | - static public function promptAlert($text){ |
|
35 | + static public function promptAlert($text) { |
|
36 | 36 | echo '<script>'; |
37 | - echo 'alert("',fw\Filter::escapeHtml($text),'")'; |
|
37 | + echo 'alert("', fw\Filter::escapeHtml($text), '")'; |
|
38 | 38 | echo '</script>'; |
39 | 39 | } |
40 | 40 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @return float Result of the safe division |
48 | 48 | */ |
49 | 49 | public static function safeDivision($num, $denom, $default = 0) { |
50 | - if($denom && $denom!=0){ |
|
50 | + if ($denom && $denom != 0) { |
|
51 | 51 | return $num / $denom; |
52 | 52 | } |
53 | 53 | return $default; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param float $default Default value if denominator null or 0 |
62 | 62 | * @return float Percentage |
63 | 63 | */ |
64 | - public static function getPercentage($num, $denom, $default = 0){ |
|
64 | + public static function getPercentage($num, $denom, $default = 0) { |
|
65 | 65 | return 100 * self::safeDivision($num, $denom, $default); |
66 | 66 | } |
67 | 67 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * @param int $target The final max width/height |
73 | 73 | * @return array array of ($width, $height). One of them must be $target |
74 | 74 | */ |
75 | - static public function getResizedImageSize($file, $target=25){ |
|
76 | - list($width, $height, , ) = getimagesize($file); |
|
75 | + static public function getResizedImageSize($file, $target = 25) { |
|
76 | + list($width, $height,,) = getimagesize($file); |
|
77 | 77 | $max = max($width, $height); |
78 | 78 | $rapp = $target / $max; |
79 | 79 | $width = intval($rapp * $width); |
@@ -103,21 +103,21 @@ discard block |
||
103 | 103 | * @param int $length Length of the token, default to 32 |
104 | 104 | * @return string Random token |
105 | 105 | */ |
106 | - public static function generateRandomToken($length=32) { |
|
106 | + public static function generateRandomToken($length = 32) { |
|
107 | 107 | $chars = str_split('abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'); |
108 | 108 | $len_chars = count($chars); |
109 | 109 | $token = ''; |
110 | 110 | |
111 | 111 | for ($i = 0; $i < $length; $i++) |
112 | - $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
112 | + $token .= $chars[mt_rand(0, $len_chars - 1)]; |
|
113 | 113 | |
114 | 114 | # Number of 32 char chunks |
115 | - $chunks = ceil( strlen($token) / 32 ); |
|
115 | + $chunks = ceil(strlen($token) / 32); |
|
116 | 116 | $md5token = ''; |
117 | 117 | |
118 | 118 | # Run each chunk through md5 |
119 | - for ( $i=1; $i<=$chunks; $i++ ) |
|
120 | - $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
119 | + for ($i = 1; $i <= $chunks; $i++) |
|
120 | + $md5token .= md5(substr($token, $i * 32 - 32, 32)); |
|
121 | 121 | |
122 | 122 | # Trim the token |
123 | 123 | return substr($md5token, 0, $length); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | protected static function getBase64EncryptionKey() { |
132 | 132 | $key = 'STANDARDKEYIFNOSERVER'; |
133 | - if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
133 | + if (!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
134 | 134 | $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
135 | 135 | |
136 | 136 | return $key; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param string $data Text to encrypt |
144 | 144 | * @return string Encrypted and encoded text |
145 | 145 | */ |
146 | - public static function encryptToSafeBase64($data){ |
|
146 | + public static function encryptToSafeBase64($data) { |
|
147 | 147 | $nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES); |
148 | 148 | $id = sodium_crypto_secretbox($data, $nonce, self::getBase64EncryptionKey()); |
149 | 149 | $encrypted = base64_encode($nonce.$id); |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | * @param string $encrypted Text to decrypt |
164 | 164 | * @return string Decrypted text |
165 | 165 | */ |
166 | - public static function decryptFromSafeBase64($encrypted){ |
|
166 | + public static function decryptFromSafeBase64($encrypted) { |
|
167 | 167 | $encrypted = str_replace('-', '+', $encrypted); |
168 | 168 | $encrypted = str_replace('_', '/', $encrypted); |
169 | 169 | $encrypted = str_replace('*', '=', $encrypted); |
170 | 170 | $encrypted = base64_decode($encrypted); |
171 | - if($encrypted === false) |
|
171 | + if ($encrypted === false) |
|
172 | 172 | throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
173 | 173 | |
174 | 174 | if (mb_strlen($encrypted, '8bit') < (SODIUM_CRYPTO_SECRETBOX_NONCEBYTES + SODIUM_CRYPTO_SECRETBOX_MACBYTES)) |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | |
180 | 180 | $decrypted = sodium_crypto_secretbox_open($ciphertext, $nonce, self::getBase64EncryptionKey()); |
181 | 181 | |
182 | - if($decrypted === false) { |
|
182 | + if ($decrypted === false) { |
|
183 | 183 | throw new \InvalidArgumentException('The message has been tampered with in transit.'); |
184 | 184 | } |
185 | 185 | |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | * @param string $string Filesystem encoded string to encode |
195 | 195 | * @return string UTF-8 encoded string |
196 | 196 | */ |
197 | - public static function encodeFileSystemToUtf8($string){ |
|
197 | + public static function encodeFileSystemToUtf8($string) { |
|
198 | 198 | if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
199 | - return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
199 | + return iconv('cp1252', 'utf-8//IGNORE', $string); |
|
200 | 200 | } |
201 | 201 | return $string; |
202 | 202 | } |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | * @param string $string UTF-8 encoded string to encode |
208 | 208 | * @return string Filesystem encoded string |
209 | 209 | */ |
210 | - public static function encodeUtf8ToFileSystem($string){ |
|
210 | + public static function encodeUtf8ToFileSystem($string) { |
|
211 | 211 | if (preg_match('//u', $string) && strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
212 | - return iconv('utf-8', 'cp1252//IGNORE' , $string); |
|
212 | + return iconv('utf-8', 'cp1252//IGNORE', $string); |
|
213 | 213 | } |
214 | 214 | return $string; |
215 | 215 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @return boolean True if path valid |
223 | 223 | */ |
224 | 224 | public static function isValidPath($filename, $acceptfolder = FALSE) { |
225 | - if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
225 | + if (strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
226 | 226 | return false; |
227 | 227 | } |
228 | 228 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * @return array Array of month short names |
235 | 235 | */ |
236 | 236 | public static function getCalendarShortMonths($calendarId = 0) { |
237 | - if(!isset(self::$calendarShortMonths[$calendarId])) { |
|
237 | + if (!isset(self::$calendarShortMonths[$calendarId])) { |
|
238 | 238 | $calendar_info = cal_info($calendarId); |
239 | 239 | self::$calendarShortMonths[$calendarId] = $calendar_info['abbrevmonths']; |
240 | 240 | } |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | * @param int $sosa Sosa number |
248 | 248 | * @return number |
249 | 249 | */ |
250 | - public static function getGeneration($sosa){ |
|
251 | - return(int)log($sosa, 2)+1; |
|
250 | + public static function getGeneration($sosa) { |
|
251 | + return(int)log($sosa, 2) + 1; |
|
252 | 252 | } |
253 | 253 | |
254 | 254 |
@@ -108,16 +108,18 @@ discard block |
||
108 | 108 | $len_chars = count($chars); |
109 | 109 | $token = ''; |
110 | 110 | |
111 | - for ($i = 0; $i < $length; $i++) |
|
112 | - $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
111 | + for ($i = 0; $i < $length; $i++) { |
|
112 | + $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
113 | + } |
|
113 | 114 | |
114 | 115 | # Number of 32 char chunks |
115 | 116 | $chunks = ceil( strlen($token) / 32 ); |
116 | 117 | $md5token = ''; |
117 | 118 | |
118 | 119 | # Run each chunk through md5 |
119 | - for ( $i=1; $i<=$chunks; $i++ ) |
|
120 | - $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
120 | + for ( $i=1; $i<=$chunks; $i++ ) { |
|
121 | + $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
122 | + } |
|
121 | 123 | |
122 | 124 | # Trim the token |
123 | 125 | return substr($md5token, 0, $length); |
@@ -130,8 +132,9 @@ discard block |
||
130 | 132 | */ |
131 | 133 | protected static function getBase64EncryptionKey() { |
132 | 134 | $key = 'STANDARDKEYIFNOSERVER'; |
133 | - if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
134 | - $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
|
135 | + if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) { |
|
136 | + $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
|
137 | + } |
|
135 | 138 | |
136 | 139 | return $key; |
137 | 140 | } |
@@ -168,11 +171,13 @@ discard block |
||
168 | 171 | $encrypted = str_replace('_', '/', $encrypted); |
169 | 172 | $encrypted = str_replace('*', '=', $encrypted); |
170 | 173 | $encrypted = base64_decode($encrypted); |
171 | - if($encrypted === false) |
|
172 | - throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
|
174 | + if($encrypted === false) { |
|
175 | + throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
|
176 | + } |
|
173 | 177 | |
174 | - if (mb_strlen($encrypted, '8bit') < (SODIUM_CRYPTO_SECRETBOX_NONCEBYTES + SODIUM_CRYPTO_SECRETBOX_MACBYTES)) |
|
175 | - throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
|
178 | + if (mb_strlen($encrypted, '8bit') < (SODIUM_CRYPTO_SECRETBOX_NONCEBYTES + SODIUM_CRYPTO_SECRETBOX_MACBYTES)) { |
|
179 | + throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
|
180 | + } |
|
176 | 181 | |
177 | 182 | $nonce = mb_substr($encrypted, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit'); |
178 | 183 | $ciphertext = mb_substr($encrypted, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit'); |
@@ -222,7 +227,9 @@ discard block |
||
222 | 227 | * @return boolean True if path valid |
223 | 228 | */ |
224 | 229 | public static function isValidPath($filename, $acceptfolder = FALSE) { |
225 | - if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
230 | + if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) { |
|
231 | + return true; |
|
232 | + } |
|
226 | 233 | return false; |
227 | 234 | } |
228 | 235 |
@@ -22,187 +22,187 @@ |
||
22 | 22 | * Name of the file containing the description of the map. |
23 | 23 | * @var string $filename |
24 | 24 | */ |
25 | - protected $filename; |
|
25 | + protected $filename; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Indicates whether the description has been loaded from the file. |
29 | 29 | * @var bool $is_loaded |
30 | 30 | */ |
31 | - protected $is_loaded; |
|
31 | + protected $is_loaded; |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Description/title of the map. |
35 | 35 | * @var string $description |
36 | 36 | */ |
37 | - protected $description; |
|
37 | + protected $description; |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Name(s) of the parent level(s) of the map. |
41 | 41 | * @var string $is_loaded |
42 | 42 | */ |
43 | - protected $top_level_name; |
|
44 | - |
|
45 | - /** |
|
46 | - * Map canvas |
|
47 | - * @var OutlineMapCanvas $canvas |
|
48 | - */ |
|
49 | - protected $canvas; |
|
50 | - |
|
51 | - /** |
|
52 | - * Map subdivisions |
|
53 | - * @var array $subdivisions |
|
54 | - */ |
|
55 | - protected $subdivisions; |
|
56 | - |
|
57 | - /** |
|
58 | - * Places mappings |
|
59 | - * @var array $subdivisions |
|
60 | - */ |
|
61 | - protected $mappings; |
|
62 | - |
|
63 | - /** |
|
64 | - * Constructor for GeoAnalysisMap. |
|
65 | - * |
|
66 | - * @param string $filename Outline map file name |
|
67 | - * @param bool $load Should the map be loaded immediately |
|
68 | - */ |
|
69 | - public function __construct($filename, $load = false) { |
|
70 | - $this->filename = $filename; |
|
71 | - $this->is_loaded = false; |
|
72 | - $this->subdivisions = array(); |
|
73 | - $this->mappings = array(); |
|
74 | - if($load) $this->load(); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Load the map settings contained within its XML representation |
|
79 | - * |
|
80 | - * XML structure : |
|
81 | - * - displayName : Display name of the map |
|
82 | - * - topLevel : Values of the top level subdivisions (separated by commas, if multiple) |
|
83 | - * - canvas : all settings related to the map canvas. |
|
84 | - * - width : canvas width, in px |
|
85 | - * - height : canvas height, in px |
|
86 | - * - maxcolor : color to identify places with ancestors, RGB hexadecimal |
|
87 | - * - hovercolor : same as previous, color when mouse is hovering the place, RGB hexadecimal |
|
88 | - * - bgcolor : map background color, RGB hexadecimal |
|
89 | - * - bgstroke : map stroke color, RGB hexadecimal |
|
90 | - * - defaultcolor : default color of places, RGB hexadecimal |
|
91 | - * - defaultstroke : default stroke color, RGB hexadecimal |
|
92 | - * - subdvisions : for each subdivision : |
|
43 | + protected $top_level_name; |
|
44 | + |
|
45 | + /** |
|
46 | + * Map canvas |
|
47 | + * @var OutlineMapCanvas $canvas |
|
48 | + */ |
|
49 | + protected $canvas; |
|
50 | + |
|
51 | + /** |
|
52 | + * Map subdivisions |
|
53 | + * @var array $subdivisions |
|
54 | + */ |
|
55 | + protected $subdivisions; |
|
56 | + |
|
57 | + /** |
|
58 | + * Places mappings |
|
59 | + * @var array $subdivisions |
|
60 | + */ |
|
61 | + protected $mappings; |
|
62 | + |
|
63 | + /** |
|
64 | + * Constructor for GeoAnalysisMap. |
|
65 | + * |
|
66 | + * @param string $filename Outline map file name |
|
67 | + * @param bool $load Should the map be loaded immediately |
|
68 | + */ |
|
69 | + public function __construct($filename, $load = false) { |
|
70 | + $this->filename = $filename; |
|
71 | + $this->is_loaded = false; |
|
72 | + $this->subdivisions = array(); |
|
73 | + $this->mappings = array(); |
|
74 | + if($load) $this->load(); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Load the map settings contained within its XML representation |
|
79 | + * |
|
80 | + * XML structure : |
|
81 | + * - displayName : Display name of the map |
|
82 | + * - topLevel : Values of the top level subdivisions (separated by commas, if multiple) |
|
83 | + * - canvas : all settings related to the map canvas. |
|
84 | + * - width : canvas width, in px |
|
85 | + * - height : canvas height, in px |
|
86 | + * - maxcolor : color to identify places with ancestors, RGB hexadecimal |
|
87 | + * - hovercolor : same as previous, color when mouse is hovering the place, RGB hexadecimal |
|
88 | + * - bgcolor : map background color, RGB hexadecimal |
|
89 | + * - bgstroke : map stroke color, RGB hexadecimal |
|
90 | + * - defaultcolor : default color of places, RGB hexadecimal |
|
91 | + * - defaultstroke : default stroke color, RGB hexadecimal |
|
92 | + * - subdvisions : for each subdivision : |
|
93 | 93 | * - id : Subdivision id, must be compatible with PHP variable constraints, and unique |
94 | - * - name: Display name for the place |
|
94 | + * - name: Display name for the place |
|
95 | 95 | * - parent: if any, describe to which parent level the place if belonging to |
96 | - * - <em>Element value<em> : SVG description of the subdvision shape |
|
96 | + * - <em>Element value<em> : SVG description of the subdvision shape |
|
97 | 97 | * - mapping : for each subdivision : |
98 | 98 | * - name : Name of the place to map |
99 | - * - mapto: Name of the place to map to |
|
99 | + * - mapto: Name of the place to map to |
|
100 | 100 | * |
101 | - */ |
|
102 | - protected function load() { |
|
103 | - if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){ |
|
104 | - $xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename); |
|
105 | - if($xml){ |
|
106 | - $this->description = trim($xml->displayName); |
|
107 | - $this->top_level_name = trim($xml->topLevel); |
|
108 | - $this->canvas = new OutlineMapCanvas( |
|
109 | - trim($xml->canvas->width), |
|
110 | - trim($xml->canvas->height), |
|
111 | - trim($xml->canvas->maxcolor), |
|
112 | - trim($xml->canvas->hovercolor), |
|
113 | - trim($xml->canvas->bgcolor), |
|
114 | - trim($xml->canvas->bgstroke), |
|
115 | - trim($xml->canvas->defaultcolor), |
|
116 | - trim($xml->canvas->defaultstroke) |
|
117 | - ); |
|
118 | - foreach($xml->subdivisions->children() as $subdivision){ |
|
119 | - $attributes = $subdivision->attributes(); |
|
120 | - $key = I18N::strtolower(trim($attributes['name'])); |
|
121 | - if(isset($attributes['parent'])) $key .= '@'. I18N::strtolower(trim($attributes['parent'])); |
|
122 | - $this->subdivisions[$key] = array( |
|
123 | - 'id' => trim($attributes['id']), |
|
124 | - 'displayname' => trim($attributes['name']), |
|
125 | - 'coord' => trim($subdivision[0]) |
|
126 | - ); |
|
127 | - } |
|
128 | - if(isset($xml->mappings)) { |
|
129 | - foreach($xml->mappings->children() as $mappings){ |
|
130 | - $attributes = $mappings->attributes(); |
|
131 | - $this->mappings[I18N::strtolower(trim($attributes['name']))] = I18N::strtolower(trim($attributes['mapto'])); |
|
132 | - } |
|
133 | - } |
|
134 | - $this->is_loaded = true; |
|
135 | - return; |
|
136 | - } |
|
137 | - } |
|
138 | - throw new \Exception('The Outline Map could not be loaded from XML.'); |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * Get the status of the map loading from the XML file. |
|
143 | - * |
|
144 | - * @return bool |
|
145 | - */ |
|
146 | - public function isLoaded() { |
|
147 | - try{ |
|
148 | - if(!$this->is_loaded) $this->load(); |
|
149 | - } |
|
150 | - catch (\Exception $ex) { } |
|
151 | - return $this->is_loaded; |
|
152 | - } |
|
101 | + */ |
|
102 | + protected function load() { |
|
103 | + if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){ |
|
104 | + $xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename); |
|
105 | + if($xml){ |
|
106 | + $this->description = trim($xml->displayName); |
|
107 | + $this->top_level_name = trim($xml->topLevel); |
|
108 | + $this->canvas = new OutlineMapCanvas( |
|
109 | + trim($xml->canvas->width), |
|
110 | + trim($xml->canvas->height), |
|
111 | + trim($xml->canvas->maxcolor), |
|
112 | + trim($xml->canvas->hovercolor), |
|
113 | + trim($xml->canvas->bgcolor), |
|
114 | + trim($xml->canvas->bgstroke), |
|
115 | + trim($xml->canvas->defaultcolor), |
|
116 | + trim($xml->canvas->defaultstroke) |
|
117 | + ); |
|
118 | + foreach($xml->subdivisions->children() as $subdivision){ |
|
119 | + $attributes = $subdivision->attributes(); |
|
120 | + $key = I18N::strtolower(trim($attributes['name'])); |
|
121 | + if(isset($attributes['parent'])) $key .= '@'. I18N::strtolower(trim($attributes['parent'])); |
|
122 | + $this->subdivisions[$key] = array( |
|
123 | + 'id' => trim($attributes['id']), |
|
124 | + 'displayname' => trim($attributes['name']), |
|
125 | + 'coord' => trim($subdivision[0]) |
|
126 | + ); |
|
127 | + } |
|
128 | + if(isset($xml->mappings)) { |
|
129 | + foreach($xml->mappings->children() as $mappings){ |
|
130 | + $attributes = $mappings->attributes(); |
|
131 | + $this->mappings[I18N::strtolower(trim($attributes['name']))] = I18N::strtolower(trim($attributes['mapto'])); |
|
132 | + } |
|
133 | + } |
|
134 | + $this->is_loaded = true; |
|
135 | + return; |
|
136 | + } |
|
137 | + } |
|
138 | + throw new \Exception('The Outline Map could not be loaded from XML.'); |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Get the status of the map loading from the XML file. |
|
143 | + * |
|
144 | + * @return bool |
|
145 | + */ |
|
146 | + public function isLoaded() { |
|
147 | + try{ |
|
148 | + if(!$this->is_loaded) $this->load(); |
|
149 | + } |
|
150 | + catch (\Exception $ex) { } |
|
151 | + return $this->is_loaded; |
|
152 | + } |
|
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Get the map file name. |
156 | 156 | * @return string |
157 | 157 | */ |
158 | - public function getFileName() { |
|
159 | - return $this->filename; |
|
160 | - } |
|
158 | + public function getFileName() { |
|
159 | + return $this->filename; |
|
160 | + } |
|
161 | 161 | |
162 | 162 | /** |
163 | 163 | * Get the map file name. |
164 | 164 | * @return string |
165 | 165 | */ |
166 | - public function getDescription() { |
|
167 | - if(!$this->is_loaded) $this->load(); |
|
168 | - return $this->description; |
|
169 | - } |
|
166 | + public function getDescription() { |
|
167 | + if(!$this->is_loaded) $this->load(); |
|
168 | + return $this->description; |
|
169 | + } |
|
170 | 170 | |
171 | 171 | /** |
172 | 172 | * Get the name of the map parent level. |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - public function getTopLevelName() { |
|
176 | - if(!$this->is_loaded) $this->load(); |
|
177 | - return $this->top_level_name; |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * Get the Outline Map canvas. |
|
182 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
|
183 | - */ |
|
184 | - public function getCanvas() { |
|
185 | - if(!$this->is_loaded) $this->load(); |
|
186 | - return $this->canvas; |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * Get the subdivisions of the map. |
|
191 | - * @return array |
|
192 | - */ |
|
193 | - public function getSubdivisions() { |
|
194 | - if(!$this->is_loaded) $this->load(); |
|
195 | - return $this->subdivisions; |
|
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * Get the places mappings of the map. |
|
200 | - * @return array |
|
201 | - */ |
|
202 | - public function getPlacesMappings() { |
|
203 | - if(!$this->is_loaded) $this->load(); |
|
204 | - return $this->mappings; |
|
205 | - } |
|
175 | + public function getTopLevelName() { |
|
176 | + if(!$this->is_loaded) $this->load(); |
|
177 | + return $this->top_level_name; |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * Get the Outline Map canvas. |
|
182 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
|
183 | + */ |
|
184 | + public function getCanvas() { |
|
185 | + if(!$this->is_loaded) $this->load(); |
|
186 | + return $this->canvas; |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Get the subdivisions of the map. |
|
191 | + * @return array |
|
192 | + */ |
|
193 | + public function getSubdivisions() { |
|
194 | + if(!$this->is_loaded) $this->load(); |
|
195 | + return $this->subdivisions; |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * Get the places mappings of the map. |
|
200 | + * @return array |
|
201 | + */ |
|
202 | + public function getPlacesMappings() { |
|
203 | + if(!$this->is_loaded) $this->load(); |
|
204 | + return $this->mappings; |
|
205 | + } |
|
206 | 206 | |
207 | 207 | } |
208 | 208 | |
209 | 209 | \ No newline at end of file |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $this->is_loaded = false; |
72 | 72 | $this->subdivisions = array(); |
73 | 73 | $this->mappings = array(); |
74 | - if($load) $this->load(); |
|
74 | + if ($load) $this->load(); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | * |
101 | 101 | */ |
102 | 102 | protected function load() { |
103 | - if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){ |
|
103 | + if (file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)) { |
|
104 | 104 | $xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename); |
105 | - if($xml){ |
|
105 | + if ($xml) { |
|
106 | 106 | $this->description = trim($xml->displayName); |
107 | 107 | $this->top_level_name = trim($xml->topLevel); |
108 | 108 | $this->canvas = new OutlineMapCanvas( |
@@ -115,18 +115,18 @@ discard block |
||
115 | 115 | trim($xml->canvas->defaultcolor), |
116 | 116 | trim($xml->canvas->defaultstroke) |
117 | 117 | ); |
118 | - foreach($xml->subdivisions->children() as $subdivision){ |
|
118 | + foreach ($xml->subdivisions->children() as $subdivision) { |
|
119 | 119 | $attributes = $subdivision->attributes(); |
120 | 120 | $key = I18N::strtolower(trim($attributes['name'])); |
121 | - if(isset($attributes['parent'])) $key .= '@'. I18N::strtolower(trim($attributes['parent'])); |
|
121 | + if (isset($attributes['parent'])) $key .= '@'.I18N::strtolower(trim($attributes['parent'])); |
|
122 | 122 | $this->subdivisions[$key] = array( |
123 | 123 | 'id' => trim($attributes['id']), |
124 | 124 | 'displayname' => trim($attributes['name']), |
125 | 125 | 'coord' => trim($subdivision[0]) |
126 | 126 | ); |
127 | 127 | } |
128 | - if(isset($xml->mappings)) { |
|
129 | - foreach($xml->mappings->children() as $mappings){ |
|
128 | + if (isset($xml->mappings)) { |
|
129 | + foreach ($xml->mappings->children() as $mappings) { |
|
130 | 130 | $attributes = $mappings->attributes(); |
131 | 131 | $this->mappings[I18N::strtolower(trim($attributes['name']))] = I18N::strtolower(trim($attributes['mapto'])); |
132 | 132 | } |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | * @return bool |
145 | 145 | */ |
146 | 146 | public function isLoaded() { |
147 | - try{ |
|
148 | - if(!$this->is_loaded) $this->load(); |
|
147 | + try { |
|
148 | + if (!$this->is_loaded) $this->load(); |
|
149 | 149 | } |
150 | 150 | catch (\Exception $ex) { } |
151 | 151 | return $this->is_loaded; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @return string |
165 | 165 | */ |
166 | 166 | public function getDescription() { |
167 | - if(!$this->is_loaded) $this->load(); |
|
167 | + if (!$this->is_loaded) $this->load(); |
|
168 | 168 | return $this->description; |
169 | 169 | } |
170 | 170 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return string |
174 | 174 | */ |
175 | 175 | public function getTopLevelName() { |
176 | - if(!$this->is_loaded) $this->load(); |
|
176 | + if (!$this->is_loaded) $this->load(); |
|
177 | 177 | return $this->top_level_name; |
178 | 178 | } |
179 | 179 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
183 | 183 | */ |
184 | 184 | public function getCanvas() { |
185 | - if(!$this->is_loaded) $this->load(); |
|
185 | + if (!$this->is_loaded) $this->load(); |
|
186 | 186 | return $this->canvas; |
187 | 187 | } |
188 | 188 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @return array |
192 | 192 | */ |
193 | 193 | public function getSubdivisions() { |
194 | - if(!$this->is_loaded) $this->load(); |
|
194 | + if (!$this->is_loaded) $this->load(); |
|
195 | 195 | return $this->subdivisions; |
196 | 196 | } |
197 | 197 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @return array |
201 | 201 | */ |
202 | 202 | public function getPlacesMappings() { |
203 | - if(!$this->is_loaded) $this->load(); |
|
203 | + if (!$this->is_loaded) $this->load(); |
|
204 | 204 | return $this->mappings; |
205 | 205 | } |
206 | 206 |
@@ -71,7 +71,9 @@ discard block |
||
71 | 71 | $this->is_loaded = false; |
72 | 72 | $this->subdivisions = array(); |
73 | 73 | $this->mappings = array(); |
74 | - if($load) $this->load(); |
|
74 | + if($load) { |
|
75 | + $this->load(); |
|
76 | + } |
|
75 | 77 | } |
76 | 78 | |
77 | 79 | /** |
@@ -118,7 +120,9 @@ discard block |
||
118 | 120 | foreach($xml->subdivisions->children() as $subdivision){ |
119 | 121 | $attributes = $subdivision->attributes(); |
120 | 122 | $key = I18N::strtolower(trim($attributes['name'])); |
121 | - if(isset($attributes['parent'])) $key .= '@'. I18N::strtolower(trim($attributes['parent'])); |
|
123 | + if(isset($attributes['parent'])) { |
|
124 | + $key .= '@'. I18N::strtolower(trim($attributes['parent'])); |
|
125 | + } |
|
122 | 126 | $this->subdivisions[$key] = array( |
123 | 127 | 'id' => trim($attributes['id']), |
124 | 128 | 'displayname' => trim($attributes['name']), |
@@ -145,9 +149,10 @@ discard block |
||
145 | 149 | */ |
146 | 150 | public function isLoaded() { |
147 | 151 | try{ |
148 | - if(!$this->is_loaded) $this->load(); |
|
149 | - } |
|
150 | - catch (\Exception $ex) { } |
|
152 | + if(!$this->is_loaded) { |
|
153 | + $this->load(); |
|
154 | + } |
|
155 | + } catch (\Exception $ex) { } |
|
151 | 156 | return $this->is_loaded; |
152 | 157 | } |
153 | 158 | |
@@ -164,7 +169,9 @@ discard block |
||
164 | 169 | * @return string |
165 | 170 | */ |
166 | 171 | public function getDescription() { |
167 | - if(!$this->is_loaded) $this->load(); |
|
172 | + if(!$this->is_loaded) { |
|
173 | + $this->load(); |
|
174 | + } |
|
168 | 175 | return $this->description; |
169 | 176 | } |
170 | 177 | |
@@ -173,7 +180,9 @@ discard block |
||
173 | 180 | * @return string |
174 | 181 | */ |
175 | 182 | public function getTopLevelName() { |
176 | - if(!$this->is_loaded) $this->load(); |
|
183 | + if(!$this->is_loaded) { |
|
184 | + $this->load(); |
|
185 | + } |
|
177 | 186 | return $this->top_level_name; |
178 | 187 | } |
179 | 188 | |
@@ -182,7 +191,9 @@ discard block |
||
182 | 191 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
183 | 192 | */ |
184 | 193 | public function getCanvas() { |
185 | - if(!$this->is_loaded) $this->load(); |
|
194 | + if(!$this->is_loaded) { |
|
195 | + $this->load(); |
|
196 | + } |
|
186 | 197 | return $this->canvas; |
187 | 198 | } |
188 | 199 | |
@@ -191,7 +202,9 @@ discard block |
||
191 | 202 | * @return array |
192 | 203 | */ |
193 | 204 | public function getSubdivisions() { |
194 | - if(!$this->is_loaded) $this->load(); |
|
205 | + if(!$this->is_loaded) { |
|
206 | + $this->load(); |
|
207 | + } |
|
195 | 208 | return $this->subdivisions; |
196 | 209 | } |
197 | 210 | |
@@ -200,7 +213,9 @@ discard block |
||
200 | 213 | * @return array |
201 | 214 | */ |
202 | 215 | public function getPlacesMappings() { |
203 | - if(!$this->is_loaded) $this->load(); |
|
216 | + if(!$this->is_loaded) { |
|
217 | + $this->load(); |
|
218 | + } |
|
204 | 219 | return $this->mappings; |
205 | 220 | } |
206 | 221 |
@@ -36,47 +36,47 @@ discard block |
||
36 | 36 | */ |
37 | 37 | class GeoAnalysisController extends MvcController |
38 | 38 | { |
39 | - /** |
|
40 | - * GeoAnalysis Provider |
|
41 | - * @var GeoAnalysisProvider $provider |
|
42 | - */ |
|
43 | - protected $provider; |
|
39 | + /** |
|
40 | + * GeoAnalysis Provider |
|
41 | + * @var GeoAnalysisProvider $provider |
|
42 | + */ |
|
43 | + protected $provider; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Constructor for GeoAnalysis controller |
|
47 | - * @param AbstractModule $module |
|
48 | - */ |
|
49 | - public function __construct(AbstractModule $module) { |
|
50 | - parent::__construct($module); |
|
45 | + /** |
|
46 | + * Constructor for GeoAnalysis controller |
|
47 | + * @param AbstractModule $module |
|
48 | + */ |
|
49 | + public function __construct(AbstractModule $module) { |
|
50 | + parent::__construct($module); |
|
51 | 51 | |
52 | - $this->provider = $this->module->getProvider(); |
|
53 | - } |
|
52 | + $this->provider = $this->module->getProvider(); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Pages |
|
57 | - */ |
|
55 | + /** |
|
56 | + * Pages |
|
57 | + */ |
|
58 | 58 | |
59 | - /** |
|
60 | - * GeoAnalysis@index |
|
61 | - */ |
|
62 | - public function index() { |
|
59 | + /** |
|
60 | + * GeoAnalysis@index |
|
61 | + */ |
|
62 | + public function index() { |
|
63 | 63 | |
64 | - $controller = new PageController(); |
|
65 | - $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
64 | + $controller = new PageController(); |
|
65 | + $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
66 | 66 | |
67 | - $data = new ViewBag(); |
|
68 | - $data->set('title', $controller->getPageTitle()); |
|
69 | - $data->set('has_analysis', false); |
|
67 | + $data = new ViewBag(); |
|
68 | + $data->set('title', $controller->getPageTitle()); |
|
69 | + $data->set('has_analysis', false); |
|
70 | 70 | |
71 | - $ga_id = Filter::getInteger('ga_id'); |
|
71 | + $ga_id = Filter::getInteger('ga_id'); |
|
72 | 72 | |
73 | - if($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
74 | - $data->set('has_analysis', true); |
|
75 | - $data->set('geoanalysis', $ga); |
|
73 | + if($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
74 | + $data->set('has_analysis', true); |
|
75 | + $data->set('geoanalysis', $ga); |
|
76 | 76 | |
77 | - $controller |
|
78 | - ->addExternalJavascript(Constants::WT_RAPHAEL_JS_URL()) |
|
79 | - ->addInlineJavascript(' |
|
77 | + $controller |
|
78 | + ->addExternalJavascript(Constants::WT_RAPHAEL_JS_URL()) |
|
79 | + ->addInlineJavascript(' |
|
80 | 80 | jQuery("#geodispersion-tabs").tabs(); |
81 | 81 | jQuery("#geodispersion-tabs").css("visibility", "visible"); |
82 | 82 | |
@@ -97,128 +97,128 @@ discard block |
||
97 | 97 | "json" |
98 | 98 | ); |
99 | 99 | '); |
100 | - } |
|
100 | + } |
|
101 | 101 | |
102 | - ViewFactory::make('GeoAnalysis', $this, $controller, $data)->render(); |
|
103 | - } |
|
102 | + ViewFactory::make('GeoAnalysis', $this, $controller, $data)->render(); |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * GeoAnalysis@listAll |
|
107 | - */ |
|
108 | - public function listAll() { |
|
105 | + /** |
|
106 | + * GeoAnalysis@listAll |
|
107 | + */ |
|
108 | + public function listAll() { |
|
109 | 109 | |
110 | - $controller = new PageController(); |
|
111 | - $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
110 | + $controller = new PageController(); |
|
111 | + $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
112 | 112 | |
113 | - $data = new ViewBag(); |
|
114 | - $data->set('title', $controller->getPageTitle()); |
|
115 | - $data->set('has_list', false); |
|
113 | + $data = new ViewBag(); |
|
114 | + $data->set('title', $controller->getPageTitle()); |
|
115 | + $data->set('has_list', false); |
|
116 | 116 | |
117 | - $ga_list = $this->provider->getGeoAnalysisList(); |
|
118 | - if(count($ga_list) > 0 ) { |
|
119 | - $data->set('has_list', true); |
|
120 | - $data->set('geoanalysislist', $ga_list); |
|
121 | - } |
|
117 | + $ga_list = $this->provider->getGeoAnalysisList(); |
|
118 | + if(count($ga_list) > 0 ) { |
|
119 | + $data->set('has_list', true); |
|
120 | + $data->set('geoanalysislist', $ga_list); |
|
121 | + } |
|
122 | 122 | |
123 | - ViewFactory::make('GeoAnalysisList', $this, $controller, $data)->render(); |
|
124 | - } |
|
123 | + ViewFactory::make('GeoAnalysisList', $this, $controller, $data)->render(); |
|
124 | + } |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * GeoAnalysis@setStatus |
128 | 128 | */ |
129 | - public function setStatus() { |
|
130 | - $controller = new JsonController(); |
|
129 | + public function setStatus() { |
|
130 | + $controller = new JsonController(); |
|
131 | 131 | |
132 | - $ga_id = Filter::getInteger('ga_id'); |
|
133 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
132 | + $ga_id = Filter::getInteger('ga_id'); |
|
133 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
134 | 134 | |
135 | - $controller->restrictAccess( |
|
136 | - true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
137 | - && Auth::isManager(Globals::getTree()) |
|
138 | - && $ga !== null |
|
139 | - ); |
|
135 | + $controller->restrictAccess( |
|
136 | + true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
137 | + && Auth::isManager(Globals::getTree()) |
|
138 | + && $ga !== null |
|
139 | + ); |
|
140 | 140 | |
141 | - $status = Filter::getBool('status'); |
|
142 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
143 | - try{ |
|
144 | - $this->provider->setGeoAnalysisStatus($ga, $status); |
|
145 | - $res['status'] = $status; |
|
141 | + $status = Filter::getBool('status'); |
|
142 | + $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
143 | + try{ |
|
144 | + $this->provider->setGeoAnalysisStatus($ga, $status); |
|
145 | + $res['status'] = $status; |
|
146 | 146 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
147 | - } |
|
148 | - catch (\Exception $ex) { |
|
149 | - $res['error'] = $ex->getMessage(); |
|
147 | + } |
|
148 | + catch (\Exception $ex) { |
|
149 | + $res['error'] = $ex->getMessage(); |
|
150 | 150 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
151 | - } |
|
151 | + } |
|
152 | 152 | |
153 | - $controller->pageHeader(); |
|
154 | - if($res['error']) http_response_code(500); |
|
153 | + $controller->pageHeader(); |
|
154 | + if($res['error']) http_response_code(500); |
|
155 | 155 | |
156 | - $controller->encode($res); |
|
157 | - } |
|
156 | + $controller->encode($res); |
|
157 | + } |
|
158 | 158 | |
159 | 159 | /** |
160 | - * GeoAnalysis@delete |
|
161 | - */ |
|
162 | - public function delete() { |
|
163 | - $controller = new JsonController(); |
|
160 | + * GeoAnalysis@delete |
|
161 | + */ |
|
162 | + public function delete() { |
|
163 | + $controller = new JsonController(); |
|
164 | 164 | |
165 | - $ga_id = Filter::getInteger('ga_id'); |
|
166 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
165 | + $ga_id = Filter::getInteger('ga_id'); |
|
166 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
167 | 167 | |
168 | - $controller->restrictAccess( |
|
169 | - true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
170 | - && Auth::isManager(Globals::getTree()) |
|
171 | - && $ga |
|
172 | - ); |
|
168 | + $controller->restrictAccess( |
|
169 | + true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
170 | + && Auth::isManager(Globals::getTree()) |
|
171 | + && $ga |
|
172 | + ); |
|
173 | 173 | |
174 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
175 | - try{ |
|
176 | - $this->provider->deleteGeoAnalysis($ga); |
|
174 | + $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
175 | + try{ |
|
176 | + $this->provider->deleteGeoAnalysis($ga); |
|
177 | 177 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
178 | - } |
|
179 | - catch (\Exception $ex) { |
|
180 | - $res['error'] = $ex->getMessage(); |
|
178 | + } |
|
179 | + catch (\Exception $ex) { |
|
180 | + $res['error'] = $ex->getMessage(); |
|
181 | 181 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage()); |
182 | - } |
|
182 | + } |
|
183 | 183 | |
184 | - $controller->pageHeader(); |
|
185 | - if($res['error']) http_response_code(500); |
|
184 | + $controller->pageHeader(); |
|
185 | + if($res['error']) http_response_code(500); |
|
186 | 186 | |
187 | - $controller->encode($res); |
|
188 | - } |
|
187 | + $controller->encode($res); |
|
188 | + } |
|
189 | 189 | |
190 | - /** |
|
191 | - * GeoAnalysis@dataTabs |
|
192 | - */ |
|
193 | - public function dataTabs() { |
|
194 | - $wt_tree = Globals::getTree(); |
|
195 | - $controller = new JsonController(); |
|
190 | + /** |
|
191 | + * GeoAnalysis@dataTabs |
|
192 | + */ |
|
193 | + public function dataTabs() { |
|
194 | + $wt_tree = Globals::getTree(); |
|
195 | + $controller = new JsonController(); |
|
196 | 196 | |
197 | - $ga_id = Filter::getInteger('ga_id'); |
|
198 | - $ga = $this->provider->getGeoAnalysis($ga_id); |
|
199 | - $sosa_provider = new SosaProvider($wt_tree, Auth::user()); |
|
197 | + $ga_id = Filter::getInteger('ga_id'); |
|
198 | + $ga = $this->provider->getGeoAnalysis($ga_id); |
|
199 | + $sosa_provider = new SosaProvider($wt_tree, Auth::user()); |
|
200 | 200 | |
201 | - $controller |
|
202 | - ->restrictAccess($ga && $sosa_provider->isSetup()) |
|
203 | - ->pageHeader(); |
|
201 | + $controller |
|
202 | + ->restrictAccess($ga && $sosa_provider->isSetup()) |
|
203 | + ->pageHeader(); |
|
204 | 204 | |
205 | - $jsonArray = array(); |
|
205 | + $jsonArray = array(); |
|
206 | 206 | |
207 | - list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); |
|
207 | + list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); |
|
208 | 208 | |
209 | - $flags = array(); |
|
210 | - if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
211 | - $mapProvider = new GoogleMapsProvider(); |
|
212 | - foreach($placesDispGeneral['places'] as $place => $count) { |
|
213 | - $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $wt_tree)); |
|
214 | - } |
|
215 | - } |
|
209 | + $flags = array(); |
|
210 | + if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
211 | + $mapProvider = new GoogleMapsProvider(); |
|
212 | + foreach($placesDispGeneral['places'] as $place => $count) { |
|
213 | + $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $wt_tree)); |
|
214 | + } |
|
215 | + } |
|
216 | 216 | |
217 | - $jsonArray['generaltab'] = $this->htmlPlacesAnalysisGeneralTab($ga, $placesDispGeneral, $flags); |
|
218 | - $jsonArray['generationstab'] = $this->htmlPlacesAnalysisGenerationsTab($ga, $placesDispGenerations, $flags); |
|
217 | + $jsonArray['generaltab'] = $this->htmlPlacesAnalysisGeneralTab($ga, $placesDispGeneral, $flags); |
|
218 | + $jsonArray['generationstab'] = $this->htmlPlacesAnalysisGenerationsTab($ga, $placesDispGenerations, $flags); |
|
219 | 219 | |
220 | - $controller->encode($jsonArray); |
|
221 | - } |
|
220 | + $controller->encode($jsonArray); |
|
221 | + } |
|
222 | 222 | |
223 | 223 | /** |
224 | 224 | * Returns HTML code for the GeoAnalysis general tab (can be either a map or a table). |
@@ -228,71 +228,71 @@ discard block |
||
228 | 228 | * @param (null|array) $flags Array of flags |
229 | 229 | * @return string HTML code for the general tab |
230 | 230 | */ |
231 | - protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) { |
|
232 | - if(!empty($placesGeneralResults)){ |
|
233 | - $data = new ViewBag(); |
|
231 | + protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) { |
|
232 | + if(!empty($placesGeneralResults)){ |
|
233 | + $data = new ViewBag(); |
|
234 | 234 | |
235 | - $nb_found = $placesGeneralResults['knownsum']; |
|
236 | - $nb_other = 0; |
|
237 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
238 | - $nb_unknown = $placesGeneralResults['unknown']; |
|
235 | + $nb_found = $placesGeneralResults['knownsum']; |
|
236 | + $nb_other = 0; |
|
237 | + if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
238 | + $nb_unknown = $placesGeneralResults['unknown']; |
|
239 | 239 | |
240 | - $data->set('stats_gen_nb_found', $nb_found); |
|
241 | - $data->set('stats_gen_nb_other', $nb_other); |
|
242 | - $data->set('stats_gen_nb_unknown', $nb_unknown); |
|
240 | + $data->set('stats_gen_nb_found', $nb_found); |
|
241 | + $data->set('stats_gen_nb_other', $nb_other); |
|
242 | + $data->set('stats_gen_nb_unknown', $nb_unknown); |
|
243 | 243 | |
244 | - $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags()); |
|
244 | + $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags()); |
|
245 | 245 | |
246 | - if($ga->hasMap()) { |
|
247 | - $max = $placesGeneralResults['max']; |
|
248 | - $map = $ga->getOptions()->getMap(); |
|
249 | - if($map->isLoaded()) { |
|
250 | - $results_by_subdivs = $map->getSubdivisions(); |
|
251 | - $places_mappings = $map->getPlacesMappings(); |
|
252 | - foreach ($placesGeneralResults['places'] as $location => $count) { |
|
253 | - $levelvalues = array_reverse(array_map('trim',explode(',', $location))); |
|
254 | - $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel(); |
|
255 | - if($level_map >= 0 && $level_map < count($levelvalues)) { |
|
256 | - $levelref = I18N::strtolower($levelvalues[0] . '@' . $levelvalues[$level_map]); |
|
257 | - if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
258 | - } |
|
259 | - else { |
|
260 | - $levelref = $levelvalues[0]; |
|
261 | - } |
|
262 | - $levelref = I18N::strtolower($levelref); |
|
263 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
264 | - if(isset($results_by_subdivs[$levelref])) { |
|
265 | - $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
|
266 | - $count_subd += $count; |
|
267 | - $results_by_subdivs[$levelref]['count'] = $count_subd; |
|
268 | - $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max); |
|
269 | - if($ga->getOptions()->isUsingFlags() && $flags) { |
|
270 | - $results_by_subdivs[$levelref]['place'] = new Place($location, Globals::getTree()); |
|
271 | - $results_by_subdivs[$levelref]['flag'] = $flags[$location]; |
|
272 | - } |
|
273 | - } |
|
274 | - } |
|
246 | + if($ga->hasMap()) { |
|
247 | + $max = $placesGeneralResults['max']; |
|
248 | + $map = $ga->getOptions()->getMap(); |
|
249 | + if($map->isLoaded()) { |
|
250 | + $results_by_subdivs = $map->getSubdivisions(); |
|
251 | + $places_mappings = $map->getPlacesMappings(); |
|
252 | + foreach ($placesGeneralResults['places'] as $location => $count) { |
|
253 | + $levelvalues = array_reverse(array_map('trim',explode(',', $location))); |
|
254 | + $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel(); |
|
255 | + if($level_map >= 0 && $level_map < count($levelvalues)) { |
|
256 | + $levelref = I18N::strtolower($levelvalues[0] . '@' . $levelvalues[$level_map]); |
|
257 | + if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
258 | + } |
|
259 | + else { |
|
260 | + $levelref = $levelvalues[0]; |
|
261 | + } |
|
262 | + $levelref = I18N::strtolower($levelref); |
|
263 | + if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
264 | + if(isset($results_by_subdivs[$levelref])) { |
|
265 | + $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
|
266 | + $count_subd += $count; |
|
267 | + $results_by_subdivs[$levelref]['count'] = $count_subd; |
|
268 | + $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max); |
|
269 | + if($ga->getOptions()->isUsingFlags() && $flags) { |
|
270 | + $results_by_subdivs[$levelref]['place'] = new Place($location, Globals::getTree()); |
|
271 | + $results_by_subdivs[$levelref]['flag'] = $flags[$location]; |
|
272 | + } |
|
273 | + } |
|
274 | + } |
|
275 | 275 | |
276 | - $data->set('map', $map); |
|
277 | - $data->set('results_by_subdivisions', $results_by_subdivs); |
|
278 | - } |
|
276 | + $data->set('map', $map); |
|
277 | + $data->set('results_by_subdivisions', $results_by_subdivs); |
|
278 | + } |
|
279 | 279 | |
280 | - $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
|
281 | - } |
|
282 | - else { |
|
283 | - $results = $placesGeneralResults['places']; |
|
284 | - arsort($results); |
|
285 | - $data->set('results', $results); |
|
286 | - $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
280 | + $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
|
281 | + } |
|
282 | + else { |
|
283 | + $results = $placesGeneralResults['places']; |
|
284 | + arsort($results); |
|
285 | + $data->set('results', $results); |
|
286 | + $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
287 | 287 | |
288 | - $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
|
289 | - } |
|
290 | - } |
|
291 | - else { |
|
292 | - $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
|
293 | - } |
|
294 | - return $html; |
|
295 | - } |
|
288 | + $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
|
289 | + } |
|
290 | + } |
|
291 | + else { |
|
292 | + $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
|
293 | + } |
|
294 | + return $html; |
|
295 | + } |
|
296 | 296 | |
297 | 297 | /** |
298 | 298 | * Returns HTML code for the GeoAnalysis generations tab. |
@@ -302,66 +302,66 @@ discard block |
||
302 | 302 | * @param (null|array) $flags Array of flags |
303 | 303 | * @return string HTML code for the generations tab |
304 | 304 | */ |
305 | - protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) { |
|
306 | - if(!empty($placesGenerationsResults) && $ga->getOptions()){ |
|
307 | - $data = new ViewBag(); |
|
305 | + protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) { |
|
306 | + if(!empty($placesGenerationsResults) && $ga->getOptions()){ |
|
307 | + $data = new ViewBag(); |
|
308 | 308 | |
309 | - ksort($placesGenerationsResults); |
|
309 | + ksort($placesGenerationsResults); |
|
310 | 310 | |
311 | - $detailslevel = $ga->getOptions()->getMaxDetailsInGen(); |
|
312 | - $data->set('max_details_gen', $detailslevel); |
|
313 | - $data->set('use_flags', $ga->getOptions()->isUsingFlags()); |
|
314 | - $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
315 | - $display_all_places = !is_null($detailslevel) && $detailslevel == 0; |
|
316 | - $data->set('display_all_places', $display_all_places); |
|
311 | + $detailslevel = $ga->getOptions()->getMaxDetailsInGen(); |
|
312 | + $data->set('max_details_gen', $detailslevel); |
|
313 | + $data->set('use_flags', $ga->getOptions()->isUsingFlags()); |
|
314 | + $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
315 | + $display_all_places = !is_null($detailslevel) && $detailslevel == 0; |
|
316 | + $data->set('display_all_places', $display_all_places); |
|
317 | 317 | |
318 | - $results_by_gen = array(); |
|
319 | - foreach($placesGenerationsResults as $gen => $genData){ |
|
320 | - $sum = 0; |
|
321 | - $other = 0; |
|
322 | - $unknown = 0; |
|
323 | - if(isset($genData['sum'])) $sum = $genData['sum']; |
|
324 | - if(isset($genData['other'])) $other = $genData['other']; |
|
325 | - if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
318 | + $results_by_gen = array(); |
|
319 | + foreach($placesGenerationsResults as $gen => $genData){ |
|
320 | + $sum = 0; |
|
321 | + $other = 0; |
|
322 | + $unknown = 0; |
|
323 | + if(isset($genData['sum'])) $sum = $genData['sum']; |
|
324 | + if(isset($genData['other'])) $other = $genData['other']; |
|
325 | + if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
326 | 326 | |
327 | - if($sum > 0) { |
|
328 | - $results_by_gen[$gen]['sum'] = $sum; |
|
329 | - $results_by_gen[$gen]['other'] = $other; |
|
330 | - $results_by_gen[$gen]['unknown'] = $unknown; |
|
331 | - $results_by_gen[$gen]['places'] = array(); |
|
332 | - arsort($genData['places']); |
|
327 | + if($sum > 0) { |
|
328 | + $results_by_gen[$gen]['sum'] = $sum; |
|
329 | + $results_by_gen[$gen]['other'] = $other; |
|
330 | + $results_by_gen[$gen]['unknown'] = $unknown; |
|
331 | + $results_by_gen[$gen]['places'] = array(); |
|
332 | + arsort($genData['places']); |
|
333 | 333 | |
334 | - if($display_all_places){ |
|
335 | - foreach($genData['places'] as $placename=> $count){ |
|
336 | - $results_by_gen[$gen]['places'][$placename]['count'] = $count; |
|
334 | + if($display_all_places){ |
|
335 | + foreach($genData['places'] as $placename=> $count){ |
|
336 | + $results_by_gen[$gen]['places'][$placename]['count'] = $count; |
|
337 | 337 | |
338 | - if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){ |
|
339 | - $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, Globals::getTree()); |
|
340 | - $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
|
341 | - } |
|
342 | - } |
|
343 | - } |
|
344 | - else { |
|
345 | - $tmp = $genData['places']; |
|
346 | - if($other > 0) { |
|
347 | - $tmp = array_slice($tmp, 0, 5, true); |
|
348 | - $tmp['other'] = $other; |
|
349 | - arsort($tmp); |
|
350 | - } |
|
351 | - $results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true); |
|
352 | - } |
|
353 | - } |
|
354 | - } |
|
338 | + if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){ |
|
339 | + $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, Globals::getTree()); |
|
340 | + $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
|
341 | + } |
|
342 | + } |
|
343 | + } |
|
344 | + else { |
|
345 | + $tmp = $genData['places']; |
|
346 | + if($other > 0) { |
|
347 | + $tmp = array_slice($tmp, 0, 5, true); |
|
348 | + $tmp['other'] = $other; |
|
349 | + arsort($tmp); |
|
350 | + } |
|
351 | + $results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true); |
|
352 | + } |
|
353 | + } |
|
354 | + } |
|
355 | 355 | |
356 | - $data->set('results_by_generations', $results_by_gen); |
|
356 | + $data->set('results_by_generations', $results_by_gen); |
|
357 | 357 | |
358 | - $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
|
358 | + $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
|
359 | 359 | |
360 | - } |
|
361 | - else { |
|
362 | - $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
|
363 | - } |
|
364 | - return $html; |
|
365 | - } |
|
360 | + } |
|
361 | + else { |
|
362 | + $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
|
363 | + } |
|
364 | + return $html; |
|
365 | + } |
|
366 | 366 | |
367 | 367 | } |
368 | 368 | \ No newline at end of file |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $ga_id = Filter::getInteger('ga_id'); |
72 | 72 | |
73 | - if($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
73 | + if ($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
74 | 74 | $data->set('has_analysis', true); |
75 | 75 | $data->set('geoanalysis', $ga); |
76 | 76 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | jQuery.get( |
84 | 84 | "module.php", |
85 | 85 | { |
86 | - "mod" : "'. $this->module->getName() .'", |
|
86 | + "mod" : "'. $this->module->getName().'", |
|
87 | 87 | "mod_action": "GeoAnalysis@dataTabs", |
88 | 88 | "ga_id" : "'.$ga_id.'" |
89 | 89 | }, |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $data->set('has_list', false); |
116 | 116 | |
117 | 117 | $ga_list = $this->provider->getGeoAnalysisList(); |
118 | - if(count($ga_list) > 0 ) { |
|
118 | + if (count($ga_list) > 0) { |
|
119 | 119 | $data->set('has_list', true); |
120 | 120 | $data->set('geoanalysislist', $ga_list); |
121 | 121 | } |
@@ -139,19 +139,19 @@ discard block |
||
139 | 139 | ); |
140 | 140 | |
141 | 141 | $status = Filter::getBool('status'); |
142 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
143 | - try{ |
|
142 | + $res = array('geoanalysis' => $ga->getId(), 'error' => null); |
|
143 | + try { |
|
144 | 144 | $this->provider->setGeoAnalysisStatus($ga, $status); |
145 | 145 | $res['status'] = $status; |
146 | - Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
|
146 | + Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '.($status ? 'enabled' : 'disabled').'.'); |
|
147 | 147 | } |
148 | 148 | catch (\Exception $ex) { |
149 | 149 | $res['error'] = $ex->getMessage(); |
150 | - Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
|
150 | + Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be '.($status ? 'enabled' : 'disabled').'. Error: '.$ex->getMessage()); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | $controller->pageHeader(); |
154 | - if($res['error']) http_response_code(500); |
|
154 | + if ($res['error']) http_response_code(500); |
|
155 | 155 | |
156 | 156 | $controller->encode($res); |
157 | 157 | } |
@@ -171,18 +171,18 @@ discard block |
||
171 | 171 | && $ga |
172 | 172 | ); |
173 | 173 | |
174 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
175 | - try{ |
|
174 | + $res = array('geoanalysis' => $ga->getId(), 'error' => null); |
|
175 | + try { |
|
176 | 176 | $this->provider->deleteGeoAnalysis($ga); |
177 | 177 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
178 | 178 | } |
179 | 179 | catch (\Exception $ex) { |
180 | 180 | $res['error'] = $ex->getMessage(); |
181 | - Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage()); |
|
181 | + Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '.$ex->getMessage()); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $controller->pageHeader(); |
185 | - if($res['error']) http_response_code(500); |
|
185 | + if ($res['error']) http_response_code(500); |
|
186 | 186 | |
187 | 187 | $controller->encode($res); |
188 | 188 | } |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); |
208 | 208 | |
209 | 209 | $flags = array(); |
210 | - if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
210 | + if ($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
211 | 211 | $mapProvider = new GoogleMapsProvider(); |
212 | - foreach($placesDispGeneral['places'] as $place => $count) { |
|
212 | + foreach ($placesDispGeneral['places'] as $place => $count) { |
|
213 | 213 | $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $wt_tree)); |
214 | 214 | } |
215 | 215 | } |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | * @param (null|array) $flags Array of flags |
229 | 229 | * @return string HTML code for the general tab |
230 | 230 | */ |
231 | - protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) { |
|
232 | - if(!empty($placesGeneralResults)){ |
|
231 | + protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags = null) { |
|
232 | + if (!empty($placesGeneralResults)) { |
|
233 | 233 | $data = new ViewBag(); |
234 | 234 | |
235 | 235 | $nb_found = $placesGeneralResults['knownsum']; |
236 | 236 | $nb_other = 0; |
237 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
237 | + if (isset($placesGeneralResults['other'])) $nb_other = $placesGeneralResults['other']; |
|
238 | 238 | $nb_unknown = $placesGeneralResults['unknown']; |
239 | 239 | |
240 | 240 | $data->set('stats_gen_nb_found', $nb_found); |
@@ -243,30 +243,30 @@ discard block |
||
243 | 243 | |
244 | 244 | $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags()); |
245 | 245 | |
246 | - if($ga->hasMap()) { |
|
246 | + if ($ga->hasMap()) { |
|
247 | 247 | $max = $placesGeneralResults['max']; |
248 | 248 | $map = $ga->getOptions()->getMap(); |
249 | - if($map->isLoaded()) { |
|
249 | + if ($map->isLoaded()) { |
|
250 | 250 | $results_by_subdivs = $map->getSubdivisions(); |
251 | 251 | $places_mappings = $map->getPlacesMappings(); |
252 | 252 | foreach ($placesGeneralResults['places'] as $location => $count) { |
253 | - $levelvalues = array_reverse(array_map('trim',explode(',', $location))); |
|
253 | + $levelvalues = array_reverse(array_map('trim', explode(',', $location))); |
|
254 | 254 | $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel(); |
255 | - if($level_map >= 0 && $level_map < count($levelvalues)) { |
|
256 | - $levelref = I18N::strtolower($levelvalues[0] . '@' . $levelvalues[$level_map]); |
|
257 | - if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
255 | + if ($level_map >= 0 && $level_map < count($levelvalues)) { |
|
256 | + $levelref = I18N::strtolower($levelvalues[0].'@'.$levelvalues[$level_map]); |
|
257 | + if (!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
258 | 258 | } |
259 | 259 | else { |
260 | 260 | $levelref = $levelvalues[0]; |
261 | 261 | } |
262 | 262 | $levelref = I18N::strtolower($levelref); |
263 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
264 | - if(isset($results_by_subdivs[$levelref])) { |
|
263 | + if (isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
264 | + if (isset($results_by_subdivs[$levelref])) { |
|
265 | 265 | $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
266 | - $count_subd += $count; |
|
266 | + $count_subd += $count; |
|
267 | 267 | $results_by_subdivs[$levelref]['count'] = $count_subd; |
268 | 268 | $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max); |
269 | - if($ga->getOptions()->isUsingFlags() && $flags) { |
|
269 | + if ($ga->getOptions()->isUsingFlags() && $flags) { |
|
270 | 270 | $results_by_subdivs[$levelref]['place'] = new Place($location, Globals::getTree()); |
271 | 271 | $results_by_subdivs[$levelref]['flag'] = $flags[$location]; |
272 | 272 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | } |
290 | 290 | } |
291 | 291 | else { |
292 | - $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
|
292 | + $html = '<p class="warning">'.I18N::translate('No data is available for the general analysis.').'</p>'; |
|
293 | 293 | } |
294 | 294 | return $html; |
295 | 295 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * @return string HTML code for the generations tab |
304 | 304 | */ |
305 | 305 | protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) { |
306 | - if(!empty($placesGenerationsResults) && $ga->getOptions()){ |
|
306 | + if (!empty($placesGenerationsResults) && $ga->getOptions()) { |
|
307 | 307 | $data = new ViewBag(); |
308 | 308 | |
309 | 309 | ksort($placesGenerationsResults); |
@@ -316,26 +316,26 @@ discard block |
||
316 | 316 | $data->set('display_all_places', $display_all_places); |
317 | 317 | |
318 | 318 | $results_by_gen = array(); |
319 | - foreach($placesGenerationsResults as $gen => $genData){ |
|
319 | + foreach ($placesGenerationsResults as $gen => $genData) { |
|
320 | 320 | $sum = 0; |
321 | 321 | $other = 0; |
322 | 322 | $unknown = 0; |
323 | - if(isset($genData['sum'])) $sum = $genData['sum']; |
|
324 | - if(isset($genData['other'])) $other = $genData['other']; |
|
325 | - if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
323 | + if (isset($genData['sum'])) $sum = $genData['sum']; |
|
324 | + if (isset($genData['other'])) $other = $genData['other']; |
|
325 | + if (isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
326 | 326 | |
327 | - if($sum > 0) { |
|
327 | + if ($sum > 0) { |
|
328 | 328 | $results_by_gen[$gen]['sum'] = $sum; |
329 | 329 | $results_by_gen[$gen]['other'] = $other; |
330 | 330 | $results_by_gen[$gen]['unknown'] = $unknown; |
331 | 331 | $results_by_gen[$gen]['places'] = array(); |
332 | 332 | arsort($genData['places']); |
333 | 333 | |
334 | - if($display_all_places){ |
|
335 | - foreach($genData['places'] as $placename=> $count){ |
|
334 | + if ($display_all_places) { |
|
335 | + foreach ($genData['places'] as $placename=> $count) { |
|
336 | 336 | $results_by_gen[$gen]['places'][$placename]['count'] = $count; |
337 | 337 | |
338 | - if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){ |
|
338 | + if ($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != '') { |
|
339 | 339 | $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, Globals::getTree()); |
340 | 340 | $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
341 | 341 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | } |
344 | 344 | else { |
345 | 345 | $tmp = $genData['places']; |
346 | - if($other > 0) { |
|
346 | + if ($other > 0) { |
|
347 | 347 | $tmp = array_slice($tmp, 0, 5, true); |
348 | 348 | $tmp['other'] = $other; |
349 | 349 | arsort($tmp); |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | |
360 | 360 | } |
361 | 361 | else { |
362 | - $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
|
362 | + $html = '<p class="warning">'.I18N::translate('No data is available for the generations analysis.').'</p>'; |
|
363 | 363 | } |
364 | 364 | return $html; |
365 | 365 | } |
@@ -144,14 +144,15 @@ discard block |
||
144 | 144 | $this->provider->setGeoAnalysisStatus($ga, $status); |
145 | 145 | $res['status'] = $status; |
146 | 146 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
147 | - } |
|
148 | - catch (\Exception $ex) { |
|
147 | + } catch (\Exception $ex) { |
|
149 | 148 | $res['error'] = $ex->getMessage(); |
150 | 149 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
151 | 150 | } |
152 | 151 | |
153 | 152 | $controller->pageHeader(); |
154 | - if($res['error']) http_response_code(500); |
|
153 | + if($res['error']) { |
|
154 | + http_response_code(500); |
|
155 | + } |
|
155 | 156 | |
156 | 157 | $controller->encode($res); |
157 | 158 | } |
@@ -175,14 +176,15 @@ discard block |
||
175 | 176 | try{ |
176 | 177 | $this->provider->deleteGeoAnalysis($ga); |
177 | 178 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
178 | - } |
|
179 | - catch (\Exception $ex) { |
|
179 | + } catch (\Exception $ex) { |
|
180 | 180 | $res['error'] = $ex->getMessage(); |
181 | 181 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage()); |
182 | 182 | } |
183 | 183 | |
184 | 184 | $controller->pageHeader(); |
185 | - if($res['error']) http_response_code(500); |
|
185 | + if($res['error']) { |
|
186 | + http_response_code(500); |
|
187 | + } |
|
186 | 188 | |
187 | 189 | $controller->encode($res); |
188 | 190 | } |
@@ -234,7 +236,9 @@ discard block |
||
234 | 236 | |
235 | 237 | $nb_found = $placesGeneralResults['knownsum']; |
236 | 238 | $nb_other = 0; |
237 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
239 | + if(isset($placesGeneralResults['other'])) { |
|
240 | + $nb_other =$placesGeneralResults['other']; |
|
241 | + } |
|
238 | 242 | $nb_unknown = $placesGeneralResults['unknown']; |
239 | 243 | |
240 | 244 | $data->set('stats_gen_nb_found', $nb_found); |
@@ -255,12 +259,13 @@ discard block |
||
255 | 259 | if($level_map >= 0 && $level_map < count($levelvalues)) { |
256 | 260 | $levelref = I18N::strtolower($levelvalues[0] . '@' . $levelvalues[$level_map]); |
257 | 261 | if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
258 | - } |
|
259 | - else { |
|
262 | + } else { |
|
260 | 263 | $levelref = $levelvalues[0]; |
261 | 264 | } |
262 | 265 | $levelref = I18N::strtolower($levelref); |
263 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
266 | + if(isset($places_mappings[$levelref])) { |
|
267 | + $levelref = $places_mappings[$levelref]; |
|
268 | + } |
|
264 | 269 | if(isset($results_by_subdivs[$levelref])) { |
265 | 270 | $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
266 | 271 | $count_subd += $count; |
@@ -278,8 +283,7 @@ discard block |
||
278 | 283 | } |
279 | 284 | |
280 | 285 | $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
281 | - } |
|
282 | - else { |
|
286 | + } else { |
|
283 | 287 | $results = $placesGeneralResults['places']; |
284 | 288 | arsort($results); |
285 | 289 | $data->set('results', $results); |
@@ -287,8 +291,7 @@ discard block |
||
287 | 291 | |
288 | 292 | $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
289 | 293 | } |
290 | - } |
|
291 | - else { |
|
294 | + } else { |
|
292 | 295 | $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
293 | 296 | } |
294 | 297 | return $html; |
@@ -320,9 +323,15 @@ discard block |
||
320 | 323 | $sum = 0; |
321 | 324 | $other = 0; |
322 | 325 | $unknown = 0; |
323 | - if(isset($genData['sum'])) $sum = $genData['sum']; |
|
324 | - if(isset($genData['other'])) $other = $genData['other']; |
|
325 | - if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
326 | + if(isset($genData['sum'])) { |
|
327 | + $sum = $genData['sum']; |
|
328 | + } |
|
329 | + if(isset($genData['other'])) { |
|
330 | + $other = $genData['other']; |
|
331 | + } |
|
332 | + if(isset($genData['unknown'])) { |
|
333 | + $unknown = $genData['unknown']; |
|
334 | + } |
|
326 | 335 | |
327 | 336 | if($sum > 0) { |
328 | 337 | $results_by_gen[$gen]['sum'] = $sum; |
@@ -340,8 +349,7 @@ discard block |
||
340 | 349 | $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
341 | 350 | } |
342 | 351 | } |
343 | - } |
|
344 | - else { |
|
352 | + } else { |
|
345 | 353 | $tmp = $genData['places']; |
346 | 354 | if($other > 0) { |
347 | 355 | $tmp = array_slice($tmp, 0, 5, true); |
@@ -357,8 +365,7 @@ discard block |
||
357 | 365 | |
358 | 366 | $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
359 | 367 | |
360 | - } |
|
361 | - else { |
|
368 | + } else { |
|
362 | 369 | $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
363 | 370 | } |
364 | 371 | return $html; |
@@ -22,61 +22,61 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class ImageBuilder { |
24 | 24 | |
25 | - /** |
|
26 | - * Reference media |
|
27 | - * @var Media $media |
|
28 | - */ |
|
29 | - protected $media; |
|
25 | + /** |
|
26 | + * Reference media |
|
27 | + * @var Media $media |
|
28 | + */ |
|
29 | + protected $media; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Use TTF font |
|
33 | - * @var bool $use_ttf |
|
34 | - */ |
|
35 | - protected $use_ttf; |
|
31 | + /** |
|
32 | + * Use TTF font |
|
33 | + * @var bool $use_ttf |
|
34 | + */ |
|
35 | + protected $use_ttf; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Expiration offset. Default is one day. |
|
39 | - * @var int $expire_offset |
|
40 | - */ |
|
41 | - protected $expire_offset; |
|
37 | + /** |
|
38 | + * Expiration offset. Default is one day. |
|
39 | + * @var int $expire_offset |
|
40 | + */ |
|
41 | + protected $expire_offset; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Should the certificate display a watermark |
|
45 | - * @var bool $show_watermark |
|
46 | - */ |
|
47 | - protected $show_watermark; |
|
43 | + /** |
|
44 | + * Should the certificate display a watermark |
|
45 | + * @var bool $show_watermark |
|
46 | + */ |
|
47 | + protected $show_watermark; |
|
48 | 48 | |
49 | - /** |
|
50 | - * Maximum watermark font size. Default is 18. |
|
51 | - * @var int $font_max_size |
|
52 | - */ |
|
53 | - protected $font_max_size; |
|
49 | + /** |
|
50 | + * Maximum watermark font size. Default is 18. |
|
51 | + * @var int $font_max_size |
|
52 | + */ |
|
53 | + protected $font_max_size; |
|
54 | 54 | |
55 | - /** |
|
56 | - * Watermark font color, in hexadecimal. Default is #4D6DF3. |
|
57 | - * @var string $font_color |
|
58 | - */ |
|
59 | - protected $font_color; |
|
55 | + /** |
|
56 | + * Watermark font color, in hexadecimal. Default is #4D6DF3. |
|
57 | + * @var string $font_color |
|
58 | + */ |
|
59 | + protected $font_color; |
|
60 | 60 | |
61 | - /** |
|
62 | - * Should the image be rendered as attachment (vs inline) * |
|
63 | - * @var bool $as_attachment |
|
64 | - */ |
|
65 | - protected $as_attachment; |
|
61 | + /** |
|
62 | + * Should the image be rendered as attachment (vs inline) * |
|
63 | + * @var bool $as_attachment |
|
64 | + */ |
|
65 | + protected $as_attachment; |
|
66 | 66 | |
67 | 67 | /** |
68 | - * Contructor for ImageBuilder |
|
69 | - * |
|
70 | - * @param Media|null $media Reference media object |
|
71 | - */ |
|
68 | + * Contructor for ImageBuilder |
|
69 | + * |
|
70 | + * @param Media|null $media Reference media object |
|
71 | + */ |
|
72 | 72 | public function __construct(Media $media = null){ |
73 | - $this->media = $media; |
|
74 | - $this->use_ttf = function_exists('imagettftext'); |
|
75 | - $this->expire_offset = 3600 * 24; |
|
76 | - $this->show_watermark = true; |
|
77 | - $this->font_max_size = 18; |
|
78 | - $this->font_color = '#4D6DF3'; |
|
79 | - $this->as_attachment = false; |
|
73 | + $this->media = $media; |
|
74 | + $this->use_ttf = function_exists('imagettftext'); |
|
75 | + $this->expire_offset = 3600 * 24; |
|
76 | + $this->show_watermark = true; |
|
77 | + $this->font_max_size = 18; |
|
78 | + $this->font_color = '#4D6DF3'; |
|
79 | + $this->as_attachment = false; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @return int |
86 | 86 | */ |
87 | 87 | public function getExpireOffset() { |
88 | - return $this->expire_offset; |
|
88 | + return $this->expire_offset; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | * @return ImageBuilder |
96 | 96 | */ |
97 | 97 | public function setExpireOffset($expireOffset) { |
98 | - if($expireOffset) $this->expire_offset = $expireOffset; |
|
99 | - return $this; |
|
98 | + if($expireOffset) $this->expire_offset = $expireOffset; |
|
99 | + return $this; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return bool |
106 | 106 | */ |
107 | 107 | public function isShowWatermark() { |
108 | - return $this->show_watermark; |
|
108 | + return $this->show_watermark; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | * @return ImageBuilder |
116 | 116 | */ |
117 | 117 | public function setShowWatermark($show_watermark) { |
118 | - if(!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
119 | - return $this; |
|
118 | + if(!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
119 | + return $this; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @return ImageBuilder |
127 | 127 | */ |
128 | 128 | public function setFontMaxSize($font_max_size) { |
129 | - if($font_max_size) $this->font_max_size = $font_max_size; |
|
130 | - return $this; |
|
129 | + if($font_max_size) $this->font_max_size = $font_max_size; |
|
130 | + return $this; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | * @return ImageBuilder |
138 | 138 | */ |
139 | 139 | public function setFontColor($font_color) { |
140 | - if($font_color) $this->font_color = $font_color; |
|
141 | - return $this; |
|
140 | + if($font_color) $this->font_color = $font_color; |
|
141 | + return $this; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | * @return ImageBuilder |
149 | 149 | */ |
150 | 150 | public function setAsAttachment($is_attachement) { |
151 | - if(is_bool($is_attachement)) $this->as_attachment = $is_attachement; |
|
152 | - return $this; |
|
151 | + if(is_bool($is_attachement)) $this->as_attachment = $is_attachement; |
|
152 | + return $this; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -157,135 +157,135 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function render(){ |
159 | 159 | |
160 | - if (!$this->media || !$this->media->canShow()) { |
|
161 | - Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.')); |
|
162 | - $this->renderError(); |
|
163 | - } |
|
160 | + if (!$this->media || !$this->media->canShow()) { |
|
161 | + Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.')); |
|
162 | + $this->renderError(); |
|
163 | + } |
|
164 | 164 | |
165 | - $serverFilename = $this->media->getServerFilename(); |
|
165 | + $serverFilename = $this->media->getServerFilename(); |
|
166 | 166 | |
167 | - if (!file_exists($serverFilename)) { |
|
168 | - Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<'); |
|
169 | - $this->renderError(); |
|
170 | - } |
|
167 | + if (!file_exists($serverFilename)) { |
|
168 | + Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<'); |
|
169 | + $this->renderError(); |
|
170 | + } |
|
171 | 171 | |
172 | - $mimetype = $this->media->mimeType(); |
|
173 | - $imgsize = $this->media->getImageAttributes(); |
|
174 | - $filetime = $this->media->getFiletime(); |
|
175 | - $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT'; |
|
176 | - $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()) . ' GMT'; |
|
172 | + $mimetype = $this->media->mimeType(); |
|
173 | + $imgsize = $this->media->getImageAttributes(); |
|
174 | + $filetime = $this->media->getFiletime(); |
|
175 | + $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT'; |
|
176 | + $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()) . ' GMT'; |
|
177 | 177 | |
178 | - $type = Functions::isImageTypeSupported($imgsize['ext']); |
|
179 | - $usewatermark = false; |
|
180 | - // if this image supports watermarks and the watermark module is intalled... |
|
181 | - if ($type) { |
|
182 | - $usewatermark = $this->isShowWatermark(); |
|
183 | - } |
|
178 | + $type = Functions::isImageTypeSupported($imgsize['ext']); |
|
179 | + $usewatermark = false; |
|
180 | + // if this image supports watermarks and the watermark module is intalled... |
|
181 | + if ($type) { |
|
182 | + $usewatermark = $this->isShowWatermark(); |
|
183 | + } |
|
184 | 184 | |
185 | - // determine whether we have enough memory to watermark this image |
|
186 | - if ($usewatermark) { |
|
187 | - if (!FunctionsMedia::hasMemoryForImage($serverFilename)) { |
|
188 | - // not enough memory to watermark this file |
|
189 | - $usewatermark = false; |
|
190 | - } |
|
191 | - } |
|
185 | + // determine whether we have enough memory to watermark this image |
|
186 | + if ($usewatermark) { |
|
187 | + if (!FunctionsMedia::hasMemoryForImage($serverFilename)) { |
|
188 | + // not enough memory to watermark this file |
|
189 | + $usewatermark = false; |
|
190 | + } |
|
191 | + } |
|
192 | 192 | |
193 | - $etag = $this->media->getEtag(); |
|
193 | + $etag = $this->media->getEtag(); |
|
194 | 194 | |
195 | - // parse IF_MODIFIED_SINCE header from client |
|
196 | - $if_modified_since = 'x'; |
|
197 | - if (!empty(Filter::server('HTTP_IF_MODIFIED_SINCE'))) { |
|
198 | - $if_modified_since = preg_replace('/;.*$/', '', Filter::server('HTTP_IF_MODIFIED_SINCE')); |
|
199 | - } |
|
195 | + // parse IF_MODIFIED_SINCE header from client |
|
196 | + $if_modified_since = 'x'; |
|
197 | + if (!empty(Filter::server('HTTP_IF_MODIFIED_SINCE'))) { |
|
198 | + $if_modified_since = preg_replace('/;.*$/', '', Filter::server('HTTP_IF_MODIFIED_SINCE')); |
|
199 | + } |
|
200 | 200 | |
201 | - // parse IF_NONE_MATCH header from client |
|
202 | - $if_none_match = 'x'; |
|
203 | - if (!empty(Filter::server('HTTP_IF_NONE_MATCH'))) { |
|
204 | - $if_none_match = str_replace('"', '', Filter::server('HTTP_IF_NONE_MATCH')); |
|
205 | - } |
|
201 | + // parse IF_NONE_MATCH header from client |
|
202 | + $if_none_match = 'x'; |
|
203 | + if (!empty(Filter::server('HTTP_IF_NONE_MATCH'))) { |
|
204 | + $if_none_match = str_replace('"', '', Filter::server('HTTP_IF_NONE_MATCH')); |
|
205 | + } |
|
206 | 206 | |
207 | - // add caching headers. allow browser to cache file, but not proxy |
|
208 | - header('Last-Modified: ' . $filetimeHeader); |
|
209 | - header('ETag: "' . $etag . '"'); |
|
210 | - header('Expires: ' . $expireHeader); |
|
211 | - header('Cache-Control: max-age=' . $this->getExpireOffset() . ', s-maxage=0, proxy-revalidate'); |
|
207 | + // add caching headers. allow browser to cache file, but not proxy |
|
208 | + header('Last-Modified: ' . $filetimeHeader); |
|
209 | + header('ETag: "' . $etag . '"'); |
|
210 | + header('Expires: ' . $expireHeader); |
|
211 | + header('Cache-Control: max-age=' . $this->getExpireOffset() . ', s-maxage=0, proxy-revalidate'); |
|
212 | 212 | |
213 | - // if this file is already in the user’s cache, don’t resend it |
|
214 | - // first check if the if_modified_since param matches |
|
215 | - if ($if_modified_since === $filetimeHeader) { |
|
216 | - // then check if the etag matches |
|
217 | - if ($if_none_match === $etag) { |
|
218 | - http_response_code(304); |
|
213 | + // if this file is already in the user’s cache, don’t resend it |
|
214 | + // first check if the if_modified_since param matches |
|
215 | + if ($if_modified_since === $filetimeHeader) { |
|
216 | + // then check if the etag matches |
|
217 | + if ($if_none_match === $etag) { |
|
218 | + http_response_code(304); |
|
219 | 219 | |
220 | - return; |
|
221 | - } |
|
222 | - } |
|
220 | + return; |
|
221 | + } |
|
222 | + } |
|
223 | 223 | |
224 | - // send headers for the image |
|
225 | - $disposition = $this->as_attachment ? 'attachment' : 'inline'; |
|
226 | - header('Content-Type: ' . $mimetype); |
|
227 | - header('Content-Disposition: ' . $disposition . '; filename="' . addslashes(basename($this->media->getFilename())) . '"'); |
|
224 | + // send headers for the image |
|
225 | + $disposition = $this->as_attachment ? 'attachment' : 'inline'; |
|
226 | + header('Content-Type: ' . $mimetype); |
|
227 | + header('Content-Disposition: ' . $disposition . '; filename="' . addslashes(basename($this->media->getFilename())) . '"'); |
|
228 | 228 | |
229 | - if ($usewatermark) { |
|
230 | - // generate the watermarked image |
|
231 | - $imCreateFunc = 'imagecreatefrom' . $type; |
|
232 | - $imSendFunc = 'image' . $type; |
|
229 | + if ($usewatermark) { |
|
230 | + // generate the watermarked image |
|
231 | + $imCreateFunc = 'imagecreatefrom' . $type; |
|
232 | + $imSendFunc = 'image' . $type; |
|
233 | 233 | |
234 | - if (function_exists($imCreateFunc) && function_exists($imSendFunc)) { |
|
235 | - $im = $imCreateFunc($serverFilename); |
|
236 | - $im = $this->applyWatermark($im); |
|
234 | + if (function_exists($imCreateFunc) && function_exists($imSendFunc)) { |
|
235 | + $im = $imCreateFunc($serverFilename); |
|
236 | + $im = $this->applyWatermark($im); |
|
237 | 237 | |
238 | - // send the image |
|
239 | - $imSendFunc($im); |
|
240 | - imagedestroy($im); |
|
238 | + // send the image |
|
239 | + $imSendFunc($im); |
|
240 | + imagedestroy($im); |
|
241 | 241 | |
242 | - return; |
|
243 | - } else { |
|
244 | - // this image is defective. log it |
|
245 | - Log::addMediaLog('Image Builder error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage()); |
|
246 | - } |
|
247 | - } |
|
242 | + return; |
|
243 | + } else { |
|
244 | + // this image is defective. log it |
|
245 | + Log::addMediaLog('Image Builder error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage()); |
|
246 | + } |
|
247 | + } |
|
248 | 248 | |
249 | - // determine filesize of image (could be original or watermarked version) |
|
250 | - $filesize = filesize($serverFilename); |
|
249 | + // determine filesize of image (could be original or watermarked version) |
|
250 | + $filesize = filesize($serverFilename); |
|
251 | 251 | |
252 | - // set content-length header, send file |
|
253 | - header('Content-Length: ' . $filesize); |
|
252 | + // set content-length header, send file |
|
253 | + header('Content-Length: ' . $filesize); |
|
254 | 254 | |
255 | - // Some servers disable fpassthru() and readfile() |
|
256 | - if (function_exists('readfile')) { |
|
257 | - readfile($serverFilename); |
|
258 | - } else { |
|
259 | - $fp = fopen($serverFilename, 'rb'); |
|
260 | - if (function_exists('fpassthru')) { |
|
261 | - fpassthru($fp); |
|
262 | - } else { |
|
263 | - while (!feof($fp)) { |
|
264 | - echo fread($fp, 65536); |
|
265 | - } |
|
266 | - } |
|
267 | - fclose($fp); |
|
268 | - } |
|
255 | + // Some servers disable fpassthru() and readfile() |
|
256 | + if (function_exists('readfile')) { |
|
257 | + readfile($serverFilename); |
|
258 | + } else { |
|
259 | + $fp = fopen($serverFilename, 'rb'); |
|
260 | + if (function_exists('fpassthru')) { |
|
261 | + fpassthru($fp); |
|
262 | + } else { |
|
263 | + while (!feof($fp)) { |
|
264 | + echo fread($fp, 65536); |
|
265 | + } |
|
266 | + } |
|
267 | + fclose($fp); |
|
268 | + } |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Render an error as an image. |
273 | 273 | */ |
274 | 274 | protected function renderError() { |
275 | - $error = I18N::translate('The media file was not found in this family tree.'); |
|
275 | + $error = I18N::translate('The media file was not found in this family tree.'); |
|
276 | 276 | |
277 | - $width = (mb_strlen($error) * 6.5 + 50) * 1.15; |
|
278 | - $height = 60; |
|
279 | - $im = imagecreatetruecolor($width, $height); /* Create a black image */ |
|
280 | - $bgc = imagecolorallocate($im, 255, 255, 255); /* set background color */ |
|
281 | - imagefilledrectangle($im, 2, 2, $width - 4, $height - 4, $bgc); /* create a rectangle, leaving 2 px border */ |
|
277 | + $width = (mb_strlen($error) * 6.5 + 50) * 1.15; |
|
278 | + $height = 60; |
|
279 | + $im = imagecreatetruecolor($width, $height); /* Create a black image */ |
|
280 | + $bgc = imagecolorallocate($im, 255, 255, 255); /* set background color */ |
|
281 | + imagefilledrectangle($im, 2, 2, $width - 4, $height - 4, $bgc); /* create a rectangle, leaving 2 px border */ |
|
282 | 282 | |
283 | - $this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, 'top', 'left'); |
|
283 | + $this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, 'top', 'left'); |
|
284 | 284 | |
285 | - http_response_code(404); |
|
286 | - header('Content-Type: image/png'); |
|
287 | - imagepng($im); |
|
288 | - imagedestroy($im); |
|
285 | + http_response_code(404); |
|
286 | + header('Content-Type: image/png'); |
|
287 | + imagepng($im); |
|
288 | + imagedestroy($im); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -297,25 +297,25 @@ discard block |
||
297 | 297 | */ |
298 | 298 | protected function applyWatermark($im) { |
299 | 299 | |
300 | - // text to watermark with |
|
301 | - if(method_exists($this->media, 'getWatermarkText')) { |
|
302 | - $word1_text = $this->media->getWatermarkText(); |
|
303 | - } |
|
304 | - else { |
|
305 | - $word1_text = $this->media->getTitle(); |
|
306 | - } |
|
300 | + // text to watermark with |
|
301 | + if(method_exists($this->media, 'getWatermarkText')) { |
|
302 | + $word1_text = $this->media->getWatermarkText(); |
|
303 | + } |
|
304 | + else { |
|
305 | + $word1_text = $this->media->getTitle(); |
|
306 | + } |
|
307 | 307 | |
308 | - $this->embedText( |
|
309 | - $im, |
|
310 | - $word1_text, |
|
311 | - $this->font_max_size, |
|
312 | - $this->font_color, |
|
313 | - WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, |
|
314 | - 'top', |
|
315 | - 'left' |
|
316 | - ); |
|
308 | + $this->embedText( |
|
309 | + $im, |
|
310 | + $word1_text, |
|
311 | + $this->font_max_size, |
|
312 | + $this->font_color, |
|
313 | + WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, |
|
314 | + 'top', |
|
315 | + 'left' |
|
316 | + ); |
|
317 | 317 | |
318 | - return ($im); |
|
318 | + return ($im); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -332,94 +332,94 @@ discard block |
||
332 | 332 | */ |
333 | 333 | protected function embedText($im, $text, $maxsize, $color, $font, $vpos, $hpos) { |
334 | 334 | |
335 | - // there are two ways to embed text with PHP |
|
336 | - // (preferred) using GD and FreeType you can embed text using any True Type font |
|
337 | - // (fall back) if that is not available, you can insert basic monospaced text |
|
335 | + // there are two ways to embed text with PHP |
|
336 | + // (preferred) using GD and FreeType you can embed text using any True Type font |
|
337 | + // (fall back) if that is not available, you can insert basic monospaced text |
|
338 | 338 | |
339 | - $col = $this->hexrgb($color); |
|
340 | - $textcolor = imagecolorallocate($im, $col['red'], $col['green'], $col['blue']); |
|
339 | + $col = $this->hexrgb($color); |
|
340 | + $textcolor = imagecolorallocate($im, $col['red'], $col['green'], $col['blue']); |
|
341 | 341 | |
342 | - // make adjustments to settings that imagestring and imagestringup can’t handle |
|
343 | - if (!$this->use_ttf) { |
|
344 | - // imagestringup only writes up, can’t use top2bottom |
|
345 | - if ($hpos === 'top2bottom') { |
|
346 | - $hpos = 'bottom2top'; |
|
347 | - } |
|
348 | - } |
|
342 | + // make adjustments to settings that imagestring and imagestringup can’t handle |
|
343 | + if (!$this->use_ttf) { |
|
344 | + // imagestringup only writes up, can’t use top2bottom |
|
345 | + if ($hpos === 'top2bottom') { |
|
346 | + $hpos = 'bottom2top'; |
|
347 | + } |
|
348 | + } |
|
349 | 349 | |
350 | - $text = I18N::reverseText($text); |
|
351 | - $height = imagesy($im); |
|
352 | - $width = imagesx($im); |
|
353 | - $calc_angle = rad2deg(atan($height / $width)); |
|
354 | - $hypoth = $height / sin(deg2rad($calc_angle)); |
|
350 | + $text = I18N::reverseText($text); |
|
351 | + $height = imagesy($im); |
|
352 | + $width = imagesx($im); |
|
353 | + $calc_angle = rad2deg(atan($height / $width)); |
|
354 | + $hypoth = $height / sin(deg2rad($calc_angle)); |
|
355 | 355 | |
356 | - // vertical and horizontal position of the text |
|
357 | - switch ($vpos) { |
|
358 | - default: |
|
359 | - case 'top': |
|
360 | - $taille = $this->textLength($maxsize, $width, $text); |
|
361 | - $pos_y = $height * 0.15 + $taille; |
|
362 | - $pos_x = $width * 0.15; |
|
363 | - $rotation = 0; |
|
364 | - break; |
|
365 | - case 'middle': |
|
366 | - $taille = $this->textLength($maxsize, $width, $text); |
|
367 | - $pos_y = ($height + $taille) / 2; |
|
368 | - $pos_x = $width * 0.15; |
|
369 | - $rotation = 0; |
|
370 | - break; |
|
371 | - case 'bottom': |
|
372 | - $taille = $this->textLength($maxsize, $width, $text); |
|
373 | - $pos_y = ($height * .85 - $taille); |
|
374 | - $pos_x = $width * 0.15; |
|
375 | - $rotation = 0; |
|
376 | - break; |
|
377 | - case 'across': |
|
378 | - switch ($hpos) { |
|
379 | - default: |
|
380 | - case 'left': |
|
381 | - $taille = $this->textLength($maxsize, $hypoth, $text); |
|
382 | - $pos_y = ($height * .85 - $taille); |
|
383 | - $pos_x = $width * 0.15; |
|
384 | - $rotation = $calc_angle; |
|
385 | - break; |
|
386 | - case 'right': |
|
387 | - $taille = $this->textLength($maxsize, $hypoth, $text); |
|
388 | - $pos_y = ($height * .15 - $taille); |
|
389 | - $pos_x = $width * 0.85; |
|
390 | - $rotation = $calc_angle + 180; |
|
391 | - break; |
|
392 | - case 'top2bottom': |
|
393 | - $taille = $this->textLength($maxsize, $height, $text); |
|
394 | - $pos_y = ($height * .15 - $taille); |
|
395 | - $pos_x = ($width * .90 - $taille); |
|
396 | - $rotation = -90; |
|
397 | - break; |
|
398 | - case 'bottom2top': |
|
399 | - $taille = $this->textLength($maxsize, $height, $text); |
|
400 | - $pos_y = $height * 0.85; |
|
401 | - $pos_x = $width * 0.15; |
|
402 | - $rotation = 90; |
|
403 | - break; |
|
404 | - } |
|
405 | - break; |
|
406 | - } |
|
356 | + // vertical and horizontal position of the text |
|
357 | + switch ($vpos) { |
|
358 | + default: |
|
359 | + case 'top': |
|
360 | + $taille = $this->textLength($maxsize, $width, $text); |
|
361 | + $pos_y = $height * 0.15 + $taille; |
|
362 | + $pos_x = $width * 0.15; |
|
363 | + $rotation = 0; |
|
364 | + break; |
|
365 | + case 'middle': |
|
366 | + $taille = $this->textLength($maxsize, $width, $text); |
|
367 | + $pos_y = ($height + $taille) / 2; |
|
368 | + $pos_x = $width * 0.15; |
|
369 | + $rotation = 0; |
|
370 | + break; |
|
371 | + case 'bottom': |
|
372 | + $taille = $this->textLength($maxsize, $width, $text); |
|
373 | + $pos_y = ($height * .85 - $taille); |
|
374 | + $pos_x = $width * 0.15; |
|
375 | + $rotation = 0; |
|
376 | + break; |
|
377 | + case 'across': |
|
378 | + switch ($hpos) { |
|
379 | + default: |
|
380 | + case 'left': |
|
381 | + $taille = $this->textLength($maxsize, $hypoth, $text); |
|
382 | + $pos_y = ($height * .85 - $taille); |
|
383 | + $pos_x = $width * 0.15; |
|
384 | + $rotation = $calc_angle; |
|
385 | + break; |
|
386 | + case 'right': |
|
387 | + $taille = $this->textLength($maxsize, $hypoth, $text); |
|
388 | + $pos_y = ($height * .15 - $taille); |
|
389 | + $pos_x = $width * 0.85; |
|
390 | + $rotation = $calc_angle + 180; |
|
391 | + break; |
|
392 | + case 'top2bottom': |
|
393 | + $taille = $this->textLength($maxsize, $height, $text); |
|
394 | + $pos_y = ($height * .15 - $taille); |
|
395 | + $pos_x = ($width * .90 - $taille); |
|
396 | + $rotation = -90; |
|
397 | + break; |
|
398 | + case 'bottom2top': |
|
399 | + $taille = $this->textLength($maxsize, $height, $text); |
|
400 | + $pos_y = $height * 0.85; |
|
401 | + $pos_x = $width * 0.15; |
|
402 | + $rotation = 90; |
|
403 | + break; |
|
404 | + } |
|
405 | + break; |
|
406 | + } |
|
407 | 407 | |
408 | - // apply the text |
|
409 | - if ($this->use_ttf) { |
|
410 | - // if imagettftext throws errors, catch them with a custom error handler |
|
411 | - set_error_handler(array($this, 'imageTtfTextErrorHandler')); |
|
412 | - imagettftext($im, $taille, $rotation, $pos_x, $pos_y, $textcolor, $font, $text); |
|
413 | - restore_error_handler(); |
|
414 | - } |
|
415 | - // Don’t use an ‘else’ here since imagettftextErrorHandler may have changed the value of $useTTF from true to false |
|
416 | - if (!$this->use_ttf) { |
|
417 | - if ($rotation !== 90) { |
|
418 | - imagestring($im, 5, $pos_x, $pos_y, $text, $textcolor); |
|
419 | - } else { |
|
420 | - imagestringup($im, 5, $pos_x, $pos_y, $text, $textcolor); |
|
421 | - } |
|
422 | - } |
|
408 | + // apply the text |
|
409 | + if ($this->use_ttf) { |
|
410 | + // if imagettftext throws errors, catch them with a custom error handler |
|
411 | + set_error_handler(array($this, 'imageTtfTextErrorHandler')); |
|
412 | + imagettftext($im, $taille, $rotation, $pos_x, $pos_y, $textcolor, $font, $text); |
|
413 | + restore_error_handler(); |
|
414 | + } |
|
415 | + // Don’t use an ‘else’ here since imagettftextErrorHandler may have changed the value of $useTTF from true to false |
|
416 | + if (!$this->use_ttf) { |
|
417 | + if ($rotation !== 90) { |
|
418 | + imagestring($im, 5, $pos_x, $pos_y, $text, $textcolor); |
|
419 | + } else { |
|
420 | + imagestringup($im, 5, $pos_x, $pos_y, $text, $textcolor); |
|
421 | + } |
|
422 | + } |
|
423 | 423 | |
424 | 424 | } |
425 | 425 | |
@@ -431,53 +431,53 @@ discard block |
||
431 | 431 | */ |
432 | 432 | protected function hexrgb ($hexstr) |
433 | 433 | { |
434 | - $int = hexdec($hexstr); |
|
434 | + $int = hexdec($hexstr); |
|
435 | 435 | |
436 | - return array('red' => 0xFF & ($int >> 0x10), |
|
437 | - 'green' => 0xFF & ($int >> 0x8), |
|
438 | - 'blue' => 0xFF & $int); |
|
436 | + return array('red' => 0xFF & ($int >> 0x10), |
|
437 | + 'green' => 0xFF & ($int >> 0x8), |
|
438 | + 'blue' => 0xFF & $int); |
|
439 | 439 | } |
440 | 440 | |
441 | - /** |
|
442 | - * Generate an approximate length of text, in pixels. |
|
443 | - * |
|
444 | - * @param int $t |
|
445 | - * @param int $mxl |
|
446 | - * @param string $text |
|
447 | - * |
|
448 | - * @return int |
|
449 | - */ |
|
450 | - function textLength($t, $mxl, $text) { |
|
451 | - $taille_c = $t; |
|
452 | - $len = mb_strlen($text); |
|
453 | - while (($taille_c - 2) * $len > $mxl) { |
|
454 | - $taille_c--; |
|
455 | - if ($taille_c == 2) { |
|
456 | - break; |
|
457 | - } |
|
458 | - } |
|
441 | + /** |
|
442 | + * Generate an approximate length of text, in pixels. |
|
443 | + * |
|
444 | + * @param int $t |
|
445 | + * @param int $mxl |
|
446 | + * @param string $text |
|
447 | + * |
|
448 | + * @return int |
|
449 | + */ |
|
450 | + function textLength($t, $mxl, $text) { |
|
451 | + $taille_c = $t; |
|
452 | + $len = mb_strlen($text); |
|
453 | + while (($taille_c - 2) * $len > $mxl) { |
|
454 | + $taille_c--; |
|
455 | + if ($taille_c == 2) { |
|
456 | + break; |
|
457 | + } |
|
458 | + } |
|
459 | 459 | |
460 | - return $taille_c; |
|
461 | - } |
|
460 | + return $taille_c; |
|
461 | + } |
|
462 | 462 | |
463 | - /** |
|
464 | - * imagettftext is the function that is most likely to throw an error |
|
465 | - * use this custom error handler to catch and log it |
|
466 | - * |
|
467 | - * @param int $errno |
|
468 | - * @param string $errstr |
|
469 | - * |
|
470 | - * @return bool |
|
471 | - */ |
|
472 | - function imageTtfTextErrorHandler($errno, $errstr) { |
|
473 | - // log the error |
|
474 | - Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<'); |
|
463 | + /** |
|
464 | + * imagettftext is the function that is most likely to throw an error |
|
465 | + * use this custom error handler to catch and log it |
|
466 | + * |
|
467 | + * @param int $errno |
|
468 | + * @param string $errstr |
|
469 | + * |
|
470 | + * @return bool |
|
471 | + */ |
|
472 | + function imageTtfTextErrorHandler($errno, $errstr) { |
|
473 | + // log the error |
|
474 | + Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<'); |
|
475 | 475 | |
476 | - // change value of useTTF to false so the fallback watermarking can be used. |
|
477 | - $this->use_ttf = false; |
|
476 | + // change value of useTTF to false so the fallback watermarking can be used. |
|
477 | + $this->use_ttf = false; |
|
478 | 478 | |
479 | - return true; |
|
480 | - } |
|
479 | + return true; |
|
480 | + } |
|
481 | 481 | |
482 | 482 | } |
483 | 483 |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @param Media|null $media Reference media object |
71 | 71 | */ |
72 | - public function __construct(Media $media = null){ |
|
72 | + public function __construct(Media $media = null) { |
|
73 | 73 | $this->media = $media; |
74 | 74 | $this->use_ttf = function_exists('imagettftext'); |
75 | 75 | $this->expire_offset = 3600 * 24; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return ImageBuilder |
96 | 96 | */ |
97 | 97 | public function setExpireOffset($expireOffset) { |
98 | - if($expireOffset) $this->expire_offset = $expireOffset; |
|
98 | + if ($expireOffset) $this->expire_offset = $expireOffset; |
|
99 | 99 | return $this; |
100 | 100 | } |
101 | 101 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @return ImageBuilder |
116 | 116 | */ |
117 | 117 | public function setShowWatermark($show_watermark) { |
118 | - if(!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
118 | + if (!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
119 | 119 | return $this; |
120 | 120 | } |
121 | 121 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @return ImageBuilder |
127 | 127 | */ |
128 | 128 | public function setFontMaxSize($font_max_size) { |
129 | - if($font_max_size) $this->font_max_size = $font_max_size; |
|
129 | + if ($font_max_size) $this->font_max_size = $font_max_size; |
|
130 | 130 | return $this; |
131 | 131 | } |
132 | 132 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @return ImageBuilder |
138 | 138 | */ |
139 | 139 | public function setFontColor($font_color) { |
140 | - if($font_color) $this->font_color = $font_color; |
|
140 | + if ($font_color) $this->font_color = $font_color; |
|
141 | 141 | return $this; |
142 | 142 | } |
143 | 143 | |
@@ -148,32 +148,32 @@ discard block |
||
148 | 148 | * @return ImageBuilder |
149 | 149 | */ |
150 | 150 | public function setAsAttachment($is_attachement) { |
151 | - if(is_bool($is_attachement)) $this->as_attachment = $is_attachement; |
|
151 | + if (is_bool($is_attachement)) $this->as_attachment = $is_attachement; |
|
152 | 152 | return $this; |
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
156 | 156 | * Render the image to the output. |
157 | 157 | */ |
158 | - public function render(){ |
|
158 | + public function render() { |
|
159 | 159 | |
160 | 160 | if (!$this->media || !$this->media->canShow()) { |
161 | - Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.')); |
|
161 | + Log::addMediaLog('Image Builder error: >'.I18N::translate('Missing or private media object.')); |
|
162 | 162 | $this->renderError(); |
163 | 163 | } |
164 | 164 | |
165 | 165 | $serverFilename = $this->media->getServerFilename(); |
166 | 166 | |
167 | 167 | if (!file_exists($serverFilename)) { |
168 | - Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<'); |
|
168 | + Log::addMediaLog('Image Builder error: >'.I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<'); |
|
169 | 169 | $this->renderError(); |
170 | 170 | } |
171 | 171 | |
172 | 172 | $mimetype = $this->media->mimeType(); |
173 | 173 | $imgsize = $this->media->getImageAttributes(); |
174 | 174 | $filetime = $this->media->getFiletime(); |
175 | - $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT'; |
|
176 | - $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()) . ' GMT'; |
|
175 | + $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime).' GMT'; |
|
176 | + $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()).' GMT'; |
|
177 | 177 | |
178 | 178 | $type = Functions::isImageTypeSupported($imgsize['ext']); |
179 | 179 | $usewatermark = false; |
@@ -205,10 +205,10 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | // add caching headers. allow browser to cache file, but not proxy |
208 | - header('Last-Modified: ' . $filetimeHeader); |
|
209 | - header('ETag: "' . $etag . '"'); |
|
210 | - header('Expires: ' . $expireHeader); |
|
211 | - header('Cache-Control: max-age=' . $this->getExpireOffset() . ', s-maxage=0, proxy-revalidate'); |
|
208 | + header('Last-Modified: '.$filetimeHeader); |
|
209 | + header('ETag: "'.$etag.'"'); |
|
210 | + header('Expires: '.$expireHeader); |
|
211 | + header('Cache-Control: max-age='.$this->getExpireOffset().', s-maxage=0, proxy-revalidate'); |
|
212 | 212 | |
213 | 213 | // if this file is already in the user’s cache, don’t resend it |
214 | 214 | // first check if the if_modified_since param matches |
@@ -223,13 +223,13 @@ discard block |
||
223 | 223 | |
224 | 224 | // send headers for the image |
225 | 225 | $disposition = $this->as_attachment ? 'attachment' : 'inline'; |
226 | - header('Content-Type: ' . $mimetype); |
|
227 | - header('Content-Disposition: ' . $disposition . '; filename="' . addslashes(basename($this->media->getFilename())) . '"'); |
|
226 | + header('Content-Type: '.$mimetype); |
|
227 | + header('Content-Disposition: '.$disposition.'; filename="'.addslashes(basename($this->media->getFilename())).'"'); |
|
228 | 228 | |
229 | 229 | if ($usewatermark) { |
230 | 230 | // generate the watermarked image |
231 | - $imCreateFunc = 'imagecreatefrom' . $type; |
|
232 | - $imSendFunc = 'image' . $type; |
|
231 | + $imCreateFunc = 'imagecreatefrom'.$type; |
|
232 | + $imSendFunc = 'image'.$type; |
|
233 | 233 | |
234 | 234 | if (function_exists($imCreateFunc) && function_exists($imSendFunc)) { |
235 | 235 | $im = $imCreateFunc($serverFilename); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | return; |
243 | 243 | } else { |
244 | 244 | // this image is defective. log it |
245 | - Log::addMediaLog('Image Builder error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage()); |
|
245 | + Log::addMediaLog('Image Builder error: >'.I18N::translate('This media file is broken and cannot be watermarked.').'< in file >'.$serverFilename.'< memory used: '.memory_get_usage()); |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $filesize = filesize($serverFilename); |
251 | 251 | |
252 | 252 | // set content-length header, send file |
253 | - header('Content-Length: ' . $filesize); |
|
253 | + header('Content-Length: '.$filesize); |
|
254 | 254 | |
255 | 255 | // Some servers disable fpassthru() and readfile() |
256 | 256 | if (function_exists('readfile')) { |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $bgc = imagecolorallocate($im, 255, 255, 255); /* set background color */ |
281 | 281 | imagefilledrectangle($im, 2, 2, $width - 4, $height - 4, $bgc); /* create a rectangle, leaving 2 px border */ |
282 | 282 | |
283 | - $this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, 'top', 'left'); |
|
283 | + $this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT.Config::FONT_DEJAVU_SANS_TTF, 'top', 'left'); |
|
284 | 284 | |
285 | 285 | http_response_code(404); |
286 | 286 | header('Content-Type: image/png'); |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | protected function applyWatermark($im) { |
299 | 299 | |
300 | 300 | // text to watermark with |
301 | - if(method_exists($this->media, 'getWatermarkText')) { |
|
301 | + if (method_exists($this->media, 'getWatermarkText')) { |
|
302 | 302 | $word1_text = $this->media->getWatermarkText(); |
303 | 303 | } |
304 | 304 | else { |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $word1_text, |
311 | 311 | $this->font_max_size, |
312 | 312 | $this->font_color, |
313 | - WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, |
|
313 | + WT_ROOT.Config::FONT_DEJAVU_SANS_TTF, |
|
314 | 314 | 'top', |
315 | 315 | 'left' |
316 | 316 | ); |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | * @param string $hexstr |
430 | 430 | * @return int[] |
431 | 431 | */ |
432 | - protected function hexrgb ($hexstr) |
|
432 | + protected function hexrgb($hexstr) |
|
433 | 433 | { |
434 | 434 | $int = hexdec($hexstr); |
435 | 435 | |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | */ |
472 | 472 | function imageTtfTextErrorHandler($errno, $errstr) { |
473 | 473 | // log the error |
474 | - Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<'); |
|
474 | + Log::addErrorLog('Image Builder error: >'.$errno.'/'.$errstr.'< while processing file >'.$this->media->getServerFilename().'<'); |
|
475 | 475 | |
476 | 476 | // change value of useTTF to false so the fallback watermarking can be used. |
477 | 477 | $this->use_ttf = false; |
@@ -95,7 +95,9 @@ discard block |
||
95 | 95 | * @return ImageBuilder |
96 | 96 | */ |
97 | 97 | public function setExpireOffset($expireOffset) { |
98 | - if($expireOffset) $this->expire_offset = $expireOffset; |
|
98 | + if($expireOffset) { |
|
99 | + $this->expire_offset = $expireOffset; |
|
100 | + } |
|
99 | 101 | return $this; |
100 | 102 | } |
101 | 103 | |
@@ -115,7 +117,9 @@ discard block |
||
115 | 117 | * @return ImageBuilder |
116 | 118 | */ |
117 | 119 | public function setShowWatermark($show_watermark) { |
118 | - if(!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
120 | + if(!is_null($show_watermark)) { |
|
121 | + $this->show_watermark = $show_watermark; |
|
122 | + } |
|
119 | 123 | return $this; |
120 | 124 | } |
121 | 125 | |
@@ -126,7 +130,9 @@ discard block |
||
126 | 130 | * @return ImageBuilder |
127 | 131 | */ |
128 | 132 | public function setFontMaxSize($font_max_size) { |
129 | - if($font_max_size) $this->font_max_size = $font_max_size; |
|
133 | + if($font_max_size) { |
|
134 | + $this->font_max_size = $font_max_size; |
|
135 | + } |
|
130 | 136 | return $this; |
131 | 137 | } |
132 | 138 | |
@@ -137,7 +143,9 @@ discard block |
||
137 | 143 | * @return ImageBuilder |
138 | 144 | */ |
139 | 145 | public function setFontColor($font_color) { |
140 | - if($font_color) $this->font_color = $font_color; |
|
146 | + if($font_color) { |
|
147 | + $this->font_color = $font_color; |
|
148 | + } |
|
141 | 149 | return $this; |
142 | 150 | } |
143 | 151 | |
@@ -148,7 +156,9 @@ discard block |
||
148 | 156 | * @return ImageBuilder |
149 | 157 | */ |
150 | 158 | public function setAsAttachment($is_attachement) { |
151 | - if(is_bool($is_attachement)) $this->as_attachment = $is_attachement; |
|
159 | + if(is_bool($is_attachement)) { |
|
160 | + $this->as_attachment = $is_attachement; |
|
161 | + } |
|
152 | 162 | return $this; |
153 | 163 | } |
154 | 164 | |
@@ -300,8 +310,7 @@ discard block |
||
300 | 310 | // text to watermark with |
301 | 311 | if(method_exists($this->media, 'getWatermarkText')) { |
302 | 312 | $word1_text = $this->media->getWatermarkText(); |
303 | - } |
|
304 | - else { |
|
313 | + } else { |
|
305 | 314 | $word1_text = $this->media->getTitle(); |
306 | 315 | } |
307 | 316 |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | * {@inhericDoc} |
24 | 24 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
25 | 25 | */ |
26 | - protected function renderContent() { |
|
27 | - ?> |
|
26 | + protected function renderContent() { |
|
27 | + ?> |
|
28 | 28 | <div id="maj-sosa-stats-page"> |
29 | 29 | <h2><?php echo $this->data->get('title'); ?></h2> |
30 | 30 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | <?php } ?> |
37 | 37 | |
38 | 38 | <?php if($this->data->get('is_setup')) { |
39 | - $general_stats = $this->data->get('general_stats'); ?> |
|
39 | + $general_stats = $this->data->get('general_stats'); ?> |
|
40 | 40 | <h3><?php echo I18N::translate('General statistics'); ?></h3> |
41 | 41 | <div class="maj-table"> |
42 | 42 | <div class="maj-row"> |
@@ -126,23 +126,23 @@ discard block |
||
126 | 126 | <td class="label" colspan="13"> |
127 | 127 | <?php |
128 | 128 | echo I18N::translate( |
129 | - 'Mean generation depth: %s', |
|
130 | - I18N::plural( |
|
131 | - I18N::translate('%s generation'), |
|
132 | - I18N::translate('%s generations'), |
|
133 | - $this->data->get('mean_gen_depth'), |
|
134 | - I18N::number($this->data->get('mean_gen_depth'),2) |
|
135 | - ) |
|
136 | - ). |
|
129 | + 'Mean generation depth: %s', |
|
130 | + I18N::plural( |
|
131 | + I18N::translate('%s generation'), |
|
132 | + I18N::translate('%s generations'), |
|
133 | + $this->data->get('mean_gen_depth'), |
|
134 | + I18N::number($this->data->get('mean_gen_depth'),2) |
|
135 | + ) |
|
136 | + ). |
|
137 | 137 | ' — ' . |
138 | 138 | I18N::translate( |
139 | - 'Standard deviation: %s', |
|
140 | - I18N::plural( |
|
141 | - I18N::translate('%s generation'), |
|
142 | - I18N::translate('%s generations'), |
|
143 | - $this->data->get('stddev_gen_depth'), |
|
144 | - I18N::number($this->data->get('stddev_gen_depth'),2) |
|
145 | - ) |
|
139 | + 'Standard deviation: %s', |
|
140 | + I18N::plural( |
|
141 | + I18N::translate('%s generation'), |
|
142 | + I18N::translate('%s generations'), |
|
143 | + $this->data->get('stddev_gen_depth'), |
|
144 | + I18N::number($this->data->get('stddev_gen_depth'),2) |
|
145 | + ) |
|
146 | 146 | ); |
147 | 147 | ?> |
148 | 148 | </td> |
@@ -160,13 +160,13 @@ discard block |
||
160 | 160 | <div class="maj-row"> |
161 | 161 | <div class="label"><?= I18N::translate('%s times', I18N::number($count)); ?></div> |
162 | 162 | <div class="value"><?php |
163 | - echo implode( |
|
164 | - I18N::$list_separator, |
|
165 | - array_map(function(Individual $indi) { |
|
166 | - return '<a href="'. $indi->getHtmlUrl(). '">'. $indi->getFullName() . ' ' . $indi->getSexImage() . '</a>'; |
|
167 | - }, $indis) |
|
168 | - ); |
|
169 | - ?></div> |
|
163 | + echo implode( |
|
164 | + I18N::$list_separator, |
|
165 | + array_map(function(Individual $indi) { |
|
166 | + return '<a href="'. $indi->getHtmlUrl(). '">'. $indi->getFullName() . ' ' . $indi->getSexImage() . '</a>'; |
|
167 | + }, $indis) |
|
168 | + ); |
|
169 | + ?></div> |
|
170 | 170 | </div> |
171 | 171 | <?php } ?> |
172 | 172 | </div> |
@@ -187,6 +187,6 @@ discard block |
||
187 | 187 | <?php } else { ?> |
188 | 188 | <div class="center warning"><?php echo I18N::translate('No Sosa root individual has been defined.'); ?></div> |
189 | 189 | <?php } |
190 | - } |
|
190 | + } |
|
191 | 191 | |
192 | 192 | } |
193 | 193 | \ No newline at end of file |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | <?php |
32 | 32 | /** @var \Fisharebest\Webtrees\Individual $root_indi */ |
33 | 33 | $root_indi = $this->data->get('root_indi'); |
34 | - if($root_indi !== null && $root_indi->canShowName()) { ?> |
|
34 | + if ($root_indi !== null && $root_indi->canShowName()) { ?> |
|
35 | 35 | <h4 class="center"><?= I18N::translate('%s: %s', I18N::translate('Root individual'), $root_indi->getFullName()); ?><h4> |
36 | 36 | <?php } ?> |
37 | 37 | |
38 | - <?php if($this->data->get('is_setup')) { |
|
38 | + <?php if ($this->data->get('is_setup')) { |
|
39 | 39 | $general_stats = $this->data->get('general_stats'); ?> |
40 | 40 | <h3><?php echo I18N::translate('General statistics'); ?></h3> |
41 | 41 | <div class="maj-table"> |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | </div> |
58 | 58 | <div class="maj-row"> |
59 | 59 | <div class="label"><?php echo I18N::translate('Generation mean duration'); ?></div> |
60 | - <div class="value"><?php echo I18N::plural('%s year', '%s years', $general_stats['mean_gen_time'], I18N::number($general_stats['mean_gen_time'], 1)); ?></div> |
|
60 | + <div class="value"><?php echo I18N::plural('%s year', '%s years', $general_stats['mean_gen_time'], I18N::number($general_stats['mean_gen_time'], 1)); ?></div> |
|
61 | 61 | </div> |
62 | 62 | </div> |
63 | 63 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | </tr> |
98 | 98 | </thead> |
99 | 99 | <tbody> |
100 | - <?php foreach($this->data->get('generation_stats') as $gen => $row) { ?> |
|
100 | + <?php foreach ($this->data->get('generation_stats') as $gen => $row) { ?> |
|
101 | 101 | <tr class="maj-row"> |
102 | 102 | <td class="label"><?php echo I18N::translate('<strong>G%d</strong>', $gen); ?></td> |
103 | 103 | <td class="label"><?php echo I18N::translate('%1$s <> %2$s', $row['gen_min_birth'], $row['gen_max_birth']); ?></td> |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | <td class="value"><?php echo I18N::number($row['different']); ?></td> |
112 | 112 | <td class="value left percent_container"> |
113 | 113 | <div class="percent_frame"> |
114 | - <div class="percent_cell" style="width:<?php echo 100*$row['perc_different'] ?>%;"> |
|
114 | + <div class="percent_cell" style="width:<?php echo 100 * $row['perc_different'] ?>%;"> |
|
115 | 115 | <?php echo I18N::percentage($row['perc_different']); ?> |
116 | 116 | </div> |
117 | 117 | </div> |
@@ -131,17 +131,17 @@ discard block |
||
131 | 131 | I18N::translate('%s generation'), |
132 | 132 | I18N::translate('%s generations'), |
133 | 133 | $this->data->get('mean_gen_depth'), |
134 | - I18N::number($this->data->get('mean_gen_depth'),2) |
|
134 | + I18N::number($this->data->get('mean_gen_depth'), 2) |
|
135 | 135 | ) |
136 | 136 | ). |
137 | - ' — ' . |
|
137 | + ' — '. |
|
138 | 138 | I18N::translate( |
139 | 139 | 'Standard deviation: %s', |
140 | 140 | I18N::plural( |
141 | 141 | I18N::translate('%s generation'), |
142 | 142 | I18N::translate('%s generations'), |
143 | 143 | $this->data->get('stddev_gen_depth'), |
144 | - I18N::number($this->data->get('stddev_gen_depth'),2) |
|
144 | + I18N::number($this->data->get('stddev_gen_depth'), 2) |
|
145 | 145 | ) |
146 | 146 | ); |
147 | 147 | ?> |
@@ -153,17 +153,17 @@ discard block |
||
153 | 153 | |
154 | 154 | <?php |
155 | 155 | $top10_multi_ancestors = $this->data->get('top10multiancestors'); |
156 | - if(count($top10_multi_ancestors) > 0) { ?> |
|
156 | + if (count($top10_multi_ancestors) > 0) { ?> |
|
157 | 157 | <h3><?= I18N::translate('Most duplicated root Sosa ancestors'); ?></h3> |
158 | 158 | <div class="maj-table"> |
159 | - <?php foreach($top10_multi_ancestors as $count => $indis) { ?> |
|
159 | + <?php foreach ($top10_multi_ancestors as $count => $indis) { ?> |
|
160 | 160 | <div class="maj-row"> |
161 | 161 | <div class="label"><?= I18N::translate('%s times', I18N::number($count)); ?></div> |
162 | 162 | <div class="value"><?php |
163 | 163 | echo implode( |
164 | 164 | I18N::$list_separator, |
165 | 165 | array_map(function(Individual $indi) { |
166 | - return '<a href="'. $indi->getHtmlUrl(). '">'. $indi->getFullName() . ' ' . $indi->getSexImage() . '</a>'; |
|
166 | + return '<a href="'.$indi->getHtmlUrl().'">'.$indi->getFullName().' '.$indi->getSexImage().'</a>'; |
|
167 | 167 | }, $indis) |
168 | 168 | ); |
169 | 169 | ?></div> |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | |
175 | 175 | <h3><?php echo I18N::translate('Known Sosa ancestors\' family dispersion'); ?></h3> |
176 | 176 | <div class="center"> |
177 | - <?php echo $this->data->get('chart_img_g2') ?: '' ; ?> |
|
178 | - <?php echo $this->data->get('chart_img_g3') ?: '' ; ?> |
|
177 | + <?php echo $this->data->get('chart_img_g2') ?: ''; ?> |
|
178 | + <?php echo $this->data->get('chart_img_g3') ?: ''; ?> |
|
179 | 179 | <!-- <canvas id="chart_ancestors_g2" width="300" height="300"></canvas> --> |
180 | 180 | </div> |
181 | 181 | |
182 | 182 | <h3><?php echo I18N::translate('Mean generation depth by grandparents'); ?></h3> |
183 | 183 | <div class="center"> |
184 | - <?php echo $this->data->get('chart_img_gendepth3') ?: '' ; ?> |
|
184 | + <?php echo $this->data->get('chart_img_gendepth3') ?: ''; ?> |
|
185 | 185 | </div> |
186 | 186 | |
187 | 187 | <?php } else { ?> |
@@ -22,13 +22,13 @@ |
||
22 | 22 | public function upgrade() { |
23 | 23 | |
24 | 24 | Database::exec( |
25 | - 'ALTER TABLE `##maj_sosa`' . |
|
26 | - ' ADD COLUMN majs_birth_year_est SMALLINT NULL AFTER majs_birth_year,' . |
|
27 | - ' ADD COLUMN majs_death_year_est SMALLINT NULL AFTER majs_death_year' |
|
25 | + 'ALTER TABLE `##maj_sosa`' . |
|
26 | + ' ADD COLUMN majs_birth_year_est SMALLINT NULL AFTER majs_birth_year,' . |
|
27 | + ' ADD COLUMN majs_death_year_est SMALLINT NULL AFTER majs_death_year' |
|
28 | 28 | ); |
29 | 29 | |
30 | 30 | Database::exec( |
31 | - 'DELETE FROM `##maj_sosa`' |
|
31 | + 'DELETE FROM `##maj_sosa`' |
|
32 | 32 | ); |
33 | 33 | } |
34 | 34 | } |
@@ -22,8 +22,8 @@ |
||
22 | 22 | public function upgrade() { |
23 | 23 | |
24 | 24 | Database::exec( |
25 | - 'ALTER TABLE `##maj_sosa`' . |
|
26 | - ' ADD COLUMN majs_birth_year_est SMALLINT NULL AFTER majs_birth_year,' . |
|
25 | + 'ALTER TABLE `##maj_sosa`'. |
|
26 | + ' ADD COLUMN majs_birth_year_est SMALLINT NULL AFTER majs_birth_year,'. |
|
27 | 27 | ' ADD COLUMN majs_death_year_est SMALLINT NULL AFTER majs_death_year' |
28 | 28 | ); |
29 | 29 |
@@ -93,8 +93,12 @@ discard block |
||
93 | 93 | foreach($stats_gen as $gen => $tab){ |
94 | 94 | $genY1= I18N::translate('-'); |
95 | 95 | $genY2= I18N::translate('-'); |
96 | - if($tab['firstBirth']>0) $genY1=$tab['firstEstimatedBirth']; |
|
97 | - if($tab['lastBirth']>0) $genY2=$tab['lastEstimatedBirth']; |
|
96 | + if($tab['firstBirth']>0) { |
|
97 | + $genY1=$tab['firstEstimatedBirth']; |
|
98 | + } |
|
99 | + if($tab['lastBirth']>0) { |
|
100 | + $genY2=$tab['lastEstimatedBirth']; |
|
101 | + } |
|
98 | 102 | $total_theoretical += $gen_theoretical; |
99 | 103 | $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical); |
100 | 104 | $missing=2*$prev_known - $tab['sosaCount']; |
@@ -169,7 +173,9 @@ discard block |
||
169 | 173 | private function htmlAncestorDispersionG2() |
170 | 174 | { |
171 | 175 | $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2); |
172 | - if(count($ancestorsDispGen2) == 0) return; |
|
176 | + if(count($ancestorsDispGen2) == 0) { |
|
177 | + return; |
|
178 | + } |
|
173 | 179 | |
174 | 180 | $size = '600x300'; |
175 | 181 | |
@@ -251,7 +257,9 @@ discard block |
||
251 | 257 | */ |
252 | 258 | private function htmlAncestorGenDepthG3() { |
253 | 259 | $ancestorsGenDepth3 = $this->sosa_provider->getGenerationDepthStatsAtGen(3); |
254 | - if(count($ancestorsGenDepth3) == 0) return; |
|
260 | + if(count($ancestorsGenDepth3) == 0) { |
|
261 | + return; |
|
262 | + } |
|
255 | 263 | |
256 | 264 | $ancestors = array(); |
257 | 265 | $chd_mean = array(); |
@@ -262,8 +270,7 @@ discard block |
||
262 | 270 | if($ancestor !== null && $ancestor->canShowName()) { |
263 | 271 | $tmp = $ancestor->getAllNames(); |
264 | 272 | $ancestors[] = Filter::escapeUrl($tmp[$ancestor->getPrimaryName()]['fullNN']); |
265 | - } |
|
266 | - else { |
|
273 | + } else { |
|
267 | 274 | $ancestors[] = I18N::translate('Sosa %s', I18N::number($sosa)); |
268 | 275 | } |
269 | 276 | $chd_mean[] = $genDepthStat['mean_gen_depth']; |
@@ -28,279 +28,279 @@ |
||
28 | 28 | */ |
29 | 29 | class SosaStatsController extends MvcController |
30 | 30 | { |
31 | - /** |
|
32 | - * Sosa Provider for the controller |
|
33 | - * @var SosaProvider $sosa_provider |
|
34 | - */ |
|
35 | - protected $sosa_provider; |
|
31 | + /** |
|
32 | + * Sosa Provider for the controller |
|
33 | + * @var SosaProvider $sosa_provider |
|
34 | + */ |
|
35 | + protected $sosa_provider; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor for SosaStatsController |
|
39 | - * @param AbstractModule $module |
|
40 | - */ |
|
41 | - public function __construct(AbstractModule $module) { |
|
42 | - parent::__construct($module); |
|
37 | + /** |
|
38 | + * Constructor for SosaStatsController |
|
39 | + * @param AbstractModule $module |
|
40 | + */ |
|
41 | + public function __construct(AbstractModule $module) { |
|
42 | + parent::__construct($module); |
|
43 | 43 | |
44 | - $this->sosa_provider = new SosaProvider(Globals::getTree(), Auth::user()); |
|
45 | - } |
|
44 | + $this->sosa_provider = new SosaProvider(Globals::getTree(), Auth::user()); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Pages |
|
49 | - */ |
|
47 | + /** |
|
48 | + * Pages |
|
49 | + */ |
|
50 | 50 | |
51 | - /** |
|
52 | - * SosaStats@index |
|
53 | - */ |
|
54 | - public function index() { |
|
55 | - $wt_tree = Globals::getTree(); |
|
56 | - $controller = new PageController(); |
|
57 | - $controller |
|
58 | - ->setPageTitle(I18N::translate('Sosa Statistics')) |
|
59 | - ->addInlineJavascript('$(".help_tooltip").tooltip();') |
|
60 | - ; |
|
51 | + /** |
|
52 | + * SosaStats@index |
|
53 | + */ |
|
54 | + public function index() { |
|
55 | + $wt_tree = Globals::getTree(); |
|
56 | + $controller = new PageController(); |
|
57 | + $controller |
|
58 | + ->setPageTitle(I18N::translate('Sosa Statistics')) |
|
59 | + ->addInlineJavascript('$(".help_tooltip").tooltip();') |
|
60 | + ; |
|
61 | 61 | |
62 | - $view_bag = new ViewBag(); |
|
63 | - $view_bag->set('title', $controller->getPageTitle()); |
|
64 | - $view_bag->set('is_setup', false); |
|
62 | + $view_bag = new ViewBag(); |
|
63 | + $view_bag->set('title', $controller->getPageTitle()); |
|
64 | + $view_bag->set('is_setup', false); |
|
65 | 65 | |
66 | - if($this->sosa_provider->isSetup()) { |
|
67 | - $view_bag->set('is_setup', true); |
|
66 | + if($this->sosa_provider->isSetup()) { |
|
67 | + $view_bag->set('is_setup', true); |
|
68 | 68 | |
69 | - $view_bag->set('root_indi', $this->sosa_provider->getRootIndi()); |
|
69 | + $view_bag->set('root_indi', $this->sosa_provider->getRootIndi()); |
|
70 | 70 | |
71 | - $sosaCount = $this->sosa_provider->getSosaCount(); |
|
72 | - $diffSosaCount = $this->sosa_provider->getDifferentSosaCount(); |
|
71 | + $sosaCount = $this->sosa_provider->getSosaCount(); |
|
72 | + $diffSosaCount = $this->sosa_provider->getDifferentSosaCount(); |
|
73 | 73 | |
74 | - $general_stats = array( |
|
75 | - 'sosa_count' => $sosaCount, |
|
76 | - 'distinct_count' => $diffSosaCount, |
|
77 | - 'sosa_rate' => Functions::safeDivision($diffSosaCount, $this->sosa_provider->getTotalIndividuals()), |
|
78 | - 'pedi_collapse' => 1 - Functions::safeDivision($diffSosaCount, $sosaCount), |
|
79 | - 'mean_gen_time' => $this->sosa_provider->getMeanGenerationTime() |
|
80 | - ); |
|
81 | - $view_bag->set('general_stats', $general_stats); |
|
74 | + $general_stats = array( |
|
75 | + 'sosa_count' => $sosaCount, |
|
76 | + 'distinct_count' => $diffSosaCount, |
|
77 | + 'sosa_rate' => Functions::safeDivision($diffSosaCount, $this->sosa_provider->getTotalIndividuals()), |
|
78 | + 'pedi_collapse' => 1 - Functions::safeDivision($diffSosaCount, $sosaCount), |
|
79 | + 'mean_gen_time' => $this->sosa_provider->getMeanGenerationTime() |
|
80 | + ); |
|
81 | + $view_bag->set('general_stats', $general_stats); |
|
82 | 82 | |
83 | - $stats_gen = $this->sosa_provider->getStatisticsByGeneration(); |
|
84 | - $view_bag->set('missinganc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList@missing&ged='.$wt_tree->getNameUrl().'&gen='); |
|
85 | - $view_bag->set('sosaanc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList&ged='.$wt_tree->getNameUrl().'&gen='); |
|
83 | + $stats_gen = $this->sosa_provider->getStatisticsByGeneration(); |
|
84 | + $view_bag->set('missinganc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList@missing&ged='.$wt_tree->getNameUrl().'&gen='); |
|
85 | + $view_bag->set('sosaanc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList&ged='.$wt_tree->getNameUrl().'&gen='); |
|
86 | 86 | |
87 | - $gen_theoretical=1; |
|
88 | - $total_theoretical=0; |
|
89 | - $prev_diff=0; |
|
90 | - $prev_known=0.5; |
|
91 | - $generation_stats = array(); |
|
87 | + $gen_theoretical=1; |
|
88 | + $total_theoretical=0; |
|
89 | + $prev_diff=0; |
|
90 | + $prev_known=0.5; |
|
91 | + $generation_stats = array(); |
|
92 | 92 | |
93 | - foreach($stats_gen as $gen => $tab){ |
|
94 | - $genY1= I18N::translate('-'); |
|
95 | - $genY2= I18N::translate('-'); |
|
96 | - if($tab['firstBirth']>0) $genY1=$tab['firstEstimatedBirth']; |
|
97 | - if($tab['lastBirth']>0) $genY2=$tab['lastEstimatedBirth']; |
|
98 | - $total_theoretical += $gen_theoretical; |
|
99 | - $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical); |
|
100 | - $missing=2*$prev_known - $tab['sosaCount']; |
|
101 | - $gen_diff=$tab['diffSosaTotalCount']-$prev_diff; |
|
93 | + foreach($stats_gen as $gen => $tab){ |
|
94 | + $genY1= I18N::translate('-'); |
|
95 | + $genY2= I18N::translate('-'); |
|
96 | + if($tab['firstBirth']>0) $genY1=$tab['firstEstimatedBirth']; |
|
97 | + if($tab['lastBirth']>0) $genY2=$tab['lastEstimatedBirth']; |
|
98 | + $total_theoretical += $gen_theoretical; |
|
99 | + $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical); |
|
100 | + $missing=2*$prev_known - $tab['sosaCount']; |
|
101 | + $gen_diff=$tab['diffSosaTotalCount']-$prev_diff; |
|
102 | 102 | |
103 | - $generation_stats[$gen] = array( |
|
104 | - 'gen_min_birth' => $genY1, |
|
105 | - 'gen_max_birth' => $genY2, |
|
106 | - 'theoretical' => $gen_theoretical, |
|
107 | - 'known' => $tab['sosaCount'], |
|
108 | - 'perc_known' => $perc_sosa_count_theor, |
|
109 | - 'missing' => $missing, |
|
110 | - 'perc_missing' => 1-Functions::safeDivision($tab['sosaCount'], 2*$prev_known), |
|
111 | - 'total_known' => $tab['sosaTotalCount'], |
|
112 | - 'perc_total_known' => Functions::safeDivision($tab['sosaTotalCount'], $total_theoretical), |
|
113 | - 'different' => $gen_diff, |
|
114 | - 'perc_different' => Functions::safeDivision($gen_diff, $tab['sosaCount']), |
|
115 | - 'total_different' => $tab['diffSosaTotalCount'], |
|
116 | - 'pedi_collapse' => 1 - Functions::safeDivision($tab['diffSosaTotalCount'], $tab['sosaTotalCount']) |
|
117 | - ); |
|
103 | + $generation_stats[$gen] = array( |
|
104 | + 'gen_min_birth' => $genY1, |
|
105 | + 'gen_max_birth' => $genY2, |
|
106 | + 'theoretical' => $gen_theoretical, |
|
107 | + 'known' => $tab['sosaCount'], |
|
108 | + 'perc_known' => $perc_sosa_count_theor, |
|
109 | + 'missing' => $missing, |
|
110 | + 'perc_missing' => 1-Functions::safeDivision($tab['sosaCount'], 2*$prev_known), |
|
111 | + 'total_known' => $tab['sosaTotalCount'], |
|
112 | + 'perc_total_known' => Functions::safeDivision($tab['sosaTotalCount'], $total_theoretical), |
|
113 | + 'different' => $gen_diff, |
|
114 | + 'perc_different' => Functions::safeDivision($gen_diff, $tab['sosaCount']), |
|
115 | + 'total_different' => $tab['diffSosaTotalCount'], |
|
116 | + 'pedi_collapse' => 1 - Functions::safeDivision($tab['diffSosaTotalCount'], $tab['sosaTotalCount']) |
|
117 | + ); |
|
118 | 118 | |
119 | - $gen_theoretical = $gen_theoretical * 2; |
|
120 | - $prev_known=$tab['sosaCount']; |
|
121 | - $prev_diff=$tab['diffSosaTotalCount']; |
|
122 | - } |
|
119 | + $gen_theoretical = $gen_theoretical * 2; |
|
120 | + $prev_known=$tab['sosaCount']; |
|
121 | + $prev_diff=$tab['diffSosaTotalCount']; |
|
122 | + } |
|
123 | 123 | |
124 | - $view_bag->set('generation_stats', $generation_stats); |
|
124 | + $view_bag->set('generation_stats', $generation_stats); |
|
125 | 125 | |
126 | - $gen_depth_stats = $this->sosa_provider->getGenerationDepthStatsAtGen(1); |
|
127 | - $view_bag->set('mean_gen_depth', count($gen_depth_stats) > 0 ? $gen_depth_stats[1]['mean_gen_depth'] : 0); |
|
128 | - $view_bag->set('stddev_gen_depth', count($gen_depth_stats) > 0 ? $gen_depth_stats[1]['stddev_gen_depth'] : 0); |
|
126 | + $gen_depth_stats = $this->sosa_provider->getGenerationDepthStatsAtGen(1); |
|
127 | + $view_bag->set('mean_gen_depth', count($gen_depth_stats) > 0 ? $gen_depth_stats[1]['mean_gen_depth'] : 0); |
|
128 | + $view_bag->set('stddev_gen_depth', count($gen_depth_stats) > 0 ? $gen_depth_stats[1]['stddev_gen_depth'] : 0); |
|
129 | 129 | |
130 | - $view_bag->set('top10multiancestors', $this->getTop10Ancestors()); |
|
130 | + $view_bag->set('top10multiancestors', $this->getTop10Ancestors()); |
|
131 | 131 | |
132 | - $view_bag->set('chart_img_g2', $this->htmlAncestorDispersionG2()); |
|
133 | - $view_bag->set('chart_img_g3', $this->htmlAncestorDispersionG3()); |
|
132 | + $view_bag->set('chart_img_g2', $this->htmlAncestorDispersionG2()); |
|
133 | + $view_bag->set('chart_img_g3', $this->htmlAncestorDispersionG3()); |
|
134 | 134 | |
135 | - $view_bag->set('chart_img_gendepth3', $this->htmlAncestorGenDepthG3()); |
|
136 | - //$view_bag->set('mean_gen_depth_gen3_stats', $this->sosa_provider->getMeanGeneratuonDepthAndDeviationAtGen(3)); |
|
137 | - } |
|
135 | + $view_bag->set('chart_img_gendepth3', $this->htmlAncestorGenDepthG3()); |
|
136 | + //$view_bag->set('mean_gen_depth_gen3_stats', $this->sosa_provider->getMeanGeneratuonDepthAndDeviationAtGen(3)); |
|
137 | + } |
|
138 | 138 | |
139 | - ViewFactory::make('SosaStats', $this, $controller, $view_bag)->render(); |
|
140 | - } |
|
139 | + ViewFactory::make('SosaStats', $this, $controller, $view_bag)->render(); |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * Return an array of the top 10 of ancestor appearing multiple times, grouped by the number of occurrences. |
|
144 | - * The key is the number of appearance, and the value contains the list of Inidvidual |
|
145 | - * |
|
146 | - * @return array Top 10 ancestors with count |
|
147 | - */ |
|
148 | - private function getTop10Ancestors() |
|
149 | - { |
|
150 | - $top10multiancestors = $this->sosa_provider->getTopMultiSosaAncestorsNoTies(10); |
|
151 | - $top10ancestors = array(); |
|
152 | - if($top10multiancestors !== null && count($top10multiancestors)) { |
|
153 | - foreach($top10multiancestors as $pid => $count) { |
|
154 | - $indi = Individual::getInstance($pid, $this->sosa_provider->getTree()); |
|
155 | - if($indi !== null && $indi->canShowName()) { |
|
156 | - array_key_exists($count, $top10ancestors) ? |
|
157 | - $top10ancestors[$count][] = $indi: |
|
158 | - $top10ancestors[$count] = array($count => $indi); |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
162 | - return $top10ancestors; |
|
163 | - } |
|
142 | + /** |
|
143 | + * Return an array of the top 10 of ancestor appearing multiple times, grouped by the number of occurrences. |
|
144 | + * The key is the number of appearance, and the value contains the list of Inidvidual |
|
145 | + * |
|
146 | + * @return array Top 10 ancestors with count |
|
147 | + */ |
|
148 | + private function getTop10Ancestors() |
|
149 | + { |
|
150 | + $top10multiancestors = $this->sosa_provider->getTopMultiSosaAncestorsNoTies(10); |
|
151 | + $top10ancestors = array(); |
|
152 | + if($top10multiancestors !== null && count($top10multiancestors)) { |
|
153 | + foreach($top10multiancestors as $pid => $count) { |
|
154 | + $indi = Individual::getInstance($pid, $this->sosa_provider->getTree()); |
|
155 | + if($indi !== null && $indi->canShowName()) { |
|
156 | + array_key_exists($count, $top10ancestors) ? |
|
157 | + $top10ancestors[$count][] = $indi: |
|
158 | + $top10ancestors[$count] = array($count => $indi); |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | + return $top10ancestors; |
|
163 | + } |
|
164 | 164 | |
165 | - /** |
|
166 | - * Returns HTML code for a graph showing the dispersion of ancestors across father & mother |
|
167 | - * @return string HTML code |
|
168 | - */ |
|
169 | - private function htmlAncestorDispersionG2() |
|
170 | - { |
|
171 | - $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2); |
|
172 | - if(count($ancestorsDispGen2) == 0) return; |
|
165 | + /** |
|
166 | + * Returns HTML code for a graph showing the dispersion of ancestors across father & mother |
|
167 | + * @return string HTML code |
|
168 | + */ |
|
169 | + private function htmlAncestorDispersionG2() |
|
170 | + { |
|
171 | + $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2); |
|
172 | + if(count($ancestorsDispGen2) == 0) return; |
|
173 | 173 | |
174 | - $size = '600x300'; |
|
174 | + $size = '600x300'; |
|
175 | 175 | |
176 | - $total = array_sum($ancestorsDispGen2); |
|
177 | - $father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; |
|
178 | - $father = array ( |
|
179 | - 'color' => '84beff', |
|
180 | - 'count' => $father_count, |
|
181 | - 'perc' => Functions::safeDivision($father_count, $total), |
|
182 | - 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat') |
|
183 | - ); |
|
184 | - $mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; |
|
185 | - $mother = array ( |
|
186 | - 'color' => 'ffd1dc', |
|
187 | - 'count' => $mother_count, |
|
188 | - 'perc' => Functions::safeDivision($mother_count, $total), |
|
189 | - 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot') |
|
190 | - ); |
|
191 | - $shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
|
192 | - $shared = array ( |
|
193 | - 'color' => '777777', |
|
194 | - 'count' => $shared_count, |
|
195 | - 'perc' => Functions::safeDivision($shared_count, $total), |
|
196 | - 'name' => I18N::translate('Shared') |
|
197 | - ); |
|
176 | + $total = array_sum($ancestorsDispGen2); |
|
177 | + $father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; |
|
178 | + $father = array ( |
|
179 | + 'color' => '84beff', |
|
180 | + 'count' => $father_count, |
|
181 | + 'perc' => Functions::safeDivision($father_count, $total), |
|
182 | + 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat') |
|
183 | + ); |
|
184 | + $mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; |
|
185 | + $mother = array ( |
|
186 | + 'color' => 'ffd1dc', |
|
187 | + 'count' => $mother_count, |
|
188 | + 'perc' => Functions::safeDivision($mother_count, $total), |
|
189 | + 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot') |
|
190 | + ); |
|
191 | + $shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
|
192 | + $shared = array ( |
|
193 | + 'color' => '777777', |
|
194 | + 'count' => $shared_count, |
|
195 | + 'perc' => Functions::safeDivision($shared_count, $total), |
|
196 | + 'name' => I18N::translate('Shared') |
|
197 | + ); |
|
198 | 198 | |
199 | - $chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc'])); |
|
200 | - $chart_title = I18N::translate('Known Sosa ancestors\' dispersion'); |
|
201 | - $chl = |
|
202 | - $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' . |
|
203 | - $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' . |
|
204 | - $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1); |
|
205 | - return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$father['color']},{$shared['color']},{$mother['color']}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
206 | - } |
|
199 | + $chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc'])); |
|
200 | + $chart_title = I18N::translate('Known Sosa ancestors\' dispersion'); |
|
201 | + $chl = |
|
202 | + $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' . |
|
203 | + $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' . |
|
204 | + $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1); |
|
205 | + return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$father['color']},{$shared['color']},{$mother['color']}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
206 | + } |
|
207 | 207 | |
208 | - /** |
|
209 | - * Returns HTML code for a graph showing the dispersion of ancestors across grand-parents |
|
210 | - * @return string HTML code |
|
211 | - */ |
|
212 | - private function htmlAncestorDispersionG3() |
|
213 | - { |
|
214 | - $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(3); |
|
208 | + /** |
|
209 | + * Returns HTML code for a graph showing the dispersion of ancestors across grand-parents |
|
210 | + * @return string HTML code |
|
211 | + */ |
|
212 | + private function htmlAncestorDispersionG3() |
|
213 | + { |
|
214 | + $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(3); |
|
215 | 215 | |
216 | - $size = '700x300'; |
|
216 | + $size = '700x300'; |
|
217 | 217 | |
218 | - $color_motmot = 'ffd1dc'; |
|
219 | - $color_motfat = 'b998a0'; |
|
220 | - $color_fatfat = '577292'; |
|
221 | - $color_fatmot = '84beff'; |
|
222 | - $color_shared = '777777'; |
|
218 | + $color_motmot = 'ffd1dc'; |
|
219 | + $color_motfat = 'b998a0'; |
|
220 | + $color_fatfat = '577292'; |
|
221 | + $color_fatmot = '84beff'; |
|
222 | + $color_shared = '777777'; |
|
223 | 223 | |
224 | - $total_fatfat = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; |
|
225 | - $total_fatmot = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; |
|
226 | - $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0; |
|
227 | - $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0; |
|
228 | - $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
|
229 | - $total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha; |
|
224 | + $total_fatfat = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; |
|
225 | + $total_fatmot = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; |
|
226 | + $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0; |
|
227 | + $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0; |
|
228 | + $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
|
229 | + $total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha; |
|
230 | 230 | |
231 | - $chd = $this->arrayToExtendedEncoding(array( |
|
232 | - 4095 * Functions::safeDivision($total_fatfat, $total), |
|
233 | - 4095 * Functions::safeDivision($total_fatmot, $total), |
|
234 | - 4095 * Functions::safeDivision($total_sha, $total), |
|
235 | - 4095 * Functions::safeDivision($total_motfat, $total), |
|
236 | - 4095 * Functions::safeDivision($total_motmot, $total) |
|
237 | - )); |
|
238 | - $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3'); |
|
239 | - $chl = |
|
240 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' . |
|
241 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' . |
|
242 | - I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' . |
|
243 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' . |
|
244 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1); |
|
245 | - return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
246 | - } |
|
231 | + $chd = $this->arrayToExtendedEncoding(array( |
|
232 | + 4095 * Functions::safeDivision($total_fatfat, $total), |
|
233 | + 4095 * Functions::safeDivision($total_fatmot, $total), |
|
234 | + 4095 * Functions::safeDivision($total_sha, $total), |
|
235 | + 4095 * Functions::safeDivision($total_motfat, $total), |
|
236 | + 4095 * Functions::safeDivision($total_motmot, $total) |
|
237 | + )); |
|
238 | + $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3'); |
|
239 | + $chl = |
|
240 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' . |
|
241 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' . |
|
242 | + I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' . |
|
243 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' . |
|
244 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1); |
|
245 | + return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * Returns HTML code for a graph showing the grand-parents' mean generation depth and standard deviation |
|
250 | - * @return string HTML code |
|
251 | - */ |
|
252 | - private function htmlAncestorGenDepthG3() { |
|
253 | - $ancestorsGenDepth3 = $this->sosa_provider->getGenerationDepthStatsAtGen(3); |
|
254 | - if(count($ancestorsGenDepth3) == 0) return; |
|
248 | + /** |
|
249 | + * Returns HTML code for a graph showing the grand-parents' mean generation depth and standard deviation |
|
250 | + * @return string HTML code |
|
251 | + */ |
|
252 | + private function htmlAncestorGenDepthG3() { |
|
253 | + $ancestorsGenDepth3 = $this->sosa_provider->getGenerationDepthStatsAtGen(3); |
|
254 | + if(count($ancestorsGenDepth3) == 0) return; |
|
255 | 255 | |
256 | - $ancestors = array(); |
|
257 | - $chd_mean = array(); |
|
258 | - $chd_error_low = array(); |
|
259 | - $chd_error_high = array(); |
|
260 | - foreach($ancestorsGenDepth3 as $sosa => $genDepthStat) { |
|
261 | - $ancestor = Individual::getInstance($genDepthStat['root_ancestor_id'], $this->sosa_provider->getTree()); |
|
262 | - if($ancestor !== null && $ancestor->canShowName()) { |
|
263 | - $tmp = $ancestor->getAllNames(); |
|
264 | - $ancestors[] = Filter::escapeUrl($tmp[$ancestor->getPrimaryName()]['fullNN']); |
|
265 | - } |
|
266 | - else { |
|
267 | - $ancestors[] = I18N::translate('Sosa %s', I18N::number($sosa)); |
|
268 | - } |
|
269 | - $chd_mean[] = $genDepthStat['mean_gen_depth']; |
|
270 | - $chd_error_low[] = max(0, $genDepthStat['mean_gen_depth'] - $genDepthStat['stddev_gen_depth']); |
|
271 | - $chd_error_high[] = $genDepthStat['mean_gen_depth'] + $genDepthStat['stddev_gen_depth']; |
|
272 | - } |
|
256 | + $ancestors = array(); |
|
257 | + $chd_mean = array(); |
|
258 | + $chd_error_low = array(); |
|
259 | + $chd_error_high = array(); |
|
260 | + foreach($ancestorsGenDepth3 as $sosa => $genDepthStat) { |
|
261 | + $ancestor = Individual::getInstance($genDepthStat['root_ancestor_id'], $this->sosa_provider->getTree()); |
|
262 | + if($ancestor !== null && $ancestor->canShowName()) { |
|
263 | + $tmp = $ancestor->getAllNames(); |
|
264 | + $ancestors[] = Filter::escapeUrl($tmp[$ancestor->getPrimaryName()]['fullNN']); |
|
265 | + } |
|
266 | + else { |
|
267 | + $ancestors[] = I18N::translate('Sosa %s', I18N::number($sosa)); |
|
268 | + } |
|
269 | + $chd_mean[] = $genDepthStat['mean_gen_depth']; |
|
270 | + $chd_error_low[] = max(0, $genDepthStat['mean_gen_depth'] - $genDepthStat['stddev_gen_depth']); |
|
271 | + $chd_error_high[] = $genDepthStat['mean_gen_depth'] + $genDepthStat['stddev_gen_depth']; |
|
272 | + } |
|
273 | 273 | |
274 | - $maxChd = ceil(max($chd_error_high)); |
|
275 | - $chd = implode(',', $chd_mean) . '|' . implode(',', $chd_error_low) . '|' . implode(',', $chd_error_high); |
|
276 | - $chxl = implode('|', array_reverse($ancestors)); |
|
277 | - $chbh = 30; |
|
278 | - $chs = count($ancestors) * $chbh + 50; |
|
279 | - $chxl_title = I18N::translate('Mean generation depth and standard deviation'); |
|
274 | + $maxChd = ceil(max($chd_error_high)); |
|
275 | + $chd = implode(',', $chd_mean) . '|' . implode(',', $chd_error_low) . '|' . implode(',', $chd_error_high); |
|
276 | + $chxl = implode('|', array_reverse($ancestors)); |
|
277 | + $chbh = 30; |
|
278 | + $chs = count($ancestors) * $chbh + 50; |
|
279 | + $chxl_title = I18N::translate('Mean generation depth and standard deviation'); |
|
280 | 280 | |
281 | - return "<img src=\"https://chart.googleapis.com/chart?cht=bhs&chco=84beff&chs=600x{$chs}&chbh={$chbh}&chd=t1:{$chd}&chds=0,{$maxChd}&chxt=x,x,y&chxl=1:|{$chxl_title}|2:|{$chxl}&chxp=1,50&chxr=0,0,{$maxChd},1&chm=E,577292,1:2,,2\" />"; |
|
282 | - } |
|
281 | + return "<img src=\"https://chart.googleapis.com/chart?cht=bhs&chco=84beff&chs=600x{$chs}&chbh={$chbh}&chd=t1:{$chd}&chds=0,{$maxChd}&chxt=x,x,y&chxl=1:|{$chxl_title}|2:|{$chxl}&chxp=1,50&chxr=0,0,{$maxChd},1&chm=E,577292,1:2,,2\" />"; |
|
282 | + } |
|
283 | 283 | |
284 | - /** |
|
285 | - * Convert an array to Google Chart encoding |
|
286 | - * @param arrat $a Array to encode |
|
287 | - * @return string |
|
288 | - */ |
|
289 | - private function arrayToExtendedEncoding($a) { |
|
290 | - $xencoding = WT_GOOGLE_CHART_ENCODING; |
|
284 | + /** |
|
285 | + * Convert an array to Google Chart encoding |
|
286 | + * @param arrat $a Array to encode |
|
287 | + * @return string |
|
288 | + */ |
|
289 | + private function arrayToExtendedEncoding($a) { |
|
290 | + $xencoding = WT_GOOGLE_CHART_ENCODING; |
|
291 | 291 | |
292 | - $encoding = ''; |
|
293 | - foreach ($a as $value) { |
|
294 | - if ($value < 0) { |
|
295 | - $value = 0; |
|
296 | - } |
|
297 | - $first = (int) ($value / 64); |
|
298 | - $second = $value % 64; |
|
299 | - $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second]; |
|
300 | - } |
|
292 | + $encoding = ''; |
|
293 | + foreach ($a as $value) { |
|
294 | + if ($value < 0) { |
|
295 | + $value = 0; |
|
296 | + } |
|
297 | + $first = (int) ($value / 64); |
|
298 | + $second = $value % 64; |
|
299 | + $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second]; |
|
300 | + } |
|
301 | 301 | |
302 | - return $encoding; |
|
303 | - } |
|
302 | + return $encoding; |
|
303 | + } |
|
304 | 304 | |
305 | 305 | |
306 | 306 | } |
307 | 307 | \ No newline at end of file |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $view_bag->set('title', $controller->getPageTitle()); |
64 | 64 | $view_bag->set('is_setup', false); |
65 | 65 | |
66 | - if($this->sosa_provider->isSetup()) { |
|
66 | + if ($this->sosa_provider->isSetup()) { |
|
67 | 67 | $view_bag->set('is_setup', true); |
68 | 68 | |
69 | 69 | $view_bag->set('root_indi', $this->sosa_provider->getRootIndi()); |
@@ -84,21 +84,21 @@ discard block |
||
84 | 84 | $view_bag->set('missinganc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList@missing&ged='.$wt_tree->getNameUrl().'&gen='); |
85 | 85 | $view_bag->set('sosaanc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList&ged='.$wt_tree->getNameUrl().'&gen='); |
86 | 86 | |
87 | - $gen_theoretical=1; |
|
88 | - $total_theoretical=0; |
|
89 | - $prev_diff=0; |
|
90 | - $prev_known=0.5; |
|
87 | + $gen_theoretical = 1; |
|
88 | + $total_theoretical = 0; |
|
89 | + $prev_diff = 0; |
|
90 | + $prev_known = 0.5; |
|
91 | 91 | $generation_stats = array(); |
92 | 92 | |
93 | - foreach($stats_gen as $gen => $tab){ |
|
94 | - $genY1= I18N::translate('-'); |
|
95 | - $genY2= I18N::translate('-'); |
|
96 | - if($tab['firstBirth']>0) $genY1=$tab['firstEstimatedBirth']; |
|
97 | - if($tab['lastBirth']>0) $genY2=$tab['lastEstimatedBirth']; |
|
93 | + foreach ($stats_gen as $gen => $tab) { |
|
94 | + $genY1 = I18N::translate('-'); |
|
95 | + $genY2 = I18N::translate('-'); |
|
96 | + if ($tab['firstBirth'] > 0) $genY1 = $tab['firstEstimatedBirth']; |
|
97 | + if ($tab['lastBirth'] > 0) $genY2 = $tab['lastEstimatedBirth']; |
|
98 | 98 | $total_theoretical += $gen_theoretical; |
99 | 99 | $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical); |
100 | - $missing=2*$prev_known - $tab['sosaCount']; |
|
101 | - $gen_diff=$tab['diffSosaTotalCount']-$prev_diff; |
|
100 | + $missing = 2 * $prev_known - $tab['sosaCount']; |
|
101 | + $gen_diff = $tab['diffSosaTotalCount'] - $prev_diff; |
|
102 | 102 | |
103 | 103 | $generation_stats[$gen] = array( |
104 | 104 | 'gen_min_birth' => $genY1, |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | 'known' => $tab['sosaCount'], |
108 | 108 | 'perc_known' => $perc_sosa_count_theor, |
109 | 109 | 'missing' => $missing, |
110 | - 'perc_missing' => 1-Functions::safeDivision($tab['sosaCount'], 2*$prev_known), |
|
110 | + 'perc_missing' => 1 - Functions::safeDivision($tab['sosaCount'], 2 * $prev_known), |
|
111 | 111 | 'total_known' => $tab['sosaTotalCount'], |
112 | 112 | 'perc_total_known' => Functions::safeDivision($tab['sosaTotalCount'], $total_theoretical), |
113 | 113 | 'different' => $gen_diff, |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | ); |
118 | 118 | |
119 | 119 | $gen_theoretical = $gen_theoretical * 2; |
120 | - $prev_known=$tab['sosaCount']; |
|
121 | - $prev_diff=$tab['diffSosaTotalCount']; |
|
120 | + $prev_known = $tab['sosaCount']; |
|
121 | + $prev_diff = $tab['diffSosaTotalCount']; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | $view_bag->set('generation_stats', $generation_stats); |
@@ -149,13 +149,12 @@ discard block |
||
149 | 149 | { |
150 | 150 | $top10multiancestors = $this->sosa_provider->getTopMultiSosaAncestorsNoTies(10); |
151 | 151 | $top10ancestors = array(); |
152 | - if($top10multiancestors !== null && count($top10multiancestors)) { |
|
153 | - foreach($top10multiancestors as $pid => $count) { |
|
152 | + if ($top10multiancestors !== null && count($top10multiancestors)) { |
|
153 | + foreach ($top10multiancestors as $pid => $count) { |
|
154 | 154 | $indi = Individual::getInstance($pid, $this->sosa_provider->getTree()); |
155 | - if($indi !== null && $indi->canShowName()) { |
|
155 | + if ($indi !== null && $indi->canShowName()) { |
|
156 | 156 | array_key_exists($count, $top10ancestors) ? |
157 | - $top10ancestors[$count][] = $indi: |
|
158 | - $top10ancestors[$count] = array($count => $indi); |
|
157 | + $top10ancestors[$count][] = $indi : $top10ancestors[$count] = array($count => $indi); |
|
159 | 158 | } |
160 | 159 | } |
161 | 160 | } |
@@ -169,27 +168,27 @@ discard block |
||
169 | 168 | private function htmlAncestorDispersionG2() |
170 | 169 | { |
171 | 170 | $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2); |
172 | - if(count($ancestorsDispGen2) == 0) return; |
|
171 | + if (count($ancestorsDispGen2) == 0) return; |
|
173 | 172 | |
174 | 173 | $size = '600x300'; |
175 | 174 | |
176 | 175 | $total = array_sum($ancestorsDispGen2); |
177 | 176 | $father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; |
178 | - $father = array ( |
|
177 | + $father = array( |
|
179 | 178 | 'color' => '84beff', |
180 | 179 | 'count' => $father_count, |
181 | 180 | 'perc' => Functions::safeDivision($father_count, $total), |
182 | 181 | 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat') |
183 | 182 | ); |
184 | 183 | $mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; |
185 | - $mother = array ( |
|
184 | + $mother = array( |
|
186 | 185 | 'color' => 'ffd1dc', |
187 | 186 | 'count' => $mother_count, |
188 | 187 | 'perc' => Functions::safeDivision($mother_count, $total), |
189 | 188 | 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot') |
190 | 189 | ); |
191 | 190 | $shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
192 | - $shared = array ( |
|
191 | + $shared = array( |
|
193 | 192 | 'color' => '777777', |
194 | 193 | 'count' => $shared_count, |
195 | 194 | 'perc' => Functions::safeDivision($shared_count, $total), |
@@ -199,10 +198,10 @@ discard block |
||
199 | 198 | $chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc'])); |
200 | 199 | $chart_title = I18N::translate('Known Sosa ancestors\' dispersion'); |
201 | 200 | $chl = |
202 | - $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' . |
|
203 | - $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' . |
|
204 | - $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1); |
|
205 | - return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$father['color']},{$shared['color']},{$mother['color']}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
201 | + $father['name'].' - '.I18N::percentage($father['perc'], 1).'|'. |
|
202 | + $shared['name'].' - '.I18N::percentage($shared['perc'], 1).'|'. |
|
203 | + $mother['name'].' - '.I18N::percentage($mother['perc'], 1); |
|
204 | + return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$father['color']},{$shared['color']},{$mother['color']}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"".$chart_title."\" title=\"".$chart_title."\" />"; |
|
206 | 205 | } |
207 | 206 | |
208 | 207 | /** |
@@ -226,7 +225,7 @@ discard block |
||
226 | 225 | $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0; |
227 | 226 | $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0; |
228 | 227 | $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
229 | - $total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha; |
|
228 | + $total = $total_fatfat + $total_fatmot + $total_motfat + $total_motmot + $total_sha; |
|
230 | 229 | |
231 | 230 | $chd = $this->arrayToExtendedEncoding(array( |
232 | 231 | 4095 * Functions::safeDivision($total_fatfat, $total), |
@@ -237,12 +236,12 @@ discard block |
||
237 | 236 | )); |
238 | 237 | $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3'); |
239 | 238 | $chl = |
240 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' . |
|
241 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' . |
|
242 | - I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' . |
|
243 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' . |
|
244 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1); |
|
245 | - return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
239 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat').' - '.I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1).'|'. |
|
240 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot').' - '.I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1).'|'. |
|
241 | + I18N::translate('Shared').' - '.I18N::percentage(Functions::safeDivision($total_sha, $total), 1).'|'. |
|
242 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat').' - '.I18N::percentage(Functions::safeDivision($total_motfat, $total), 1).'|'. |
|
243 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot').' - '.I18N::percentage(Functions::safeDivision($total_motmot, $total), 1); |
|
244 | + return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"".$chart_title."\" title=\"".$chart_title."\" />"; |
|
246 | 245 | } |
247 | 246 | |
248 | 247 | /** |
@@ -251,15 +250,15 @@ discard block |
||
251 | 250 | */ |
252 | 251 | private function htmlAncestorGenDepthG3() { |
253 | 252 | $ancestorsGenDepth3 = $this->sosa_provider->getGenerationDepthStatsAtGen(3); |
254 | - if(count($ancestorsGenDepth3) == 0) return; |
|
253 | + if (count($ancestorsGenDepth3) == 0) return; |
|
255 | 254 | |
256 | 255 | $ancestors = array(); |
257 | 256 | $chd_mean = array(); |
258 | 257 | $chd_error_low = array(); |
259 | 258 | $chd_error_high = array(); |
260 | - foreach($ancestorsGenDepth3 as $sosa => $genDepthStat) { |
|
259 | + foreach ($ancestorsGenDepth3 as $sosa => $genDepthStat) { |
|
261 | 260 | $ancestor = Individual::getInstance($genDepthStat['root_ancestor_id'], $this->sosa_provider->getTree()); |
262 | - if($ancestor !== null && $ancestor->canShowName()) { |
|
261 | + if ($ancestor !== null && $ancestor->canShowName()) { |
|
263 | 262 | $tmp = $ancestor->getAllNames(); |
264 | 263 | $ancestors[] = Filter::escapeUrl($tmp[$ancestor->getPrimaryName()]['fullNN']); |
265 | 264 | } |
@@ -272,7 +271,7 @@ discard block |
||
272 | 271 | } |
273 | 272 | |
274 | 273 | $maxChd = ceil(max($chd_error_high)); |
275 | - $chd = implode(',', $chd_mean) . '|' . implode(',', $chd_error_low) . '|' . implode(',', $chd_error_high); |
|
274 | + $chd = implode(',', $chd_mean).'|'.implode(',', $chd_error_low).'|'.implode(',', $chd_error_high); |
|
276 | 275 | $chxl = implode('|', array_reverse($ancestors)); |
277 | 276 | $chbh = 30; |
278 | 277 | $chs = count($ancestors) * $chbh + 50; |
@@ -294,9 +293,9 @@ discard block |
||
294 | 293 | if ($value < 0) { |
295 | 294 | $value = 0; |
296 | 295 | } |
297 | - $first = (int) ($value / 64); |
|
296 | + $first = (int)($value / 64); |
|
298 | 297 | $second = $value % 64; |
299 | - $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second]; |
|
298 | + $encoding .= $xencoding[(int)$first].$xencoding[(int)$second]; |
|
300 | 299 | } |
301 | 300 | |
302 | 301 | return $encoding; |