コード例 #1
0
 function init()
 {
     global $PRIV_HIDE, $PRIV_PUBLIC, $ENABLE_CLIPPINGS_CART, $SCRIPT_NAME, $pgv_lang, $SERVER_URL, $CONTACT_EMAIL, $HOME_SITE_TEXT, $HOME_SITE_URL, $MEDIA_DIRECTORY;
     global $GEDCOM, $CHARACTER_SET, $cart;
     if (!isset($ENABLE_CLIPPINGS_CART)) {
         $ENABLE_CLIPPINGS_CART = $PRIV_HIDE;
     }
     if ($ENABLE_CLIPPINGS_CART === true) {
         $ENABLE_CLIPPING_CART = $PRIV_PUBLIC;
     }
     if ($ENABLE_CLIPPINGS_CART < PGV_USER_ACCESS_LEVEL) {
         header("Location: index.php");
         exit;
     }
     if (!isset($_SESSION['exportConvPath'])) {
         $_SESSION['exportConvPath'] = $MEDIA_DIRECTORY;
     }
     if (!isset($_SESSION['exportConvSlashes'])) {
         $_SESSION['exportConvSlashes'] = 'forward';
     }
     $this->action = safe_GET("action");
     $this->id = safe_GET('id');
     $remove = safe_GET('remove', "", "no");
     $convert = safe_GET('convert', "", "no");
     $this->Zip = safe_GET('Zip');
     $this->IncludeMedia = safe_GET('IncludeMedia');
     $this->conv_path = safe_GET('conv_path', PGV_REGEX_NOSCRIPT, $_SESSION['exportConvPath']);
     $this->conv_slashes = safe_GET('conv_slashes', array('forward', 'backward'), $_SESSION['exportConvSlashes']);
     $this->privatize_export = safe_GET('privatize_export', array('none', 'visitor', 'user', 'gedadmin', 'admin'));
     $this->filetype = safe_GET('filetype');
     $this->level1 = safe_GET('level1');
     $this->level2 = safe_GET('level2');
     $this->level3 = safe_GET('level3');
     if (empty($this->filetype)) {
         $this->filetype = "gedcom";
     }
     $others = safe_GET('others');
     $item = safe_GET('item');
     if (!isset($cart)) {
         $cart = $_SESSION['cart'];
     }
     $this->type = safe_GET('type');
     $this->conv_path = stripLRMRLM($this->conv_path);
     $_SESSION['exportConvPath'] = $this->conv_path;
     // remember this for the next Download
     $_SESSION['exportConvSlashes'] = $this->conv_slashes;
     if ($this->action == 'add') {
         if (empty($this->type) && !empty($this->id)) {
             $this->type = "";
             $obj = GedcomRecord::getInstance($this->id);
             if (is_null($obj)) {
                 $this->id = "";
                 $this->action = "";
             } else {
                 $this->type = strtolower($obj->getType());
             }
         } else {
             if (empty($this->id)) {
                 $this->action = "";
             }
         }
         if (!empty($this->id) && $this->type != 'fam' && $this->type != 'indi' && $this->type != 'sour') {
             $this->action = 'add1';
         }
     }
     if ($this->action == 'add1') {
         $clipping = array();
         $clipping['type'] = $this->type;
         $clipping['id'] = $this->id;
         $clipping['gedcom'] = $GEDCOM;
         $ret = $this->add_clipping($clipping);
         if ($ret) {
             if ($this->type == 'sour') {
                 if ($others == 'linked') {
                     foreach (fetch_linked_indi($this->id, 'SOUR', PGV_GED_ID) as $indi) {
                         if ($indi->canDisplayName()) {
                             $this->add_clipping(array('type' => 'indi', 'id' => $indi->getXref()));
                         }
                     }
                     foreach (fetch_linked_fam($this->id, 'SOUR', PGV_GED_ID) as $fam) {
                         if ($fam->canDisplayName()) {
                             $this->add_clipping(array('type' => 'fam', 'id' => $fam->getXref()));
                         }
                     }
                 }
             }
             if ($this->type == 'fam') {
                 if ($others == 'parents') {
                     $parents = find_parents($this->id);
                     if (!empty($parents["HUSB"])) {
                         $clipping = array();
                         $clipping['type'] = "indi";
                         $clipping['id'] = $parents["HUSB"];
                         $ret = $this->add_clipping($clipping);
                     }
                     if (!empty($parents["WIFE"])) {
                         $clipping = array();
                         $clipping['type'] = "indi";
                         $clipping['id'] = $parents["WIFE"];
                         $ret = $this->add_clipping($clipping);
                     }
                 } else {
                     if ($others == "members") {
                         $this->add_family_members($this->id);
                     } else {
                         if ($others == "descendants") {
                             $this->add_family_descendancy($this->id);
                         }
                     }
                 }
             } else {
                 if ($this->type == 'indi') {
                     if ($others == 'parents') {
                         $famids = find_family_ids($this->id);
                         foreach ($famids as $indexval => $famid) {
                             $clipping = array();
                             $clipping['type'] = "fam";
                             $clipping['id'] = $famid;
                             $ret = $this->add_clipping($clipping);
                             if ($ret) {
                                 $this->add_family_members($famid);
                             }
                         }
                     } else {
                         if ($others == 'ancestors') {
                             $this->add_ancestors_to_cart($this->id, $this->level1);
                         } else {
                             if ($others == 'ancestorsfamilies') {
                                 $this->add_ancestors_to_cart_families($this->id, $this->level2);
                             } else {
                                 if ($others == 'members') {
                                     $famids = find_sfamily_ids($this->id);
                                     foreach ($famids as $indexval => $famid) {
                                         $clipping = array();
                                         $clipping['type'] = "fam";
                                         $clipping['id'] = $famid;
                                         $ret = $this->add_clipping($clipping);
                                         if ($ret) {
                                             $this->add_family_members($famid);
                                         }
                                     }
                                 } else {
                                     if ($others == 'descendants') {
                                         $famids = find_sfamily_ids($this->id);
                                         foreach ($famids as $indexval => $famid) {
                                             $clipping = array();
                                             $clipping['type'] = "fam";
                                             $clipping['id'] = $famid;
                                             $ret = $this->add_clipping($clipping);
                                             if ($ret) {
                                                 $this->add_family_descendancy($famid, $this->level3);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         if ($this->action == 'remove') {
             $ct = count($cart);
             for ($i = $item + 1; $i < $ct; $i++) {
                 $cart[$i - 1] = $cart[$i];
             }
             unset($cart[$ct - 1]);
         } else {
             if ($this->action == 'empty') {
                 $cart = array();
                 $_SESSION["cart"] = $cart;
             } else {
                 if ($this->action == 'download') {
                     usort($cart, "same_group");
                     if ($this->filetype == "gedcom") {
                         $path = substr($SCRIPT_NAME, 0, strrpos($SCRIPT_NAME, "/"));
                         if (empty($path)) {
                             $path = "/";
                         }
                         if ($path[strlen($path) - 1] != "/") {
                             $path .= "/";
                         }
                         if ($SERVER_URL[strlen($SERVER_URL) - 1] == "/") {
                             $dSERVER_URL = substr($SERVER_URL, 0, strlen($SERVER_URL) - 1);
                         } else {
                             $dSERVER_URL = $SERVER_URL;
                         }
                         $media = array();
                         $mediacount = 0;
                         $ct = count($cart);
                         $filetext = "0 HEAD\n1 SOUR " . PGV_PHPGEDVIEW . "\n2 NAME " . PGV_PHPGEDVIEW . "\n2 VERS " . PGV_VERSION_TEXT . "\n1 DEST DISKETTE\n1 DATE " . date("j M Y") . "\n2 TIME " . date("H:i:s") . "\n";
                         $filetext .= "1 GEDC\n2 VERS 5.5\n2 FORM LINEAGE-LINKED\n1 CHAR {$CHARACTER_SET}\n";
                         $head = find_gedcom_record("HEAD");
                         $placeform = trim(get_sub_record(1, "1 PLAC", $head));
                         if (!empty($placeform)) {
                             $filetext .= $placeform . "\n";
                         } else {
                             $filetext .= "1 PLAC\n2 FORM " . "City, County, State/Province, Country" . "\n";
                         }
                         if ($convert == "yes") {
                             $filetext = preg_replace("/UTF-8/", "ANSI", $filetext);
                             $filetext = utf8_decode($filetext);
                         }
                         $tempUserID = '#ExPoRt#';
                         if ($this->privatize_export != 'none') {
                             // Create a temporary userid
                             $export_user_id = createTempUser($tempUserID, $this->privatize_export, $GEDCOM);
                             // Create a temporary userid
                             // Temporarily become this user
                             $_SESSION["org_user"] = $_SESSION["pgv_user"];
                             $_SESSION["pgv_user"] = $tempUserID;
                         }
                         for ($i = 0; $i < $ct; $i++) {
                             $clipping = $cart[$i];
                             if ($clipping['gedcom'] == $GEDCOM) {
                                 $record = find_gedcom_record($clipping['id']);
                                 $savedRecord = $record;
                                 // Save this for the "does this file exist" check
                                 if ($clipping['type'] == 'obje') {
                                     $record = convert_media_path($record, $this->conv_path, $this->conv_slashes);
                                 }
                                 $record = privatize_gedcom($record);
                                 $record = remove_custom_tags($record, $remove);
                                 if ($convert == "yes") {
                                     $record = utf8_decode($record);
                                 }
                                 switch ($clipping['type']) {
                                     case 'indi':
                                         $ft = preg_match_all("/1 FAMC @(.*)@/", $record, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             if (!id_in_cart($match[$k][1])) {
                                                 $record = preg_replace("/1 FAMC @" . $match[$k][1] . "@.*/", "", $record);
                                             }
                                         }
                                         $ft = preg_match_all("/1 FAMS @(.*)@/", $record, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             if (!id_in_cart($match[$k][1])) {
                                                 $record = preg_replace("/1 FAMS @" . $match[$k][1] . "@.*/", "", $record);
                                             }
                                         }
                                         $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1]));
                                             if (file_exists($filename)) {
                                                 $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename);
                                                 $mediacount++;
                                             }
                                             //								$record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record);
                                         }
                                         $filetext .= trim($record) . "\n";
                                         $filetext .= "1 SOUR @SPGV1@\n";
                                         $filetext .= "2 PAGE " . $dSERVER_URL . "/individual.php?pid=" . $clipping['id'] . "\n";
                                         $filetext .= "2 DATA\n";
                                         $filetext .= "3 TEXT " . $pgv_lang["indi_downloaded_from"] . "\n";
                                         $filetext .= "4 CONT " . $dSERVER_URL . "/individual.php?pid=" . $clipping['id'] . "\n";
                                         break;
                                     case 'fam':
                                         $ft = preg_match_all("/1 CHIL @(.*)@/", $record, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             if (!id_in_cart($match[$k][1])) {
                                                 /* if the child is not in the list delete the record of it */
                                                 $record = preg_replace("/1 CHIL @" . $match[$k][1] . "@.*/", "", $record);
                                             }
                                         }
                                         $ft = preg_match_all("/1 HUSB @(.*)@/", $record, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             if (!id_in_cart($match[$k][1])) {
                                                 /* if the husband is not in the list delete the record of him */
                                                 $record = preg_replace("/1 HUSB @" . $match[$k][1] . "@.*/", "", $record);
                                             }
                                         }
                                         $ft = preg_match_all("/1 WIFE @(.*)@/", $record, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             if (!id_in_cart($match[$k][1])) {
                                                 /* if the wife is not in the list delete the record of her */
                                                 $record = preg_replace("/1 WIFE @" . $match[$k][1] . "@.*/", "", $record);
                                             }
                                         }
                                         $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1]));
                                             if (file_exists($filename)) {
                                                 $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename);
                                                 $mediacount++;
                                             }
                                             //								$record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record);
                                         }
                                         $filetext .= trim($record) . "\n";
                                         $filetext .= "1 SOUR @SPGV1@\n";
                                         $filetext .= "2 PAGE " . $dSERVER_URL . $path . "family.php?famid=" . $clipping['id'] . "\n";
                                         $filetext .= "2 DATA\n";
                                         $filetext .= "3 TEXT " . $pgv_lang["family_downloaded_from"] . "\n";
                                         $filetext .= "4 CONT " . $dSERVER_URL . "/family.php?famid=" . $clipping['id'] . "\n";
                                         break;
                                     case 'source':
                                         $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1]));
                                             if (file_exists($filename)) {
                                                 $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename);
                                                 $mediacount++;
                                             }
                                             //								$record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record);
                                         }
                                         $filetext .= trim($record) . "\n";
                                         $filetext .= "1 NOTE " . $pgv_lang["source_downloaded_from"] . "\n";
                                         $filetext .= "2 CONT " . $dSERVER_URL . "/source.php?sid=" . $clipping['id'] . "\n";
                                         break;
                                     default:
                                         $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1]));
                                             if (file_exists($filename)) {
                                                 $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename);
                                                 $mediacount++;
                                             }
                                             //								$record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record);
                                         }
                                         $filetext .= trim($record) . "\n";
                                         break;
                                 }
                             }
                         }
                         if ($this->privatize_export != 'none') {
                             $_SESSION["pgv_user"] = $_SESSION["org_user"];
                             delete_user($export_user_id);
                             AddToLog("deleted dummy user -> {$tempUserID} <-");
                         }
                         if ($this->IncludeMedia == "yes") {
                             $this->media_list = $media;
                         }
                         $filetext .= "0 @SPGV1@ SOUR\n";
                         if ($user_id = get_user_id($CONTACT_EMAIL)) {
                             $filetext .= "1 AUTH " . getUserFullName($user_id) . "\n";
                         }
                         $filetext .= "1 TITL " . $HOME_SITE_TEXT . "\n";
                         $filetext .= "1 ABBR " . $HOME_SITE_TEXT . "\n";
                         $filetext .= "1 PUBL " . $HOME_SITE_URL . "\n";
                         $filetext .= "0 TRLR\n";
                         //-- make sure the preferred line endings are used
                         $filetext = preg_replace("/[\r\n]+/", PGV_EOL, $filetext);
                         $this->download_data = $filetext;
                         $this->download_clipping();
                     } else {
                         if ($this->filetype == "gramps") {
                             // Sort the clippings cart because the export works better when the cart is sorted
                             usort($cart, "same_group");
                             require_once "includes/classes/class_geclippings.php";
                             $gramps_Exp = new GEClippings();
                             $gramps_Exp->begin_xml();
                             $ct = count($cart);
                             usort($cart, "same_group");
                             for ($i = 0; $i < $ct; $i++) {
                                 $clipping = $cart[$i];
                                 switch ($clipping['type']) {
                                     case 'indi':
                                         $rec = find_person_record($clipping['id']);
                                         $rec = remove_custom_tags($rec, $remove);
                                         if ($this->privatize_export != 'none') {
                                             $rec = privatize_gedcom($rec);
                                         }
                                         $gramps_Exp->create_person($rec, $clipping['id']);
                                         break;
                                     case 'fam':
                                         $rec = find_family_record($clipping['id']);
                                         $rec = remove_custom_tags($rec, $remove);
                                         if ($this->privatize_export != 'none') {
                                             $rec = privatize_gedcom($rec);
                                         }
                                         $gramps_Exp->create_family($rec, $clipping['id']);
                                         break;
                                     case 'source':
                                         $rec = find_source_record($clipping['id']);
                                         $rec = remove_custom_tags($rec, $remove);
                                         if ($this->privatize_export != 'none') {
                                             $rec = privatize_gedcom($rec);
                                         }
                                         $gramps_Exp->create_source($rec, $clipping['id']);
                                         break;
                                 }
                             }
                             $this->download_data = $gramps_Exp->dom->saveXML();
                             if ($convert) {
                                 $this->download_data = utf8_decode($this->download_data);
                             }
                             $this->media_list = $gramps_Exp->get_all_media();
                             $this->download_clipping();
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
 /**
  * Creates the SourceRef element and appends it to the Parent Element.  If the actual Source has not
  * 	been previously created, this will retrieve the record for that, and create that also.
  *
  * @param DOMElement $eParent - the parent DOMElement to which the created Note Element is appended
  * @param string $sourcerefRec - the record containing the reference to a Source
  * @param int $level - The GEDCOM line level where the SOUR tag may be found
  */
 function create_sourceref($eParent, $sourcerefRec, $level)
 {
     if (($sourceID = get_gedcom_value("SOUR", $level, $sourcerefRec)) != null) {
         if (id_in_cart($sourceID)) {
             $eSourceRef = $this->dom->createElement("sourceref");
             $eSourceRef = $eParent->appendChild($eSourceRef);
             if (($sourceHlink = $this->query_dom("./sources/source[@id = \"{$sourceID}\"]/@handle")) == null) {
                 $this->create_source($sourceID, find_source_record($sourceID));
             }
             $eSourceRef->setAttribute("hlink", $this->query_dom("./sources/source[@id = \"{$sourceID}\"]/@handle"));
             if (($page = get_gedcom_value("SOUR:PAGE", $level, $sourcerefRec)) != null) {
                 $eSPage = $this->dom->createElement("spage");
                 $etSPage = $this->dom->createTextNode($page);
                 $etSPage = $eSPage->appendChild($etSPage);
                 $eSPage = $eSourceRef->appendChild($eSPage);
             }
             if (($comments = get_gedcom_value("SOUR:NOTE", $level, $sourcerefRec)) != null) {
                 $eSComments = $this->dom->createElement("scomments");
                 $etSComments = $this->dom->createTextNode($comments);
                 $etSComments = $eSComments->appendChild($etSComments);
                 $eSComments = $eSourceRef->appendChild($eSComments);
             }
             if (($text = get_gedcom_value("SOUR:TEXT", $level, $sourcerefRec)) != null) {
                 $num = 1;
                 while (($cont = get_gedcom_value("SOUR:TEXT:CONT", $level, $sourcerefRec, $num)) != null) {
                     $text .= $cont;
                     $num++;
                 }
                 $eSText = $this->dom->createElement("stext");
                 $etSText = $this->dom->createTextNode($text);
                 $etSText = $eSText->appendChild($etSText);
                 $eSText = $eSourceRef->appendChild($eSText);
             }
             if (($dateRec = get_sub_record(1, $level + 1 . " DATE", $sourcerefRec)) != null) {
                 $this->create_date($eSourceRef, $dateRec, $level + 1);
             }
         }
     }
 }
コード例 #3
0
ファイル: functions.php プロジェクト: bitweaver/phpgedview
/**
 * get gedcom tag value
 *
 * returns the value of a gedcom tag from the given gedcom record
 * @param string $tag	The tag to find, use : to delineate subtags
 * @param int $level	The gedcom line level of the first tag to find, setting level to 0 will cause it to use 1+ the level of the incoming record
 * @param string $gedrec	The gedcom record to get the value from
 * @param int $truncate	Should the value be truncated to a certain number of characters
 * @param boolean $convert	Should data like dates be converted using the configuration settings
 * @return string
 */
function get_gedcom_value($tag, $level, $gedrec, $truncate = '', $convert = true)
{
    global $SHOW_PEDIGREE_PLACES, $pgv_lang;
    if (empty($gedrec)) {
        return "";
    }
    $tags = explode(':', $tag);
    $origlevel = $level;
    if ($level == 0) {
        $level = $gedrec[0] + 1;
    }
    $subrec = $gedrec;
    foreach ($tags as $indexval => $t) {
        $lastsubrec = $subrec;
        $subrec = get_sub_record($level, "{$level} {$t}", $subrec);
        if (empty($subrec) && $origlevel == 0) {
            $level--;
            $subrec = get_sub_record($level, "{$level} {$t}", $lastsubrec);
        }
        if (empty($subrec)) {
            if ($t == "TITL") {
                $subrec = get_sub_record($level, "{$level} ABBR", $lastsubrec);
                if (!empty($subrec)) {
                    $t = "ABBR";
                }
            }
            if (empty($subrec)) {
                if ($level > 0) {
                    $level--;
                }
                $subrec = get_sub_record($level, "@ {$t}", $gedrec);
                if (empty($subrec)) {
                    return;
                }
            }
        }
        $level++;
    }
    $level--;
    $ct = preg_match("/{$level} {$t}(.*)/", $subrec, $match);
    if ($ct == 0) {
        $ct = preg_match("/{$level} @.+@ (.+)/", $subrec, $match);
    }
    if ($ct == 0) {
        $ct = preg_match("/@ {$t} (.+)/", $subrec, $match);
    }
    if ($ct > 0) {
        $value = trim($match[1]);
        $ct = preg_match("/@(.*)@/", $value, $match);
        if ($ct > 0 && $t != "DATE") {
            $oldsub = $subrec;
            switch ($t) {
                case 'HUSB':
                case 'WIFE':
                case 'CHIL':
                    $subrec = find_person_record($match[1]);
                    break;
                case 'FAMC':
                case 'FAMS':
                    $subrec = find_family_record($match[1]);
                    break;
                case 'SOUR':
                    $subrec = find_source_record($match[1]);
                    break;
                case 'REPO':
                    $subrec = find_other_record($match[1]);
                    break;
                default:
                    $subrec = find_gedcom_record($match[1]);
                    break;
            }
            if ($subrec) {
                $value = $match[1];
                $ct = preg_match("/0 @{$match['1']}@ {$t} (.+)/", $subrec, $match);
                if ($ct > 0) {
                    $value = $match[1];
                    $level = 0;
                } else {
                    $subrec = $oldsub;
                }
            } else {
                //-- set the value to the id without the @
                $value = $match[1];
            }
        }
        if ($level != 0 || $t != "NOTE") {
            $value .= get_cont($level + 1, $subrec);
        }
        $value = preg_replace("'\n'", "", $value);
        $value = preg_replace("'<br />'", "\n", $value);
        $value = trim($value);
        //-- if it is a date value then convert the date
        if ($convert && $t == "DATE") {
            $g = new GedcomDate($value);
            $value = $g->Display();
            if (!empty($truncate)) {
                if (UTF8_strlen($value) > $truncate) {
                    $value = preg_replace("/\\(.+\\)/", "", $value);
                    //if (UTF8_strlen($value)>$truncate) {
                    //	$value = preg_replace_callback("/([a-zśź]+)/ui", create_function('$matches', 'return UTF8_substr($matches[1], 0, 3);'), $value);
                    //}
                }
            }
        } else {
            //-- if it is a place value then apply the pedigree place limit
            if ($convert && $t == "PLAC") {
                if ($SHOW_PEDIGREE_PLACES > 0) {
                    $plevels = explode(',', $value);
                    $value = "";
                    for ($plevel = 0; $plevel < $SHOW_PEDIGREE_PLACES; $plevel++) {
                        if (!empty($plevels[$plevel])) {
                            if ($plevel > 0) {
                                $value .= ", ";
                            }
                            $value .= trim($plevels[$plevel]);
                        }
                    }
                }
                if (!empty($truncate)) {
                    if (strlen($value) > $truncate) {
                        $plevels = explode(',', $value);
                        $value = "";
                        for ($plevel = 0; $plevel < count($plevels); $plevel++) {
                            if (!empty($plevels[$plevel])) {
                                if (strlen($plevels[$plevel]) + strlen($value) + 3 < $truncate) {
                                    if ($plevel > 0) {
                                        $value .= ", ";
                                    }
                                    $value .= trim($plevels[$plevel]);
                                } else {
                                    break;
                                }
                            }
                        }
                    }
                }
            } else {
                if ($convert && $t == "SEX") {
                    if ($value == "M") {
                        $value = get_first_letter($pgv_lang["male"]);
                    } elseif ($value == "F") {
                        $value = get_first_letter($pgv_lang["female"]);
                    } else {
                        $value = get_first_letter($pgv_lang["unknown"]);
                    }
                } else {
                    if (!empty($truncate)) {
                        if (strlen($value) > $truncate) {
                            $plevels = explode(' ', $value);
                            $value = "";
                            for ($plevel = 0; $plevel < count($plevels); $plevel++) {
                                if (!empty($plevels[$plevel])) {
                                    if (strlen($plevels[$plevel]) + strlen($value) + 3 < $truncate) {
                                        if ($plevel > 0) {
                                            $value .= " ";
                                        }
                                        $value .= trim($plevels[$plevel]);
                                    } else {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return $value;
    }
    return "";
}
コード例 #4
0
ファイル: source_ctrl.php プロジェクト: bitweaver/phpgedview
 /**
  * Accept any edit changes into the database
  * Also update the indirec we will use to generate the page
  */
 function acceptChanges()
 {
     global $GEDCOM;
     if (!PGV_USER_CAN_ACCEPT) {
         return;
     }
     if (accept_changes($this->sid . "_" . $GEDCOM)) {
         $this->show_changes = false;
         $this->accept_success = true;
         $indirec = find_source_record($this->sid);
         //-- check if we just deleted the record and redirect to index
         if (empty($indirec)) {
             header("Location: index.php?ctype=gedcom");
             exit;
         }
         $this->source = new Source($indirec);
     }
 }