Esempio n. 1
0
/**
 * print a note record
 * @param string $text
 * @param int $nlevel	the level of the note record
 * @param string $nrec	the note record to print
 * @return boolean
 */
function print_note_record($text, $nlevel, $nrec)
{
    global $pgv_lang;
    global $PGV_IMAGE_DIR, $PGV_IMAGES;
    $elementID = "N-" . floor(microtime() * 1000000);
    $text = preg_replace("/~~/", "<br />", trim($text));
    $text .= get_cont($nlevel, $nrec);
    $text = preg_replace("'(https?://[\\w\\./\\-&=?~%#]*)'", "<a href=\"\$1\" target=\"blank\">URL</a>", $text);
    $text = trim($text);
    if (!empty($text)) {
        $text = PrintReady($text);
        $brpos = strpos($text, "<br />");
        print "\n\t\t<br /><span class=\"label\">";
        if ($brpos !== false) {
            print "<a href=\"javascript:;\" onclick=\"expand_layer('{$elementID}'); return false;\"><img id=\"{$elementID}_img\" src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["plus"]["other"] . "\" border=\"0\" width=\"11\" height=\"11\" alt=\"" . $pgv_lang["show_details"] . "\" title=\"" . $pgv_lang["show_details"] . "\" /></a> ";
        }
        print $pgv_lang["note"] . ": </span><span class=\"field\">";
        if ($brpos !== false) {
            print substr($text, 0, $brpos);
            print "<span id=\"{$elementID}\" class=\"note_details\">";
            print substr($text, $brpos + 6);
            print "</span>";
        } else {
            print $text;
        }
        return true;
    }
    return false;
}
Esempio n. 2
0
/**
 * print a note record
 *
 * @param string $text
 * @param int    $nlevel   the level of the note record
 * @param string $nrec     the note record to print
 * @param bool   $textOnly Don't print the "Note: " introduction
 *
 * @return boolean
 */
function print_note_record($text, $nlevel, $nrec, $textOnly = false)
{
    global $WT_TREE;
    $text .= get_cont($nlevel, $nrec);
    // Check if shared note (we have already checked that it exists)
    if (preg_match('/^0 @(' . WT_REGEX_XREF . ')@ NOTE/', $nrec, $match)) {
        $note = WT_Note::getInstance($match[1]);
        $label = 'SHARED_NOTE';
        // If Census assistant installed, allow it to format the note
        if (array_key_exists('GEDFact_assistant', WT_Module::getActiveModules())) {
            $html = GEDFact_assistant_WT_Module::formatCensusNote($note);
        } else {
            $html = WT_Filter::formatText($note->getNote(), $WT_TREE);
        }
    } else {
        $note = null;
        $label = 'NOTE';
        $html = WT_Filter::formatText($text, $WT_TREE);
    }
    if ($textOnly) {
        return strip_tags($text);
    }
    if (strpos($text, "\n") === false) {
        // A one-line note? strip the block-level tags, so it displays inline
        return WT_Gedcom_Tag::getLabelValue($label, strip_tags($html, '<a><strong><em>'));
    } elseif ($WT_TREE->preference('EXPAND_NOTES')) {
        // A multi-line note, and we're expanding notes by default
        return WT_Gedcom_Tag::getLabelValue($label, $html);
    } else {
        // A multi-line note, with an expand/collapse option
        $element_id = Uuid::uuid4();
        // NOTE: class "note-details" is (currently) used only by some third-party themes
        if ($note) {
            $first_line = '<a href="' . $note->getHtmlUrl() . '">' . $note->getFullName() . '</a>';
        } else {
            list($first_line) = explode("\n", $text);
        }
        return '<div class="fact_NOTE"><span class="label">' . '<a href="#" onclick="expand_layer(\'' . $element_id . '\'); return false;"><i id="' . $element_id . '_img" class="icon-plus"></i></a> ' . WT_Gedcom_Tag::getLabel($label) . ':</span> ' . '<span id="' . $element_id . '-alt">' . $first_line . '</span>' . '</div>' . '<div class="note-details" id="' . $element_id . '" style="display:none">' . $html . '</div>';
    }
}
function print_main_notes(WT_Fact $fact, $level)
{
    global $WT_TREE, $SHOW_FACT_ICONS;
    $factrec = $fact->getGedcom();
    $fact_id = $fact->getFactId();
    $parent = $fact->getParent();
    $pid = $parent->getXref();
    if ($fact->isNew()) {
        $styleadd = ' new';
        $can_edit = $level == 1 && $fact->canEdit();
    } elseif ($fact->isOld()) {
        $styleadd = ' old';
        $can_edit = false;
    } else {
        $styleadd = '';
        $can_edit = $level == 1 && $fact->canEdit();
    }
    $ct = preg_match_all("/{$level} NOTE (.*)/", $factrec, $match, PREG_SET_ORDER);
    for ($j = 0; $j < $ct; $j++) {
        // Note object, or inline note?
        if (preg_match("/{$level} NOTE @(.*)@/", $match[$j][0], $nmatch)) {
            $note = WT_Note::getInstance($nmatch[1]);
            if ($note && !$note->canShow()) {
                continue;
            }
        } else {
            $note = null;
        }
        if ($level >= 2) {
            echo '<tr class="row_note2"><td class="descriptionbox rela ', $styleadd, ' width20">';
        } else {
            echo '<tr><td class="descriptionbox ', $styleadd, ' width20">';
        }
        if ($can_edit) {
            echo '<a onclick="return edit_record(\'', $pid, '\', \'', $fact_id, '\');" href="#" title="', WT_I18N::translate('Edit'), '">';
            if ($level < 2) {
                if ($SHOW_FACT_ICONS) {
                    echo '<i class="icon-note"></i> ';
                }
                if ($note) {
                    echo WT_Gedcom_Tag::getLabel('SHARED_NOTE');
                } else {
                    echo WT_Gedcom_Tag::getLabel('NOTE');
                }
                echo '</a>';
                echo '<div class="editfacts">';
                echo "<div class=\"editlink\"><a class=\"editicon\" onclick=\"return edit_record('{$pid}', '{$fact_id}');\" href=\"#\" title=\"" . WT_I18N::translate('Edit') . "\"><span class=\"link_text\">" . WT_I18N::translate('Edit') . "</span></a></div>";
                echo '<div class="copylink"><a class="copyicon" href="#" onclick="return copy_fact(\'', $pid, '\', \'', $fact_id, '\');" title="' . WT_I18N::translate('Copy') . '"><span class="link_text">' . WT_I18N::translate('Copy') . '</span></a></div>';
                echo "<div class=\"deletelink\"><a class=\"deleteicon\" onclick=\"return delete_fact('" . WT_I18N::translate('Are you sure you want to delete this fact?') . "', '{$pid}', '{$fact_id}');\" href=\"#\" title=\"" . WT_I18N::translate('Delete') . "\"><span class=\"link_text\">" . WT_I18N::translate('Delete') . "</span></a></div>";
                if ($note) {
                    echo '<a class="icon-note" href="', $note->getHtmlUrl(), '" title="' . WT_I18N::translate('View') . '"><span class="link_text">' . WT_I18N::translate('View') . '</span></a>';
                }
                echo '</div>';
            }
        } else {
            if ($level < 2) {
                if ($SHOW_FACT_ICONS) {
                    echo '<i class="icon-note"></i> ';
                }
                if ($note) {
                    echo WT_Gedcom_Tag::getLabel('SHARED_NOTE');
                } else {
                    echo WT_Gedcom_Tag::getLabel('NOTE');
                }
            }
            $factlines = explode("\n", $factrec);
            // 1 BIRT Y\n2 NOTE ...
            $factwords = explode(" ", $factlines[0]);
            // 1 BIRT Y
            $factname = $factwords[1];
            // BIRT
            $parent = WT_GedcomRecord::getInstance($pid);
            if ($factname == 'EVEN' || $factname == 'FACT') {
                // Add ' EVEN' to provide sensible output for an event with an empty TYPE record
                $ct = preg_match("/2 TYPE (.*)/", $factrec, $ematch);
                if ($ct > 0) {
                    $factname = trim($ematch[1]);
                    echo $factname;
                } else {
                    echo WT_Gedcom_Tag::getLabel($factname, $parent);
                }
            } else {
                if ($factname != 'NOTE') {
                    // Note is already printed
                    echo WT_Gedcom_Tag::getLabel($factname, $parent);
                    if ($note) {
                        echo '<div class="editfacts"><a class="icon-note" href="', $note->getHtmlUrl(), '" title="' . WT_I18N::translate('View') . '"><span class="link_text">' . WT_I18N::translate('View') . '</span></a></div>';
                    }
                }
            }
        }
        echo '</td>';
        if ($note) {
            // Note objects
            if (array_key_exists('GEDFact_assistant', WT_Module::getActiveModules())) {
                // If Census assistant installed, allow it to format the note
                $text = GEDFact_assistant_WT_Module::formatCensusNote($note);
            } else {
                $text = WT_Filter::formatText($note->getNote(), $WT_TREE);
            }
        } else {
            // Inline notes
            $nrec = get_sub_record($level, "{$level} NOTE", $factrec, $j + 1);
            $text = $match[$j][1] . get_cont($level + 1, $nrec);
            $text = WT_Filter::formatText($text, $WT_TREE);
        }
        echo '<td class="optionbox', $styleadd, ' wrap">';
        echo $text;
        if (!empty($noterec)) {
            echo print_fact_sources($noterec, 1);
        }
        // 2 RESN tags.  Note, there can be more than one, such as "privacy" and "locked"
        if (preg_match_all("/\n2 RESN (.+)/", $factrec, $matches)) {
            foreach ($matches[1] as $match) {
                echo '<br><span class="label">', WT_Gedcom_Tag::getLabel('RESN'), ':</span> <span class="field">';
                switch ($match) {
                    case 'none':
                        // Note: "2 RESN none" is not valid gedcom, and the GUI will not let you add it.
                        // However, webtrees privacy rules will interpret it as "show an otherwise private fact to public".
                        echo '<i class="icon-resn-none"></i> ', WT_I18N::translate('Show to visitors');
                        break;
                    case 'privacy':
                        echo '<i class="icon-resn-privacy"></i> ', WT_I18N::translate('Show to members');
                        break;
                    case 'confidential':
                        echo '<i class="icon-resn-confidential"></i> ', WT_I18N::translate('Show to managers');
                        break;
                    case 'locked':
                        echo '<i class="icon-resn-locked"></i> ', WT_I18N::translate('Only managers can edit');
                        break;
                    default:
                        echo $match;
                        break;
                }
                echo '</span>';
            }
        }
        echo '</td></tr>';
    }
}
Esempio n. 4
0
/**
 * get gedcom tag value
 *
 * @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
 *
 * @return string the value of a gedcom tag from the given gedcom record
 */
function get_gedcom_value($tag, $level, $gedrec)
{
    if (empty($gedrec)) {
        return '';
    }
    $tags = explode(':', $tag);
    $origlevel = $level;
    if ($level == 0) {
        $level = $gedrec[0] + 1;
    }
    $subrec = $gedrec;
    foreach ($tags as $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]);
        if ($t == 'NOTE' && preg_match('/^@(.+)@$/', $value, $match)) {
            $note = WT_Note::getInstance($match[1]);
            if ($note) {
                $value = $note->getNote();
            } else {
                //-- set the value to the id without the @
                $value = $match[1];
            }
        }
        if ($level != 0 || $t != "NOTE") {
            $value .= get_cont($level + 1, $subrec);
        }
        return $value;
    }
    return "";
}
Esempio n. 5
0
/**
 * get the full file path
 *
 * get the file path from a multimedia gedcom record
 * @param string $mediarec a OBJE subrecord
 * @return the fullpath from the FILE record
 */
function extract_fullpath($mediarec)
{
    preg_match("/(\\d) _*FILE (.*)/", $mediarec, $amatch);
    if (empty($amatch[2])) {
        return "";
    }
    $level = trim($amatch[1]);
    $fullpath = trim($amatch[2]);
    $filerec = get_sub_record($level, $amatch[0], $mediarec);
    $fullpath .= get_cont($level + 1, $filerec);
    return $fullpath;
}
 }
 $EMAIL = "";
 $ct = preg_match("/1 (_?EMAIL) (.*)/", $gedrec, $match);
 if ($ct > 0) {
     $EMAIL = trim($match[2]);
     $subrec = get_sub_record(1, "1 " . $match[1], $gedrec);
     $EMAIL .= get_cont(2, $subrec);
 }
 $FAX = "";
 $subrec = get_sub_record(1, "1 FAX", $gedrec);
 if (!empty($subrec)) {
     $ct = preg_match("/1 FAX (.*)/", $subrec, $match);
     if ($ct > 0) {
         $FAX = trim($match[1]);
     }
     $FAX .= get_cont(2, $subrec);
 }
 $indifacts = array();
 $person = Person::getInstance($pid);
 $facts = $person->getIndiFacts();
 $repeat_tags = array();
 foreach ($facts as $event) {
     $fact = $event->getTag();
     if ($fact == "EVEN" || $fact == "FACT") {
         $fact = $event->getType();
     }
     if (in_array($fact, $addfacts)) {
         if (!isset($repeat_tags[$fact])) {
             $repeat_tags[$fact] = 1;
         } else {
             $repeat_tags[$fact]++;
 /**
  * Creates the Note element and appends it to the parent element
  *
  * @param DOMElement $eParent - the parent DOMElement to which the created Note Element is appended
  * @param string $noteRec - the entire Family, Individual, etc. record in which the event may be found
  * @param int $level - The GEDCOM line level where the NOTE tag may be found
  */
 function create_note($eParent, $noteRec, $level)
 {
     $note = get_gedcom_value("NOTE", $level, $noteRec);
     $note .= get_cont($level + 1, $noteRec, false);
     //		$num = 1;
     //		while (($cont = get_gedcom_value("NOTE:CONT", $level, $noteRec, $num)) != null) {
     //			$note .= $cont;
     //			$num++;
     //		}
     $eNote = $this->dom->createElement("note");
     $etNote = $this->dom->createTextNode(htmlentities($note, ENT_COMPAT, 'UTF-8'));
     $etNote = $eNote->appendChild($etNote);
     $eNote = $eParent->appendChild($eNote);
 }
Esempio n. 8
0
//-- print out editing fields for any other data in the media record
$sourceSOUR = '';
if (!empty($gedrec)) {
    preg_match_all('/\\n(1 (?!FILE|FORM|TYPE|TITL|_PRIM|_THUM|CHAN|DATA).*(\\n[2-9] .*)*)/', $gedrec, $matches);
    foreach ($matches[1] as $subrec) {
        $pieces = explode("\n", $subrec);
        foreach ($pieces as $piece) {
            $ft = preg_match("/(\\d) (\\w+)(.*)/", $piece, $match);
            if ($ft == 0) {
                continue;
            }
            $subLevel = $match[1];
            $fact = trim($match[2]);
            $event = trim($match[3]);
            if ($fact == 'NOTE' || $fact == 'TEXT') {
                $event .= get_cont($subLevel + 1, $subrec);
            }
            if ($sourceSOUR != '' && $subLevel <= $sourceLevel) {
                // Get rid of all saved Source data
                add_simple_tag($sourceLevel . ' SOUR ' . $sourceSOUR);
                add_simple_tag($sourceLevel + 1 . ' PAGE ' . $sourcePAGE);
                add_simple_tag($sourceLevel + 2 . ' TEXT ' . $sourceTEXT);
                add_simple_tag($sourceLevel + 2 . ' DATE ' . $sourceDATE, '', WT_Gedcom_Tag::getLabel('DATA:DATE'));
                add_simple_tag($sourceLevel + 1 . ' QUAY ' . $sourceQUAY);
                $sourceSOUR = '';
            }
            if ($fact == 'SOUR') {
                $sourceLevel = $subLevel;
                $sourceSOUR = $event;
                $sourcePAGE = '';
                $sourceTEXT = '';
Esempio n. 9
0
</b><br /><br />
	<form method="post" action="edit_interface.php" onsubmit="return check_form(this);">
		<input type="hidden" name="action" value="update" />
		<input type="hidden" name="pid" value="<?php 
        echo $pid;
        ?>
" />

		<?php 
        if (!isset($pgv_changes[$pid . "_" . PGV_GEDCOM])) {
            $gedrec = find_gedcom_record($pid, PGV_GED_ID);
        } else {
            $gedrec = find_updated_record($pid, PGV_GED_ID);
        }
        if (preg_match("/^0 @{$pid}@ NOTE ?(.*)/", $gedrec, $n1match)) {
            $note_content = $n1match[1] . get_cont(1, $gedrec, false);
        } else {
            $note_content = '';
        }
        ?>
		<table class="facts_table">
			<tr>
				<td class="descriptionbox <?php 
        echo $TEXT_DIRECTION;
        ?>
 wrap width25"><?php 
        print_help_link("edit_SHARED_NOTE_help", "qm", "shared_note");
        echo $pgv_lang["shared_note"];
        ?>
</td>
				<td class="optionbox wrap">
Esempio n. 10
0
/**
* @todo add info
* @see PGVRFactsSHandler()
*/
function PGVRFactsEHandler()
{
    global $repeats, $repeatsStack, $repeatBytes, $parser, $parserStack, $report, $gedrec, $fact, $desc, $type, $processRepeats;
    $processRepeats--;
    if ($processRepeats > 0) {
        return;
    }
    $line = xml_get_current_line_number($parser) - 1;
    $lineoffset = 0;
    for ($i = 0; $i < count($repeatsStack); $i++) {
        $p = $repeatsStack[$i];
        $l = $p[1];
        $lineoffset += $l;
    }
    //-- read the xml from the file
    $lines = file($report);
    $reportxml = "<tempdoc>\n";
    while ($lineoffset + $repeatBytes > 0 && strstr($lines[$lineoffset + $repeatBytes], "<PGVRFacts ") === false) {
        $lineoffset--;
    }
    $lineoffset++;
    //	var_dump($lineoffset);
    for ($i = $repeatBytes + $lineoffset; $i < $line + $lineoffset; $i++) {
        //		print $i." ".htmlentities($lines[$i],ENT_COMPAT,'UTF-8');
        $reportxml .= $lines[$i];
    }
    $reportxml .= "</tempdoc>\n";
    array_push($parserStack, $parser);
    $oldgedrec = $gedrec;
    for ($i = 0; $i < count($repeats); $i++) {
        $gedrec = $repeats[$i];
        $match = array();
        $ft = preg_match("/1 (\\w+)(.*)/", $gedrec, $match);
        $fact = "";
        $desc = "";
        if ($ft > 0) {
            $fact = $match[1];
            if ($fact == "EVEN" || $fact == "FACT") {
                $tmatch = array();
                $tt = preg_match("/2 TYPE (.+)/", $gedrec, $tmatch);
                if ($tt > 0) {
                    $type = trim($tmatch[1]);
                }
            }
            $desc = trim($match[2]);
            //			print $fact."[".$desc."]";
            $desc .= get_cont(2, $gedrec);
        }
        //-- start the sax parser
        $repeat_parser = xml_parser_create();
        $parser = $repeat_parser;
        //-- make sure everything is case sensitive
        xml_parser_set_option($repeat_parser, XML_OPTION_CASE_FOLDING, false);
        //-- set the main element handler functions
        xml_set_element_handler($repeat_parser, "startElement", "endElement");
        //-- set the character data handler
        xml_set_character_data_handler($repeat_parser, "characterData");
        if (!xml_parse($repeat_parser, $reportxml, true)) {
            die(sprintf($reportxml . "\nPGVRFactsEHandler XML error: %s at line %d", xml_error_string(xml_get_error_code($repeat_parser)), xml_get_current_line_number($repeat_parser)));
            debug_print_backtrace();
        }
        xml_parser_free($repeat_parser);
    }
    $parser = array_pop($parserStack);
    $gedrec = $oldgedrec;
    $temp = array_pop($repeatsStack);
    $repeats = $temp[0];
    $repeatBytes = $temp[1];
}