@@ -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 | */ |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | * @param string $gedcom |
31 | 31 | * @return NULL|\MyArtJaub\Webtrees\Family |
32 | 32 | */ |
33 | - public static function getIntance($xref, Tree $tree, $gedcom = null){ |
|
33 | + public static function getIntance($xref, Tree $tree, $gedcom = null) { |
|
34 | 34 | $dfam = null; |
35 | 35 | $fam = fw\Family::getInstance($xref, $tree, $gedcom); |
36 | - if($fam){ |
|
36 | + if ($fam) { |
|
37 | 37 | $dfam = new Family($fam); |
38 | 38 | } |
39 | 39 | return $dfam; |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return int Level of sources |
46 | 46 | * */ |
47 | - function isMarriageSourced(){ |
|
48 | - if($this->is_marriage_sourced !== null) return $this->is_marriage_sourced; |
|
47 | + function isMarriageSourced() { |
|
48 | + if ($this->is_marriage_sourced !== null) return $this->is_marriage_sourced; |
|
49 | 49 | $this->is_marriage_sourced = $this->isFactSourced(WT_EVENTS_MARR.'|MARC'); |
50 | 50 | return $this->is_marriage_sourced; |
51 | 51 | } |
@@ -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 |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @return string List of elements |
33 | 33 | */ |
34 | 34 | static public function getListFromArray(array $array) { |
35 | - $n=count($array); |
|
35 | + $n = count($array); |
|
36 | 36 | switch ($n) { |
37 | 37 | case 0: |
38 | 38 | return ''; |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | default: |
42 | 42 | return implode( |
43 | 43 | /* I18N: list separator */ I18N::translate(', '), |
44 | - array_slice($array, 0, $n-1) |
|
45 | - ) . |
|
46 | - /* I18N: last list separator, " and " in English, " et " in French */ I18N::translate(' and ') . |
|
47 | - $array[$n-1]; |
|
44 | + array_slice($array, 0, $n - 1) |
|
45 | + ). |
|
46 | + /* I18N: last list separator, " and " in English, " et " in French */ I18N::translate(' and '). |
|
47 | + $array[$n - 1]; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | \Fisharebest\Webtrees\Fact $fact, |
60 | 60 | \MyArtJaub\Webtrees\Map\MapProviderInterface $mapProvider |
61 | 61 | ) { |
62 | - $html=''; |
|
63 | - if($place = $fact->getPlace()) { |
|
64 | - $iconPlace= $mapProvider->getPlaceIcon($place); |
|
65 | - if($iconPlace && strlen($iconPlace) > 0){ |
|
66 | - $html.= '<div class="fact_flag">'. self::htmlPlaceIcon($place, $iconPlace, 50). '</div>'; |
|
62 | + $html = ''; |
|
63 | + if ($place = $fact->getPlace()) { |
|
64 | + $iconPlace = $mapProvider->getPlaceIcon($place); |
|
65 | + if ($iconPlace && strlen($iconPlace) > 0) { |
|
66 | + $html .= '<div class="fact_flag">'.self::htmlPlaceIcon($place, $iconPlace, 50).'</div>'; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | return $html; |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * @param number $size |
78 | 78 | * @return string HTML code of the inserted flag |
79 | 79 | */ |
80 | - public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) { |
|
81 | - return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />'; |
|
80 | + public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path, $size = 50) { |
|
81 | + return '<img class="flag_gm_h'.$size.'" src="'.$icon_path.'" title="'.$place->getGedcomName().'" alt="'.$place->getGedcomName().'" />'; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $minimum = PHP_INT_MAX; |
97 | 97 | $maximum = 1; |
98 | 98 | foreach ($list as $item => $params) { |
99 | - if(array_key_exists('count', $params)) { |
|
99 | + if (array_key_exists('count', $params)) { |
|
100 | 100 | $maximum = max($maximum, $params['count']); |
101 | 101 | $minimum = min($minimum, $params['count']); |
102 | 102 | } |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | $size = 75.0 + 125.0 * ($count - $minimum) / ($maximum - $minimum); |
115 | 115 | } |
116 | 116 | |
117 | - $html .= '<a style="font-size:' . $size . '%" href="' . $url . '">'; |
|
117 | + $html .= '<a style="font-size:'.$size.'%" href="'.$url.'">'; |
|
118 | 118 | if ($totals) { |
119 | - $html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $text . '</span>', I18N::number($count)); |
|
119 | + $html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">'.$text.'</span>', I18N::number($count)); |
|
120 | 120 | } else { |
121 | 121 | $html .= $text; |
122 | 122 | } |
123 | 123 | $html .= '</a>'; |
124 | 124 | } |
125 | - return '<div class="tag_cloud">' . $html . '</div>'; |
|
125 | + return '<div class="tag_cloud">'.$html.'</div>'; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | * @param bool $isStrong Bolden the name ? |
158 | 158 | * @return string HTML Code for individual item |
159 | 159 | */ |
160 | - public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true){ |
|
160 | + public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true) { |
|
161 | 161 | $html = ''; |
162 | 162 | $tag = 'em'; |
163 | - if($isStrong) $tag = 'strong'; |
|
164 | - if($individual && $individual->canShow()){ |
|
163 | + if ($isStrong) $tag = 'strong'; |
|
164 | + if ($individual && $individual->canShow()) { |
|
165 | 165 | $dindi = new Individual($individual); |
166 | 166 | $html = $individual->getSexImage(); |
167 | 167 | $html .= '<a class="list_item" href="'. |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $html .= '</a>'; |
177 | 177 | } |
178 | 178 | else { |
179 | - $html .= '<span class=\"list_item\"><'.$tag.'>' . I18N::translate('Private') . '</'.$tag.'></span>'; |
|
179 | + $html .= '<span class=\"list_item\"><'.$tag.'>'.I18N::translate('Private').'</'.$tag.'></span>'; |
|
180 | 180 | } |
181 | 181 | return $html; |
182 | 182 | } |
@@ -188,22 +188,22 @@ discard block |
||
188 | 188 | * @param boolean $anchor option to print a link to calendar |
189 | 189 | * @return string HTML code for short date |
190 | 190 | */ |
191 | - public static function formatFactDateShort(\Fisharebest\Webtrees\Fact $fact, $anchor=false) { |
|
191 | + public static function formatFactDateShort(\Fisharebest\Webtrees\Fact $fact, $anchor = false) { |
|
192 | 192 | global $SEARCH_SPIDER; |
193 | 193 | |
194 | - $html=''; |
|
194 | + $html = ''; |
|
195 | 195 | $date = $fact->getDate(); |
196 | - if($date->isOK()){ |
|
197 | - $html.=' '.$date->Display($anchor && !$SEARCH_SPIDER, '%Y'); |
|
196 | + if ($date->isOK()) { |
|
197 | + $html .= ' '.$date->Display($anchor && !$SEARCH_SPIDER, '%Y'); |
|
198 | 198 | } |
199 | - else{ |
|
199 | + else { |
|
200 | 200 | // 1 DEAT Y with no DATE => print YES |
201 | 201 | // 1 BIRT 2 SOUR @S1@ => print YES |
202 | 202 | // 1 DEAT N is not allowed |
203 | 203 | // It is not proper GEDCOM form to use a N(o) value with an event tag to infer that it did not happen. |
204 | 204 | $factdetail = explode(' ', trim($fact->getGedcom())); |
205 | 205 | if (isset($factdetail) && (count($factdetail) == 3 && strtoupper($factdetail[2]) == 'Y') || (count($factdetail) == 4 && $factdetail[2] == 'SOUR')) { |
206 | - $html.=I18N::translate('yes'); |
|
206 | + $html .= I18N::translate('yes'); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | return $html; |
@@ -217,12 +217,12 @@ discard block |
||
217 | 217 | * @param boolean $anchor option to print a link to placelist |
218 | 218 | * @return string HTML code for short place |
219 | 219 | */ |
220 | - public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor=false){ |
|
221 | - $html=''; |
|
220 | + public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor = false) { |
|
221 | + $html = ''; |
|
222 | 222 | |
223 | 223 | if ($fact === null) return $html; |
224 | 224 | $place = $fact->getPlace(); |
225 | - if($place){ |
|
225 | + if ($place) { |
|
226 | 226 | $dplace = new Place($place); |
227 | 227 | $html .= $dplace->htmlFormattedName($format, $anchor); |
228 | 228 | } |
@@ -240,21 +240,21 @@ discard block |
||
240 | 240 | * @param string $size CSS size for the icon. A CSS style css_$size is required |
241 | 241 | * @return string HTML code for the formatted Sosa numbers |
242 | 242 | */ |
243 | - public static function formatSosaNumbers(array $sosatab, $format = 1, $size = 'small'){ |
|
243 | + public static function formatSosaNumbers(array $sosatab, $format = 1, $size = 'small') { |
|
244 | 244 | $html = ''; |
245 | - switch($format){ |
|
245 | + switch ($format) { |
|
246 | 246 | case 1: |
247 | - if(count($sosatab)>0){ |
|
247 | + if (count($sosatab) > 0) { |
|
248 | 248 | $html = '<i class="icon-maj-sosa_'.$size.'" title="'.I18N::translate('Sosa').'"></i>'; |
249 | 249 | } |
250 | 250 | break; |
251 | 251 | case 2: |
252 | - if(count($sosatab)>0){ |
|
252 | + if (count($sosatab) > 0) { |
|
253 | 253 | ksort($sosatab); |
254 | 254 | $tmp_html = array(); |
255 | 255 | foreach ($sosatab as $sosa => $gen) { |
256 | 256 | $tmp_html[] = sprintf( |
257 | - '<i class="icon-maj-sosa_%1$s" title="'.I18N::translate('Sosa').'"></i> <strong>%2$d '.I18N::translate('(G%s)', $gen) .'</strong>', |
|
257 | + '<i class="icon-maj-sosa_%1$s" title="'.I18N::translate('Sosa').'"></i> <strong>%2$d '.I18N::translate('(G%s)', $gen).'</strong>', |
|
258 | 258 | $size, |
259 | 259 | $sosa |
260 | 260 | ); |
@@ -280,15 +280,15 @@ discard block |
||
280 | 280 | * @param string $size CSS size for the icon. A CSS style css_$size is required |
281 | 281 | * @return string HTML code for IsSourced icon |
282 | 282 | */ |
283 | - public static function formatIsSourcedIcon($sourceType, $isSourced, $tag='EVEN', $format = 1, $size='normal'){ |
|
284 | - $html=''; |
|
285 | - $image=null; |
|
286 | - $title=null; |
|
287 | - switch($format){ |
|
283 | + public static function formatIsSourcedIcon($sourceType, $isSourced, $tag = 'EVEN', $format = 1, $size = 'normal') { |
|
284 | + $html = ''; |
|
285 | + $image = null; |
|
286 | + $title = null; |
|
287 | + switch ($format) { |
|
288 | 288 | case 1: |
289 | - switch($sourceType){ |
|
289 | + switch ($sourceType) { |
|
290 | 290 | case 'E': |
291 | - switch($isSourced){ |
|
291 | + switch ($isSourced) { |
|
292 | 292 | case 0: |
293 | 293 | $image = 'event_unknown'; |
294 | 294 | $title = I18N::translate('%s not found', GedcomTag::getLabel($tag)); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | } |
319 | 319 | break; |
320 | 320 | case 'R': |
321 | - switch($isSourced){ |
|
321 | + switch ($isSourced) { |
|
322 | 322 | case -1: |
323 | 323 | $image = 'record_notsourced'; |
324 | 324 | $title = I18N::translate('%s not sourced', GedcomTag::getLabel($tag)); |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | default: |
340 | 340 | break; |
341 | 341 | } |
342 | - if($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
342 | + if ($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
343 | 343 | break; |
344 | 344 | default: |
345 | 345 | break; |
@@ -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(){ |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | class Individual extends GedcomRecord { |
22 | 22 | |
23 | 23 | /** @var array|null List of titles the individal holds */ |
24 | - protected $titles=null; |
|
24 | + protected $titles = null; |
|
25 | 25 | |
26 | 26 | /** @var string|null Individual's primary surname, without any privacy applied to it */ |
27 | 27 | protected $unprotected_prim_surname = null; |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * @param null|string $gedcom |
44 | 44 | * @return null|Individual |
45 | 45 | */ |
46 | - public static function getIntance($xref, Tree $tree, $gedcom = null){ |
|
46 | + public static function getIntance($xref, Tree $tree, $gedcom = null) { |
|
47 | 47 | $indi = \Fisharebest\Webtrees\Individual::getInstance($xref, $tree, $gedcom); |
48 | - if($indi){ |
|
48 | + if ($indi) { |
|
49 | 49 | return new Individual($indi); |
50 | 50 | } |
51 | 51 | return null; |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return array Array of titles |
58 | 58 | */ |
59 | - public function getTitles(){ |
|
60 | - if(is_null($this->titles) && $module = Module::getModuleByName(Constants::MODULE_MAJ_MISC_NAME)){ |
|
59 | + public function getTitles() { |
|
60 | + if (is_null($this->titles) && $module = Module::getModuleByName(Constants::MODULE_MAJ_MISC_NAME)) { |
|
61 | 61 | $pattern = '/(.*) (('.$module->getSetting('MAJ_TITLE_PREFIX', '').')(.*))/'; |
62 | - $this->titles=array(); |
|
62 | + $this->titles = array(); |
|
63 | 63 | $titlefacts = $this->gedcomrecord->getFacts('TITL'); |
64 | - foreach($titlefacts as $titlefact){ |
|
64 | + foreach ($titlefacts as $titlefact) { |
|
65 | 65 | $ct2 = preg_match_all($pattern, $titlefact->getValue(), $match2); |
66 | - if($ct2>0){ |
|
67 | - $this->titles[$match2[1][0]][]= trim($match2[2][0]); |
|
66 | + if ($ct2 > 0) { |
|
67 | + $this->titles[$match2[1][0]][] = trim($match2[2][0]); |
|
68 | 68 | } |
69 | - else{ |
|
70 | - $this->titles[$titlefact->getValue()][]=''; |
|
69 | + else { |
|
70 | + $this->titles[$titlefact->getValue()][] = ''; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | } |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | * @return string Primary surname |
82 | 82 | */ |
83 | 83 | public function getUnprotectedPrimarySurname() { |
84 | - if(!$this->unprotected_prim_surname){ |
|
85 | - $tmp=$this->gedcomrecord->getAllNames(); |
|
84 | + if (!$this->unprotected_prim_surname) { |
|
85 | + $tmp = $this->gedcomrecord->getAllNames(); |
|
86 | 86 | $this->unprotected_prim_surname = $tmp[$this->gedcomrecord->getPrimaryName()]['surname']; |
87 | 87 | } |
88 | 88 | return $this->unprotected_prim_surname; |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | * @param boolean $perc Should the coefficient of reliability be returned |
95 | 95 | * @return string|array Estimated birth place if found, null otherwise |
96 | 96 | */ |
97 | - public function getEstimatedBirthPlace($perc=false){ |
|
98 | - if($bplace = $this->gedcomrecord->getBirthPlace()){ |
|
99 | - if($perc){ |
|
100 | - return array ($bplace, 1); |
|
97 | + public function getEstimatedBirthPlace($perc = false) { |
|
98 | + if ($bplace = $this->gedcomrecord->getBirthPlace()) { |
|
99 | + if ($perc) { |
|
100 | + return array($bplace, 1); |
|
101 | 101 | } |
102 | - else{ |
|
102 | + else { |
|
103 | 103 | return $bplace; |
104 | 104 | } |
105 | 105 | } |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * @param boolean $perc Should the coefficient of reliability be returned |
113 | 113 | * @return string|array Estimated birth place if found, null otherwise |
114 | 114 | */ |
115 | - public function getSignificantPlace(){ |
|
116 | - if($bplace = $this->gedcomrecord->getBirthPlace()){ |
|
115 | + public function getSignificantPlace() { |
|
116 | + if ($bplace = $this->gedcomrecord->getBirthPlace()) { |
|
117 | 117 | return $bplace; |
118 | 118 | } |
119 | 119 | |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - if($dplace = $this->gedcomrecord->getDeathPlace()){ |
|
126 | + if ($dplace = $this->gedcomrecord->getDeathPlace()) { |
|
127 | 127 | return $dplace; |
128 | 128 | } |
129 | 129 | |
130 | - foreach($this->gedcomrecord->getSpouseFamilies() as $fams) { |
|
130 | + foreach ($this->gedcomrecord->getSpouseFamilies() as $fams) { |
|
131 | 131 | foreach ($fams->getAllEventPlaces('RESI') as $rplace) { |
132 | 132 | if ($rplace) { |
133 | 133 | return $rplace; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return boolean Is the individual a Sosa ancestor |
145 | 145 | */ |
146 | - public function isSosa(){ |
|
146 | + public function isSosa() { |
|
147 | 147 | return count($this->getSosaNumbers()) > 0; |
148 | 148 | } |
149 | 149 | |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | * @uses \MyArtJaub\Webtrees\Functions\ModuleManager |
155 | 155 | * @return array List of Sosa numbers |
156 | 156 | */ |
157 | - public function getSosaNumbers(){ |
|
158 | - if($this->sosa === null) { |
|
157 | + public function getSosaNumbers() { |
|
158 | + if ($this->sosa === null) { |
|
159 | 159 | $provider = new SosaProvider($this->gedcomrecord->getTree()); |
160 | 160 | $this->sosa = $provider->getSosaNumbers($this->gedcomrecord); |
161 | 161 | } |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return int Level of sources |
169 | 169 | * */ |
170 | - public function isBirthSourced(){ |
|
171 | - if($this->is_birth_sourced !== null) return $this->is_birth_sourced; |
|
170 | + public function isBirthSourced() { |
|
171 | + if ($this->is_birth_sourced !== null) return $this->is_birth_sourced; |
|
172 | 172 | $this->is_birth_sourced = $this->isFactSourced(WT_EVENTS_BIRT); |
173 | 173 | return $this->is_birth_sourced; |
174 | 174 | } |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @return int Level of sources |
180 | 180 | * */ |
181 | - public function isDeathSourced(){ |
|
182 | - if($this->is_death_sourced !== null) return $this->is_death_sourced; |
|
181 | + public function isDeathSourced() { |
|
182 | + if ($this->is_death_sourced !== null) return $this->is_death_sourced; |
|
183 | 183 | $this->is_death_sourced = $this->isFactSourced(WT_EVENTS_DEAT); |
184 | 184 | return $this->is_death_sourced; |
185 | 185 | } |
@@ -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 |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param string $file Filename containing the task object |
81 | 81 | * @param TaskProviderInterface $provider Provider for tasks |
82 | 82 | */ |
83 | - public function __construct($file, TaskProviderInterface $provider = null){ |
|
83 | + public function __construct($file, TaskProviderInterface $provider = null) { |
|
84 | 84 | $this->name = trim(basename($file, '.php')); |
85 | 85 | $this->provider = $provider; |
86 | 86 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return TaskProviderInterface |
92 | 92 | */ |
93 | - public function getProvider(){ |
|
93 | + public function getProvider() { |
|
94 | 94 | return $this->provider; |
95 | 95 | } |
96 | 96 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param TaskProviderInterface $provider |
101 | 101 | * @return self Enable method-chaining |
102 | 102 | */ |
103 | - public function setProvider(TaskProviderInterface $provider){ |
|
103 | + public function setProvider(TaskProviderInterface $provider) { |
|
104 | 104 | $this->provider = $provider; |
105 | 105 | return $this; |
106 | 106 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited |
116 | 116 | * @param bool $is_running Indicates if the task is currently running |
117 | 117 | */ |
118 | - public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running){ |
|
118 | + public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running) { |
|
119 | 119 | $this->is_enabled = $is_enabled; |
120 | 120 | $this->last_updated = $last_updated; |
121 | 121 | $this->last_result = $last_result; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return string |
131 | 131 | */ |
132 | - public function getName(){ |
|
132 | + public function getName() { |
|
133 | 133 | return $this->name; |
134 | 134 | } |
135 | 135 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return boolean True if enabled |
141 | 141 | */ |
142 | - public function isEnabled(){ |
|
142 | + public function isEnabled() { |
|
143 | 143 | return $this->is_enabled; |
144 | 144 | } |
145 | 145 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return \DateTime |
150 | 150 | */ |
151 | - public function getLastUpdated(){ |
|
151 | + public function getLastUpdated() { |
|
152 | 152 | return $this->last_updated; |
153 | 153 | } |
154 | 154 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @return bool |
159 | 159 | */ |
160 | - public function isLastRunSuccess(){ |
|
160 | + public function isLastRunSuccess() { |
|
161 | 161 | return $this->last_result; |
162 | 162 | } |
163 | 163 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return int |
168 | 168 | */ |
169 | - public function getFrequency(){ |
|
169 | + public function getFrequency() { |
|
170 | 170 | return $this->frequency; |
171 | 171 | } |
172 | 172 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @param int $frequency |
177 | 177 | * @return self Enable method-chaining |
178 | 178 | */ |
179 | - public function setFrequency($frequency){ |
|
179 | + public function setFrequency($frequency) { |
|
180 | 180 | $this->frequency = $frequency; |
181 | 181 | return $this; |
182 | 182 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @return int |
188 | 188 | */ |
189 | - public function getRemainingOccurrences(){ |
|
189 | + public function getRemainingOccurrences() { |
|
190 | 190 | return $this->nb_occurrences; |
191 | 191 | } |
192 | 192 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @param int $nb_occur |
197 | 197 | * @return self Enable method-chaining |
198 | 198 | */ |
199 | - public function setRemainingOccurrences($nb_occur){ |
|
199 | + public function setRemainingOccurrences($nb_occur) { |
|
200 | 200 | $this->nb_occurrences = $nb_occur; |
201 | 201 | return $this; |
202 | 202 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return bool |
208 | 208 | */ |
209 | - public function isRunning(){ |
|
209 | + public function isRunning() { |
|
210 | 210 | return $this->is_running; |
211 | 211 | } |
212 | 212 | |
@@ -235,7 +235,7 @@ discard block |
||
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 | |
@@ -243,23 +243,23 @@ discard block |
||
243 | 243 | * Execute the task, default skeleton |
244 | 244 | * |
245 | 245 | */ |
246 | - public function execute(){ |
|
246 | + public function execute() { |
|
247 | 247 | |
248 | - if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
248 | + if ($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
249 | 249 | $this->is_running = false; |
250 | 250 | |
251 | - if(!$this->is_running){ |
|
251 | + if (!$this->is_running) { |
|
252 | 252 | $this->last_result = false; |
253 | 253 | $this->is_running = true; |
254 | 254 | $this->save(); |
255 | 255 | |
256 | 256 | Log::addDebugLog('Start execution of Admin task: '.$this->getTitle()); |
257 | 257 | $this->last_result = $this->executeSteps(); |
258 | - if($this->last_result){ |
|
258 | + if ($this->last_result) { |
|
259 | 259 | $this->last_updated = new \DateTime(); |
260 | - if($this->nb_occurrences > 0){ |
|
260 | + if ($this->nb_occurrences > 0) { |
|
261 | 261 | $this->nb_occurrences--; |
262 | - if($this->nb_occurrences == 0) $this->is_enabled = false; |
|
262 | + if ($this->nb_occurrences == 0) $this->is_enabled = false; |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | $this->is_running = false; |
@@ -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); |
@@ -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,7 +35,7 @@ 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 | 40 | /** @var string The "TITL" value from the GEDCOM |
41 | 41 | * This is a tweak to overcome the private level from the parent object... |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | $this->title = basename($this->getFilename(), '.'.$this->extension()); |
95 | 95 | |
96 | 96 | $ct = preg_match("/(?<year>\d{1,4})(\.(?<month>\d{1,2}))?(\.(?<day>\d{1,2}))?( (?<type>[A-Z]{1,2}) )?(?<details>.*)/", $this->title, $match); |
97 | - if($ct > 0){ |
|
98 | - $monthId = (int) $match['month']; |
|
97 | + if ($ct > 0) { |
|
98 | + $monthId = (int)$match['month']; |
|
99 | 99 | $calendarShortMonths = Functions::getCalendarShortMonths(); |
100 | 100 | $monthShortName = array_key_exists($monthId, $calendarShortMonths) ? $calendarShortMonths[$monthId] : $monthId; |
101 | 101 | $this->certDate = new Date($match['day'].' '.strtoupper($monthShortName).' '.$match['year']); |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | * @see \Fisharebest\Webtrees\GedcomRecord::getInstance() |
112 | 112 | */ |
113 | 113 | static public function getInstance($xref, Tree $tree, $gedcom = null, CertificateProviderInterface $provider = null) { |
114 | - try{ |
|
114 | + try { |
|
115 | 115 | $certfile = Functions::decryptFromSafeBase64($xref); |
116 | 116 | |
117 | 117 | //NEED TO CHECK THAT !!! |
118 | - if(Functions::isValidPath($certfile, true)) { |
|
118 | + if (Functions::isValidPath($certfile, true)) { |
|
119 | 119 | return new Certificate($certfile, $tree, $provider); |
120 | 120 | } |
121 | 121 | } |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @param string|Source $xref |
154 | 154 | */ |
155 | - public function setSource($xref){ |
|
156 | - if($xref instanceof Source){ |
|
155 | + public function setSource($xref) { |
|
156 | + if ($xref instanceof Source) { |
|
157 | 157 | $this->source = $data; |
158 | 158 | } else { |
159 | 159 | $this->source = Source::getInstance($xref, $this->tree); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return Date Certificate date |
175 | 175 | */ |
176 | - public function getCertificateDate(){ |
|
176 | + public function getCertificateDate() { |
|
177 | 177 | return $this->certDate; |
178 | 178 | } |
179 | 179 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return string Certificate date |
184 | 184 | */ |
185 | - public function getCertificateType(){ |
|
185 | + public function getCertificateType() { |
|
186 | 186 | return $this->certType; |
187 | 187 | } |
188 | 188 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return string Certificate details |
193 | 193 | */ |
194 | - public function getCertificateDetails(){ |
|
194 | + public function getCertificateDetails() { |
|
195 | 195 | return $this->certDetails; |
196 | 196 | } |
197 | 197 | |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return string|NULL Certificate city |
202 | 202 | */ |
203 | - public function getCity(){ |
|
203 | + public function getCity() { |
|
204 | 204 | $chunks = explode('/', $this->getFilename(), 2); |
205 | - if(count($chunks) > 1) return $chunks[0]; |
|
205 | + if (count($chunks) > 1) return $chunks[0]; |
|
206 | 206 | return null; |
207 | 207 | } |
208 | 208 | |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | * {@inhericDoc} |
211 | 211 | * @see \Fisharebest\Webtrees\Media::getServerFilename() |
212 | 212 | */ |
213 | - public function getServerFilename($which='main') { |
|
214 | - $filename = $this->provider->getRealCertificatesDirectory() . $this->getFilename(); |
|
213 | + public function getServerFilename($which = 'main') { |
|
214 | + $filename = $this->provider->getRealCertificatesDirectory().$this->getFilename(); |
|
215 | 215 | return Functions::encodeUtf8ToFileSystem($filename); |
216 | 216 | } |
217 | 217 | |
@@ -222,11 +222,11 @@ discard block |
||
222 | 222 | public function getHtmlUrlDirect($which = 'main', $download = false) { |
223 | 223 | $sidstr = ($this->source) ? '&sid='.$this->source->getXref() : ''; |
224 | 224 | return |
225 | - 'module.php?mod='. \MyArtJaub\Webtrees\Constants::MODULE_MAJ_CERTIF_NAME . |
|
226 | - '&mod_action=Certificate@image' . |
|
227 | - '&ged='. $this->tree->getNameUrl() . |
|
228 | - '&cid=' . $this->getXref() . $sidstr . |
|
229 | - '&cb=' . $this->getEtag($which); |
|
225 | + 'module.php?mod='.\MyArtJaub\Webtrees\Constants::MODULE_MAJ_CERTIF_NAME. |
|
226 | + '&mod_action=Certificate@image'. |
|
227 | + '&ged='.$this->tree->getNameUrl(). |
|
228 | + '&cid='.$this->getXref().$sidstr. |
|
229 | + '&cb='.$this->getEtag($which); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -237,26 +237,26 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return string Watermark text |
239 | 239 | */ |
240 | - public function getWatermarkText(){ |
|
240 | + public function getWatermarkText() { |
|
241 | 241 | $module = Module::getModuleByName(Constants::MODULE_MAJ_CERTIF_NAME); |
242 | 242 | |
243 | - if($module) { |
|
243 | + if ($module) { |
|
244 | 244 | $wmtext = $module->getSetting('MAJ_WM_DEFAULT', I18N::translate('This image is protected under copyright law.')); |
245 | - $sid= Filter::get('sid', WT_REGEX_XREF); |
|
245 | + $sid = Filter::get('sid', WT_REGEX_XREF); |
|
246 | 246 | |
247 | - if($sid){ |
|
247 | + if ($sid) { |
|
248 | 248 | $this->source = Source::getInstance($sid, $this->tree); |
249 | 249 | } |
250 | - else{ |
|
251 | - $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
|
250 | + else { |
|
251 | + $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
|
252 | 252 | } |
253 | 253 | |
254 | - if($this->source) { |
|
254 | + if ($this->source) { |
|
255 | 255 | $wmtext = '©'; |
256 | 256 | $repofact = $this->source->getFirstFact('REPO'); |
257 | - if($repofact) { |
|
257 | + if ($repofact) { |
|
258 | 258 | $repo = $repofact->getTarget(); |
259 | - if($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
259 | + if ($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
260 | 260 | } |
261 | 261 | $wmtext .= $this->source->getFullName(); |
262 | 262 | } |
@@ -279,45 +279,45 @@ discard block |
||
279 | 279 | '; |
280 | 280 | |
281 | 281 | $script = ''; |
282 | - if($controller && !($controller instanceof IndividualController)){ |
|
282 | + if ($controller && !($controller instanceof IndividualController)) { |
|
283 | 283 | $controller->addInlineJavascript('$(document).ready(function() { '.$js.' });'); |
284 | 284 | } else { |
285 | - $script = '<script>' . $js . '</script>'; |
|
285 | + $script = '<script>'.$js.'</script>'; |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | if ($which == 'icon' || !file_exists($this->getServerFilename())) { |
289 | 289 | // Use an icon |
290 | 290 | $image = |
291 | - '<i dir="auto" class="icon-maj-certificate margin-h-2"' . |
|
292 | - ' title="' . strip_tags($this->getFullName()) . '"' . |
|
291 | + '<i dir="auto" class="icon-maj-certificate margin-h-2"'. |
|
292 | + ' title="'.strip_tags($this->getFullName()).'"'. |
|
293 | 293 | '></i>'; |
294 | 294 | } else { |
295 | 295 | $imgsize = getimagesize($this->getServerFilename()); |
296 | 296 | $image = |
297 | - '<img' . |
|
298 | - ' class ="'. 'certif_image' . '"' . |
|
299 | - ' dir="' . 'auto' . '"' . // For the tool-tip |
|
300 | - ' src="' . $this->getHtmlUrlDirect() . '"' . |
|
301 | - ' alt="' . strip_tags($this->getFullName()) . '"' . |
|
302 | - ' title="' . strip_tags($this->getFullName()) . '"' . |
|
303 | - $imgsize[3] . // height="yyy" width="xxx" |
|
297 | + '<img'. |
|
298 | + ' class ="'.'certif_image'.'"'. |
|
299 | + ' dir="'.'auto'.'"'.// For the tool-tip |
|
300 | + ' src="'.$this->getHtmlUrlDirect().'"'. |
|
301 | + ' alt="'.strip_tags($this->getFullName()).'"'. |
|
302 | + ' title="'.strip_tags($this->getFullName()).'"'. |
|
303 | + $imgsize[3].// height="yyy" width="xxx" |
|
304 | 304 | '>'; |
305 | 305 | } |
306 | 306 | return |
307 | - '<a' . |
|
308 | - ' class="' . 'certgallery' . '"' . |
|
309 | - ' href="' . $this->getHtmlUrlDirect() . '"' . |
|
310 | - ' type="' . $this->mimeType() . '"' . |
|
311 | - ' data-obje-url="' . $this->getHtmlUrl() . '"' . |
|
312 | - ' data-title="' . strip_tags($this->getFullName()) . '"' . |
|
313 | - '>' . $image . '</a>'.$script; |
|
307 | + '<a'. |
|
308 | + ' class="'.'certgallery'.'"'. |
|
309 | + ' href="'.$this->getHtmlUrlDirect().'"'. |
|
310 | + ' type="'.$this->mimeType().'"'. |
|
311 | + ' data-obje-url="'.$this->getHtmlUrl().'"'. |
|
312 | + ' data-title="'.strip_tags($this->getFullName()).'"'. |
|
313 | + '>'.$image.'</a>'.$script; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
317 | 317 | * {@inhericDoc} |
318 | 318 | * @see \Fisharebest\Webtrees\GedcomRecord::linkedIndividuals() |
319 | 319 | */ |
320 | - public function linkedIndividuals($link = '_ACT'){ |
|
320 | + public function linkedIndividuals($link = '_ACT') { |
|
321 | 321 | $rows = Database::prepare( |
322 | 322 | 'SELECT i_id AS xref, i_gedcom AS gedcom'. |
323 | 323 | ' FROM `##individuals`'. |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * {@inhericDoc} |
342 | 342 | * @see \Fisharebest\Webtrees\GedcomRecord::linkedFamilies() |
343 | 343 | */ |
344 | - public function linkedFamilies($link = '_ACT'){ |
|
344 | + public function linkedFamilies($link = '_ACT') { |
|
345 | 345 | $rows = Database::prepare( |
346 | 346 | 'SELECT f_id AS xref, f_gedcom AS gedcom'. |
347 | 347 | ' FROM `##families`'. |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @return Source|NULL Linked source |
368 | 368 | */ |
369 | - public function fetchALinkedSource(){ |
|
369 | + public function fetchALinkedSource() { |
|
370 | 370 | $sid = null; |
371 | 371 | |
372 | 372 | // Try to find in individual, then families, then other types of records. We are interested in the first available value. |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | 'gedcom_id' => $this->tree->getTreeId(), |
379 | 379 | 'gedcom' => '%_ACT '.$this->getFilename().'%' |
380 | 380 | ))->fetchOne(); |
381 | - if(!$ged){ |
|
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') |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | 'gedcom_id' => $this->tree->getTreeId(), |
387 | 387 | 'gedcom' => '%_ACT '.$this->getFilename().'%' |
388 | 388 | ))->fetchOne(); |
389 | - if(!$ged){ |
|
389 | + if (!$ged) { |
|
390 | 390 | $ged = Database::prepare( |
391 | 391 | 'SELECT o_gedcom AS gedrec FROM `##other`'. |
392 | 392 | ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom') |
@@ -397,28 +397,28 @@ discard block |
||
397 | 397 | } |
398 | 398 | } |
399 | 399 | //If a record has been found, parse it to find the source reference. |
400 | - if($ged){ |
|
400 | + if ($ged) { |
|
401 | 401 | $gedlines = explode("\n", $ged); |
402 | 402 | $level = 0; |
403 | 403 | $levelsource = -1; |
404 | - $sid_tmp=null; |
|
404 | + $sid_tmp = null; |
|
405 | 405 | $sourcefound = false; |
406 | - foreach($gedlines as $gedline){ |
|
406 | + foreach ($gedlines as $gedline) { |
|
407 | 407 | // Get the level |
408 | 408 | if (!$sourcefound && preg_match('~^('.WT_REGEX_INTEGER.') ~', $gedline, $match)) { |
409 | 409 | $level = $match[1]; |
410 | 410 | //If we are not any more within the context of a source, reset |
411 | - if($level <= $levelsource){ |
|
411 | + if ($level <= $levelsource) { |
|
412 | 412 | $levelsource = -1; |
413 | 413 | $sid_tmp = null; |
414 | 414 | } |
415 | 415 | // If a source, get the level and the reference |
416 | 416 | if (preg_match('~^'.$level.' SOUR @('.WT_REGEX_XREF.')@$~', $gedline, $match2)) { |
417 | 417 | $levelsource = $level; |
418 | - $sid_tmp=$match2[1]; |
|
418 | + $sid_tmp = $match2[1]; |
|
419 | 419 | } |
420 | 420 | // If the image has be found, get the source reference and exit. |
421 | - if($levelsource>=0 && $sid_tmp && preg_match('~^'.$level.' _ACT '.preg_quote($this->getFilename()).'~', $gedline, $match3)){ |
|
421 | + if ($levelsource >= 0 && $sid_tmp && preg_match('~^'.$level.' _ACT '.preg_quote($this->getFilename()).'~', $gedline, $match3)) { |
|
422 | 422 | $sid = $sid_tmp; |
423 | 423 | $sourcefound = true; |
424 | 424 | } |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | } |
427 | 427 | } |
428 | 428 | |
429 | - if($sid) $this->source = Source::getInstance($sid, $this->tree); |
|
429 | + if ($sid) $this->source = Source::getInstance($sid, $this->tree); |
|
430 | 430 | |
431 | 431 | return $this->source; |
432 | 432 | } |
@@ -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){ |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
68 | 68 | */ |
69 | 69 | public function getConfigLink() { |
70 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
70 | + return 'module.php?mod='.$this->getName().'&mod_action=AdminConfig'; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function getMenu(Tree $tree, $reference = null) { |
94 | 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')); |
|
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 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -102,27 +102,27 @@ discard block |
||
102 | 102 | public function hFactSourcePrepend($srec) { |
103 | 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)){ |
|
108 | + if ($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)) { |
|
109 | 109 | if (!$srec || strlen($srec) == 0) return $html; |
110 | 110 | |
111 | 111 | $certificate = null; |
112 | 112 | $subrecords = explode("\n", $srec); |
113 | 113 | $levelSOUR = substr($subrecords[0], 0, 1); |
114 | 114 | if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) { |
115 | - $sid=$match[1]; |
|
115 | + $sid = $match[1]; |
|
116 | 116 | }; |
117 | 117 | $nb_subrecords = count($subrecords); |
118 | - for ($i=0; $i < $nb_subrecords; $i++) { |
|
118 | + for ($i = 0; $i < $nb_subrecords; $i++) { |
|
119 | 119 | $subrecords[$i] = trim($subrecords[$i]); |
120 | 120 | $tag = substr($subrecords[$i], 2, 4); |
121 | 121 | $text = substr($subrecords[$i], 7); |
122 | - if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
122 | + if ($tag == '_ACT') $certificate = new Certificate($text, $WT_TREE, $this->getProvider()); |
|
123 | 123 | } |
124 | 124 | |
125 | - if($certificate && $certificate->canShow()) |
|
125 | + if ($certificate && $certificate->canShow()) |
|
126 | 126 | $html = $this->getDisplay_ACT($certificate, $sid); |
127 | 127 | |
128 | 128 | } |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) { |
151 | 151 | $html = ''; |
152 | - switch($tag){ |
|
152 | + switch ($tag) { |
|
153 | 153 | case '_ACT': |
154 | - if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
154 | + if ($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
155 | 155 | break; |
156 | 156 | } |
157 | 157 | return $html; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | $html = ''; |
168 | 168 | |
169 | - switch($tag){ |
|
169 | + switch ($tag) { |
|
170 | 170 | case '_ACT': |
171 | 171 | $element_id = Uuid::uuid4(); |
172 | 172 | $controller |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | ->addExternalJavascript(WT_STATIC_URL.WT_MODULES_DIR.$this->getName().'/js/autocomplete.js') |
175 | 175 | ->addExternalJavascript(WT_STATIC_URL.WT_MODULES_DIR.$this->getName().'/js/updatecertificatevalues.js'); |
176 | 176 | $certificate = null; |
177 | - if($value){ |
|
177 | + if ($value) { |
|
178 | 178 | $certificate = new Certificate($value, $WT_TREE, $this->getProvider()); |
179 | 179 | } |
180 | 180 | $tabCities = $this->getProvider()->getCitiesList(); |
181 | 181 | $html .= '<select id="certifCity'.$element_id.'" class="_CITY">'; |
182 | - foreach ($tabCities as $cities){ |
|
183 | - $selectedCity=''; |
|
184 | - if($certificate && $cities== $certificate->getCity()) $selectedCity='selected="true"'; |
|
182 | + foreach ($tabCities as $cities) { |
|
183 | + $selectedCity = ''; |
|
184 | + if ($certificate && $cities == $certificate->getCity()) $selectedCity = 'selected="true"'; |
|
185 | 185 | $html .= '<option value="'.$cities.'" '.$selectedCity.' />'.$cities.'</option>'; |
186 | 186 | } |
187 | 187 | $html .= '</select>'; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag() |
200 | 200 | */ |
201 | 201 | public function hAddSimpleTag($context, $level) { |
202 | - switch($context){ |
|
202 | + switch ($context) { |
|
203 | 203 | case 'SOUR': |
204 | 204 | FunctionsEdit::addSimpleTag($level.' _ACT'); |
205 | 205 | break; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag() |
212 | 212 | */ |
213 | 213 | public function hHasHelpTextTag($tag) { |
214 | - switch($tag){ |
|
214 | + switch ($tag) { |
|
215 | 215 | case '_ACT': |
216 | 216 | return true; |
217 | 217 | break; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag() |
225 | 225 | */ |
226 | 226 | public function hGetHelpTextTag($tag) { |
227 | - switch($tag){ |
|
227 | + switch ($tag) { |
|
228 | 228 | case '_ACT': |
229 | 229 | return array( |
230 | 230 | I18N::translate('Certificate'), |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | public function getProvider() { |
243 | 243 | global $WT_TREE; |
244 | 244 | |
245 | - if(!$this->provider) { |
|
245 | + if (!$this->provider) { |
|
246 | 246 | $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/'); |
247 | 247 | $this->provider = new CertificateFileProvider($root_path, $WT_TREE); |
248 | 248 | } |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
257 | 257 | * @param string|null $sid Linked Source ID, if it exists |
258 | 258 | */ |
259 | - protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
|
259 | + protected function getDisplay_ACT(Certificate $certificate, $sid = null) { |
|
260 | 260 | $html = ''; |
261 | - if($certificate){ |
|
261 | + if ($certificate) { |
|
262 | 262 | $certificate->setSource($sid); |
263 | 263 | $html = $certificate->displayImage('icon'); |
264 | 264 | } |
@@ -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; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param Fisharebest\Webtrees\Family $fams |
58 | 58 | */ |
59 | 59 | public function addFamily(Family $fams) { |
60 | - if($fams && !isset($this->linked_fams[$fams])) { |
|
60 | + if ($fams && !isset($this->linked_fams[$fams])) { |
|
61 | 61 | $this->linked_fams[$fams] = array(); |
62 | 62 | } |
63 | 63 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param LineageNode $child |
70 | 70 | */ |
71 | 71 | public function addChild(Family $fams, LineageNode $child = null) { |
72 | - if($fams) { |
|
72 | + if ($fams) { |
|
73 | 73 | $this->addFamily($fams); |
74 | 74 | $tmp = $this->linked_fams[$fams]; |
75 | 75 | $tmp[] = $child; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @return boolean |
120 | 120 | */ |
121 | 121 | public function hasFollowUpSurname() { |
122 | - return !is_null($this->alt_surname) && strlen($this->alt_surname) > 0 ; |
|
122 | + return !is_null($this->alt_surname) && strlen($this->alt_surname) > 0; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | } |
@@ -246,7 +246,6 @@ discard block |
||
246 | 246 | /** |
247 | 247 | * Return the list of all sosas, with the generations it belongs to |
248 | 248 | * |
249 | - * @param int $ged_id ID of the gedcom file |
|
250 | 249 | * @return array Associative array of Sosa ancestors, with their generation, comma separated |
251 | 250 | */ |
252 | 251 | public function getAllSosaWithGenerations(){ |
@@ -266,7 +265,7 @@ discard block |
||
266 | 265 | /** |
267 | 266 | * Get an associative array of Sosa individuals in generation G. Keys are Sosa numbers, values individuals. |
268 | 267 | * |
269 | - * @param number $gen Generation |
|
268 | + * @param integer $gen Generation |
|
270 | 269 | * @return array Array of Sosa individuals |
271 | 270 | */ |
272 | 271 | public function getSosaListAtGeneration($gen){ |
@@ -297,7 +296,7 @@ discard block |
||
297 | 296 | /** |
298 | 297 | * Get an associative array of Sosa families in generation G. Keys are Sosa numbers for the husband, values families. |
299 | 298 | * |
300 | - * @param number $gen Generation |
|
299 | + * @param integer $gen Generation |
|
301 | 300 | * @return array Array of Sosa families |
302 | 301 | */ |
303 | 302 | public function getFamilySosaListAtGeneration($gen){ |
@@ -333,7 +332,7 @@ discard block |
||
333 | 332 | /** |
334 | 333 | * Get an associative array of Sosa individuals in generation G who are missing parents. Keys are Sosa numbers, values individuals. |
335 | 334 | * |
336 | - * @param number $gen Generation |
|
335 | + * @param integer $gen Generation |
|
337 | 336 | * @return array Array of Sosa individuals |
338 | 337 | */ |
339 | 338 | public function getMissingSosaListAtGeneration($gen){ |
@@ -428,8 +427,8 @@ discard block |
||
428 | 427 | /** |
429 | 428 | * Get the number of Sosa in a specific generation. |
430 | 429 | * |
431 | - * @param number $gen Generation |
|
432 | - * @return number Number of Sosas in generation |
|
430 | + * @param integer $gen Generation |
|
431 | + * @return integer Number of Sosas in generation |
|
433 | 432 | */ |
434 | 433 | public function getSosaCountAtGeneration($gen){ |
435 | 434 | if(!$this->is_setup) return 0; |
@@ -447,7 +446,7 @@ discard block |
||
447 | 446 | /** |
448 | 447 | * Get the total number of Sosa up to a specific generation. |
449 | 448 | * |
450 | - * @param number $gen Generation |
|
449 | + * @param integer $gen Generation |
|
451 | 450 | * @return number Total number of Sosas up to generation |
452 | 451 | */ |
453 | 452 | public function getSosaCountUpToGeneration($gen){ |
@@ -482,7 +481,7 @@ discard block |
||
482 | 481 | /** |
483 | 482 | * Get the number of distinct Sosa individual up to a specific generation. |
484 | 483 | * |
485 | - * @param number $gen Generation |
|
484 | + * @param integer $gen Generation |
|
486 | 485 | * @return number Number of distinct Sosa individuals up to generation |
487 | 486 | */ |
488 | 487 | public function getDifferentSosaCountUpToGeneration($gen){ |
@@ -505,7 +504,7 @@ discard block |
||
505 | 504 | * - last : Last birth year in generation |
506 | 505 | * - avg : Average birth year |
507 | 506 | * |
508 | - * @param number $gen Generation |
|
507 | + * @param integer $gen Generation |
|
509 | 508 | * @return array Birth statistics array |
510 | 509 | */ |
511 | 510 | public function getStatsBirthYearInGeneration($gen){ |
@@ -84,18 +84,18 @@ discard block |
||
84 | 84 | * @param User $user |
85 | 85 | */ |
86 | 86 | public function __construct(Tree $tree, User $user = null) { |
87 | - if(self::$default_user === null) |
|
87 | + if (self::$default_user === null) |
|
88 | 88 | self::$default_user = User::find(-1); |
89 | 89 | |
90 | 90 | $this->tree = $tree; |
91 | 91 | $this->user = $user; |
92 | 92 | $this->is_setup = true; |
93 | - if($this->user === null) $this->user = Auth::user(); |
|
94 | - if(strlen($this->user->getUserId()) == 0) $this->user = self::$default_user; |
|
93 | + if ($this->user === null) $this->user = Auth::user(); |
|
94 | + if (strlen($this->user->getUserId()) == 0) $this->user = self::$default_user; |
|
95 | 95 | |
96 | 96 | // Check if the user, or the default user, has a root already setup; |
97 | - if(empty($this->getRootIndiId())) { |
|
98 | - if($this->user == self::$default_user) { // If the default user is not setup |
|
97 | + if (empty($this->getRootIndiId())) { |
|
98 | + if ($this->user == self::$default_user) { // If the default user is not setup |
|
99 | 99 | $this->is_setup = false; |
100 | 100 | } |
101 | 101 | else { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function getRootIndi() { |
129 | 129 | $root_indi_id = $this->getRootIndiId(); |
130 | - if(!empty($root_indi_id)) { |
|
130 | + if (!empty($root_indi_id)) { |
|
131 | 131 | return Individual::getInstance($root_indi_id, $this->tree); |
132 | 132 | } |
133 | 133 | return null; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * Remove all Sosa entries related to the gedcom file and user |
142 | 142 | */ |
143 | 143 | public function deleteAll() { |
144 | - if(!$this->is_setup) return; |
|
144 | + if (!$this->is_setup) return; |
|
145 | 145 | Database::prepare( |
146 | 146 | 'DELETE FROM `##maj_sosa`'. |
147 | 147 | ' WHERE majs_gedcom_id= :tree_id and majs_user_id = :user_id ') |
@@ -157,12 +157,12 @@ discard block |
||
157 | 157 | * @param int $sosa |
158 | 158 | */ |
159 | 159 | public function deleteAncestors($sosa) { |
160 | - if(!$this->is_setup) return; |
|
160 | + if (!$this->is_setup) return; |
|
161 | 161 | $gen = Functions::getGeneration($sosa); |
162 | 162 | Database::prepare( |
163 | 163 | 'DELETE FROM `##maj_sosa`'. |
164 | - ' WHERE majs_gedcom_id=:tree_id and majs_user_id = :user_id' . |
|
165 | - ' AND majs_gen >= :gen' . |
|
164 | + ' WHERE majs_gedcom_id=:tree_id and majs_user_id = :user_id'. |
|
165 | + ' AND majs_gen >= :gen'. |
|
166 | 166 | ' AND FLOOR(majs_sosa / (POW(2, (majs_gen - :gen)))) = :sosa' |
167 | 167 | )->execute(array( |
168 | 168 | 'tree_id' => $this->tree->getTreeId(), |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param array $sosa_records |
178 | 178 | */ |
179 | 179 | public function insertOrUpdate($sosa_records) { |
180 | - if(!$this->is_setup) return; |
|
180 | + if (!$this->is_setup) return; |
|
181 | 181 | |
182 | 182 | $treeid = $this->tree->getTreeId(); |
183 | 183 | $userid = $this->user->getUserId(); |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | $values_table = array(); |
186 | 186 | |
187 | 187 | $i = 0; |
188 | - foreach ($sosa_records as $row) { |
|
188 | + foreach ($sosa_records as $row) { |
|
189 | 189 | $gen = Functions::getGeneration($row['sosa']); |
190 | - if($gen <= self::MAX_DB_GENERATIONS) { |
|
190 | + if ($gen <= self::MAX_DB_GENERATIONS) { |
|
191 | 191 | $questionmarks_table[] = |
192 | 192 | '(:tree_id'.$i.', :user_id'.$i.', :sosa'.$i.', :indi_id'.$i.', :gen'.$i.', :byear'.$i.', :dyear'.$i.')'; |
193 | 193 | $values_table = array_merge( |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | $i++; |
207 | 207 | } |
208 | 208 | |
209 | - $sql = 'REPLACE INTO `##maj_sosa`' . |
|
210 | - ' (majs_gedcom_id, majs_user_id, majs_sosa, majs_i_id, majs_gen, majs_birth_year, majs_death_year)' . |
|
211 | - ' VALUES '. implode(',', $questionmarks_table); |
|
209 | + $sql = 'REPLACE INTO `##maj_sosa`'. |
|
210 | + ' (majs_gedcom_id, majs_user_id, majs_sosa, majs_i_id, majs_gen, majs_birth_year, majs_death_year)'. |
|
211 | + ' VALUES '.implode(',', $questionmarks_table); |
|
212 | 212 | Database::prepare($sql)->execute($values_table); |
213 | 213 | } |
214 | 214 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @return array Array of sosa numbers |
225 | 225 | */ |
226 | 226 | public function getSosaNumbers(Individual $indi) { |
227 | - if(!$this->is_setup) return array(); |
|
227 | + if (!$this->is_setup) return array(); |
|
228 | 228 | return Database::prepare( |
229 | 229 | 'SELECT majs_sosa, majs_gen FROM `##maj_sosa`'. |
230 | 230 | ' WHERE majs_i_id=:indi_id AND majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return number Last generation if found, 1 otherwise |
242 | 242 | */ |
243 | 243 | public function getLastGeneration() { |
244 | - if(!$this->is_setup) return; |
|
244 | + if (!$this->is_setup) return; |
|
245 | 245 | return Database::prepare( |
246 | 246 | 'SELECT MAX(majs_gen) FROM `##maj_sosa`'. |
247 | 247 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -261,13 +261,13 @@ discard block |
||
261 | 261 | * @param int $ged_id ID of the gedcom file |
262 | 262 | * @return array Associative array of Sosa ancestors, with their generation, comma separated |
263 | 263 | */ |
264 | - public function getAllSosaWithGenerations(){ |
|
265 | - if(!$this->is_setup) return array(); |
|
264 | + public function getAllSosaWithGenerations() { |
|
265 | + if (!$this->is_setup) return array(); |
|
266 | 266 | return Database::prepare( |
267 | - 'SELECT majs_i_id AS indi,' . |
|
268 | - ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations' . |
|
269 | - ' FROM `##maj_sosa`' . |
|
270 | - ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' . |
|
267 | + 'SELECT majs_i_id AS indi,'. |
|
268 | + ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations'. |
|
269 | + ' FROM `##maj_sosa`'. |
|
270 | + ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
|
271 | 271 | ' GROUP BY majs_i_id' |
272 | 272 | )->execute(array( |
273 | 273 | 'tree_id' => $this->tree->getTreeId(), |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | * @param number $gen Generation |
282 | 282 | * @return array Array of Sosa individuals |
283 | 283 | */ |
284 | - public function getSosaListAtGeneration($gen){ |
|
285 | - if(!$this->is_setup) return array(); |
|
286 | - if(!$this->sosa_list_by_gen) |
|
284 | + public function getSosaListAtGeneration($gen) { |
|
285 | + if (!$this->is_setup) return array(); |
|
286 | + if (!$this->sosa_list_by_gen) |
|
287 | 287 | $this->sosa_list_by_gen = array(); |
288 | 288 | |
289 | - if($gen){ |
|
290 | - if(!isset($this->sosa_list_by_gen[$gen])){ |
|
289 | + if ($gen) { |
|
290 | + if (!isset($this->sosa_list_by_gen[$gen])) { |
|
291 | 291 | $this->sosa_list_by_gen[$gen] = Database::prepare( |
292 | 292 | 'SELECT majs_sosa AS sosa, majs_i_id AS indi'. |
293 | 293 | ' FROM `##maj_sosa`'. |
@@ -312,13 +312,13 @@ discard block |
||
312 | 312 | * @param number $gen Generation |
313 | 313 | * @return array Array of Sosa families |
314 | 314 | */ |
315 | - public function getFamilySosaListAtGeneration($gen){ |
|
316 | - if(!$this->is_setup) return array(); |
|
317 | - if(!$this->sosa_fam_list_by_gen) |
|
315 | + public function getFamilySosaListAtGeneration($gen) { |
|
316 | + if (!$this->is_setup) return array(); |
|
317 | + if (!$this->sosa_fam_list_by_gen) |
|
318 | 318 | $this->sosa_fam_list_by_gen = array(); |
319 | 319 | |
320 | - if($gen){ |
|
321 | - if(!isset($this->sosa_fam_list_by_gen[$gen])){ |
|
320 | + if ($gen) { |
|
321 | + if (!isset($this->sosa_fam_list_by_gen[$gen])) { |
|
322 | 322 | $this->sosa_fam_list_by_gen[$gen] = Database::prepare( |
323 | 323 | 'SELECT s1.majs_sosa AS sosa, f_id AS fam'. |
324 | 324 | ' FROM `##families`'. |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | * @param number $gen Generation |
349 | 349 | * @return array Array of Sosa individuals |
350 | 350 | */ |
351 | - public function getMissingSosaListAtGeneration($gen){ |
|
352 | - if(!$this->is_setup) return array(); |
|
353 | - if($gen){ |
|
351 | + public function getMissingSosaListAtGeneration($gen) { |
|
352 | + if (!$this->is_setup) return array(); |
|
353 | + if ($gen) { |
|
354 | 354 | return $this->sosa_list_by_gen[$gen] = Database::prepare( |
355 | 355 | 'SELECT schild.majs_sosa sosa, schild.majs_i_id indi, sfat.majs_sosa IS NOT NULL has_father, smot.majs_sosa IS NOT NULL has_mother'. |
356 | 356 | ' FROM `##maj_sosa` schild'. |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | * @return array Statistics array |
388 | 388 | */ |
389 | 389 | public function getStatisticsByGeneration() { |
390 | - if(!$this->is_setup) return array(); |
|
391 | - if(!$this->statistics_tab) { |
|
390 | + if (!$this->is_setup) return array(); |
|
391 | + if (!$this->statistics_tab) { |
|
392 | 392 | $this->statistics_tab = array(); |
393 | - if($maxGeneration = $this->getLastGeneration()) { |
|
393 | + if ($maxGeneration = $this->getLastGeneration()) { |
|
394 | 394 | for ($gen = 1; $gen <= $maxGeneration; $gen++) { |
395 | 395 | $birthStats = $this->getStatsBirthYearInGeneration($gen); |
396 | 396 | $this->statistics_tab[$gen] = array( |
@@ -413,9 +413,9 @@ discard block |
||
413 | 413 | * @return int |
414 | 414 | */ |
415 | 415 | public function getTotalIndividuals() { |
416 | - if(!$this->is_setup) return 0; |
|
416 | + if (!$this->is_setup) return 0; |
|
417 | 417 | return Database::prepare( |
418 | - 'SELECT SQL_CACHE COUNT(*) FROM `##individuals`' . |
|
418 | + 'SELECT SQL_CACHE COUNT(*) FROM `##individuals`'. |
|
419 | 419 | ' WHERE i_file = :tree_id') |
420 | 420 | ->execute(array('tree_id' => $this->tree->getTreeId())) |
421 | 421 | ->fetchOne() ?: 0; |
@@ -426,10 +426,10 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @return number Number of Sosas |
428 | 428 | */ |
429 | - public function getSosaCount(){ |
|
430 | - if(!$this->is_setup) return 0; |
|
429 | + public function getSosaCount() { |
|
430 | + if (!$this->is_setup) return 0; |
|
431 | 431 | return Database::prepare( |
432 | - 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
432 | + 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`'. |
|
433 | 433 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
434 | 434 | ->execute(array( |
435 | 435 | 'tree_id' => $this->tree->getTreeId(), |
@@ -443,10 +443,10 @@ discard block |
||
443 | 443 | * @param number $gen Generation |
444 | 444 | * @return number Number of Sosas in generation |
445 | 445 | */ |
446 | - public function getSosaCountAtGeneration($gen){ |
|
447 | - if(!$this->is_setup) return 0; |
|
446 | + public function getSosaCountAtGeneration($gen) { |
|
447 | + if (!$this->is_setup) return 0; |
|
448 | 448 | return Database::prepare( |
449 | - 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
449 | + 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`'. |
|
450 | 450 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
451 | 451 | ' AND majs_gen= :gen') |
452 | 452 | ->execute(array( |
@@ -462,10 +462,10 @@ discard block |
||
462 | 462 | * @param number $gen Generation |
463 | 463 | * @return number Total number of Sosas up to generation |
464 | 464 | */ |
465 | - public function getSosaCountUpToGeneration($gen){ |
|
466 | - if(!$this->is_setup) return 0; |
|
465 | + public function getSosaCountUpToGeneration($gen) { |
|
466 | + if (!$this->is_setup) return 0; |
|
467 | 467 | return Database::prepare( |
468 | - 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
468 | + 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`'. |
|
469 | 469 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
470 | 470 | ' AND majs_gen <= :gen') |
471 | 471 | ->execute(array( |
@@ -480,10 +480,10 @@ discard block |
||
480 | 480 | * |
481 | 481 | * @return number Total number of distinct individual |
482 | 482 | */ |
483 | - public function getDifferentSosaCount(){ |
|
484 | - if(!$this->is_setup) return 0; |
|
483 | + public function getDifferentSosaCount() { |
|
484 | + if (!$this->is_setup) return 0; |
|
485 | 485 | return Database::prepare( |
486 | - 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
486 | + 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`'. |
|
487 | 487 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
488 | 488 | ->execute(array( |
489 | 489 | 'tree_id' => $this->tree->getTreeId(), |
@@ -497,10 +497,10 @@ discard block |
||
497 | 497 | * @param number $gen Generation |
498 | 498 | * @return number Number of distinct Sosa individuals up to generation |
499 | 499 | */ |
500 | - public function getDifferentSosaCountUpToGeneration($gen){ |
|
501 | - if(!$this->is_setup) return 0; |
|
500 | + public function getDifferentSosaCountUpToGeneration($gen) { |
|
501 | + if (!$this->is_setup) return 0; |
|
502 | 502 | return Database::prepare( |
503 | - 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
503 | + 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`'. |
|
504 | 504 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
505 | 505 | ' AND majs_gen <= :gen') |
506 | 506 | ->execute(array( |
@@ -520,11 +520,11 @@ discard block |
||
520 | 520 | * @param number $gen Generation |
521 | 521 | * @return array Birth statistics array |
522 | 522 | */ |
523 | - public function getStatsBirthYearInGeneration($gen){ |
|
524 | - if(!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
523 | + public function getStatsBirthYearInGeneration($gen) { |
|
524 | + if (!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
525 | 525 | return Database::prepare( |
526 | 526 | 'SELECT MIN(majs_birth_year) AS first, AVG(majs_birth_year) AS avg, MAX(majs_birth_year) AS last'. |
527 | - ' FROM `##maj_sosa`' . |
|
527 | + ' FROM `##maj_sosa`'. |
|
528 | 528 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
529 | 529 | ' AND majs_gen=:gen AND NOT majs_birth_year = :birth_year') |
530 | 530 | ->execute(array( |
@@ -540,26 +540,26 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @return number|NULL Mean generation time |
542 | 542 | */ |
543 | - public function getMeanGenerationTime(){ |
|
544 | - if(!$this->is_setup) return; |
|
545 | - if(!$this->statistics_tab){ |
|
543 | + public function getMeanGenerationTime() { |
|
544 | + if (!$this->is_setup) return; |
|
545 | + if (!$this->statistics_tab) { |
|
546 | 546 | $this->getStatisticsByGeneration(); |
547 | 547 | } |
548 | 548 | //Linear regression on x=generation and y=birthdate |
549 | 549 | $sum_xy = 0; |
550 | - $sum_x=0; |
|
551 | - $sum_y=0; |
|
552 | - $sum_x2=0; |
|
553 | - $n=count($this->statistics_tab); |
|
554 | - foreach($this->statistics_tab as $gen=>$stats){ |
|
555 | - $sum_xy+=$gen*$stats['avgBirth']; |
|
556 | - $sum_x+=$gen; |
|
557 | - $sum_y+=$stats['avgBirth']; |
|
558 | - $sum_x2+=$gen*$gen; |
|
550 | + $sum_x = 0; |
|
551 | + $sum_y = 0; |
|
552 | + $sum_x2 = 0; |
|
553 | + $n = count($this->statistics_tab); |
|
554 | + foreach ($this->statistics_tab as $gen=>$stats) { |
|
555 | + $sum_xy += $gen * $stats['avgBirth']; |
|
556 | + $sum_x += $gen; |
|
557 | + $sum_y += $stats['avgBirth']; |
|
558 | + $sum_x2 += $gen * $gen; |
|
559 | 559 | } |
560 | - $denom=($n*$sum_x2)-($sum_x*$sum_x); |
|
561 | - if($denom!=0){ |
|
562 | - return -(($n*$sum_xy)-($sum_x*$sum_y))/($denom); |
|
560 | + $denom = ($n * $sum_x2) - ($sum_x * $sum_x); |
|
561 | + if ($denom != 0) { |
|
562 | + return -(($n * $sum_xy) - ($sum_x * $sum_y)) / ($denom); |
|
563 | 563 | } |
564 | 564 | return null; |
565 | 565 | } |
@@ -587,14 +587,14 @@ discard block |
||
587 | 587 | * @return array |
588 | 588 | */ |
589 | 589 | public function getAncestorDispersionForGen($gen) { |
590 | - if(!$this->is_setup || $gen > 11) return array(); // Going further than 11 gen will be out of range in the query |
|
590 | + if (!$this->is_setup || $gen > 11) return array(); // Going further than 11 gen will be out of range in the query |
|
591 | 591 | return Database::prepare( |
592 | 592 | 'SELECT branches, count(i_id)'. |
593 | 593 | ' FROM ('. |
594 | 594 | ' SELECT i_id,'. |
595 | 595 | ' CASE'. |
596 | 596 | ' WHEN CEIL(LOG2(SUM(branch))) = LOG2(SUM(branch)) THEN SUM(branch)'. |
597 | - ' ELSE -1'. // We put all ancestors shared between some branches in the same bucket |
|
597 | + ' ELSE -1'.// We put all ancestors shared between some branches in the same bucket |
|
598 | 598 | ' END branches'. |
599 | 599 | ' FROM ('. |
600 | 600 | ' SELECT DISTINCT majs_i_id i_id,'. |