コード例 #1
0
ファイル: module.php プロジェクト: jpretired/jp-webtrees
    private function config()
    {
        global $WT_TREE;
        $controller = new webtrees\Controller\PageController();
        $controller->restrictAccess(webtrees\Auth::isManager($WT_TREE))->setPageTitle($this->getTitle())->pageHeader();
        $args = array();
        $args['module_name'] = $this->getName();
        $args['tree_id'] = $WT_TREE->getTreeId();
        $items = webtrees\Database::prepare("SELECT block_id, block_order, gedcom_id, bs1.setting_value AS menu_title, bs2.setting_value AS menu_address" . " FROM `##block` b" . " JOIN `##block_setting` bs1 USING (block_id)" . " JOIN `##block_setting` bs2 USING (block_id)" . " WHERE module_name = :module_name" . " AND bs1.setting_name = 'menu_title'" . " AND bs2.setting_name = 'menu_address'" . " AND IFNULL(gedcom_id, :tree_id) = :tree_id" . " ORDER BY block_order")->execute($args)->fetchAll();
        unset($args['tree_id']);
        $min_block_order = webtrees\Database::prepare("SELECT MIN(block_order) FROM `##block` WHERE module_name = :module_name")->execute($args)->fetchOne();
        $max_block_order = webtrees\Database::prepare("SELECT MAX(block_order) FROM `##block` WHERE module_name = :module_name")->execute($args)->fetchOne();
        ?>
		
		<style>
			.text-left-not-xs, .text-left-not-sm, .text-left-not-md, .text-left-not-lg {
				text-align: left;
			}
			.text-center-not-xs, .text-center-not-sm, .text-center-not-md, .text-center-not-lg {
				text-align: center;
			}
			.text-right-not-xs, .text-right-not-sm, .text-right-not-md, .text-right-not-lg {
				text-align: right;
			}
			.text-justify-not-xs, .text-justify-not-sm, .text-justify-not-md, .text-justify-not-lg {
				text-align: justify;
			}

			@media (max-width: 767px) {
				.text-left-not-xs, .text-center-not-xs, .text-right-not-xs, .text-justify-not-xs {
					text-align: inherit;
				}
				.text-left-xs {
					text-align: left;
				}
				.text-center-xs {
					text-align: center;
				}
				.text-right-xs {
					text-align: right;
				}
				.text-justify-xs {
					text-align: justify;
				}
			}
			@media (min-width: 768px) and (max-width: 991px) {
				.text-left-not-sm, .text-center-not-sm, .text-right-not-sm, .text-justify-not-sm {
					text-align: inherit;
				}
				.text-left-sm {
					text-align: left;
				}
				.text-center-sm {
					text-align: center;
				}
				.text-right-sm {
					text-align: right;
				}
				.text-justify-sm {
					text-align: justify;
				}
			}
			@media (min-width: 992px) and (max-width: 1199px) {
				.text-left-not-md, .text-center-not-md, .text-right-not-md, .text-justify-not-md {
					text-align: inherit;
				}
				.text-left-md {
					text-align: left;
				}
				.text-center-md {
					text-align: center;
				}
				.text-right-md {
					text-align: right;
				}
				.text-justify-md {
					text-align: justify;
				}
			}
			@media (min-width: 1200px) {
				.text-left-not-lg, .text-center-not-lg, .text-right-not-lg, .text-justify-not-lg {
					text-align: inherit;
				}
				.text-left-lg {
					text-align: left;
				}
				.text-center-lg {
					text-align: center;
				}
				.text-right-lg {
					text-align: right;
				}
				.text-justify-lg {
					text-align: justify;
				}
			}
		</style>
		
		<ol class="breadcrumb small">
			<li><a href="admin.php"><?php 
        echo webtrees\I18N::translate('Control panel');
        ?>
</a></li>
			<li><a href="admin_modules.php"><?php 
        echo webtrees\I18N::translate('Module administration');
        ?>
</a></li>
			<li class="active"><?php 
        echo $controller->getPageTitle();
        ?>
</li>
		</ol>
		
		<div class="row">
			<div class="col-sm-4 col-xs-12">
				<form class="form">
					<label for="ged" class="sr-only">
						<?php 
        echo webtrees\I18N::translate('Family tree');
        ?>
					</label>
					<input type="hidden" name="mod" value="<?php 
        echo $this->getName();
        ?>
">
					<input type="hidden" name="mod_action" value="admin_config">
					<div class="col-sm-9 col-xs-9" style="padding:0;">
						<?php 
        echo webtrees\Functions\FunctionsEdit::selectEditControl('ged', webtrees\Tree::getNameList(), null, $WT_TREE->getName(), 'class="form-control"');
        ?>
					</div>
					<div class="col-sm-3" style="padding:0;">
						<input type="submit" class="btn btn-primary" value="<?php 
        echo webtrees\I18N::translate('show');
        ?>
">
					</div>
				</form>
			</div>
			<span class="visible-xs hidden-sm hidden-md hidden-lg" style="display:block;"></br></br></span>
			<div class="col-sm-4 text-center text-left-xs col-xs-12">
				<p>
					<a href="module.php?mod=<?php 
        echo $this->getName();
        ?>
&amp;mod_action=admin_edit" class="btn btn-primary">
						<i class="fa fa-plus"></i>
						<?php 
        echo webtrees\I18N::translate('Add Menu');
        ?>
					</a>
				</p>
			</div>
			<div class="col-sm-4 text-right text-left-xs col-xs-12">		
				<?php 
        // TODO: Move to internal item/page
        if (file_exists(WT_MODULES_DIR . $this->getName() . '/readme.html')) {
            ?>
					<a href="<?php 
            echo WT_MODULES_DIR . $this->getName();
            ?>
/readme.html" class="btn btn-info">
						<i class="fa fa-newspaper-o"></i>
						<?php 
            echo webtrees\I18N::translate('ReadMe');
            ?>
					</a>
				<?php 
        }
        ?>
			</div>
		</div>
		
		<table class="table table-bordered table-condensed">
			<thead>
				<tr>
					<th class="col-sm-2"><?php 
        echo webtrees\I18N::translate('Position');
        ?>
</th>
					<th class="col-sm-4"><?php 
        echo webtrees\I18N::translate('Menu title');
        ?>
</th>
					<th class="col-sm-4"><?php 
        echo webtrees\I18N::translate('Menu address');
        ?>
</th>
					<th class="col-sm-2" colspan=4><?php 
        echo webtrees\I18N::translate('Controls');
        ?>
</th>
				</tr>
			</thead>
			<tbody>
				<?php 
        foreach ($items as $item) {
            ?>
				<tr>
					<td>
						<?php 
            echo $item->block_order, ', ';
            if ($item->gedcom_id == null) {
                echo webtrees\I18N::translate('All');
            } else {
                echo webtrees\Tree::findById($item->gedcom_id)->getTitleHtml();
            }
            ?>
					</td>
					<td>
						<?php 
            echo webtrees\Filter::escapeHtml(webtrees\I18N::translate($item->menu_title));
            ?>
					</td>
					<td>
						<?php 
            echo webtrees\Filter::escapeHtml(substr(webtrees\I18N::translate($item->menu_address), 0, 1) == '<' ? webtrees\I18N::translate($item->menu_address) : nl2br(webtrees\I18N::translate($item->menu_address)));
            ?>
					</td>
					<td class="text-center">
						<a href="module.php?mod=<?php 
            echo $this->getName();
            ?>
&amp;mod_action=admin_edit&amp;block_id=<?php 
            echo $item->block_id;
            ?>
">
							<div class="icon-edit">&nbsp;</div>
						</a>
					</td>
					<td class="text-center">
						<a href="module.php?mod=<?php 
            echo $this->getName();
            ?>
&amp;mod_action=admin_moveup&amp;block_id=<?php 
            echo $item->block_id;
            ?>
">
							<?php 
            if ($item->block_order == $min_block_order) {
                echo '&nbsp;';
            } else {
                echo '<div class="icon-uarrow">&nbsp;</div>';
            }
            ?>
						</a>
					</td>
					<td class="text-center">
						<a href="module.php?mod=<?php 
            echo $this->getName();
            ?>
&amp;mod_action=admin_movedown&amp;block_id=<?php 
            echo $item->block_id;
            ?>
">
							<?php 
            if ($item->block_order == $max_block_order) {
                echo '&nbsp;';
            } else {
                echo '<div class="icon-darrow">&nbsp;</div>';
            }
            ?>
						</a>
					</td>
					<td class="text-center">
						<a href="module.php?mod=<?php 
            echo $this->getName();
            ?>
&amp;mod_action=admin_delete&amp;block_id=<?php 
            echo $item->block_id;
            ?>
"
							onclick="return confirm('<?php 
            echo webtrees\I18N::translate('Are you sure you want to delete this menu?');
            ?>
');">
							<div class="icon-delete">&nbsp;</div>
						</a>
					</td>
				</tr>
				<?php 
        }
        ?>
			</tbody>
		</table>
<?php 
    }
コード例 #2
0
echo I18N::translate('User');
?>
			</label>
			<?php 
echo FunctionsEdit::selectEditControl('user', $users_array, '', $user, 'class="form-control"');
?>
		</div>

		<div class="form-group col-xs-6 col-md-3">
			<label for="gedc">
				<?php 
echo I18N::translate('Family tree');
?>
			</label>
			<?php 
echo FunctionsEdit::selectEditControl('gedc', Tree::getNameList(), '', $gedc, Auth::isAdmin() ? 'class="form-control"' : 'disabled class="form-control"');
?>
		</div>
	</div>

	<div class="row text-center">
		<button type="submit" class="btn btn-primary">
			<?php 
echo I18N::translate('Filter');
?>
		</button>

		<button type="submit" class="btn btn-primary" onclick="document.logs.action.value='export';return true;" <?php 
echo $action === 'show' ? '' : 'disabled';
?>
>
コード例 #3
0
ファイル: GoogleMapsModule.php プロジェクト: bxbroze/webtrees
    /**
     * Places administration.
     */
    private function adminPlaces()
    {
        global $WT_TREE;
        $action = Filter::get('action');
        $parent = Filter::get('parent');
        $inactive = Filter::getBool('inactive');
        $deleteRecord = Filter::get('deleteRecord');
        if (!isset($parent)) {
            $parent = 0;
        }
        $controller = new PageController();
        $controller->restrictAccess(Auth::isAdmin());
        if ($action == 'ExportFile' && Auth::isAdmin()) {
            $tmp = $this->placeIdToHierarchy($parent);
            $maxLevel = $this->getHighestLevel();
            if ($maxLevel > 8) {
                $maxLevel = 8;
            }
            $tmp[0] = 'places';
            $outputFileName = preg_replace('/[:;\\/\\\\(\\)\\{\\}\\[\\] $]/', '_', implode('-', $tmp)) . '.csv';
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename="' . $outputFileName . '"');
            echo '"', I18N::translate('Level'), '";"', I18N::translate('Country'), '";';
            if ($maxLevel > 0) {
                echo '"', I18N::translate('State'), '";';
            }
            if ($maxLevel > 1) {
                echo '"', I18N::translate('County'), '";';
            }
            if ($maxLevel > 2) {
                echo '"', I18N::translate('City'), '";';
            }
            if ($maxLevel > 3) {
                echo '"', I18N::translate('Place'), '";';
            }
            if ($maxLevel > 4) {
                echo '"', I18N::translate('Place'), '";';
            }
            if ($maxLevel > 5) {
                echo '"', I18N::translate('Place'), '";';
            }
            if ($maxLevel > 6) {
                echo '"', I18N::translate('Place'), '";';
            }
            if ($maxLevel > 7) {
                echo '"', I18N::translate('Place'), '";';
            }
            echo '"', I18N::translate('Longitude'), '";"', I18N::translate('Latitude'), '";';
            echo '"', I18N::translate('Zoom level'), '";"', I18N::translate('Icon'), '";', WT_EOL;
            $this->outputLevel($parent);
            exit;
        }
        $controller->setPageTitle(I18N::translate('Google Maps™'))->pageHeader();
        ?>
		<ol class="breadcrumb small">
			<li><a href="admin.php"><?php 
        echo I18N::translate('Control panel');
        ?>
</a></li>
			<li><a href="admin_modules.php"><?php 
        echo I18N::translate('Module administration');
        ?>
</a></li>
			<li class="active"><?php 
        echo $controller->getPageTitle();
        ?>
</li>
		</ol>

		<ul class="nav nav-tabs nav-justified" role="tablist">
			<li role="presentation">
				<a href="?mod=googlemap&amp;mod_action=admin_config" role="tab">
					<?php 
        echo I18N::translate('Google Maps™ preferences');
        ?>
				</a>
			</li>
			<li role="presentation" class="active">
				<a href="#">
					<?php 
        echo I18N::translate('Geographic data');
        ?>
				</a>
			</li>
			<li role="presentation">
				<a href="?mod=googlemap&amp;mod_action=admin_placecheck">
					<?php 
        echo I18N::translate('Place check');
        ?>
				</a>
			</li>
		</ul>

		<h2><?php 
        echo I18N::translate('Geographic data');
        ?>
</h2>
		<?php 
        if ($action == 'ImportGedcom') {
            $placelist = array();
            $j = 0;
            $gedcom_records = Database::prepare("SELECT i_gedcom FROM `##individuals` WHERE i_file=? UNION ALL SELECT f_gedcom FROM `##families` WHERE f_file=?")->execute(array($WT_TREE->getTreeId(), $WT_TREE->getTreeId()))->fetchOneColumn();
            foreach ($gedcom_records as $gedrec) {
                $i = 1;
                $placerec = Functions::getSubRecord(2, '2 PLAC', $gedrec, $i);
                while (!empty($placerec)) {
                    if (preg_match("/2 PLAC (.+)/", $placerec, $match)) {
                        $placelist[$j] = array();
                        $placelist[$j]['place'] = trim($match[1]);
                        if (preg_match("/4 LATI (.*)/", $placerec, $match)) {
                            $placelist[$j]['lati'] = trim($match[1]);
                            if ($placelist[$j]['lati'][0] != 'N' && $placelist[$j]['lati'][0] != 'S') {
                                if ($placelist[$j]['lati'] < 0) {
                                    $placelist[$j]['lati'][0] = 'S';
                                } else {
                                    $placelist[$j]['lati'] = 'N' . $placelist[$j]['lati'];
                                }
                            }
                        } else {
                            $placelist[$j]['lati'] = null;
                        }
                        if (preg_match("/4 LONG (.*)/", $placerec, $match)) {
                            $placelist[$j]['long'] = trim($match[1]);
                            if ($placelist[$j]['long'][0] != 'E' && $placelist[$j]['long'][0] != 'W') {
                                if ($placelist[$j]['long'] < 0) {
                                    $placelist[$j]['long'][0] = 'W';
                                } else {
                                    $placelist[$j]['long'] = 'E' . $placelist[$j]['long'];
                                }
                            }
                        } else {
                            $placelist[$j]['long'] = null;
                        }
                        $j = $j + 1;
                    }
                    $i = $i + 1;
                    $placerec = Functions::getSubRecord(2, '2 PLAC', $gedrec, $i);
                }
            }
            asort($placelist);
            $prevPlace = '';
            $prevLati = '';
            $prevLong = '';
            $placelistUniq = array();
            $j = 0;
            foreach ($placelist as $k => $place) {
                if ($place['place'] != $prevPlace) {
                    $placelistUniq[$j] = array();
                    $placelistUniq[$j]['place'] = $place['place'];
                    $placelistUniq[$j]['lati'] = $place['lati'];
                    $placelistUniq[$j]['long'] = $place['long'];
                    $j = $j + 1;
                } elseif ($place['place'] == $prevPlace && ($place['lati'] != $prevLati || $place['long'] != $prevLong)) {
                    if ($placelistUniq[$j - 1]['lati'] == 0 || $placelistUniq[$j - 1]['long'] == 0) {
                        $placelistUniq[$j - 1]['lati'] = $place['lati'];
                        $placelistUniq[$j - 1]['long'] = $place['long'];
                    } elseif ($place['lati'] != '0' || $place['long'] != '0') {
                        echo 'Difference: previous value = ', $prevPlace, ', ', $prevLati, ', ', $prevLong, ' current = ', $place['place'], ', ', $place['lati'], ', ', $place['long'], '<br>';
                    }
                }
                $prevPlace = $place['place'];
                $prevLati = $place['lati'];
                $prevLong = $place['long'];
            }
            $highestIndex = $this->getHighestIndex();
            $default_zoom_level = array(4, 7, 10, 12);
            foreach ($placelistUniq as $k => $place) {
                $parent = preg_split('/ *, */', $place['place']);
                $parent = array_reverse($parent);
                $parent_id = 0;
                for ($i = 0; $i < count($parent); $i++) {
                    if (!isset($default_zoom_level[$i])) {
                        $default_zoom_level[$i] = $default_zoom_level[$i - 1];
                    }
                    $escparent = $parent[$i];
                    if ($escparent == '') {
                        $escparent = 'Unknown';
                    }
                    $row = Database::prepare("SELECT pl_id, pl_long, pl_lati, pl_zoom FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ?")->execute(array($i, $parent_id, $escparent))->fetchOneRow();
                    if ($i < count($parent) - 1) {
                        // Create higher-level places, if necessary
                        if (empty($row)) {
                            $highestIndex++;
                            Database::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_zoom) VALUES (?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $default_zoom_level[$i]));
                            echo Filter::escapeHtml($escparent), '<br>';
                            $parent_id = $highestIndex;
                        } else {
                            $parent_id = $row->pl_id;
                        }
                    } else {
                        // Create lowest-level place, if necessary
                        if (empty($row->pl_id)) {
                            $highestIndex++;
                            Database::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_long, pl_lati, pl_zoom) VALUES (?, ?, ?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $place['long'], $place['lati'], $default_zoom_level[$i]));
                            echo Filter::escapeHtml($escparent), '<br>';
                        } else {
                            if (empty($row->pl_long) && empty($row->pl_lati) && $place['lati'] != '0' && $place['long'] != '0') {
                                Database::prepare("UPDATE `##placelocation` SET pl_lati=?, pl_long=? WHERE pl_id=?")->execute(array($place['lati'], $place['long'], $row->pl_id));
                                echo Filter::escapeHtml($escparent), '<br>';
                            }
                        }
                    }
                }
            }
            $parent = 0;
        }
        if ($action === 'ImportFile') {
            $placefiles = $this->findFiles(WT_MODULES_DIR . 'googlemap/extra');
            sort($placefiles);
            ?>
		<form class="form-horizontal" method="post" enctype="multipart/form-data" id="importfile" name="importfile" action="module.php?mod=googlemap&amp;mod_action=admin_places&amp;action=ImportFile2">

			<!-- PLACES FILE -->
			<div class="form-group">
				<label class="control-label col-sm-4" for="placesfile">
					<?php 
            echo I18N::translate('File containing places (CSV)');
            ?>
				</label>
				<div class="col-sm-8">
					<div class="btn btn-default">
					<input id="placesfile" type="file" name="placesfile">
					</div>
				</div>
			</div>

			<!-- LOCAL FILE -->
			<?php 
            if (count($placefiles) > 0) {
                ?>
			<div class="form-group">
				<label class="control-label col-sm-4" for="localfile">
					<?php 
                echo I18N::translate('Server file containing places (CSV)');
                ?>
				</label>
				<div class="col-sm-8">
					<div class="input-group">
						<span class="input-group-addon">
							<?php 
                echo WT_MODULES_DIR . 'googlemap/extra/';
                ?>
						</span>
						<?php 
                foreach ($placefiles as $p => $placefile) {
                    unset($placefiles[$p]);
                    $p = Filter::escapeHtml($placefile);
                    if (substr($placefile, 0, 1) == "/") {
                        $placefiles[$p] = substr($placefile, 1);
                    } else {
                        $placefiles[$p] = $placefile;
                    }
                }
                echo FunctionsEdit::selectEditControl('localfile', $placefiles, '', '', 'class="form-control"');
                ?>
					</div>
				</div>
			</div>
			<?php 
            }
            ?>

			<!-- CLEAR DATABASE -->
			<fieldset class="form-group">
				<legend class="control-label col-sm-4">
					<?php 
            echo I18N::translate('Delete all existing geographic data before importing the file.');
            ?>
				</legend>
				<div class="col-sm-8">
					<?php 
            echo FunctionsEdit::editFieldYesNo('cleardatabase', 0, 'class="radio-inline"');
            ?>
				</div>
			</fieldset>

			<!-- UPDATE ONLY -->
			<fieldset class="form-group">
				<legend class="control-label col-sm-4">
					<?php 
            echo I18N::translate('Do not create new locations, just import coordinates for existing locations.');
            ?>
				</legend>
				<div class="col-sm-8">
					<?php 
            echo FunctionsEdit::editFieldYesNo('updateonly', 0, 'class="radio-inline"');
            ?>
				</div>
			</fieldset>

			<!-- OVERWRITE DATA -->
			<fieldset class="form-group">
				<legend class="control-label col-sm-4">
					<?php 
            echo I18N::translate('Overwrite existing coordinates.');
            ?>
				</legend>
				<div class="col-sm-8">
					<?php 
            echo FunctionsEdit::editFieldYesNo('overwritedata', 0, 'class="radio-inline"');
            ?>
				</div>
			</fieldset>

			<!-- SAVE BUTTON -->
			<div class="form-group">
				<div class="col-sm-offset-4 col-sm-8">
					<button type="submit" class="btn btn-primary">
						<i class="fa fa-check"></i>
						<?php 
            echo I18N::translate('Continue adding');
            ?>
					</button>
				</div>
			</div>
		</form>
		<?php 
            exit;
        }
        if ($action === 'ImportFile2') {
            $country_names = array();
            $stats = new Stats($WT_TREE);
            foreach ($stats->iso3166() as $key => $value) {
                $country_names[$key] = I18N::translate($key);
            }
            if (Filter::postBool('cleardatabase')) {
                Database::exec("DELETE FROM `##placelocation` WHERE 1=1");
            }
            if (!empty($_FILES['placesfile']['tmp_name'])) {
                $lines = file($_FILES['placesfile']['tmp_name']);
            } elseif (!empty($_REQUEST['localfile'])) {
                $lines = file(WT_MODULES_DIR . 'googlemap/extra' . $_REQUEST['localfile']);
            }
            // Strip BYTE-ORDER-MARK, if present
            if (!empty($lines[0]) && substr($lines[0], 0, 3) === WT_UTF8_BOM) {
                $lines[0] = substr($lines[0], 3);
            }
            asort($lines);
            $highestIndex = $this->getHighestIndex();
            $placelist = array();
            $j = 0;
            $maxLevel = 0;
            foreach ($lines as $p => $placerec) {
                $fieldrec = explode(';', $placerec);
                if ($fieldrec[0] > $maxLevel) {
                    $maxLevel = $fieldrec[0];
                }
            }
            $fields = count($fieldrec);
            $set_icon = true;
            if (!is_dir(WT_MODULES_DIR . 'googlemap/places/flags/')) {
                $set_icon = false;
            }
            foreach ($lines as $p => $placerec) {
                $fieldrec = explode(';', $placerec);
                if (is_numeric($fieldrec[0]) && $fieldrec[0] <= $maxLevel) {
                    $placelist[$j] = array();
                    $placelist[$j]['place'] = '';
                    for ($ii = $fields - 4; $ii > 1; $ii--) {
                        if ($fieldrec[0] > $ii - 2) {
                            $placelist[$j]['place'] .= $fieldrec[$ii] . ',';
                        }
                    }
                    foreach ($country_names as $countrycode => $countryname) {
                        if ($countrycode == strtoupper($fieldrec[1])) {
                            $fieldrec[1] = $countryname;
                            break;
                        }
                    }
                    $placelist[$j]['place'] .= $fieldrec[1];
                    $placelist[$j]['long'] = $fieldrec[$fields - 4];
                    $placelist[$j]['lati'] = $fieldrec[$fields - 3];
                    $placelist[$j]['zoom'] = $fieldrec[$fields - 2];
                    if ($set_icon) {
                        $placelist[$j]['icon'] = trim($fieldrec[$fields - 1]);
                    } else {
                        $placelist[$j]['icon'] = '';
                    }
                    $j = $j + 1;
                }
            }
            $prevPlace = '';
            $prevLati = '';
            $prevLong = '';
            $placelistUniq = array();
            $j = 0;
            foreach ($placelist as $k => $place) {
                if ($place['place'] != $prevPlace) {
                    $placelistUniq[$j] = array();
                    $placelistUniq[$j]['place'] = $place['place'];
                    $placelistUniq[$j]['lati'] = $place['lati'];
                    $placelistUniq[$j]['long'] = $place['long'];
                    $placelistUniq[$j]['zoom'] = $place['zoom'];
                    $placelistUniq[$j]['icon'] = $place['icon'];
                    $j = $j + 1;
                } elseif ($place['place'] == $prevPlace && ($place['lati'] != $prevLati || $place['long'] != $prevLong)) {
                    if ($placelistUniq[$j - 1]['lati'] == 0 || $placelistUniq[$j - 1]['long'] == 0) {
                        $placelistUniq[$j - 1]['lati'] = $place['lati'];
                        $placelistUniq[$j - 1]['long'] = $place['long'];
                        $placelistUniq[$j - 1]['zoom'] = $place['zoom'];
                        $placelistUniq[$j - 1]['icon'] = $place['icon'];
                    } elseif ($place['lati'] != '0' || $place['long'] != '0') {
                        echo 'Difference: previous value = ', $prevPlace, ', ', $prevLati, ', ', $prevLong, ' current = ', $place['place'], ', ', $place['lati'], ', ', $place['long'], '<br>';
                    }
                }
                $prevPlace = $place['place'];
                $prevLati = $place['lati'];
                $prevLong = $place['long'];
            }
            $default_zoom_level = array();
            $default_zoom_level[0] = 4;
            $default_zoom_level[1] = 7;
            $default_zoom_level[2] = 10;
            $default_zoom_level[3] = 12;
            foreach ($placelistUniq as $k => $place) {
                $parent = explode(',', $place['place']);
                $parent = array_reverse($parent);
                $parent_id = 0;
                for ($i = 0; $i < count($parent); $i++) {
                    $escparent = $parent[$i];
                    if ($escparent == '') {
                        $escparent = 'Unknown';
                    }
                    $row = Database::prepare("SELECT pl_id, pl_long, pl_lati, pl_zoom, pl_icon FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place")->execute(array($i, $parent_id, $escparent))->fetchOneRow();
                    if (empty($row)) {
                        // this name does not yet exist: create entry
                        if (!Filter::postBool('updateonly')) {
                            $highestIndex = $highestIndex + 1;
                            if ($i + 1 == count($parent)) {
                                $zoomlevel = $place['zoom'];
                            } elseif (isset($default_zoom_level[$i])) {
                                $zoomlevel = $default_zoom_level[$i];
                            } else {
                                $zoomlevel = $this->getSetting('GM_MAX_ZOOM');
                            }
                            if ($place['lati'] == '0' || $place['long'] == '0' || $i + 1 < count($parent)) {
                                Database::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_zoom, pl_icon) VALUES (?, ?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $zoomlevel, $place['icon']));
                            } else {
                                //delete leading zero
                                $pl_lati = str_replace(array('N', 'S', ','), array('', '-', '.'), $place['lati']);
                                $pl_long = str_replace(array('E', 'W', ','), array('', '-', '.'), $place['long']);
                                if ($pl_lati >= 0) {
                                    $place['lati'] = 'N' . abs($pl_lati);
                                } elseif ($pl_lati < 0) {
                                    $place['lati'] = 'S' . abs($pl_lati);
                                }
                                if ($pl_long >= 0) {
                                    $place['long'] = 'E' . abs($pl_long);
                                } elseif ($pl_long < 0) {
                                    $place['long'] = 'W' . abs($pl_long);
                                }
                                Database::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_long, pl_lati, pl_zoom, pl_icon) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $place['long'], $place['lati'], $zoomlevel, $place['icon']));
                            }
                            $parent_id = $highestIndex;
                        }
                    } else {
                        $parent_id = $row->pl_id;
                        if (Filter::postBool('overwritedata') && $i + 1 == count($parent)) {
                            Database::prepare("UPDATE `##placelocation` SET pl_lati = ?, pl_long = ?, pl_zoom = ?, pl_icon = ? WHERE pl_id = ?")->execute(array($place['lati'], $place['long'], $place['zoom'], $place['icon'], $parent_id));
                        } else {
                            // Update only if existing data is missing
                            if (!$row->pl_long && !$row->pl_lati) {
                                Database::prepare("UPDATE `##placelocation` SET pl_lati = ?, pl_long = ? WHERE pl_id = ?")->execute(array($place['lati'], $place['long'], $parent_id));
                            }
                            if (!$row->pl_icon && $place['icon']) {
                                Database::prepare("UPDATE `##placelocation` SET pl_icon = ? WHERE pl_id = ?")->execute(array($place['icon'], $parent_id));
                            }
                        }
                    }
                }
            }
            $parent = 0;
        }
        if ($action == 'DeleteRecord') {
            $exists = Database::prepare("SELECT 1 FROM `##placelocation` WHERE pl_parent_id=?")->execute(array($deleteRecord))->fetchOne();
            if (!$exists) {
                Database::prepare("DELETE FROM `##placelocation` WHERE pl_id=?")->execute(array($deleteRecord));
            } else {
                echo '<table class="facts_table"><tr><td>', I18N::translate('Location not removed: this location contains sub-locations'), '</td></tr></table>';
            }
        }
        ?>
		<script>
		function updateList(inactive) {
			window.location.href='<?php 
        if (strstr($_SERVER['REQUEST_URI'], '&inactive', true)) {
            $uri = strstr($_SERVER['REQUEST_URI'], '&inactive', true);
        } else {
            $uri = $_SERVER['REQUEST_URI'];
        }
        echo $uri, '&inactive=';
        ?>
'+inactive;
		}

		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;
		}

		function delete_place(placeid) {
			var answer=confirm('<?php 
        echo I18N::translate('Remove this location?');
        ?>
');
			if (answer == true) {
				window.location = '<?php 
        echo Functions::getQueryUrl(array('action' => 'DeleteRecord'));
        ?>
&action=DeleteRecord&deleteRecord=' + placeid;
			}
		}
		</script>
		<p id="gm_breadcrumb">
			<?php 
        $where_am_i = $this->placeIdToHierarchy($parent);
        foreach (array_reverse($where_am_i, true) as $id => $place) {
            if ($id == $parent) {
                if ($place != 'Unknown') {
                    echo Filter::escapeHtml($place);
                } else {
                    echo I18N::translate('unknown');
                }
            } else {
                echo '<a href="module.php?mod=googlemap&mod_action=admin_places&parent=', $id, '&inactive=', $inactive, '">';
                if ($place != 'Unknown') {
                    echo Filter::escapeHtml($place), '</a>';
                } else {
                    echo I18N::translate('unknown'), '</a>';
                }
            }
            echo ' - ';
        }
        ?>
			<a href="module.php?mod=googlemap&mod_action=admin_places&parent=0&inactive=', $inactive, '"><?php 
        echo I18N::translate('Top level');
        ?>
</a>
		</p>

		<form class="form-inline" name="active" method="post" action="module.php?mod=googlemap&mod_action=admin_places&parent=', $parent, '&inactive=', $inactive, '">
			<div class="checkbox">
				<label for="inactive">
				   <?php 
        echo FunctionsEdit::checkbox('inactive', $inactive, 'onclick="updateList(this.checked)"');
        ?>
				   <?php 
        echo I18N::translate('Show inactive places');
        ?>
				</label>
			</div>
			<p class="small text-muted">
				<?php 
        echo I18N::translate('By default, the list shows only those places which can be found in your family trees.  You may have details for other places, such as those imported in bulk from an external file.  Selecting this option will show all places, including ones that are not currently used.');
        ?>
				<?php 
        echo I18N::translate('If you have a large number of inactive places, it can be slow to generate the list.');
        ?>
			</p>
		</form>

		<?php 
        $placelist = $this->getPlaceListLocation($parent, $inactive);
        echo '<div class="gm_plac_edit">';
        echo '<table class="table table-bordered table-condensed table-hover"><tr>';
        echo '<th>', GedcomTag::getLabel('PLAC'), '</th>';
        echo '<th>', GedcomTag::getLabel('LATI'), '</th>';
        echo '<th>', GedcomTag::getLabel('LONG'), '</th>';
        echo '<th>', I18N::translate('Zoom level'), '</th>';
        echo '<th>', I18N::translate('Icon'), '</th>';
        echo '<th>';
        echo I18N::translate('Edit'), '</th><th>', I18N::translate('Delete'), '</th></tr>';
        if (count($placelist) == 0) {
            echo '<tr><td colspan="7">', I18N::translate('No places found'), '</td></tr>';
        }
        foreach ($placelist as $place) {
            echo '<tr><td><a href="module.php?mod=googlemap&mod_action=admin_places&parent=', $place['place_id'], '&inactive=', $inactive, '">';
            if ($place['place'] != 'Unknown') {
                echo Filter::escapeHtml($place['place']), '</a></td>';
            } else {
                echo I18N::translate('unknown'), '</a></td>';
            }
            echo '<td>', $place['lati'], '</td>';
            echo '<td>', $place['long'], '</td>';
            echo '<td>', $place['zoom'], '</td>';
            echo '<td>';
            if ($place['icon']) {
                echo '<img src="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/', $place['icon'], '" width="25" height="15">';
            } else {
                if ($place['lati'] || $place['long']) {
                    echo '<img src="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/images/mm_20_red.png">';
                } else {
                    echo '<img src="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/images/mm_20_yellow.png">';
                }
            }
            echo '</td>';
            echo '<td class="narrow"><a href="#" onclick="edit_place_location(', $place['place_id'], ');return false;" class="icon-edit" title="', I18N::translate('Edit'), '"></a></td>';
            $noRows = Database::prepare("SELECT COUNT(pl_id) FROM `##placelocation` WHERE pl_parent_id=?")->execute(array($place['place_id']))->fetchOne();
            if ($noRows == 0) {
                ?>
				<td><a href="#" onclick="delete_place(<?php 
                echo $place['place_id'];
                ?>
);return false;" class="icon-delete" title="<?php 
                echo I18N::translate('Remove');
                ?>
"></a></td>
		<?php 
            } else {
                ?>
				<td><i class="icon-delete-grey"></i></td>
		<?php 
            }
            ?>
			</tr>
			<?php 
        }
        ?>
		</table>
		</div>

		<hr>
		<form class="form-horizontal" action="?" onsubmit="add_place_location(this.parent_id.options[this.parent_id.selectedIndex].value); return false;">
			<div class="form-group">
				<label class="form-control-static col-sm-4" for="parent_id">
					<?php 
        echo I18N::translate('Add a new geographic location');
        ?>
				</label>
				<div class="col-sm-8">
					<div class="col-sm-6">
						<?php 
        echo FunctionsEdit::selectEditControl('parent_id', $where_am_i, I18N::translate('Top level'), $parent, 'class="form-control"');
        ?>
					</div>
					<button type="submit" class="btn btn-default">
						<i class="fa fa-plus"></i>
						<?php 
        echo I18N::translate('Add');
        ?>
					</button>
				</div>
			</div>
		</form>

		<form class="form-horizontal" action="module.php" method="get">
			<input type="hidden" name="mod" value="googlemap">
			<input type="hidden" name="mod_action" value="admin_places">
			<input type="hidden" name="action" value="ImportGedcom">
			<div class="form-group">
				<label class="form-control-static col-sm-4" for="ged">
					<?php 
        echo I18N::translate('Import all places from a family tree');
        ?>
				</label>
				<div class="col-sm-8">
					<div class="col-sm-6">
						<?php 
        echo FunctionsEdit::selectEditControl('ged', Tree::getNameList(), null, $WT_TREE->getName(), 'class="form-control"');
        ?>
					</div>
					<button type="submit" class="btn btn-default">
						<i class="fa fa-upload"></i>
						<?php 
        echo I18N::translate('Import');
        ?>
					</button>
				</div>
			</div>
		</form>

		<form class="form-horizontal" action="module.php" method="get">
			<input type="hidden" name="mod" value="googlemap">
			<input type="hidden" name="mod_action" value="admin_places">
			<input type="hidden" name="action" value="ImportFile">
			<div class="form-group">
				<label class="form-control-static col-sm-4">
					<?php 
        echo I18N::translate('Upload geographic data');
        ?>
				</label>
				<div class="col-sm-8">
					<div class="col-sm-6">
						<button type="submit" class="btn btn-default">
							<i class="fa fa-upload"></i>
							<?php 
        echo I18N::translate('Upload');
        ?>
						</button>
					</div>
				</div>
			</div>
		</form>

		<form class="form-horizontal" action="module.php" method="get">
			<input type="hidden" name="mod" value="googlemap">
			<input type="hidden" name="mod_action" value="admin_places">
			<input type="hidden" name="action" value="ExportFile">
			<div class="form-group">
				<label class="form-control-static col-sm-4">
					<?php 
        echo I18N::translate('Download geographic data');
        ?>
				</label>
				<div class="col-sm-8">
					<div class="col-sm-6">
						<?php 
        echo FunctionsEdit::selectEditControl('parent', $where_am_i, I18N::translate('All'), $WT_TREE->getTreeId(), 'class="form-control"');
        ?>
					</div>
					<button type="submit" class="btn btn-default">
						<i class="fa fa-download"></i>
						<?php 
        echo I18N::translate('Download');
        ?>
					</button>
				</div>
			</div>
		</form>
		<?php 
    }
コード例 #4
0
                }
            }
            foreach (Tree::getAll() as $tree) {
                if (!in_array($tree->getName(), $basenames)) {
                    FlashMessages::addMessage(I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success');
                    $tree->delete();
                }
            }
        }
        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
        return;
}
$default_tree_title = I18N::translate('My family tree');
$default_tree_name = 'tree';
$default_tree_number = 1;
$existing_trees = Tree::getNameList();
while (array_key_exists($default_tree_name . $default_tree_number, $existing_trees)) {
    $default_tree_number++;
}
$default_tree_name .= $default_tree_number;
// Process GET actions
switch (Filter::get('action')) {
    case 'importform':
        $controller->setPageTitle($WT_TREE->getTitleHtml() . ' — ' . I18N::translate('Import a GEDCOM file'))->pageHeader();
        ?>
	<ol class="breadcrumb small">
		<li><a href="admin.php"><?php 
        echo I18N::translate('Control panel');
        ?>
</a></li>
		<li><a href="admin_trees_manage.php"><?php 
コード例 #5
0
    /**
     * Provide a form to manage the FAQs.
     */
    private function config()
    {
        global $WT_TREE;
        $controller = new PageController();
        $controller->restrictAccess(Auth::isAdmin())->setPageTitle(I18N::translate('Frequently asked questions'))->pageHeader();
        $faqs = Database::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 = :module_name" . " AND bs1.setting_name = 'header'" . " AND bs2.setting_name = 'faqbody'" . " AND IFNULL(gedcom_id, :tree_id_1) = :tree_id_2" . " ORDER BY block_order")->execute(array('module_name' => $this->getName(), 'tree_id_1' => $WT_TREE->getTreeId(), 'tree_id_2' => $WT_TREE->getTreeId()))->fetchAll();
        $min_block_order = Database::prepare("SELECT MIN(block_order) FROM `##block` WHERE module_name = 'faq' AND (gedcom_id = :tree_id OR gedcom_id IS NULL)")->execute(array('tree_id' => $WT_TREE->getTreeId()))->fetchOne();
        $max_block_order = Database::prepare("SELECT MAX(block_order) FROM `##block` WHERE module_name = 'faq' AND (gedcom_id = :tree_id OR gedcom_id IS NULL)")->execute(array('tree_id' => $WT_TREE->getTreeId()))->fetchOne();
        ?>
		<ol class="breadcrumb small">
			<li><a href="admin.php"><?php 
        echo I18N::translate('Control panel');
        ?>
</a></li>
			<li><a href="admin_modules.php"><?php 
        echo I18N::translate('Module administration');
        ?>
</a></li>
			<li class="active"><?php 
        echo $controller->getPageTitle();
        ?>
</li>
		</ol>
		<h2><?php 
        echo $controller->getPageTitle();
        ?>
</h2>
		<p>
			<?php 
        echo I18N::translate('FAQs are lists of questions and answers, which allow you to explain the site’s rules, policies, and procedures to your visitors.  Questions are typically concerned with privacy, copyright, user-accounts, unsuitable content, requirement for source-citations, etc.');
        ?>
			<?php 
        echo I18N::translate('You may use HTML to format the answer and to add links to other websites.');
        ?>
		</p>
		<form class="form form-inline">
			<label for="ged" class="sr-only">
				<?php 
        echo I18N::translate('Family tree');
        ?>
			</label>
			<input type="hidden" name="mod" value="<?php 
        echo $this->getName();
        ?>
">
			<input type="hidden" name="mod_action" value="admin_config">
			<?php 
        echo FunctionsEdit::selectEditControl('ged', Tree::getNameList(), null, $WT_TREE->getName(), 'class="form-control"');
        ?>
			<input type="submit" class="btn btn-primary" value="<?php 
        echo I18N::translate('show');
        ?>
">
		</form>

		<p>
			<a href="module.php?mod=<?php 
        echo $this->getName();
        ?>
&amp;mod_action=admin_edit" class="btn btn-default">
				<i class="fa fa-plus"></i>
				<?php 
        echo I18N::translate('Add an FAQ item');
        ?>
			</a>
		</p>

		<?php 
        echo '<table class="table table-bordered">';
        if (empty($faqs)) {
            echo '<tr><td class="error center" colspan="5">', I18N::translate('The FAQ list is empty.'), '</td></tr></table>';
        } else {
            foreach ($faqs as $faq) {
                // NOTE: Print the position of the current item
                echo '<tr class="faq_edit_pos"><td>';
                echo I18N::translate('#%s', $faq->block_order + 1), ' ';
                if ($faq->gedcom_id === null) {
                    echo I18N::translate('All');
                } else {
                    echo $WT_TREE->getTitleHtml();
                }
                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, '"><i class="fa fa-arrow-up"></i></i> ', I18N::translate('Move up'), '</a>';
                }
                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, '"><i class="fa fa-arrow-down"></i></i> ', I18N::translate('Move down'), '</a>';
                }
                echo '</td><td>';
                echo '<a href="module.php?mod=', $this->getName(), '&amp;mod_action=admin_edit&amp;block_id=', $faq->block_id, '"><i class="fa fa-pencil"></i> ', I18N::translate('Edit'), '</a>';
                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(\'', I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($faq->header)), '\');"><i class="fa fa-trash"></i> ', I18N::translate('Delete'), '</a>';
                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>';
        }
    }
コード例 #6
0
    /**
     * Main entry point
     *
     * @return string
     */
    private function main()
    {
        global $WT_TREE;
        $this->plugins = $this->getPluginList();
        // List of available plugins
        $this->plugin = Filter::get('plugin');
        // User parameters
        $this->xref = Filter::get('xref', WT_REGEX_XREF);
        $this->action = Filter::get('action');
        $this->data = Filter::get('data');
        // Don't do any processing until a plugin is chosen.
        if ($this->plugin && array_key_exists($this->plugin, $this->plugins)) {
            $this->PLUGIN = new $this->plugin();
            $this->PLUGIN->getOptions();
            $this->getAllXrefs();
            switch ($this->action) {
                case 'update':
                    $record = self::getLatestRecord($this->xref, $this->all_xrefs[$this->xref]);
                    if ($this->PLUGIN->doesRecordNeedUpdate($this->xref, $record)) {
                        $newrecord = $this->PLUGIN->updateRecord($this->xref, $record);
                        if ($newrecord != $record) {
                            if ($newrecord) {
                                GedcomRecord::getInstance($this->xref, $WT_TREE)->updateRecord($newrecord, $this->PLUGIN->chan);
                            } else {
                                GedcomRecord::getInstance($this->xref, $WT_TREE)->deleteRecord();
                            }
                        }
                    }
                    $this->xref = $this->findNextXref($this->xref);
                    break;
                case 'update_all':
                    foreach ($this->all_xrefs as $xref => $type) {
                        $record = self::getLatestRecord($xref, $type);
                        if ($this->PLUGIN->doesRecordNeedUpdate($xref, $record)) {
                            $newrecord = $this->PLUGIN->updateRecord($xref, $record);
                            if ($newrecord != $record) {
                                if ($newrecord) {
                                    GedcomRecord::getInstance($xref, $WT_TREE)->updateRecord($newrecord, $this->PLUGIN->chan);
                                } else {
                                    GedcomRecord::getInstance($xref, $WT_TREE)->deleteRecord();
                                }
                            }
                        }
                    }
                    $this->xref = '';
                    break;
            }
            // Make sure that our requested record really does need updating.
            // It may have been updated in another session, or may not have
            // been specified at all.
            if (array_key_exists($this->xref, $this->all_xrefs) && $this->PLUGIN->doesRecordNeedUpdate($this->xref, self::getLatestRecord($this->xref, $this->all_xrefs[$this->xref]))) {
                $this->curr_xref = $this->xref;
            }
            // The requested record doesn't need updating - find one that does
            if (!$this->curr_xref) {
                $this->curr_xref = $this->findNextXref($this->xref);
            }
            if (!$this->curr_xref) {
                $this->curr_xref = $this->findPrevXref($this->xref);
            }
            // If we've found a record to update, get details and look for the next/prev
            if ($this->curr_xref) {
                $this->prev_xref = $this->findPrevXref($this->curr_xref);
                $this->next_xref = $this->findNextXref($this->curr_xref);
            }
        }
        // HTML common to all pages
        $controller = new PageController();
        $controller->setPageTitle(I18N::translate('Batch update'))->restrictAccess(Auth::isAdmin())->pageHeader();
        echo $this->getJavascript();
        ?>
		<ol class="breadcrumb small">
			<li><a href="admin.php"><?php 
        echo I18N::translate('Control panel');
        ?>
</a></li>
			<li><a href="admin_modules.php"><?php 
        echo I18N::translate('Module administration');
        ?>
</a></li>
			<li class="active"><?php 
        echo $controller->getPageTitle();
        ?>
</li>
		</ol>
		<h2><?php 
        echo $controller->getPageTitle();
        ?>
</h2>
		
		<form id="batch_update_form" class="form-horizontal" action="module.php" method="get">
			<input type="hidden" name="mod" value="batch_update">
			<input type="hidden" name="mod_action" value="admin_batch_update">
			<input type="hidden" name="xref"   value="' . $this->xref . '">
			<input type="hidden" name="action" value=""><?php 
        // will be set by javascript for next update
        ?>
			<input type="hidden" name="data"   value=""><?php 
        // will be set by javascript for next update
        ?>
			<div class="form-group">
				<label class="control-label col-sm-3"><?php 
        echo I18N::translate('Family tree');
        ?>
</label>
				<div class="col-sm-9">
		<?php 
        echo FunctionsEdit::selectEditControl('ged', Tree::getNameList(), '', $WT_TREE->getName(), 'class="form-control" onchange="reset_reload();"');
        ?>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-sm-3"><?php 
        echo I18N::translate('Batch update');
        ?>
</label>
				<div class="col-sm-9">
					<select class="form-control" name="plugin" onchange="reset_reload();">
						<?php 
        if (!$this->plugin) {
            ?>
							<option value="" selected></option>
						<?php 
        }
        ?>
						<?php 
        foreach ($this->plugins as $class => $plugin) {
            ?>
							<option value="<?php 
            echo $class;
            ?>
" <?php 
            echo $this->plugin == $class ? 'selected' : '';
            ?>
><?php 
            echo $plugin->getName();
            ?>
</option>
					<?php 
        }
        ?>
					</select>
					<?php 
        if ($this->PLUGIN) {
            ?>
						<p class="small text-muted"><?php 
            echo $this->PLUGIN->getDescription();
            ?>
</p>
		<?php 
        }
        ?>
				</div>
			</div>

				<?php 
        if (!Auth::user()->getPreference('auto_accept')) {
            ?>
				<div class="alert alert-danger">
				<?php 
            echo I18N::translate('Your user account does not have “automatically approve changes” enabled.  You will only be able to change one record at a time.');
            ?>
				</div>
			<?php 
        }
        ?>

			<?php 
        // If a plugin is selected, display the details
        ?>
			<?php 
        if ($this->PLUGIN) {
            ?>
				<?php 
            echo $this->PLUGIN->getOptionsForm();
            ?>
				<?php 
            if (substr($this->action, -4) == '_all') {
                ?>
					<?php 
                // Reset - otherwise we might "undo all changes", which refreshes the
                ?>
					<?php 
                // page, which makes them all again!
                ?>
					<script>reset_reload();</script>
			<?php 
            } else {
                ?>
					<hr>
					<div id="batch_update2" class="col-sm-12">
						<?php 
                if ($this->curr_xref) {
                    ?>
							<?php 
                    // Create an object, so we can get the latest version of the name.
                    ?>
								<?php 
                    $this->record = GedcomRecord::getInstance($this->curr_xref, $WT_TREE);
                    ?>
			
							<div class="form-group">
								<?php 
                    echo self::createSubmitButton(I18N::translate('previous'), $this->prev_xref);
                    ?>
					<?php 
                    echo self::createSubmitButton(I18N::translate('next'), $this->next_xref);
                    ?>
							</div>
							<div class="form-group">
								<a class="lead" href="<?php 
                    echo $this->record->getHtmlUrl();
                    ?>
"><?php 
                    echo $this->record->getFullName();
                    ?>
</a>
					<?php 
                    echo $this->PLUGIN->getActionPreview($this->record);
                    ?>
							</div>
							<div class="form-group">
							<?php 
                    echo implode(' ', $this->PLUGIN->getActionButtons($this->curr_xref, $this->record));
                    ?>
							</div>
						<?php 
                } else {
                    ?>
							<div class="alert alert-info"><?php 
                    echo I18N::translate('Nothing found.');
                    ?>
</div>
					<?php 
                }
                ?>
					</div>
				<?php 
            }
            ?>
		<?php 
        }
        ?>
		</form>
		<?php 
    }
コード例 #7
0
ファイル: StoriesModule.php プロジェクト: tunandras/webtrees
    /**
     * The admin view - list, create, edit, delete stories.
     */
    private function config()
    {
        global $WT_TREE;
        $controller = new PageController();
        $controller->restrictAccess(Auth::isAdmin())->setPageTitle($this->getTitle())->pageHeader()->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)->addInlineJavascript('
				jQuery("#story_table").dataTable({
					' . I18N::datatablesI18N() . ',
					autoWidth: false,
					paging: true,
					pagingType: "full_numbers",
					lengthChange: true,
					filter: true,
					info: true,
					sorting: [[0,"asc"]],
					columns: [
						/* 0-name */ null,
						/* 1-NAME */ null,
						/* 2-NAME */ { sortable:false },
						/* 3-NAME */ { sortable:false }
					]
				});
			');
        $stories = Database::prepare("SELECT block_id, xref" . " FROM `##block` b" . " WHERE module_name=?" . " AND gedcom_id=?" . " ORDER BY xref")->execute(array($this->getName(), $WT_TREE->getTreeId()))->fetchAll();
        ?>
		<ol class="breadcrumb small">
			<li><a href="admin.php"><?php 
        echo I18N::translate('Control panel');
        ?>
</a></li>
			<li><a href="admin_modules.php"><?php 
        echo I18N::translate('Module administration');
        ?>
</a></li>
			<li class="active"><?php 
        echo $controller->getPageTitle();
        ?>
</li>
		</ol>

		<h1><?php 
        echo $controller->getPageTitle();
        ?>
</h1>

		<form class="form form-inline">
			<label for="ged" class="sr-only">
				<?php 
        echo I18N::translate('Family tree');
        ?>
			</label>
			<input type="hidden" name="mod" value="<?php 
        echo $this->getName();
        ?>
">
			<input type="hidden" name="mod_action" value="admin_config">
			<?php 
        echo FunctionsEdit::selectEditControl('ged', Tree::getNameList(), null, $WT_TREE->getName(), 'class="form-control"');
        ?>
			<input type="submit" class="btn btn-primary" value="<?php 
        echo I18N::translate('show');
        ?>
">
		</form>

		<p>
			<a href="module.php?mod=<?php 
        echo $this->getName();
        ?>
&amp;mod_action=admin_edit" class="btn btn-default">
				<i class="fa fa-plus"></i>
				<?php 
        echo I18N::translate('Add a story');
        ?>
			</a>
		</p>

		<table class="table table-bordered table-condensed">
			<thead>
				<tr>
					<th><?php 
        echo I18N::translate('Story title');
        ?>
</th>
					<th><?php 
        echo I18N::translate('Individual');
        ?>
</th>
					<th><?php 
        echo I18N::translate('Edit');
        ?>
</th>
					<th><?php 
        echo I18N::translate('Delete');
        ?>
</th>
				</tr>
			</thead>
			<tbody>
				<?php 
        foreach ($stories as $story) {
            ?>
				<tr>
					<td>
						<?php 
            echo Filter::escapeHtml($this->getBlockSetting($story->block_id, 'title'));
            ?>
					</td>
					<td>
						<?php 
            $individual = Individual::getInstance($story->xref, $WT_TREE);
            ?>
						<?php 
            if ($individual) {
                ?>
						<a href="<?php 
                echo $individual->getHtmlUrl();
                ?>
#stories">
							<?php 
                echo $individual->getFullName();
                ?>
						</a>
						<?php 
            } else {
                ?>
							<?php 
                echo $story->xref;
                ?>
						<?php 
            }
            ?>
						</td>
						<td>
							<a href="module.php?mod=<?php 
            echo $this->getName();
            ?>
&amp;mod_action=admin_edit&amp;block_id=<?php 
            echo $story->block_id;
            ?>
">
								<i class="fa fa-pencil"></i> <?php 
            echo I18N::translate('Edit');
            ?>
							</a>
						</td>
						<td>
							<a
								href="module.php?mod=<?php 
            echo $this->getName();
            ?>
&amp;mod_action=admin_delete&amp;block_id=<?php 
            echo $story->block_id;
            ?>
"
								onclick="return confirm('<?php 
            echo I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($this->getBlockSetting($story->block_id, 'title')));
            ?>
');"
							>
								<i class="fa fa-trash"></i> <?php 
            echo I18N::translate('Delete');
            ?>
							</a>
					</td>
				</tr>
				<?php 
        }
        ?>
			</tbody>
		</table>
		<?php 
    }
コード例 #8
0
ファイル: BatchUpdateModule.php プロジェクト: jflash/webtrees
 /**
  * Main entry point
  *
  * @return string
  */
 private function main()
 {
     global $WT_TREE;
     $this->plugins = $this->getPluginList();
     // List of available plugins
     $this->plugin = Filter::get('plugin');
     // User parameters
     $this->xref = Filter::get('xref', WT_REGEX_XREF);
     $this->action = Filter::get('action');
     $this->data = Filter::get('data');
     // Don't do any processing until a plugin is chosen.
     if ($this->plugin && array_key_exists($this->plugin, $this->plugins)) {
         $this->PLUGIN = new $this->plugin();
         $this->PLUGIN->getOptions();
         $this->getAllXrefs();
         switch ($this->action) {
             case 'update':
                 $record = self::getLatestRecord($this->xref, $this->all_xrefs[$this->xref]);
                 if ($this->PLUGIN->doesRecordNeedUpdate($this->xref, $record)) {
                     $newrecord = $this->PLUGIN->updateRecord($this->xref, $record);
                     if ($newrecord != $record) {
                         if ($newrecord) {
                             GedcomRecord::getInstance($this->xref, $WT_TREE)->updateRecord($newrecord, $this->PLUGIN->chan);
                         } else {
                             GedcomRecord::getInstance($this->xref, $WT_TREE)->deleteRecord();
                         }
                     }
                 }
                 $this->xref = $this->findNextXref($this->xref);
                 break;
             case 'update_all':
                 foreach ($this->all_xrefs as $xref => $type) {
                     $record = self::getLatestRecord($xref, $type);
                     if ($this->PLUGIN->doesRecordNeedUpdate($xref, $record)) {
                         $newrecord = $this->PLUGIN->updateRecord($xref, $record);
                         if ($newrecord != $record) {
                             if ($newrecord) {
                                 GedcomRecord::getInstance($this->xref, $WT_TREE)->updateRecord($newrecord, $this->PLUGIN->chan);
                             } else {
                                 GedcomRecord::getInstance($this->xref, $WT_TREE)->deleteRecord();
                             }
                         }
                     }
                 }
                 $this->xref = '';
                 break;
         }
         // Make sure that our requested record really does need updating.
         // It may have been updated in another session, or may not have
         // been specified at all.
         if (array_key_exists($this->xref, $this->all_xrefs) && $this->PLUGIN->doesRecordNeedUpdate($this->xref, self::getLatestRecord($this->xref, $this->all_xrefs[$this->xref]))) {
             $this->curr_xref = $this->xref;
         }
         // The requested record doesn't need updating - find one that does
         if (!$this->curr_xref) {
             $this->curr_xref = $this->findNextXref($this->xref);
         }
         if (!$this->curr_xref) {
             $this->curr_xref = $this->findPrevXref($this->xref);
         }
         // If we've found a record to update, get details and look for the next/prev
         if ($this->curr_xref) {
             $this->prev_xref = $this->findPrevXref($this->curr_xref);
             $this->next_xref = $this->findNextXref($this->curr_xref);
         }
     }
     // HTML common to all pages
     $html = $this->getJavascript() . '<form id="batch_update_form" action="module.php" method="get">' . '<input type="hidden" name="mod" value="batch_update">' . '<input type="hidden" name="mod_action" value="admin_batch_update">' . '<input type="hidden" name="xref"   value="' . $this->xref . '">' . '<input type="hidden" name="action" value="">' . '<input type="hidden" name="data"   value="">' . '<table id="batch_update"><tr>' . '<th>' . I18N::translate('Family tree') . '</th>' . '<td>' . FunctionsEdit::selectEditControl('ged', Tree::getNameList(), '', $WT_TREE->getName(), 'onchange="reset_reload();"') . '</td></tr><tr><th>' . I18N::translate('Batch update') . '</th><td><select name="plugin" onchange="reset_reload();">';
     if (!$this->plugin) {
         $html .= '<option value="" selected></option>';
     }
     foreach ($this->plugins as $class => $plugin) {
         $html .= '<option value="' . $class . '" ' . ($this->plugin == $class ? 'selected' : '') . '>' . $plugin->getName() . '</option>';
     }
     $html .= '</select>';
     if ($this->PLUGIN) {
         $html .= '<br><em>' . $this->PLUGIN->getDescription() . '</em>';
     }
     $html .= '</td></tr>';
     if (!Auth::user()->getPreference('auto_accept')) {
         $html .= '<tr><td colspan="2" class="warning">' . I18N::translate('Your user account does not have “automatically approve changes” enabled.  You will only be able to change one record at a time.') . '</td></tr>';
     }
     // If a plugin is selected, display the details
     if ($this->PLUGIN) {
         $html .= $this->PLUGIN->getOptionsForm();
         if (substr($this->action, -4) == '_all') {
             // Reset - otherwise we might "undo all changes", which refreshes the
             // page, which makes them all again!
             $html .= '<script>reset_reload();</script>';
         } else {
             if ($this->curr_xref) {
                 // Create an object, so we can get the latest version of the name.
                 $this->record = GedcomRecord::getInstance($this->curr_xref, $WT_TREE);
                 $html .= '</table><table id="batch_update2"><tr><td>' . self::createSubmitButton(I18N::translate('previous'), $this->prev_xref) . self::createSubmitButton(I18N::translate('next'), $this->next_xref) . '</td><th><a href="' . $this->record->getHtmlUrl() . '">' . $this->record->getFullName() . '</a>' . '</th>' . '</tr><tr><td valign="top">' . '<br>' . implode('<br>', $this->PLUGIN->getActionButtons($this->curr_xref, $this->record)) . '<br>' . '</td><td dir="ltr" align="left">' . $this->PLUGIN->getActionPreview($this->record) . '</td></tr>';
             } else {
                 $html .= '<tr><td class="accepted" colspan=2>' . I18N::translate('Nothing found.') . '</td></tr>';
             }
         }
     }
     $html .= '</table></form>';
     return $html;
 }