Search Forums
Forums
Kiwitrees on Twitter
    Tags

    Default record, googlemap. modified, responsive menus, immigration, block, name, progress, design, fancy image bar, 3.1.1, errors, repo, 2.0, sanity checker, roadmap, Advanced search, 3.0.0. setup, help, gender change, sanity, 3.2.3, php 5.6, follow, styles, MYSQL, GEDCOM, lists, Google Maps, cookie, menus, click, pdf, json, access roles, admin, contacts, Extra menus, configure, places, family facts, Export/Import, CREM, sidebar, datatables, simpl_grey, default individual, mystyle, image, editor, ID notes, merge, IE problem, burial, place, inactive, clipboard, blank screem, latest version, margin, timeout

    Tagged: 

    Topic:   How to be sure that BIRT / TIME / PLAC events anot empty before displaying a Tab  

    This topic contains 7 replies, has 3 voices, and was last updated by  pfelix 1 week, 2 days ago.

    Viewing 8 posts - 1 through 8 (of 8 total)
    • Author
      Posts
    • #10214

      PierreF
      Participant

      8 posts

      Hi have a new question
      I’ve created a new Tab module for displaying personal info.

      But before displaying the data in that Tab, I would like to verifiy some events such as :

        The Birth Date (BIRT) is not empty
        The Birth Time (TIME ?) is not empty
        The Birth Place (PLAC ?) is not empty too, with LAT & LONG data filled

      Otherwise, I display a special message in ordrer to add theses infos !

      Could you help me do it properly ….. I’me not sure to be able to do that !!
      Thanks for your help !

      #10216
      kiwi
      kiwi
      Keymaster

      1643 posts

      Do really just want to check for “empty”, or also for “invalid”, or for ‘null’? These are all different states.

      The normal check uses the function “isOK()”. Used throughout the system (for dates), a good place to look for examples would be in “includes\functions\functions_print.php”. Just do a search for that function in there to see many examples.
      You could also look in the same file for examples of the function “canShow()”. This checks that facts/events can be displayed in the context of this viewer without breaking all or any privacy rule settings. Privacy can be relevant to a fact/event level, record, (indi, fam, etc), family tree or even site levels.

      There is no built-in function like it for TIME. In fact, it’s use is not encouraged, as it was removed completely as a valid tag, from GEDCOM ver 5.5.1, which is the version kiwitrees tries to follow. So to be strictly correct you should not use it or expect it to exist. Of course, you still can, and many people do, but it has never been given any validation checking.

      With PLAC it is much more complex. PHP isset() or empty() or is_null()would be a start. But you mention “with LAT & LONG data-filled“. That a whole larger issue. You need to check the PLAC tag, and then separately check if a matching place, with coordinates, exists in the Google Map module table (##placelocations), AND that the GM module exists and is currently active for this user. Check the code in the Google Maps module for methods around this topic, perhaps especially in the sections module.php related to the “place-check” function.
      But you might also want to check LAT/Long tags in the GEDCOM data, as these can be entered without the use of the GM module.

      Nigel
      My personal kiwitrees site is www.our-families.info
      #10217
      kiwi
      kiwi
      Keymaster

      1643 posts

      Just another thought regarding what you are doing. As mentioned, privacy checks are an important issue. The complications of code and the additional resource needed to calculate the results are the reason I generally keep such checks out of the “public” or “member” areas such as indi page, it’s tabs, sidebar etc.

      Instead, kiwitrees has a suite of “check” tools in the admin area to help with bulk checking for such issues (and many many more). These have the huge advantage that the viewers’ credentials have already been checked. You must be an administrator to see them, so no further privacy checks are required. I’m referring to the various tools in Administration > Family Tree Tools, such as “Sanity checks”, “Missing data” and others. As a newcomer to kiwitrees, you might not be aware they exist.

      Nigel
      My personal kiwitrees site is www.our-families.info
      #10218

      pfelix
      Participant

      4 posts

      Hi and thanks for your response.
      I’ll look to all your infos.
      But one last technical question :

      Ho can I display directly to the KT_Event Object data as shown below with a print_r($fact) of the getFacts() controler ?

      KT_Event Object
      (
      [lineNumber] => 6
      [tag] => BIRT
      [date] => KT_Date Object
      (
      [qual1] =>
      [date1] => KT_Date_Gregorian Object
      (
      [y] => 1967
      [m] => 1
      [d] => 8
      [minJD] => 2439499
      [maxJD] => 2439499
      )
      )
      [place] =>
      [gedcomRecord] => 1 BIRT
      2 DATE 08 JAN 1947
      3 TIME 11:05
      2 NOTE Pierre Birth at 11h
      2 PLAC Paris
      3 MAP
      4 LATI N43.602387
      4 LONG E1.442884

      [/left]

      I can easily acces to the date with such code :

        $date_event_BIRT = $fact->getDate();
        $date_eventY_BIRT = $date_event_BIRT->date1->y;

      But How can I print :
      PLAC
      LATI
      LONG
      ?
      I’m not a real php dev …. just someone who tries to understand code !!!
      Thanks for your help

      #10219
      kiwi
      kiwi
      Keymaster

      1643 posts

      You need to study the methods used in the file “includes\functions\functions_print_facts.php

      Nigel
      My personal kiwitrees site is www.our-families.info
      #10220

      pfelix
      Participant

      4 posts

      Hi Nigel,
      May be you can help me on that point :
      I had a look on functions_print_facts.php and I tried do do that (see below) wich works on Webtrees

      foreach ($controller->record->getFacts() as $fact) {
      if($fact->getTag() == ‘BIRT’) {
      preg_match_all(‘/\n4 (LATI) (.+)/’, $fact->getGedcom(), $match, PREG_SET_ORDER);
      foreach ($matches as $match) {
      if (preg_match(‘/\n4 LATI (.+)/’, $fact->getGedcomRecord())) {
      $Birth_Lat = $match[2];

      echo $match[2];*/
      }
      }

      }
      }

      On Kiwitrees, I obtain an error :
      ERROR 8: Undefined variable: matches

      I tried to change with that line : preg_match_all(‘/\n4 LATI (.+)/’, $fact->getGedcomRecord(), $match, PREG_SET_ORDER);
      But no succes.
      Do you have an idea on what part of code I’ve to change ?
      Thanks for your help

      #10221
      kiwi
      kiwi
      Keymaster

      1643 posts

      wich works on Webtrees

      First, I must repeat what I have said before. Do NOT expect webtrees code to work in kiwitrees. There are similarities, but they are NOT the same. Some code might work, much will not.Every day the differences grow larger and larger. Decide which you are going to use and stick to it. Asking identical questions on both forums just wastes two busy developers time rather than one!

      As for your error – that answer is in the error message quite clearly. It says:

      Undefined variable: matches

      In your preg_match_all you refer to $match.
      In your loop you refer to foreach ($matches…….

      Nigel
      My personal kiwitrees site is www.our-families.info
      #10222

      pfelix
      Participant

      4 posts

      Hi Nigel,
      I speak about Webtrees because I’m moving my old webtrees app to Kiwitrees that seems more powerfull for me.

      I try to make my app work on Kiwitrees as it still works on old webtrees version.

      But don’t be afraid, I won’t disturbe you a lot anymore !
      Thanks for your help !

    Viewing 8 posts - 1 through 8 (of 8 total)

    You must be logged in to reply to this topic.