Menu

help me import media obje into .ged file

Help
2003-12-21
2004-01-07
  • Gabriel Ruggieri

    I use Family Tree Maker and it does not store the multimedia objects in the .ged file when you export so every time I upload a new file I have to replace the obje values by hand. I am just starting to code simple things in php and I need a little help or maybe a lot of help. I created this table that I have stored all the necessary values I need to tie into the .ged file. I want a module that will cycle through this table and add the needed lines to the .ged file when I run it. I really wish that phpgedview ran off a tale for these values then I would not have to re import the ged file to see the pictures.  All in ALL PHPGEDVIEW is the best thing to happen to my genealogy research, it has allowed me to share it with family and not the world.
        TIA, Gabriel

    CREATE TABLE pgv_media (
      p_indi      varchar(15)  NOT NULL,
      p_indiname  varchar(30)  NOT NULL,
      p_name      varchar(30)  NOT NULL,
      p_ext       char(3)      NOT NULL,
      p_ind       char(1)      NOT NULL,
      p_titl      varchar(255) NULL,
      p_order     int(11)      NOT NULL,
      p_file      varchar(255) NOT NULL,
      PRIMARY KEY  (pindi , pname, pfile)
    ) TYPE=MyISAM;

    INSERT INTO pgv_media VALUES ('I0001', 'Doe, John', 'I0001_0000.jpg', 'jpg', 'Y', 'Head Shot', 0, 'doe.ged');
    INSERT INTO pgv_media VALUES ('I0001', 'Doe, John', 'I0001_0001.jpg', 'jpg', 'Y', 'Family Portrait', 1, 'doe.ged');
    INSERT INTO pgv_media VALUES ('I0002', 'Doe, Mary', 'I0002_0000.jpg', 'jpg', 'Y', 'Head Shot', 0, 'doe.ged');

    //-- get the medialist
    function get_media_list() {
    global $medialist, $GEDCOM;
    global $TBLPREFIX;

    $medialist = array();

    $sql = "SELECT * FROM ".$TBLPREFIX."media WHERE p_file='$GEDCOM'";
    $res = dbquery($sql);
    $ct = mysql_num_rows($res);
    while($row=mysql_fetch_array($res)){
      $media = array();
      $media["GEDFILE"] = $row["p_file"];
      $media["INDI"]    = $row["p_indi"];
      $media["FILE"]    = $row["p_name"];
      $media["FORM"]    = $row["p_ext"];
      $media["_PRIM"]   = $row["p_ind"];
      $media["TITL"]    = $row["p_titl"];
    }
    return $medialist;
    }

    add_obje.php
        $tmedlist = array();
        $tmedlist = get_media_list();
         uasort($tmedlist, "itemsort");
       

    1) Add everything to the .ged file using the pgv_media table as the driver, if the value is not in the .ged add it, or even simpler just add it.
    2) I did not add a value for the location "C:\MY ...." because I do not see that it is used anywhere for phpgedview.

    :Loop
    A) Find last line for Individual
    B) Insert these rows
      "1 OBJE"
      "2 FORM ".$tmedlist["FORM"]
      "2 FILE ".$tmedlist["FILE"]
      "2 TITL ".$tmedlist["TITL"]
      "2 _PRIM ".$tmedlist["_PRIM"]
      "2 _TYPE PHOTO"

     
    • tales

      tales - 2003-12-22

      This is one reason I switched to Legacy. It was a lot easier to move the gedcom to the new program than to try to edit gedcom files. I am much happier with its versatility. Have you considered that kind of option?

       
    • John Finlay

      John Finlay - 2003-12-22

      It looks like you have made a pretty good solution here.  I might be able to save you some trouble adding the OBJE records to the GEDCOM by using the GDBI functions.

      In the next beta release I am going to add a tools directory that contains PHP scripts of this nature to help people run conversions or other processes on their gedcoms before they are imported.

      --John

       
    • John Finlay

      John Finlay - 2003-12-22

      I've added all of the tools that I have done so far to a GEDCOM tools patch in the patches section here
      http://sourceforge.net/tracker/index.php?func=detail&aid=864554&group_id=55456&atid=477081

      This package includes an addmedia file that will add the media to the file.

      --John

       
      • Gabriel Ruggieri

        John,
        First thanks for helping, I took what you had posted and tried it but it is giving me an error. First error was on the table. I just had to change the values on the index fields to match the field names on the table.

        Does it matter that my .ged file is not in the index directory? I did the deal where you ../doe.ged so that people can not copy it.

        The next error it is giving me that I have not been able to figure out is this.
        Warning: main(./index/ruggieri.ged_conf.php): failed to open stream: No such file or directory in /hsphere/local/home/??????/???????.us/phpGedView/session.php on line 143

        Fatal error: main(): Failed opening required './index/ruggieri.ged_conf.php' (include_path='.:/usr/local/lib/php') in /hsphere/local/home/??????/???????.us/phpGedView/session.php on line 143

        Any suggestions?
           TIA, Gabriel

         
    • John Finlay

      John Finlay - 2003-12-23

      You have to add your gedcom file to the configuration before it will work.

      So, you would follow these steps:
      1. Make sure write permissions are set on the index directory
      2. go to Admin page
      3. go to Manage Gedcoms
      4. Click "Add New Gedcom"
      5. Enter the path to you gedcom file and set the configuration values
      6. Save the configuration
      7. point your browser to tools/addmedia.php
      8. go to Admin->Manage Gedcoms->Import to import the gedcom file.

      --John

       
    • Gabriel Ruggieri

      John,
      My .ged file is already there and I can run it normally just fine. Just in case I went ahead and deleted then reloaded everything and started from scratch. It was still not working, so I tried eliminating each peice until it would work. It seems to be having a problem with ../config.php. I moved the addmedia.php to the phpgedview directory and it did run. Unfourtanatley it still did not do an update. I am running the beta 2.65b3 . I did find a couple of errors with the sql and fixed those. I believe that ../config should work

      .I am lost of what to try next .

           TIA, Gabriel

       
    • John Finlay

      John Finlay - 2003-12-24

      The addmedia.php file should be located in a "tools" subdirectory which would have required the ../config.php and the ../gdbi_functions.php.

      If you placed it in the main phpgedview directory then you would need to change the ../config.php to just config.php and the ../gdbi_functions.php to just gdbi_functions.php.

      I'll take a look at it and see what is wrong.

      --John

       
    • Gabriel Ruggieri

      John,
      I had taken the ../ off of the the modules when I moved addmedia.php to phpgedview, it says that it worked but I looked at the file and no change had occured. I still do not understand why it will not run from the original directy. I put it back into the tools directy where it belongs and it still kicks out with these errors.

      Warning: main(./index/ruggieri.ged_conf.php): failed to open stream: No such file or directory in /hsphere/local/home/pegasusb/ruggieri.us/phpGedView/session.php on line 143

      Fatal error: main(): Failed opening required './index/ruggieri.ged_conf.php' (include_path='.:/usr/local/lib/php') in /hsphere/local/home/pegasusb/ruggieri.us/phpGedView/session.php on line 143

      I went and looked at line 143 and it is
           require(get_config_file());

      My site works so I know my config file is there plus I have tried it both being singed on and off to my website.
           Gabriel

       
    • Gabriel Ruggieri

      John,
      I finally got sometime and with a little tweaking I got the code to work, thanks for your help.
          Gabriel

       
    • John Finlay

      John Finlay - 2004-01-07

      I've updated the "GEDCOM Tools" patch with a working version.  It turns out that the files will not work from inside a tools directory.  They need to be placed in the mail phpgedview directory.

      You can download the latest tools here:
      http://sourceforge.net/tracker/index.php?func=detail&aid=864554&group_id=55456&atid=477081

      --John

       

Log in to post a comment.