function AddToSearchLog($log_message, $geds)
{
    global $WT_REQUEST;
    foreach (WT_Tree::getAll() as $tree) {
        WT_DB::prepare("INSERT INTO `##log` (log_type, log_message, ip_address, user_id, gedcom_id) VALUES ('search', ?, ?, ?, ?)")->execute(array((count(WT_Tree::getAll()) == count($geds) ? 'Global search: ' : 'Gedcom search: ') . $log_message, $WT_REQUEST->getClientIp(), WT_USER_ID ? WT_USER_ID : null, $tree->tree_id));
    }
}
Exemple #2
0
 public static function getGedcomMenu()
 {
     $menu = new WT_Menu(WT_I18N::translate('Home page'), 'index.php?ctype=gedcom&ged=' . WT_GEDURL, 'menu-tree');
     $ALLOW_CHANGE_GEDCOM = WT_Site::preference('ALLOW_CHANGE_GEDCOM') && count(WT_Tree::getAll()) > 1;
     foreach (WT_Tree::getAll() as $tree) {
         if ($tree->tree_id == WT_GED_ID || $ALLOW_CHANGE_GEDCOM) {
             $submenu = new WT_Menu($tree->tree_title_html, 'index.php?ctype=gedcom&ged=' . $tree->tree_name_url, 'menu-tree-' . $tree->tree_id);
             $menu->addSubmenu($submenu);
         }
     }
     return $menu;
 }
Exemple #3
0
			</tr>';
        }
        echo '<tr>
				<th colspan="4">', WT_I18N::translate('Family tree access and settings'), '</th>
			</tr>
			<tr>
				<td colspan="4">
					<table id="adduser2">
						<tr>
							<th>', WT_I18N::translate('Family tree'), '</th>
							<th>', WT_I18N::translate('Default individual'), help_link('default_individual'), '</th>
							<th>', WT_I18N::translate('Individual record'), help_link('useradmin_gedcomid'), '</th>
							<th>', WT_I18N::translate('Role'), help_link('role'), '</th>
							<th>', WT_I18N::translate('Restrict to immediate family'), help_link('RELATIONSHIP_PATH_LENGTH'), '</th>
						</tr>';
        foreach (WT_Tree::getAll() as $tree) {
            echo '<tr>', '<td>', $tree->tree_title_html, '</td>', '<td>';
            $varname = 'rootid' . $tree->tree_id;
            echo '<input data-autocomplete-type="INDI" data-autocomplete-ged="' . $tree->tree_name_html . '" type="text" size="12" name="', $varname, '" id="', $varname, '" value="', WT_Filter::escapeHtml(WT_Filter::post('rootid' . $tree->tree_id, WT_REGEX_XREF)), '"> ', print_findindi_link($varname, '', $tree->tree_name), '</td>', '<td>';
            $varname = 'gedcomid' . $tree->tree_id;
            echo '<input data-autocomplete-type="INDI" data-autocomplete-ged="' . $tree->tree_name_html . '" type="text" size="12" name="', $varname, '" id="', $varname, '" value="', WT_Filter::escapeHtml(WT_Filter::post('gedcomid' . $tree->tree_id, WT_REGEX_XREF)), '"> ', print_findindi_link($varname, '', $tree->tree_name), '</td>', '<td>';
            $varname = 'canedit' . $tree->tree_id;
            echo '<select name="', $varname, '">';
            foreach ($ALL_EDIT_OPTIONS as $EDIT_OPTION => $desc) {
                echo '<option value="', $EDIT_OPTION, '" ';
                if ($EDIT_OPTION == WT_I18N::translate('None')) {
                    echo 'selected="selected" ';
                }
                echo '>', $desc, '</option>';
            }
            echo '</select>', '</td>', '<td>';
Exemple #4
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;
             }
         }
     }
 }
Exemple #5
0
    private function adminPlaceCheck()
    {
        require_once WT_ROOT . 'includes/functions/functions_edit.php';
        $action = WT_Filter::get('action', '', 'go');
        $gedcom_id = WT_Filter::get('gedcom_id', null, WT_GED_ID);
        $country = WT_Filter::get('country', '.+', 'XYZ');
        $state = WT_Filter::get('state', '.+', 'XYZ');
        $matching = WT_Filter::getBool('matching');
        $controller = new WT_Controller_Page();
        $controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('Google Maps™'))->pageHeader();
        echo '
			<table id="gm_config">
				<tr>
					<th>
						<a href="module.php?mod=googlemap&amp;mod_action=admin_config">', WT_I18N::translate('Google Maps™ preferences'), '</a>
					</th>
					<th>
						<a href="module.php?mod=googlemap&amp;mod_action=admin_places">
							', WT_I18N::translate('Geographic data'), '
						</a>
					</th>
					<th>
						<a class="current" href="module.php?mod=googlemap&amp;mod_action=admin_placecheck">
							', WT_I18N::translate('Place check'), '
						</a>
					</th>
				</tr>
			</table>';
        //Start of User Defined options
        echo '
			<form method="get" name="placecheck" action="module.php">
				<input type="hidden" name="mod" value="', $this->getName(), '">
				<input type="hidden" name="mod_action" value="admin_placecheck">
				<div class="gm_check">
					<label>', WT_I18N::translate('Family tree'), '</label>';
        echo select_edit_control('gedcom_id', WT_Tree::getIdList(), null, $gedcom_id, ' onchange="this.form.submit();"');
        echo '<label>', WT_I18N::translate('Country'), '</label>
					<select name="country" onchange="this.form.submit();">
						<option value="XYZ" selected="selected">', WT_I18N::translate('&lt;select&gt;'), '</option>
						<option value="XYZ">', WT_I18N::translate('All'), '</option>';
        $rows = WT_DB::prepare("SELECT pl_id, pl_place FROM `##placelocation` WHERE pl_level=0 ORDER BY pl_place")->fetchAssoc();
        foreach ($rows as $id => $place) {
            echo '<option value="', WT_Filter::escapeHtml($place), '"';
            if ($place == $country) {
                echo ' selected="selected"';
                $par_id = $id;
            }
            echo '>', WT_Filter::escapeHtml($place), '</option>';
        }
        echo '</select>';
        if ($country != 'XYZ') {
            echo '<label>', WT_I18N::translate('Subdivision'), '</label>
							<select name="state" onchange="this.form.submit();">
								<option value="XYZ" selected="selected">', WT_I18N::translate('&lt;select&gt;'), '</option>
								<option value="XYZ">', WT_I18N::translate('All'), '</option>';
            $places = WT_DB::prepare("SELECT pl_place FROM `##placelocation` WHERE pl_parent_id=? ORDER BY pl_place")->execute(array($par_id))->fetchOneColumn();
            foreach ($places as $place) {
                echo '<option value="', WT_Filter::escapeHtml($place), '"', $place == $state ? ' selected="selected"' : '', '>', WT_Filter::escapeHtml($place), '</option>';
            }
            echo '</select>';
        }
        echo '<label>', WT_I18N::translate('Include fully matched places: '), '</label>';
        echo '<input type="checkbox" name="matching" value="1" onchange="this.form.submit();"';
        if ($matching) {
            echo ' checked="checked"';
        }
        echo '>';
        echo '</div>';
        // close div gm_check
        echo '<input type="hidden" name="action" value="go">';
        echo '</form>';
        //close form placecheck
        echo '<hr>';
        switch ($action) {
            case 'go':
                //Identify gedcom file
                $trees = WT_Tree::getAll();
                echo '<div id="gm_check_title">', $trees[$gedcom_id]->tree_title_html, '</div>';
                //Select all '2 PLAC ' tags in the file and create array
                $place_list = array();
                $ged_data = WT_DB::prepare("SELECT i_gedcom FROM `##individuals` WHERE i_gedcom LIKE ? AND i_file=?")->execute(array("%\n2 PLAC %", $gedcom_id))->fetchOneColumn();
                foreach ($ged_data as $ged_datum) {
                    preg_match_all('/\\n2 PLAC (.+)/', $ged_datum, $matches);
                    foreach ($matches[1] as $match) {
                        $place_list[$match] = true;
                    }
                }
                $ged_data = WT_DB::prepare("SELECT f_gedcom FROM `##families` WHERE f_gedcom LIKE ? AND f_file=?")->execute(array("%\n2 PLAC %", $gedcom_id))->fetchOneColumn();
                foreach ($ged_data as $ged_datum) {
                    preg_match_all('/\\n2 PLAC (.+)/', $ged_datum, $matches);
                    foreach ($matches[1] as $match) {
                        $place_list[$match] = true;
                    }
                }
                // Unique list of places
                $place_list = array_keys($place_list);
                // Apply_filter
                if ($country == 'XYZ') {
                    $filter = '.*$';
                } else {
                    $filter = preg_quote($country) . '$';
                    if ($state != 'XYZ') {
                        $filter = preg_quote($state) . ', ' . $filter;
                    }
                }
                $place_list = preg_grep('/' . $filter . '/', $place_list);
                //sort the array, limit to unique values, and count them
                usort($place_list, array('WT_I18N', 'strcasecmp'));
                $i = count($place_list);
                //calculate maximum no. of levels to display
                $x = 0;
                $max = 0;
                while ($x < $i) {
                    $levels = explode(",", $place_list[$x]);
                    $parts = count($levels);
                    if ($parts > $max) {
                        $max = $parts;
                    }
                    $x++;
                }
                $x = 0;
                //scripts for edit, add and refresh
                ?>
			<script>
			function edit_place_location(placeid) {
				window.open('module.php?mod=googlemap&mod_action=places_edit&action=update&placeid='+placeid, '_blank', gmap_window_specs);
				return false;
			}

			function add_place_location(placeid) {
				window.open('module.php?mod=googlemap&mod_action=places_edit&action=add&placeid='+placeid, '_blank', gmap_window_specs);
				return false;
			}
			</script>
			<?php 
                //start to produce the display table
                $cols = 0;
                $span = $max * 3 + 3;
                echo '<div class="gm_check_details">';
                echo '<table class="gm_check_details"><tr>';
                echo '<th rowspan="3">', WT_I18N::translate('Place'), '</th>';
                echo '<th colspan="', $span, '">', WT_I18N::translate('Geographic data'), '</th></tr>';
                echo '<tr>';
                while ($cols < $max) {
                    if ($cols == 0) {
                        echo '<th colspan="3">', WT_I18N::translate('Country'), '</th>';
                    } else {
                        echo '<th colspan="3">', WT_I18N::translate('Level'), '&nbsp;', $cols + 1, '</th>';
                    }
                    $cols++;
                }
                echo '</tr><tr>';
                $cols = 0;
                while ($cols < $max) {
                    echo '<th>', WT_Gedcom_Tag::getLabel('PLAC'), '</th><th>', WT_I18N::translate('Latitude'), '</th><th>', WT_I18N::translate('Longitude'), '</th>';
                    $cols++;
                }
                echo '</tr>';
                $countrows = 0;
                $matched = array();
                while ($x < $i) {
                    $placestr = "";
                    $levels = explode(",", $place_list[$x]);
                    $parts = count($levels);
                    $levels = array_reverse($levels);
                    $placestr .= "<a href=\"placelist.php?action=show";
                    foreach ($levels as $pindex => $ppart) {
                        $ppart = urlencode(trim($ppart));
                        $placestr .= "&amp;parent[{$pindex}]=" . $ppart . "";
                    }
                    $placestr .= "\">" . $place_list[$x] . "</a>";
                    $gedplace = "<tr><td>" . $placestr . "</td>";
                    $z = 0;
                    $id = 0;
                    $level = 0;
                    $matched[$x] = 0;
                    // used to exclude places where the gedcom place is matched at all levels
                    $mapstr_edit = "<a href=\"#\" onclick=\"edit_place_location('";
                    $mapstr_add = "<a href=\"#\" onclick=\"add_place_location('";
                    $mapstr3 = "";
                    $mapstr4 = "";
                    $mapstr5 = "')\" title='";
                    $mapstr6 = "' >";
                    $mapstr7 = "')\">";
                    $mapstr8 = "</a>";
                    $plac = array();
                    $lati = array();
                    $long = array();
                    while ($z < $parts) {
                        if ($levels[$z] == ' ' || $levels[$z] == '') {
                            $levels[$z] = "unknown";
                        }
                        // GoogleMap module uses "unknown" while GEDCOM uses , ,
                        $levels[$z] = rtrim(ltrim($levels[$z]));
                        $placelist = $this->createPossiblePlaceNames($levels[$z], $z + 1);
                        // add the necessary prefix/postfix values to the place name
                        foreach ($placelist as $key => $placename) {
                            $row = WT_DB::prepare("SELECT pl_id, pl_place, pl_long, pl_lati, pl_zoom FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place")->execute(array($z, $id, $placename))->fetchOneRow(PDO::FETCH_ASSOC);
                            if (!empty($row['pl_id'])) {
                                $row['pl_placerequested'] = $levels[$z];
                                // keep the actual place name that was requested so we can display that instead of what is in the db
                                break;
                            }
                        }
                        if ($row['pl_id'] != '') {
                            $id = $row['pl_id'];
                        }
                        if ($row['pl_place'] != '') {
                            $placestr2 = $mapstr_edit . $id . "&amp;level=" . $level . $mapstr3 . $mapstr5 . WT_I18N::translate('Zoom=') . $row['pl_zoom'] . $mapstr6 . $row['pl_placerequested'] . $mapstr8;
                            if ($row['pl_place'] == 'unknown') {
                                $matched[$x]++;
                            }
                        } else {
                            if ($levels[$z] == "unknown") {
                                $placestr2 = $mapstr_add . $id . "&amp;level=" . $level . $mapstr3 . $mapstr7 . "<strong>" . rtrim(ltrim(WT_I18N::translate('unknown'))) . "</strong>" . $mapstr8;
                                $matched[$x]++;
                            } else {
                                $placestr2 = $mapstr_add . $id . "&amp;place_name=" . urlencode($levels[$z]) . "&amp;level=" . $level . $mapstr3 . $mapstr7 . '<span class="error">' . rtrim(ltrim($levels[$z])) . '</span>' . $mapstr8;
                                $matched[$x]++;
                            }
                        }
                        $plac[$z] = "<td>" . $placestr2 . "</td>\n";
                        if ($row['pl_lati'] == '0') {
                            $lati[$z] = "<td class='error'><strong>" . $row['pl_lati'] . "</strong></td>";
                        } elseif ($row['pl_lati'] != '') {
                            $lati[$z] = "<td>" . $row['pl_lati'] . "</td>";
                        } else {
                            $lati[$z] = "<td class='error center'><strong>X</strong></td>";
                            $matched[$x]++;
                        }
                        if ($row['pl_long'] == '0') {
                            $long[$z] = "<td class='error'><strong>" . $row['pl_long'] . "</strong></td>";
                        } elseif ($row['pl_long'] != '') {
                            $long[$z] = "<td>" . $row['pl_long'] . "</td>";
                        } else {
                            $long[$z] = "<td class='error center'><strong>X</strong></td>";
                            $matched[$x]++;
                        }
                        $level++;
                        $mapstr3 = $mapstr3 . "&amp;parent[" . $z . "]=" . WT_Filter::escapeJs($row['pl_placerequested']);
                        $mapstr4 = $mapstr4 . "&amp;parent[" . $z . "]=" . WT_Filter::escapeJs($levels[$z]);
                        $z++;
                    }
                    if ($matching) {
                        $matched[$x] = 1;
                    }
                    if ($matched[$x] != 0) {
                        echo $gedplace;
                        $z = 0;
                        while ($z < $max) {
                            if ($z < $parts) {
                                echo $plac[$z];
                                echo $lati[$z];
                                echo $long[$z];
                            } else {
                                echo '<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>';
                            }
                            $z++;
                        }
                        echo '</tr>';
                        $countrows++;
                    }
                    $x++;
                }
                // echo final row of table
                echo '<tr><td colspan="2" class="accepted">', WT_I18N::translate('Total places: %s', WT_I18N::number($countrows)), '</td></tr></table></div>';
                break;
            default:
                // Do not run until user selects a gedcom/place/etc.
                // Instead, show some useful help info.
                echo '<div class="gm_check_top accepted">', WT_I18N::translate('This will list all the places from the selected GEDCOM file. By default this will NOT INCLUDE places that are fully matched between the GEDCOM file and the GoogleMap tables'), '</div>';
                break;
        }
    }
Exemple #6
0
    public function configureBlock($block_id)
    {
        if (WT_Filter::postBool('save') && WT_Filter::checkCsrf()) {
            set_block_setting($block_id, 'gedcom', WT_Filter::post('gedcom'));
            set_block_setting($block_id, 'title', WT_Filter::post('title'));
            set_block_setting($block_id, 'html', WT_Filter::post('html'));
            set_block_setting($block_id, 'show_timestamp', WT_Filter::postBool('show_timestamp'));
            set_block_setting($block_id, 'timestamp', WT_Filter::post('timestamp'));
            $languages = array();
            foreach (WT_I18N::installed_languages() as $code => $name) {
                if (WT_Filter::postBool('lang_' . $code)) {
                    $languages[] = $code;
                }
            }
            set_block_setting($block_id, 'languages', implode(',', $languages));
            exit;
        }
        require_once WT_ROOT . 'includes/functions/functions_edit.php';
        $templates = array(WT_I18N::translate('Keyword examples') => '#getAllTagsTable#', WT_I18N::translate('Narrative description') => WT_I18N::translate('This GEDCOM (family tree) was last updated on #gedcomUpdated#. There are #totalSurnames# surnames in this family tree. The earliest recorded event is the #firstEventType# of #firstEventName# in #firstEventYear#. The most recent event is the #lastEventType# of #lastEventName# in #lastEventYear#.<br><br>If you have any comments or feedback please contact #contactWebmaster#.'), WT_I18N::translate('Statistics') => '<div class="gedcom_stats">
				<span style="font-weight: bold"><a href="index.php?command=gedcom">#gedcomTitle#</a></span><br>
				' . WT_I18N::translate('This family tree was last updated on %s.', '#gedcomUpdated#') . '
				<table id="keywords">
					<tr>
						<td valign="top" class="width20">
							<table cellspacing="1" cellpadding="0">
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Individuals') . '</td>
									<td class="facts_value" align="right"><a href="indilist.php?surname_sublist=no">#totalIndividuals#</a></td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Males') . '</td>
									<td class="facts_value" align="right">#totalSexMales#<br>#totalSexMalesPercentage#</td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Females') . '</td>
									<td class="facts_value" align="right">#totalSexFemales#<br>#totalSexFemalesPercentage#</td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Total surnames') . '</td>
									<td class="facts_value" align="right"><a href="indilist.php?show_all=yes&amp;surname_sublist=yes&amp;ged=' . WT_GEDURL . '">#totalSurnames#</a></td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Families') . '</td>
									<td class="facts_value" align="right"><a href="famlist.php?ged=' . WT_GEDURL . '">#totalFamilies#</a></td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Sources') . '</td>
									<td class="facts_value" align="right"><a href="sourcelist.php?ged=' . WT_GEDURL . '">#totalSources#</a></td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Media objects') . '</td>
									<td class="facts_value" align="right"><a href="medialist.php?ged=' . WT_GEDURL . '">#totalMedia#</a></td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Repositories') . '</td>
									<td class="facts_value" align="right"><a href="repolist.php?ged=' . WT_GEDURL . '">#totalRepositories#</a></td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Total events') . '</td>
									<td class="facts_value" align="right">#totalEvents#</td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Total users') . '</td>
									<td class="facts_value" align="right">#totalUsers#</td>
								</tr>
							</table>
						</td>
						<td><br></td>
						<td valign="top">
							<table cellspacing="1" cellpadding="0" border="0">
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Earliest birth year') . '</td>
									<td class="facts_value" align="right">#firstBirthYear#</td>
									<td class="facts_value">#firstBirth#</td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Latest birth year') . '</td>
									<td class="facts_value" align="right">#lastBirthYear#</td>
									<td class="facts_value">#lastBirth#</td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Earliest death year') . '</td>
									<td class="facts_value" align="right">#firstDeathYear#</td>
									<td class="facts_value">#firstDeath#</td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Latest death year') . '</td>
									<td class="facts_value" align="right">#lastDeathYear#</td>
									<td class="facts_value">#lastDeath#</td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Individual who lived the longest') . '</td>
									<td class="facts_value" align="right">#longestLifeAge#</td>
									<td class="facts_value">#longestLife#</td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Average age at death') . '</td>
									<td class="facts_value" align="right">#averageLifespan#</td>
									<td class="facts_value"></td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Family with the most children') . '</td>
									<td class="facts_value" align="right">#largestFamilySize#</td>
									<td class="facts_value">#largestFamily#</td>
								</tr>
								<tr>
									<td class="facts_label">' . WT_I18N::translate('Average number of children per family') . '</td>
									<td class="facts_value" align="right">#averageChildren#</td>
									<td class="facts_value"></td>
								</tr>
							</table>
						</td>
					</tr>
				</table><br>
				<span style="font-weight: bold">' . WT_I18N::translate('Most common surnames') . '</span><br>
				#commonSurnames#
			</div>');
        $title = get_block_setting($block_id, 'title');
        $html = get_block_setting($block_id, 'html');
        // title
        echo '<tr><td class="descriptionbox wrap">', WT_Gedcom_Tag::getLabel('TITL'), '</td><td class="optionbox"><input type="text" name="title" size="30" value="', WT_Filter::escapeHtml($title), '"></td></tr>';
        // templates
        echo '<tr><td class="descriptionbox wrap">', WT_I18N::translate('Templates'), help_link('block_html_template', $this->getName()), '</td><td class="optionbox">';
        // The CK editor needs lots of help to load/save data :-(
        if (array_key_exists('ckeditor', WT_Module::getActiveModules())) {
            $ckeditor_onchange = 'CKEDITOR.instances.html.setData(document.block.html.value);';
        } else {
            $ckeditor_onchange = '';
        }
        echo '<select name="template" onchange="document.block.html.value=document.block.template.options[document.block.template.selectedIndex].value;', $ckeditor_onchange, '">';
        echo '<option value="', WT_Filter::escapeHtml($html), '">', WT_I18N::translate('Custom'), '</option>';
        foreach ($templates as $title => $template) {
            echo '<option value="', WT_Filter::escapeHtml($template), '">', $title, '</option>';
        }
        echo '</select></td></tr>';
        // gedcom
        $gedcom = get_block_setting($block_id, 'gedcom');
        if (count(WT_Tree::getAll()) > 1) {
            if ($gedcom == '__current__') {
                $sel_current = ' selected="selected"';
            } else {
                $sel_current = '';
            }
            if ($gedcom == '__default__') {
                $sel_default = ' selected="selected"';
            } else {
                $sel_default = '';
            }
            echo '<tr><td class="descriptionbox wrap">', WT_I18N::translate('Family tree'), '</td><td class="optionbox">', '<select name="gedcom">', '<option value="__current__"', $sel_current, '>', WT_I18N::translate('Current'), '</option>', '<option value="__default__"', $sel_default, '>', WT_I18N::translate('Default'), '</option>';
            foreach (WT_Tree::getAll() as $tree) {
                if ($tree->tree_name == $gedcom) {
                    $sel = ' selected="selected"';
                } else {
                    $sel = '';
                }
                echo '<option value="', $tree->tree_name, '"', $sel, ' dir="auto">', $tree->tree_title_html, '</option>';
            }
            echo '</select></td></tr>';
        }
        // html
        echo '<tr><td colspan="2" class="descriptionbox">', WT_I18N::translate('Content'), help_link('block_html_content', $this->getName()), '</td></tr><tr>', '<td colspan="2" class="optionbox">';
        echo '<textarea name="html" class="html-edit" rows="10" style="width:98%;">', WT_Filter::escapeHtml($html), '</textarea>';
        echo '</td></tr>';
        $show_timestamp = get_block_setting($block_id, 'show_timestamp', false);
        echo '<tr><td class="descriptionbox wrap">';
        echo WT_I18N::translate('Show the date and time of update');
        echo '</td><td class="optionbox">';
        echo edit_field_yes_no('show_timestamp', $show_timestamp);
        echo '<input type="hidden" name="timestamp" value="', WT_TIMESTAMP, '">';
        echo '</td></tr>';
        $languages = get_block_setting($block_id, 'languages');
        echo '<tr><td class="descriptionbox wrap">';
        echo WT_I18N::translate('Show this block for which languages?');
        echo '</td><td class="optionbox">';
        echo edit_language_checkboxes('lang_', $languages);
        echo '</td></tr>';
    }
Exemple #7
0
 private function fetchFriendList()
 {
     global $WT_SESSION, $controller;
     $controller = new WT_Controller_Page();
     $controller->addInlineJavaScript("\n            \$('head').append('<link rel=\"stylesheet\" href=\"" . WT_MODULES_DIR . $this->getName() . "/facebook.css?v=" . WT_FACEBOOK_VERSION . "\" />');", WT_Controller_Page::JS_PRIORITY_LOW);
     $preApproved = unserialize($this->getSetting('preapproved'));
     if (WT_Filter::postArray('preApproved') && WT_Filter::checkCsrf()) {
         $roleRows = WT_Filter::postArray('preApproved');
         $fbUsernames = WT_Filter::postArray('facebook_username', WT_REGEX_USERNAME);
         foreach ($fbUsernames as $facebook_username) {
             $facebook_username = $this->cleanseFacebookUsername($facebook_username);
             $this->appendPreapproved($preApproved, $facebook_username, $roleRows);
         }
         $this->setSetting('preapproved', serialize($preApproved));
         WT_FlashMessages::addMessage(WT_I18N::translate('Users successfully imported from Facebook'));
         header("Location: module.php?mod=" . $this->getName() . "&mod_action=admin");
         exit;
     }
     if (empty($WT_SESSION->facebook_access_token)) {
         $this->error_page(WT_I18N::translate("You must <a href='%s'>login to the site via Facebook</a> in order to import friends from Facebook", "index.php?logout=1"));
     }
     $graph_url = "https://graph.facebook.com/" . self::api_dir . "me/friends?fields=first_name,last_name,name,username&access_token=" . $WT_SESSION->facebook_access_token;
     $friendsResponse = $this->fetch_url($graph_url);
     if ($friendsResponse === FALSE) {
         $this->error_page(WT_I18N::translate("Could not fetch your friends from Facebook. Note that this feature won't work for Facebook Apps created after 2014-04-30 due to a Facebook policy change."));
     }
     $controller->restrictAccess(\WT\Auth::isAdmin())->setPageTitle($this->getTitle())->pageHeader();
     $friends = json_decode($friendsResponse);
     if (empty($friends->data)) {
         $this->error_page(WT_I18N::translate("No friend data"));
         return;
     }
     function nameSort($a, $b)
     {
         return strcmp($a->last_name . " " . $a->first_name, $b->last_name . " " . $b->first_name);
     }
     usort($friends->data, "nameSort");
     echo "<form id='facebook_friend_list' method='post' action=''>";
     require_once WT_ROOT . 'includes/functions/functions_edit.php';
     // for select_edit_control
     $index = 0;
     foreach (WT_Tree::getAll() as $tree) {
         $class = $index++ % 2 ? 'odd' : 'even';
         echo "<label>" . $tree->tree_name_html . " - " . WT_I18N::translate('Role') . help_link('role') . ": " . select_edit_control('preApproved[' . $tree->tree_id . '][canedit]', $this->get_edit_options(), NULL, NULL) . "</label>";
     }
     foreach ($friends->data as $friend) {
         $facebook_username = $this->cleanseFacebookUsername(isset($friend->username) ? $friend->username : $friend->id);
         // Exclude friends who are already pre-approved or are current users
         if (isset($preApproved[$facebook_username]) || $this->get_user_id_from_facebook_username($facebook_username)) {
             continue;
         }
         echo "<label><input name='facebook_username[]' type='checkbox' value='" . $facebook_username . "'/>" . $friend->name . "</label>";
     }
     echo WT_Filter::getCsrf();
     echo "<button>Select Friends</button></form>";
 }
Exemple #8
0
 private function config()
 {
     require_once WT_ROOT . 'includes/functions/functions_edit.php';
     $controller = new WT_Controller_Page();
     $controller->setPageTitle($this->getTitle())->pageHeader();
     $faqs = WT_DB::prepare("SELECT block_id, block_order, gedcom_id, bs1.setting_value AS header, bs2.setting_value AS faqbody" . " FROM `##block` b" . " JOIN `##block_setting` bs1 USING (block_id)" . " JOIN `##block_setting` bs2 USING (block_id)" . " WHERE module_name = ?" . " AND bs1.setting_name = 'header'" . " AND bs2.setting_name = 'faqbody'" . " AND IFNULL(gedcom_id, ?) = ?" . " ORDER BY block_order")->execute(array($this->getName(), WT_GED_ID, WT_GED_ID))->fetchAll();
     $min_block_order = WT_DB::prepare("SELECT MIN(block_order) FROM `##block` WHERE module_name=?")->execute(array($this->getName()))->fetchOne();
     $max_block_order = WT_DB::prepare("SELECT MAX(block_order) FROM `##block` WHERE module_name=?")->execute(array($this->getName()))->fetchOne();
     echo '<p><form method="get" action="', WT_SCRIPT_NAME, '">', WT_I18N::translate('Family tree'), ' ', '<input type="hidden" name="mod", value="', $this->getName(), '">', '<input type="hidden" name="mod_action", value="admin_config">', select_edit_control('ged', WT_Tree::getNameList(), null, WT_GEDCOM), '<input type="submit" value="', WT_I18N::translate('show'), '">', '</form></p>';
     echo '<a href="module.php?mod=', $this->getName(), '&amp;mod_action=admin_edit">', WT_I18N::translate('Add an FAQ item'), '</a>';
     echo help_link('add_faq_item', $this->getName());
     echo '<table id="faq_edit">';
     if (empty($faqs)) {
         echo '<tr><td class="error center" colspan="5">', WT_I18N::translate('The FAQ list is empty.'), '</td></tr></table>';
     } else {
         $trees = WT_Tree::getAll();
         foreach ($faqs as $faq) {
             // NOTE: Print the position of the current item
             echo '<tr class="faq_edit_pos"><td>';
             echo WT_I18N::translate('Position item'), ': ', $faq->block_order + 1, ', ';
             if ($faq->gedcom_id == null) {
                 echo WT_I18N::translate('All');
             } else {
                 echo $trees[$faq->gedcom_id]->tree_title_html;
             }
             echo '</td>';
             // NOTE: Print the edit options of the current item
             echo '<td>';
             if ($faq->block_order == $min_block_order) {
                 echo '&nbsp;';
             } else {
                 echo '<a href="module.php?mod=', $this->getName(), '&amp;mod_action=admin_moveup&amp;block_id=', $faq->block_id, '" class="icon-uarrow"></a>';
                 echo help_link('moveup_faq_item', $this->getName());
             }
             echo '</td><td>';
             if ($faq->block_order == $max_block_order) {
                 echo '&nbsp;';
             } else {
                 echo '<a href="module.php?mod=', $this->getName(), '&amp;mod_action=admin_movedown&amp;block_id=', $faq->block_id, '" class="icon-darrow"></a>';
                 echo help_link('movedown_faq_item', $this->getName());
             }
             echo '</td><td>';
             echo '<a href="module.php?mod=', $this->getName(), '&amp;mod_action=admin_edit&amp;block_id=', $faq->block_id, '">', WT_I18N::translate('Edit'), '</a>';
             echo help_link('edit_faq_item', $this->getName());
             echo '</td><td>';
             echo '<a href="module.php?mod=', $this->getName(), '&amp;mod_action=admin_delete&amp;block_id=', $faq->block_id, '" onclick="return confirm(\'', WT_I18N::translate('Are you sure you want to delete this FAQ entry?'), '\');">', WT_I18N::translate('Delete'), '</a>';
             echo help_link('delete_faq_item', $this->getName());
             echo '</td></tr>';
             // NOTE: Print the title text of the current item
             echo '<tr><td colspan="5">';
             echo '<div class="faq_edit_item">';
             echo '<div class="faq_edit_title">', $faq->header, '</div>';
             // NOTE: Print the body text of the current item
             echo '<div class="faq_edit_content">', substr($faq->faqbody, 0, 1) == '<' ? $faq->faqbody : nl2br($faq->faqbody, false), '</div></div></td></tr>';
         }
         echo '</table>';
     }
 }
Exemple #9
0
 function gedcomTitle()
 {
     $trees = WT_Tree::getAll();
     return $trees[$this->_ged_id]->tree_title_html;
 }
Exemple #10
0
    function printResults()
    {
        require_once WT_ROOT . 'includes/functions/functions_print_lists.php';
        global $GEDCOM;
        $somethingPrinted = false;
        // whether anything printed
        // ---- section to search and display results on a general keyword search
        if ($this->action == "general" || $this->action == "soundex" || $this->action == "replace") {
            if ($this->myindilist || $this->myfamlist || $this->mysourcelist || $this->mynotelist) {
                $this->addInlineJavascript('jQuery("#search-result-tabs").tabs();');
                $this->addInlineJavascript('jQuery("#search-result-tabs").css("visibility", "visible");');
                $this->addInlineJavascript('jQuery(".loading-image").css("display", "none");');
                echo '<br>';
                echo '<div class="loading-image">&nbsp;</div>';
                echo '<div id="search-result-tabs"><ul>';
                if ($this->myindilist) {
                    echo '<li><a href="#searchAccordion-indi"><span id="indisource">', WT_I18N::translate('Individuals'), '</span></a></li>';
                }
                if ($this->myfamlist) {
                    echo '<li><a href="#searchAccordion-fam"><span id="famsource">', WT_I18N::translate('Families'), '</span></a></li>';
                }
                if ($this->mysourcelist) {
                    echo '<li><a href="#searchAccordion-source"><span id="mediasource">', WT_I18N::translate('Sources'), '</span></a></li>';
                }
                if ($this->mynotelist) {
                    echo '<li><a href="#searchAccordion-note"><span id="notesource">', WT_I18N::translate('Notes'), '</span></a></li>';
                }
                echo '</ul>';
                // individual results
                echo '<div id="searchAccordion-indi">';
                // Split individuals by tree
                $trees = WT_Tree::getAll();
                foreach ($this->sgeds as $ged_id => $gedcom) {
                    $datalist = array();
                    foreach ($this->myindilist as $individual) {
                        if ($individual->getGedcomId() == $ged_id) {
                            $datalist[] = $individual;
                        }
                    }
                    if ($datalist) {
                        $somethingPrinted = true;
                        usort($datalist, array('WT_GedcomRecord', 'compare'));
                        $GEDCOM = $gedcom;
                        load_gedcom_settings($ged_id);
                        echo '<h3 class="indi-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $trees[$ged_id]->tree_title_html, '</span></a></h3>
							<div class="indi-acc_content">', format_indi_table($datalist);
                        echo '</div>';
                        //indi-acc_content
                    }
                }
                echo '</div>';
                //#searchAccordion-indi
                $this->addInlineJavascript('jQuery("#searchAccordion-indi").accordion({heightStyle: "content", collapsible: true});');
                // family results
                echo '<div id="searchAccordion-fam">';
                // Split families by gedcom
                foreach ($this->sgeds as $ged_id => $gedcom) {
                    $datalist = array();
                    foreach ($this->myfamlist as $family) {
                        if ($family->getGedcomId() == $ged_id) {
                            $datalist[] = $family;
                        }
                    }
                    if ($datalist) {
                        $somethingPrinted = true;
                        usort($datalist, array('WT_GedcomRecord', 'compare'));
                        $GEDCOM = $gedcom;
                        load_gedcom_settings($ged_id);
                        echo '<h3 class="fam-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $trees[$ged_id]->tree_title_html, '</span></a></h3>
							<div class="fam-acc_content">', format_fam_table($datalist);
                        echo '</div>';
                        //fam-acc_content
                    }
                }
                echo '</div>';
                //#searchAccordion-fam
                $this->addInlineJavascript('jQuery("#searchAccordion-fam").accordion({heightStyle: "content", collapsible: true});');
                // source results
                echo '<div id="searchAccordion-source">';
                // Split sources by gedcom
                foreach ($this->sgeds as $ged_id => $gedcom) {
                    $datalist = array();
                    foreach ($this->mysourcelist as $source) {
                        if ($source->getGedcomId() == $ged_id) {
                            $datalist[] = $source;
                        }
                    }
                    if ($datalist) {
                        $somethingPrinted = true;
                        usort($datalist, array('WT_GedcomRecord', 'compare'));
                        $GEDCOM = $gedcom;
                        load_gedcom_settings($ged_id);
                        echo '<h3 class="source-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $trees[$ged_id]->tree_title_html, '</span></a></h3>
							<div class="source-acc_content">', format_sour_table($datalist);
                        echo '</div>';
                        //fam-acc_content
                    }
                }
                echo '</div>';
                //#searchAccordion-source
                $this->addInlineJavascript('jQuery("#searchAccordion-source").accordion({heightStyle: "content", collapsible: true});');
                // note results
                echo '<div id="searchAccordion-note">';
                // Split notes by gedcom
                foreach ($this->sgeds as $ged_id => $gedcom) {
                    $datalist = array();
                    foreach ($this->mynotelist as $note) {
                        if ($note->getGedcomId() == $ged_id) {
                            $datalist[] = $note;
                        }
                    }
                    if ($datalist) {
                        $somethingPrinted = true;
                        usort($datalist, array('WT_GedcomRecord', 'compare'));
                        $GEDCOM = $gedcom;
                        load_gedcom_settings($ged_id);
                        echo '<h3 class="note-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $trees[$ged_id]->tree_title_html, '</span></a></h3>
							<div class="note-acc_content">', format_note_table($datalist);
                        echo '</div>';
                        //note-acc_content
                    }
                }
                echo '</div>';
                //#searchAccordion-note
                $this->addInlineJavascript('jQuery("#searchAccordion-note").accordion({heightStyle: "content", collapsible: true});');
                $GEDCOM = WT_GEDCOM;
                load_gedcom_settings(WT_GED_ID);
                echo '</div>';
                //#search-result-tabs
            } elseif (isset($this->query)) {
                echo '<br><div class="warning center"><em>' . WT_I18N::translate('No results found.') . '</em><br>';
                if (!isset($this->srindi) && !isset($this->srfams) && !isset($this->srsour) && !isset($this->srnote)) {
                    echo '<em>' . WT_I18N::translate('Be sure to select an option to search for.') . '</em><br>';
                }
                echo '</div>';
            }
        }
        return $somethingPrinted;
        // whether anything printed
    }
Exemple #11
0
 private function admin()
 {
     $controller = new WT_Controller_Page();
     $controller->restrictAccess(Auth::isAdmin())->setPageTitle($this->getTitle())->pageHeader();
     // Save the updated preferences
     if (WT_Filter::post('action') == 'save') {
         foreach (WT_Tree::getAll() as $tree) {
             set_gedcom_setting($tree->tree_id, 'include_in_sitemap', WT_Filter::postBool('include' . $tree->tree_id));
         }
         // Clear cache and force files to be regenerated
         WT_DB::prepare("DELETE FROM `##module_setting` WHERE setting_name LIKE 'sitemap%'")->execute();
     }
     $include_any = false;
     echo '<h3>', $this->getTitle(), '</h3>', '<p>', WT_I18N::translate('Sitemaps are a way for webmasters to tell search engines about the pages on a website that are available for crawling.  All major search engines support sitemaps.  For more information, see <a href="http://www.sitemaps.org/">www.sitemaps.org</a>.') . '</p>', '<p>', WT_I18N::translate('Which family trees should be included in the sitemaps?'), '</p>', '<form method="post" action="module.php?mod=' . $this->getName() . '&amp;mod_action=admin">', '<input type="hidden" name="action" value="save">';
     foreach (WT_Tree::getAll() as $tree) {
         echo '<p><input type="checkbox" name="include', $tree->tree_id, '"';
         if (get_gedcom_setting($tree->tree_id, 'include_in_sitemap')) {
             echo ' checked="checked"';
             $include_any = true;
         }
         echo '>', $tree->tree_title_html, '</p>';
     }
     echo '<input type="submit" value="', WT_I18N::translate('save'), '">', '</form>', '<hr>';
     if ($include_any) {
         $site_map_url1 = WT_SERVER_NAME . WT_SCRIPT_PATH . 'module.php?mod=' . $this->getName() . '&amp;mod_action=generate&amp;file=sitemap.xml';
         $site_map_url2 = rawurlencode(WT_SERVER_NAME . WT_SCRIPT_PATH . 'module.php?mod=' . $this->getName() . '&mod_action=generate&file=sitemap.xml');
         echo '<p>', WT_I18N::translate('To tell search engines that sitemaps are available, you should add the following line to your robots.txt file.'), '</p>';
         echo '<pre>Sitemap: ', $site_map_url1, '</pre>', '<hr>', '<p>', WT_I18N::translate('To tell search engines that sitemaps are available, you can use the following links.'), '</p>', '<ul>', '<li><a target="_blank" href="http://www.bing.com/webmaster/ping.aspx?siteMap=' . $site_map_url2 . '">Bing</a></li>', '<li><a target="_blank" href="http://www.google.com/webmasters/tools/ping?sitemap=' . $site_map_url2 . '">Google</a></li>', '</ul>';
     }
 }