@@ -52,7 +52,7 @@ |
||
52 | 52 | /** |
53 | 53 | * Find the spouse of a person, using the Xref comparison. |
54 | 54 | * |
55 | - * @param Individual $person |
|
55 | + * @param fw\Individual $person |
|
56 | 56 | * |
57 | 57 | * @return Individual|null |
58 | 58 | */ |
@@ -39,10 +39,10 @@ |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | - * Check if this family's marriages are sourced |
|
43 | - * |
|
44 | - * @return int Level of sources |
|
45 | - * */ |
|
42 | + * Check if this family's marriages are sourced |
|
43 | + * |
|
44 | + * @return int Level of sources |
|
45 | + * */ |
|
46 | 46 | function isMarriageSourced(){ |
47 | 47 | if($this->_ismarriagesourced != null) return $this->_ismarriagesourced; |
48 | 48 | $this->_ismarriagesourced = $this->isFactSourced(WT_EVENTS_MARR.'|MARC'); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param \Fisharebest\Webtrees\Place $place |
76 | 76 | * @param string $icon_path |
77 | - * @param number $size |
|
77 | + * @param integer $size |
|
78 | 78 | * @return string HTML code of the inserted flag |
79 | 79 | */ |
80 | 80 | public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) { |
@@ -184,7 +184,6 @@ discard block |
||
184 | 184 | /** |
185 | 185 | * Format date to display short (just years) |
186 | 186 | * |
187 | - * @param \Fisharebest\Webtrees\Fact $eventObj Fact to display date |
|
188 | 187 | * @param boolean $anchor option to print a link to calendar |
189 | 188 | * @return string HTML code for short date |
190 | 189 | */ |
@@ -212,7 +211,6 @@ discard block |
||
212 | 211 | /** |
213 | 212 | * Format fact place to display short |
214 | 213 | * |
215 | - * @param \Fisharebest\Webtrees\Fact $eventObj Fact to display date |
|
216 | 214 | * @param string $format Format of the place |
217 | 215 | * @param boolean $anchor option to print a link to placelist |
218 | 216 | * @return string HTML code for short place |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @return string HTML code of the inserted flag |
80 | 80 | */ |
81 | 81 | public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) { |
82 | - return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />'; |
|
82 | + return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />'; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * @return boolean |
356 | 356 | */ |
357 | 357 | public static function isDateWithinChartsRange(Date $date) { |
358 | - return $date->gregorianYear() >= 1550 && $date->gregorianYear() < 2030; |
|
358 | + return $date->gregorianYear() >= 1550 && $date->gregorianYear() < 2030; |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * Returns an estimated birth place based on statistics on the base |
94 | 94 | * |
95 | 95 | * @param boolean $perc Should the coefficient of reliability be returned |
96 | - * @return string|array Estimated birth place if found, null otherwise |
|
96 | + * @return string Estimated birth place if found, null otherwise |
|
97 | 97 | */ |
98 | 98 | public function getEstimatedBirthPlace($perc=false){ |
99 | 99 | if($bplace = $this->gedcomrecord->getBirthPlace()){ |
@@ -110,7 +110,6 @@ discard block |
||
110 | 110 | /** |
111 | 111 | * Returns a significant place for the individual |
112 | 112 | * |
113 | - * @param boolean $perc Should the coefficient of reliability be returned |
|
114 | 113 | * @return string|array Estimated birth place if found, null otherwise |
115 | 114 | */ |
116 | 115 | public function getSignificantPlace(){ |
@@ -113,29 +113,29 @@ discard block |
||
113 | 113 | * @return string|array Estimated birth place if found, null otherwise |
114 | 114 | */ |
115 | 115 | public function getSignificantPlace(){ |
116 | - if($bplace = $this->gedcomrecord->getBirthPlace()){ |
|
117 | - return $bplace; |
|
118 | - } |
|
116 | + if($bplace = $this->gedcomrecord->getBirthPlace()){ |
|
117 | + return $bplace; |
|
118 | + } |
|
119 | 119 | |
120 | - foreach ($this->gedcomrecord->getAllEventPlaces('RESI') as $rplace) { |
|
121 | - if ($rplace) { |
|
122 | - return $rplace; |
|
123 | - } |
|
124 | - } |
|
120 | + foreach ($this->gedcomrecord->getAllEventPlaces('RESI') as $rplace) { |
|
121 | + if ($rplace) { |
|
122 | + return $rplace; |
|
123 | + } |
|
124 | + } |
|
125 | 125 | |
126 | - if($dplace = $this->gedcomrecord->getDeathPlace()){ |
|
127 | - return $dplace; |
|
128 | - } |
|
126 | + if($dplace = $this->gedcomrecord->getDeathPlace()){ |
|
127 | + return $dplace; |
|
128 | + } |
|
129 | 129 | |
130 | - foreach($this->gedcomrecord->getSpouseFamilies() as $fams) { |
|
131 | - foreach ($fams->getAllEventPlaces('RESI') as $rplace) { |
|
132 | - if ($rplace) { |
|
133 | - return $rplace; |
|
134 | - } |
|
135 | - } |
|
136 | - } |
|
130 | + foreach($this->gedcomrecord->getSpouseFamilies() as $fams) { |
|
131 | + foreach ($fams->getAllEventPlaces('RESI') as $rplace) { |
|
132 | + if ($rplace) { |
|
133 | + return $rplace; |
|
134 | + } |
|
135 | + } |
|
136 | + } |
|
137 | 137 | |
138 | - return null; |
|
138 | + return null; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return boolean Is the individual a Sosa ancestor |
145 | 145 | */ |
146 | 146 | public function isSosa(){ |
147 | - return count($this->getSosaNumbers()) > 0; |
|
147 | + return count($this->getSosaNumbers()) > 0; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | * @return array List of Sosa numbers |
156 | 156 | */ |
157 | 157 | public function getSosaNumbers(){ |
158 | - if($this->sosa === null) { |
|
159 | - $provider = new SosaProvider($this->gedcomrecord->getTree()); |
|
160 | - $this->sosa = $provider->getSosaNumbers($this->gedcomrecord); |
|
161 | - } |
|
162 | - return $this->sosa; |
|
158 | + if($this->sosa === null) { |
|
159 | + $provider = new SosaProvider($this->gedcomrecord->getTree()); |
|
160 | + $this->sosa = $provider->getSosaNumbers($this->gedcomrecord); |
|
161 | + } |
|
162 | + return $this->sosa; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
177 | - * Check if this individual's death is sourced |
|
178 | - * |
|
179 | - * @return int Level of sources |
|
180 | - * */ |
|
177 | + * Check if this individual's death is sourced |
|
178 | + * |
|
179 | + * @return int Level of sources |
|
180 | + * */ |
|
181 | 181 | public function isDeathSourced(){ |
182 | 182 | if($this->is_death_sourced !== null) return $this->is_death_sourced; |
183 | 183 | $this->is_death_sourced = $this->isFactSourced(WT_EVENTS_DEAT); |
@@ -110,7 +110,7 @@ |
||
110 | 110 | * Set parameters of the Task |
111 | 111 | * |
112 | 112 | * @param bool $is_enabled Status of the task |
113 | - * @param \DateTime $lastupdated Time of the last task run |
|
113 | + * @param \DateTime $last_updated Time of the last task run |
|
114 | 114 | * @param bool $last_result Result of the last run, true for success, false for failure |
115 | 115 | * @param int $frequency Frequency of execution in minutes |
116 | 116 | * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited |
@@ -20,253 +20,253 @@ |
||
20 | 20 | */ |
21 | 21 | abstract class AbstractTask { |
22 | 22 | |
23 | - /** |
|
24 | - * Time out for runnign tasks, in seconds. Default 5 min |
|
25 | - * @var int TASK_TIME_OUT |
|
26 | - */ |
|
27 | - const TASK_TIME_OUT = 300; |
|
23 | + /** |
|
24 | + * Time out for runnign tasks, in seconds. Default 5 min |
|
25 | + * @var int TASK_TIME_OUT |
|
26 | + */ |
|
27 | + const TASK_TIME_OUT = 300; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Task provider |
|
31 | - * @var TaskProviderInterface $provider |
|
32 | - */ |
|
29 | + /** |
|
30 | + * Task provider |
|
31 | + * @var TaskProviderInterface $provider |
|
32 | + */ |
|
33 | 33 | protected $provider; |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Task name |
37 | 37 | * @var string $name |
38 | 38 | */ |
39 | - protected $name; |
|
39 | + protected $name; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Status of the task |
|
43 | - * @var bool $is_enabled |
|
44 | - */ |
|
45 | - protected $is_enabled; |
|
41 | + /** |
|
42 | + * Status of the task |
|
43 | + * @var bool $is_enabled |
|
44 | + */ |
|
45 | + protected $is_enabled; |
|
46 | 46 | |
47 | - /** |
|
48 | - * Last updated date |
|
49 | - * @var \DateTime $last_updated |
|
50 | - */ |
|
51 | - protected $last_updated; |
|
47 | + /** |
|
48 | + * Last updated date |
|
49 | + * @var \DateTime $last_updated |
|
50 | + */ |
|
51 | + protected $last_updated; |
|
52 | 52 | |
53 | - /** |
|
54 | - * Last run result |
|
55 | - * @var bool $last_result |
|
56 | - */ |
|
57 | - protected $last_result; |
|
53 | + /** |
|
54 | + * Last run result |
|
55 | + * @var bool $last_result |
|
56 | + */ |
|
57 | + protected $last_result; |
|
58 | 58 | |
59 | - /** |
|
60 | - * Task run frequency |
|
61 | - * @var int $frequency |
|
62 | - */ |
|
63 | - protected $frequency; |
|
59 | + /** |
|
60 | + * Task run frequency |
|
61 | + * @var int $frequency |
|
62 | + */ |
|
63 | + protected $frequency; |
|
64 | 64 | |
65 | - /** |
|
66 | - * Task remaining runs |
|
67 | - * @var int $nb_occurrences |
|
68 | - */ |
|
69 | - protected $nb_occurrences; |
|
65 | + /** |
|
66 | + * Task remaining runs |
|
67 | + * @var int $nb_occurrences |
|
68 | + */ |
|
69 | + protected $nb_occurrences; |
|
70 | 70 | |
71 | - /** |
|
72 | - * Current running status of the task |
|
73 | - * @var bool $is_running |
|
74 | - */ |
|
75 | - protected $is_running; |
|
71 | + /** |
|
72 | + * Current running status of the task |
|
73 | + * @var bool $is_running |
|
74 | + */ |
|
75 | + protected $is_running; |
|
76 | 76 | |
77 | - /** |
|
78 | - * Constructor for the Admin task class |
|
77 | + /** |
|
78 | + * Constructor for the Admin task class |
|
79 | 79 | * |
80 | 80 | * @param string $file Filename containing the task object |
81 | 81 | * @param TaskProviderInterface $provider Provider for tasks |
82 | - */ |
|
83 | - public function __construct($file, TaskProviderInterface $provider = null){ |
|
84 | - $this->name = trim(basename($file, '.php')); |
|
82 | + */ |
|
83 | + public function __construct($file, TaskProviderInterface $provider = null){ |
|
84 | + $this->name = trim(basename($file, '.php')); |
|
85 | 85 | $this->provider = $provider; |
86 | - } |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * Get the provider. |
|
90 | - * |
|
91 | - * @return TaskProviderInterface |
|
92 | - */ |
|
93 | - public function getProvider(){ |
|
94 | - return $this->provider; |
|
95 | - } |
|
88 | + /** |
|
89 | + * Get the provider. |
|
90 | + * |
|
91 | + * @return TaskProviderInterface |
|
92 | + */ |
|
93 | + public function getProvider(){ |
|
94 | + return $this->provider; |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * Set the provider. |
|
99 | - * |
|
100 | - * @param TaskProviderInterface $provider |
|
101 | - * @return self Enable method-chaining |
|
102 | - */ |
|
103 | - public function setProvider(TaskProviderInterface $provider){ |
|
104 | - $this->provider = $provider; |
|
105 | - return $this; |
|
106 | - } |
|
97 | + /** |
|
98 | + * Set the provider. |
|
99 | + * |
|
100 | + * @param TaskProviderInterface $provider |
|
101 | + * @return self Enable method-chaining |
|
102 | + */ |
|
103 | + public function setProvider(TaskProviderInterface $provider){ |
|
104 | + $this->provider = $provider; |
|
105 | + return $this; |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Set parameters of the Task |
|
110 | - * |
|
111 | - * @param bool $is_enabled Status of the task |
|
112 | - * @param \DateTime $lastupdated Time of the last task run |
|
113 | - * @param bool $last_result Result of the last run, true for success, false for failure |
|
114 | - * @param int $frequency Frequency of execution in minutes |
|
115 | - * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited |
|
116 | - * @param bool $is_running Indicates if the task is currently running |
|
117 | - */ |
|
118 | - public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running){ |
|
119 | - $this->is_enabled = $is_enabled; |
|
120 | - $this->last_updated = $last_updated; |
|
121 | - $this->last_result = $last_result; |
|
122 | - $this->frequency = $frequency; |
|
123 | - $this->nb_occurrences = $nb_occur; |
|
124 | - $this->is_running = $is_running; |
|
125 | - } |
|
108 | + /** |
|
109 | + * Set parameters of the Task |
|
110 | + * |
|
111 | + * @param bool $is_enabled Status of the task |
|
112 | + * @param \DateTime $lastupdated Time of the last task run |
|
113 | + * @param bool $last_result Result of the last run, true for success, false for failure |
|
114 | + * @param int $frequency Frequency of execution in minutes |
|
115 | + * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited |
|
116 | + * @param bool $is_running Indicates if the task is currently running |
|
117 | + */ |
|
118 | + public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running){ |
|
119 | + $this->is_enabled = $is_enabled; |
|
120 | + $this->last_updated = $last_updated; |
|
121 | + $this->last_result = $last_result; |
|
122 | + $this->frequency = $frequency; |
|
123 | + $this->nb_occurrences = $nb_occur; |
|
124 | + $this->is_running = $is_running; |
|
125 | + } |
|
126 | 126 | |
127 | - /** |
|
128 | - * Get the name of the task |
|
129 | - * |
|
130 | - * @return string |
|
131 | - */ |
|
132 | - public function getName(){ |
|
133 | - return $this->name; |
|
134 | - } |
|
127 | + /** |
|
128 | + * Get the name of the task |
|
129 | + * |
|
130 | + * @return string |
|
131 | + */ |
|
132 | + public function getName(){ |
|
133 | + return $this->name; |
|
134 | + } |
|
135 | 135 | |
136 | 136 | |
137 | - /** |
|
138 | - * Return the status of the task in a boolean way |
|
139 | - * |
|
140 | - * @return boolean True if enabled |
|
141 | - */ |
|
142 | - public function isEnabled(){ |
|
143 | - return $this->is_enabled; |
|
144 | - } |
|
137 | + /** |
|
138 | + * Return the status of the task in a boolean way |
|
139 | + * |
|
140 | + * @return boolean True if enabled |
|
141 | + */ |
|
142 | + public function isEnabled(){ |
|
143 | + return $this->is_enabled; |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * Get the last updated time. |
|
148 | - * |
|
149 | - * @return \DateTime |
|
150 | - */ |
|
151 | - public function getLastUpdated(){ |
|
152 | - return $this->last_updated; |
|
153 | - } |
|
146 | + /** |
|
147 | + * Get the last updated time. |
|
148 | + * |
|
149 | + * @return \DateTime |
|
150 | + */ |
|
151 | + public function getLastUpdated(){ |
|
152 | + return $this->last_updated; |
|
153 | + } |
|
154 | 154 | |
155 | - /** |
|
156 | - * Check if the last result has been successful. |
|
157 | - * |
|
158 | - * @return bool |
|
159 | - */ |
|
160 | - public function isLastRunSuccess(){ |
|
161 | - return $this->last_result; |
|
162 | - } |
|
155 | + /** |
|
156 | + * Check if the last result has been successful. |
|
157 | + * |
|
158 | + * @return bool |
|
159 | + */ |
|
160 | + public function isLastRunSuccess(){ |
|
161 | + return $this->last_result; |
|
162 | + } |
|
163 | 163 | |
164 | - /** |
|
165 | - * Get the task frequency. |
|
166 | - * |
|
167 | - * @return int |
|
168 | - */ |
|
169 | - public function getFrequency(){ |
|
170 | - return $this->frequency; |
|
171 | - } |
|
164 | + /** |
|
165 | + * Get the task frequency. |
|
166 | + * |
|
167 | + * @return int |
|
168 | + */ |
|
169 | + public function getFrequency(){ |
|
170 | + return $this->frequency; |
|
171 | + } |
|
172 | 172 | |
173 | 173 | /** |
174 | - * Set the task frequency. |
|
175 | - * |
|
174 | + * Set the task frequency. |
|
175 | + * |
|
176 | 176 | * @param int $frequency |
177 | - * @return self Enable method-chaining |
|
178 | - */ |
|
179 | - public function setFrequency($frequency){ |
|
180 | - $this->frequency = $frequency; |
|
177 | + * @return self Enable method-chaining |
|
178 | + */ |
|
179 | + public function setFrequency($frequency){ |
|
180 | + $this->frequency = $frequency; |
|
181 | 181 | return $this; |
182 | - } |
|
182 | + } |
|
183 | 183 | |
184 | - /** |
|
185 | - * Get the number of remaining occurrences. |
|
186 | - * |
|
187 | - * @return int |
|
188 | - */ |
|
189 | - public function getRemainingOccurrences(){ |
|
190 | - return $this->nb_occurrences; |
|
191 | - } |
|
184 | + /** |
|
185 | + * Get the number of remaining occurrences. |
|
186 | + * |
|
187 | + * @return int |
|
188 | + */ |
|
189 | + public function getRemainingOccurrences(){ |
|
190 | + return $this->nb_occurrences; |
|
191 | + } |
|
192 | 192 | |
193 | 193 | /** |
194 | - * Set the number of remaining occurrences. |
|
195 | - * |
|
194 | + * Set the number of remaining occurrences. |
|
195 | + * |
|
196 | 196 | * @param int $nb_occur |
197 | - * @return self Enable method-chaining |
|
198 | - */ |
|
199 | - public function setRemainingOccurrences($nb_occur){ |
|
200 | - $this->nb_occurrences = $nb_occur; |
|
197 | + * @return self Enable method-chaining |
|
198 | + */ |
|
199 | + public function setRemainingOccurrences($nb_occur){ |
|
200 | + $this->nb_occurrences = $nb_occur; |
|
201 | 201 | return $this; |
202 | - } |
|
202 | + } |
|
203 | 203 | |
204 | - /** |
|
205 | - * Check if the task if running. |
|
206 | - * |
|
207 | - * @return bool |
|
208 | - */ |
|
209 | - public function isRunning(){ |
|
210 | - return $this->is_running; |
|
211 | - } |
|
204 | + /** |
|
205 | + * Check if the task if running. |
|
206 | + * |
|
207 | + * @return bool |
|
208 | + */ |
|
209 | + public function isRunning(){ |
|
210 | + return $this->is_running; |
|
211 | + } |
|
212 | 212 | |
213 | 213 | |
214 | - /** |
|
215 | - * Return the name to display for the task |
|
216 | - * |
|
217 | - * @return string Title for the task |
|
218 | - */ |
|
219 | - abstract public function getTitle(); |
|
214 | + /** |
|
215 | + * Return the name to display for the task |
|
216 | + * |
|
217 | + * @return string Title for the task |
|
218 | + */ |
|
219 | + abstract public function getTitle(); |
|
220 | 220 | |
221 | - /** |
|
222 | - * Return the default frequency for the execution of the task |
|
223 | - * |
|
224 | - * @return int Frequency for the execution of the task |
|
225 | - */ |
|
226 | - abstract public function getDefaultFrequency(); |
|
221 | + /** |
|
222 | + * Return the default frequency for the execution of the task |
|
223 | + * |
|
224 | + * @return int Frequency for the execution of the task |
|
225 | + */ |
|
226 | + abstract public function getDefaultFrequency(); |
|
227 | 227 | |
228 | - /** |
|
229 | - * Execute the task's actions |
|
230 | - */ |
|
231 | - abstract protected function executeSteps(); |
|
228 | + /** |
|
229 | + * Execute the task's actions |
|
230 | + */ |
|
231 | + abstract protected function executeSteps(); |
|
232 | 232 | |
233 | 233 | /** |
234 | 234 | * Persist task state into database. |
235 | 235 | * @return bool |
236 | 236 | */ |
237 | 237 | public function save() { |
238 | - if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.'); |
|
238 | + if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.'); |
|
239 | 239 | return $this->provider->updateTask($this); |
240 | 240 | } |
241 | 241 | |
242 | - /** |
|
243 | - * Execute the task, default skeleton |
|
244 | - * |
|
245 | - */ |
|
246 | - public function execute(){ |
|
242 | + /** |
|
243 | + * Execute the task, default skeleton |
|
244 | + * |
|
245 | + */ |
|
246 | + public function execute(){ |
|
247 | 247 | |
248 | - if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
249 | - $this->is_running = false; |
|
248 | + if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
249 | + $this->is_running = false; |
|
250 | 250 | |
251 | - if(!$this->is_running){ |
|
252 | - $this->last_result = false; |
|
253 | - $this->is_running = true; |
|
254 | - $this->save(); |
|
251 | + if(!$this->is_running){ |
|
252 | + $this->last_result = false; |
|
253 | + $this->is_running = true; |
|
254 | + $this->save(); |
|
255 | 255 | |
256 | - Log::addDebugLog('Start execution of Admin task: '.$this->getTitle()); |
|
257 | - $this->last_result = $this->executeSteps(); |
|
258 | - if($this->last_result){ |
|
259 | - $this->last_updated = new \DateTime(); |
|
260 | - if($this->nb_occurrences > 0){ |
|
261 | - $this->nb_occurrences--; |
|
262 | - if($this->nb_occurrences == 0) $this->is_enabled = false; |
|
263 | - } |
|
264 | - } |
|
265 | - $this->is_running = false; |
|
266 | - $this->save(); |
|
267 | - Log::addDebugLog('Execution completed for Admin task: '.$this->getTitle().' - '.($this->last_result ? 'Success' : 'Failure')); |
|
268 | - } |
|
269 | - } |
|
256 | + Log::addDebugLog('Start execution of Admin task: '.$this->getTitle()); |
|
257 | + $this->last_result = $this->executeSteps(); |
|
258 | + if($this->last_result){ |
|
259 | + $this->last_updated = new \DateTime(); |
|
260 | + if($this->nb_occurrences > 0){ |
|
261 | + $this->nb_occurrences--; |
|
262 | + if($this->nb_occurrences == 0) $this->is_enabled = false; |
|
263 | + } |
|
264 | + } |
|
265 | + $this->is_running = false; |
|
266 | + $this->save(); |
|
267 | + Log::addDebugLog('Execution completed for Admin task: '.$this->getTitle().' - '.($this->last_result ? 'Success' : 'Failure')); |
|
268 | + } |
|
269 | + } |
|
270 | 270 | |
271 | 271 | |
272 | 272 | } |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | * Set the status of a specific admin task. |
33 | 33 | * The status can be enabled (true), or disabled (false). |
34 | 34 | * |
35 | - * @param AbstractTask $ga |
|
36 | 35 | * @param bool $status |
36 | + * @return void |
|
37 | 37 | */ |
38 | 38 | public function setTaskStatus(AbstractTask $task, $status); |
39 | 39 | |
@@ -49,6 +49,7 @@ discard block |
||
49 | 49 | * Delete the task from the database, in a transactional manner. |
50 | 50 | * |
51 | 51 | * @param string $task_name Task to delete |
52 | + * @return boolean |
|
52 | 53 | */ |
53 | 54 | public function deleteTask($task_name); |
54 | 55 | |
@@ -75,7 +76,7 @@ discard block |
||
75 | 76 | * Returns the list of tasks that are currently meant to run. |
76 | 77 | * Tasks to run can be forced, or can be limited to only one. |
77 | 78 | * |
78 | - * @param string|null $force Force the enabled tasks to run. |
|
79 | + * @param boolean $force Force the enabled tasks to run. |
|
79 | 80 | * @param string|null $task_name Name of the specific task to run |
80 | 81 | */ |
81 | 82 | function getTasksToRun($force = false, $task_name = null); |
@@ -37,47 +37,47 @@ |
||
37 | 37 | */ |
38 | 38 | public function setTaskStatus(AbstractTask $task, $status); |
39 | 39 | |
40 | - /** |
|
41 | - * Update an Admin Task in the database. |
|
42 | - * |
|
43 | - * @param AbstractTask $task Task to update |
|
44 | - * @return bool |
|
45 | - */ |
|
46 | - function updateTask(AbstractTask $task); |
|
40 | + /** |
|
41 | + * Update an Admin Task in the database. |
|
42 | + * |
|
43 | + * @param AbstractTask $task Task to update |
|
44 | + * @return bool |
|
45 | + */ |
|
46 | + function updateTask(AbstractTask $task); |
|
47 | 47 | |
48 | - /** |
|
49 | - * Delete the task from the database, in a transactional manner. |
|
50 | - * |
|
51 | - * @param string $task_name Task to delete |
|
52 | - */ |
|
53 | - public function deleteTask($task_name); |
|
48 | + /** |
|
49 | + * Delete the task from the database, in a transactional manner. |
|
50 | + * |
|
51 | + * @param string $task_name Task to delete |
|
52 | + */ |
|
53 | + public function deleteTask($task_name); |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Returns the number of Admin Tasks (active and inactive). |
|
58 | - * |
|
59 | - * @return int |
|
60 | - */ |
|
61 | - public function getTasksCount(); |
|
56 | + /** |
|
57 | + * Returns the number of Admin Tasks (active and inactive). |
|
58 | + * |
|
59 | + * @return int |
|
60 | + */ |
|
61 | + public function getTasksCount(); |
|
62 | 62 | |
63 | - /** |
|
64 | - * Return the list of Admin Tasks matching specified criterias. |
|
65 | - * |
|
66 | - * @param string $search Search criteria in analysis description |
|
67 | - * @param array $order_by Columns to order by |
|
68 | - * @param int $start Offset to start with (for pagination) |
|
69 | - * @param int|null $limit Max number of items to return (for pagination) |
|
70 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
71 | - */ |
|
72 | - function getFilteredTasksList($search = null, $order_by = null, $start = 0, $limit = null); |
|
63 | + /** |
|
64 | + * Return the list of Admin Tasks matching specified criterias. |
|
65 | + * |
|
66 | + * @param string $search Search criteria in analysis description |
|
67 | + * @param array $order_by Columns to order by |
|
68 | + * @param int $start Offset to start with (for pagination) |
|
69 | + * @param int|null $limit Max number of items to return (for pagination) |
|
70 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
71 | + */ |
|
72 | + function getFilteredTasksList($search = null, $order_by = null, $start = 0, $limit = null); |
|
73 | 73 | |
74 | - /** |
|
75 | - * Returns the list of tasks that are currently meant to run. |
|
76 | - * Tasks to run can be forced, or can be limited to only one. |
|
77 | - * |
|
78 | - * @param string|null $force Force the enabled tasks to run. |
|
79 | - * @param string|null $task_name Name of the specific task to run |
|
80 | - */ |
|
74 | + /** |
|
75 | + * Returns the list of tasks that are currently meant to run. |
|
76 | + * Tasks to run can be forced, or can be limited to only one. |
|
77 | + * |
|
78 | + * @param string|null $force Force the enabled tasks to run. |
|
79 | + * @param string|null $task_name Name of the specific task to run |
|
80 | + */ |
|
81 | 81 | function getTasksToRun($force = false, $task_name = null); |
82 | 82 | |
83 | 83 | /** |
@@ -109,6 +109,7 @@ discard block |
||
109 | 109 | /** |
110 | 110 | * {@inhericDoc} |
111 | 111 | * @see \Fisharebest\Webtrees\GedcomRecord::getInstance() |
112 | + * @param string $xref |
|
112 | 113 | */ |
113 | 114 | static public function getInstance($xref, Tree $tree, $gedcom = null, CertificateProviderInterface $provider = null) { |
114 | 115 | try{ |
@@ -150,7 +151,7 @@ discard block |
||
150 | 151 | /** |
151 | 152 | * Define a source associated with the certificate |
152 | 153 | * |
153 | - * @param string|Source $xref |
|
154 | + * @param string|null $xref |
|
154 | 155 | */ |
155 | 156 | public function setSource($xref){ |
156 | 157 | if($xref instanceof Source){ |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class Certificate extends Media { |
37 | 37 | |
38 | - const URL_PREFIX = 'module.php?mod=myartjaub_certificates&mod_action=Certificate&cid='; |
|
38 | + const URL_PREFIX = 'module.php?mod=myartjaub_certificates&mod_action=Certificate&cid='; |
|
39 | 39 | |
40 | - /** @var string The "TITL" value from the GEDCOM |
|
41 | - * This is a tweak to overcome the private level from the parent object... |
|
42 | - */ |
|
43 | - protected $title = ''; |
|
40 | + /** @var string The "TITL" value from the GEDCOM |
|
41 | + * This is a tweak to overcome the private level from the parent object... |
|
42 | + */ |
|
43 | + protected $title = ''; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Certificate provider |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param CertificateProviderInterface $provider |
81 | 81 | */ |
82 | 82 | public function __construct($data, Tree $tree, CertificateProviderInterface $provider) { |
83 | - $this->provider = $provider; |
|
83 | + $this->provider = $provider; |
|
84 | 84 | // Data is only the file name |
85 | 85 | $data = str_replace("\\", '/', $data); |
86 | 86 | $xref = Functions::encryptToSafeBase64($data); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @see \Fisharebest\Webtrees\Media::getTitle() |
166 | 166 | */ |
167 | 167 | public function getTitle() { |
168 | - return $this->title; |
|
168 | + return $this->title; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -241,26 +241,26 @@ discard block |
||
241 | 241 | $module = Module::getModuleByName(Constants::MODULE_MAJ_CERTIF_NAME); |
242 | 242 | |
243 | 243 | if($module) { |
244 | - $wmtext = $module->getSetting('MAJ_WM_DEFAULT', I18N::translate('This image is protected under copyright law.')); |
|
245 | - $sid= Filter::get('sid', WT_REGEX_XREF); |
|
244 | + $wmtext = $module->getSetting('MAJ_WM_DEFAULT', I18N::translate('This image is protected under copyright law.')); |
|
245 | + $sid= Filter::get('sid', WT_REGEX_XREF); |
|
246 | 246 | |
247 | - if($sid){ |
|
248 | - $this->source = Source::getInstance($sid, $this->tree); |
|
249 | - } |
|
250 | - else{ |
|
251 | - $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
|
252 | - } |
|
247 | + if($sid){ |
|
248 | + $this->source = Source::getInstance($sid, $this->tree); |
|
249 | + } |
|
250 | + else{ |
|
251 | + $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
|
252 | + } |
|
253 | 253 | |
254 | - if($this->source) { |
|
255 | - $wmtext = '©'; |
|
256 | - $repofact = $this->source->getFirstFact('REPO'); |
|
257 | - if($repofact) { |
|
258 | - $repo = $repofact->getTarget(); |
|
259 | - if($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
260 | - } |
|
261 | - $wmtext .= $this->source->getFullName(); |
|
262 | - } |
|
263 | - return $wmtext; |
|
254 | + if($this->source) { |
|
255 | + $wmtext = '©'; |
|
256 | + $repofact = $this->source->getFirstFact('REPO'); |
|
257 | + if($repofact) { |
|
258 | + $repo = $repofact->getTarget(); |
|
259 | + if($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
260 | + } |
|
261 | + $wmtext .= $this->source->getFullName(); |
|
262 | + } |
|
263 | + return $wmtext; |
|
264 | 264 | } |
265 | 265 | return ''; |
266 | 266 | } |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | ' FROM `##individuals`'. |
324 | 324 | ' WHERE i_file= :gedcom_id AND i_gedcom LIKE :gedcom') |
325 | 325 | ->execute(array( |
326 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
327 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
326 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
327 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
328 | 328 | ))->fetchAll(); |
329 | 329 | |
330 | 330 | $list = array(); |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | ' FROM `##families`'. |
348 | 348 | ' WHERE f_file= :gedcom_id AND f_gedcom LIKE :gedcom') |
349 | 349 | ->execute(array( |
350 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
351 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
350 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
351 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
352 | 352 | ))->fetchAll(); |
353 | 353 | |
354 | 354 | $list = array(); |
@@ -375,25 +375,25 @@ discard block |
||
375 | 375 | 'SELECT i_gedcom AS gedrec FROM `##individuals`'. |
376 | 376 | ' WHERE i_file=:gedcom_id AND i_gedcom LIKE :gedcom') |
377 | 377 | ->execute(array( |
378 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
379 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
378 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
379 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
380 | 380 | ))->fetchOne(); |
381 | 381 | if(!$ged){ |
382 | 382 | $ged = Database::prepare( |
383 | 383 | 'SELECT f_gedcom AS gedrec FROM `##families`'. |
384 | 384 | ' WHERE f_file=:gedcom_id AND f_gedcom LIKE :gedcom') |
385 | - ->execute(array( |
|
386 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
387 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
388 | - ))->fetchOne(); |
|
385 | + ->execute(array( |
|
386 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
387 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
388 | + ))->fetchOne(); |
|
389 | 389 | if(!$ged){ |
390 | 390 | $ged = Database::prepare( |
391 | - 'SELECT o_gedcom AS gedrec FROM `##other`'. |
|
392 | - ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom') |
|
393 | - ->execute(array( |
|
394 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
395 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
396 | - ))->fetchOne(); |
|
391 | + 'SELECT o_gedcom AS gedrec FROM `##other`'. |
|
392 | + ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom') |
|
393 | + ->execute(array( |
|
394 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
395 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
396 | + ))->fetchOne(); |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | //If a record has been found, parse it to find the source reference. |
@@ -252,7 +252,7 @@ |
||
252 | 252 | /** |
253 | 253 | * Return the HTML code for custom simple tag _ACT |
254 | 254 | * |
255 | - * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
|
255 | + * @param Certificate $certificate Certificate (as per the GEDCOM) |
|
256 | 256 | * @param string|null $sid Linked Source ID, if it exists |
257 | 257 | */ |
258 | 258 | protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
@@ -29,143 +29,143 @@ discard block |
||
29 | 29 | * Certificates Module. |
30 | 30 | */ |
31 | 31 | class CertificatesModule |
32 | - extends AbstractModule |
|
33 | - implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtenderInterface, CustomSimpleTagManagerInterface |
|
32 | + extends AbstractModule |
|
33 | + implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtenderInterface, CustomSimpleTagManagerInterface |
|
34 | 34 | { |
35 | - /** @var string For custom modules - link for support, upgrades, etc. */ |
|
36 | - const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
35 | + /** @var string For custom modules - link for support, upgrades, etc. */ |
|
36 | + const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Provider for Certificates |
|
40 | - * @var CertificateProviderInterface $provider |
|
41 | - */ |
|
42 | - protected $provider; |
|
38 | + /** |
|
39 | + * Provider for Certificates |
|
40 | + * @var CertificateProviderInterface $provider |
|
41 | + */ |
|
42 | + protected $provider; |
|
43 | 43 | |
44 | - /** |
|
45 | - * {@inhericDoc} |
|
46 | - */ |
|
47 | - public function getTitle() { |
|
48 | - return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates'); |
|
49 | - } |
|
44 | + /** |
|
45 | + * {@inhericDoc} |
|
46 | + */ |
|
47 | + public function getTitle() { |
|
48 | + return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates'); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * {@inhericDoc} |
|
53 | - */ |
|
54 | - public function getDescription() { |
|
55 | - return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.'); |
|
56 | - } |
|
51 | + /** |
|
52 | + * {@inhericDoc} |
|
53 | + */ |
|
54 | + public function getDescription() { |
|
55 | + return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.'); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * {@inhericDoc} |
|
60 | - */ |
|
61 | - public function modAction($mod_action) { |
|
62 | - \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
63 | - } |
|
58 | + /** |
|
59 | + * {@inhericDoc} |
|
60 | + */ |
|
61 | + public function modAction($mod_action) { |
|
62 | + \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * {@inhericDoc} |
|
67 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
68 | - */ |
|
69 | - public function getConfigLink() { |
|
70 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
71 | - } |
|
65 | + /** |
|
66 | + * {@inhericDoc} |
|
67 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
68 | + */ |
|
69 | + public function getConfigLink() { |
|
70 | + return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * {@inhericDoc} |
|
75 | - * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
76 | - */ |
|
77 | - public function getSubscribedHooks() { |
|
78 | - return array( |
|
79 | - 'hFactSourcePrepend' => 50, |
|
80 | - 'hGetExpectedTags' => 50, |
|
81 | - 'hHtmlSimpleTagDisplay#_ACT' => 50, |
|
82 | - 'hHtmlSimpleTagEditor#_ACT' => 50, |
|
83 | - 'hAddSimpleTag#SOUR' => 50, |
|
84 | - 'hHasHelpTextTag#_ACT' => 50, |
|
85 | - 'hGetHelpTextTag#_ACT' => 50 |
|
86 | - ); |
|
87 | - } |
|
73 | + /** |
|
74 | + * {@inhericDoc} |
|
75 | + * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
76 | + */ |
|
77 | + public function getSubscribedHooks() { |
|
78 | + return array( |
|
79 | + 'hFactSourcePrepend' => 50, |
|
80 | + 'hGetExpectedTags' => 50, |
|
81 | + 'hHtmlSimpleTagDisplay#_ACT' => 50, |
|
82 | + 'hHtmlSimpleTagEditor#_ACT' => 50, |
|
83 | + 'hAddSimpleTag#SOUR' => 50, |
|
84 | + 'hHasHelpTextTag#_ACT' => 50, |
|
85 | + 'hGetHelpTextTag#_ACT' => 50 |
|
86 | + ); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * {@inhericDoc} |
|
91 | - * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu() |
|
92 | - */ |
|
93 | - public function getMenu(Tree $tree, $reference = null) { |
|
94 | - $tree_url = $tree ? $tree->getNameUrl() : ''; |
|
95 | - return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow')); |
|
96 | - } |
|
89 | + /** |
|
90 | + * {@inhericDoc} |
|
91 | + * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu() |
|
92 | + */ |
|
93 | + public function getMenu(Tree $tree, $reference = null) { |
|
94 | + $tree_url = $tree ? $tree->getNameUrl() : ''; |
|
95 | + return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow')); |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * {@inhericDoc} |
|
100 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourcePrepend() |
|
101 | - */ |
|
102 | - public function hFactSourcePrepend($srec) { |
|
103 | - global $WT_TREE; |
|
98 | + /** |
|
99 | + * {@inhericDoc} |
|
100 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourcePrepend() |
|
101 | + */ |
|
102 | + public function hFactSourcePrepend($srec) { |
|
103 | + global $WT_TREE; |
|
104 | 104 | |
105 | - $html=''; |
|
106 | - $sid=null; |
|
105 | + $html=''; |
|
106 | + $sid=null; |
|
107 | 107 | |
108 | - if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){ |
|
109 | - if (!$srec || strlen($srec) == 0) return $html; |
|
108 | + if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){ |
|
109 | + if (!$srec || strlen($srec) == 0) return $html; |
|
110 | 110 | |
111 | - $certificate = null; |
|
112 | - $subrecords = explode("\n", $srec); |
|
113 | - $levelSOUR = substr($subrecords[0], 0, 1); |
|
114 | - $match = null; |
|
115 | - if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) { |
|
116 | - $sid=$match[1]; |
|
117 | - }; |
|
118 | - $nb_subrecords = count($subrecords); |
|
119 | - for ($i=0; $i < $nb_subrecords; $i++) { |
|
120 | - $subrecords[$i] = trim($subrecords[$i]); |
|
121 | - $tag = substr($subrecords[$i], 2, 4); |
|
122 | - $text = substr($subrecords[$i], 7); |
|
123 | - if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
124 | - } |
|
111 | + $certificate = null; |
|
112 | + $subrecords = explode("\n", $srec); |
|
113 | + $levelSOUR = substr($subrecords[0], 0, 1); |
|
114 | + $match = null; |
|
115 | + if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) { |
|
116 | + $sid=$match[1]; |
|
117 | + }; |
|
118 | + $nb_subrecords = count($subrecords); |
|
119 | + for ($i=0; $i < $nb_subrecords; $i++) { |
|
120 | + $subrecords[$i] = trim($subrecords[$i]); |
|
121 | + $tag = substr($subrecords[$i], 2, 4); |
|
122 | + $text = substr($subrecords[$i], 7); |
|
123 | + if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
124 | + } |
|
125 | 125 | |
126 | - if($certificate && $certificate->canShow()) |
|
127 | - $html = $this->getDisplay_ACT($certificate, $sid); |
|
126 | + if($certificate && $certificate->canShow()) |
|
127 | + $html = $this->getDisplay_ACT($certificate, $sid); |
|
128 | 128 | |
129 | - } |
|
130 | - return $html; |
|
131 | - } |
|
129 | + } |
|
130 | + return $html; |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * {@inhericDoc} |
|
135 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourceAppend() |
|
136 | - */ |
|
137 | - public function hFactSourceAppend($srec) { } |
|
133 | + /** |
|
134 | + * {@inhericDoc} |
|
135 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourceAppend() |
|
136 | + */ |
|
137 | + public function hFactSourceAppend($srec) { } |
|
138 | 138 | |
139 | - /** |
|
140 | - * {@inhericDoc} |
|
141 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetExpectedTags() |
|
142 | - */ |
|
143 | - public function hGetExpectedTags() { |
|
144 | - return array('SOUR' => '_ACT'); |
|
145 | - } |
|
139 | + /** |
|
140 | + * {@inhericDoc} |
|
141 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetExpectedTags() |
|
142 | + */ |
|
143 | + public function hGetExpectedTags() { |
|
144 | + return array('SOUR' => '_ACT'); |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * {@inhericDoc} |
|
149 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagDisplay() |
|
150 | - */ |
|
151 | - public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) { |
|
152 | - $html = ''; |
|
153 | - switch($tag){ |
|
154 | - case '_ACT': |
|
155 | - if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
156 | - break; |
|
157 | - } |
|
158 | - return $html; |
|
159 | - } |
|
147 | + /** |
|
148 | + * {@inhericDoc} |
|
149 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagDisplay() |
|
150 | + */ |
|
151 | + public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) { |
|
152 | + $html = ''; |
|
153 | + switch($tag){ |
|
154 | + case '_ACT': |
|
155 | + if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
156 | + break; |
|
157 | + } |
|
158 | + return $html; |
|
159 | + } |
|
160 | 160 | |
161 | - /** |
|
162 | - * {@inhericDoc} |
|
163 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagEditor() |
|
164 | - */ |
|
165 | - public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) { |
|
166 | - global $controller, $WT_TREE; |
|
161 | + /** |
|
162 | + * {@inhericDoc} |
|
163 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagEditor() |
|
164 | + */ |
|
165 | + public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) { |
|
166 | + global $controller, $WT_TREE; |
|
167 | 167 | |
168 | - $html = ''; |
|
168 | + $html = ''; |
|
169 | 169 | |
170 | 170 | switch($tag){ |
171 | 171 | case '_ACT': |
@@ -193,77 +193,77 @@ discard block |
||
193 | 193 | } |
194 | 194 | |
195 | 195 | return $html; |
196 | - } |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * {@inhericDoc} |
|
200 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag() |
|
201 | - */ |
|
202 | - public function hAddSimpleTag($context, $level) { |
|
203 | - switch($context){ |
|
204 | - case 'SOUR': |
|
205 | - FunctionsEdit::addSimpleTag($level.' _ACT'); |
|
206 | - break; |
|
207 | - } |
|
208 | - } |
|
198 | + /** |
|
199 | + * {@inhericDoc} |
|
200 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag() |
|
201 | + */ |
|
202 | + public function hAddSimpleTag($context, $level) { |
|
203 | + switch($context){ |
|
204 | + case 'SOUR': |
|
205 | + FunctionsEdit::addSimpleTag($level.' _ACT'); |
|
206 | + break; |
|
207 | + } |
|
208 | + } |
|
209 | 209 | |
210 | - /** |
|
211 | - * {@inhericDoc} |
|
212 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag() |
|
213 | - */ |
|
214 | - public function hHasHelpTextTag($tag) { |
|
215 | - switch($tag){ |
|
210 | + /** |
|
211 | + * {@inhericDoc} |
|
212 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag() |
|
213 | + */ |
|
214 | + public function hHasHelpTextTag($tag) { |
|
215 | + switch($tag){ |
|
216 | 216 | case '_ACT': |
217 | 217 | return true; |
218 | 218 | } |
219 | 219 | return false; |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - /** |
|
223 | - * {@inhericDoc} |
|
224 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag() |
|
225 | - */ |
|
226 | - public function hGetHelpTextTag($tag) { |
|
227 | - switch($tag){ |
|
228 | - case '_ACT': |
|
229 | - return array( |
|
230 | - I18N::translate('Certificate'), |
|
231 | - '<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>'); |
|
232 | - default: |
|
233 | - return null; |
|
234 | - } |
|
235 | - } |
|
222 | + /** |
|
223 | + * {@inhericDoc} |
|
224 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag() |
|
225 | + */ |
|
226 | + public function hGetHelpTextTag($tag) { |
|
227 | + switch($tag){ |
|
228 | + case '_ACT': |
|
229 | + return array( |
|
230 | + I18N::translate('Certificate'), |
|
231 | + '<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>'); |
|
232 | + default: |
|
233 | + return null; |
|
234 | + } |
|
235 | + } |
|
236 | 236 | |
237 | - /** |
|
238 | - * Returns the default Certificate File Provider, as configured in the module |
|
239 | - * |
|
240 | - * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface |
|
241 | - */ |
|
242 | - public function getProvider() { |
|
243 | - global $WT_TREE; |
|
237 | + /** |
|
238 | + * Returns the default Certificate File Provider, as configured in the module |
|
239 | + * |
|
240 | + * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface |
|
241 | + */ |
|
242 | + public function getProvider() { |
|
243 | + global $WT_TREE; |
|
244 | 244 | |
245 | - if(!$this->provider) { |
|
246 | - $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/'); |
|
247 | - $this->provider = new CertificateFileProvider($root_path, $WT_TREE); |
|
248 | - } |
|
249 | - return $this->provider; |
|
250 | - } |
|
245 | + if(!$this->provider) { |
|
246 | + $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/'); |
|
247 | + $this->provider = new CertificateFileProvider($root_path, $WT_TREE); |
|
248 | + } |
|
249 | + return $this->provider; |
|
250 | + } |
|
251 | 251 | |
252 | 252 | |
253 | - /** |
|
254 | - * Return the HTML code for custom simple tag _ACT |
|
255 | - * |
|
256 | - * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
|
257 | - * @param string|null $sid Linked Source ID, if it exists |
|
258 | - */ |
|
259 | - protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
|
260 | - $html = ''; |
|
261 | - if($certificate){ |
|
262 | - $certificate->setSource($sid); |
|
263 | - $html = $certificate->displayImage('icon'); |
|
264 | - } |
|
265 | - return $html; |
|
266 | - } |
|
253 | + /** |
|
254 | + * Return the HTML code for custom simple tag _ACT |
|
255 | + * |
|
256 | + * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
|
257 | + * @param string|null $sid Linked Source ID, if it exists |
|
258 | + */ |
|
259 | + protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
|
260 | + $html = ''; |
|
261 | + if($certificate){ |
|
262 | + $certificate->setSource($sid); |
|
263 | + $html = $certificate->displayImage('icon'); |
|
264 | + } |
|
265 | + return $html; |
|
266 | + } |
|
267 | 267 | |
268 | 268 | } |
269 | 269 | |
270 | 270 | \ No newline at end of file |
@@ -89,7 +89,7 @@ |
||
89 | 89 | /** |
90 | 90 | * Returns the number of geographical analysis (active and inactive). |
91 | 91 | * |
92 | - * @return int |
|
92 | + * @return string |
|
93 | 93 | */ |
94 | 94 | public function getGeoAnalysisCount() { |
95 | 95 | return Database::prepare( |
@@ -21,130 +21,130 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class GeoAnalysisProvider { |
23 | 23 | |
24 | - /** |
|
25 | - * Reference tree |
|
26 | - * @var Tree $tree |
|
27 | - */ |
|
28 | - protected $tree; |
|
24 | + /** |
|
25 | + * Reference tree |
|
26 | + * @var Tree $tree |
|
27 | + */ |
|
28 | + protected $tree; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Cached hierarchy of places in the Gedcom file. |
|
32 | - * |
|
33 | - * @var (array|null) $place_hierarchy |
|
34 | - */ |
|
35 | - protected $place_hierarchy; |
|
30 | + /** |
|
31 | + * Cached hierarchy of places in the Gedcom file. |
|
32 | + * |
|
33 | + * @var (array|null) $place_hierarchy |
|
34 | + */ |
|
35 | + protected $place_hierarchy; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor for GeoAnalysis Provider. |
|
39 | - * A provider is defined in relation to a specific tree. |
|
40 | - * |
|
41 | - * @param Tree $tree |
|
42 | - */ |
|
43 | - public function __construct(Tree $tree) { |
|
44 | - $this->tree = $tree; |
|
45 | - $this->place_hierarchy = null; |
|
46 | - } |
|
37 | + /** |
|
38 | + * Constructor for GeoAnalysis Provider. |
|
39 | + * A provider is defined in relation to a specific tree. |
|
40 | + * |
|
41 | + * @param Tree $tree |
|
42 | + */ |
|
43 | + public function __construct(Tree $tree) { |
|
44 | + $this->tree = $tree; |
|
45 | + $this->place_hierarchy = null; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Creates and returns a GeoAnalysis object from a data row. |
|
50 | - * The row data is expected to be an array with the indexes: |
|
51 | - * - majgd_id: geodispersion analysis ID |
|
52 | - * - majgd_descr: geodispersion analysis description/title |
|
53 | - * - majgd_sublevel: Analysis level |
|
54 | - * - majgd_useflagsgen: Use flags in places display |
|
55 | - * - majgd_detailsgen: Number of top places |
|
56 | - * - majgd_map: file name of the map |
|
57 | - * - majgd_toplevel: parent level for the map |
|
58 | - * |
|
59 | - * @param array $row |
|
60 | - * @return GeoAnalysis |
|
61 | - */ |
|
62 | - protected function loadGeoAnalysisFromRow($row) { |
|
63 | - $options = new GeoDisplayOptions(); |
|
64 | - $options |
|
65 | - ->setUsingFlags($row['majgd_useflagsgen'] == 'yes') |
|
66 | - ->setMaxDetailsInGen($row['majgd_detailsgen']); |
|
48 | + /** |
|
49 | + * Creates and returns a GeoAnalysis object from a data row. |
|
50 | + * The row data is expected to be an array with the indexes: |
|
51 | + * - majgd_id: geodispersion analysis ID |
|
52 | + * - majgd_descr: geodispersion analysis description/title |
|
53 | + * - majgd_sublevel: Analysis level |
|
54 | + * - majgd_useflagsgen: Use flags in places display |
|
55 | + * - majgd_detailsgen: Number of top places |
|
56 | + * - majgd_map: file name of the map |
|
57 | + * - majgd_toplevel: parent level for the map |
|
58 | + * |
|
59 | + * @param array $row |
|
60 | + * @return GeoAnalysis |
|
61 | + */ |
|
62 | + protected function loadGeoAnalysisFromRow($row) { |
|
63 | + $options = new GeoDisplayOptions(); |
|
64 | + $options |
|
65 | + ->setUsingFlags($row['majgd_useflagsgen'] == 'yes') |
|
66 | + ->setMaxDetailsInGen($row['majgd_detailsgen']); |
|
67 | 67 | |
68 | - if($row['majgd_map']) { |
|
69 | - $options |
|
70 | - ->setMap(new OutlineMap($row['majgd_map'])) |
|
71 | - ->setMapLevel($row['majgd_toplevel']); |
|
72 | - } |
|
68 | + if($row['majgd_map']) { |
|
69 | + $options |
|
70 | + ->setMap(new OutlineMap($row['majgd_map'])) |
|
71 | + ->setMapLevel($row['majgd_toplevel']); |
|
72 | + } |
|
73 | 73 | |
74 | - $enabled = true; |
|
75 | - if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
76 | - $enabled = false; |
|
77 | - } |
|
74 | + $enabled = true; |
|
75 | + if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
76 | + $enabled = false; |
|
77 | + } |
|
78 | 78 | |
79 | - return new GeoAnalysis( |
|
80 | - $this->tree, |
|
81 | - $row['majgd_id'], |
|
82 | - $row['majgd_descr'], |
|
83 | - $row['majgd_sublevel'], |
|
84 | - $options, |
|
85 | - $enabled |
|
86 | - ); |
|
87 | - } |
|
79 | + return new GeoAnalysis( |
|
80 | + $this->tree, |
|
81 | + $row['majgd_id'], |
|
82 | + $row['majgd_descr'], |
|
83 | + $row['majgd_sublevel'], |
|
84 | + $options, |
|
85 | + $enabled |
|
86 | + ); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Returns the number of geographical analysis (active and inactive). |
|
91 | - * |
|
92 | - * @return int |
|
93 | - */ |
|
94 | - public function getGeoAnalysisCount() { |
|
95 | - return Database::prepare( |
|
96 | - 'SELECT COUNT(majgd_id)' . |
|
97 | - ' FROM `##maj_geodispersion`' . |
|
98 | - ' WHERE majgd_file = :gedcom_id' |
|
99 | - )->execute(array( |
|
100 | - 'gedcom_id' => $this->tree->getTreeId() |
|
101 | - ))->fetchOne(); |
|
102 | - } |
|
89 | + /** |
|
90 | + * Returns the number of geographical analysis (active and inactive). |
|
91 | + * |
|
92 | + * @return int |
|
93 | + */ |
|
94 | + public function getGeoAnalysisCount() { |
|
95 | + return Database::prepare( |
|
96 | + 'SELECT COUNT(majgd_id)' . |
|
97 | + ' FROM `##maj_geodispersion`' . |
|
98 | + ' WHERE majgd_file = :gedcom_id' |
|
99 | + )->execute(array( |
|
100 | + 'gedcom_id' => $this->tree->getTreeId() |
|
101 | + ))->fetchOne(); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Get a geographical analysis by its ID. |
|
106 | - * The function can only search for only enabled analysis, or all. |
|
107 | - * |
|
108 | - * @param int $id geodispersion analysis ID |
|
109 | - * @param bool $only_enabled Search for only enabled geodispersion analysis |
|
110 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL |
|
111 | - */ |
|
112 | - public function getGeoAnalysis($id, $only_enabled = true) { |
|
113 | - $args = array ( |
|
114 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
115 | - 'ga_id' => $id |
|
116 | - ); |
|
104 | + /** |
|
105 | + * Get a geographical analysis by its ID. |
|
106 | + * The function can only search for only enabled analysis, or all. |
|
107 | + * |
|
108 | + * @param int $id geodispersion analysis ID |
|
109 | + * @param bool $only_enabled Search for only enabled geodispersion analysis |
|
110 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL |
|
111 | + */ |
|
112 | + public function getGeoAnalysis($id, $only_enabled = true) { |
|
113 | + $args = array ( |
|
114 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
115 | + 'ga_id' => $id |
|
116 | + ); |
|
117 | 117 | |
118 | - $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
119 | - ' FROM `##maj_geodispersion`' . |
|
120 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; |
|
121 | - if($only_enabled) { |
|
122 | - $sql .= ' AND majgd_status = :status'; |
|
123 | - $args['status'] = 'enabled'; |
|
124 | - } |
|
125 | - $sql .= ' ORDER BY majgd_descr'; |
|
118 | + $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
119 | + ' FROM `##maj_geodispersion`' . |
|
120 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; |
|
121 | + if($only_enabled) { |
|
122 | + $sql .= ' AND majgd_status = :status'; |
|
123 | + $args['status'] = 'enabled'; |
|
124 | + } |
|
125 | + $sql .= ' ORDER BY majgd_descr'; |
|
126 | 126 | |
127 | - $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); |
|
127 | + $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); |
|
128 | 128 | |
129 | - if($ga_array) { |
|
130 | - return $this->loadGeoAnalysisFromRow($ga_array); |
|
131 | - } |
|
129 | + if($ga_array) { |
|
130 | + return $this->loadGeoAnalysisFromRow($ga_array); |
|
131 | + } |
|
132 | 132 | |
133 | - return null; |
|
134 | - } |
|
133 | + return null; |
|
134 | + } |
|
135 | 135 | |
136 | - /** |
|
137 | - * Add a new geodispersion analysis in the database, in a transactional manner. |
|
138 | - * When successful, eturns the newly created GeoAnalysis object. |
|
139 | - * |
|
140 | - * @param string $description geodispersion analysis title |
|
141 | - * @param int $analysis_level Analysis level |
|
142 | - * @param string $map_file Filename of the map |
|
143 | - * @param int $map_top_level Parent level of the map |
|
144 | - * @param bool $use_flags Use flag in the place display |
|
145 | - * @param int $gen_details Number of top places to display |
|
146 | - * @return GeoAnalysis |
|
147 | - */ |
|
136 | + /** |
|
137 | + * Add a new geodispersion analysis in the database, in a transactional manner. |
|
138 | + * When successful, eturns the newly created GeoAnalysis object. |
|
139 | + * |
|
140 | + * @param string $description geodispersion analysis title |
|
141 | + * @param int $analysis_level Analysis level |
|
142 | + * @param string $map_file Filename of the map |
|
143 | + * @param int $map_top_level Parent level of the map |
|
144 | + * @param bool $use_flags Use flag in the place display |
|
145 | + * @param int $gen_details Number of top places to display |
|
146 | + * @return GeoAnalysis |
|
147 | + */ |
|
148 | 148 | public function createGeoAnalysis($description, $analysis_level, $map_file, $map_top_level, $use_flags, $gen_details) { |
149 | 149 | try{ |
150 | 150 | Database::beginTransaction(); |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage()); |
175 | 175 | } |
176 | 176 | return $ga; |
177 | - } |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Update a geodispersion analysis in the database, in transactional manner. |
|
181 | - * When successful, returns the updated GeoAnalysis object |
|
182 | - * |
|
183 | - * @param GeoAnalysis $ga |
|
184 | - * @return GeoAnalysis |
|
185 | - */ |
|
186 | - public function updateGeoAnalysis(GeoAnalysis $ga) { |
|
187 | - try { |
|
179 | + /** |
|
180 | + * Update a geodispersion analysis in the database, in transactional manner. |
|
181 | + * When successful, returns the updated GeoAnalysis object |
|
182 | + * |
|
183 | + * @param GeoAnalysis $ga |
|
184 | + * @return GeoAnalysis |
|
185 | + */ |
|
186 | + public function updateGeoAnalysis(GeoAnalysis $ga) { |
|
187 | + try { |
|
188 | 188 | Database::beginTransaction(); |
189 | 189 | |
190 | 190 | Database::prepare( |
@@ -217,238 +217,238 @@ discard block |
||
217 | 217 | $ga = null; |
218 | 218 | } |
219 | 219 | return $ga; |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - /** |
|
223 | - * Set the status of a specific analysis. |
|
224 | - * The status can be enabled (true), or disabled (false). |
|
225 | - * |
|
226 | - * @param GeoAnalysis $ga |
|
227 | - * @param bool $status |
|
228 | - */ |
|
229 | - public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) { |
|
230 | - Database::prepare( |
|
231 | - 'UPDATE `##maj_geodispersion`'. |
|
232 | - ' SET majgd_status = :status'. |
|
233 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
234 | - )->execute(array( |
|
235 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
236 | - 'status' => $status ? 'enabled' : 'disabled', |
|
237 | - 'ga_id' => $ga->getId() |
|
238 | - )); |
|
239 | - } |
|
222 | + /** |
|
223 | + * Set the status of a specific analysis. |
|
224 | + * The status can be enabled (true), or disabled (false). |
|
225 | + * |
|
226 | + * @param GeoAnalysis $ga |
|
227 | + * @param bool $status |
|
228 | + */ |
|
229 | + public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) { |
|
230 | + Database::prepare( |
|
231 | + 'UPDATE `##maj_geodispersion`'. |
|
232 | + ' SET majgd_status = :status'. |
|
233 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
234 | + )->execute(array( |
|
235 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
236 | + 'status' => $status ? 'enabled' : 'disabled', |
|
237 | + 'ga_id' => $ga->getId() |
|
238 | + )); |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Delete a geodispersion analysis from the database. |
|
243 | - * |
|
244 | - * @param GeoAnalysis $ga |
|
245 | - */ |
|
246 | - public function deleteGeoAnalysis(GeoAnalysis $ga) { |
|
247 | - Database::prepare( |
|
248 | - 'DELETE FROM `##maj_geodispersion`'. |
|
249 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
250 | - )->execute(array( |
|
251 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
252 | - 'ga_id' => $ga->getId() |
|
253 | - )); |
|
254 | - } |
|
241 | + /** |
|
242 | + * Delete a geodispersion analysis from the database. |
|
243 | + * |
|
244 | + * @param GeoAnalysis $ga |
|
245 | + */ |
|
246 | + public function deleteGeoAnalysis(GeoAnalysis $ga) { |
|
247 | + Database::prepare( |
|
248 | + 'DELETE FROM `##maj_geodispersion`'. |
|
249 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
250 | + )->execute(array( |
|
251 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
252 | + 'ga_id' => $ga->getId() |
|
253 | + )); |
|
254 | + } |
|
255 | 255 | |
256 | - /** |
|
257 | - * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM |
|
258 | - * |
|
259 | - * @return array List of enabled maps |
|
260 | - */ |
|
261 | - public function getGeoAnalysisList(){ |
|
262 | - $res = array(); |
|
256 | + /** |
|
257 | + * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM |
|
258 | + * |
|
259 | + * @return array List of enabled maps |
|
260 | + */ |
|
261 | + public function getGeoAnalysisList(){ |
|
262 | + $res = array(); |
|
263 | 263 | |
264 | - $list = Database::prepare( |
|
265 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . |
|
266 | - ' FROM `##maj_geodispersion`' . |
|
267 | - ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. |
|
268 | - ' ORDER BY majgd_descr' |
|
269 | - )->execute(array( |
|
270 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
271 | - 'status' => 'enabled' |
|
272 | - ))->fetchAll(\PDO::FETCH_ASSOC); |
|
264 | + $list = Database::prepare( |
|
265 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . |
|
266 | + ' FROM `##maj_geodispersion`' . |
|
267 | + ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. |
|
268 | + ' ORDER BY majgd_descr' |
|
269 | + )->execute(array( |
|
270 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
271 | + 'status' => 'enabled' |
|
272 | + ))->fetchAll(\PDO::FETCH_ASSOC); |
|
273 | 273 | |
274 | - foreach($list as $ga) { |
|
275 | - $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
276 | - } |
|
274 | + foreach($list as $ga) { |
|
275 | + $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
276 | + } |
|
277 | 277 | |
278 | - return $res; |
|
279 | - } |
|
278 | + return $res; |
|
279 | + } |
|
280 | 280 | |
281 | - /** |
|
282 | - * Return the list of geodispersion analysis matching specified criterias. |
|
283 | - * |
|
284 | - * @param string $search Search criteria in analysis description |
|
285 | - * @param array $order_by Columns to order by |
|
286 | - * @param int $start Offset to start with (for pagination) |
|
287 | - * @param int|null $limit Max number of items to return (for pagination) |
|
288 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
289 | - */ |
|
290 | - public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ |
|
291 | - $res = array(); |
|
281 | + /** |
|
282 | + * Return the list of geodispersion analysis matching specified criterias. |
|
283 | + * |
|
284 | + * @param string $search Search criteria in analysis description |
|
285 | + * @param array $order_by Columns to order by |
|
286 | + * @param int $start Offset to start with (for pagination) |
|
287 | + * @param int|null $limit Max number of items to return (for pagination) |
|
288 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
289 | + */ |
|
290 | + public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ |
|
291 | + $res = array(); |
|
292 | 292 | |
293 | - $sql = |
|
294 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
295 | - ' FROM `##maj_geodispersion`' . |
|
296 | - ' WHERE majgd_file = :gedcom_id'; |
|
293 | + $sql = |
|
294 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
295 | + ' FROM `##maj_geodispersion`' . |
|
296 | + ' WHERE majgd_file = :gedcom_id'; |
|
297 | 297 | |
298 | - $args = array('gedcom_id'=> $this->tree->getTreeId()); |
|
298 | + $args = array('gedcom_id'=> $this->tree->getTreeId()); |
|
299 | 299 | |
300 | - if($search) { |
|
301 | - $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; |
|
302 | - $args['search'] = $search; |
|
303 | - } |
|
300 | + if($search) { |
|
301 | + $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; |
|
302 | + $args['search'] = $search; |
|
303 | + } |
|
304 | 304 | |
305 | - if ($order_by) { |
|
306 | - $sql .= ' ORDER BY '; |
|
307 | - foreach ($order_by as $key => $value) { |
|
308 | - if ($key > 0) { |
|
309 | - $sql .= ','; |
|
310 | - } |
|
305 | + if ($order_by) { |
|
306 | + $sql .= ' ORDER BY '; |
|
307 | + foreach ($order_by as $key => $value) { |
|
308 | + if ($key > 0) { |
|
309 | + $sql .= ','; |
|
310 | + } |
|
311 | 311 | |
312 | - switch ($value['dir']) { |
|
313 | - case 'asc': |
|
314 | - $sql .= $value['column'] . ' ASC '; |
|
315 | - break; |
|
316 | - case 'desc': |
|
317 | - $sql .= $value['column'] . ' DESC '; |
|
318 | - break; |
|
319 | - } |
|
320 | - } |
|
321 | - } else { |
|
322 | - $sql = " ORDER BY majgd_descr ASC"; |
|
323 | - } |
|
312 | + switch ($value['dir']) { |
|
313 | + case 'asc': |
|
314 | + $sql .= $value['column'] . ' ASC '; |
|
315 | + break; |
|
316 | + case 'desc': |
|
317 | + $sql .= $value['column'] . ' DESC '; |
|
318 | + break; |
|
319 | + } |
|
320 | + } |
|
321 | + } else { |
|
322 | + $sql = " ORDER BY majgd_descr ASC"; |
|
323 | + } |
|
324 | 324 | |
325 | - if ($limit) { |
|
326 | - $sql .= " LIMIT :limit OFFSET :offset"; |
|
327 | - $args['limit'] = $limit; |
|
328 | - $args['offset'] = $start; |
|
329 | - } |
|
325 | + if ($limit) { |
|
326 | + $sql .= " LIMIT :limit OFFSET :offset"; |
|
327 | + $args['limit'] = $limit; |
|
328 | + $args['offset'] = $start; |
|
329 | + } |
|
330 | 330 | |
331 | - $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); |
|
331 | + $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); |
|
332 | 332 | |
333 | - foreach($data as $ga) { |
|
334 | - $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
335 | - } |
|
333 | + foreach($data as $ga) { |
|
334 | + $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
335 | + } |
|
336 | 336 | |
337 | - return $res; |
|
338 | - } |
|
337 | + return $res; |
|
338 | + } |
|
339 | 339 | |
340 | - /** |
|
341 | - * Returns the infered place hierarchy, determined from the Gedcom data. |
|
342 | - * Depending on the data, it can be based on the Gedcom Header description, or from a place example. |
|
343 | - * This is returned as an associative array: |
|
344 | - * - type: describe the source of the data (<em>header<em> / <em>data</em>) |
|
345 | - * - hierarchy: an array of the place hierarchy (in reverse order of the gedcom) |
|
346 | - * |
|
347 | - * @return array |
|
348 | - */ |
|
349 | - public function getPlacesHierarchy() { |
|
350 | - if(!$this->place_hierarchy) { |
|
351 | - if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
352 | - $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
|
353 | - } |
|
354 | - else { |
|
355 | - $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData()); |
|
356 | - } |
|
357 | - } |
|
358 | - return $this->place_hierarchy; |
|
359 | - } |
|
340 | + /** |
|
341 | + * Returns the infered place hierarchy, determined from the Gedcom data. |
|
342 | + * Depending on the data, it can be based on the Gedcom Header description, or from a place example. |
|
343 | + * This is returned as an associative array: |
|
344 | + * - type: describe the source of the data (<em>header<em> / <em>data</em>) |
|
345 | + * - hierarchy: an array of the place hierarchy (in reverse order of the gedcom) |
|
346 | + * |
|
347 | + * @return array |
|
348 | + */ |
|
349 | + public function getPlacesHierarchy() { |
|
350 | + if(!$this->place_hierarchy) { |
|
351 | + if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
352 | + $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
|
353 | + } |
|
354 | + else { |
|
355 | + $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData()); |
|
356 | + } |
|
357 | + } |
|
358 | + return $this->place_hierarchy; |
|
359 | + } |
|
360 | 360 | |
361 | - /** |
|
362 | - * Returns an array of the place hierarchy, as defined in the GEDCOM header. |
|
363 | - * The places are reversed compared to normal GEDCOM structure. |
|
364 | - * |
|
365 | - * @return array|null |
|
366 | - */ |
|
367 | - protected function getPlacesHierarchyFromHeader() { |
|
368 | - $head = GedcomRecord::getInstance('HEAD', $this->tree); |
|
369 | - $head_place = $head->getFirstFact('PLAC'); |
|
370 | - if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ |
|
371 | - return array_reverse(array_map('trim',explode(',', $head_place_value))); |
|
372 | - } |
|
373 | - return null; |
|
374 | - } |
|
361 | + /** |
|
362 | + * Returns an array of the place hierarchy, as defined in the GEDCOM header. |
|
363 | + * The places are reversed compared to normal GEDCOM structure. |
|
364 | + * |
|
365 | + * @return array|null |
|
366 | + */ |
|
367 | + protected function getPlacesHierarchyFromHeader() { |
|
368 | + $head = GedcomRecord::getInstance('HEAD', $this->tree); |
|
369 | + $head_place = $head->getFirstFact('PLAC'); |
|
370 | + if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ |
|
371 | + return array_reverse(array_map('trim',explode(',', $head_place_value))); |
|
372 | + } |
|
373 | + return null; |
|
374 | + } |
|
375 | 375 | |
376 | - /** |
|
377 | - * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM. |
|
378 | - * It will look for the longest hierarchy in the tree. |
|
379 | - * The places are reversed compared to normal GEDCOM structure. |
|
380 | - * |
|
381 | - * @return array |
|
382 | - */ |
|
383 | - protected function getPlacesHierarchyFromData() { |
|
384 | - $random_place = null; |
|
385 | - $nb_levels = 0; |
|
376 | + /** |
|
377 | + * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM. |
|
378 | + * It will look for the longest hierarchy in the tree. |
|
379 | + * The places are reversed compared to normal GEDCOM structure. |
|
380 | + * |
|
381 | + * @return array |
|
382 | + */ |
|
383 | + protected function getPlacesHierarchyFromData() { |
|
384 | + $random_place = null; |
|
385 | + $nb_levels = 0; |
|
386 | 386 | |
387 | - //Select all '2 PLAC ' tags in the file and create array |
|
388 | - $places_list=array(); |
|
389 | - $ged_data = Database::prepare( |
|
390 | - 'SELECT i_gedcom AS gedcom'. |
|
391 | - ' FROM `##individuals`'. |
|
392 | - ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. |
|
393 | - ' UNION ALL'. |
|
394 | - 'SELECT f_gedcom AS gedcom'. |
|
395 | - ' FROM `##families`'. |
|
396 | - ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' |
|
397 | - )->execute(array( |
|
398 | - 'gedcom' => '%\n2 PLAC %', |
|
399 | - 'gedcom_id' => $this->tree->getTreeId() |
|
400 | - ))->fetchOneColumn(); |
|
401 | - foreach ($ged_data as $ged_datum) { |
|
402 | - preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
|
403 | - foreach ($matches[1] as $match) { |
|
404 | - $places_list[$match]=true; |
|
405 | - } |
|
406 | - } |
|
387 | + //Select all '2 PLAC ' tags in the file and create array |
|
388 | + $places_list=array(); |
|
389 | + $ged_data = Database::prepare( |
|
390 | + 'SELECT i_gedcom AS gedcom'. |
|
391 | + ' FROM `##individuals`'. |
|
392 | + ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. |
|
393 | + ' UNION ALL'. |
|
394 | + 'SELECT f_gedcom AS gedcom'. |
|
395 | + ' FROM `##families`'. |
|
396 | + ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' |
|
397 | + )->execute(array( |
|
398 | + 'gedcom' => '%\n2 PLAC %', |
|
399 | + 'gedcom_id' => $this->tree->getTreeId() |
|
400 | + ))->fetchOneColumn(); |
|
401 | + foreach ($ged_data as $ged_datum) { |
|
402 | + preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
|
403 | + foreach ($matches[1] as $match) { |
|
404 | + $places_list[$match]=true; |
|
405 | + } |
|
406 | + } |
|
407 | 407 | |
408 | - // Unique list of places |
|
409 | - $places_list=array_keys($places_list); |
|
408 | + // Unique list of places |
|
409 | + $places_list=array_keys($places_list); |
|
410 | 410 | |
411 | - //sort the array, limit to unique values, and count them |
|
412 | - $places_parts=array(); |
|
413 | - usort($places_list, array('I18N', 'strcasecmp')); |
|
414 | - $nb_places = count($places_list); |
|
411 | + //sort the array, limit to unique values, and count them |
|
412 | + $places_parts=array(); |
|
413 | + usort($places_list, array('I18N', 'strcasecmp')); |
|
414 | + $nb_places = count($places_list); |
|
415 | 415 | |
416 | - //calculate maximum no. of levels to display |
|
417 | - $has_found_good_example = false; |
|
418 | - foreach($places_list as $place){ |
|
419 | - $levels = explode(",", $place); |
|
420 | - $parts = count($levels); |
|
421 | - if ($parts >= $nb_levels){ |
|
422 | - $nb_levels = $parts; |
|
423 | - if(!$has_found_good_example){ |
|
424 | - $random_place = $$place; |
|
425 | - if(min(array_map('strlen', $levels)) > 0){ |
|
426 | - $has_found_good_example = true; |
|
427 | - } |
|
428 | - } |
|
429 | - } |
|
430 | - } |
|
416 | + //calculate maximum no. of levels to display |
|
417 | + $has_found_good_example = false; |
|
418 | + foreach($places_list as $place){ |
|
419 | + $levels = explode(",", $place); |
|
420 | + $parts = count($levels); |
|
421 | + if ($parts >= $nb_levels){ |
|
422 | + $nb_levels = $parts; |
|
423 | + if(!$has_found_good_example){ |
|
424 | + $random_place = $$place; |
|
425 | + if(min(array_map('strlen', $levels)) > 0){ |
|
426 | + $has_found_good_example = true; |
|
427 | + } |
|
428 | + } |
|
429 | + } |
|
430 | + } |
|
431 | 431 | |
432 | - return array_reverse(array_map('trim',explode(',', $randomPlace))); |
|
433 | - } |
|
432 | + return array_reverse(array_map('trim',explode(',', $randomPlace))); |
|
433 | + } |
|
434 | 434 | |
435 | - /** |
|
436 | - * Returns the list of geodispersion maps available within the maps folder. |
|
437 | - * |
|
438 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[] |
|
439 | - */ |
|
440 | - public function getOutlineMapsList() { |
|
441 | - $res = array(); |
|
442 | - $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
|
443 | - if(is_dir($root_path)){ |
|
444 | - $dir = opendir($root_path); |
|
445 | - while (($file=readdir($dir))!== false) { |
|
446 | - if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
|
447 | - $res[base64_encode($file)] = new OutlineMap($file, true); |
|
448 | - } |
|
449 | - } |
|
450 | - } |
|
451 | - return $res; |
|
452 | - } |
|
435 | + /** |
|
436 | + * Returns the list of geodispersion maps available within the maps folder. |
|
437 | + * |
|
438 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[] |
|
439 | + */ |
|
440 | + public function getOutlineMapsList() { |
|
441 | + $res = array(); |
|
442 | + $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
|
443 | + if(is_dir($root_path)){ |
|
444 | + $dir = opendir($root_path); |
|
445 | + while (($file=readdir($dir))!== false) { |
|
446 | + if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
|
447 | + $res[base64_encode($file)] = new OutlineMap($file, true); |
|
448 | + } |
|
449 | + } |
|
450 | + } |
|
451 | + return $res; |
|
452 | + } |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | \ No newline at end of file |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * Constructor for Lineage node |
42 | 42 | * |
43 | - * @param Fisharebest\Webtrees\Individual $node_indi Main individual |
|
43 | + * @param Individual $node_indi Main individual |
|
44 | 44 | * @param LineageRootNode $root_node Node of the lineage root |
45 | 45 | * @param unknown $alt_surname Follow-up surname |
46 | 46 | */ |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * Add a spouse family to the node |
56 | 56 | * |
57 | - * @param Fisharebest\Webtrees\Family $fams |
|
57 | + * @param Family $fams |
|
58 | 58 | */ |
59 | 59 | public function addFamily(Family $fams) { |
60 | 60 | if($fams && !isset($this->linked_fams[$fams])) { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | /** |
66 | 66 | * Add a child LineageNode to the node |
67 | 67 | * |
68 | - * @param Fisharebest\Webtrees\Family $fams |
|
68 | + * @param Family $fams |
|
69 | 69 | * @param LineageNode $child |
70 | 70 | */ |
71 | 71 | public function addChild(Family $fams, LineageNode $child = null) { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | /** |
81 | 81 | * Returns the node individual |
82 | 82 | * |
83 | - * @return Fisharebest\Webtrees\Individual |
|
83 | + * @return \Fisharebest\Webtrees\GedcomRecord |
|
84 | 84 | */ |
85 | 85 | public function getIndividual() { |
86 | 86 | return $this->node_indi; |