Пример #1
0
function get_place_desc($n)
{
    global $language;
    $label = 'desc_' . $language;
    $str = fetch_val("\n        SELECT {$label} FROM place_level_desc WHERE place_level_id = {$n}\n    ");
    $str .= ':';
    return $str;
}
    $note_width = 80;
    form_begin('edit_event', $_SERVER['PHP_SELF']);
    hidden_input('source', $source);
    hidden_input('event', $event);
    hidden_input('posted', 1);
    select_tag($rec['tag_fk']);
    select_place($rec['place_fk']);
    date_input($rec['event_date'], $rec['sd']);
    textarea_input("{$_Text}:<br />{$notelen}", $note_height, $note_width, 'event_note', $note);
    form_submit();
    form_end();
    echo "<h3>{$_Citations}</h3>\n";
    $handle = pg_query("\n        SELECT source_fk\n        FROM event_citations\n        WHERE event_fk = {$event}\n    ");
    while ($row = pg_fetch_row($handle)) {
        echo '<p>' . $row[0] . ' ';
        echo fetch_val("SELECT get_source_text({$row['0']})");
        echo "</p>\n";
    }
    echo "</body>\n</html>\n";
} else {
    // do action
    $source = $_POST['source'];
    $event = $_POST['event'];
    $tag = $_POST['tag_fk'];
    $place = $_POST['place_fk'];
    if ($place == 0) {
        $place = 1;
    }
    $note = note_to_db($_POST['event_note']);
    $event_date = pad_date($_POST['date_1']) . $_POST['date_type'] . pad_date($_POST['date_2']) . '1';
    $sort_date = parse_sort_date($_POST['sort_date'], $event_date);
Пример #3
0
    echo "</body>\n</html>\n";
} else {
    $person = $_POST['person'];
    $source = $_POST['source'];
    $text = $_POST['text'];
    $source_date = $_POST['source_date'] ? $_POST['source_date'] : fetch_val("SELECT true_date_extract('{$text}')");
    $psource = $_POST['psource'] ? $_POST['psource'] : 0;
    $sort = $_POST['sort'] ? $_POST['sort'] : 1;
    $part_type = $_POST['part_type'];
    $ch_part_type = isset($_POST['ch_part_type']) ? $_POST['ch_part_type'] : 0;
    $sort = get_sort($psource, $text, $sort);
    $text = note_to_db($text);
    $ret = $_POST['ret'];
    $template = isset($_POST['template']) ? $_POST['template'] : false;
    if ($template) {
        if (fetch_val("\n                SELECT count(*)\n                FROM templates\n                WHERE source_fk = {$source}\n            ")) {
            pg_query("\n                UPDATE templates\n                SET template = '{$template}'\n                WHERE source_fk = {$source}\n            ");
        } else {
            pg_query("\n                INSERT INTO templates (source_fk, template)\n                VALUES ({$source}, '{$template}')\n            ");
        }
    }
    // this is a freak situation that arises when $psource = 0
    // and a rather brute hack to remedy it.
    if ($source == $psource) {
        $psource = 0;
    }
    pg_prepare("query", "UPDATE sources SET\n            parent_id = \$1,\n            sort_order = \$2,\n            source_text = \$3,\n            source_date = \$4,\n            part_type = \$5,\n            ch_part_type = \$6\n        WHERE source_id = \$7");
    pg_execute("query", array($psource, $sort, $text, $source_date, $part_type, $ch_part_type, $source));
    // this script is called from two different locations.
    // One sets $person, the other doesn't.
    if ($person) {
        if ($row['event_type'] == 3) {
            // event has any number of participants, print names as ordered list
            $subhandle = pg_query("\n                SELECT\n                    person_fk,\n                    is_principal,\n                    sort_order\n                FROM\n                    participants\n                WHERE\n                    event_fk={$event}\n                ORDER BY\n                    sort_order\n            ");
            echo '<ul>';
            while ($subrow = pg_fetch_assoc($subhandle)) {
                $participant = $subrow['person_fk'];
                $bp = $subrow['is_principal'] == 't' ? ' H ' : ' B ';
                echo '<li> ';
                // print link to edit sort order
                echo to_url('./forms/source_sort_order_edit.php', array('person' => $participant, 'event' => $event, 'node' => $self), square_brace($subrow['sort_order']), 'Edit sort order');
                echo $bp . linked_name($participant, './family.php');
                // a non-principal, eg a person mentioned as heir in a probate,
                // who may or may not be described in a separate note
                if ($subrow['is_principal'] == 'f') {
                    // print participant note if it exists
                    if ($note = fetch_val("\n                        SELECT link_expand(part_note)\n                        FROM participant_notes\n                        WHERE person_fk = {$participant}\n                        AND event_fk = {$event}\n                    ")) {
                        echo ': ' . $note;
                    }
                    // print link to edit participant note
                    echo ' ' . paren(to_url('./forms/part_note.php', array('person' => $participant, 'event' => $event, 'node' => $self), $_edit));
                }
                echo "</li>\n";
            }
            echo "</ul>\n";
        }
        echo "</li>\n";
    }
    echo "</ol>\n";
}
// *****************************************************************************
// section II: print list of relations cited by this source
<?php

/***************************************************************************
 *   person_toggle_dcf.php                                                 *
 *   Yggdrasil: Toggle "dead child" flag                                   *
 *                                                                         *
 *   Copyright (C) 2006-2011 by Leif B. Kristensen <*****@*****.**>   *
 *   All rights reserved. For terms of use, see LICENSE.txt                *
 ***************************************************************************/
require "../settings/settings.php";
require "../functions.php";
$person = $_GET['person'];
if (fetch_val("SELECT dead_child({$person})") == 'f') {
    pg_query("\n        INSERT INTO dead_children (person_fk)\n        VALUES ({$person})\n    ");
} else {
    pg_query("\n        DELETE FROM dead_children\n        WHERE person_fk = {$person}\n    ");
}
header("Location: {$app_root}/family.php?person={$person}");
Пример #6
0
<?php

/***************************************************************************
 *   place_view.php                                                        *
 *   Yggdrasil: Place View                                                 *
 *                                                                         *
 *   Copyright (C) 2006-2011 by Leif B. Kristensen <*****@*****.**>   *
 *   All rights reserved. For terms of use, see LICENSE.txt                *
 ***************************************************************************/
// This script is basically a "report" listing events and persons associated
// with a place. It is accessed from the Place Manager through the 'browse'
// (se på) link.
require "./settings/settings.php";
require "./functions.php";
$place_id = $_GET['place_id'];
$place_name = fetch_val("SELECT get_place_name({$place_id})");
$title = "Hendelser knyttet til stedsnavn \"{$place_name}\"";
require "./header.php";
echo "<div class=\"normal\">\n";
echo "<h2>{$title}</h2>\n";
echo "<p><a href=\"./place_manager.php\">Alle stedsnavn</a></p>\n";
echo "<table>\n";
echo "<tr><th>ID</th><th>Hendelse</th><th>Dato</th><th>Deltagere</th></tr>\n";
$handle = pg_query("SELECT event_id, event_name, event_date, p1, p2\n                        FROM place_events WHERE place_fk = {$place_id} ORDER BY event_date");
while ($row = pg_fetch_assoc($handle)) {
    unset($participant_list);
    $event = $row['event_id'];
    $p_handle = pg_query("SELECT person_fk FROM participants\n                            WHERE event_fk = {$event} ORDER BY sort_order");
    while ($parts = pg_fetch_row($p_handle)) {
        $participant_list[] = linked_name($parts[0], './family.php');
    }
Пример #7
0
    text_input("{$_Age}:", 10, 'age', '', "({$_Adds_birth_event})");
    form_submit();
    form_end();
    echo "<h3>{$_Citations}</h3>\n";
    $handle = pg_query("SELECT source_fk FROM event_citations WHERE event_fk = {$event}");
    while ($row = pg_fetch_row($handle)) {
        echo '<p>' . $row[0] . ' ';
        echo fetch_val("SELECT get_source_text({$row['0']})");
        echo "</p>\n";
    }
    echo "</body>\n</html>\n";
} else {
    // do action
    $src = $_POST['source_id'];
    $txt = $_POST['source_text'];
    if ($txt && fetch_val("SELECT is_leaf({$src})") == 't') {
        echo "Cannot create subsource under source #{$src}. ";
        echo "Please go back and check your source reference.";
        die;
    }
    $event = $_POST['event'];
    $person = $_POST['person'];
    $tag = $_POST['tag_fk'];
    $place = $_POST['place_fk'];
    if ($place == 0) {
        $place = 1;
    }
    $note = note_to_db($_POST['event_note']);
    $event_date = pad_date($_POST['date_1']) . $_POST['date_type'] . pad_date($_POST['date_2']) . '1';
    $sort_date = parse_sort_date($_POST['sort_date'], $event_date);
    pg_query("BEGIN");
Пример #8
0
function get_participant_note($p, $e)
{
    return fetch_val("SELECT COALESCE(\n                        (SELECT link_expand(part_note)\n                        FROM participant_notes\n                        WHERE person_fk={$p} AND event_fk={$e}), '')");
}
Пример #9
0
/***************************************************************************
 *   spt_view.php                                                          *
 *   Yggdrasil: Source Part Type View                                      *
 *                                                                         *
 *   Copyright (C) 2011 by Leif B. Kristensen <*****@*****.**>        *
 *   All rights reserved. For terms of use, see LICENSE.txt                *
 ***************************************************************************/
// This script is basically a report listing sources of one type.
// It is accessed from the Source Part Type Manager via the 'report' link.
require "./settings/settings.php";
require "./functions.php";
require_once "./langs/{$language}.php";
$spt = $_GET['spt'];
$label = 'label_' . $language;
$spt_name = fetch_val("\n    SELECT {$label} FROM source_part_types WHERE part_type_id = {$spt}\n");
$title = "{$_All} {$_sources} {$_of} type {$spt_name}";
require "./header.php";
echo "<div class=\"normal\">\n";
echo "<h2>{$title}</h2>\n";
echo "<table>";
$handle = pg_query("\n    SELECT\n        source_id,\n        link_expand(source_text) AS txt,\n        source_date,\n        ecc(source_id) AS e,\n        rcc(source_id) AS r,\n        ssc(source_id) AS s,\n        usc(source_id) AS u,\n        spt.{$label} AS {$label}\n    FROM\n        sources, source_part_types spt\n    WHERE\n        spt.part_type_id = sources.part_type\n    AND\n        spt.part_type_id = {$spt}\n    AND\n        source_id <> 0\n    ORDER BY\n        source_date,\n        source_text\n");
while ($row = pg_fetch_assoc($handle)) {
    $id = $row['source_id'];
    echo '<tr>';
    echo td(paren(to_url('source_manager.php', array('node' => $id), $_Select) . '&nbsp;/&nbsp;' . to_url('./forms/source_edit.php', array('person' => 0, 'source' => $id), $_Edit)));
    if ($row['e'] || $row['r'] || $row['s']) {
        echo td(square_brace(italic($row['source_date'])) . ' ' . $row['txt'] . node_details($row['e'], $row['r'], $row['s'], $row['u']));
    } else {
        // source is unused, print with gray text
        echo td(span_type(square_brace(italic($row['source_date'])) . conc($row['txt']), "faded"));
Пример #10
0
        $relation_id = fetch_val("\n            INSERT INTO relations (\n                child_fk,\n                parent_fk\n            )\n            VALUES (\n                {$child},\n                {$person}\n            )\n            RETURNING relation_id\n        ");
        if ($source_id) {
            // add relation citation
            pg_query("\n                INSERT INTO relation_citations (\n                    relation_fk,\n                    source_fk\n                )\n                VALUES (\n                    {$relation_id},\n                    {$source_id}\n                )\n            ");
        }
    }
    // add relation if this script was called with a 'father' param:
    if ($_POST['father']) {
        $father = $_POST['father'];
        $relation_id = fetch_val("\n            INSERT INTO relations (\n                child_fk,\n                parent_fk\n            )\n            VALUES (\n                {$person},\n                {$father}\n            )\n            RETURNING relation_id\n        ");
        if ($source_id) {
            // add relation citation
            pg_query("\n                INSERT INTO relation_citations (\n                    relation_fk,\n                    source_fk\n                )\n                VALUES (\n                    {$relation_id},\n                    {$source_id}\n                )\n            ");
        }
    }
    // add relation if this script was called with a 'mother' param:
    if ($_POST['mother']) {
        $mother = $_POST['mother'];
        $relation_id = fetch_val("\n            INSERT INTO relations (\n                child_fk,\n                parent_fk\n            )\n            VALUES (\n                {$person},\n                {$mother}\n            )\n            RETURNING relation_id\n        ");
        if ($source_id) {
            // add relation citation
            pg_query("\n                INSERT INTO relation_citations (\n                    relation_fk,\n                    source_fk\n                )\n                VALUES (\n                    {$relation_id},\n                    {$source_id}\n                )\n            ");
        }
    }
    if ($_POST['age']) {
        // generate birth event
        add_birth($person, $event_date, $_POST['age'], $source_id);
    }
    pg_query("COMMIT") or die(pg_last_error());
    header("Location: {$app_root}/family.php?person={$person}");
}
Пример #11
0
function is_principal($p, $e)
{
    if (fetch_val("\n        SELECT\n            is_principal\n        FROM\n            participants\n        WHERE\n            person_fk={$p} AND event_fk={$e}\n        ") == 't') {
        return 1;
    } else {
        return 0;
    }
}
<?php

/***************************************************************************
 *   source_toggle_sd.php                                                  *
 *   Yggdrasil: Toggle show delete link for unused sources                 *
 *                                                                         *
 *   Copyright (C) 2006-2011 by Leif B. Kristensen <*****@*****.**>   *
 *   All rights reserved. For terms of use, see LICENSE.txt                *
 ***************************************************************************/
require "../settings/settings.php";
require "../functions.php";
$node = $_GET['node'];
if (fetch_val("SELECT show_delete FROM user_settings WHERE username = current_user") == 'f') {
    pg_query("\n        UPDATE user_settings\n        SET show_delete = TRUE\n        WHERE username = current_user\n    ");
} else {
    pg_query("\n        UPDATE user_settings\n        SET show_delete = FALSE\n        WHERE username = current_user\n    ");
}
header("Location: {$app_root}/source_manager.php?node={$node}");
Пример #13
0
/***************************************************************************
 *   index.php                                                             *
 *   Yggdrasil: Entry Page                                                 *
 *                                                                         *
 *   Copyright (C) 2006-2011 by Leif B. Kristensen <*****@*****.**>   *
 *   All rights reserved. For terms of use, see LICENSE.txt                *
 ***************************************************************************/
require "./settings/settings.php";
require_once "./langs/{$language}.php";
$title = "{$_Index_and_name_search}";
$form = 'search';
$focus = 'given';
require "./functions.php";
require "./header.php";
$pcount = fetch_val("SELECT COUNT(*) FROM persons") - fetch_val("SELECT COUNT(*) FROM merged");
echo "<div class=\"normal\">";
echo "<h2>{$title} ({$pcount} {$_persons})</h2>\n";
// this is a rather special form compared to the rest of the package,
// hence it doesn't use the forms.php abstractions
echo "<form id=\"search\" action=\"" . $_SERVER['PHP_SELF'] . "\">\n<div>\n";
echo "{$_Given_name}: <input type=\"text\" size=\"12\" name=\"given\" />\n";
echo "\"{$_Surname}\": <input type=\"text\" size=\"12\" name=\"surname\" />\n";
echo "{$_Birth_year}: <input type=\"text\" size=\"8\" name=\"bdate\" />\n";
echo "&plusmn;<select name = \"diff\">\n";
echo "<option selected=\"selected\" value=\"0\"></option>\n";
echo "<option value=\"2\">2</option>\n";
echo "<option value=\"5\">5</option>\n";
echo "<option value=\"10\">10</option>\n";
echo "<option value=\"20\">20</option>\n";
echo "</select></td></tr>\n";
Пример #14
0
<?php

/***************************************************************************
 *   place_manager.php                                                     *
 *   Yggdrasil: Place Manager                                              *
 *                                                                         *
 *   Copyright (C) 2006-2011 by Leif B. Kristensen <*****@*****.**>   *
 *   All rights reserved. For terms of use, see LICENSE.txt                *
 ***************************************************************************/
require "./settings/settings.php";
require "./functions.php";
require_once "./langs/{$language}.php";
$title = "{$_Place_names}";
require "./header.php";
$count = fetch_val("SELECT COUNT(*) FROM places");
echo "<div class=\"normal\">\n";
echo "<h2>{$_Place_names} ({$count})</h2>\n";
echo "<p>( <a href=\"./forms/place_edit.php?place_id=0\">{$_insert}</a> )</p>\n";
echo "<table>\n";
$handle = pg_query("SELECT place_id, place_name, place_count FROM pm_view");
while ($row = pg_fetch_assoc($handle)) {
    echo "<tr>";
    if ($row['place_count'] == 0) {
        echo "<td><strong><a href=\"./forms/place_delete.php?place_id=" . $row['place_id'] . "\">{$_delete}</a></strong></td>";
    } else {
        echo "<td><a href=\"./place_view.php?place_id=" . $row['place_id'] . "\">{$_report}</a></td>";
    }
    echo "<td align=\"right\">" . $row['place_count'] . "</td>";
    echo "<td><a href=\"./forms/place_edit.php?place_id=" . $row['place_id'] . "\">" . $row['place_name'] . "</a></td>";
    echo "</tr>\n";
}
Пример #15
0
     }
     if ($merge_mothers) {
         // delete 'source' mother relationship, transfer citation(s)
         $relid_s = get_relation_id($source, 2);
         $relid_t = get_relation_id($target, 2);
         pg_query("\n                UPDATE relation_citations\n                SET relation_fk = {$relid_t}\n                WHERE relation_fk = {$relid_s}\n            ");
         pg_query("\n                DELETE FROM relations\n                WHERE relation_id = {$relid_s}\n            ");
     }
     // transfer remaining relations
     pg_query("\n            UPDATE relations\n            SET child_fk = {$target}\n            WHERE child_fk = {$source}\n        ");
     pg_query("\n            UPDATE relations\n            SET parent_fk = {$target}\n            WHERE parent_fk = {$source}\n        ");
     // update source_linkage
     pg_query("\n            UPDATE source_linkage\n            SET person_fk = {$target}\n            WHERE person_fk = {$source}\n        ");
     // insert "event" for source person with a link to target person
     $event_note = " [p={$target}|ID #{$target}]";
     $event = fetch_val("\n            INSERT INTO events (\n                tag_fk,\n                place_fk,\n                event_date,\n                sort_date,\n                event_note\n            )\n            VALUES (\n                1040,\n                1,\n                '000000003000000001',\n                '00010101',\n                '{$event_note}'\n            )\n            RETURNING event_id\n        ");
     add_participant($source, $event);
     pg_query("\n            INSERT INTO merged (old_person_fk,new_person_fk)\n            VALUES ({$source}, {$target})\n        ");
     set_last_edit($source);
     set_last_edit($target);
     pg_query("\n            COMMIT\n        ");
     // return to main view of "stripped" person.
     header("Location: {$app_root}/family.php?person={$source}");
 } else {
     // explain why the merge failed
     $title = "{$_App_name}: {$_Merge_persons_failed}";
     require "./form_header.php";
     echo "<h2>{$title}!</h2>\n";
     $name_1 = get_name($person_1);
     $name_2 = get_name($person_2);
     echo "<p>{$_Cannot_merge} {$name_1} ({$_born} {$bdate_1}), {$_with} {$name_2} ({$_born} {$bdate_2}).<br />\n";
Пример #16
0
    PRIMARY KEY (source_fk, per_id)
);
*/
require "../settings/settings.php";
require "../functions.php";
require "./forms.php";
require_once "../langs/{$language}.php";
if (!isset($_POST['posted'])) {
    $node = $_GET['node'];
    $title = "Lag lenke";
    $form = 'linkage_add';
    $focus = 'text';
    $per_id = fetch_val("SELECT COUNT(*) + 1 FROM source_linkage WHERE source_fk={$node}");
    require "./form_header.php";
    echo "<h2>Lag lenke</h2>\n";
    echo '<p>' . fetch_val("SELECT source_text FROM sources WHERE source_id={$node}") . "</p>\n";
    form_begin($form, $_SERVER['PHP_SELF']);
    hidden_input('posted', 1);
    hidden_input('node', $node);
    // per_id
    text_input("Lnr.: ", 10, 'per_id', $per_id);
    // role_fk
    select_role();
    person_id_input(0, 'person_id', 'Person:');
    select_surety();
    text_input("Navn i kilden: ", 100, 's_name');
    textarea_input("Note: ", 5, 100, 'sl_note');
    form_submit();
    form_end();
    echo "<h3>Personer nevnt i kilden:</h3>\n";
    list_mentioned($node, 0);
<?php

/***************************************************************************
 *   person_toggle_pf.php                                                  *
 *   Yggdrasil: Toggle private flag                                        *
 *                                                                         *
 *   Copyright (C) 2006-2011 by Leif B. Kristensen <*****@*****.**>   *
 *   All rights reserved. For terms of use, see LICENSE.txt                *
 ***************************************************************************/
require "../settings/settings.php";
require "../functions.php";
$person = $_GET['person'];
if (fetch_val("SELECT is_public({$person})") == 't') {
    pg_query("\n        INSERT INTO private_persons (person_fk)\n        VALUES ({$person})\n    ");
} else {
    pg_query("\n        DELETE FROM private_persons\n        WHERE person_fk = {$person}\n    ");
}
header("Location: {$app_root}/family.php?person={$person}");
Пример #18
0
<?php

/***************************************************************************
 *   tag_view.php                                                          *
 *   Yggdrasil: Tag View                                                   *
 *                                                                         *
 *   Copyright (C) 2006-2011 by Leif B. Kristensen <*****@*****.**>   *
 *   All rights reserved. For terms of use, see LICENSE.txt                *
 ***************************************************************************/
// This script is basically a report listing events and persons associated
// with a tag. It is accessed from the Tag Manager via the 'report' link.
require "./settings/settings.php";
require "./functions.php";
require_once "./langs/{$language}.php";
$tag = $_GET['tag'];
$tag_name = fetch_val("SELECT get_tag_name({$tag})");
$title = "{$_All} {$_events} {$_of} type {$tag_name}";
require "./header.php";
echo "<div class=\"normal\">\n";
echo "<h2>{$title}</h2>\n";
$handle = pg_query("\n    SELECT\n        event_id,\n        event_name,\n        event_date,\n        place_name,\n        p1,\n        p2\n    FROM\n        tag_events\n    WHERE\n        tag_fk = {$tag}\n    ORDER BY\n        event_date,\n        event_id\n");
while ($row = pg_fetch_assoc($handle)) {
    echo '<p>[' . $row['event_id'] . '] ';
    echo $row['event_name'];
    echo ' ' . fuzzydate($row['event_date']);
    echo ' ' . $row['place_name'] . ': ';
    echo list_participants($row['event_id']);
    // print source(s)
    $innerhandle = pg_query("\n    SELECT\n        source_text\n    FROM\n        event_notes\n    WHERE\n        note_id = " . $row['event_id']);
    while ($row = pg_fetch_assoc($innerhandle)) {
        echo conc(paren($_Source . ':' . conc(ltrim($row['source_text']))));
 *   A very very simple edit form, with one input field                    *
 *                                                                         *
 *   Copyright (C) 2006-2011 by Leif B. Kristensen <*****@*****.**>   *
 *   All rights reserved. For terms of use, see LICENSE.txt                *
 ***************************************************************************/
require "../settings/settings.php";
require_once "../langs/{$language}.php";
require "../functions.php";
require "./forms.php";
if (!isset($_POST['posted'])) {
    // do form
    $person = $_GET['person'];
    $event = $_GET['event'];
    $node = $_GET['node'];
    $name = get_name($person);
    $srt = fetch_val("\n        SELECT sort_order\n        FROM participants\n        WHERE person_fk = {$person}\n        AND event_fk = {$event}\n    ");
    $title = "Edit sort order for {$name} @ #{$event}";
    require "./form_header.php";
    echo "<h2>{$title}</h2>\n";
    // print paragraph with event text here
    form_begin('edit_event', $_SERVER['PHP_SELF']);
    hidden_input('person', $person);
    hidden_input('event', $event);
    hidden_input('node', $node);
    hidden_input('posted', 1);
    text_input("Sort order:", 10, 'srt', $srt);
    form_submit();
    form_end();
    echo "</body>\n</html>\n";
} else {
    // do action
Пример #20
0
if (!isset($_POST['posted'])) {
    $node = $_GET['node'];
    $title = "{$_Add_source}";
    $form = 'source_add';
    $focus = 'text';
    require "./form_header.php";
    // if there's a template for this source group, get it
    $template = fetch_val("\n        SELECT template\n        FROM templates\n        WHERE source_fk = {$node}\n    ");
    $part_type = fetch_val("\n        SELECT ch_part_type\n        FROM sources\n        WHERE source_id = {$node}\n    ");
    $spt_label = fetch_val("SELECT get_spt_label({$part_type})");
    echo "<h2>{$_Add_source} ({$spt_label})</h2>\n";
    form_begin($form, $_SERVER['PHP_SELF']);
    hidden_input('posted', 1);
    source_num_input("{$_Parent_node}:", 'node', $node);
    editarea_input("{$_Text}:", 20, 100, 'text', $template);
    if (fetch_val("\n        SELECT is_leaf FROM source_part_types WHERE part_type_id = {$part_type}\n    ") == 't') {
        hidden_input('template', false);
        hidden_input('part_type', $part_type);
        hidden_input('ch_part_type', 0);
    } else {
        textarea_input('Template:', 3, 100, 'template');
        select_source_type('Type:', 'part_type', $part_type);
        select_source_type("{$_Subtype}:", 'ch_part_type', 0);
    }
    text_input("{$_Sort_order}:", 20, 'sort');
    text_input("{$_Source_date}:", 20, 'source_date');
    form_submit();
    form_end();
    echo "</body>\n</html>\n";
} else {
    $node = $_POST['node'];
Пример #21
0
    }
    require "./form_header.php";
    echo "<h2>{$title}</h2>\n";
    form_begin('spt_edit', $_SERVER['PHP_SELF']);
    hidden_input('posted', 1);
    hidden_input('spt', $spt);
    text_input("Description:", 80, 'description', $description);
    text_input("Label (en):", 40, 'label_en', $label_en);
    text_input("Label (nb):", 40, 'label_nb', $label_nb);
    select_bool("Is leaf", 'is_leaf', $is_leaf);
    form_submit();
    form_end();
    echo "</body>\n</html>\n";
} else {
    $spt = $_POST['spt'];
    $description = $_POST['description'];
    $label_en = $_POST['label_en'];
    $label_nb = $_POST['label_nb'];
    $is_leaf = $_POST['is_leaf'];
    if ($spt == 0) {
        // insert new source part type
        pg_query("BEGIN");
        $spt = fetch_val("\n        SELECT MAX(part_type_id) FROM source_part_types\n        ") + 1;
        pg_query("\n            INSERT INTO source_part_types (\n                part_type_id,\n                description,\n                label_en,\n                label_nb,\n                is_leaf\n            )\n            VALUES (\n                {$spt},\n                '{$description}',\n                '{$label_en}',\n                '{$label_nb}',\n                '{$is_leaf}'\n            )");
        pg_query("COMMIT");
    } else {
        // modify existing tag
        pg_query("\n        UPDATE source_part_types SET\n                description = '{$description}',\n                label_en = '{$label_en}',\n                label_nb = '{$label_nb}',\n                is_leaf = '{$is_leaf}'\n            WHERE part_type_id = {$spt}");
    }
    header("Location: {$app_root}/spt_manager.php");
}
Пример #22
0
/***************************************************************************
 *   nolink.php                                                            *
 *   Yggdrasil: Unidentified people mentioned in sources                   *
 *   (Part of the experimental source linkage                              *
 *                                                                         *
 *   Copyright (C) 2009-2011 by Leif B. Kristensen <*****@*****.**>   *
 *   All rights reserved. For terms of use, see LICENSE.txt                *
 ***************************************************************************/
require "./settings/settings.php";
require_once "./langs/{$language}.php";
require "./functions.php";
$title = 'Uidentifiserte personer';
require "./header.php";
echo "<div class=\"normal\">\n";
echo "<h2>Uidentifiserte personer fra lenking:</h2>\n";
$handle = pg_query("\n    SELECT\n        s.source_id AS source,\n        part_ldesc(s.part_type) AS s_type,\n        get_lsurety(l.surety_fk) AS surety,\n        get_lrole(l.role_fk) AS rolle,\n        l.s_name AS name,\n        get_source_text(s.source_id) AS txt,\n        link_expand(l.sl_note) AS note\n    FROM\n        sources s,\n        source_linkage l\n    WHERE\n        l.source_fk = s.source_id\n    AND\n        l.person_fk IS NULL\n    ORDER BY\n        s.source_date,\n        s.sort_order,\n        l.per_id\n");
echo "<ol>\n";
while ($row = pg_fetch_assoc($handle)) {
    $principal = fetch_val("\n        SELECT person_fk FROM source_linkage\n        WHERE source_fk = " . $row['source'] . " AND role_fk = 1\n    ");
    echo "<li>" . bold($row['name']) . '<br />' . $row['surety'] . ' ' . $row['rolle'] . ' ved ' . $row['s_type'];
    if ($principal) {
        echo ' av ' . linked_name($principal, './family.php');
    }
    echo '. ' . $row['txt'];
    echo conc(italic($row['note']));
    echo conc(paren(to_url('./source_manager.php', array('node' => $row['source']), 'Til kildebehandler')));
    echo "</li>\n";
}
echo "</ol>\n";
echo "</div>\n";
include "./footer.php";
Пример #23
0
    }
    $tag = $_POST['tag_fk'];
    pg_query("BEGIN");
    $event = fetch_val("\n        INSERT INTO events (\n            tag_fk,\n            place_fk,\n            event_date,\n            sort_date,\n            event_note\n        )\n        VALUES (\n            {$tag},\n            {$place},\n            '{$event_date}',\n            '{$sort_date}',\n            '{$event_note}'\n        )\n        RETURNING event_id\n    ");
    set_last_selected_place($place);
    add_participant($person, $event);
    if ($_POST['coprincipal'] && has_coprincipal($tag)) {
        // constrain to events which allows for coprincipal, ie tag_type = 2
        $coprincipal = $_POST['coprincipal'];
        add_participant($coprincipal, $event);
    }
    if ($tag == 31) {
        // hard-coded reference to probate
        pg_query("SELECT generate_probate_witnesses({$event})");
    }
    $source_id = add_source($person, $tag, $event, $src, note_to_db($txt));
    $age = $_POST['age'];
    if ($age && is_numeric($age)) {
        // generate birth event
        add_birth($person, $event_date, $age, $source_id);
    }
    if ($tag == 3) {
        // hard-coded death tag, check if died young
        if ((died_young($person) || $age && $age < 16) && fetch_val("SELECT dead_child({$person})") == 'f') {
            pg_query("INSERT INTO dead_children (person_fk) VALUES ({$person})");
            pg_query("UPDATE persons SET toponym='' WHERE person_id = {$person}");
        }
    }
    pg_query("COMMIT");
    header("Location: {$app_root}/family.php?person={$person}");
}
Пример #24
0
    $handle = pg_query("SELECT source_fk FROM event_citations WHERE event_fk = {$event}");
    while ($row = pg_fetch_row($handle)) {
        echo '<p>' . $row[0] . ' ';
        echo fetch_val("SELECT get_source_text({$row['0']})");
        echo "</p>\n";
    }
    echo "</body>\n</html>\n";
} else {
    // do action
    $person = $_POST['person'];
    $event = $_POST['event'];
    $node = $_POST['node'];
    $note = note_to_db($_POST['note']);
    pg_query("BEGIN");
    // $note_exists will always be 0 or 1.
    $note_exists = fetch_val("SELECT COUNT(*) FROM participant_notes\n                    WHERE person_fk={$person} AND event_fk={$event}");
    if (!$note_exists && $note != '') {
        $query = "INSERT INTO participant_notes (person_fk, event_fk, part_note)\n                    VALUES ({$person}, {$event}, '{$note}')";
    } else {
        if ($note_exists && $note != '') {
            $query = "UPDATE participant_notes SET part_note='{$note}'\n                    WHERE person_fk={$person} AND event_fk={$event}";
        } else {
            if ($note_exists && $note == '') {
                $query = "DELETE FROM participant_notes\n                    WHERE person_fk={$person} AND event_fk={$event}";
            }
        }
    }
    pg_query($query);
    pg_query("COMMIT");
    if ($node) {
        // return to source manager
Пример #25
0
            // check for duplicates
            if (fetch_val("\n                SELECT\n                    COUNT(*)\n                FROM\n                    relation_citations\n                WHERE\n                    relation_fk = {$relation}\n                AND\n                    source_fk = {$source_id}\n            ") == 0) {
                pg_query("\n                    INSERT INTO relation_citations\n                    VALUES ({$relation}, {$source_id})\n                ");
            }
        }
    } else {
        if ($_POST['source_id']) {
            // if not bsource
            if ($_POST['source_text']) {
                // add new source
                $parent_id = $_POST['source_id'];
                $text = note_to_db($_POST['source_text']);
                // use two-param overload of add_source
                $source_id = fetch_val("SELECT add_source({$parent_id}, '{$text}')");
                // remove old citation if new source is an expansion,
                // ie. parent of new source == old source
                pg_query("\n                DELETE FROM\n                    relation_citations\n                WHERE\n                    relation_fk = {$relation}\n                AND\n                    source_fk = {$parent_id}\n            ");
            } else {
                $source_id = $_POST['source_id'];
            }
            // Entering the same source twice for the same relation will violate the
            // composite primary key (relation_fk, source_fk) constraint.
            // Test before trying to insert a relation citation.
            if ($relation && fetch_val("\n                    SELECT\n                        COUNT(*)\n                    FROM\n                        relation_citations\n                    WHERE\n                        relation_fk = {$relation}\n                    AND\n                        source_fk = {$source_id}\n                ") == 0) {
                pg_query("\n                INSERT INTO relation_citations\n                VALUES ({$relation}, {$source_id})\n            ");
            }
        }
    }
    pg_query("COMMIT");
    header("Location: {$app_root}/family.php?person={$person}");
}