@@ -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 | */ |
@@ -45,7 +45,9 @@ |
||
| 45 | 45 | * @return int Level of sources |
| 46 | 46 | * */ |
| 47 | 47 | function isMarriageSourced(){ |
| 48 | - if($this->is_marriage_sourced !== null) return $this->is_marriage_sourced; |
|
| 48 | + if($this->is_marriage_sourced !== null) { |
|
| 49 | + return $this->is_marriage_sourced; |
|
| 50 | + } |
|
| 49 | 51 | $this->is_marriage_sourced = $this->isFactSourced(WT_EVENTS_MARR.'|MARC'); |
| 50 | 52 | return $this->is_marriage_sourced; |
| 51 | 53 | } |
@@ -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 |
@@ -160,7 +160,9 @@ discard block |
||
| 160 | 160 | public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true){ |
| 161 | 161 | $html = ''; |
| 162 | 162 | $tag = 'em'; |
| 163 | - if($isStrong) $tag = 'strong'; |
|
| 163 | + if($isStrong) { |
|
| 164 | + $tag = 'strong'; |
|
| 165 | + } |
|
| 164 | 166 | if($individual && $individual->canShow()){ |
| 165 | 167 | $dindi = new Individual($individual); |
| 166 | 168 | $html = $individual->getSexImage(); |
@@ -174,8 +176,7 @@ discard block |
||
| 174 | 176 | $html .= ' <span><small><em>'.$dindi->format_first_major_fact(WT_EVENTS_BIRT, 10).'</em></small></span>'; |
| 175 | 177 | $html .= ' <span><small><em>'.$dindi->format_first_major_fact(WT_EVENTS_DEAT, 10).'</em></small></span>'; |
| 176 | 178 | $html .= '</a>'; |
| 177 | - } |
|
| 178 | - else { |
|
| 179 | + } else { |
|
| 179 | 180 | $html .= '<span class=\"list_item\"><'.$tag.'>' . I18N::translate('Private') . '</'.$tag.'></span>'; |
| 180 | 181 | } |
| 181 | 182 | return $html; |
@@ -195,8 +196,7 @@ discard block |
||
| 195 | 196 | $date = $fact->getDate(); |
| 196 | 197 | if($date->isOK()){ |
| 197 | 198 | $html.=' '.$date->Display($anchor && !$SEARCH_SPIDER, '%Y'); |
| 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 |
@@ -220,7 +220,9 @@ discard block |
||
| 220 | 220 | public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor=false){ |
| 221 | 221 | $html=''; |
| 222 | 222 | |
| 223 | - if ($fact === null) return $html; |
|
| 223 | + if ($fact === null) { |
|
| 224 | + return $html; |
|
| 225 | + } |
|
| 224 | 226 | $place = $fact->getPlace(); |
| 225 | 227 | if($place){ |
| 226 | 228 | $dplace = new Place($place); |
@@ -339,7 +341,9 @@ discard block |
||
| 339 | 341 | default: |
| 340 | 342 | break; |
| 341 | 343 | } |
| 342 | - if($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
| 344 | + if($image && $title) { |
|
| 345 | + $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
| 346 | + } |
|
| 343 | 347 | break; |
| 344 | 348 | default: |
| 345 | 349 | 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(){ |
@@ -65,8 +65,7 @@ discard block |
||
| 65 | 65 | $ct2 = preg_match_all($pattern, $titlefact->getValue(), $match2); |
| 66 | 66 | if($ct2>0){ |
| 67 | 67 | $this->titles[$match2[1][0]][]= trim($match2[2][0]); |
| 68 | - } |
|
| 69 | - else{ |
|
| 68 | + } else{ |
|
| 70 | 69 | $this->titles[$titlefact->getValue()][]=''; |
| 71 | 70 | } |
| 72 | 71 | } |
@@ -98,8 +97,7 @@ discard block |
||
| 98 | 97 | if($bplace = $this->gedcomrecord->getBirthPlace()){ |
| 99 | 98 | if($perc){ |
| 100 | 99 | return array ($bplace, 1); |
| 101 | - } |
|
| 102 | - else{ |
|
| 100 | + } else{ |
|
| 103 | 101 | return $bplace; |
| 104 | 102 | } |
| 105 | 103 | } |
@@ -168,7 +166,9 @@ discard block |
||
| 168 | 166 | * @return int Level of sources |
| 169 | 167 | * */ |
| 170 | 168 | public function isBirthSourced(){ |
| 171 | - if($this->is_birth_sourced !== null) return $this->is_birth_sourced; |
|
| 169 | + if($this->is_birth_sourced !== null) { |
|
| 170 | + return $this->is_birth_sourced; |
|
| 171 | + } |
|
| 172 | 172 | $this->is_birth_sourced = $this->isFactSourced(WT_EVENTS_BIRT); |
| 173 | 173 | return $this->is_birth_sourced; |
| 174 | 174 | } |
@@ -179,7 +179,9 @@ discard block |
||
| 179 | 179 | * @return int Level of sources |
| 180 | 180 | * */ |
| 181 | 181 | public function isDeathSourced(){ |
| 182 | - if($this->is_death_sourced !== null) return $this->is_death_sourced; |
|
| 182 | + if($this->is_death_sourced !== null) { |
|
| 183 | + return $this->is_death_sourced; |
|
| 184 | + } |
|
| 183 | 185 | $this->is_death_sourced = $this->isFactSourced(WT_EVENTS_DEAT); |
| 184 | 186 | return $this->is_death_sourced; |
| 185 | 187 | } |
@@ -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 |
@@ -236,7 +236,9 @@ discard block |
||
| 236 | 236 | * @return bool |
| 237 | 237 | */ |
| 238 | 238 | public function save() { |
| 239 | - if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.'); |
|
| 239 | + if(!$this->provider) { |
|
| 240 | + throw new \Exception('The task has not been initialised with a provider.'); |
|
| 241 | + } |
|
| 240 | 242 | return $this->provider->updateTask($this); |
| 241 | 243 | } |
| 242 | 244 | |
@@ -246,8 +248,9 @@ discard block |
||
| 246 | 248 | */ |
| 247 | 249 | public function execute(){ |
| 248 | 250 | |
| 249 | - if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
| 250 | - $this->is_running = false; |
|
| 251 | + if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) { |
|
| 252 | + $this->is_running = false; |
|
| 253 | + } |
|
| 251 | 254 | |
| 252 | 255 | if(!$this->is_running){ //TODO put in place a time_out for running... |
| 253 | 256 | //TODO Log the executions in the logs |
@@ -261,7 +264,9 @@ discard block |
||
| 261 | 264 | $this->last_updated = new \DateTime(); |
| 262 | 265 | if($this->nb_occurrences > 0){ |
| 263 | 266 | $this->nb_occurrences--; |
| 264 | - if($this->nb_occurrences == 0) $this->is_enabled = false; |
|
| 267 | + if($this->nb_occurrences == 0) { |
|
| 268 | + $this->is_enabled = false; |
|
| 269 | + } |
|
| 265 | 270 | } |
| 266 | 271 | } |
| 267 | 272 | $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){ |
@@ -118,8 +118,7 @@ discard block |
||
| 118 | 118 | if(Functions::isValidPath($certfile, true)) { |
| 119 | 119 | return new Certificate($certfile, $tree, $provider); |
| 120 | 120 | } |
| 121 | - } |
|
| 122 | - catch (\Exception $ex) { |
|
| 121 | + } catch (\Exception $ex) { |
|
| 123 | 122 | Log::addErrorLog('Certificate module error : > '.$ex->getMessage().' < with data > '.$xref.' <'); |
| 124 | 123 | } |
| 125 | 124 | |
@@ -202,7 +201,9 @@ discard block |
||
| 202 | 201 | */ |
| 203 | 202 | public function getCity(){ |
| 204 | 203 | $chunks = explode('/', $this->getFilename(), 2); |
| 205 | - if(count($chunks) > 1) return $chunks[0]; |
|
| 204 | + if(count($chunks) > 1) { |
|
| 205 | + return $chunks[0]; |
|
| 206 | + } |
|
| 206 | 207 | return null; |
| 207 | 208 | } |
| 208 | 209 | |
@@ -246,8 +247,7 @@ discard block |
||
| 246 | 247 | |
| 247 | 248 | if($sid){ |
| 248 | 249 | $this->source = Source::getInstance($sid, $this->tree); |
| 249 | - } |
|
| 250 | - else{ |
|
| 250 | + } else{ |
|
| 251 | 251 | $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
| 252 | 252 | } |
| 253 | 253 | |
@@ -256,7 +256,9 @@ discard block |
||
| 256 | 256 | $repofact = $this->source->getFirstFact('REPO'); |
| 257 | 257 | if($repofact) { |
| 258 | 258 | $repo = $repofact->getTarget(); |
| 259 | - if($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
| 259 | + if($repo && $repo instanceof Repository) { |
|
| 260 | + $wmtext .= ' '.$repo->getFullName().' - '; |
|
| 261 | + } |
|
| 260 | 262 | } |
| 261 | 263 | $wmtext .= $this->source->getFullName(); |
| 262 | 264 | } |
@@ -426,7 +428,9 @@ discard block |
||
| 426 | 428 | } |
| 427 | 429 | } |
| 428 | 430 | |
| 429 | - if($sid) $this->source = Source::getInstance($sid, $this->tree); |
|
| 431 | + if($sid) { |
|
| 432 | + $this->source = Source::getInstance($sid, $this->tree); |
|
| 433 | + } |
|
| 430 | 434 | |
| 431 | 435 | return $this->source; |
| 432 | 436 | } |
@@ -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){ |
@@ -105,7 +105,9 @@ discard block |
||
| 105 | 105 | $sid=null; |
| 106 | 106 | |
| 107 | 107 | if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){ |
| 108 | - if (!$srec || strlen($srec) == 0) return $html; |
|
| 108 | + if (!$srec || strlen($srec) == 0) { |
|
| 109 | + return $html; |
|
| 110 | + } |
|
| 109 | 111 | |
| 110 | 112 | $certificate = null; |
| 111 | 113 | $subrecords = explode("\n", $srec); |
@@ -118,11 +120,14 @@ discard block |
||
| 118 | 120 | $level = substr($subrecords[$i], 0, 1); |
| 119 | 121 | $tag = substr($subrecords[$i], 2, 4); |
| 120 | 122 | $text = substr($subrecords[$i], 7); |
| 121 | - if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
| 123 | + if($tag == '_ACT') { |
|
| 124 | + $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
| 125 | + } |
|
| 122 | 126 | } |
| 123 | 127 | |
| 124 | - if($certificate && $certificate->canShow()) |
|
| 125 | - $html = $this->getDisplay_ACT($certificate, $sid); |
|
| 128 | + if($certificate && $certificate->canShow()) { |
|
| 129 | + $html = $this->getDisplay_ACT($certificate, $sid); |
|
| 130 | + } |
|
| 126 | 131 | |
| 127 | 132 | } |
| 128 | 133 | return $html; |
@@ -150,7 +155,9 @@ discard block |
||
| 150 | 155 | $html = ''; |
| 151 | 156 | switch($tag){ |
| 152 | 157 | case '_ACT': |
| 153 | - if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
| 158 | + if($context == 'SOUR') { |
|
| 159 | + $html = $this->getDisplay_ACT($value, $contextid); |
|
| 160 | + } |
|
| 154 | 161 | break; |
| 155 | 162 | } |
| 156 | 163 | return $html; |
@@ -180,7 +187,9 @@ discard block |
||
| 180 | 187 | $html .= '<select id="certifCity'.$element_id.'" class="_CITY">'; |
| 181 | 188 | foreach ($tabCities as $cities){ |
| 182 | 189 | $selectedCity=''; |
| 183 | - if($certificate && $cities== $certificate->getCity()) $selectedCity='selected="true"'; |
|
| 190 | + if($certificate && $cities== $certificate->getCity()) { |
|
| 191 | + $selectedCity='selected="true"'; |
|
| 192 | + } |
|
| 184 | 193 | $html .= '<option value="'.$cities.'" '.$selectedCity.' />'.$cities.'</option>'; |
| 185 | 194 | } |
| 186 | 195 | $html .= '</select>'; |
@@ -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; |
@@ -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,21 +84,25 @@ 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) |
|
| 88 | - self::$default_user = User::find(-1); |
|
| 87 | + if(self::$default_user === null) { |
|
| 88 | + self::$default_user = User::find(-1); |
|
| 89 | + } |
|
| 89 | 90 | |
| 90 | 91 | $this->tree = $tree; |
| 91 | 92 | $this->user = $user; |
| 92 | 93 | $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; |
|
| 94 | + if($this->user === null) { |
|
| 95 | + $this->user = Auth::user(); |
|
| 96 | + } |
|
| 97 | + if(strlen($this->user->getUserId()) == 0) { |
|
| 98 | + $this->user = self::$default_user; |
|
| 99 | + } |
|
| 95 | 100 | |
| 96 | 101 | // Check if the user, or the default user, has a root already setup; |
| 97 | 102 | if(!$this->getRootIndi()) { |
| 98 | 103 | if($this->user == self::$default_user) { // If the default user is not setup |
| 99 | 104 | $this->is_setup = false; |
| 100 | - } |
|
| 101 | - else { |
|
| 105 | + } else { |
|
| 102 | 106 | $this->user = self::$default_user; |
| 103 | 107 | $this->is_setup = $this->getRootIndi() === null; |
| 104 | 108 | } |
@@ -129,7 +133,9 @@ discard block |
||
| 129 | 133 | * Remove all Sosa entries related to the gedcom file and user |
| 130 | 134 | */ |
| 131 | 135 | public function deleteAll() { |
| 132 | - if(!$this->is_setup) return; |
|
| 136 | + if(!$this->is_setup) { |
|
| 137 | + return; |
|
| 138 | + } |
|
| 133 | 139 | Database::prepare( |
| 134 | 140 | 'DELETE FROM `##maj_sosa`'. |
| 135 | 141 | ' WHERE majs_gedcom_id= :tree_id and majs_user_id = :user_id ') |
@@ -145,7 +151,9 @@ discard block |
||
| 145 | 151 | * @param int $sosa |
| 146 | 152 | */ |
| 147 | 153 | public function deleteAncestors($sosa) { |
| 148 | - if(!$this->is_setup) return; |
|
| 154 | + if(!$this->is_setup) { |
|
| 155 | + return; |
|
| 156 | + } |
|
| 149 | 157 | $gen = Functions::getGeneration($sosa); |
| 150 | 158 | Database::prepare( |
| 151 | 159 | 'DELETE FROM `##maj_sosa`'. |
@@ -165,7 +173,9 @@ discard block |
||
| 165 | 173 | * @param array $sosa_records |
| 166 | 174 | */ |
| 167 | 175 | public function insertOrUpdate($sosa_records) { |
| 168 | - if(!$this->is_setup) return; |
|
| 176 | + if(!$this->is_setup) { |
|
| 177 | + return; |
|
| 178 | + } |
|
| 169 | 179 | |
| 170 | 180 | $treeid = $this->tree->getTreeId(); |
| 171 | 181 | $userid = $this->user->getUserId(); |
@@ -212,7 +222,9 @@ discard block |
||
| 212 | 222 | * @return array Array of sosa numbers |
| 213 | 223 | */ |
| 214 | 224 | public function getSosaNumbers(Individual $indi) { |
| 215 | - if(!$this->is_setup) return array(); |
|
| 225 | + if(!$this->is_setup) { |
|
| 226 | + return array(); |
|
| 227 | + } |
|
| 216 | 228 | return Database::prepare( |
| 217 | 229 | 'SELECT majs_sosa, majs_gen FROM `##maj_sosa`'. |
| 218 | 230 | ' WHERE majs_i_id=:indi_id AND majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -229,7 +241,9 @@ discard block |
||
| 229 | 241 | * @return number Last generation if found, 1 otherwise |
| 230 | 242 | */ |
| 231 | 243 | public function getLastGeneration() { |
| 232 | - if(!$this->is_setup) return; |
|
| 244 | + if(!$this->is_setup) { |
|
| 245 | + return; |
|
| 246 | + } |
|
| 233 | 247 | return Database::prepare( |
| 234 | 248 | 'SELECT MAX(majs_gen) FROM `##maj_sosa`'. |
| 235 | 249 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -250,7 +264,9 @@ discard block |
||
| 250 | 264 | * @return array Associative array of Sosa ancestors, with their generation, comma separated |
| 251 | 265 | */ |
| 252 | 266 | public function getAllSosaWithGenerations(){ |
| 253 | - if(!$this->is_setup) return array(); |
|
| 267 | + if(!$this->is_setup) { |
|
| 268 | + return array(); |
|
| 269 | + } |
|
| 254 | 270 | return Database::prepare( |
| 255 | 271 | 'SELECT majs_i_id AS indi,' . |
| 256 | 272 | ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations' . |
@@ -270,9 +286,12 @@ discard block |
||
| 270 | 286 | * @return array Array of Sosa individuals |
| 271 | 287 | */ |
| 272 | 288 | public function getSosaListAtGeneration($gen){ |
| 273 | - if(!$this->is_setup) return array(); |
|
| 274 | - if(!$this->sosa_list_by_gen) |
|
| 275 | - $this->sosa_list_by_gen = array(); |
|
| 289 | + if(!$this->is_setup) { |
|
| 290 | + return array(); |
|
| 291 | + } |
|
| 292 | + if(!$this->sosa_list_by_gen) { |
|
| 293 | + $this->sosa_list_by_gen = array(); |
|
| 294 | + } |
|
| 276 | 295 | |
| 277 | 296 | if($gen){ |
| 278 | 297 | if(!isset($this->sosa_list_by_gen[$gen])){ |
@@ -301,9 +320,12 @@ discard block |
||
| 301 | 320 | * @return array Array of Sosa families |
| 302 | 321 | */ |
| 303 | 322 | public function getFamilySosaListAtGeneration($gen){ |
| 304 | - if(!$this->is_setup) return array(); |
|
| 305 | - if(!$this->sosa_fam_list_by_gen) |
|
| 306 | - $this->sosa_fam_list_by_gen = array(); |
|
| 323 | + if(!$this->is_setup) { |
|
| 324 | + return array(); |
|
| 325 | + } |
|
| 326 | + if(!$this->sosa_fam_list_by_gen) { |
|
| 327 | + $this->sosa_fam_list_by_gen = array(); |
|
| 328 | + } |
|
| 307 | 329 | |
| 308 | 330 | if($gen){ |
| 309 | 331 | if(!isset($this->sosa_fam_list_by_gen[$gen])){ |
@@ -337,7 +359,9 @@ discard block |
||
| 337 | 359 | * @return array Array of Sosa individuals |
| 338 | 360 | */ |
| 339 | 361 | public function getMissingSosaListAtGeneration($gen){ |
| 340 | - if(!$this->is_setup) return array(); |
|
| 362 | + if(!$this->is_setup) { |
|
| 363 | + return array(); |
|
| 364 | + } |
|
| 341 | 365 | if($gen){ |
| 342 | 366 | return $this->sosa_list_by_gen[$gen] = Database::prepare( |
| 343 | 367 | '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'. |
@@ -375,7 +399,9 @@ discard block |
||
| 375 | 399 | * @return array Statistics array |
| 376 | 400 | */ |
| 377 | 401 | public function getStatisticsByGeneration() { |
| 378 | - if(!$this->is_setup) return array(); |
|
| 402 | + if(!$this->is_setup) { |
|
| 403 | + return array(); |
|
| 404 | + } |
|
| 379 | 405 | if(!$this->statistics_tab) { |
| 380 | 406 | $this->statistics_tab = array(); |
| 381 | 407 | if($maxGeneration = $this->getLastGeneration()) { |
@@ -401,7 +427,9 @@ discard block |
||
| 401 | 427 | * @return int |
| 402 | 428 | */ |
| 403 | 429 | public function getTotalIndividuals() { |
| 404 | - if(!$this->is_setup) return 0; |
|
| 430 | + if(!$this->is_setup) { |
|
| 431 | + return 0; |
|
| 432 | + } |
|
| 405 | 433 | return Database::prepare( |
| 406 | 434 | 'SELECT SQL_CACHE COUNT(*) FROM `##individuals`' . |
| 407 | 435 | ' WHERE i_file = :tree_id') |
@@ -415,7 +443,9 @@ discard block |
||
| 415 | 443 | * @return number Number of Sosas |
| 416 | 444 | */ |
| 417 | 445 | public function getSosaCount(){ |
| 418 | - if(!$this->is_setup) return 0; |
|
| 446 | + if(!$this->is_setup) { |
|
| 447 | + return 0; |
|
| 448 | + } |
|
| 419 | 449 | return Database::prepare( |
| 420 | 450 | 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
| 421 | 451 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
@@ -432,7 +462,9 @@ discard block |
||
| 432 | 462 | * @return number Number of Sosas in generation |
| 433 | 463 | */ |
| 434 | 464 | public function getSosaCountAtGeneration($gen){ |
| 435 | - if(!$this->is_setup) return 0; |
|
| 465 | + if(!$this->is_setup) { |
|
| 466 | + return 0; |
|
| 467 | + } |
|
| 436 | 468 | return Database::prepare( |
| 437 | 469 | 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
| 438 | 470 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
@@ -451,7 +483,9 @@ discard block |
||
| 451 | 483 | * @return number Total number of Sosas up to generation |
| 452 | 484 | */ |
| 453 | 485 | public function getSosaCountUpToGeneration($gen){ |
| 454 | - if(!$this->is_setup) return 0; |
|
| 486 | + if(!$this->is_setup) { |
|
| 487 | + return 0; |
|
| 488 | + } |
|
| 455 | 489 | return Database::prepare( |
| 456 | 490 | 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
| 457 | 491 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
@@ -469,7 +503,9 @@ discard block |
||
| 469 | 503 | * @return number Total number of distinct individual |
| 470 | 504 | */ |
| 471 | 505 | public function getDifferentSosaCount(){ |
| 472 | - if(!$this->is_setup) return 0; |
|
| 506 | + if(!$this->is_setup) { |
|
| 507 | + return 0; |
|
| 508 | + } |
|
| 473 | 509 | return Database::prepare( |
| 474 | 510 | 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
| 475 | 511 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
@@ -486,7 +522,9 @@ discard block |
||
| 486 | 522 | * @return number Number of distinct Sosa individuals up to generation |
| 487 | 523 | */ |
| 488 | 524 | public function getDifferentSosaCountUpToGeneration($gen){ |
| 489 | - if(!$this->is_setup) return 0; |
|
| 525 | + if(!$this->is_setup) { |
|
| 526 | + return 0; |
|
| 527 | + } |
|
| 490 | 528 | return Database::prepare( |
| 491 | 529 | 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
| 492 | 530 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
@@ -509,7 +547,9 @@ discard block |
||
| 509 | 547 | * @return array Birth statistics array |
| 510 | 548 | */ |
| 511 | 549 | public function getStatsBirthYearInGeneration($gen){ |
| 512 | - if(!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
| 550 | + if(!$this->is_setup) { |
|
| 551 | + return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
| 552 | + } |
|
| 513 | 553 | return Database::prepare( |
| 514 | 554 | 'SELECT MIN(majs_birth_year) AS first, AVG(majs_birth_year) AS avg, MAX(majs_birth_year) AS last'. |
| 515 | 555 | ' FROM `##maj_sosa`' . |
@@ -529,7 +569,9 @@ discard block |
||
| 529 | 569 | * @return number|NULL Mean generation time |
| 530 | 570 | */ |
| 531 | 571 | public function getMeanGenerationTime(){ |
| 532 | - if(!$this->is_setup) return; |
|
| 572 | + if(!$this->is_setup) { |
|
| 573 | + return; |
|
| 574 | + } |
|
| 533 | 575 | if(!$this->statistics_tab){ |
| 534 | 576 | $this->getStatisticsByGeneration(); |
| 535 | 577 | } |
@@ -575,7 +617,10 @@ discard block |
||
| 575 | 617 | * @return array |
| 576 | 618 | */ |
| 577 | 619 | public function getAncestorDispersionForGen($gen) { |
| 578 | - if(!$this->is_setup || $gen > 11) return array(); // Going further than 11 gen will be out of range in the query |
|
| 620 | + if(!$this->is_setup || $gen > 11) { |
|
| 621 | + return array(); |
|
| 622 | + } |
|
| 623 | + // Going further than 11 gen will be out of range in the query |
|
| 579 | 624 | return Database::prepare( |
| 580 | 625 | 'SELECT branches, count(i_id)'. |
| 581 | 626 | ' FROM ('. |