コード例 #1
0
ファイル: module.php プロジェクト: jpretired/jp-webtrees
    private function edit()
    {
        global $WT_TREE;
        if (webtrees\Filter::postBool('save') && webtrees\Filter::checkCsrf()) {
            $block_id = webtrees\Filter::post('block_id');
            if ($block_id) {
                webtrees\Database::prepare("UPDATE `##block` SET gedcom_id=NULLIF(?, ''), block_order=? WHERE block_id=?")->execute(array(webtrees\Filter::post('gedcom_id'), (int) webtrees\Filter::post('block_order'), $block_id));
            } else {
                webtrees\Database::prepare("INSERT INTO `##block` (gedcom_id, module_name, block_order) VALUES (NULLIF(?, ''), ?, ?)")->execute(array(webtrees\Filter::post('gedcom_id'), $this->getName(), (int) webtrees\Filter::post('block_order')));
                $block_id = webtrees\Database::getInstance()->lastInsertId();
            }
            $this->setBlockSetting($block_id, 'menu_title', webtrees\Filter::post('menu_title'));
            $this->setBlockSetting($block_id, 'menu_address', webtrees\Filter::post('menu_address'));
            $this->setBlockSetting($block_id, 'menu_access', webtrees\Filter::post('menu_access'));
            $languages = array();
            foreach (webtrees\I18N::installedLocales() as $locale) {
                if (webtrees\Filter::postBool('lang_' . $locale->languageTag())) {
                    $languages[] = $locale->languageTag();
                }
            }
            $this->setBlockSetting($block_id, 'languages', implode(',', $languages));
            $this->config();
        } else {
            $block_id = webtrees\Filter::get('block_id');
            $controller = new webtrees\Controller\PageController();
            $controller->restrictAccess(webtrees\Auth::isEditor($WT_TREE));
            if ($block_id) {
                $controller->setPageTitle(webtrees\I18N::translate('Edit menu'));
                $menu_title = $this->getBlockSetting($block_id, 'menu_title');
                $menu_address = $this->getBlockSetting($block_id, 'menu_address');
                $menu_access = $this->getBlockSetting($block_id, 'menu_access');
                $block_order = webtrees\Database::prepare("SELECT block_order FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne();
                $gedcom_id = webtrees\Database::prepare("SELECT gedcom_id FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne();
            } else {
                $controller->setPageTitle(webtrees\I18N::translate('Add menu'));
                $menu_access = 1;
                $menu_title = '';
                $menu_address = '';
                $block_order = webtrees\Database::prepare("SELECT IFNULL(MAX(block_order)+1, 0) FROM `##block` WHERE module_name=?")->execute(array($this->getName()))->fetchOne();
                $gedcom_id = $WT_TREE->getTreeId();
            }
            $controller->pageHeader();
            ?>
			
			<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><a href="module.php?mod=<?php 
            echo $this->getName();
            ?>
&mod_action=admin_config"><?php 
            echo webtrees\I18N::translate($this->getTitle());
            ?>
</a></li>
				<li class="active"><?php 
            echo $controller->getPageTitle();
            ?>
</li>
			</ol>
			
			<form class="form-horizontal" method="POST" action="#" name="menu" id="menuForm">
				<?php 
            echo webtrees\Filter::getCsrf();
            ?>
				<input type="hidden" name="save" value="1">
				<input type="hidden" name="block_id" value="<?php 
            echo $block_id;
            ?>
">
				<h3><?php 
            echo webtrees\I18N::translate('General');
            ?>
</h3>
				
				<div class="form-group">
					<label class="control-label col-sm-3" for="menu_title">
						<?php 
            echo webtrees\I18N::translate('Title');
            ?>
					</label>
					<div class="col-sm-9">
						<input
							class="form-control"
							id="menu_title"
							size="90"
							name="menu_title"
							required
							type="text"
							value="<?php 
            echo webtrees\Filter::escapeHtml($menu_title);
            ?>
"
							>
					</div>
					<span class="help-block col-sm-9 col-sm-offset-3 small text-muted">
						<?php 
            echo webtrees\I18N::translate('Add your menu title here');
            ?>
					</span>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-3" for="menu_address">
						<?php 
            echo webtrees\I18N::translate('Menu address');
            ?>
					</label>
					<div class="col-sm-9">
						<input
							class="form-control"
							id="menu_address"
							size="90"
							name="menu_address"
							required
							type="text"
							value="<?php 
            echo webtrees\Filter::escapeHtml($menu_address);
            ?>
"
							>
					</div>
					<span class="help-block col-sm-9 col-sm-offset-3 small text-muted">
						<?php 
            echo webtrees\I18N::translate('Add your menu address here');
            ?>
					</span>
				</div>
				
				<h3><?php 
            echo webtrees\I18N::translate('Languages');
            ?>
</h3>
				
				<div class="form-group">
					<label class="control-label col-sm-3" for="lang_*">
						<?php 
            echo webtrees\I18N::translate('Show this menu for which languages?');
            ?>
					</label>
					<div class="col-sm-9">
						<?php 
            $accepted_languages = explode(',', $this->getBlockSetting($block_id, 'languages'));
            foreach (webtrees\I18N::installedLocales() as $locale) {
                ?>
								<div class="checkbox">
									<label title="<?php 
                echo $locale->languageTag();
                ?>
">
										<input type="checkbox" name="lang_<?php 
                echo $locale->languageTag();
                ?>
" <?php 
                echo in_array($locale->languageTag(), $accepted_languages) ? 'checked' : '';
                ?>
 ><?php 
                echo $locale->endonym();
                ?>
									</label>
								</div>
						<?php 
            }
            ?>
					</div>
				</div>
				
				<h3><?php 
            echo webtrees\I18N::translate('Visibility and Access');
            ?>
</h3>
				
				<div class="form-group">
					<label class="control-label col-sm-3" for="block_order">
						<?php 
            echo webtrees\I18N::translate('Menu position');
            ?>
					</label>
					<div class="col-sm-9">
						<input
							class="form-control"
							id="position"
							name="block_order"
							size="3"
							required
							type="number"
							value="<?php 
            echo webtrees\Filter::escapeHtml($block_order);
            ?>
"
						>
					</div>
					<span class="help-block col-sm-9 col-sm-offset-3 small text-muted">
						<?php 
            echo webtrees\I18N::translate('This field controls the order in which the menu items are displayed.'), '<br><br>', webtrees\I18N::translate('You do not have to enter the numbers sequentially. If you leave holes in the numbering scheme, you can insert other menu items later. For example, if you use the numbers 1, 6, 11, 16, you can later insert menu items with the missing sequence numbers. Negative numbers and zero are allowed, and can be used to insert menu items in front of the first one.'), '<br><br>', webtrees\I18N::translate('When more than one menu item has the same position number, only one of these menu items will be visible.');
            ?>
					</span>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-3" for="block_order">
						<?php 
            echo webtrees\I18N::translate('Menu visibility');
            ?>
					</label>
					<div class="col-sm-9">
						<?php 
            echo webtrees\Functions\FunctionsEdit::selectEditControl('gedcom_id', webtrees\Tree::getIdList(), webtrees\I18N::translate('All'), $WT_TREE->getTreeId(), 'class="form-control"');
            ?>
					</div>
					<span class="help-block col-sm-9 col-sm-offset-3 small text-muted">
						<?php 
            echo webtrees\I18N::translate('You can determine whether this menu item will be visible regardless of family tree, or whether it will be visible only to the current family tree.');
            ?>
					</span>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-3" for="menu_access">
						<?php 
            echo webtrees\I18N::translate('Access level');
            ?>
					</label>
					<div class="col-sm-9">
						<?php 
            echo webtrees\Functions\FunctionsEdit::editFieldAccessLevel('menu_access', $menu_access, 'class="form-control"');
            ?>
					</div>
				</div>
				
				<div class="row col-sm-9 col-sm-offset-3">
					<button class="btn btn-primary" type="submit">
						<i class="fa fa-check"></i>
						<?php 
            echo webtrees\I18N::translate('save');
            ?>
					</button>
					<button class="btn" type="button" onclick="window.location='<?php 
            echo $this->getConfigLink();
            ?>
';">
						<i class="fa fa-close"></i>
						<?php 
            echo webtrees\I18N::translate('cancel');
            ?>
					</button>
				</div>
			</form>
<?php 
        }
    }
コード例 #2
0
        echo '<p>', I18N::translate('In a family tree, each record has an internal reference number (called an “XREF”) such as “F123” or “R14”.'), '</p>', '<p>', I18N::plural('The two family trees have %1$s record which uses the same “XREF”.', 'The two family trees have %1$s records which use the same “XREF”.', count($xrefs), count($xrefs)), '</p>', '<p>', I18N::translate('You must renumber the records in one of the trees before you can merge them.'), '</p>', '<p>', '<a class="current" href="admin_trees_renumber.php?ged=', $tree1->getNameUrl(), '">', I18N::translate('Renumber family tree'), ' — ', $tree1->getTitleHtml(), '</a>', '</p>', '<p>', '<a class="current" href="admin_trees_renumber.php?ged=', $tree2->getNameUrl(), '">', I18N::translate('Renumber family tree'), ' — ', $tree2->getTitleHtml(), '</a>', '</p>';
    } else {
        Database::beginTransaction();
        Database::exec("LOCK TABLE" . " `##individuals` WRITE," . " `##individuals` AS individuals2 READ," . " `##families` WRITE," . " `##families` AS families2 READ," . " `##sources` WRITE," . " `##sources` AS sources2 READ," . " `##media` WRITE," . " `##media` AS media2 READ," . " `##other` WRITE," . " `##other` AS other2 READ," . " `##name` WRITE," . " `##name` AS name2 READ," . " `##placelinks` WRITE," . " `##placelinks` AS placelinks2 READ," . " `##change` WRITE," . " `##change` AS change2 READ," . " `##dates` WRITE," . " `##dates` AS dates2 READ," . " `##default_resn` WRITE," . " `##default_resn` AS default_resn2 READ," . " `##hit_counter` WRITE," . " `##hit_counter` AS hit_counter2 READ," . " `##link` WRITE," . " `##link` AS link2 READ");
        Database::prepare("INSERT INTO `##individuals` (i_id, i_file, i_rin, i_sex, i_gedcom)" . " SELECT i_id, ?, i_rin, i_sex, i_gedcom FROM `##individuals` AS individuals2 WHERE i_file = ?")->execute(array($tree2_id, $tree1_id));
        Database::prepare("INSERT INTO `##families` (f_id, f_file, f_husb, f_wife, f_gedcom, f_numchil)" . " SELECT f_id, ?, f_husb, f_wife, f_gedcom, f_numchil FROM `##families` AS families2 WHERE f_file = ?")->execute(array($tree2_id, $tree1_id));
        Database::prepare("INSERT INTO `##sources` (s_id, s_file, s_name, s_gedcom)" . " SELECT s_id, ?, s_name, s_gedcom FROM `##sources` AS sources2 WHERE s_file = ?")->execute(array($tree2_id, $tree1_id));
        Database::prepare("INSERT INTO `##media` (m_id, m_ext, m_type, m_titl, m_filename, m_file, m_gedcom)" . " SELECT m_id, m_ext, m_type, m_titl, m_filename, ?, m_gedcom FROM `##media` AS media2 WHERE m_file = ?")->execute(array($tree2_id, $tree1_id));
        Database::prepare("INSERT INTO `##other` (o_id, o_file, o_type, o_gedcom)" . " SELECT o_id, ?, o_type, o_gedcom FROM `##other` AS other2 WHERE o_file = ? AND o_type NOT IN ('HEAD', 'TRLR')")->execute(array($tree2_id, $tree1_id));
        Database::prepare("INSERT INTO `##name` (n_file, n_id, n_num, n_type, n_sort, n_full, n_surname, n_surn, n_givn, n_soundex_givn_std, n_soundex_surn_std, n_soundex_givn_dm, n_soundex_surn_dm)" . " SELECT ?, n_id, n_num, n_type, n_sort, n_full, n_surname, n_surn, n_givn, n_soundex_givn_std, n_soundex_surn_std, n_soundex_givn_dm, n_soundex_surn_dm FROM `##name` AS name2 WHERE n_file = ?")->execute(array($tree2_id, $tree1_id));
        Database::prepare("INSERT INTO `##placelinks` (pl_p_id, pl_gid, pl_file)" . " SELECT pl_p_id, pl_gid, ? FROM `##placelinks` AS placelinks2 WHERE pl_file = ?")->execute(array($tree2_id, $tree1_id));
        Database::prepare("INSERT INTO `##dates` (d_day, d_month, d_mon, d_year, d_julianday1, d_julianday2, d_fact, d_gid, d_file, d_type)" . " SELECT d_day, d_month, d_mon, d_year, d_julianday1, d_julianday2, d_fact, d_gid, ?, d_type FROM `##dates` AS dates2 WHERE d_file = ?")->execute(array($tree2_id, $tree1_id));
        Database::prepare("INSERT INTO `##default_resn` (gedcom_id, xref, tag_type, resn)" . " SELECT ?, xref, tag_type, resn FROM `##default_resn` AS default_resn2 WHERE gedcom_id = ?")->execute(array($tree2_id, $tree1_id));
        Database::prepare("INSERT INTO `##link` (l_file, l_from, l_type, l_to)" . " SELECT ?, l_from, l_type, l_to FROM `##link` AS link2 WHERE l_file = ?")->execute(array($tree2_id, $tree1_id));
        // This table may contain old (deleted) references, which could clash. IGNORE these.
        Database::prepare("INSERT IGNORE INTO `##change` (change_time, status, gedcom_id, xref, old_gedcom, new_gedcom, user_id)" . " SELECT change_time, status, ?, xref, old_gedcom, new_gedcom, user_id FROM `##change` AS change2 WHERE gedcom_id = ?")->execute(array($tree2_id, $tree1_id));
        // This table may contain old (deleted) references, which could clash. IGNORE these.
        Database::prepare("INSERT IGNORE INTO `##hit_counter` (gedcom_id, page_name, page_parameter, page_count)" . " SELECT ?, page_name, page_parameter, page_count FROM `##hit_counter` AS hit_counter2 WHERE gedcom_id = ? AND page_name <> 'index.php'")->execute(array($tree2_id, $tree1_id));
        Database::exec("UNLOCK TABLES");
        Database::commit();
        echo '<p>', I18N::translate('The family trees have been merged successfully.'), '</p>';
    }
} else {
    echo '<form method="post">';
    echo '<input type="hidden" name="go" value="1">';
    echo '<p>', I18N::translate('Copy all the records from %1$s into %2$s.', FunctionsEdit::selectEditControl('tree1_id', Tree::getIdList(), '', null), FunctionsEdit::selectEditControl('tree2_id', Tree::getIdList(), '', null)), '</p>';
    echo '<button type="submit" class="btn btn-primary">';
    echo '<i class="fa fa-check"></i> ', I18N::translate('continue');
    echo '</button>';
    echo '</form>';
}
コード例 #3
0
ファイル: GoogleMapsModule.php プロジェクト: bxbroze/webtrees
    /**
     * Check places for missing data, etc.
     */
    private function adminPlaceCheck()
    {
        global $WT_TREE;
        $gedcom_id = Filter::get('gedcom_id', null, $WT_TREE->getTreeId());
        $country = Filter::get('country', '.+', 'XYZ');
        $state = Filter::get('state', '.+', 'XYZ');
        $matching = Filter::getBool('matching');
        $controller = new PageController();
        $controller->restrictAccess(Auth::isAdmin())->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">
				<a href="?mod=googlemap&amp;mod_action=admin_places">
					<?php 
        echo I18N::translate('Geographic data');
        ?>
				</a>
			</li>
			<li role="presentation" class="active">
				<a href="#">
					<?php 
        echo I18N::translate('Place check');
        ?>
				</a>
			</li>
		</ul>
		<?php 
        echo '<h2>', I18N::translate('Place check'), '</h2>';
        // User options
        $rows = Database::prepare("SELECT pl_id, pl_place FROM `##placelocation` WHERE pl_level=0 ORDER BY pl_place")->fetchAssoc();
        echo '<form name="placecheck" class="form form-inline">';
        echo '<input type="hidden" name="mod" value="', $this->getName(), '">';
        echo '<input type="hidden" name="mod_action" value="admin_placecheck">';
        echo '<div class="form-group">';
        echo '<label for="gedcom_id">', I18N::translate('Family tree'), '</label> ';
        echo FunctionsEdit::selectEditControl('gedcom_id', Tree::getIdList(), null, $gedcom_id, ' onchange="this.form.submit();" class="form-control"'), ' ';
        echo '<label for="country">', I18N::translate('Country'), '</label> ';
        echo '<select name="country" onchange="this.form.submit();" class="form-control"> ';
        echo '<option value="XYZ">', I18N::translate('All'), '</option>';
        foreach ($rows as $id => $place) {
            echo '<option value="', Filter::escapeHtml($place), '" ';
            if ($place == $country) {
                echo 'selected';
                $par_id = $id;
            }
            echo '>', Filter::escapeHtml($place), '</option>';
        }
        echo '</select> ';
        if ($country != 'XYZ') {
            echo '<label for="state">', I18N::translate('Subdivision'), '</label> ';
            echo '<select name="state" onchange="this.form.submit();" class="form-control">';
            echo '<option value="XYZ">', I18N::translate('All'), '</option>';
            $places = Database::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="', Filter::escapeHtml($place), '" ', $place == $state ? 'selected' : '', '>', Filter::escapeHtml($place), '</option>';
            }
            echo '</select> ';
        }
        echo '<div class="checkbox-inline">';
        echo '<label for="matching">';
        echo '<input type="checkbox" name="matching" value="1" onchange="this.form.submit();" ', $matching ? 'checked' : '', '>';
        echo I18N::translate('Include fully matched places');
        echo '</label>';
        echo '</div></div>';
        echo '</form>';
        echo '<hr>';
        //Select all '2 PLAC ' tags in the file and create array
        $place_list = array();
        $ged_data = Database::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 = Database::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, '\\Fisharebest\\Webtrees\\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
        echo '<table class="table table-bordered table-condensed table-hover"><thead><tr>';
        echo '<th rowspan="3">', I18N::translate('Place'), '</th>';
        echo '<th colspan="', $max * 3, '">', I18N::translate('Geographic data'), '</th></tr>';
        echo '<tr>';
        for ($cols = 0; $cols < $max; ++$cols) {
            if ($cols == 0) {
                echo '<th colspan="3">', I18N::translate('Country'), '</th>';
            } else {
                echo '<th colspan="3">', I18N::translate('Level'), ' ', $cols + 1, '</th>';
            }
        }
        echo '</tr><tr>';
        for ($cols = 0; $cols < $max; ++$cols) {
            echo '<th>', GedcomTag::getLabel('PLAC'), '</th>';
            echo '<th>', I18N::translate('Latitude'), '</th>';
            echo '<th>', I18N::translate('Longitude'), '</th>';
        }
        echo '</tr></thead><tbody>';
        $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) {
                $placestr .= '&amp;parent[' . $pindex . ']=' . urlencode($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="#" dir="auto" onclick="edit_place_location(\'';
            $mapstr_add = '<a href="#" dir="auto" 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] = 'unknown';
                    // GoogleMap module uses "unknown" while GEDCOM uses , ,
                }
                $placelist = $this->createPossiblePlaceNames($levels[$z], $z + 1);
                // add the necessary prefix/postfix values to the place name
                foreach ($placelist as $key => $placename) {
                    $row = Database::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 . 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>" . 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="danger">' . $levels[$z] . '</span>' . $mapstr8;
                        $matched[$x]++;
                    }
                }
                $plac[$z] = '<td>' . $placestr2 . '</td>';
                if ($row['pl_lati'] == '0' && $row['pl_long'] == '0') {
                    $lati[$z] = '<td class="danger">0</td>';
                } elseif ($row['pl_lati'] != '') {
                    $lati[$z] = '<td>' . $row['pl_lati'] . '</td>';
                } else {
                    $lati[$z] = '<td class="danger"><i class="fa fa-warning"></i></td>';
                    $matched[$x]++;
                }
                if ($row['pl_lati'] == '0' && $row['pl_long'] == '0') {
                    $long[$z] = '<td class="danger">0</td>';
                } elseif ($row['pl_long'] != '') {
                    $long[$z] = '<td>' . $row['pl_long'] . '</td>';
                } else {
                    $long[$z] = '<td class="danger"><i class="fa fa-warning"></i></td>';
                    $matched[$x]++;
                }
                $level++;
                $mapstr3 = $mapstr3 . "&amp;parent[" . $z . "]=" . Filter::escapeJs($row['pl_placerequested']);
                $mapstr4 = $mapstr4 . "&amp;parent[" . $z . "]=" . 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></td>';
                        echo '<td></td>';
                        echo '<td></td>';
                    }
                    $z++;
                }
                echo '</tr>';
                $countrows++;
            }
            $x++;
        }
        echo '</tbody>';
        echo '<tfoot>';
        echo '<tr>';
        echo '<th colspan="', 1 + 3 * $max, '">', I18N::translate('Total places: %s', I18N::number($countrows)), '</th>';
        echo '</tr>';
        echo '</tfoot>';
        echo '</table>';
    }
コード例 #4
0
    /**
     * Action from the configuration page
     */
    private function edit()
    {
        global $WT_TREE;
        if (Filter::postBool('save') && Filter::checkCsrf()) {
            $block_id = Filter::postInteger('block_id');
            if ($block_id) {
                Database::prepare("UPDATE `##block` SET gedcom_id = NULLIF(:tree_id, '0'), block_order = :block_order WHERE block_id = :block_id")->execute(array('tree_id' => Filter::postInteger('gedcom_id'), 'block_order' => Filter::postInteger('block_order'), 'block_id' => $block_id));
            } else {
                Database::prepare("INSERT INTO `##block` (gedcom_id, module_name, block_order) VALUES (NULLIF(:tree_id, '0'), :module_name, :block_order)")->execute(array('tree_id' => Filter::postInteger('gedcom_id'), 'module_name' => $this->getName(), 'block_order' => Filter::postInteger('block_order')));
                $block_id = Database::getInstance()->lastInsertId();
            }
            $this->setBlockSetting($block_id, 'header', Filter::post('header'));
            $this->setBlockSetting($block_id, 'faqbody', Filter::post('faqbody'));
            $languages = Filter::postArray('lang');
            $this->setBlockSetting($block_id, 'languages', implode(',', $languages));
            $this->config();
        } else {
            $block_id = Filter::getInteger('block_id');
            $controller = new PageController();
            if ($block_id) {
                $controller->setPageTitle(I18N::translate('Edit FAQ item'));
                $header = $this->getBlockSetting($block_id, 'header');
                $faqbody = $this->getBlockSetting($block_id, 'faqbody');
                $block_order = Database::prepare("SELECT block_order FROM `##block` WHERE block_id = :block_id")->execute(array('block_id' => $block_id))->fetchOne();
                $gedcom_id = Database::prepare("SELECT gedcom_id FROM `##block` WHERE block_id = :block_id")->execute(array('block_id' => $block_id))->fetchOne();
            } else {
                $controller->setPageTitle(I18N::translate('Add an FAQ item'));
                $header = '';
                $faqbody = '';
                $block_order = Database::prepare("SELECT IFNULL(MAX(block_order)+1, 0) FROM `##block` WHERE module_name = :module_name")->execute(array('module_name' => $this->getName()))->fetchOne();
                $gedcom_id = $WT_TREE->getTreeId();
            }
            $controller->pageHeader();
            if (Module::getModuleByName('ckeditor')) {
                CkeditorModule::enableEditor($controller);
            }
            ?>
			<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><a
						href="module.php?mod=<?php 
            echo $this->getName();
            ?>
&mod_action=admin_config"><?php 
            echo I18N::translate('Frequently asked questions');
            ?>
</a>
				</li>
				<li class="active"><?php 
            echo $controller->getPageTitle();
            ?>
</li>
			</ol>
			<h1><?php 
            echo $controller->getPageTitle();
            ?>
</h1>

			<form name="faq" class="form-horizontal" method="post" action="module.php?mod=<?php 
            echo $this->getName();
            ?>
&amp;mod_action=admin_edit">
			<?php 
            echo Filter::getCsrf();
            ?>
			<input type="hidden" name="save" value="1">
			<input type="hidden" name="block_id" value="<?php 
            echo $block_id;
            ?>
">

			<div class="form-group">
				<label for="header" class="col-sm-3 control-label">
					<?php 
            echo I18N::translate('Question');
            ?>
				</label>

				<div class="col-sm-9">
					<input type="text" class="form-control" name="header" id="header"
					       value="<?php 
            echo Filter::escapeHtml($header);
            ?>
">
				</div>
			</div>

			<div class="form-group">
				<label for="faqbody" class="col-sm-3 control-label">
					<?php 
            echo I18N::translate('Answer');
            ?>
				</label>

				<div class="col-sm-9">
					<textarea name="faqbody" id="faqbody" class="form-control html-edit"
					          rows="10"><?php 
            echo Filter::escapeHtml($faqbody);
            ?>
</textarea>
				</div>
			</div>

			<div class="form-group">
				<label for="xref" class="col-sm-3 control-label">
					<?php 
            echo I18N::translate('Show this block for which languages?');
            ?>
				</label>

				<div class="col-sm-9">
					<?php 
            echo FunctionsEdit::editLanguageCheckboxes('lang', explode(',', $this->getBlockSetting($block_id, 'languages')));
            ?>
				</div>
			</div>

			<div class="form-group">
				<label for="block_order" class="col-sm-3 control-label">
					<?php 
            echo I18N::translate('FAQ position');
            ?>
				</label>

				<div class="col-sm-9">
					<input type="text" name="block_order" id="block_order" class="form-control" value="<?php 
            echo $block_order;
            ?>
">
				</div>
			</div>

			<div class="form-group">
				<label for="gedcom_id" class="col-sm-3 control-label">
					<?php 
            echo I18N::translate('FAQ visibility');
            ?>
				</label>

				<div class="col-sm-9">
					<?php 
            echo FunctionsEdit::selectEditControl('gedcom_id', Tree::getIdList(), I18N::translate('All'), $gedcom_id, 'class="form-control"');
            ?>
					<p class="small text-muted">
						<?php 
            echo I18N::translate('A FAQ item can be displayed on just one of the family trees, or on all the family trees.');
            ?>
					</p>
				</div>
			</div>

			<div class="form-group">
				<div class="col-sm-offset-3 col-sm-9">
					<button type="submit" class="btn btn-primary">
						<i class="fa fa-check"></i>
						<?php 
            echo I18N::translate('save');
            ?>
					</button>
				</div>
			</div>

		</form>
		<?php 
        }
    }