Web based family history software

file Question getAllBirthPlaces and getAllDeathPlaces return only first one.

  • elysch
  • elysch's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 months 2 weeks ago #1 by elysch
Hello.

I found this function in app/Individual.php. AFAICT, this only returns the first place, because of the return inside the foreach.
Code:
    /**      * Get all the death places - for the individual lists.      *      * @return array      */     public function getAllDeathPlaces(): array     {         foreach (Gedcom::DEATH_EVENTS as $event) {             $places = $this->getAllEventPlaces([$event]);             if ($places !== []) {                 return $places;             }         }         return [];     }

I propose this instead:
Code:
    /**      * Get all the death places - for the individual lists.      *      * @return array<Place>      */     public function getAllDeathPlaces(): array     {         $found = false;         $placesList = [];         foreach (Gedcom::DEATH_EVENTS as $event) {             $places = $this->getAllEventPlaces([$event]);             if ($places !== []) {                 $placesList = array_merge($placesList, $places);                 $found = true;             }         }         if ($found) {             return $placesList;         } else {             return [];         }     }

I wanted to add all the death places in a list, that's why I discovered it.

Ely

 

Please Log in or Create an account to join the conversation.

  • elysch
  • elysch's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 months 2 weeks ago - 7 months 2 weeks ago #2 by elysch
Found the same is happening with:
getAllBirthDates
getAllBirthPlaces
getAllDeathDates
getAllDeathPlaces

And these need changes to return the first one only:
getBirthDate
getBirthPlace
getDeathDate
getDeathPlace

Maybe these need to be changed too
getEstimatedBirthDate
getEstimatedDeathDate
Last edit: 7 months 2 weeks ago by elysch.

Please Log in or Create an account to join the conversation.

More
7 months 2 weeks ago #3 by fisharebest
> AFAICT, this only returns the first place

It returns *all* the BIRT places (if there are any).

If none are found, it returns all the CHR places (if there are any)

If none are found, it returns all the BAPM places (if there are any)

In other words, if we only have CHR/BAPM, then these are used as a fallback.

Similar for death. If we don't have any death places, we look for burial/cremation places.

Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

  • elysch
  • elysch's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 months 2 weeks ago - 7 months 2 weeks ago #4 by elysch
If there is more than one place, I recommend to make some changes in "./resources/views/lists/individuals-table.phtml", to display all places in an orderly manner.

The change would be from:
Code:
                    <!-- Death place -->                     <td data-sort="<?= e($individual->getDeathPlace()->gedcomName()) ?>">                         <?php foreach ($individual->getAllDeathPlaces() as $death_place) : ?>                             <div><?= $death_place->shortName(true) ?></div>                         <?php endforeach ?>                     </td>


to

Code:
                    <!-- Death place -->                     <td data-sort="<?= e($individual->getDeathPlace()->gedcomName()) ?>">                         <?php $more_than_one=false; ?>                         <?php foreach ($individual->getAllDeathPlaces() as $death_place) : ?>                             <div><?php if ($more_than_one) {echo "</br>";} ?><?= $death_place->shortName(true) ?></div>                             <?php $more_than_one=true; ?>                         <?php endforeach ?>                     </td>

 
Last edit: 7 months 2 weeks ago by elysch.

Please Log in or Create an account to join the conversation.

  • elysch
  • elysch's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 months 2 weeks ago #5 by elysch

> AFAICT, this only returns the first place

It returns *all* the BIRT places (if there are any).

If none are found, it returns all the CHR places (if there are any)

If none are found, it returns all the BAPM places (if there are any)

In other words, if we only have CHR/BAPM, then these are used as a fallback.

Similar for death. If we don't have any death places, we look for burial/cremation places.


Oh... I see... you're right.

I was looking for another function, then.
One that returns DEAT + BURI + CREM  ... I understand now. 

How would you call this new function?

Please Log in or Create an account to join the conversation.

More
7 months 2 weeks ago - 7 months 2 weeks ago #6 by fisharebest
> I was looking for another function, then.
> One that returns DEAT + BURI + CREM ... I understand now.
> How would you call this new function?
Code:
$individual->getAllEventPlaces(['DEAT','BURI','CREM'])

Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Last edit: 7 months 2 weeks ago by fisharebest.

Please Log in or Create an account to join the conversation.

  • elysch
  • elysch's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 months 2 weeks ago #7 by elysch
Code:
$individual->getAllEventPlaces(['DEAT','BURI','CREM'])

You're right. Feel kind of fool, hahaha

Sorry.

Well... I think are needed anyway the changes in ./resources/views/lists/individuals-table.phtml to add a </br>'s
:)
 

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum