Example #1
0
 public function getBlock($block_id, $template = true, $cfg = null)
 {
     global $ctype, $SHOW_COUNTER;
     $count_placement = get_block_setting($block_id, 'count_placement', 'before');
     $num = (int) get_block_setting($block_id, 'num', 10);
     $block = get_block_setting($block_id, 'block', false);
     if ($cfg) {
         foreach (array('count_placement', 'num', 'block') as $name) {
             if (array_key_exists($name, $cfg)) {
                 ${$name} = $cfg[$name];
             }
         }
     }
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) {
         $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>';
     } else {
         $title = '';
     }
     $title .= $this->getTitle();
     $content = "";
     // load the lines from the file
     $top10 = WT_DB::prepare("SELECT page_parameter, page_count" . " FROM `##hit_counter`" . " WHERE gedcom_id=? AND page_name IN ('individual.php','family.php','source.php','repo.php','note.php','mediaviewer.php')" . " ORDER BY page_count DESC LIMIT " . $num)->execute(array(WT_GED_ID))->FetchAssoc();
     if ($block) {
         $content .= "<table width=\"90%\">";
     } else {
         $content .= "<table>";
     }
     foreach ($top10 as $id => $count) {
         $record = WT_GedcomRecord::getInstance($id);
         if ($record && $record->canShow()) {
             $content .= '<tr valign="top">';
             if ($count_placement == 'before') {
                 $content .= '<td dir="ltr" align="right">[' . $count . ']</td>';
             }
             $content .= '<td class="name2" ><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></td>';
             if ($count_placement == 'after') {
                 $content .= '<td dir="ltr" align="right">[' . $count . ']</td>';
             }
             $content .= '</tr>';
         }
     }
     $content .= "</table>";
     if ($template) {
         if ($block) {
             require WT_THEME_DIR . 'templates/block_small_temp.php';
         } else {
             require WT_THEME_DIR . 'templates/block_main_temp.php';
         }
     } else {
         return $content;
     }
 }
Example #2
0
 protected function _canShowByType($access_level)
 {
     // Hide media objects if they are attached to private records
     $linked_ids = WT_DB::prepare("SELECT l_from FROM `##link` WHERE l_to=? AND l_file=?")->execute(array($this->xref, $this->gedcom_id))->fetchOneColumn();
     foreach ($linked_ids as $linked_id) {
         $linked_record = WT_GedcomRecord::getInstance($linked_id);
         if ($linked_record && !$linked_record->canShow($access_level)) {
             return false;
         }
     }
     // ... otherwise apply default behaviour
     return parent::_canShowByType($access_level);
 }
Example #3
0
 public function modAction($modAction)
 {
     global $controller;
     switch ($modAction) {
         case 'menu-add-favorite':
             // Process the "add to user favorites" menu item on indi/fam/etc. pages
             $record = WT_GedcomRecord::getInstance(WT_Filter::post('xref', WT_REGEX_XREF));
             if (WT_USER_ID && $record->canShowName()) {
                 self::addFavorite(array('user_id' => WT_USER_ID, 'gedcom_id' => $record->getGedcomId(), 'gid' => $record->getXref(), 'type' => $record::RECORD_TYPE, 'url' => null, 'note' => null, 'title' => null));
                 WT_FlashMessages::addMessage(WT_I18N::translate('“%s” has been added to your favorites.', $record->getFullName()));
             }
             break;
     }
 }
Example #4
0
 function __construct($xref, $gedcom, $pending, $gedcom_id)
 {
     parent::__construct($xref, $gedcom, $pending, $gedcom_id);
     // Fetch husband and wife
     if (preg_match('/^1 HUSB @(.+)@/m', $gedcom . $pending, $match)) {
         $this->husb = WT_Individual::getInstance($match[1]);
     }
     if (preg_match('/^1 WIFE @(.+)@/m', $gedcom . $pending, $match)) {
         $this->wife = WT_Individual::getInstance($match[1]);
     }
     // Make sure husb/wife are the right way round.
     if ($this->husb && $this->husb->getSex() == 'F' || $this->wife && $this->wife->getSex() == 'M') {
         list($this->husb, $this->wife) = array($this->wife, $this->husb);
     }
 }
Example #5
0
 public function __construct()
 {
     // Automatically fix broken links
     if ($this->record && $this->record->canEdit()) {
         $broken_links = 0;
         foreach ($this->record->getFacts('HUSB|WIFE|CHIL|FAMS|FAMC|REPO') as $fact) {
             if (!$fact->isOld() && $fact->getTarget() === null) {
                 $this->record->deleteFact($fact->getFactId(), false);
                 WT_FlashMessages::addMessage(WT_I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $this->record->getFullName(), $fact->getValue()));
                 $broken_links = true;
             }
         }
         foreach ($this->record->getFacts('NOTE|SOUR|OBJE') as $fact) {
             // These can be links or inline.  Only delete links.
             if (!$fact->isOld() && $fact->getTarget() === null && preg_match('/^@.*@$/', $fact->getValue())) {
                 $this->record->deleteFact($fact->getFactId(), false);
                 WT_FlashMessages::addMessage(WT_I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $this->record->getFullName(), $fact->getValue()));
                 $broken_links = true;
             }
         }
         if ($broken_links) {
             // Reload the updated family
             $this->record = WT_GedcomRecord::getInstance($this->record->getXref());
         }
     }
     parent::__construct();
     // We want robots to index this page
     $this->setMetaRobots('index,follow');
     // Set a page title
     if ($this->record) {
         $this->setCanonicalUrl($this->record->getHtmlUrl());
         if ($this->record->canShowName()) {
             // e.g. "John Doe" or "1881 Census of Wales"
             $this->setPageTitle($this->record->getFullName());
         } else {
             // e.g. "Individual" or "Source"
             $record = $this->record;
             $this->setPageTitle(WT_Gedcom_Tag::getLabel($record::RECORD_TYPE));
         }
     } else {
         // No such record
         $this->setPageTitle(WT_I18N::translate('Private'));
     }
 }
Example #6
0
function create_edit_form(WT_GedcomRecord $record, WT_Fact $fact)
{
    global $ADVANCED_PLAC_FACTS, $date_and_time, $FULL_SOURCES, $tags;
    $pid = $record->getXref();
    $tags = array();
    $gedlines = explode("\n", $fact->getGedcom());
    $linenum = 0;
    $fields = explode(' ', $gedlines[$linenum]);
    $glevel = $fields[0];
    $level = $glevel;
    $type = $fact->getTag();
    $parent = $fact->getParent();
    $level0type = $parent::RECORD_TYPE;
    $level1type = $type;
    $i = $linenum;
    $inSource = false;
    $levelSource = 0;
    $add_date = true;
    // List of tags we would expect at the next level
    // NB add_missing_subtags() already takes care of the simple cases
    // where a level 1 tag is missing a level 2 tag.  Here we only need to
    // handle the more complicated cases.
    $expected_subtags = array('SOUR' => array('PAGE', 'DATA'), 'DATA' => array('TEXT'), 'PLAC' => array('MAP'), 'MAP' => array('LATI', 'LONG'));
    if ($FULL_SOURCES) {
        $expected_subtags['SOUR'][] = 'QUAY';
        $expected_subtags['DATA'][] = 'DATE';
    }
    if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $ADVANCED_PLAC_FACTS, $match)) {
        $expected_subtags['PLAC'] = array_merge($match[1], $expected_subtags['PLAC']);
    }
    $stack = array(0 => $level0type);
    // Loop on existing tags :
    while (true) {
        // Keep track of our hierarchy, e.g. 1=>BIRT, 2=>PLAC, 3=>FONE
        $stack[(int) $level] = $type;
        // Merge them together, e.g. BIRT:PLAC:FONE
        $label = implode(':', array_slice($stack, 1, $level));
        $text = '';
        for ($j = 2; $j < count($fields); $j++) {
            if ($j > 2) {
                $text .= ' ';
            }
            $text .= $fields[$j];
        }
        $text = rtrim($text);
        while ($i + 1 < count($gedlines) && preg_match("/" . ($level + 1) . " CONT ?(.*)/", $gedlines[$i + 1], $cmatch) > 0) {
            $text .= "\n" . $cmatch[1];
            $i++;
        }
        if ($type == "SOUR") {
            $inSource = true;
            $levelSource = $level;
        } elseif ($levelSource >= $level) {
            $inSource = false;
        }
        if ($type != "DATA" && $type != "CONT") {
            $tags[] = $type;
            $person = WT_Individual::getInstance($pid);
            $subrecord = $level . ' ' . $type . ' ' . $text;
            if ($inSource && $type == "DATE") {
                add_simple_tag($subrecord, '', WT_Gedcom_Tag::getLabel($label, $person));
            } elseif (!$inSource && $type == "DATE") {
                add_simple_tag($subrecord, $level1type, WT_Gedcom_Tag::getLabel($label, $person));
                $add_date = false;
            } elseif ($type == 'STAT') {
                add_simple_tag($subrecord, $level1type, WT_Gedcom_Tag::getLabel($label, $person));
            } elseif ($level0type == 'REPO') {
                $repo = WT_Repository::getInstance($pid);
                add_simple_tag($subrecord, $level0type, WT_Gedcom_Tag::getLabel($label, $repo));
            } else {
                add_simple_tag($subrecord, $level0type, WT_Gedcom_Tag::getLabel($label, $person));
            }
        }
        // Get a list of tags present at the next level
        $subtags = array();
        for ($ii = $i + 1; isset($gedlines[$ii]) && preg_match('/^\\s*(\\d+)\\s+(\\S+)/', $gedlines[$ii], $mm) && $mm[1] > $level; ++$ii) {
            if ($mm[1] == $level + 1) {
                $subtags[] = $mm[2];
            }
        }
        // Insert missing tags
        if (!empty($expected_subtags[$type])) {
            foreach ($expected_subtags[$type] as $subtag) {
                if (!in_array($subtag, $subtags)) {
                    if (!$inSource || $subtag != "DATA") {
                        add_simple_tag($level + 1 . ' ' . $subtag, '', WT_Gedcom_Tag::getLabel("{$label}:{$subtag}"));
                    }
                    if (!empty($expected_subtags[$subtag])) {
                        foreach ($expected_subtags[$subtag] as $subsubtag) {
                            add_simple_tag($level + 2 . ' ' . $subsubtag, '', WT_Gedcom_Tag::getLabel("{$label}:{$subtag}:{$subsubtag}"));
                        }
                    }
                }
            }
        }
        // Awkward special cases
        if ($level == 2 && $type == 'DATE' && in_array($level1type, $date_and_time) && !in_array('TIME', $subtags)) {
            add_simple_tag("3 TIME");
            // TIME is NOT a valid 5.5.1 tag
        }
        if ($level == 2 && $type == 'STAT' && WT_Gedcom_Code_Temp::isTagLDS($level1type) && !in_array('DATE', $subtags)) {
            add_simple_tag("3 DATE", '', WT_Gedcom_Tag::getLabel('STAT:DATE'));
        }
        $i++;
        if (isset($gedlines[$i])) {
            $fields = explode(' ', $gedlines[$i]);
            $level = $fields[0];
            if (isset($fields[1])) {
                $type = trim($fields[1]);
            } else {
                $level = 0;
            }
        } else {
            $level = 0;
        }
        if ($level <= $glevel) {
            break;
        }
    }
    if ($level1type != '_PRIM') {
        insert_missing_subtags($level1type, $add_date);
    }
    return $level1type;
}
Example #7
0
        if ($linkto == "repository") {
            echo WT_I18N::translate('Repository'), "</td>";
            echo '<td  class="optionbox wrap">';
            if ($linktoid == "") {
                echo '<input class="pedigree_form" type="text" name="linktoid" id="linktorid" size="3" value="', $linktoid, '">';
            } else {
                $record = WT_Repository::getInstance($linktoid);
                echo $record->format_list('span', false, $record->getFullName());
            }
        }
        if ($linkto == "note") {
            echo WT_I18N::translate('Shared note'), "</td>";
            echo '<td  class="optionbox wrap">';
            if ($linktoid == "") {
                echo '<input class="pedigree_form" type="text" name="linktoid" id="linktonid" size="3" value="', $linktoid, '">';
            } else {
                $record = WT_Note::getInstance($linktoid);
                echo $record->format_list('span', false, $record->getFullName());
            }
        }
        echo '</td></tr>';
        echo '<tr><td class="topbottombar" colspan="2"><input type="submit" value="', WT_I18N::translate('Set link'), '"></td></tr>';
        echo '</table>';
        echo '</form>';
    } elseif ($action == "update" && $paramok) {
        $record = WT_GedcomRecord::getInstance($linktoid);
        $record->createFact('1 OBJE @' . $mediaid . '@', true);
        $controller->addInlineJavascript('closePopupAndReloadParent();');
    }
    echo '<button onclick="closePopupAndReloadParent();">', WT_I18N::translate('close'), '</button>';
}
Example #8
0
 public function getCartList()
 {
     global $WT_SESSION;
     // Keep track of the INDI from the parent page, otherwise it will
     // get lost after ajax updates
     $pid = WT_Filter::get('pid', WT_REGEX_XREF);
     if (!$WT_SESSION->cart[WT_GED_ID]) {
         $out = WT_I18N::translate('Your clippings cart is empty.');
     } else {
         $out = '<ul>';
         foreach (array_keys($WT_SESSION->cart[WT_GED_ID]) as $xref) {
             $record = WT_GedcomRecord::getInstance($xref);
             if ($record && ($record::RECORD_TYPE == 'INDI' || $record::RECORD_TYPE == 'FAM')) {
                 // Just show INDI/FAM in the sidbar
                 switch ($record::RECORD_TYPE) {
                     case 'INDI':
                         $icon = 'icon-indis';
                         break;
                     case 'FAM':
                         $icon = 'icon-sfamily';
                         break;
                 }
                 $out .= '<li>';
                 if (!empty($icon)) {
                     $out .= '<i class="' . $icon . '"></i>';
                 }
                 $out .= '<a href="' . $record->getHtmlUrl() . '">';
                 if ($record::RECORD_TYPE == 'INDI') {
                     $out .= $record->getSexImage();
                 }
                 $out .= ' ' . $record->getFullName() . ' ';
                 if ($record::RECORD_TYPE == 'INDI' && $record->canShow()) {
                     $out .= ' (' . $record->getLifeSpan() . ')';
                 }
                 $out .= '</a>';
                 $out .= '<a class="icon-remove remove_cart" href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;sb_action=clippings&amp;remove=' . $xref . '&amp;pid=' . $pid . '" title="' . WT_I18N::translate('Remove') . '"></a>';
                 $out .= '</li>';
             }
         }
         $out .= '</ul>';
     }
     if ($WT_SESSION->cart[WT_GED_ID]) {
         $out .= '<br><a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;sb_action=clippings&amp;empty=true&amp;pid=' . $pid . '" class="remove_cart">' . WT_I18N::translate('Empty the clippings cart') . '</a>' . help_link('empty_cart', $this->getName()) . '<br>' . '<a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;sb_action=clippings&amp;download=true&amp;pid=' . $pid . '" class="add_cart">' . WT_I18N::translate('Download') . '</a>';
     }
     $record = WT_Individual::getInstance($pid);
     if ($record && !array_key_exists($record->getXref(), $WT_SESSION->cart[WT_GED_ID])) {
         $out .= '<br><a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;sb_action=clippings&amp;add=' . $pid . '&amp;pid=' . $pid . '" class="add_cart"><i class="icon-clippings"></i> ' . WT_I18N::translate('Add %s to the clippings cart', $record->getFullName()) . '</a>';
     }
     return $out;
 }
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>';
    }
}
Example #10
0
 public function getBlock($block_id, $template = true, $cfg = null)
 {
     global $ctype, $WEBTREES_EMAIL;
     $changes = WT_DB::prepare("SELECT 1" . " FROM `##change`" . " WHERE status='pending'" . " LIMIT 1")->fetchOne();
     $days = get_block_setting($block_id, 'days', 1);
     $sendmail = get_block_setting($block_id, 'sendmail', true);
     $block = get_block_setting($block_id, 'block', true);
     if ($cfg) {
         foreach (array('days', 'sendmail', 'block') as $name) {
             if (array_key_exists($name, $cfg)) {
                 ${$name} = $cfg[$name];
             }
         }
     }
     if ($changes && $sendmail == 'yes') {
         // There are pending changes - tell moderators/managers/administrators about them.
         if (WT_TIMESTAMP - WT_Site::getPreference('LAST_CHANGE_EMAIL') > 60 * 60 * 24 * $days) {
             // Which users have pending changes?
             foreach (User::all() as $user) {
                 if ($user->getSetting('contactmethod') !== 'none') {
                     foreach (WT_Tree::getAll() as $tree) {
                         if (exists_pending_change($user, $tree)) {
                             WT_I18N::init($user->getSetting('language'));
                             WT_Mail::systemMessage($tree, $user, WT_I18N::translate('Pending changes'), WT_I18N::translate('There are pending changes for you to moderate.') . WT_Mail::EOL . WT_MAIL::EOL . '<a href="' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'index.php?ged=' . WT_GEDURL . '">' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'index.php?ged=' . WT_GEDURL . '</a>');
                             WT_I18N::init(WT_LOCALE);
                         }
                     }
                 }
             }
             WT_Site::setPreference('LAST_CHANGE_EMAIL', WT_TIMESTAMP);
         }
         if (WT_USER_CAN_EDIT) {
             $id = $this->getName() . $block_id;
             $class = $this->getName() . '_block';
             if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) {
                 $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>';
             } else {
                 $title = '';
             }
             $title .= $this->getTitle() . help_link('review_changes', $this->getName());
             $content = '';
             if (WT_USER_CAN_ACCEPT) {
                 $content .= "<a href=\"#\" onclick=\"window.open('edit_changes.php','_blank', chan_window_specs); return false;\">" . WT_I18N::translate('There are pending changes for you to moderate.') . "</a><br>";
             }
             if ($sendmail == "yes") {
                 $content .= WT_I18N::translate('Last email reminder was sent ') . format_timestamp(WT_Site::getPreference('LAST_CHANGE_EMAIL')) . "<br>";
                 $content .= WT_I18N::translate('Next email reminder will be sent after ') . format_timestamp(WT_Site::getPreference('LAST_CHANGE_EMAIL') + 60 * 60 * 24 * $days) . "<br><br>";
             }
             $changes = WT_DB::prepare("SELECT xref" . " FROM  `##change`" . " WHERE status='pending'" . " AND   gedcom_id=?" . " GROUP BY xref")->execute(array(WT_GED_ID))->fetchAll();
             foreach ($changes as $change) {
                 $record = WT_GedcomRecord::getInstance($change->xref);
                 if ($record->canShow()) {
                     $content .= '<b>' . $record->getFullName() . '</b>';
                     $content .= $block ? '<br>' : ' ';
                     $content .= '<a href="' . $record->getHtmlUrl() . '">' . WT_I18N::translate('View the changes') . '</a>';
                     $content .= '<br>';
                 }
             }
             if ($template) {
                 if ($block) {
                     require WT_THEME_DIR . 'templates/block_small_temp.php';
                 } else {
                     require WT_THEME_DIR . 'templates/block_main_temp.php';
                 }
             } else {
                 return $content;
             }
         }
     }
 }
Example #11
0
 public static function getFavoritesMenu()
 {
     global $REQUIRE_AUTHENTICATION, $controller, $SEARCH_SPIDER;
     $show_user_favs = WT_USER_ID && array_key_exists('user_favorites', WT_Module::getActiveModules());
     $show_gedc_favs = !$REQUIRE_AUTHENTICATION && array_key_exists('gedcom_favorites', WT_Module::getActiveModules());
     if ($show_user_favs && !$SEARCH_SPIDER) {
         if ($show_gedc_favs && !$SEARCH_SPIDER) {
             $favorites = array_merge(gedcom_favorites_WT_Module::getFavorites(WT_GED_ID), user_favorites_WT_Module::getFavorites(WT_USER_ID));
         } else {
             $favorites = user_favorites_WT_Module::getFavorites(WT_USER_ID);
         }
     } else {
         if ($show_gedc_favs && !$SEARCH_SPIDER) {
             $favorites = gedcom_favorites_WT_Module::getFavorites(WT_GED_ID);
         } else {
             return null;
         }
     }
     // Sort $favorites alphabetically?
     $menu = new WT_Menu(WT_I18N::translate('Favorites'), '#', 'menu-favorites');
     foreach ($favorites as $favorite) {
         switch ($favorite['type']) {
             case 'URL':
                 $submenu = new WT_Menu($favorite['title'], $favorite['url']);
                 $menu->addSubMenu($submenu);
                 break;
             case 'INDI':
             case 'FAM':
             case 'SOUR':
             case 'OBJE':
             case 'NOTE':
                 $obj = WT_GedcomRecord::getInstance($favorite['gid']);
                 if ($obj && $obj->canShowName()) {
                     $submenu = new WT_Menu($obj->getFullName(), $obj->getHtmlUrl());
                     $menu->addSubMenu($submenu);
                 }
                 break;
         }
     }
     if ($show_user_favs) {
         if (isset($controller->record) && $controller->record instanceof WT_GedcomRecord) {
             $submenu = new WT_Menu(WT_I18N::translate('Add to favorites'), '#');
             $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&amp;mod_action=menu-add-favorite',{xref:'" . $controller->record->getXref() . "'},function(){location.reload();})");
             $menu->addSubMenu($submenu);
         }
     }
     return $menu;
 }
Example #12
0
function calendar_list_text($list, $tag1, $tag2, $show_sex_symbols)
{
    global $males, $females;
    $html = '';
    foreach ($list as $id => $facts) {
        $tmp = WT_GedcomRecord::GetInstance($id);
        $html .= $tag1 . '<a href="' . $tmp->getHtmlUrl() . '">' . $tmp->getFullName() . '</a> ';
        if ($show_sex_symbols && $tmp instanceof WT_Individual) {
            switch ($tmp->getSex()) {
                case 'M':
                    $html .= '<i class="icon-sex_m_9x9" title="' . WT_I18N::translate('Male') . '"></i>';
                    ++$males;
                    break;
                case 'F':
                    $html .= '<i class="icon-sex_f_9x9" title="' . WT_I18N::translate('Female') . '"></i>';
                    ++$females;
                    break;
                default:
                    $html .= '<i class="icon-sex_u_9x9" title="' . WT_I18N::translate_c('unknown gender', 'Unknown') . '"></i>';
                    break;
            }
        }
        $html .= '<div class="indent">' . $facts . '</div>' . $tag2;
    }
    return $html;
}
Example #13
0
 static function compareClippings($a, $b)
 {
     $a = WT_GedcomRecord::getInstance($a);
     $b = WT_GedcomRecord::getInstance($b);
     if ($a && $b) {
         switch ($a::RECORD_TYPE) {
             case 'INDI':
                 $t1 = 1;
                 break;
             case 'FAM':
                 $t1 = 2;
                 break;
             case 'SOUR':
                 $t1 = 3;
                 break;
             case 'REPO':
                 $t1 = 4;
                 break;
             case 'OBJE':
                 $t1 = 5;
                 break;
             case 'NOTE':
                 $t1 = 6;
                 break;
             default:
                 $t1 = 7;
                 break;
         }
         switch ($b::RECORD_TYPE) {
             case 'INDI':
                 $t2 = 1;
                 break;
             case 'FAM':
                 $t2 = 2;
                 break;
             case 'SOUR':
                 $t2 = 3;
                 break;
             case 'REPO':
                 $t2 = 4;
                 break;
             case 'OBJE':
                 $t2 = 5;
                 break;
             case 'NOTE':
                 $t2 = 6;
                 break;
             default:
                 $t2 = 7;
                 break;
         }
         if ($t1 != $t2) {
             return $t1 - $t2;
         } else {
             return WT_GedcomRecord::compare($a, $b);
         }
     } else {
         return 0;
     }
 }
Example #14
0
function check_record_access(WT_GedcomRecord $object = null)
{
    global $controller;
    if (!$object || !$object->canShow() || !$object->canEdit()) {
        $controller->pageHeader()->addInlineJavascript('closePopupAndReloadParent();');
        exit;
    }
}
Example #15
0
 public function deleteRecord()
 {
     // Create a pending change
     WT_DB::prepare("INSERT INTO `##change` (gedcom_id, xref, old_gedcom, new_gedcom, user_id) VALUES (?, ?, ?, '', ?)")->execute(array($this->gedcom_id, $this->xref, $this->getGedcom(), Auth::id()));
     // Accept this pending change
     if (Auth::user()->getSetting('auto_accept')) {
         accept_all_changes($this->xref, $this->gedcom_id);
     }
     // Clear the cache
     self::$gedcom_record_cache = null;
     self::$pending_record_cache = null;
     Log::addEditLog('Delete: ' . static::RECORD_TYPE . ' ' . $this->xref);
 }
Example #16
0
 public function getTarget()
 {
     $xref = trim($this->getValue(), '@');
     switch ($this->tag) {
         case 'FAMC':
         case 'FAMS':
             return WT_Family::getInstance($xref, $this->getParent()->getGedcomId());
         case 'HUSB':
         case 'WIFE':
         case 'CHIL':
             return WT_Individual::getInstance($xref, $this->getParent()->getGedcomId());
         case 'SOUR':
             return WT_Source::getInstance($xref, $this->getParent()->getGedcomId());
         case 'OBJE':
             return WT_Media::getInstance($xref, $this->getParent()->getGedcomId());
         case 'REPO':
             return WT_Repository::getInstance($xref, $this->getParent()->getGedcomId());
         case 'NOTE':
             return WT_Note::getInstance($xref, $this->getParent()->getGedcomId());
         default:
             return WT_GedcomRecord::getInstance($xref, $this->getParent()->getGedcomId());
     }
 }
Example #17
0
echo ' ', print_findnote_link('xref');
echo ' ', print_findmedia_link('xref', '1media');
echo '</td><td>';
echo select_edit_control('tag_type', $all_tags, '', null, null);
echo '</td><td>';
echo select_edit_control('resn', $PRIVACY_CONSTANTS, null, 'privacy', null);
echo '</td><td>';
echo '<input type="button" value="', WT_I18N::translate('Add'), '" onClick="document.configform.elements[\'action\'].value=\'add\';document.configform.submit();">';
echo '<input type="hidden" name="default_resn_id" value="">';
// value set by JS
echo '</td></tr>';
$rows = WT_DB::prepare("SELECT default_resn_id, tag_type, xref, resn" . " FROM `##default_resn`" . " LEFT JOIN `##name` ON (gedcom_id=n_file AND xref=n_id AND n_num=0)" . " WHERE gedcom_id=?" . " ORDER BY xref IS NULL, n_sort, xref, tag_type")->execute(array(WT_GED_ID))->fetchAll();
foreach ($rows as $row) {
    echo '<tr><td>';
    if ($row->xref) {
        $record = WT_GedcomRecord::getInstance($row->xref);
        if ($record) {
            echo '<a href="', $record->getHtmlUrl(), '">', $record->getFullName(), '</a>';
        } else {
            echo WT_I18N::translate('this record does not exist');
        }
    } else {
        echo '&nbsp;';
    }
    echo '</td><td>';
    if ($row->tag_type) {
        // I18N: e.g. Marriage (MARR)
        echo WT_Gedcom_Tag::getLabel($row->tag_type);
    } else {
        echo '&nbsp;';
    }
	<p id="save-cancel">
		<input type="submit" class="save" value="<?php 
    echo WT_I18N::translate('save');
    ?>
" onclick="shiftlinks();">
		<input type="button" class="cancel" value="<?php 
    echo WT_I18N::translate('close');
    ?>
" onclick="window.close();">
	</p>
</form>
<?php 
} elseif ($action == "update" && $paramok) {
    // Unlink records indicated by radio button =========
    if ($exist_links) {
        foreach (explode(',', $exist_links) as $remLinkId) {
            $indi = WT_GedcomRecord::getInstance($remLinkId);
            $indi->removeLinks($mediaid, $update_CHAN != 'no_change');
        }
    }
    // Add new Links ====================================
    if ($more_links) {
        // array_unique() because parseAddLinks() may includes the gid field, even
        // when it is also in the list.
        foreach (array_unique(explode(',', $more_links)) as $addLinkId) {
            $indi = WT_GedcomRecord::getInstance($addLinkId);
            $indi->createFact('1 OBJE @' . $mediaid . '@', $update_CHAN != 'no_change');
        }
    }
    $controller->addInlineJavascript('closePopupAndReloadParent();');
}
Example #19
0
function event_sort_name($a, $b)
{
    if ($a['jd'] == $b['jd']) {
        return WT_GedcomRecord::compare($a['record'], $b['record']);
    } else {
        return $a['jd'] - $b['jd'];
    }
}
Example #20
0
 public function extractNames()
 {
     parent::_extractNames(1, 'TITL', $this->getFacts('TITL'));
 }
Example #21
0
/**
 * XML </ Relatives> end element handler
 *
 * @see RelativesSHandler()
 */
function RelativesEHandler()
{
    global $list, $repeats, $repeatsStack, $repeatBytes, $parser, $parserStack, $report, $gedrec, $processRepeats, $list_total, $list_private, $generation;
    $processRepeats--;
    if ($processRepeats > 0) {
        return;
    }
    // Check if there is any relatives
    if (count($list) > 0) {
        // @deprecated
        //$line = xml_get_current_line_number($parser)-1;
        $lineoffset = 0;
        foreach ($repeatsStack as $rep) {
            $lineoffset += $rep[1];
        }
        //-- read the xml from the file
        $lines = file($report);
        while (strpos($lines[$lineoffset + $repeatBytes], "<Relatives") === false && $lineoffset + $repeatBytes > 0) {
            $lineoffset--;
        }
        $lineoffset++;
        $reportxml = "<tempdoc>\n";
        $line_nr = $lineoffset + $repeatBytes;
        // Relatives Level counter
        $count = 1;
        while (0 < $count) {
            if (strpos($lines[$line_nr], "<Relatives") !== false) {
                $count++;
            } elseif (strpos($lines[$line_nr], "</Relatives") !== false) {
                $count--;
            }
            if (0 < $count) {
                $reportxml .= $lines[$line_nr];
            }
            $line_nr++;
        }
        // No need to drag this
        unset($lines);
        $reportxml .= "</tempdoc>\n";
        // Save original values
        array_push($parserStack, $parser);
        $oldgedrec = $gedrec;
        $list_total = count($list);
        $list_private = 0;
        foreach ($list as $key => $value) {
            if (isset($value->generation)) {
                $generation = $value->generation;
            }
            $tmp = WT_GedcomRecord::getInstance($key);
            $gedrec = $tmp->privatizeGedcom(WT_USER_ACCESS_LEVEL);
            //-- 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)) {
                printf($reportxml . "\nRelativesEHandler XML error: %s at line %d", xml_error_string(xml_get_error_code($repeat_parser)), xml_get_current_line_number($repeat_parser));
                exit;
            }
            xml_parser_free($repeat_parser);
        }
        // Clean up the GLOBAL list array
        unset($list);
        $parser = array_pop($parserStack);
        $gedrec = $oldgedrec;
    }
    $temp = array_pop($repeatsStack);
    $repeats = $temp[0];
    $repeatBytes = $temp[1];
}
Example #22
0
             echo '></td>';
             echo '<td>', nl2br(WT_Filter::escapeHtml($fact2->getGedcom()), false), '</td></tr>';
         }
     }
     echo '</table>';
     echo '</td></tr>';
     echo '</table>';
     echo '<input type="submit" value="', WT_I18N::translate('save'), '">';
     echo '</form></div>';
 } elseif ($action == 'merge') {
     echo '<div id="merge3"><h3>', WT_I18N::translate('Merge records'), '</h3>';
     if ($GEDCOM == $ged2) {
         //-- replace all the records that linked to gid2
         $ids = fetch_all_links($gid2, WT_GED_ID);
         foreach ($ids as $id) {
             $record = WT_GedcomRecord::getInstance($id);
             if (!$record->isOld()) {
                 echo WT_I18N::translate('Updating linked record'), ' ', $id, '<br>';
                 $gedcom = str_replace("@{$gid2}@", "@{$gid1}@", $record->getGedcom());
                 $gedcom = preg_replace('/(\\n1.*@.+@.*(?:(?:\\n[2-9].*)*))((?:\\n1.*(?:\\n[2-9].*)*)*\\1)/', '$2', $gedcom);
                 $record->updateRecord($gedcom, true);
             }
         }
         // Update any linked user-accounts
         WT_DB::prepare("UPDATE `##user_gedcom_setting`" . " SET setting_value=?" . " WHERE gedcom_id=? AND setting_name='gedcomid' AND setting_value=?")->execute(array($gid2, WT_GED_ID, $gid1));
         // Merge hit counters
         $hits = WT_DB::prepare("SELECT page_name, SUM(page_count)" . " FROM `##hit_counter`" . " WHERE gedcom_id=? AND page_parameter IN (?, ?)" . " GROUP BY page_name")->execute(array(WT_GED_ID, $gid1, $gid2))->fetchAssoc();
         foreach ($hits as $page_name => $page_count) {
             WT_DB::prepare("UPDATE `##hit_counter` SET page_count=?" . " WHERE gedcom_id=? AND page_name=? AND page_parameter=?")->execute(array($page_count, WT_GED_ID, $page_name, $gid1));
         }
         WT_DB::prepare("DELETE FROM `##hit_counter`" . " WHERE gedcom_id=? AND page_parameter=?")->execute(array(WT_GED_ID, $gid2));
Example #23
0
 public function extractNames()
 {
     parent::_extractNames(1, 'NAME', $this->getFacts('NAME'));
 }
Example #24
0
                         // Level 1 links
                         $source->deleteFact($fact->getFactId(), true);
                     } elseif (strpos($fact->getGedcom(), ' @' . $target . '@')) {
                         // Level 2-3 links
                         $source->updateFact($fact->getFactId(), preg_replace(array('/\\n2 OBJE @' . $target . '@(\\n[3-9].*)*/', '/\\n3 OBJE @' . $target . '@(\\n[4-9].*)*/'), '', $fact->getGedcom()), true);
                     }
                 }
             }
         }
     } else {
         header('HTTP/1.0 406 Not Acceptable');
     }
     break;
 case 'reject-changes':
     // Reject all the pending changes for a record
     $record = WT_GedcomRecord::getInstance(WT_Filter::post('xref', WT_REGEX_XREF));
     if ($record && WT_USER_CAN_ACCEPT && $record->canShow() && $record->canEdit()) {
         WT_FlashMessages::addMessage(WT_I18N::translate('The changes to “%s” have been rejected.', $record->getFullName()));
         reject_all_changes($record->getXref(), $record->getGedcomId());
     } else {
         header('HTTP/1.0 406 Not Acceptable');
     }
     break;
 case 'theme':
     // Change the current theme
     $theme_dir = WT_Filter::post('theme');
     if (WT_Site::getPreference('ALLOW_USER_THEMES') && in_array($theme_dir, get_theme_names())) {
         $WT_SESSION->theme_dir = $theme_dir;
         if (Auth::id()) {
             // Remember our selection
             Auth::user()->setSetting('theme', $theme_dir);
/**
 * print a list of events
 *
 * This performs the same function as print_events_table(), but formats the output differently.
 */
function print_events_list($startjd, $endjd, $events = 'BIRT MARR DEAT', $only_living = false, $sort_by = 'anniv')
{
    // Did we have any output?  Did we skip anything?
    $output = 0;
    $filter = 0;
    $filtered_events = array();
    $html = '';
    foreach (get_events_list($startjd, $endjd, $events) as $fact) {
        $record = $fact->getParent();
        //-- only living people ?
        if ($only_living) {
            if ($record instanceof WT_Individual && $record->isDead()) {
                $filter++;
                continue;
            }
            if ($record instanceof WT_Family) {
                $husb = $record->getHusband();
                if (is_null($husb) || $husb->isDead()) {
                    $filter++;
                    continue;
                }
                $wife = $record->getWife();
                if (is_null($wife) || $wife->isDead()) {
                    $filter++;
                    continue;
                }
            }
        }
        $output++;
        $filtered_events[] = $fact;
    }
    // Now we've filtered the list, we can sort by event, if required
    switch ($sort_by) {
        case 'anniv':
            uasort($filtered_events, function ($x, $y) {
                return WT_Date::compare($y->getDate(), $x->getDate());
                // most recent first
            });
            break;
        case 'alpha':
            uasort($filtered_events, function ($x, $y) {
                return WT_GedcomRecord::compare($x->getParent(), $y->getParent());
            });
            break;
    }
    foreach ($filtered_events as $fact) {
        $record = $fact->getParent();
        $html .= '<a href="' . $record->getHtmlUrl() . '" class="list_item name2">' . $record->getFullName() . '</a>';
        if ($record instanceof WT_Individual) {
            $html .= $record->getSexImage();
        }
        $html .= '<br><div class="indent">';
        $html .= $fact->getLabel() . ' — ' . $fact->getDate()->Display(true);
        if ($fact->anniv) {
            $html .= ' (' . WT_I18N::translate('%s year anniversary', $fact->anniv) . ')';
        }
        if (!$fact->getPlace()->isEmpty()) {
            $html .= ' — <a href="' . $fact->getPlace()->getURL() . '">' . $fact->getPlace()->getFullName() . '</a>';
        }
        $html .= '</div>';
    }
    // Print a final summary message about restricted/filtered facts
    $summary = '';
    if ($endjd == WT_CLIENT_JD) {
        // We're dealing with the Today’s Events block
        if ($output == 0) {
            if ($filter == 0) {
                $summary = WT_I18N::translate('No events exist for today.');
            } else {
                $summary = WT_I18N::translate('No events for living individuals exist for today.');
            }
        }
    } else {
        // We're dealing with the Upcoming Events block
        if ($output == 0) {
            if ($filter == 0) {
                if ($endjd == $startjd) {
                    $summary = WT_I18N::translate('No events exist for tomorrow.');
                } else {
                    // I18N: translation for %s==1 is unused; it is translated separately as “tomorrow”
                    $summary = WT_I18N::plural('No events exist for the next %s day.', 'No events exist for the next %s days.', $endjd - $startjd + 1, WT_I18N::number($endjd - $startjd + 1));
                }
            } else {
                if ($endjd == $startjd) {
                    $summary = WT_I18N::translate('No events for living individuals exist for tomorrow.');
                } else {
                    // I18N: translation for %s==1 is unused; it is translated separately as “tomorrow”
                    $summary = WT_I18N::plural('No events for living people exist for the next %s day.', 'No events for living people exist for the next %s days.', $endjd - $startjd + 1, WT_I18N::number($endjd - $startjd + 1));
                }
            }
        }
    }
    if ($summary) {
        $html .= "<b>" . $summary . "</b>";
    }
    return $html;
}
Example #26
0
 function getActionPreview(WT_GedcomRecord $record)
 {
     $old_lines = preg_split('/[\\n]+/', $record->getGedcom());
     $new_lines = preg_split('/[\\n]+/', $this->updateRecord($record->getXref(), $record->getGedcom()));
     // Find matching lines using longest-common-subsequence algorithm.
     $lcs = self::LCS($old_lines, $new_lines, 0, count($old_lines) - 1, 0, count($new_lines) - 1);
     $diff_lines = array();
     $last_old = -1;
     $last_new = -1;
     while ($lcs) {
         list($old, $new) = array_shift($lcs);
         while ($last_old < $old - 1) {
             $diff_lines[] = self::decorateDeletedText($old_lines[++$last_old]);
         }
         while ($last_new < $new - 1) {
             $diff_lines[] = self::decorateInsertedText($new_lines[++$last_new]);
         }
         $diff_lines[] = $new_lines[$new];
         $last_old = $old;
         $last_new = $new;
     }
     while ($last_old < count($old_lines) - 1) {
         $diff_lines[] = self::decorateDeletedText($old_lines[++$last_old]);
     }
     while ($last_new < count($new_lines) - 1) {
         $diff_lines[] = self::decorateInsertedText($new_lines[++$last_new]);
     }
     return '<pre>' . self::createEditLinks(implode("\n", $diff_lines)) . '</pre>';
 }
Example #27
0
 public function getBlock($block_id, $template = true, $cfg = null)
 {
     global $ctype, $show_full, $PEDIGREE_FULL_DETAILS, $controller;
     self::updateSchema();
     // make sure the favorites table has been created
     $action = WT_Filter::get('action');
     switch ($action) {
         case 'deletefav':
             $favorite_id = WT_Filter::getInteger('favorite_id');
             if ($favorite_id) {
                 self::deleteFavorite($favorite_id);
             }
             break;
         case 'addfav':
             $gid = WT_Filter::get('gid', WT_REGEX_XREF);
             $favnote = WT_Filter::get('favnote');
             $url = WT_Filter::getUrl('url');
             $favtitle = WT_Filter::get('favtitle');
             if ($gid) {
                 $record = WT_GedcomRecord::getInstance($gid);
                 if ($record && $record->canShow()) {
                     self::addFavorite(array('user_id' => $ctype == 'user' ? WT_USER_ID : null, 'gedcom_id' => WT_GED_ID, 'gid' => $record->getXref(), 'type' => $record::RECORD_TYPE, 'url' => null, 'note' => $favnote, 'title' => $favtitle));
                 }
             } elseif ($url) {
                 self::addFavorite(array('user_id' => $ctype == 'user' ? WT_USER_ID : null, 'gedcom_id' => WT_GED_ID, 'gid' => null, 'type' => 'URL', 'url' => $url, 'note' => $favnote, 'title' => $favtitle ? $favtitle : $url));
             }
             break;
     }
     $block = get_block_setting($block_id, 'block', false);
     if ($cfg) {
         foreach (array('block') as $name) {
             if (array_key_exists($name, $cfg)) {
                 ${$name} = $cfg[$name];
             }
         }
     }
     // Override GEDCOM configuration temporarily
     if (isset($show_full)) {
         $saveShowFull = $show_full;
     }
     $savePedigreeFullDetails = $PEDIGREE_FULL_DETAILS;
     $show_full = 1;
     $PEDIGREE_FULL_DETAILS = 1;
     $userfavs = $this->getFavorites($ctype == 'user' ? WT_USER_ID : WT_GED_ID);
     if (!is_array($userfavs)) {
         $userfavs = array();
     }
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     $title = $this->getTitle();
     if (WT_USER_ID) {
         $controller->addExternalJavascript(WT_STATIC_URL . 'js/autocomplete.js')->addInlineJavascript('autocomplete();');
     }
     $content = '';
     $style = 2;
     // 1 means "regular box", 2 means "wide box"
     if ($userfavs) {
         foreach ($userfavs as $key => $favorite) {
             if (isset($favorite['id'])) {
                 $key = $favorite['id'];
             }
             $removeFavourite = '<a class="font9" href="index.php?ctype=' . $ctype . '&amp;action=deletefav&amp;favorite_id=' . $key . '" onclick="return confirm(\'' . WT_I18N::translate('Are you sure you want to remove this item from your list of favorites?') . '\');">' . WT_I18N::translate('Remove') . '</a> ';
             if ($favorite['type'] == 'URL') {
                 $content .= '<div id="boxurl' . $key . '.0" class="person_box">';
                 if ($ctype == 'user' || WT_USER_GEDCOM_ADMIN) {
                     $content .= $removeFavourite;
                 }
                 $content .= '<a href="' . $favorite['url'] . '"><b>' . $favorite['title'] . '</b></a>';
                 $content .= '<br>' . $favorite['note'];
                 $content .= '</div>';
             } else {
                 $record = WT_GedcomRecord::getInstance($favorite['gid']);
                 if ($record && $record->canShow()) {
                     if ($record instanceof WT_Individual) {
                         $content .= '<div id="box' . $favorite["gid"] . '.0" class="person_box action_header';
                         switch ($record->getsex()) {
                             case 'M':
                                 break;
                             case 'F':
                                 $content .= 'F';
                                 break;
                             case 'U':
                                 $content .= 'NN';
                                 break;
                         }
                         $content .= '">';
                         if ($ctype == "user" || WT_USER_GEDCOM_ADMIN) {
                             $content .= $removeFavourite;
                         }
                         ob_start();
                         print_pedigree_person($record, $style, 1, $key);
                         $content .= ob_get_clean();
                         $content .= $favorite['note'];
                         $content .= '</div>';
                     } else {
                         $content .= '<div id="box' . $favorite['gid'] . '.0" class="person_box">';
                         if ($ctype == 'user' || WT_USER_GEDCOM_ADMIN) {
                             $content .= $removeFavourite;
                         }
                         $content .= $record->format_list('span');
                         $content .= '<br>' . $favorite['note'];
                         $content .= '</div>';
                     }
                 }
             }
         }
     }
     if ($ctype == 'user' || WT_USER_GEDCOM_ADMIN) {
         $uniqueID = Uuid::uuid4();
         // This block can theoretically appear multiple times, so use a unique ID.
         $content .= '<div class="add_fav_head">';
         $content .= '<a href="#" onclick="return expand_layer(\'add_fav' . $uniqueID . '\');">' . WT_I18N::translate('Add a new favorite') . '<i id="add_fav' . $uniqueID . '_img" class="icon-plus"></i></a>';
         $content .= '</div>';
         $content .= '<div id="add_fav' . $uniqueID . '" style="display: none;">';
         $content .= '<form name="addfavform" method="get" action="index.php">';
         $content .= '<input type="hidden" name="action" value="addfav">';
         $content .= '<input type="hidden" name="ctype" value="' . $ctype . '">';
         $content .= '<input type="hidden" name="ged" value="' . WT_GEDCOM . '">';
         $content .= '<div class="add_fav_ref">';
         $content .= '<input type="radio" name="fav_category" value="record" checked="checked" onclick="jQuery(\'#gid' . $uniqueID . '\').removeAttr(\'disabled\'); jQuery(\'#url, #favtitle\').attr(\'disabled\',\'disabled\').val(\'\');">';
         $content .= '<label for="gid' . $uniqueID . '">' . WT_I18N::translate('Enter an individual, family, or source ID') . '</label>';
         $content .= '<input class="pedigree_form" data-autocomplete-type="IFSRO" type="text" name="gid" id="gid' . $uniqueID . '" size="5" value="">';
         $content .= ' ' . print_findindi_link('gid' . $uniqueID);
         $content .= ' ' . print_findfamily_link('gid' . $uniqueID);
         $content .= ' ' . print_findsource_link('gid' . $uniqueID);
         $content .= ' ' . print_findrepository_link('gid' . $uniqueID);
         $content .= ' ' . print_findnote_link('gid' . $uniqueID);
         $content .= ' ' . print_findmedia_link('gid' . $uniqueID);
         $content .= '</div>';
         $content .= '<div class="add_fav_url">';
         $content .= '<input type="radio" name="fav_category" value="url" onclick="jQuery(\'#url, #favtitle\').removeAttr(\'disabled\'); jQuery(\'#gid' . $uniqueID . '\').attr(\'disabled\',\'disabled\').val(\'\');">';
         $content .= '<input type="text" name="url" id="url" size="20" value="" placeholder="' . WT_Gedcom_Tag::getLabel('URL') . '" disabled="disabled"> ';
         $content .= '<input type="text" name="favtitle" id="favtitle" size="20" value="" placeholder="' . WT_I18N::translate('Title') . '" disabled="disabled">';
         $content .= '<p>' . WT_I18N::translate('Enter an optional note about this favorite') . '</p>';
         $content .= '<textarea name="favnote" rows="6" cols="50"></textarea>';
         $content .= '</div>';
         $content .= '<input type="submit" value="' . WT_I18N::translate('Add') . '">';
         $content .= '</form></div>';
     }
     if ($template) {
         if ($block) {
             require WT_THEME_DIR . 'templates/block_small_temp.php';
         } else {
             require WT_THEME_DIR . 'templates/block_main_temp.php';
         }
     } else {
         return $content;
     }
     // Restore GEDCOM configuration
     unset($show_full);
     if (isset($saveShowFull)) {
         $show_full = $saveShowFull;
     }
     $PEDIGREE_FULL_DETAILS = $savePedigreeFullDetails;
 }
Example #28
0
             echo 'colspan="2"';
         }
         echo ' style="text-align: center;">';
         echo '<a href="', $place->getURL(), '&amp;action=show" class="formField">', $place->getPlaceName(), '</a>';
         echo '</td></tr>';
     }
     echo '</table>';
 }
 echo '</td></tr></table>';
 if ($place_id && $action == 'show') {
     // -- array of names
     $myindilist = array();
     $myfamlist = array();
     $positions = WT_DB::prepare("SELECT DISTINCT pl_gid FROM `##placelinks` WHERE pl_p_id=? AND pl_file=?")->execute(array($place_id, WT_GED_ID))->fetchOneColumn();
     foreach ($positions as $position) {
         $record = WT_GedcomRecord::getInstance($position);
         if ($record && $record->canShow()) {
             if ($record instanceof WT_Individual) {
                 $myindilist[] = $record;
             }
             if ($record instanceof WT_Family) {
                 $myfamlist[] = $record;
             }
         }
     }
     echo '<br>';
     //-- display results
     $controller->addInlineJavascript('jQuery("#places-tabs").tabs();')->addInlineJavascript('jQuery("#places-tabs").css("visibility", "visible");')->addInlineJavascript('jQuery(".loading-image").css("display", "none");');
     echo '<div class="loading-image">&nbsp;</div>';
     echo '<div id="places-tabs"><ul>';
     if ($myindilist) {
Example #29
0
    static function print_addnewnote_assisted_link($element_id, $xref, $action)
    {
        global $controller;
        // We do not yet support family records
        if (!WT_GedcomRecord::getInstance($xref) instanceof WT_Individual) {
            return '';
        }
        // Only modify “add shared note” links on the add/edit actions.
        // TODO: does the “edit” action work?
        if ($action != 'add' && $action != 'edit') {
            return '';
        }
        // There are lots of “add shared note” links.  We only need to modify the 2nd one
        static $n = 0;
        if (++$n != 2) {
            return '';
        }
        $controller->addInlineJavascript('
			var pid_array=jQuery("#pid_array");
			function set_pid_array(pa) {
				pid_array.val(pa);
			}
		');
        return '<br>' . '<input type="hidden" name="pid_array" id="pid_array" value="">' . '<a href="#" onclick="return addnewnote_assisted(document.getElementById(\'' . $element_id . '\'), \'' . $xref . '\');">' . WT_I18N::translate('Create a new shared note using assistant') . '</a>';
    }
Example #30
0
 function _eventQuery($type, $direction, $facts)
 {
     $eventTypes = array('BIRT' => WT_I18N::translate('birth'), 'DEAT' => WT_I18N::translate('death'), 'MARR' => WT_I18N::translate('marriage'), 'ADOP' => WT_I18N::translate('adoption'), 'BURI' => WT_I18N::translate('burial'), 'CENS' => WT_I18N::translate('census added'));
     $fact_query = "IN ('" . str_replace('|', "','", $facts) . "')";
     if ($direction != 'ASC') {
         $direction = 'DESC';
     }
     $rows = self::_runSQL('' . ' SELECT SQL_CACHE' . ' d_gid AS id,' . ' d_year AS year,' . ' d_fact AS fact,' . ' d_type AS type' . ' FROM' . " `##dates`" . ' WHERE' . " d_file={$this->_ged_id} AND" . " d_gid<>'HEAD' AND" . " d_fact {$fact_query} AND" . ' d_julianday1<>0' . ' ORDER BY' . " d_julianday1 {$direction}, d_type LIMIT 1");
     if (!isset($rows[0])) {
         return '';
     }
     $row = $rows[0];
     $record = WT_GedcomRecord::getInstance($row['id']);
     switch ($type) {
         default:
         case 'full':
             if ($record->canShow()) {
                 $result = $record->format_list('span', false, $record->getFullName());
             } else {
                 $result = WT_I18N::translate('This information is private and cannot be shown.');
             }
             break;
         case 'year':
             $date = new WT_Date($row['type'] . ' ' . $row['year']);
             $result = $date->Display(true);
             break;
         case 'type':
             if (isset($eventTypes[$row['fact']])) {
                 $result = $eventTypes[$row['fact']];
             } else {
                 $result = WT_Gedcom_Tag::getLabel($row['fact']);
             }
             break;
         case 'name':
             $result = "<a href=\"" . $record->getHtmlUrl() . "\">" . $record->getFullName() . "</a>";
             break;
         case 'place':
             $fact = $record->getFirstFact($row['fact']);
             if ($fact) {
                 $result = format_fact_place($fact, true, true, true);
             } else {
                 $result = WT_I18N::translate('Private');
             }
             break;
     }
     return $result;
 }