forked from HuubMons/HuMo-genealogy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_names.php
153 lines (134 loc) · 5.53 KB
/
list_names.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
<?php
include_once("header.php"); // returns CMS_ROOTPATH constant
include_once(CMS_ROOTPATH."menu.php");
echo '<p class="fonts">';
//*** Find first first_character of last name ***
print '<div style="text-align:center">';
$person_qry="SELECT UPPER(substring(pers_lastname,1,1)) as first_character
FROM humo_persons WHERE pers_tree_id='".$tree_id."' GROUP BY first_character";
// *** Search pers_prefix for names like: "van Mons" ***
if ($user['group_kindindex']=="j"){
$person_qry="SELECT UPPER(substring(CONCAT(pers_prefix,pers_lastname),1,1)) as first_character
FROM humo_persons WHERE pers_tree_id='".$tree_id."' GROUP BY first_character";
}
@$person_result= $dbh->query($person_qry);
while(@$personDb=$person_result->fetch(PDO::FETCH_OBJ)) {
if (CMS_SPECIFIC=='Joomla'){
$path_tmp='index.php?option=com_humo-gen&task=list_names&database='.
$_SESSION['tree_prefix'].'&last_name='.$personDb->first_character;
}
elseif ($humo_option["url_rewrite"]=="j"){
// *** url_rewrite ***
// *** $uri_path is made header.php ***
$path_tmp=$uri_path.'list_names/'.$_SESSION['tree_prefix'].'/'.$personDb->first_character.'/';
}
else{
$path_tmp=CMS_ROOTPATH.'list_names.php?database='.$_SESSION['tree_prefix'].'&last_name='.$personDb->first_character;
}
print ' <a href="'.$path_tmp.'">'.$personDb->first_character.'</a>';
}
if (CMS_SPECIFIC=='Joomla'){
$path_tmp='index.php?option=com_humo-gen&task=list_names&last_name=all';
}
else {
$path_tmp=CMS_ROOTPATH."list_names.php?last_name=all";
}
echo ' <a href="'.$path_tmp.'">'.__('All names')."</a>\n";
//echo '</p>';
echo '</div><br>';
// *** Alphabet find first first_character of lastname ***
$last_name='a'; // *** Default first_character ***
// *** Search variables in: http://localhost/humo-gen/list/humo1_/M/ ***
if (isset($urlpart[1])){
$last_name=urldecode(safe_text($urlpart[1])); // without urldecode skandinavian letters don't work!
}
if (isset($_GET['last_name'])){
$last_name=safe_text($_GET['last_name']);
}
echo '<div class="index_lastname">';
// Mons, van or: van Mons
if ($user['group_kindindex']=="j"){
$person_result=$dbh->query("SELECT pers_lastname, pers_prefix,
CONCAT(pers_prefix,pers_lastname) as long_name, count(pers_lastname) as count_lastnames
FROM humo_persons
WHERE pers_tree_id='".$tree_id."' AND CONCAT(pers_prefix,pers_lastname) LIKE '".$last_name."%'
GROUP BY long_name");
if ($last_name=='all'){
$person_result=$dbh->query("SELECT pers_lastname, pers_prefix,
CONCAT(pers_prefix,pers_lastname) as long_name, count(pers_lastname) as count_lastnames
FROM humo_persons WHERE pers_tree_id='".$tree_id."' GROUP BY long_name");
}
while(@$personDb=$person_result->fetch(PDO::FETCH_OBJ)) {
// *** No & character in a link, replace to: | !!!
$long_name=str_replace("_", " ", $personDb->long_name);
if ($long_name){
$link=str_replace("_", " ", $personDb->pers_prefix).$personDb->pers_lastname;
$link=str_replace("&", "|", $link);
$person_name=$long_name;
}
else{
$link=__('...');
$person_name=__('...');
}
if (CMS_SPECIFIC=='Joomla'){
$path_tmp='index.php?option=com_humo-gen&task=list&database='.
$_SESSION['tree_prefix'].'&pers_last_name='.$link.'&part_lastname=equals';
}
else {
$path_tmp=CMS_ROOTPATH.'list.php?database='.$_SESSION['tree_prefix'].'&pers_lastname='.$link.'&part_lastname=equals';
}
echo '<a href="'.$path_tmp.'">'.$person_name.'</a> ('.$personDb->count_lastnames.')'.$dirmark2.' / '.$dirmark2;
}
}
else{
// *** Select alphabet first_character ***
$person_result=$dbh->query("SELECT pers_lastname, pers_prefix,
CONCAT(pers_lastname,pers_prefix) as long_name, count(pers_lastname) as count_lastnames
FROM humo_persons
WHERE pers_tree_id='".$tree_id."' AND pers_lastname LIKE '".$last_name."%'
GROUP BY long_name");
if ($last_name=='all'){
$person_result=$dbh->query("SELECT pers_lastname, pers_prefix,
CONCAT(pers_lastname,pers_prefix) as long_name, count(pers_lastname) as count_lastnames
FROM humo_persons WHERE pers_tree_id='".$tree_id."'
GROUP BY long_name");
}
while(@$personDb=$person_result->fetch(PDO::FETCH_OBJ)) {
// *** Do not use a & character in a GET, rename to: | !!! ***
$pers_lastname=$personDb->pers_lastname;
if ($personDb->pers_prefix){ $pers_lastname.=', '.$personDb->pers_prefix; }
$pers_lastname=str_replace("_", " ", $pers_lastname);
// *** Backwards compatibly only! Not in use in newer versions ***
if ($pers_lastname){
$link=$personDb->pers_lastname;
$link=str_replace("&", "|", $link);
$pers_prefix='';
if ($personDb->pers_prefix){
$pers_prefix=$personDb->pers_prefix;
}
else{
$pers_prefix='EMPTY';
}
$person_name=$pers_lastname;
}
else{
$link=__('...');
$pers_prefix=''; //if ($personDb->pers_prefix){ $pers_prefix='&pers_prefix='.$personDb->pers_prefix; }
$person_name=__('...');
}
if (CMS_SPECIFIC=='Joomla'){
$path_tmp='index.php?option=com_humo-gen&task=list&database='.
$_SESSION['tree_prefix'].'&pers_lastname='.$link;
}
else {
$path_tmp=CMS_ROOTPATH.'list.php?database='.$_SESSION['tree_prefix'].'&pers_lastname='.$link;
}
if ($pers_prefix){ $path_tmp .= '&pers_prefix='.$pers_prefix; }
$path_tmp .= '&part_lastname=equals';
echo '<a href="'.$path_tmp.'">'.$person_name.'</a> ('.$personDb->count_lastnames.')'.$dirmark2.' / '.$dirmark2;
}
}
echo '<br><br><br>'; // some joomla templates have "back to top link" before end of page. make room for that.
echo '</div>';
include_once(CMS_ROOTPATH."footer.php");
?>