forked from HuubMons/HuMo-genealogy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sources.php
155 lines (135 loc) · 6.49 KB
/
sources.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
<?php
include_once("header.php"); // returns CMS_ROOTPATH constant
include_once(CMS_ROOTPATH."menu.php");
// *** Check user authority ***
if ($user['group_sources']!='j'){
echo __('You are not authorised to see this page.');
exit();
}
include_once(CMS_ROOTPATH."include/language_date.php");
include_once(CMS_ROOTPATH."include/date_place.php");
@set_time_limit(300);
$desc_asc=" ASC "; $sort_desc=0;
if(isset($_GET['sort_desc'])) {
$desc_asc=" ASC "; $sort_desc=0;
if($_GET['sort_desc'] == 1) { $desc_asc=" DESC "; $sort_desc=1; }
}
$order_sources='title';
if(isset($_GET['order_sources'])) {
if ($_GET['order_sources']=='title') $order_sources='title';
if ($_GET['order_sources']=='date') $order_sources='date';
if ($_GET['order_sources']=='place') $order_sources='place';
}
if($order_sources=="title") {
// *** Default querie: order by title ***
//$querie="SELECT * FROM ".safe_text($_SESSION['tree_prefix'])."sources";
$querie="SELECT * FROM humo_sources WHERE source_tree_id='".$tree_id."'";
// *** Check user group is restricted sources can be shown ***
if ($user['group_show_restricted_source']=='n'){ $querie.=" AND (source_status!='restricted' OR source_status IS NULL)"; }
$querie.=" ORDER BY source_title".$desc_asc;
}
if($order_sources=="date") {
// *** Check user group is restricted sources can be shown ***
/*
$querie="SELECT source_status, source_id, source_gedcomnr, source_title, source_date, source_place,
right(source_date,4) as year,
date_format( str_to_date( substring(source_date,4,3),'%b' ),'%m') as month,
date_format( str_to_date( left(source_date,2),'%d' ),'%d') as day
FROM ".$tree_prefix_quoted."sources";
if ($user['group_show_restricted_source']=='n'){ $querie.=" WHERE source_status!='restricted' OR source_status IS NULL"; }
$querie.=" ORDER BY year, month, day";
*/
$querie="SELECT source_status, source_id, source_gedcomnr, source_title, source_date, source_place,
CONCAT(right(source_date,4),
date_format( str_to_date( substring(source_date,4,3),'%b' ),'%m'),
date_format( str_to_date( left(source_date,2),'%d' ),'%d') )
as year
FROM humo_sources WHERE source_tree_id='".$tree_id."'";
//FROM ".$tree_prefix_quoted."sources";
if ($user['group_show_restricted_source']=='n'){ $querie.=" AND (source_status!='restricted' OR source_status IS NULL)"; }
$querie.=" ORDER BY year".$desc_asc;
}
if($order_sources=="place") {
//$querie="SELECT * FROM ".safe_text($_SESSION['tree_prefix'])."sources";
$querie="SELECT * FROM humo_sources WHERE source_tree_id='".$tree_id."'";
// *** Check user group is restricted sources can be shown ***
if ($user['group_show_restricted_source']=='n'){ $querie.=" AND (source_status!='restricted' OR source_status IS NULL)"; }
$querie.=" ORDER BY source_place".$desc_asc;
}
// *** Pages ***
$start=0; if (isset($_GET["start"])){ $start=$_GET["start"]; }
$item=0; if (isset($_GET['item'])){ $item=$_GET['item']; }
$count_sources=$humo_option['show_persons'];
// *** All sources query ***
$all_sources=$dbh->query($querie);
$source=$dbh->query($querie." LIMIT ".safe_text($item).",".$count_sources);
$line_pages=__('Page');
// "<="
if ($start>1){
$start2=$start-20;
$calculated=($start-2)*$count_sources;
$line_pages.= "<a href=\"".$_SERVER['PHP_SELF']."?start=$start2&item=$calculated";
if (isset($_GET['order_sources'])){ $line_pages.= "&order_sources=".$_GET['order_sources'].'&sort_desc='.$sort_desc; }
$line_pages.= "\"><= </a>";
}
if ($start<=0){$start=1;}
// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
for ($i=$start; $i<=$start+19; $i++) {
$calculated=($i-1)*$count_sources;
if ($calculated<$all_sources->rowCount()){
if ($item==$calculated){
$line_pages.= " <b>$i</B>";
}
else {
$line_pages.= "<a href=\"".$_SERVER['PHP_SELF']."?item=$calculated&start=$start";
if (isset($_GET['order_sources'])){ $line_pages.= "&order_sources=".$_GET['order_sources'].'&sort_desc='.$sort_desc; }
$line_pages.= "\"> $i</a>";
}
}
}
// "=>"
$calculated=($i-1)*$count_sources;
if ($calculated<$all_sources->rowCount()){
$line_pages.= "<a href=\"".$_SERVER['PHP_SELF']."?start=$i&item=$calculated";
if (isset($_GET['order_sources'])){ $line_pages.= "&order_sources=".$_GET['order_sources'].'&sort_desc='.$sort_desc; }
$line_pages.= "\"> =></a>";
}
echo '<div class=index_list1>'.$line_pages.'</div><br>';
echo '<table class="humo index_table" align="center">';
echo '<tr class=table_headline>';
echo '<th colspan="3">'.__('Source').'</th>';
echo '</tr>';
echo '<tr class=table_headline>';
$style=''; $sort_reverse=$sort_desc; $img='';
if ($order_sources=="title"){
$style=' style="background-color:#ffffa0"';
$sort_reverse='1'; if ($sort_desc=='1'){ $sort_reverse='0'; $img='up'; }
}
echo '<th><a href="sources.php?database='.$_SESSION['tree_prefix'].'&start=1&item=0&order_sources=title&sort_desc='.$sort_reverse.'"'.$style.'>'.__('Title').' <img src="images/button3'.$img.'.png"></a></th>';
$style=''; $sort_reverse=$sort_desc; $img='';
if ($order_sources=="date"){
$style=' style="background-color:#ffffa0"';
$sort_reverse='1'; if ($sort_desc=='1'){ $sort_reverse='0'; $img='up'; }
}
echo '<th><a href="sources.php?database='.$_SESSION['tree_prefix'].'&start=1&item=0&order_sources=date&sort_desc='.$sort_reverse.'"'.$style.'>'.__('Date').' <img src="images/button3'.$img.'.png"></a></th>';
$style=''; $sort_reverse=$sort_desc; $img='';
if ($order_sources=="place"){
$style=' style="background-color:#ffffa0"';
$sort_reverse='1'; if ($sort_desc=='1'){ $sort_reverse='0'; $img='up'; }
}
echo '<th><a href="sources.php?database='.$_SESSION['tree_prefix'].'&start=1&item=0&order_sources=place&sort_desc='.$sort_reverse.'"'.$style.'>'.__('Place').' <img src="images/button3'.$img.'.png"></a></th>';
echo '</tr>';
while (@$sourceDb=$source->fetch(PDO::FETCH_OBJ)){
echo '<tr><td><a href="'.CMS_ROOTPATH.'source.php?database='.$_SESSION['tree_prefix'].'&id='.$sourceDb->source_gedcomnr.'">';
// *** Aldfaer sources don't have a title! ***
if ($sourceDb->source_title){ echo $sourceDb->source_title; } else { echo $sourceDb->source_text; }
echo '</a></td>';
echo '<td>'.date_place($sourceDb->source_date, '').'</td>';
echo '<td>'.$sourceDb->source_place.'</td>';
echo '</tr>';
}
echo '</table>';
echo '<br><div class=index_list1>'.$line_pages.'</div>';
//echo '</div>';
include_once(CMS_ROOTPATH."footer.php");
?>