@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | if (($fact->getDate() || $fact->getPlace()) && $fact->canShow()) { |
71 | 71 | switch ($style) { |
72 | 72 | case 10: |
73 | - return '<i>'.$fact->getLabel().' '. \MyArtJaub\Webtrees\Functions\FunctionsPrint::formatFactDateShort($fact) .' '. \MyArtJaub\Webtrees\Functions\FunctionsPrint::formatFactPlaceShort($fact, '%1') .'</i>'; |
|
73 | + return '<i>'.$fact->getLabel().' '. \MyArtJaub\Webtrees\Functions\FunctionsPrint::formatFactDateShort($fact) .' '. \MyArtJaub\Webtrees\Functions\FunctionsPrint::formatFactPlaceShort($fact, '%1') .'</i>'; |
|
74 | 74 | default: |
75 | 75 | return $this->gedcomrecord->formatFirstMajorFact($facts, $style); |
76 | 76 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | public function canDisplayIsSourced($access_level = null){ |
89 | 89 | if(!$this->gedcomrecord->canShow($access_level)) return false; |
90 | 90 | if($access_level === null ) |
91 | - $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
|
91 | + $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
|
92 | 92 | |
93 | 93 | $global_facts = Globals::getGlobalFacts(); |
94 | 94 | if (isset($global_facts['SOUR'])) { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @return int Level of sources |
128 | 128 | */ |
129 | 129 | public function isFactSourced($eventslist){ |
130 | - if(empty($eventslist)) return 0; |
|
130 | + if(empty($eventslist)) return 0; |
|
131 | 131 | $isSourced=0; |
132 | 132 | $facts = $this->gedcomrecord->getFacts($eventslist); |
133 | 133 | foreach($facts as $fact){ |
@@ -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 | } |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public static function getInstance() |
45 | 45 | { |
46 | - if (null === static::$instance) { |
|
47 | - static::$instance = new static(); |
|
48 | - } |
|
46 | + if (null === static::$instance) { |
|
47 | + static::$instance = new static(); |
|
48 | + } |
|
49 | 49 | |
50 | - return static::$instance; |
|
50 | + return static::$instance; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::get() |
56 | 56 | */ |
57 | 57 | public function get($hook_function, $hook_context = null) { |
58 | - return new Hook($hook_function, $hook_context); |
|
58 | + return new Hook($hook_function, $hook_context); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -73,20 +73,20 @@ discard block |
||
73 | 73 | public function getPossibleHooks() { |
74 | 74 | static $hooks=null; |
75 | 75 | if ($hooks === null) { |
76 | - $hooks = array(); |
|
76 | + $hooks = array(); |
|
77 | 77 | |
78 | - // Cannot use the same logic as the core Module loading, |
|
79 | - // as this forces a new include of the module.php file. |
|
80 | - // This causes issue when classes are defined in this file. |
|
81 | - // Cannot use Module::getActiveModules as well, as this is private. |
|
82 | - $module_names = Database::prepare( |
|
83 | - 'SELECT module_name FROM `##module`' |
|
84 | - )->fetchOneColumn(); |
|
78 | + // Cannot use the same logic as the core Module loading, |
|
79 | + // as this forces a new include of the module.php file. |
|
80 | + // This causes issue when classes are defined in this file. |
|
81 | + // Cannot use Module::getActiveModules as well, as this is private. |
|
82 | + $module_names = Database::prepare( |
|
83 | + 'SELECT module_name FROM `##module`' |
|
84 | + )->fetchOneColumn(); |
|
85 | 85 | |
86 | - foreach($module_names as $module_name) { |
|
87 | - $module = Module::getModuleByName($module_name); |
|
86 | + foreach($module_names as $module_name) { |
|
87 | + $module = Module::getModuleByName($module_name); |
|
88 | 88 | |
89 | - if($module instanceof HookSubscriberInterface){ |
|
89 | + if($module instanceof HookSubscriberInterface){ |
|
90 | 90 | $subscribedhooks = $module->getSubscribedHooks(); |
91 | 91 | if(is_array($subscribedhooks)){ |
92 | 92 | foreach($subscribedhooks as $key => $value){ |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
114 | - } |
|
114 | + } |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | return $hooks; |
@@ -153,33 +153,33 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function updateHooks() { |
155 | 155 | |
156 | - if(Auth::isAdmin()){ |
|
157 | - $ihooks = self::getInstalledHooks(); |
|
158 | - $phooks = self::getPossibleHooks(); |
|
156 | + if(Auth::isAdmin()){ |
|
157 | + $ihooks = self::getInstalledHooks(); |
|
158 | + $phooks = self::getPossibleHooks(); |
|
159 | 159 | |
160 | - // Insert hooks not existing yet in the DB |
|
161 | - if($phooks !== null){ |
|
162 | - foreach($phooks as $phook => $priority){ |
|
163 | - $array_hook = explode('#', $phook); |
|
164 | - if($ihooks === null || !array_key_exists($phook, $ihooks)){ |
|
165 | - $chook = new Hook($array_hook[1], $array_hook[2]); |
|
166 | - $chook->subscribe($array_hook[0]); |
|
167 | - $chook->setPriority($array_hook[0], $priority); |
|
168 | - } |
|
169 | - } |
|
170 | - } |
|
160 | + // Insert hooks not existing yet in the DB |
|
161 | + if($phooks !== null){ |
|
162 | + foreach($phooks as $phook => $priority){ |
|
163 | + $array_hook = explode('#', $phook); |
|
164 | + if($ihooks === null || !array_key_exists($phook, $ihooks)){ |
|
165 | + $chook = new Hook($array_hook[1], $array_hook[2]); |
|
166 | + $chook->subscribe($array_hook[0]); |
|
167 | + $chook->setPriority($array_hook[0], $priority); |
|
168 | + } |
|
169 | + } |
|
170 | + } |
|
171 | 171 | |
172 | - //Remove hooks not existing any more in the file system |
|
173 | - if($ihooks !== null){ |
|
174 | - foreach(array_keys($ihooks) as $ihook){ |
|
175 | - $array_hook = explode('#', $ihook); |
|
176 | - if($phooks === null || !array_key_exists($ihook, $phooks)){ |
|
177 | - $chook = new Hook($array_hook[1], $array_hook[2]); |
|
178 | - $chook->remove($array_hook[0]); |
|
179 | - } |
|
180 | - } |
|
181 | - } |
|
182 | - } |
|
172 | + //Remove hooks not existing any more in the file system |
|
173 | + if($ihooks !== null){ |
|
174 | + foreach(array_keys($ihooks) as $ihook){ |
|
175 | + $array_hook = explode('#', $ihook); |
|
176 | + if($phooks === null || !array_key_exists($ihook, $phooks)){ |
|
177 | + $chook = new Hook($array_hook[1], $array_hook[2]); |
|
178 | + $chook->remove($array_hook[0]); |
|
179 | + } |
|
180 | + } |
|
181 | + } |
|
182 | + } |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | } |
186 | 186 | \ No newline at end of file |
@@ -24,64 +24,64 @@ discard block |
||
24 | 24 | * Geo Analysis ID |
25 | 25 | * @var int $id |
26 | 26 | */ |
27 | - protected $id; |
|
27 | + protected $id; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Geo Analysis Title |
31 | 31 | * @var string $title |
32 | 32 | */ |
33 | - protected $title; |
|
33 | + protected $title; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Level of the Gedcom hierarchy for the analysis |
37 | 37 | * @var int $analysis_level |
38 | 38 | */ |
39 | - protected $analysis_level; |
|
39 | + protected $analysis_level; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Display options |
|
43 | - * @var GeoDisplayOptions $options |
|
44 | - */ |
|
45 | - protected $options; |
|
41 | + /** |
|
42 | + * Display options |
|
43 | + * @var GeoDisplayOptions $options |
|
44 | + */ |
|
45 | + protected $options; |
|
46 | 46 | |
47 | - /** |
|
48 | - * Reference tree |
|
49 | - * @var Tree $tree |
|
50 | - */ |
|
51 | - protected $tree; |
|
47 | + /** |
|
48 | + * Reference tree |
|
49 | + * @var Tree $tree |
|
50 | + */ |
|
51 | + protected $tree; |
|
52 | 52 | |
53 | - /** |
|
54 | - * Is the analysis enabled |
|
55 | - * @var bool $enabled |
|
56 | - */ |
|
57 | - protected $enabled; |
|
53 | + /** |
|
54 | + * Is the analysis enabled |
|
55 | + * @var bool $enabled |
|
56 | + */ |
|
57 | + protected $enabled; |
|
58 | 58 | |
59 | - /** |
|
60 | - * Constructor for GeoAnalysis. |
|
61 | - * |
|
62 | - * @param Tree $tree Reference tree |
|
59 | + /** |
|
60 | + * Constructor for GeoAnalysis. |
|
61 | + * |
|
62 | + * @param Tree $tree Reference tree |
|
63 | 63 | * @param int $id GeoAnalysis ID |
64 | 64 | * @param string $title GeoAnalysis title |
65 | 65 | * @param int $analysis_level Analysis level |
66 | 66 | * @param (GeoDisplayOptions|null) $options Display options |
67 | 67 | * @param bool $enabled Is analysis enabled |
68 | - */ |
|
69 | - public function __construct(Tree $tree, $id, $title, $analysis_level, GeoDisplayOptions $options = null, $enabled = true) { |
|
70 | - $this->tree = $tree; |
|
71 | - $this->id = $id; |
|
72 | - $this->title = $title; |
|
73 | - $this->analysis_level = $analysis_level; |
|
74 | - $this->options = $options; |
|
75 | - $this->enabled = $enabled; |
|
76 | - } |
|
68 | + */ |
|
69 | + public function __construct(Tree $tree, $id, $title, $analysis_level, GeoDisplayOptions $options = null, $enabled = true) { |
|
70 | + $this->tree = $tree; |
|
71 | + $this->id = $id; |
|
72 | + $this->title = $title; |
|
73 | + $this->analysis_level = $analysis_level; |
|
74 | + $this->options = $options; |
|
75 | + $this->enabled = $enabled; |
|
76 | + } |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Get the analysis title |
80 | 80 | * @return string |
81 | 81 | */ |
82 | - public function getTitle() { |
|
83 | - return $this->title; |
|
84 | - } |
|
82 | + public function getTitle() { |
|
83 | + return $this->title; |
|
84 | + } |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Set the analysis title |
@@ -89,53 +89,53 @@ discard block |
||
89 | 89 | * @param string $title |
90 | 90 | * @return self Enable method-chaining |
91 | 91 | */ |
92 | - public function setTitle($title) { |
|
93 | - $this->title = $title; |
|
94 | - return $this; |
|
95 | - } |
|
92 | + public function setTitle($title) { |
|
93 | + $this->title = $title; |
|
94 | + return $this; |
|
95 | + } |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * Get the analysis ID |
99 | 99 | * @return int |
100 | 100 | */ |
101 | - public function getId() { |
|
102 | - return $this->id; |
|
103 | - } |
|
101 | + public function getId() { |
|
102 | + return $this->id; |
|
103 | + } |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * Get the analysis status (enabled/disabled) |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - public function isEnabled() { |
|
110 | - return $this->enabled; |
|
111 | - } |
|
109 | + public function isEnabled() { |
|
110 | + return $this->enabled; |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * Get analysis options |
|
115 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions |
|
116 | - */ |
|
117 | - public function getOptions() { |
|
118 | - return $this->options; |
|
119 | - } |
|
113 | + /** |
|
114 | + * Get analysis options |
|
115 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions |
|
116 | + */ |
|
117 | + public function getOptions() { |
|
118 | + return $this->options; |
|
119 | + } |
|
120 | 120 | |
121 | 121 | /** |
122 | - * Set analysis options |
|
122 | + * Set analysis options |
|
123 | 123 | * |
124 | - * @param \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions $options |
|
124 | + * @param \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions $options |
|
125 | 125 | * @return self Enable method-chaining |
126 | - */ |
|
127 | - public function setOptions(GeoDisplayOptions $options) { |
|
128 | - $this->options = $options; |
|
129 | - return $this; |
|
130 | - } |
|
126 | + */ |
|
127 | + public function setOptions(GeoDisplayOptions $options) { |
|
128 | + $this->options = $options; |
|
129 | + return $this; |
|
130 | + } |
|
131 | 131 | |
132 | 132 | /** |
133 | 133 | * Get analysis level |
134 | 134 | * @return int |
135 | 135 | */ |
136 | - public function getAnalysisLevel() { |
|
137 | - return $this->analysis_level; |
|
138 | - } |
|
136 | + public function getAnalysisLevel() { |
|
137 | + return $this->analysis_level; |
|
138 | + } |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Get analysis level |
@@ -143,19 +143,19 @@ discard block |
||
143 | 143 | * @param int $analysis_level |
144 | 144 | * @return self Enable method-chaining |
145 | 145 | */ |
146 | - public function setAnalysisLevel($analysis_level) { |
|
147 | - $this->analysis_level = $analysis_level; |
|
148 | - return $this; |
|
149 | - } |
|
146 | + public function setAnalysisLevel($analysis_level) { |
|
147 | + $this->analysis_level = $analysis_level; |
|
148 | + return $this; |
|
149 | + } |
|
150 | 150 | |
151 | 151 | /** |
152 | 152 | * Check whether the analysis has a linked map |
153 | 153 | * |
154 | 154 | * @return bool |
155 | 155 | */ |
156 | - public function hasMap() { |
|
157 | - return $this->options && $this->options->getMap(); |
|
158 | - } |
|
156 | + public function hasMap() { |
|
157 | + return $this->options && $this->options->getMap(); |
|
158 | + } |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * Get the URL for the GeoAnalysis. |
@@ -163,120 +163,120 @@ discard block |
||
163 | 163 | * @return string |
164 | 164 | */ |
165 | 165 | public function getHtmlUrl() { |
166 | - return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
167 | - } |
|
166 | + return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
170 | - * Return the dispersion analysis tables. |
|
171 | - * Two arrays are returned : |
|
172 | - * - the General analysis, which returns the number of ancestors for each place found, plus 4 additional indicators : |
|
173 | - * - knownsum : Number of known places |
|
174 | - * - unknown : Number of unknown places |
|
175 | - * - max : Maximum count of ancestors within a place |
|
176 | - * - other : Other places (not in the top level area) |
|
177 | - * - the Generations analysis, which returns the number of ancestors for each place found for each generation, plus 3 additional indicators within each generation : |
|
178 | - * - sum : Number of known places |
|
179 | - * - unknown : Number of unknown places |
|
180 | - * - other : Other places (not in the top level area) |
|
181 | - * |
|
182 | - * @param array $sosalist List of all sosas |
|
183 | - * @return array Array of the general and generations table |
|
184 | - */ |
|
185 | - public function getAnalysisResults($sosalist) { |
|
186 | - $placesDispGeneral = null; |
|
187 | - $placesDispGenerations = null; |
|
169 | + /** |
|
170 | + * Return the dispersion analysis tables. |
|
171 | + * Two arrays are returned : |
|
172 | + * - the General analysis, which returns the number of ancestors for each place found, plus 4 additional indicators : |
|
173 | + * - knownsum : Number of known places |
|
174 | + * - unknown : Number of unknown places |
|
175 | + * - max : Maximum count of ancestors within a place |
|
176 | + * - other : Other places (not in the top level area) |
|
177 | + * - the Generations analysis, which returns the number of ancestors for each place found for each generation, plus 3 additional indicators within each generation : |
|
178 | + * - sum : Number of known places |
|
179 | + * - unknown : Number of unknown places |
|
180 | + * - other : Other places (not in the top level area) |
|
181 | + * |
|
182 | + * @param array $sosalist List of all sosas |
|
183 | + * @return array Array of the general and generations table |
|
184 | + */ |
|
185 | + public function getAnalysisResults($sosalist) { |
|
186 | + $placesDispGeneral = null; |
|
187 | + $placesDispGenerations = null; |
|
188 | 188 | |
189 | - if($sosalist && count($sosalist) > 0) { |
|
190 | - $placesDispGeneral['knownsum'] = 0; |
|
191 | - $placesDispGeneral['unknown'] = 0; |
|
192 | - $placesDispGeneral['max'] = 0; |
|
193 | - $placesDispGeneral['places'] = array(); |
|
194 | - foreach($sosalist as $sosaid => $gens) { |
|
195 | - $sosa = Individual::getIntance($sosaid, $this->tree); |
|
196 | - $place =$sosa->getSignificantPlace(); |
|
197 | - $genstab = explode(',', $gens); |
|
198 | - $isUnknown=true; |
|
199 | - if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
200 | - $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
201 | - if(count($levels)>= $this->analysis_level){ |
|
202 | - $toplevelvalues = array(); |
|
203 | - if($this->hasMap() |
|
204 | - && $this->options->getMap()->isLoaded() |
|
205 | - && $toplevelvalue = $this->options->getMap()->getTopLevelName() |
|
206 | - ) { |
|
207 | - $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
208 | - } |
|
209 | - if(!$this->hasMap() |
|
210 | - || is_null($this->options->getMapLevel()) |
|
211 | - || ( $this->options->getMap()->isLoaded() && $this->options->getMap()->getTopLevelName() == '*') |
|
212 | - || ( |
|
213 | - $this->options->getMapLevel() <= $this->analysis_level |
|
214 | - && $this->options->getMapLevel() > 0 |
|
215 | - && count($levels) >= $this->options->getMapLevel() |
|
216 | - && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
217 | - ) |
|
218 | - ) { |
|
219 | - $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
|
220 | - if(isset($placesDispGeneral['places'][$placest])) { |
|
221 | - $placesDispGeneral['places'][$placest] += 1; |
|
222 | - } |
|
223 | - else { |
|
224 | - $placesDispGeneral['places'][$placest] = 1; |
|
225 | - } |
|
226 | - if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
227 | - $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
228 | - foreach($genstab as $gen) { |
|
229 | - if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
230 | - $placesDispGenerations[$gen]['places'][$placest] += 1; |
|
231 | - } |
|
232 | - else { |
|
233 | - $placesDispGenerations[$gen]['places'][$placest] = 1; |
|
234 | - } |
|
235 | - if(isset($placesDispGenerations[$gen]['sum'])) { |
|
236 | - $placesDispGenerations[$gen]['sum'] += 1; |
|
237 | - } |
|
238 | - else { |
|
239 | - $placesDispGenerations[$gen]['sum'] = 1; |
|
240 | - } |
|
241 | - } |
|
242 | - } |
|
243 | - else{ |
|
244 | - if(isset($placesDispGeneral['other'])) { |
|
245 | - $placesDispGeneral['other'] += 1; |
|
246 | - } |
|
247 | - else { |
|
248 | - $placesDispGeneral['other'] = 1; |
|
249 | - } |
|
250 | - foreach($genstab as $gen) { |
|
251 | - if(isset($placesDispGenerations[$gen]['other'])) { |
|
252 | - $placesDispGenerations[$gen]['other'] += 1; |
|
253 | - } |
|
254 | - else { |
|
255 | - $placesDispGenerations[$gen]['other'] = 1; |
|
256 | - } |
|
257 | - } |
|
258 | - } |
|
259 | - $placesDispGeneral['knownsum'] += 1; |
|
260 | - $isUnknown = false; |
|
261 | - } |
|
262 | - } |
|
263 | - if($isUnknown){ |
|
264 | - $placesDispGeneral['unknown'] += 1; |
|
265 | - foreach($genstab as $gen) { |
|
266 | - if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
267 | - $placesDispGenerations[$gen]['unknown'] += 1; |
|
268 | - } |
|
269 | - else { |
|
270 | - $placesDispGenerations[$gen]['unknown'] = 1; |
|
271 | - } |
|
272 | - } |
|
273 | - } |
|
274 | - } |
|
189 | + if($sosalist && count($sosalist) > 0) { |
|
190 | + $placesDispGeneral['knownsum'] = 0; |
|
191 | + $placesDispGeneral['unknown'] = 0; |
|
192 | + $placesDispGeneral['max'] = 0; |
|
193 | + $placesDispGeneral['places'] = array(); |
|
194 | + foreach($sosalist as $sosaid => $gens) { |
|
195 | + $sosa = Individual::getIntance($sosaid, $this->tree); |
|
196 | + $place =$sosa->getSignificantPlace(); |
|
197 | + $genstab = explode(',', $gens); |
|
198 | + $isUnknown=true; |
|
199 | + if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
200 | + $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
201 | + if(count($levels)>= $this->analysis_level){ |
|
202 | + $toplevelvalues = array(); |
|
203 | + if($this->hasMap() |
|
204 | + && $this->options->getMap()->isLoaded() |
|
205 | + && $toplevelvalue = $this->options->getMap()->getTopLevelName() |
|
206 | + ) { |
|
207 | + $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
208 | + } |
|
209 | + if(!$this->hasMap() |
|
210 | + || is_null($this->options->getMapLevel()) |
|
211 | + || ( $this->options->getMap()->isLoaded() && $this->options->getMap()->getTopLevelName() == '*') |
|
212 | + || ( |
|
213 | + $this->options->getMapLevel() <= $this->analysis_level |
|
214 | + && $this->options->getMapLevel() > 0 |
|
215 | + && count($levels) >= $this->options->getMapLevel() |
|
216 | + && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
217 | + ) |
|
218 | + ) { |
|
219 | + $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
|
220 | + if(isset($placesDispGeneral['places'][$placest])) { |
|
221 | + $placesDispGeneral['places'][$placest] += 1; |
|
222 | + } |
|
223 | + else { |
|
224 | + $placesDispGeneral['places'][$placest] = 1; |
|
225 | + } |
|
226 | + if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
227 | + $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
228 | + foreach($genstab as $gen) { |
|
229 | + if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
230 | + $placesDispGenerations[$gen]['places'][$placest] += 1; |
|
231 | + } |
|
232 | + else { |
|
233 | + $placesDispGenerations[$gen]['places'][$placest] = 1; |
|
234 | + } |
|
235 | + if(isset($placesDispGenerations[$gen]['sum'])) { |
|
236 | + $placesDispGenerations[$gen]['sum'] += 1; |
|
237 | + } |
|
238 | + else { |
|
239 | + $placesDispGenerations[$gen]['sum'] = 1; |
|
240 | + } |
|
241 | + } |
|
242 | + } |
|
243 | + else{ |
|
244 | + if(isset($placesDispGeneral['other'])) { |
|
245 | + $placesDispGeneral['other'] += 1; |
|
246 | + } |
|
247 | + else { |
|
248 | + $placesDispGeneral['other'] = 1; |
|
249 | + } |
|
250 | + foreach($genstab as $gen) { |
|
251 | + if(isset($placesDispGenerations[$gen]['other'])) { |
|
252 | + $placesDispGenerations[$gen]['other'] += 1; |
|
253 | + } |
|
254 | + else { |
|
255 | + $placesDispGenerations[$gen]['other'] = 1; |
|
256 | + } |
|
257 | + } |
|
258 | + } |
|
259 | + $placesDispGeneral['knownsum'] += 1; |
|
260 | + $isUnknown = false; |
|
261 | + } |
|
262 | + } |
|
263 | + if($isUnknown){ |
|
264 | + $placesDispGeneral['unknown'] += 1; |
|
265 | + foreach($genstab as $gen) { |
|
266 | + if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
267 | + $placesDispGenerations[$gen]['unknown'] += 1; |
|
268 | + } |
|
269 | + else { |
|
270 | + $placesDispGenerations[$gen]['unknown'] = 1; |
|
271 | + } |
|
272 | + } |
|
273 | + } |
|
274 | + } |
|
275 | 275 | |
276 | - } |
|
276 | + } |
|
277 | 277 | |
278 | - return array($placesDispGeneral, $placesDispGenerations); |
|
279 | - } |
|
278 | + return array($placesDispGeneral, $placesDispGenerations); |
|
279 | + } |
|
280 | 280 | |
281 | 281 | |
282 | 282 | } |
@@ -25,24 +25,24 @@ discard block |
||
25 | 25 | * {@inheritDoc} |
26 | 26 | * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisTabGeneralView::htmlAnalysisData() |
27 | 27 | */ |
28 | - protected function htmlAnalysisData() { |
|
28 | + protected function htmlAnalysisData() { |
|
29 | 29 | |
30 | - /** @var OutlineMap $map */ |
|
31 | - $map = $this->data->get('map'); |
|
30 | + /** @var OutlineMap $map */ |
|
31 | + $map = $this->data->get('map'); |
|
32 | 32 | |
33 | - if($map === null) { |
|
34 | - return '<p class="warning">' . |
|
35 | - I18N::translate('The map could not be loaded.') . |
|
36 | - '</p>'; |
|
37 | - } |
|
33 | + if($map === null) { |
|
34 | + return '<p class="warning">' . |
|
35 | + I18N::translate('The map could not be loaded.') . |
|
36 | + '</p>'; |
|
37 | + } |
|
38 | 38 | |
39 | - $canvas = $map->getCanvas(); |
|
40 | - $subdvisions_results = $this->data->get('results_by_subdivisions'); |
|
39 | + $canvas = $map->getCanvas(); |
|
40 | + $subdvisions_results = $this->data->get('results_by_subdivisions'); |
|
41 | 41 | |
42 | - $nb_found = $this->data->get('stats_gen_nb_found'); |
|
43 | - $nb_other = $this->data->get('stats_gen_nb_other'); |
|
42 | + $nb_found = $this->data->get('stats_gen_nb_found'); |
|
43 | + $nb_other = $this->data->get('stats_gen_nb_other'); |
|
44 | 44 | |
45 | - $html = '<script> |
|
45 | + $html = '<script> |
|
46 | 46 | var tip = null; |
47 | 47 | var tipText = ""; |
48 | 48 | var over = false; |
@@ -89,29 +89,29 @@ discard block |
||
89 | 89 | var map = {}; |
90 | 90 | '; |
91 | 91 | |
92 | - foreach($subdvisions_results as $name => $location){ |
|
93 | - $html.= 'map.area'.$location['id'].' = paper.path("'.$location['coord'].'").attr(attr);'; |
|
94 | - if(isset($location['transparency'])) { |
|
95 | - $textToolTip = '<strong>'.$location['displayname'].'</strong><br/>'; |
|
96 | - if($this->data->get('use_flags') && $location['flag'] != '') $textToolTip .= '<span class="geodispersion_flag">'.FunctionsPrint::htmlPlaceIcon($location['place'], $location['flag']).'</span><br/>'; |
|
97 | - $textToolTip .= I18N::translate('%d individuals', $location['count']).'<br/>'.I18N::percentage(Functions::safeDivision($location['count'], $nb_found - $nb_other), 1); |
|
98 | - $html.= 'addTip(map.area'.$location['id'].'.node, "'.Filter::escapeJs($textToolTip).'");'; |
|
99 | - $html.= 'map.area'.$location['id'].'.attr({"fill" : "'. $canvas->max_color .'", "fill-opacity" : '.$location['transparency'].' });'; |
|
100 | - $html.= 'map.area'.$location['id'].'.mouseover(function () {'. |
|
101 | - 'map.area'.$location['id'].'.stop().animate({"fill" : "'. $canvas->hover_color .'", "fill-opacity" : 1}, 100, "linear");'. |
|
102 | - '});'. |
|
103 | - 'map.area'.$location['id'].'.mouseout(function () {'. |
|
104 | - 'map.area'.$location['id'].'.stop().animate({"fill" : "'.$canvas->max_color.'", "fill-opacity" : '.$location['transparency'].'}, 100, "linear");'. |
|
105 | - '});'; |
|
106 | - } |
|
107 | - } |
|
108 | - $html .= '}); |
|
92 | + foreach($subdvisions_results as $name => $location){ |
|
93 | + $html.= 'map.area'.$location['id'].' = paper.path("'.$location['coord'].'").attr(attr);'; |
|
94 | + if(isset($location['transparency'])) { |
|
95 | + $textToolTip = '<strong>'.$location['displayname'].'</strong><br/>'; |
|
96 | + if($this->data->get('use_flags') && $location['flag'] != '') $textToolTip .= '<span class="geodispersion_flag">'.FunctionsPrint::htmlPlaceIcon($location['place'], $location['flag']).'</span><br/>'; |
|
97 | + $textToolTip .= I18N::translate('%d individuals', $location['count']).'<br/>'.I18N::percentage(Functions::safeDivision($location['count'], $nb_found - $nb_other), 1); |
|
98 | + $html.= 'addTip(map.area'.$location['id'].'.node, "'.Filter::escapeJs($textToolTip).'");'; |
|
99 | + $html.= 'map.area'.$location['id'].'.attr({"fill" : "'. $canvas->max_color .'", "fill-opacity" : '.$location['transparency'].' });'; |
|
100 | + $html.= 'map.area'.$location['id'].'.mouseover(function () {'. |
|
101 | + 'map.area'.$location['id'].'.stop().animate({"fill" : "'. $canvas->hover_color .'", "fill-opacity" : 1}, 100, "linear");'. |
|
102 | + '});'. |
|
103 | + 'map.area'.$location['id'].'.mouseout(function () {'. |
|
104 | + 'map.area'.$location['id'].'.stop().animate({"fill" : "'.$canvas->max_color.'", "fill-opacity" : '.$location['transparency'].'}, 100, "linear");'. |
|
105 | + '});'; |
|
106 | + } |
|
107 | + } |
|
108 | + $html .= '}); |
|
109 | 109 | </script> |
110 | 110 | |
111 | 111 | <div id="geodispersion_map"></div> |
112 | 112 | <div id="geodispersion_tip"></div>'; |
113 | 113 | |
114 | - return $html; |
|
115 | - } |
|
114 | + return $html; |
|
115 | + } |
|
116 | 116 | |
117 | 117 | } |
118 | 118 | \ No newline at end of file |
@@ -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 |
@@ -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 |
@@ -31,140 +31,140 @@ discard block |
||
31 | 31 | * Certificates Module. |
32 | 32 | */ |
33 | 33 | class CertificatesModule |
34 | - extends AbstractModule |
|
35 | - implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtenderInterface, CustomSimpleTagManagerInterface |
|
34 | + extends AbstractModule |
|
35 | + implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtenderInterface, CustomSimpleTagManagerInterface |
|
36 | 36 | { |
37 | - /** @var string For custom modules - link for support, upgrades, etc. */ |
|
38 | - const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
37 | + /** @var string For custom modules - link for support, upgrades, etc. */ |
|
38 | + const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Provider for Certificates |
|
42 | - * @var CertificateProviderInterface $provider |
|
43 | - */ |
|
44 | - protected $provider; |
|
40 | + /** |
|
41 | + * Provider for Certificates |
|
42 | + * @var CertificateProviderInterface $provider |
|
43 | + */ |
|
44 | + protected $provider; |
|
45 | 45 | |
46 | - /** |
|
47 | - * {@inhericDoc} |
|
48 | - */ |
|
49 | - public function getTitle() { |
|
50 | - return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates'); |
|
51 | - } |
|
46 | + /** |
|
47 | + * {@inhericDoc} |
|
48 | + */ |
|
49 | + public function getTitle() { |
|
50 | + return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates'); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * {@inhericDoc} |
|
55 | - */ |
|
56 | - public function getDescription() { |
|
57 | - return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.'); |
|
58 | - } |
|
53 | + /** |
|
54 | + * {@inhericDoc} |
|
55 | + */ |
|
56 | + public function getDescription() { |
|
57 | + return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.'); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * {@inhericDoc} |
|
62 | - */ |
|
63 | - public function modAction($mod_action) { |
|
64 | - \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
65 | - } |
|
60 | + /** |
|
61 | + * {@inhericDoc} |
|
62 | + */ |
|
63 | + public function modAction($mod_action) { |
|
64 | + \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * {@inhericDoc} |
|
69 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
70 | - */ |
|
71 | - public function getConfigLink() { |
|
72 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
73 | - } |
|
67 | + /** |
|
68 | + * {@inhericDoc} |
|
69 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
70 | + */ |
|
71 | + public function getConfigLink() { |
|
72 | + return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * {@inhericDoc} |
|
77 | - * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
78 | - */ |
|
79 | - public function getSubscribedHooks() { |
|
80 | - return array( |
|
81 | - 'hFactSourcePrepend' => 50, |
|
82 | - 'hGetExpectedTags' => 50, |
|
83 | - 'hHtmlSimpleTagDisplay#_ACT' => 50, |
|
84 | - 'hHtmlSimpleTagEditor#_ACT' => 50, |
|
85 | - 'hAddSimpleTag#SOUR' => 50, |
|
86 | - 'hHasHelpTextTag#_ACT' => 50, |
|
87 | - 'hGetHelpTextTag#_ACT' => 50 |
|
88 | - ); |
|
89 | - } |
|
75 | + /** |
|
76 | + * {@inhericDoc} |
|
77 | + * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
78 | + */ |
|
79 | + public function getSubscribedHooks() { |
|
80 | + return array( |
|
81 | + 'hFactSourcePrepend' => 50, |
|
82 | + 'hGetExpectedTags' => 50, |
|
83 | + 'hHtmlSimpleTagDisplay#_ACT' => 50, |
|
84 | + 'hHtmlSimpleTagEditor#_ACT' => 50, |
|
85 | + 'hAddSimpleTag#SOUR' => 50, |
|
86 | + 'hHasHelpTextTag#_ACT' => 50, |
|
87 | + 'hGetHelpTextTag#_ACT' => 50 |
|
88 | + ); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * {@inhericDoc} |
|
93 | - * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu() |
|
94 | - */ |
|
95 | - public function getMenu(Tree $tree, $reference = null) { |
|
96 | - $tree_url = $tree ? $tree->getNameUrl() : ''; |
|
97 | - return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow')); |
|
98 | - } |
|
91 | + /** |
|
92 | + * {@inhericDoc} |
|
93 | + * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu() |
|
94 | + */ |
|
95 | + public function getMenu(Tree $tree, $reference = null) { |
|
96 | + $tree_url = $tree ? $tree->getNameUrl() : ''; |
|
97 | + return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow')); |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * {@inhericDoc} |
|
102 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourcePrepend() |
|
103 | - */ |
|
104 | - public function hFactSourcePrepend($srec) { |
|
105 | - $wt_tree = Globals::getTree(); |
|
106 | - $html=''; |
|
107 | - $sid=null; |
|
100 | + /** |
|
101 | + * {@inhericDoc} |
|
102 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourcePrepend() |
|
103 | + */ |
|
104 | + public function hFactSourcePrepend($srec) { |
|
105 | + $wt_tree = Globals::getTree(); |
|
106 | + $html=''; |
|
107 | + $sid=null; |
|
108 | 108 | |
109 | - if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($wt_tree)){ |
|
110 | - if (!$srec || strlen($srec) == 0) return $html; |
|
109 | + if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($wt_tree)){ |
|
110 | + if (!$srec || strlen($srec) == 0) return $html; |
|
111 | 111 | |
112 | - $certificate = null; |
|
113 | - $subrecords = explode("\n", $srec); |
|
114 | - $levelSOUR = substr($subrecords[0], 0, 1); |
|
115 | - $match = null; |
|
116 | - if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) { |
|
117 | - $sid=$match[1]; |
|
118 | - }; |
|
119 | - $nb_subrecords = count($subrecords); |
|
120 | - for ($i=0; $i < $nb_subrecords; $i++) { |
|
121 | - $subrecords[$i] = trim($subrecords[$i]); |
|
122 | - $tag = substr($subrecords[$i], 2, 4); |
|
123 | - $text = substr($subrecords[$i], 7); |
|
124 | - if($tag == '_ACT') $certificate= new Certificate($text, $wt_tree, $this->getProvider()); |
|
125 | - } |
|
112 | + $certificate = null; |
|
113 | + $subrecords = explode("\n", $srec); |
|
114 | + $levelSOUR = substr($subrecords[0], 0, 1); |
|
115 | + $match = null; |
|
116 | + if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) { |
|
117 | + $sid=$match[1]; |
|
118 | + }; |
|
119 | + $nb_subrecords = count($subrecords); |
|
120 | + for ($i=0; $i < $nb_subrecords; $i++) { |
|
121 | + $subrecords[$i] = trim($subrecords[$i]); |
|
122 | + $tag = substr($subrecords[$i], 2, 4); |
|
123 | + $text = substr($subrecords[$i], 7); |
|
124 | + if($tag == '_ACT') $certificate= new Certificate($text, $wt_tree, $this->getProvider()); |
|
125 | + } |
|
126 | 126 | |
127 | - if($certificate && $certificate->canShow()) |
|
128 | - $html = $this->getDisplay_ACT($certificate, $sid); |
|
127 | + if($certificate && $certificate->canShow()) |
|
128 | + $html = $this->getDisplay_ACT($certificate, $sid); |
|
129 | 129 | |
130 | - } |
|
131 | - return $html; |
|
132 | - } |
|
130 | + } |
|
131 | + return $html; |
|
132 | + } |
|
133 | 133 | |
134 | - /** |
|
135 | - * {@inhericDoc} |
|
136 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourceAppend() |
|
137 | - */ |
|
138 | - public function hFactSourceAppend($srec) { } |
|
134 | + /** |
|
135 | + * {@inhericDoc} |
|
136 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourceAppend() |
|
137 | + */ |
|
138 | + public function hFactSourceAppend($srec) { } |
|
139 | 139 | |
140 | - /** |
|
141 | - * {@inhericDoc} |
|
142 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetExpectedTags() |
|
143 | - */ |
|
144 | - public function hGetExpectedTags() { |
|
145 | - return array('SOUR' => '_ACT'); |
|
146 | - } |
|
140 | + /** |
|
141 | + * {@inhericDoc} |
|
142 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetExpectedTags() |
|
143 | + */ |
|
144 | + public function hGetExpectedTags() { |
|
145 | + return array('SOUR' => '_ACT'); |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * {@inhericDoc} |
|
150 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagDisplay() |
|
151 | - */ |
|
152 | - public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) { |
|
153 | - $html = ''; |
|
154 | - switch($tag){ |
|
155 | - case '_ACT': |
|
156 | - if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
157 | - break; |
|
158 | - } |
|
159 | - return $html; |
|
160 | - } |
|
148 | + /** |
|
149 | + * {@inhericDoc} |
|
150 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagDisplay() |
|
151 | + */ |
|
152 | + public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) { |
|
153 | + $html = ''; |
|
154 | + switch($tag){ |
|
155 | + case '_ACT': |
|
156 | + if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
157 | + break; |
|
158 | + } |
|
159 | + return $html; |
|
160 | + } |
|
161 | 161 | |
162 | - /** |
|
163 | - * {@inhericDoc} |
|
164 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagEditor() |
|
165 | - */ |
|
166 | - public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) { |
|
167 | - $html = ''; |
|
162 | + /** |
|
163 | + * {@inhericDoc} |
|
164 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagEditor() |
|
165 | + */ |
|
166 | + public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) { |
|
167 | + $html = ''; |
|
168 | 168 | |
169 | 169 | switch($tag){ |
170 | 170 | case '_ACT': |
@@ -192,75 +192,75 @@ discard block |
||
192 | 192 | } |
193 | 193 | |
194 | 194 | return $html; |
195 | - } |
|
195 | + } |
|
196 | 196 | |
197 | - /** |
|
198 | - * {@inhericDoc} |
|
199 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag() |
|
200 | - */ |
|
201 | - public function hAddSimpleTag($context, $level) { |
|
202 | - switch($context){ |
|
203 | - case 'SOUR': |
|
204 | - FunctionsEdit::addSimpleTag($level.' _ACT'); |
|
205 | - break; |
|
206 | - } |
|
207 | - } |
|
197 | + /** |
|
198 | + * {@inhericDoc} |
|
199 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag() |
|
200 | + */ |
|
201 | + public function hAddSimpleTag($context, $level) { |
|
202 | + switch($context){ |
|
203 | + case 'SOUR': |
|
204 | + FunctionsEdit::addSimpleTag($level.' _ACT'); |
|
205 | + break; |
|
206 | + } |
|
207 | + } |
|
208 | 208 | |
209 | - /** |
|
210 | - * {@inhericDoc} |
|
211 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag() |
|
212 | - */ |
|
213 | - public function hHasHelpTextTag($tag) { |
|
214 | - switch($tag){ |
|
209 | + /** |
|
210 | + * {@inhericDoc} |
|
211 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag() |
|
212 | + */ |
|
213 | + public function hHasHelpTextTag($tag) { |
|
214 | + switch($tag){ |
|
215 | 215 | case '_ACT': |
216 | 216 | return true; |
217 | 217 | } |
218 | 218 | return false; |
219 | - } |
|
219 | + } |
|
220 | 220 | |
221 | - /** |
|
222 | - * {@inhericDoc} |
|
223 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag() |
|
224 | - */ |
|
225 | - public function hGetHelpTextTag($tag) { |
|
226 | - switch($tag){ |
|
227 | - case '_ACT': |
|
228 | - return array( |
|
229 | - I18N::translate('Certificate'), |
|
230 | - '<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>'); |
|
231 | - default: |
|
232 | - return null; |
|
233 | - } |
|
234 | - } |
|
221 | + /** |
|
222 | + * {@inhericDoc} |
|
223 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag() |
|
224 | + */ |
|
225 | + public function hGetHelpTextTag($tag) { |
|
226 | + switch($tag){ |
|
227 | + case '_ACT': |
|
228 | + return array( |
|
229 | + I18N::translate('Certificate'), |
|
230 | + '<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>'); |
|
231 | + default: |
|
232 | + return null; |
|
233 | + } |
|
234 | + } |
|
235 | 235 | |
236 | - /** |
|
237 | - * Returns the default Certificate File Provider, as configured in the module |
|
238 | - * |
|
239 | - * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface |
|
240 | - */ |
|
241 | - public function getProvider() { |
|
242 | - if(!$this->provider) { |
|
243 | - $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/'); |
|
244 | - $this->provider = new CertificateFileProvider($root_path, Globals::getTree()); |
|
245 | - } |
|
246 | - return $this->provider; |
|
247 | - } |
|
236 | + /** |
|
237 | + * Returns the default Certificate File Provider, as configured in the module |
|
238 | + * |
|
239 | + * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface |
|
240 | + */ |
|
241 | + public function getProvider() { |
|
242 | + if(!$this->provider) { |
|
243 | + $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/'); |
|
244 | + $this->provider = new CertificateFileProvider($root_path, Globals::getTree()); |
|
245 | + } |
|
246 | + return $this->provider; |
|
247 | + } |
|
248 | 248 | |
249 | 249 | |
250 | - /** |
|
251 | - * Return the HTML code for custom simple tag _ACT |
|
252 | - * |
|
253 | - * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
|
254 | - * @param string|null $sid Linked Source ID, if it exists |
|
255 | - */ |
|
256 | - protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
|
257 | - $html = ''; |
|
258 | - if($certificate){ |
|
259 | - $certificate->setSource($sid); |
|
260 | - $html = $certificate->displayImage('icon'); |
|
261 | - } |
|
262 | - return $html; |
|
263 | - } |
|
250 | + /** |
|
251 | + * Return the HTML code for custom simple tag _ACT |
|
252 | + * |
|
253 | + * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
|
254 | + * @param string|null $sid Linked Source ID, if it exists |
|
255 | + */ |
|
256 | + protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
|
257 | + $html = ''; |
|
258 | + if($certificate){ |
|
259 | + $certificate->setSource($sid); |
|
260 | + $html = $certificate->displayImage('icon'); |
|
261 | + } |
|
262 | + return $html; |
|
263 | + } |
|
264 | 264 | |
265 | 265 | |
266 | 266 | } |