Exemplo n.º 1
0
        ?>
">
			<?php 
        echo Filter::getCsrf();
        ?>
			<table class="facts_table">
				<tr>
					<td class="facts_label">
						<?php 
        echo I18N::translate('Family');
        ?>
					</td>
					<td class="facts_value">
						<input data-autocomplete-type="FAM" type="text" id="famid" name="famid" size="8">
						<?php 
        echo FunctionsPrint::printFindFamilyLink('famid');
        ?>
					</td>
				</tr>
				<tr>
					<td class="facts_label">
						<?php 
        echo GedcomTag::getLabel('PEDI');
        ?>
					</td>
					<td class="facts_value">
						<?php 
        echo FunctionsEdit::editFieldPedigree('PEDI', '', '', $person);
        ?>
						<p class="small text-muted">
							<?php 
Exemplo n.º 2
0
echo '<input type="hidden" name="action" value="', $action, '">';
echo '<input type="hidden" name="ged" value="', $WT_TREE->getNameHtml(), '">';
echo '<input type="hidden" name="pid" value="', $pid, '">';
if ($linktoid) {
    echo '<input type="hidden" name="linktoid" value="', $linktoid, '">';
}
echo '<table class="facts_table">';
echo '<tr><td class="topbottombar" colspan="2">';
echo $controller->getPageTitle(), FunctionsPrint::helpLink('OBJE');
echo '</td></tr>';
if (!$linktoid && $action == 'create') {
    echo '<tr><td class="descriptionbox wrap width25">';
    echo I18N::translate('Enter an individual, family, or source ID');
    echo '</td><td class="optionbox wrap"><input type="text" data-autocomplete-type="IFS" name="linktoid" id="linktoid" size="6" value="">';
    echo ' ', FunctionsPrint::printFindIndividualLink('linktoid');
    echo ' ', FunctionsPrint::printFindFamilyLink('linktoid');
    echo ' ', FunctionsPrint::printFindSourceLink('linktoid');
    echo '<p class="small text-muted">', I18N::translate('Enter or search for the ID of the individual, family, or source to which this media object should be linked.'), '</p></td></tr>';
}
if ($media) {
    $gedrec = $media->getGedcom();
} else {
    $gedrec = '';
}
// 1 FILE
if (preg_match('/\\n\\d (FILE.*)/', $gedrec, $match)) {
    $gedfile = $match[1];
} elseif ($filename) {
    $gedfile = 'FILE ' . $filename;
} else {
    $gedfile = 'FILE';
Exemplo n.º 3
0
    /**
     * This is a general purpose hook, allowing modules to respond to routes
     * of the form module.php?mod=FOO&mod_action=BAR
     *
     * @param string $mod_action
     */
    public function modAction($mod_action)
    {
        switch ($mod_action) {
            case 'ajax':
                $html = $this->getSidebarAjaxContent();
                header('Content-Type: text/html; charset=UTF-8');
                echo $html;
                break;
            case 'index':
                global $controller, $WT_TREE;
                $MAX_PEDIGREE_GENERATIONS = $WT_TREE->getPreference('MAX_PEDIGREE_GENERATIONS');
                $clip_ctrl = new ClippingsCartController();
                $cart = Session::get('cart');
                $controller = new PageController();
                $controller->setPageTitle($this->getTitle())->pageHeader()->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)->addInlineJavascript('autocomplete();');
                echo '<script>';
                echo 'function radAncestors(elementid) {var radFamilies=document.getElementById(elementid);radFamilies.checked=true;}';
                echo '</script>';
                if (!$cart[$WT_TREE->getTreeId()]) {
                    echo '<h2>', I18N::translate('Family tree clippings cart'), '</h2>';
                }
                if ($clip_ctrl->action == 'add') {
                    $record = GedcomRecord::getInstance($clip_ctrl->id, $WT_TREE);
                    if ($clip_ctrl->type === 'FAM') {
                        ?>
					<form action="module.php" method="get">
						<input type="hidden" name="mod" value="clippings">
						<input type="hidden" name="mod_action" value="index">
						<input type="hidden" name="id" value="<?php 
                        echo $clip_ctrl->id;
                        ?>
">
						<input type="hidden" name="type" value="<?php 
                        echo $clip_ctrl->type;
                        ?>
">
						<input type="hidden" name="action" value="add1">
						<table>
							<thead>
								<tr>
									<td class="topbottombar">
										<?php 
                        echo I18N::translate('Add to the clippings cart');
                        ?>
									</td>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td class="optionbox">
										<input type="radio" name="others" value="parents">
										<?php 
                        echo $record->getFullName();
                        ?>
									</td>
								</tr>
								<tr>
									<td class="optionbox">
										<input type="radio" name="others" value="members" checked>
										<?php 
                        echo I18N::translate('%s and their children', $record->getFullName());
                        ?>
									</td>
								</tr>
								<tr>
									<td class="optionbox">
										<input type="radio" name="others" value="descendants">
										<?php 
                        echo I18N::translate('%s and their descendants', $record->getFullName());
                        ?>
									</td>
								</tr>
							</tbody>
							<tfoot>
								<tr>
									<td class="topbottombar"><input type="submit" value="<?php 
                        echo I18N::translate('continue');
                        ?>
">
									</td>
								</tr>
							</tfoot>
						</table>
					</form>
				<?php 
                    } elseif ($clip_ctrl->type === 'INDI') {
                        ?>
					<form action="module.php" method="get">
						<input type="hidden" name="mod" value="clippings">
						<input type="hidden" name="mod_action" value="index">
						<input type="hidden" name="id" value="<?php 
                        echo $clip_ctrl->id;
                        ?>
">
						<input type="hidden" name="type" value="<?php 
                        echo $clip_ctrl->type;
                        ?>
">
						<input type="hidden" name="action" value="add1">
						<table>
							<thead>
								<tr>
									<td class="topbottombar">
										<?php 
                        echo I18N::translate('Add to the clippings cart');
                        ?>
									</td>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td class="optionbox">
										<label>
											<input type="radio" name="others" checked value="none">
											<?php 
                        echo $record->getFullName();
                        ?>
										</label>
									</td>
								</tr>
								<tr>
									<td class="optionbox">
										<label>
											<input type="radio" name="others" value="parents">
											<?php 
                        if ($record->getSex() === 'F') {
                            echo I18N::translate('%s, her parents and siblings', $record->getFullName());
                        } else {
                            echo I18N::translate('%s, his parents and siblings', $record->getFullName());
                        }
                        ?>
										</label>
									</td>
								</tr>
								<tr>
									<td class="optionbox">
										<label>
											<input type="radio" name="others" value="members">
											<?php 
                        if ($record->getSex() === 'F') {
                            echo I18N::translate('%s, her spouses and children', $record->getFullName());
                        } else {
                            echo I18N::translate('%s, his spouses and children', $record->getFullName());
                        }
                        ?>
										</label>
									</td>
								</tr>
								<tr>
									<td class="optionbox">
										<label>
											<input type="radio" name="others" value="ancestors" id="ancestors">
											<?php 
                        if ($record->getSex() === 'F') {
                            echo I18N::translate('%s and her ancestors', $record->getFullName());
                        } else {
                            echo I18N::translate('%s and his ancestors', $record->getFullName());
                        }
                        ?>
										</label>
										<br>
										<?php 
                        echo I18N::translate('Number of generations');
                        ?>
										<input type="text" size="5" name="level1" value="<?php 
                        echo $MAX_PEDIGREE_GENERATIONS;
                        ?>
" onfocus="radAncestors('ancestors');">
									</td>
								</tr>
								<tr>
									<td class="optionbox">
										<label>
											<input type="radio" name="others" value="ancestorsfamilies" id="ancestorsfamilies">
											<?php 
                        if ($record->getSex() === 'F') {
                            echo I18N::translate('%s, her ancestors and their families', $record->getFullName());
                        } else {
                            echo I18N::translate('%s, his ancestors and their families', $record->getFullName());
                        }
                        ?>
										</label>
										<br>
										<?php 
                        echo I18N::translate('Number of generations');
                        ?>
										<input type="text" size="5" name="level2" value="<?php 
                        echo $MAX_PEDIGREE_GENERATIONS;
                        ?>
" onfocus="radAncestors('ancestorsfamilies');">
									</td>
								</tr>
								<tr>
									<td class="optionbox">
										<label>
											<input type="radio" name="others" value="descendants" id="descendants">
											<?php 
                        if ($record->getSex() === 'F') {
                            echo I18N::translate('%s, her spouses and descendants', $record->getFullName());
                        } else {
                            echo I18N::translate('%s, his spouses and descendants', $record->getFullName());
                        }
                        ?>
										</label>
										<br>
										<?php 
                        echo I18N::translate('Number of generations');
                        ?>
										<input type="text" size="5" name="level3" value="<?php 
                        echo $MAX_PEDIGREE_GENERATIONS;
                        ?>
" onfocus="radAncestors('descendants');">
									</td>
								</tr>
							</tbody>
							<tfoot>
								<tr>
									<td class="topbottombar">
										<input type="submit" value="<?php 
                        echo I18N::translate('continue');
                        ?>
">
									</td>
								</tr>
							</tfoot>
						</table>
					</form>
				<?php 
                    } elseif ($clip_ctrl->type === 'SOUR') {
                        ?>
					<form action="module.php" method="get">
						<input type="hidden" name="mod" value="clippings">
						<input type="hidden" name="mod_action" value="index">
						<input type="hidden" name="id" value="<?php 
                        echo $clip_ctrl->id;
                        ?>
">
						<input type="hidden" name="type" value="<?php 
                        echo $clip_ctrl->type;
                        ?>
">
						<input type="hidden" name="action" value="add1">
						<table>
							<thead>
								<tr>
									<td class="topbottombar">
										<?php 
                        echo I18N::translate('Add to the clippings cart');
                        ?>
									</td>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td class="optionbox">
										<label>
											<input type="radio" name="others" checked value="none">
											<?php 
                        echo $record->getFullName();
                        ?>
										</label>
									</td>
								</tr>
								<tr>
									<td class="optionbox">
										<label>
											<input type="radio" name="others" value="linked">
											<?php 
                        echo I18N::translate('%s and the individuals that reference it.', $record->getFullName());
                        ?>
										</label>
									</td>
								</tr>
							</tbody>
							<tfoot>
								<tr>
									<td class="topbottombar">
										<input type="submit" value="<?php 
                        echo I18N::translate('continue');
                        ?>
">
									</td>
								</tr>
							</tfoot>
						</table>
					</form>
				<?php 
                    }
                }
                if (!$cart[$WT_TREE->getTreeId()]) {
                    if ($clip_ctrl->action != 'add') {
                        echo I18N::translate('The clippings cart allows you to take extracts (“clippings”) from this family tree and bundle them up into a single file for downloading and subsequent importing into your own genealogy program. The downloadable file is recorded in GEDCOM format.<br><ul><li>How to take clippings?<br>This is really simple. Whenever you see a clickable name (individual, family, or source) you can go to the Details page of that name. There you will see the <b>Add to clippings cart</b> option. When you click that link you will be offered several options to download.</li><li>How to download?<br>Once you have items in your cart, you can download them just by clicking the “Download” link. Follow the instructions and links.</li></ul>');
                        ?>
					<form method="get" name="addin" action="module.php">
						<input type="hidden" name="mod" value="clippings">
						<input type="hidden" name="mod_action" value="index">
						<table>
							<thead>
								<tr>
									<td colspan="2" class="topbottombar">
										<?php 
                        echo I18N::translate('Add to the clippings cart');
                        ?>
									</td>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td class="optionbox">
										<input type="hidden" name="action" value="add">
										<input type="text" data-autocomplete-type="IFSRO" name="id" id="cart_item_id" size="5">
									</td>
									<td class="optionbox">
										<?php 
                        echo FunctionsPrint::printFindIndividualLink('cart_item_id');
                        ?>
										<?php 
                        echo FunctionsPrint::printFindFamilyLink('cart_item_id');
                        ?>
										<?php 
                        echo FunctionsPrint::printFindSourceLink('cart_item_id', '');
                        ?>
										<input type="submit" value="<?php 
                        echo I18N::translate('Add');
                        ?>
">
									</td>
								</tr>
							</tbody>
						</table>
					</form>
					<?php 
                    }
                    // -- end new lines
                    echo I18N::translate('Your clippings cart is empty.');
                } else {
                    // Keep track of the INDI from the parent page, otherwise it will
                    // get lost after ajax updates
                    $pid = Filter::get('pid', WT_REGEX_XREF);
                    if ($clip_ctrl->action !== 'download' && $clip_ctrl->action !== 'add') {
                        ?>
					<form method="get" action="module.php">
						<input type="hidden" name="mod" value="clippings">
						<input type="hidden" name="mod_action" value="index">
						<input type="hidden" name="action" value="download">
						<input type="hidden" name="pid" value="<?php 
                        echo $pid;
                        ?>
">
						<table>
							<tr>
								<td colspan="2" class="topbottombar">
									<h2><?php 
                        echo I18N::translate('Download');
                        ?>
</h2>
								</td>
							</tr>
							<tr>
								<td class="descriptionbox width50 wrap">
									<?php 
                        echo I18N::translate('To reduce the size of the download, you can compress the data into a .ZIP file. You will need to uncompress the .ZIP file before you can use it.');
                        ?>
								</td>
								<td class="optionbox wrap">
									<input type="checkbox" name="Zip" value="yes">
									<?php 
                        echo I18N::translate('Zip file(s)');
                        ?>
								</td>
							</tr>
							<tr>
								<td class="descriptionbox width50 wrap">
									<?php 
                        echo I18N::translate('Include media (automatically zips files)');
                        ?>
								</td>
								<td class="optionbox">
									<input type="checkbox" name="IncludeMedia" value="yes">
								</td>
							</tr>

							<?php 
                        if (Auth::isManager($WT_TREE)) {
                            ?>
								<tr>
									<td class="descriptionbox width50 wrap">
										<?php 
                            echo I18N::translate('Apply privacy settings');
                            ?>
									</td>
									<td class="optionbox">
										<input type="radio" name="privatize_export" value="none" checked>
										<?php 
                            echo I18N::translate('None');
                            ?>
										<br>
										<input type="radio" name="privatize_export" value="gedadmin">
										<?php 
                            echo I18N::translate('Manager');
                            ?>
										<br>
										<input type="radio" name="privatize_export" value="user">
										<?php 
                            echo I18N::translate('Member');
                            ?>
										<br>
										<input type="radio" name="privatize_export" value="visitor">
										<?php 
                            echo I18N::translate('Visitor');
                            ?>
									</td>
								</tr>
							<?php 
                        } elseif (Auth::isMember($WT_TREE)) {
                            ?>
								<tr>
									<td class="descriptionbox width50 wrap">
										<?php 
                            echo I18N::translate('Apply privacy settings');
                            ?>
									</td>
									<td class="optionbox">
										<input type="radio" name="privatize_export" value="user" checked> <?php 
                            echo I18N::translate('Member');
                            ?>
<br>
										<input type="radio" name="privatize_export" value="visitor"> <?php 
                            echo I18N::translate('Visitor');
                            ?>
									</td>
								</tr>
							<?php 
                        }
                        ?>

							<tr>
								<td class="descriptionbox width50 wrap">
									<?php 
                        echo I18N::translate('Convert from UTF-8 to ISO-8859-1');
                        ?>
								</td>
								<td class="optionbox">
									<input type="checkbox" name="convert" value="yes">
								</td>
							</tr>

							<tr>
								<td class="descriptionbox width50 wrap">
									<?php 
                        echo I18N::translate('Add the GEDCOM media path to filenames');
                        ?>
								</td>
								<td class="optionbox">
									<input type="checkbox" name="conv_path" value="<?php 
                        echo Filter::escapeHtml($WT_TREE->getPreference('GEDCOM_MEDIA_PATH'));
                        ?>
">
									<span dir="auto"><?php 
                        echo Filter::escapeHtml($WT_TREE->getPreference('GEDCOM_MEDIA_PATH'));
                        ?>
</span>
								</td>
							</tr>

							<tr>
								<td class="topbottombar" colspan="2">
									<input type="submit" value="<?php 
                        echo I18N::translate('Download');
                        ?>
">
								</td>
							</tr>
						</table>
					</form>
					<br>

					<form method="get" name="addin" action="module.php">
						<input type="hidden" name="mod" value="clippings">
						<input type="hidden" name="mod_action" value="index">
						<table>
							<thead>
								<tr>
									<td colspan="2" class="topbottombar" style="text-align:center; ">
										<?php 
                        echo I18N::translate('Add to the clippings cart');
                        ?>
									</td>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td class="optionbox">
										<input type="hidden" name="action" value="add">
										<input type="text" data-autocomplete-type="IFSRO" name="id" id="cart_item_id" size="8">
									</td>
									<td class="optionbox">
										<?php 
                        echo FunctionsPrint::printFindIndividualLink('cart_item_id');
                        ?>
										<?php 
                        echo FunctionsPrint::printFindFamilyLink('cart_item_id');
                        ?>
										<?php 
                        echo FunctionsPrint::printFindSourceLink('cart_item_id');
                        ?>
										<input type="submit" value="<?php 
                        echo I18N::translate('Add');
                        ?>
">
									</td>
								</tr>
							</tbody>
							<tfoot>
								<tr>
									<th colspan="2">
										<a href="module.php?mod=clippings&amp;mod_action=index&amp;action=empty">
											<?php 
                        echo I18N::translate('Empty the clippings cart');
                        ?>
										</a>
									</th>
								</tr>
							</tfoot>
						</table>
					</form>

				<?php 
                    }
                    ?>

				<h2>
					<?php 
                    echo I18N::translate('Family tree clippings cart');
                    ?>
				</h2>
				<table id="mycart" class="sortable list_table width100">
					<thead>
						<tr>
							<th class="list_label"><?php 
                    echo I18N::translate('Record');
                    ?>
</th>
							<th class="list_label"><?php 
                    echo I18N::translate('Remove');
                    ?>
</th>
						</tr>
					</thead>
					<tbody>
						<?php 
                    foreach (array_keys($cart[$WT_TREE->getTreeId()]) as $xref) {
                        $record = GedcomRecord::getInstance($xref, $WT_TREE);
                        if ($record) {
                            switch ($record::RECORD_TYPE) {
                                case 'INDI':
                                    $icon = 'icon-indis';
                                    break;
                                case 'FAM':
                                    $icon = 'icon-sfamily';
                                    break;
                                case 'SOUR':
                                    $icon = 'icon-source';
                                    break;
                                case 'REPO':
                                    $icon = 'icon-repository';
                                    break;
                                case 'NOTE':
                                    $icon = 'icon-note';
                                    break;
                                case 'OBJE':
                                    $icon = 'icon-media';
                                    break;
                                default:
                                    $icon = 'icon-clippings';
                                    break;
                            }
                            ?>
								<tr>
									<td class="list_value">
										<i class="<?php 
                            echo $icon;
                            ?>
"></i>
										<?php 
                            echo '<a href="', $record->getHtmlUrl(), '">', $record->getFullName(), '</a>';
                            ?>
									</td>
									<td class="list_value center vmiddle"><a href="module.php?mod=clippings&amp;mod_action=index&amp;action=remove&amp;id=<?php 
                            echo $xref;
                            ?>
" class="icon-remove" title="<?php 
                            echo I18N::translate('Remove');
                            ?>
"></a></td>
								</tr>
								<?php 
                        }
                    }
                    ?>
				</table>
				<?php 
                }
                break;
            default:
                http_response_code(404);
                break;
        }
    }
Exemplo n.º 4
0
			<label for="gid2">
				<?php 
    echo I18N::translate('Second record');
    ?>
			</label>
		</div>
		<div class="col-sm-9">
			<input data-autocomplete-type="IFSRO" type="text" name="gid2" id="gid2" maxlength="20" value="<?php 
    echo $gid2;
    ?>
" >
			<?php 
    echo FunctionsPrint::printFindIndividualLink('gid2');
    ?>
			<?php 
    echo FunctionsPrint::printFindFamilyLink('gid2');
    ?>
			<?php 
    echo FunctionsPrint::printFindSourceLink('gid2');
    ?>
			<?php 
    echo FunctionsPrint::printFindRepositoryLink('gid2');
    ?>
			<?php 
    echo FunctionsPrint::printFindMediaLink('gid2');
    ?>
			<?php 
    echo FunctionsPrint::printFindNoteLink('gid2');
    ?>
		</div>
	</div>
 /**
  * Generate the HTML content of this block.
  *
  * @param int      $block_id
  * @param bool     $template
  * @param string[] $cfg
  *
  * @return string
  */
 public function getBlock($block_id, $template = true, $cfg = array())
 {
     global $ctype, $controller, $WT_TREE;
     $action = Filter::get('action');
     switch ($action) {
         case 'deletefav':
             $favorite_id = Filter::getInteger('favorite_id');
             if ($favorite_id) {
                 self::deleteFavorite($favorite_id);
             }
             break;
         case 'addfav':
             $gid = Filter::get('gid', WT_REGEX_XREF);
             $favnote = Filter::get('favnote');
             $url = Filter::getUrl('url');
             $favtitle = Filter::get('favtitle');
             if ($gid) {
                 $record = GedcomRecord::getInstance($gid, $WT_TREE);
                 if ($record && $record->canShow()) {
                     self::addFavorite(array('user_id' => $ctype === 'user' ? Auth::id() : null, 'gedcom_id' => $WT_TREE->getTreeId(), 'gid' => $record->getXref(), 'type' => $record::RECORD_TYPE, 'url' => null, 'note' => $favnote, 'title' => $favtitle));
                 }
             } elseif ($url) {
                 self::addFavorite(array('user_id' => $ctype === 'user' ? Auth::id() : null, 'gedcom_id' => $WT_TREE->getTreeId(), 'gid' => null, 'type' => 'URL', 'url' => $url, 'note' => $favnote, 'title' => $favtitle ? $favtitle : $url));
             }
             break;
     }
     $block = $this->getBlockSetting($block_id, 'block', '0');
     foreach (array('block') as $name) {
         if (array_key_exists($name, $cfg)) {
             ${$name} = $cfg[$name];
         }
     }
     $userfavs = $this->getFavorites($ctype === 'user' ? Auth::id() : $WT_TREE->getTreeId());
     if (!is_array($userfavs)) {
         $userfavs = array();
     }
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     $title = $this->getTitle();
     if (Auth::check()) {
         $controller->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)->addInlineJavascript('autocomplete();');
     }
     $content = '';
     if ($userfavs) {
         foreach ($userfavs as $key => $favorite) {
             if (isset($favorite['id'])) {
                 $key = $favorite['id'];
             }
             $removeFavourite = '<a class="font9" href="index.php?ctype=' . $ctype . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;action=deletefav&amp;favorite_id=' . $key . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to remove this item from your list of favorites?') . '\');">' . I18N::translate('Remove') . '</a> ';
             if ($favorite['type'] == 'URL') {
                 $content .= '<div id="boxurl' . $key . '.0" class="person_box">';
                 if ($ctype == 'user' || Auth::isManager($WT_TREE)) {
                     $content .= $removeFavourite;
                 }
                 $content .= '<a href="' . $favorite['url'] . '"><b>' . $favorite['title'] . '</b></a>';
                 $content .= '<br>' . $favorite['note'];
                 $content .= '</div>';
             } else {
                 $record = GedcomRecord::getInstance($favorite['gid'], $WT_TREE);
                 if ($record && $record->canShow()) {
                     if ($record instanceof Individual) {
                         $content .= '<div id="box' . $favorite["gid"] . '.0" class="person_box action_header';
                         switch ($record->getsex()) {
                             case 'M':
                                 break;
                             case 'F':
                                 $content .= 'F';
                                 break;
                             default:
                                 $content .= 'NN';
                                 break;
                         }
                         $content .= '">';
                         if ($ctype == "user" || Auth::isManager($WT_TREE)) {
                             $content .= $removeFavourite;
                         }
                         $content .= Theme::theme()->individualBoxLarge($record);
                         $content .= $favorite['note'];
                         $content .= '</div>';
                     } else {
                         $content .= '<div id="box' . $favorite['gid'] . '.0" class="person_box">';
                         if ($ctype == 'user' || Auth::isManager($WT_TREE)) {
                             $content .= $removeFavourite;
                         }
                         $content .= $record->formatList('span');
                         $content .= '<br>' . $favorite['note'];
                         $content .= '</div>';
                     }
                 }
             }
         }
     }
     if ($ctype == 'user' || Auth::isManager($WT_TREE)) {
         $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 . '\');">' . 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_TREE->getNameHtml() . '">';
         $content .= '<div class="add_fav_ref">';
         $content .= '<input type="radio" name="fav_category" value="record" checked onclick="jQuery(\'#gid' . $uniqueID . '\').removeAttr(\'disabled\'); jQuery(\'#url, #favtitle\').attr(\'disabled\',\'disabled\').val(\'\');">';
         $content .= '<label for="gid' . $uniqueID . '">' . 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 .= ' ' . FunctionsPrint::printFindIndividualLink('gid' . $uniqueID);
         $content .= ' ' . FunctionsPrint::printFindFamilyLink('gid' . $uniqueID);
         $content .= ' ' . FunctionsPrint::printFindSourceLink('gid' . $uniqueID);
         $content .= ' ' . FunctionsPrint::printFindRepositoryLink('gid' . $uniqueID);
         $content .= ' ' . FunctionsPrint::printFindNoteLink('gid' . $uniqueID);
         $content .= ' ' . FunctionsPrint::printFindMediaLink('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="' . GedcomTag::getLabel('URL') . '" disabled> ';
         $content .= '<input type="text" name="favtitle" id="favtitle" size="20" value="" placeholder="' . I18N::translate('Title') . '" disabled>';
         $content .= '<p>' . 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="' . I18N::translate('Add') . '">';
         $content .= '</form></div>';
     }
     if ($template) {
         if ($block) {
             $class .= ' small_inner_block';
         }
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
Exemplo n.º 6
0
 /**
  * add a new tag input field
  *
  * called for each fact to be edited on a form.
  * Fact level=0 means a new empty form : data are POSTed by name
  * else data are POSTed using arrays :
  * glevels[] : tag level
  *  islink[] : tag is a link
  *     tag[] : tag name
  *    text[] : tag value
  *
  * @param string $tag fact record to edit (eg 2 DATE xxxxx)
  * @param string $upperlevel optional upper level tag (eg BIRT)
  * @param string $label An optional label to echo instead of the default
  * @param string $extra optional text to display after the input field
  * @param Individual $person For male/female translations
  *
  * @return string
  */
 public static function addSimpleTag($tag, $upperlevel = '', $label = '', $extra = null, Individual $person = null)
 {
     global $tags, $main_fact, $xref, $bdm, $action, $WT_TREE;
     // Keep track of SOUR fields, so we can reference them in subsequent PAGE fields.
     static $source_element_id;
     $subnamefacts = array('NPFX', 'GIVN', 'SPFX', 'SURN', 'NSFX', '_MARNM_SURN');
     preg_match('/^(?:(\\d+) (' . WT_REGEX_TAG . ') ?(.*))/', $tag, $match);
     list(, $level, $fact, $value) = $match;
     $level = (int) $level;
     // element name : used to POST data
     if ($level === 0) {
         if ($upperlevel) {
             $element_name = $upperlevel . '_' . $fact;
         } else {
             $element_name = $fact;
         }
     } else {
         $element_name = 'text[]';
     }
     if ($level === 1) {
         $main_fact = $fact;
     }
     // element id : used by javascript functions
     if ($level === 0) {
         $element_id = $fact;
     } else {
         $element_id = $fact . Uuid::uuid4();
     }
     if ($upperlevel) {
         $element_id = $upperlevel . '_' . $fact . Uuid::uuid4();
     }
     // field value
     $islink = substr($value, 0, 1) === '@' && substr($value, 0, 2) !== '@#';
     if ($islink) {
         $value = trim(substr($tag, strlen($fact) + 3), ' @\\r');
     } else {
         $value = (string) substr($tag, strlen($fact) + 3);
     }
     if ($fact === 'REPO' || $fact === 'SOUR' || $fact === 'OBJE' || $fact === 'FAMC') {
         $islink = true;
     }
     if ($fact === 'SHARED_NOTE_EDIT' || $fact === 'SHARED_NOTE') {
         $islink = true;
         $fact = 'NOTE';
     }
     // label
     echo '<tr id="', $element_id, '_tr"';
     if ($fact === 'MAP' || ($fact === 'LATI' || $fact === 'LONG') && $value === '') {
         echo ' style="display:none;"';
     }
     echo '>';
     if (in_array($fact, $subnamefacts) || $fact === 'LATI' || $fact === 'LONG') {
         echo '<td class="optionbox wrap width25">';
     } else {
         echo '<td class="descriptionbox wrap width25">';
     }
     // tag name
     if ($label) {
         echo $label;
     } elseif ($upperlevel) {
         echo GedcomTag::getLabel($upperlevel . ':' . $fact);
     } else {
         echo GedcomTag::getLabel($fact);
     }
     // If using GEDFact-assistant window
     if ($action === 'addnewnote_assisted') {
         // Do not print on GEDFact Assistant window
     } else {
         // Not all facts have help text.
         switch ($fact) {
             case 'NAME':
                 if ($upperlevel !== 'REPO' && $upperlevel !== 'UNKNOWN') {
                     echo FunctionsPrint::helpLink($fact);
                 }
                 break;
             case 'DATE':
             case 'PLAC':
             case 'RESN':
             case 'ROMN':
             case 'SURN':
             case '_HEB':
                 echo FunctionsPrint::helpLink($fact);
                 break;
         }
     }
     // tag level
     if ($level > 0) {
         if ($fact === 'TEXT' && $level > 1) {
             echo '<input type="hidden" name="glevels[]" value="', $level - 1, '">';
             echo '<input type="hidden" name="islink[]" value="0">';
             echo '<input type="hidden" name="tag[]" value="DATA">';
             // leave data text[] value empty because the following TEXT line will cause the DATA to be added
             echo '<input type="hidden" name="text[]" value="">';
         }
         echo '<input type="hidden" name="glevels[]" value="', $level, '">';
         echo '<input type="hidden" name="islink[]" value="', $islink, '">';
         echo '<input type="hidden" name="tag[]" value="', $fact, '">';
     }
     echo '</td>';
     // value
     echo '<td class="optionbox wrap">';
     // retrieve linked NOTE
     if ($fact === 'NOTE' && $islink) {
         $note1 = Note::getInstance($value, $WT_TREE);
         if ($note1) {
             $noterec = $note1->getGedcom();
             preg_match('/' . $value . '/i', $noterec, $notematch);
             $value = $notematch[0];
         }
     }
     // Show names for spouses in MARR/HUSB/AGE and MARR/WIFE/AGE
     if ($fact === 'HUSB' || $fact === 'WIFE') {
         $family = Family::getInstance($xref, $WT_TREE);
         if ($family) {
             $spouse_link = $family->getFirstFact($fact);
             if ($spouse_link) {
                 $spouse = $spouse_link->getTarget();
                 if ($spouse) {
                     echo $spouse->getFullName();
                 }
             }
         }
     }
     if (in_array($fact, Config::emptyFacts()) && ($value === '' || $value === 'Y' || $value === 'y')) {
         echo '<input type="hidden" id="', $element_id, '" name="', $element_name, '" value="', $value, '">';
         if ($level <= 1) {
             echo '<input type="checkbox" ';
             if ($value) {
                 echo 'checked';
             }
             echo ' onclick="document.getElementById(\'' . $element_id . '\').value = (this.checked) ? \'Y\' : \'\';">';
             echo I18N::translate('yes');
         }
         if ($fact === 'CENS' && $value === 'Y') {
             echo self::censusDateSelector(WT_LOCALE, $xref);
             if (Module::getModuleByName('GEDFact_assistant') && GedcomRecord::getInstance($xref, $WT_TREE) instanceof Individual) {
                 echo '<div></div><a href="#" style="display: none;" id="assistant-link" onclick="return activateCensusAssistant();">' . I18N::translate('Create a new shared note using assistant') . '</a></div>';
             }
         }
     } elseif ($fact === 'TEMP') {
         echo self::selectEditControl($element_name, GedcomCodeTemp::templeNames(), I18N::translate('No temple - living ordinance'), $value);
     } elseif ($fact === 'ADOP') {
         echo self::editFieldAdoption($element_name, $value, '', $person);
     } elseif ($fact === 'PEDI') {
         echo self::editFieldPedigree($element_name, $value, '', $person);
     } elseif ($fact === 'STAT') {
         echo self::selectEditControl($element_name, GedcomCodeStat::statusNames($upperlevel), '', $value);
     } elseif ($fact === 'RELA') {
         echo self::editFieldRelationship($element_name, strtolower($value));
     } elseif ($fact === 'QUAY') {
         echo self::selectEditControl($element_name, GedcomCodeQuay::getValues(), '', $value);
     } elseif ($fact === '_WT_USER') {
         echo self::editFieldUsername($element_name, $value);
     } elseif ($fact === 'RESN') {
         echo self::editFieldRestriction($element_name, $value);
     } elseif ($fact === '_PRIM') {
         echo '<select id="', $element_id, '" name="', $element_name, '" >';
         echo '<option value=""></option>';
         echo '<option value="Y" ';
         if ($value === 'Y') {
             echo ' selected';
         }
         echo '>', I18N::translate('always'), '</option>';
         echo '<option value="N" ';
         if ($value === 'N') {
             echo 'selected';
         }
         echo '>', I18N::translate('never'), '</option>';
         echo '</select>';
         echo '<p class="small text-muted">', I18N::translate('Use this image for charts and on the individual’s page.'), '</p>';
     } elseif ($fact === 'SEX') {
         echo '<select id="', $element_id, '" name="', $element_name, '"><option value="M" ';
         if ($value === 'M') {
             echo 'selected';
         }
         echo '>', I18N::translate('Male'), '</option><option value="F" ';
         if ($value === 'F') {
             echo 'selected';
         }
         echo '>', I18N::translate('Female'), '</option><option value="U" ';
         if ($value === 'U' || empty($value)) {
             echo 'selected';
         }
         echo '>', I18N::translateContext('unknown gender', 'Unknown'), '</option></select>';
     } elseif ($fact === 'TYPE' && $level === 3) {
         //-- Build the selector for the Media 'TYPE' Fact
         echo '<select name="text[]"><option selected value="" ></option>';
         $selectedValue = strtolower($value);
         if (!array_key_exists($selectedValue, GedcomTag::getFileFormTypes())) {
             echo '<option selected value="', Filter::escapeHtml($value), '" >', Filter::escapeHtml($value), '</option>';
         }
         foreach (GedcomTag::getFileFormTypes() as $typeName => $typeValue) {
             echo '<option value="', $typeName, '" ';
             if ($selectedValue === $typeName) {
                 echo 'selected';
             }
             echo '>', $typeValue, '</option>';
         }
         echo '</select>';
     } elseif ($fact === 'NAME' && $upperlevel !== 'REPO' && $upperlevel !== 'UNKNOWN' || $fact === '_MARNM') {
         // Populated in javascript from sub-tags
         echo '<input type="hidden" id="', $element_id, '" name="', $element_name, '" onchange="updateTextName(\'', $element_id, '\');" value="', Filter::escapeHtml($value), '" class="', $fact, '">';
         echo '<span id="', $element_id, '_display" dir="auto">', Filter::escapeHtml($value), '</span>';
         echo ' <a href="#edit_name" onclick="convertHidden(\'', $element_id, '\'); return false;" class="icon-edit_indi" title="' . I18N::translate('Edit name') . '"></a>';
     } else {
         // textarea
         if ($fact === 'TEXT' || $fact === 'ADDR' || $fact === 'NOTE' && !$islink) {
             echo '<textarea id="', $element_id, '" name="', $element_name, '" dir="auto">', Filter::escapeHtml($value), '</textarea><br>';
         } else {
             // text
             // If using GEDFact-assistant window
             if ($action === 'addnewnote_assisted') {
                 echo '<input type="text" id="', $element_id, '" name="', $element_name, '" value="', Filter::escapeHtml($value), '" style="width:4.1em;" dir="ltr"';
             } else {
                 echo '<input type="text" id="', $element_id, '" name="', $element_name, '" value="', Filter::escapeHtml($value), '" dir="ltr"';
             }
             echo ' class="', $fact, '"';
             if (in_array($fact, $subnamefacts)) {
                 echo ' onblur="updatewholename();" onkeyup="updatewholename();"';
             }
             // Extra markup for specific fact types
             switch ($fact) {
                 case 'ALIA':
                 case 'ASSO':
                 case '_ASSO':
                     echo ' data-autocomplete-type="ASSO" data-autocomplete-extra="input.DATE"';
                     break;
                 case 'DATE':
                     echo ' onblur="valid_date(this);" onmouseout="valid_date(this);"';
                     break;
                 case 'GIVN':
                     echo ' autofocus data-autocomplete-type="GIVN"';
                     break;
                 case 'LATI':
                     echo ' onblur="valid_lati_long(this, \'N\', \'S\');" onmouseout="valid_lati_long(this, \'N\', \'S\');"';
                     break;
                 case 'LONG':
                     echo ' onblur="valid_lati_long(this, \'E\', \'W\');" onmouseout="valid_lati_long(this, \'E\', \'W\');"';
                     break;
                 case 'NOTE':
                     // Shared notes. Inline notes are handled elsewhere.
                     echo ' data-autocomplete-type="NOTE"';
                     break;
                 case 'OBJE':
                     echo ' data-autocomplete-type="OBJE"';
                     break;
                 case 'PAGE':
                     echo ' data-autocomplete-type="PAGE" data-autocomplete-extra="#' . $source_element_id . '"';
                     break;
                 case 'PLAC':
                     echo ' data-autocomplete-type="PLAC"';
                     break;
                 case 'REPO':
                     echo ' data-autocomplete-type="REPO"';
                     break;
                 case 'SOUR':
                     $source_element_id = $element_id;
                     echo ' data-autocomplete-type="SOUR"';
                     break;
                 case 'SURN':
                 case '_MARNM_SURN':
                     echo ' data-autocomplete-type="SURN"';
                     break;
                 case 'TIME':
                     echo ' pattern="([0-1][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?" dir="ltr" placeholder="' . I18N::translate('hh:mm or hh:mm:ss') . '"';
                     break;
             }
             echo '>';
         }
         $tmp_array = array('TYPE', 'TIME', 'NOTE', 'SOUR', 'REPO', 'OBJE', 'ASSO', '_ASSO', 'AGE');
         // split PLAC
         if ($fact === 'PLAC') {
             echo '<div id="', $element_id, '_pop" style="display: inline;">';
             echo FunctionsPrint::printSpecialCharacterLink($element_id), ' ', FunctionsPrint::printFindPlaceLink($element_id);
             echo '<span  onclick="jQuery(\'tr[id^=', $upperlevel, '_LATI],tr[id^=', $upperlevel, '_LONG],tr[id^=LATI],tr[id^=LONG]\').toggle(\'fast\'); return false;" class="icon-target" title="', GedcomTag::getLabel('LATI'), ' / ', GedcomTag::getLabel('LONG'), '"></span>';
             echo '</div>';
             if (Module::getModuleByName('places_assistant')) {
                 \PlacesAssistantModule::setup_place_subfields($element_id);
                 \PlacesAssistantModule::print_place_subfields($element_id);
             }
         } elseif (!in_array($fact, $tmp_array)) {
             echo FunctionsPrint::printSpecialCharacterLink($element_id);
         }
     }
     // MARRiage TYPE : hide text field and show a selection list
     if ($fact === 'TYPE' && $level === 2 && $tags[0] === 'MARR') {
         echo '<script>';
         echo 'document.getElementById(\'', $element_id, '\').style.display=\'none\'';
         echo '</script>';
         echo '<select id="', $element_id, '_sel" onchange="document.getElementById(\'', $element_id, '\').value=this.value;" >';
         foreach (array('Unknown', 'Civil', 'Religious', 'Partners') as $key) {
             if ($key === 'Unknown') {
                 echo '<option value="" ';
             } else {
                 echo '<option value="', $key, '" ';
             }
             $a = strtolower($key);
             $b = strtolower($value);
             if ($b !== '' && strpos($a, $b) !== false || strpos($b, $a) !== false) {
                 echo 'selected';
             }
             echo '>', GedcomTag::getLabel('MARR_' . strtoupper($key)), '</option>';
         }
         echo '</select>';
     } elseif ($fact === 'TYPE' && $level === 0) {
         // NAME TYPE : hide text field and show a selection list
         $onchange = 'onchange="document.getElementById(\'' . $element_id . '\').value=this.value;"';
         echo self::editFieldNameType($element_name, $value, $onchange, $person);
         echo '<script>document.getElementById("', $element_id, '").style.display="none";</script>';
     }
     // popup links
     switch ($fact) {
         case 'DATE':
             echo self::printCalendarPopup($element_id);
             break;
         case 'FAMC':
         case 'FAMS':
             echo FunctionsPrint::printFindFamilyLink($element_id);
             break;
         case 'ALIA':
         case 'ASSO':
         case '_ASSO':
             echo FunctionsPrint::printFindIndividualLink($element_id, $element_id . '_description');
             break;
         case 'FILE':
             FunctionsPrint::printFindMediaLink($element_id, '0file');
             break;
         case 'SOUR':
             echo FunctionsPrint::printFindSourceLink($element_id, $element_id . '_description'), ' ', self::printAddNewSourceLink($element_id);
             //-- checkboxes to apply '1 SOUR' to BIRT/MARR/DEAT as '2 SOUR'
             if ($level === 1) {
                 echo '<br>';
                 switch ($WT_TREE->getPreference('PREFER_LEVEL2_SOURCES')) {
                     case '2':
                         // records
                         $level1_checked = 'checked';
                         $level2_checked = '';
                         break;
                     case '1':
                         // facts
                         $level1_checked = '';
                         $level2_checked = 'checked';
                         break;
                     case '0':
                         // none
                     // none
                     default:
                         $level1_checked = '';
                         $level2_checked = '';
                         break;
                 }
                 if (strpos($bdm, 'B') !== false) {
                     echo ' <label><input type="checkbox" name="SOUR_INDI" ', $level1_checked, ' value="1">', I18N::translate('Individual'), '</label>';
                     if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
                         foreach ($matches[1] as $match) {
                             if (!in_array($match, explode('|', WT_EVENTS_DEAT))) {
                                 echo ' <label><input type="checkbox" name="SOUR_', $match, '" ', $level2_checked, ' value="1">', GedcomTag::getLabel($match), '</label>';
                             }
                         }
                     }
                 }
                 if (strpos($bdm, 'D') !== false) {
                     if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
                         foreach ($matches[1] as $match) {
                             if (in_array($match, explode('|', WT_EVENTS_DEAT))) {
                                 echo ' <label><input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="1">', GedcomTag::getLabel($match), '</label>';
                             }
                         }
                     }
                 }
                 if (strpos($bdm, 'M') !== false) {
                     echo ' <label><input type="checkbox" name="SOUR_FAM" ', $level1_checked, ' value="1">', I18N::translate('Family'), '</label>';
                     if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) {
                         foreach ($matches[1] as $match) {
                             echo ' <label><input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="1">', GedcomTag::getLabel($match), '</label>';
                         }
                     }
                 }
             }
             break;
         case 'REPO':
             echo FunctionsPrint::printFindRepositoryLink($element_id), ' ', self::printAddNewRepositoryLink($element_id);
             break;
         case 'NOTE':
             // Shared Notes Icons ========================================
             if ($islink) {
                 // Print regular Shared Note icons ---------------------------
                 echo ' ', FunctionsPrint::printFindNoteLink($element_id, $element_id . '_description'), ' ', self::printAddNewNoteLink($element_id);
                 if ($value) {
                     echo ' ', self::printEditNoteLink($value);
                 }
             }
             break;
         case 'OBJE':
             echo FunctionsPrint::printFindMediaLink($element_id, '1media');
             if (!$value) {
                 echo ' ', self::printAddNewMediaLink($element_id);
                 $value = 'new';
             }
             break;
     }
     echo '<div id="' . $element_id . '_description">';
     // current value
     if ($fact === 'DATE') {
         $date = new Date($value);
         echo $date->display();
     }
     if (($fact === 'ASSO' || $fact === '_ASSO') && $value === '') {
         if ($level === 1) {
             echo '<p class="small text-muted">' . I18N::translate('An associate is another individual who was involved with this individual, such as a friend or an employer.') . '</p>';
         } else {
             echo '<p class="small text-muted">' . I18N::translate('An associate is another individual who was involved with this fact or event, such as a witness or a priest.') . '</p>';
         }
     }
     if ($value && $value !== 'new' && $islink) {
         switch ($fact) {
             case 'ALIA':
             case 'ASSO':
             case '_ASSO':
                 $tmp = Individual::getInstance($value, $WT_TREE);
                 if ($tmp) {
                     echo ' ', $tmp->getFullName();
                 }
                 break;
             case 'SOUR':
                 $tmp = Source::getInstance($value, $WT_TREE);
                 if ($tmp) {
                     echo ' ', $tmp->getFullName();
                 }
                 break;
             case 'NOTE':
                 $tmp = Note::getInstance($value, $WT_TREE);
                 if ($tmp) {
                     echo ' ', $tmp->getFullName();
                 }
                 break;
             case 'OBJE':
                 $tmp = Media::getInstance($value, $WT_TREE);
                 if ($tmp) {
                     echo ' ', $tmp->getFullName();
                 }
                 break;
             case 'REPO':
                 $tmp = Repository::getInstance($value, $WT_TREE);
                 if ($tmp) {
                     echo ' ', $tmp->getFullName();
                 }
                 break;
         }
     }
     // pastable values
     if ($fact === 'FORM' && $upperlevel === 'OBJE') {
         FunctionsPrint::printAutoPasteLink($element_id, Config::fileFormats());
     }
     echo '</div>', $extra, '</td></tr>';
     return $element_id;
 }