-
Notifications
You must be signed in to change notification settings - Fork 0
/
placelist.php
255 lines (232 loc) · 8.35 KB
/
placelist.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<?php
// Displays a place hierachy
//
// webtrees: Web based Family History software
// Copyright (C) 2013 webtrees development team.
//
// Derived from PhpGedView
// Copyright (C) 2002 to 2010 PGV Development Team. All rights reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// $Id$
define('WT_SCRIPT_NAME', 'placelist.php');
require './includes/session.php';
require_once WT_ROOT.'includes/functions/functions_print_lists.php';
$controller=new WT_Controller_Page();
$action =safe_GET('action', array('find', 'show'), 'find');
$display=safe_GET('display', array('hierarchy', 'list'), 'hierarchy');
$parent =safe_GET('parent', WT_REGEX_UNSAFE); // Place names may include HTML chars. "Sunny View Cemetery", Smallville, <unknown>, Texas, USA"
if (!is_array($parent)) {
$parent = array();
}
$level=count($parent);
if ($display=='hierarchy') {
if ($level) {
$controller->setPageTitle(WT_I18N::translate('Place hierarchy') . ' - <span dir="auto">' . htmlspecialchars(end($parent)) . '</span>');
} else {
$controller->setPageTitle(WT_I18N::translate('Place hierarchy'));
}
} else {
$controller->setPageTitle(WT_I18N::translate('Place List'));
}
$controller->pageHeader();
echo '<div id="place-hierarchy">';
switch ($display) {
case 'list':
echo '<h2>', $controller->getPageTitle(), '</h2>';
$list_places=WT_Place::allPlaces(WT_GED_ID);
$num_places=count($list_places);
if ($num_places==0) {
echo '<b>', WT_I18N::translate('No results found.'), '</b><br>';
} else {
echo '<table class="list_table">';
echo '<tr><td class="list_label" ';
echo ' colspan="', $num_places>20 ? 3 : 2, '"><i class="icon-place"></i> ';
echo WT_I18N::translate('Place List');
echo '</td></tr><tr><td class="list_value_wrap"><ul>';
foreach ($list_places as $n=>$list_place) {
echo '<li><a href="', $list_place->getURL(), '">', $list_place->getReverseName(), '</a></li>';
if ($num_places > 20) {
if ($n == (int)($num_places / 3)) {
echo '</ul></td><td class="list_value_wrap"><ul>';
}
if ($n == (int)(($num_places / 3) * 2)) {
echo '</ul></td><td class="list_value_wrap"><ul>';
}
} elseif ($n == (int)($num_places/2)) {
echo '</ul></td><td class="list_value_wrap"><ul>';
}
}
echo '</ul></td></tr>';
echo '</table>';
}
echo '<h4><a href="placelist.php?display=hierarchy">', WT_I18N::translate('Show Places in Hierarchy'), '</a></h4>';
break;
case 'hierarchy':
$use_googlemap = array_key_exists('googlemap', WT_Module::getActiveModules()) && get_module_setting('googlemap', 'GM_PLACE_HIERARCHY');
if ($use_googlemap) {
require WT_ROOT.WT_MODULES_DIR.'googlemap/placehierarchy.php';
}
// Find this place and its ID
$place=new WT_Place(implode(', ', array_reverse($parent)), WT_GED_ID);
$place_id=$place->getPlaceId();
$child_places=$place->getChildPlaces();
$numfound=count($child_places);
//-- if the number of places found is 0 then automatically redirect to search page
if ($numfound==0) {
$action='show';
}
echo '<h2>', $controller->getPageTitle();
// Breadcrumbs
if ($place_id) {
$parent_place=$place->getParentPlace();
while ($parent_place->getPlaceId()) {
echo ', <a href="', $parent_place->getURL(), '" dir="auto">', $parent_place->getPlaceName(), '</a>';
$parent_place=$parent_place->getParentPlace();
}
echo ', <a href="', WT_SCRIPT_NAME, '">', WT_I18N::translate('Top Level'), '</a>';
}
echo '</h2>';
if ($use_googlemap) {
$linklevels='';
$placelevels='';
$place_names=array();
for ($j=0; $j<$level; $j++) {
$linklevels .= '&parent['.$j.']='.rawurlencode($parent[$j]);
if ($parent[$j]=='') {
$placelevels = ', ' . WT_I18N::translate('unknown') . $placelevels;
} else {
$placelevels = ', ' . $parent[$j] . $placelevels;
}
}
create_map($placelevels);
} elseif (array_key_exists('places_assistant', WT_Module::getActiveModules())) {
// Places Assistant is a custom/add-on module that was once part of the core code.
places_assistant_WT_Module::display_map($level, $parent);
}
// -- echo the array
foreach ($child_places as $n => $child_place) {
if ($n==0) {
echo '<table id="place_hierarchy" class="list_table"><tr><td class="list_label" ';
if ($numfound > 20) {
echo 'colspan="3"';
} elseif ($numfound > 4) {
echo 'colspan="2"';
}
echo '><i class="icon-place"></i> ';
if ($place_id) {
echo /* I18N: %s is a country or region */ WT_I18N::translate('Places in %s', $place->getPlaceName());
} else {
echo WT_I18N::translate('Place hierarchy');
}
echo '</td></tr><tr><td class="list_value"><ul>';
}
echo '<li><a href="', $child_place->getURL(), '" class="list_item">', $child_place->getPlaceName(), '</a></li>';
if ($use_googlemap) {
$place_names[$n]=$child_place->getPlaceName();
}
$n++;
if ($numfound > 20) {
if ($n == (int)($numfound / 3)) {
echo '</ul></td><td class="list_value"><ul>';
}
if ($n == (int)(($numfound / 3) * 2)) {
echo '</ul></td><td class="list_value"><ul>';
}
} elseif ($numfound > 4 && $n == (int)($numfound / 2)) {
echo '</ul></td><td class="list_value"><ul>';
}
}
if ($child_places) {
echo '</ul></td></tr>';
if ($action=='find' && $place_id) {
echo '<tr><td class="list_label" ';
if ($numfound > 20) {
echo 'colspan="3"';
} elseif ($numfound > 4) {
echo 'colspan="2"';
}
echo '>';
echo WT_I18N::translate('View all records found in this place');
echo help_link('ppp_view_records');
echo '</td></tr><tr><td class="list_value" ';
if ($numfound > 20) {
echo 'colspan="3"';
} elseif ($numfound > 4) {
echo 'colspan="2"';
}
echo ' style="text-align: center;">';
echo '<a href="', $place->getURL(), '&action=show" class="formField">', $place->getPlaceName(), '</a>';
echo '</td></tr>';
}
echo '</table>';
}
echo '</td></tr></table>';
if ($place_id && $action=='show') {
// -- array of names
$myindilist = array();
$myfamlist = array();
$positions=
WT_DB::prepare("SELECT DISTINCT pl_gid FROM `##placelinks` WHERE pl_p_id=? AND pl_file=?")
->execute(array($place_id, WT_GED_ID))
->fetchOneColumn();
foreach ($positions as $position) {
$record=WT_GedcomRecord::getInstance($position);
if ($record && $record->canDisplayDetails()) {
switch ($record->getType()) {
case 'INDI':
$myindilist[]=$record;
break;
case 'FAM':
$myfamlist[]=$record;
break;
}
}
}
echo '<br>';
//-- display results
$controller
->addInlineJavascript('jQuery("#places-tabs").tabs();')
->addInlineJavascript('jQuery("#places-tabs").css("visibility", "visible");')
->addInlineJavascript('jQuery(".loading-image").css("display", "none");');
echo '<div class="loading-image"> </div>';
echo '<div id="places-tabs"><ul>';
if ($myindilist) {
echo '<li><a href="#places-indi"><span id="indisource">', WT_I18N::translate('Individuals'), '</span></a></li>';
}
if ($myfamlist) {
echo '<li><a href="#places-fam"><span id="famsource">', WT_I18N::translate('Families'), '</span></a></li>';
}
echo '</ul>';
if ($myindilist) {
echo '<div id="places-indi">', format_indi_table($myindilist), '</div>';
}
if ($myfamlist) {
echo '<div id="places-fam">', format_fam_table($myfamlist), '</div>';
}
if (!$myindilist && !$myfamlist) {
echo '<div id="places-indi">', format_indi_table(array()), '</div>';
}
echo '</div>'; // <div id="places-tabs">
}
echo '<h4><a href="placelist.php?display=list">', WT_I18N::translate('Show All Places in a List'), '</a></h4>';
if ($use_googlemap) {
echo '<link type="text/css" href="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/css/wt_v3_googlemap.css" rel="stylesheet">';
map_scripts($numfound, $level, $parent, $linklevels, $placelevels, $place_names);
}
break;
}
echo '</div>'; // <div id="place-hierarchy">