/includes/functions_mediadb.php

Description

Various functions used by the media DB interface

phpGedView: Genealogy Viewer Copyright (C) 2002 to 2005 Peter Dyson, John Finlay and Others

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

  • version: $Id: functions_mediadb.php 981 2007-03-21 13:24:38Z fisharebest $
Functions
add_db_link (line 172)

Adds a new link into the database.

Replace the gedrec for an existing link record.

void add_db_link (string $media, string $indi, string $gedrec, string $ged, [integer $order = -1])
  • string $media: The gid of the record to be updated in the form Mxxxx.
  • string $indi: The gid that this media is linked to Ixxx Fxxx ect.
  • string $gedrec: The gedcom record as a string without the gid.
  • string $ged: The gedcom file this action is to apply to.
  • integer $order: The order that this record should be displayed on the gid. If not supplied then the order is not replaced.
check_media_depth (line 1113)

Validate the media depth

When the user has a media depth greater than 0, all media needs to be checked against this to ensure the proper path is in place. This function takes a filename, split it in parts and then recreates it according to the chosen media depth

When the input file name is a URL, this routine does nothing. Only http:// URLs are supported.

  • return:

    A filename validated for the media depth

    NOTE: The "NOTRUNC" option is required so that media that were inserted into the database before $MEDIA_DIRECTORY_LEVELS was reduced will display properly. NOTE: The "QUIET" option is used during GEDCOM import, where we really don't need to know about every Media folder that's being created.

  • author: roland-d
string check_media_depth (string $filename, [string $truncate = "FRONT"], [string $noise = "VERBOSE"])
  • string $filename: The filename that needs to be checked for media depth
  • string $truncate: Controls which part of folder structure to truncate when number of folders exceeds $MEDIA_DIRECTORY_LEVELS "NOTRUNC": Don't truncate "BACK": Truncate at end, keeping front part "FRONT": Truncate at front, keeping back part
  • string $noise: Controls the amount of chatting done by this function "VERBOSE" Print messages "QUIET" Don't print messages
check_media_structure (line 450)

Sanity check for the media folder. We need to check if the media and the thumbs folder exist. If they don't exist we will try to create them otherwise we can't continue.

  • return: Specify whether we succeeded to create the media and thumbnail folder
boolean check_media_structure ()
cropImage (line 1888)
void cropImage ( $image,  $dest_image,  $left,  $top,  $right,  $bottom)
  • $image
  • $dest_image
  • $left
  • $top
  • $right
  • $bottom
exists_db_link (line 93)

Queries the existence of a link in the db.

boolean exists_db_link (string $media, string $indi,  $ged, string $gedrec)
  • string $media: The gid of the record to be removed in the form Mxxxx.
  • string $gedrec: The gedcom record as a string without the gid.
  • string $indi: The gid that this media is linked to Ixxx Fxxx ect.
  • $ged
filterMedia (line 890)

Determine whether the current Media item matches the filter criteria

  • return: false if the Media item doesn't match the filter criteria
bool filterMedia (array $media, string $filter, string $acceptExt)
  • array $media: An item from the Media list produced by get_medialist()
  • string $filter: The filter to be looked for within various elements of the $media array
  • string $acceptExt: "http" if links to external media should be considered too
findImageSize (line 1676)
void findImageSize ( $file)
  • $file
get_db_indi_mapping_list (line 299)

Get the list of links to media from the database for a person/family/source

Searches the media table of the database for media items that are associated with a person/family/source.

The medialist that is returned contains the following elements:

  • $mapping["ID"] Database id
  • $mapping["INDI"] the gid of this media item is linked to (Ixxxx, Fxxx etc)
  • $mapping["XREF"] the unique id of this media item in the table (Mxxxx)
  • $mapping["ORDER"] the order the media item should be injected into the gedcom file
  • $mapping["GEDFILE"] the gedcom file the media item should be added to
  • $mapping["NOTE"] gedcom record snippet
  • $mapping["CHECK"] boolean for calling routine use, false by default.

  • return: A media list array.
mixed get_db_indi_mapping_list (string $indi)
  • string $indi: The person/family/source item to find media links for
get_db_mapping_list (line 259)

Get the list of links to media from the database

Searches the media table of the database for media items that are associated with the currently active GEDCOM.

The medialist that is returned contains the following elements:

  • $mapping["ID"] Database id
  • $mapping["INDI"] the gid of this media item is linked to (Ixxxx, Fxxx etc)
  • $mapping["XREF"] the unique id of this media item in the table (Mxxxx)
  • $mapping["ORDER"] the order the media item should be injected into the gedcom file
  • $mapping["GEDFILE"] the gedcom file the media item should be added to
  • $mapping["NOTE"] gedcom record snippet

  • return: A media list array.
mixed get_db_mapping_list ()
get_db_media_list (line 219)

Get the list of media from the database

Searches the media table of the database for media items that are associated with the currently active GEDCOM.

The medialist that is returned contains the following elements:

  • $media["ID"] the unique id of this media item in the table (Mxxxx)
  • $media["GEDFILE"] the gedcom file the media item should be added to
  • $media["FILE"] the filename of the media item
  • $media["FORM"] the format of the item (ie JPG, PDF, etc)
  • $media["TITL"] a title for the item, used for list display
  • $media["NOTE"] gedcom record snippet

  • return: A media list array.
mixed get_db_media_list ()
get_medialist (line 517)

Get the list of media from the database

Searches the media table of the database for media items that are associated with the currently active GEDCOM.

The medialist that is returned contains the following elements:

  • $media["ID"] the unique id of this media item in the table (Mxxxx)
  • $media["XREF"] Another copy of the Media ID (not sure why there are two)
  • $media["GEDFILE"] the gedcom file the media item should be added to
  • $media["FILE"] the filename of the media item
  • $media["FORM"] the format of the item (ie JPG, PDF, etc)
  • $media["TITL"] a title for the item, used for list display
  • $media["GEDCOM"] gedcom record snippet
  • $media["LEVEL"] level number (normally zero)
  • $media["LINKED"] Flag for front end to indicate this is linked
  • $media["LINKS"] Array of gedcom ids that this is linked to
  • $media["CHANGE"] Indicates the type of change waiting admin approval

  • return: A media list array.
mixed get_medialist ([ $currentdir = false], [ $directory = ""], [ $linkonly = false], [boolean $random = false])
  • boolean $random: If $random is true then the function will return 5 random pictures.
  • $currentdir
  • $directory
  • $linkonly
get_media_folders (line 1293)

get the list of current folders in the media directory

array get_media_folders ()
get_media_id_from_file (line 1810)
void get_media_id_from_file ( $filename)
  • $filename
get_media_relations (line 1818)
void get_media_relations ( $mid)
  • $mid
get_media_relations_with_file_name (line 1846)
void get_media_relations_with_file_name ( $filename)
  • $filename
picture_clip (line 1863)
void picture_clip ( $person_id,  $image_id,  $filename,  $thumbDir)
  • $person_id
  • $image_id
  • $filename
  • $thumbDir
PrintMediaLinks (line 1697)

Print the list of persons, families, and sources that are mentioned in the "LINKS" array of the current item from the Media list.

This function is called from media.php, medialist.php, and random_media.php

void PrintMediaLinks ( $links, [ $size = "small"])
  • $links
  • $size
real_path (line 360)

Removes /./ /../ from the middle of any given path User function as the php variant will expand leading ./ to full path which is not required and could be security issue.

  • return: Cleaned up path.
string real_path (string $path)
  • string $path: Filepath to check.
remove_db_media (line 47)

Removes a media item from this gedcom.

Removes the main media record and any associated links to individuals.

void remove_db_media (string $media, string $ged)
  • string $media: The gid of the record to be removed in the form Mxxxx.
  • string $ged: The gedcom file this action is to apply to.
retrieve_media_object (line 1247)
void retrieve_media_object ( $gedrec,  $gid)
  • $gedrec
  • $gid
search_media_pids (line 962)

Search the database for individuals that match the query

uses a regular expression to search the gedcom records of all individuals and returns an array list of the matching individuals

  • return: array with all individuals that matched the query
  • author: roland-d
array search_media_pids (string $query, [boolean $allgeds = false], [ $ANDOR = "AND"])
  • string $query: a regular expression query to search for
  • boolean $allgeds: setting if all gedcoms should be searched, default is false
  • $ANDOR
set_media_path (line 414)

Construct the correct path for media files and thumbnails before moving them

  • return: Cleaned up path.
string set_media_path (string $filename, string $moveto, [boolean $thumb = false])
  • string $filename: Filename including complete path
  • string $moveto: Diretory where it should be moved to
  • boolean $thumb: Specify whether it should be the thumbnail directory
show_media_form (line 1342)

print a form for editing or adding media items

void show_media_form (string $pid, [string $action = "newentry"], [string $filename = ""], [string $linktoid = ""], [int $level = 1], [int $line = 0])
  • string $pid: the id of the media item to edit
  • string $action: the action to take after the form is posted
  • string $filename: allows you to provide a filename to go in the FILE tag for new media items
  • string $linktoid: the id of the person/family/source to link a new media item to
  • int $level: The level at which this media item should be added
  • int $line: The line number in the GEDCOM record where this media item belongs
textblock_to_note (line 329)

Converts a block of text into a gedcom NOTE record.

  • return: Gedcom NOTE record.
gedrec textblock_to_note (integer $level, string $txt)
  • integer $level: The indent number for the NOTE record.
  • string $txt: Block of text to convert.
thumbnail_file (line 1021)

Generates the thumbnail filename and path

The full file path is taken and turned into the location of the thumbnail file.

  • return: the location of the thumbnail
  • author: roland-d
string thumbnail_file (string $filename, [bool $generateThumb = true], [bool $overwrite = false])
  • string $filename: The full filename of the media item
  • bool $generateThumb: 'true' when thumbnail should be generated, 'false' when only the file name should be returned
  • bool $overwrite: 'true' to replace existing thumbnail
unlink_db_item (line 75)

Removes a media item from a individual.

Removes this link to an individual from the database. All records attached to this link are lost also.

void unlink_db_item (string $media, string $indi, string $ged)
  • string $media: The gid of the record to be removed in the form Mxxxx.
  • string $indi: The gid that this media is linked to Ixxx Fxxx ect.
  • string $ged: The gedcom file this action is to apply to.
update_db_link (line 137)

Updates any gedcom records associated with the link.

Replace the gedrec for an existing link record.

void update_db_link (string $media, string $indi, string $gedrec, string $ged, [integer $order = -1])
  • string $media: The gid of the record to be updated in the form Mxxxx.
  • string $indi: The gid that this media is linked to Ixxx Fxxx ect.
  • string $gedrec: The gedcom record as a string without the gid.
  • string $ged: The gedcom file this action is to apply to.
  • integer $order: The order that this record should be displayed on the gid. If not supplied then the order is not replaced.
update_db_media (line 115)

Updates any gedcom records associated with the media.

Replace the gedrec for the media record.

void update_db_media (string $media, string $gedrec, string $ged)
  • string $media: The gid of the record to be removed in the form Mxxxx.
  • string $gedrec: The gedcom record as a string without the gid.
  • string $ged: The gedcom file this action is to apply to.

Documentation generated on Wed, 28 Mar 2007 09:54:18 -0600 by phpDocumentor 1.3.1