Esempio n. 1
0
    /**
     * Called by placelist.php
     *
     * @param string $placelevels
     */
    public function createMap($placelevels)
    {
        global $level, $levelm, $plzoom, $controller, $WT_TREE;
        Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
        $STREETVIEW = $this->getSetting('GM_USE_STREETVIEW');
        $parent = Filter::getArray('parent');
        // create the map
        echo '<table style="margin:20px auto 0 auto;"><tr valign="top"><td>';
        //<!-- start of map display -->
        echo '<table><tr valign="top">';
        echo '<td class="center" width="200px">';
        $levelm = $this->setLevelMap($level, $parent);
        $latlng = Database::prepare("SELECT pl_place, pl_id, pl_lati, pl_long, pl_zoom, sv_long, sv_lati, sv_bearing, sv_elevation, sv_zoom FROM `##placelocation` WHERE pl_id=?")->execute(array($levelm))->fetch(PDO::FETCH_ASSOC);
        if ($STREETVIEW && $level != 0) {
            echo '<div id="place_map" style="margin-top:20px; border:1px solid gray; width: ', $this->getSetting('GM_PH_XSIZE'), 'px; height: ', $this->getSetting('GM_PH_YSIZE'), 'px; ';
        } else {
            echo '<div id="place_map" style="border:1px solid gray; width:', $this->getSetting('GM_PH_XSIZE'), 'px; height:', $this->getSetting('GM_PH_YSIZE'), 'px; ';
        }
        echo "\"><i class=\"icon-loading-large\"></i></div>";
        echo '</td>';
        echo '<script src="', $this->googleMapsScript(), '"></script>';
        $plzoom = $latlng['pl_zoom'];
        // Map zoom level
        if (Auth::isAdmin()) {
            $placecheck_url = 'module.php?mod=googlemap&amp;mod_action=admin_placecheck';
            if ($parent && isset($parent[0])) {
                $placecheck_url .= '&amp;country=' . $parent[0];
                if (isset($parent[1])) {
                    $placecheck_url .= '&amp;state=' . $parent[1];
                }
            }
            $adminplaces_url = 'module.php?mod=googlemap&amp;mod_action=admin_places';
            if ($latlng && isset($latlng['pl_id'])) {
                $adminplaces_url .= '&amp;parent=' . $latlng['pl_id'];
            }
            echo '</tr><tr><td>';
            echo '<a href="module.php?mod=googlemap&amp;mod_action=admin_config">', I18N::translate('Google Maps™ preferences'), '</a>';
            echo '&nbsp;|&nbsp;';
            echo '<a href="' . $adminplaces_url . '">', I18N::translate('Geographic data'), '</a>';
            echo '&nbsp;|&nbsp;';
            echo '<a href="' . $placecheck_url . '">', I18N::translate('Place check'), '</a>';
            if (Module::getModuleByName('batch_update')) {
                $placelevels = preg_replace('/, ' . I18N::translate('unknown') . '/', ', ', $placelevels);
                // replace ", unknown" with ", "
                $placelevels = substr($placelevels, 2);
                // remove the leading ", "
                if ($placelevels) {
                    $batchupdate_url = 'module.php?mod=batch_update&amp;mod_action=admin_batch_update&amp;plugin=BatchUpdateSearchReplacePlugin&amp;method=exact&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;search=' . urlencode($placelevels);
                    // exact match
                    echo '&nbsp;|&nbsp;';
                    echo '<a href="' . $batchupdate_url . '">', I18N::translate('Batch update'), '</a>';
                }
            }
        }
        echo '</td></tr></table>';
        echo '</td>';
        echo '<td style="margin-left:15px; float:right;">';
        if ($STREETVIEW) {
            $controller->addInlineJavascript('
				function update_sv_params(placeid) {
					var svlati = document.getElementById("sv_latiText").value.slice(0, -1);
					var svlong = document.getElementById("sv_longText").value.slice(0, -1);
					var svbear = document.getElementById("sv_bearText").value.slice(0, -1);
					var svelev = document.getElementById("sv_elevText").value.slice(0, -1);
					var svzoom = document.getElementById("sv_zoomText").value;
					win03 = window.open("module.php?mod=googlemap&mod_action=places_edit&action=update_sv_params&placeid="+placeid+"&svlati="+svlati+"&svlong="+svlong+"&svbear="+svbear+"&svelev="+svelev+"&svzoom="+svzoom, "win03", indx_window_specs);
					if (window.focus) {win03.focus();}
				}
			');
            global $pl_lati, $pl_long;
            if ($level >= 1) {
                $pl_lati = str_replace(array('N', 'S', ','), array('', '-', '.'), $latlng['pl_lati']);
                // WT_placelocation lati
                $pl_long = str_replace(array('E', 'W', ','), array('', '-', '.'), $latlng['pl_long']);
                // WT_placelocation long
                // Check if Streetview location parameters are stored in database
                $placeid = $latlng['pl_id'];
                // Placelocation place id
                $sv_lat = $latlng['sv_lati'];
                // StreetView Point of View Latitude
                $sv_lng = $latlng['sv_long'];
                // StreetView Point of View Longitude
                $sv_dir = $latlng['sv_bearing'];
                // StreetView Point of View Direction (degrees from North)
                $sv_pitch = $latlng['sv_elevation'];
                // StreetView Point of View Elevation (+90 to -90 degrees (+=down, -=up)
                $sv_zoom = $latlng['sv_zoom'];
                // StreetView Point of View Zoom (0, 1, 2 or 3)
                // Check if Street View Lati/Long are the default of 0, if so use regular Place Lati/Long to set an initial location for the panda
                if ($latlng['sv_lati'] == 0 && $latlng['sv_long'] == 0) {
                    $sv_lat = $pl_lati;
                    $sv_lng = $pl_long;
                }
                ?>
				<div>
				<iframe style="background: transparent; margin-top: -3px; margin-left: 2px; width: 530px; height: 405px; padding: 0; border: 0;" src="module.php?mod=googlemap&amp;mod_action=wt_street_view&amp;x=<?php 
                echo $sv_lng;
                ?>
&amp;y=<?php 
                echo $sv_lat;
                ?>
&amp;z=18&amp;t=2&amp;c=1&amp;s=1&amp;b=<?php 
                echo $sv_dir;
                ?>
&amp;p=<?php 
                echo $sv_pitch;
                ?>
&amp;m=<?php 
                echo $sv_zoom;
                ?>
&amp;j=1&amp;k=1&amp;v=1" marginwidth="0" marginheight="0" frameborder="0" scrolling="no"></iframe>
				</div>

				<?php 
                $list_latlon = GedcomTag::getLabel('LATI') . "<input name='sv_latiText' id='sv_latiText' type='text' style='width:42px; background:none; border:none;' value='" . $sv_lat . "'>" . GedcomTag::getLabel('LONG') . "<input name='sv_longText' id='sv_longText' type='text' style='width:42px; background:none; border:none;' value='" . $sv_lng . "'>" . I18N::translate('Bearing') . "<input name='sv_bearText' id='sv_bearText' type='text' style='width:46px; background:none; border:none;' value='" . $sv_dir . "'>" . I18N::translate('Elevation') . "<input name='sv_elevText' id='sv_elevText' type='text' style='width:30px; background:none; border:none;' value='" . $sv_pitch . "'>" . I18N::translate('Zoom') . "<input name='sv_zoomText' id='sv_zoomText' type='text' style='width:30px; background:none; border:none;' value='" . $sv_zoom . "'>\n\t\t\t\t";
                if (Auth::isAdmin()) {
                    echo "<table align=\"center\" style=\"margin-left:6px; border:solid 1px black; width:522px; margin-top:-28px; background:#cccccc; \">";
                } else {
                    echo "<table align=\"center\" style=\"display:none; \">";
                }
                echo "<tr><td>";
                echo "<form style=\"text-align:left; margin-left:5px; font:11px verdana; color:blue;\" method=\"post\" action=\"\">";
                echo $list_latlon;
                echo "<input type=\"submit\" name=\"Submit\" onclick=\"update_sv_params({$placeid});\" value=\"", I18N::translate('save'), "\">";
                echo "</form>";
                echo "</td></tr>";
                echo "</table>";
            }
            // Next line puts Place hierarchy on new row -----
            echo '</td></tr><tr>';
        }
        // End Streetview window ===================================================================
    }
Esempio n. 2
0
     $sql_delete = "DELETE `##change` FROM `##change`" . " LEFT JOIN `##user` USING (user_id)" . " LEFT JOIN `##gedcom` USING (gedcom_id)";
     // gedcom may be deleted
     Database::prepare($sql_delete . $where)->execute($args);
     break;
 case 'export':
     header('Content-Type: text/csv');
     header('Content-Disposition: attachment; filename="webtrees-changes.csv"');
     $rows = Database::prepare($sql_select . $where . ' ORDER BY change_id')->execute($args)->fetchAll();
     foreach ($rows as $row) {
         echo '"', $row->change_time, '",', '"', $row->status, '",', '"', $row->xref, '",', '"', str_replace('"', '""', $row->old_gedcom), '",', '"', str_replace('"', '""', $row->new_gedcom), '",', '"', str_replace('"', '""', $row->user_name), '",', '"', str_replace('"', '""', $row->gedcom_name), '"', "\n";
     }
     return;
 case 'load_json':
     $start = Filter::getInteger('start');
     $length = Filter::getInteger('length');
     $order = Filter::getArray('order');
     if ($order) {
         $order_by = " ORDER BY ";
         foreach ($order as $key => $value) {
             if ($key > 0) {
                 $order_by .= ',';
             }
             // Datatables numbers columns 0, 1, 2, ...
             // MySQL numbers columns 1, 2, 3, ...
             switch ($value['dir']) {
                 case 'asc':
                     $order_by .= 1 + $value['column'] . " ASC ";
                     break;
                 case 'desc':
                     $order_by .= 1 + $value['column'] . " DESC ";
                     break;
Esempio n. 3
0
    /**
     * Called by placelist.php
     */
    public function createMap()
    {
        global $level, $levelm, $plzoom, $WT_TREE;
        Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
        $STREETVIEW = (bool) $this->getSetting('GM_USE_STREETVIEW');
        $parent = Filter::getArray('parent');
        $levelm = $this->setLevelMap($level, $parent);
        $latlng = Database::prepare("SELECT pl_place, pl_id, pl_lati, pl_long, pl_zoom, sv_long, sv_lati, sv_bearing, sv_elevation, sv_zoom FROM `##placelocation` WHERE pl_id=?")->execute(array($levelm))->fetch(PDO::FETCH_ASSOC);
        echo '<table style="margin:auto; border-collapse: collapse;">';
        echo '<tr style="vertical-align:top;"><td>';
        if ($STREETVIEW && $level != 0) {
            // Leave space for the Street View buttons, so that the maps align vertically
            echo '<div id="place_map" style="margin-top:25px; border:1px solid gray; width: ', $this->getSetting('GM_PH_XSIZE'), 'px; height: ', $this->getSetting('GM_PH_YSIZE'), 'px; ';
        } else {
            echo '<div id="place_map" style="border:1px solid gray; width:', $this->getSetting('GM_PH_XSIZE'), 'px; height:', $this->getSetting('GM_PH_YSIZE'), 'px; ';
        }
        echo '"><i class="icon-loading-large"></i></div>';
        echo '<script src="', $this->googleMapsScript(), '"></script>';
        $plzoom = $latlng['pl_zoom'];
        // Map zoom level
        if (Auth::isAdmin()) {
            $placecheck_url = 'module.php?mod=googlemap&amp;mod_action=admin_placecheck';
            if ($parent && isset($parent[0])) {
                $placecheck_url .= '&amp;country=' . $parent[0];
                if (isset($parent[1])) {
                    $placecheck_url .= '&amp;state=' . $parent[1];
                }
            }
            $adminplaces_url = 'module.php?mod=googlemap&amp;mod_action=admin_places';
            if ($latlng && isset($latlng['pl_id'])) {
                $adminplaces_url .= '&amp;parent=' . $latlng['pl_id'];
            }
            $update_places_url = 'admin_trees_places.php?ged=' . $WT_TREE->getNameHtml() . '&amp;search=' . urlencode(implode(', ', array_reverse($parent)));
            echo '<div class="gm-options">';
            echo '<a href="module.php?mod=googlemap&amp;mod_action=admin_config">', I18N::translate('Google Maps™ preferences'), '</a>';
            echo ' | <a href="' . $adminplaces_url . '">' . I18N::translate('Geographic data') . '</a>';
            echo ' | <a href="' . $placecheck_url . '">' . I18N::translate('Place check') . '</a>';
            echo ' | <a href="' . $update_places_url . '">' . I18N::translate('Update place names') . '</a>';
            echo '</div>';
        }
        echo '</td>';
        if ($STREETVIEW) {
            echo '<td>';
            global $pl_lati, $pl_long;
            if ($level >= 1) {
                $pl_lati = strtr($latlng['pl_lati'], array('N' => '', 'S' => '-', ',' => '.'));
                // WT_placelocation lati
                $pl_long = strtr($latlng['pl_long'], array('E' => '', 'W' => '-', ',' => '.'));
                // WT_placelocation long
                // Check if Streetview location parameters are stored in database
                $placeid = $latlng['pl_id'];
                // Placelocation place id
                $sv_lat = $latlng['sv_lati'];
                // StreetView Point of View Latitude
                $sv_lng = $latlng['sv_long'];
                // StreetView Point of View Longitude
                $sv_dir = $latlng['sv_bearing'];
                // StreetView Point of View Direction (degrees from North)
                $sv_pitch = $latlng['sv_elevation'];
                // StreetView Point of View Elevation (+90 to -90 degrees (+=down, -=up)
                $sv_zoom = $latlng['sv_zoom'];
                // StreetView Point of View Zoom (0, 1, 2 or 3)
                // Check if Street View Lati/Long are the default of 0, if so use regular Place Lati/Long to set an initial location for the panda
                if ($latlng['sv_lati'] == 0 && $latlng['sv_long'] == 0) {
                    $sv_lat = $pl_lati;
                    $sv_lng = $pl_long;
                }
                $frameheight = $this->getSetting('GM_PH_YSIZE') + 35;
                // Add height of buttons
                ?>
				<iframe class="gm-streetview-frame" style="height: <?php 
                echo $frameheight;
                ?>
px;" src="module.php?mod=googlemap&amp;mod_action=wt_street_view&amp;x=<?php 
                echo $sv_lng;
                ?>
&amp;y=<?php 
                echo $sv_lat;
                ?>
&amp;z=18&amp;t=2&amp;c=1&amp;s=1&amp;b=<?php 
                echo $sv_dir;
                ?>
&amp;p=<?php 
                echo $sv_pitch;
                ?>
&amp;m=<?php 
                echo $sv_zoom;
                ?>
&amp;j=1&amp;k=1&amp;v=1"></iframe>
				<?php 
                if (Auth::isAdmin()) {
                    ?>
					<div class="gm-streetview-parameters">
						<form method="post" action="module.php?mod=googlemap&amp;mod_action=places_edit">
							<?php 
                    echo Filter::getCsrf();
                    ?>
							<input type='hidden' name='placeid' value='<?php 
                    echo $placeid;
                    ?>
'>
							<input type='hidden' name='action' value='update_sv_params'>
							<input type='hidden' name='destination' value='<?php 
                    echo Filter::server("REQUEST_URI");
                    ?>
'>
							<label for='sv_latiText'><?php 
                    echo GedcomTag::getLabel('LATI');
                    ?>
</label>
							<input name='sv_latiText' id='sv_latiText' type='text' title="<?php 
                    echo $sv_lat;
                    ?>
" style='width:42px;' value='<?php 
                    echo $sv_lat;
                    ?>
'>
							<label for='sv_longText'><?php 
                    echo GedcomTag::getLabel('LONG');
                    ?>
</label>
							<input name='sv_longText' id='sv_longText' type='text' title="<?php 
                    echo $sv_lng;
                    ?>
" style='width:42px;' value='<?php 
                    echo $sv_lng;
                    ?>
'>
							<label for='sv_bearText'><?php 
                    echo I18N::translate('Bearing');
                    ?>
</label>
							<input name='sv_bearText' id='sv_bearText' type='text' style='width:30px;' value='<?php 
                    echo $sv_dir;
                    ?>
'>
							<label for='sv_elevText'><?php 
                    echo I18N::translate('Elevation');
                    ?>
</label>
							<input name='sv_elevText' id='sv_elevText' type='text' style='width:30px;' value='<?php 
                    echo $sv_pitch;
                    ?>
'>
							<label for='sv_zoomText'><?php 
                    echo I18N::translate('Zoom');
                    ?>
</label>
							<input name='sv_zoomText' id='sv_zoomText' type='text' style='width:30px;' value='<?php 
                    echo $sv_zoom;
                    ?>
'>
							<input type="submit" name="Submit" value="<?php 
                    echo I18N::translate('save');
                    ?>
">
						</form>
					</div>
					<?php 
                }
            }
            echo '</td>';
        }
        echo '</tr></table>';
    }
Esempio n. 4
0
 /**
  * Startup activity
  */
 public function __construct()
 {
     global $WT_TREE;
     parent::__construct();
     $this->setPageTitle(I18N::translate('Timeline'));
     $this->baseyear = (int) date('Y');
     $pids = Filter::getArray('pids', WT_REGEX_XREF);
     $remove = Filter::get('remove', WT_REGEX_XREF);
     foreach (array_unique($pids) as $pid) {
         if ($pid !== $remove) {
             $person = Individual::getInstance($pid, $WT_TREE);
             if ($person && $person->canShow()) {
                 $this->people[] = $person;
             }
         }
     }
     $this->pidlinks = '';
     foreach ($this->people as $indi) {
         // setup string of valid pids for links
         $this->pidlinks .= 'pids%5B%5D=' . $indi->getXref() . '&amp;';
         $bdate = $indi->getBirthDate();
         if ($bdate->isOK()) {
             $date = new GregorianDate($bdate->minimumJulianDay());
             $this->birthyears[$indi->getXref()] = $date->y;
             $this->birthmonths[$indi->getXref()] = max(1, $date->m);
             $this->birthdays[$indi->getXref()] = max(1, $date->d);
         }
         // find all the fact information
         $facts = $indi->getFacts();
         foreach ($indi->getSpouseFamilies() as $family) {
             foreach ($family->getFacts() as $fact) {
                 $facts[] = $fact;
             }
         }
         foreach ($facts as $event) {
             // get the fact type
             $fact = $event->getTag();
             if (!in_array($fact, $this->nonfacts)) {
                 // check for a date
                 $date = $event->getDate();
                 if ($date->isOK()) {
                     $date = new GregorianDate($date->minimumJulianDay());
                     $this->baseyear = min($this->baseyear, $date->y);
                     $this->topyear = max($this->topyear, $date->y);
                     if (!$indi->isDead()) {
                         $this->topyear = max($this->topyear, (int) date('Y'));
                     }
                     // do not add the same fact twice (prevents marriages from being added multiple times)
                     if (!in_array($event, $this->indifacts, true)) {
                         $this->indifacts[] = $event;
                     }
                 }
             }
         }
     }
     $scale = Filter::getInteger('scale', 0, 200);
     if ($scale === 0) {
         $this->scale = (int) (($this->topyear - $this->baseyear) / 20 * count($this->indifacts) / 4);
         if ($this->scale < 6) {
             $this->scale = 6;
         }
     } else {
         $this->scale = $scale;
     }
     if ($this->scale < 2) {
         $this->scale = 2;
     }
     $this->baseyear -= 5;
     $this->topyear += 5;
 }
Esempio n. 5
0
namespace Fisharebest\Webtrees;

/**
 * Defined in session.php
 *
 * @global Tree $WT_TREE
 */
global $WT_TREE;
use Fisharebest\Webtrees\Controller\PageController;
use Fisharebest\Webtrees\Functions\FunctionsPrintLists;
define('WT_SCRIPT_NAME', 'placelist.php');
require './includes/session.php';
$controller = new PageController();
$action = Filter::get('action', 'find|show', 'find');
$display = Filter::get('display', 'hierarchy|list', 'hierarchy');
$parent = Filter::getArray('parent');
$level = count($parent);
if ($display == 'hierarchy') {
    if ($level) {
        $controller->setPageTitle(I18N::translate('Place hierarchy') . ' - <span dir="auto">' . Filter::escapeHtml(end($parent)) . '</span>');
    } else {
        $controller->setPageTitle(I18N::translate('Place hierarchy'));
    }
} else {
    $controller->setPageTitle(I18N::translate('Place list'));
}
$controller->pageHeader();
echo '<div id="place-hierarchy">';
switch ($display) {
    case 'list':
        echo '<h2>', $controller->getPageTitle(), '</h2>';