forked from kiwi3685/kiwitrees
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
135 lines (124 loc) · 4.45 KB
/
index.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
<?php
/**
* Kiwitrees: Web based Family History software
* Copyright (C) 2012 to 2017 kiwitrees.net
*
* Derived from webtrees (www.webtrees.net)
* Copyright (C) 2010 to 2012 webtrees development team
*
* Derived from PhpGedView (phpgedview.sourceforge.net)
* Copyright (C) 2002 to 2010 PGV Development Team
*
* Kiwitrees 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 3 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 Kiwitrees. If not, see <http://www.gnu.org/licenses/>.
*/
define('KT_SCRIPT_NAME', 'index.php');
require './includes/session.php';
// The only option for action is "ajax"
$action = safe_REQUEST($_REQUEST, 'action', 'ajax');
$ctype = safe_REQUEST($_REQUEST, 'ctype', array('gedcom', 'user'), KT_USER_ID ? 'user' : 'gedcom');
//-- get the blocks list
$blocks = get_gedcom_blocks(KT_GED_ID);
$all_blocks = KT_Module::getActiveBlocks();
// We generate individual blocks using AJAX
if ($action == 'ajax') {
$controller = new KT_Controller_Ajax();
$controller->pageHeader();
// Check we're displaying an allowable block.
$block_id = safe_GET('block_id');
if (array_key_exists($block_id, $blocks['main'])) {
$module_name = $blocks['main'][$block_id];
} elseif (array_key_exists($block_id, $blocks['side'])) {
$module_name = $blocks['side'][$block_id];
} else {
exit;
}
if (array_key_exists($module_name, $all_blocks)) {
$class_name = $module_name.'_KT_Module';
$module = new $class_name;
$module->getBlock($block_id);
}
if (KT_DEBUG_SQL) {
echo KT_DB::getQueryLog();
}
exit;
}
$controller = new KT_Controller_Page();
$controller
->setPageTitle(KT_I18N::translate('Home'))
->setMetaRobots('index,follow')
->setCanonicalUrl(KT_SCRIPT_NAME . '?ctype=' . $ctype . '&ged=' . KT_GEDCOM)
->pageHeader()
// By default jQuery modifies AJAX URLs to disable caching, causing JS libraries to be loaded many times.
->addInlineJavascript('jQuery.ajaxSetup({cache:true});');
echo '<div id="home-page">';
if ($blocks['main']) {
if ($blocks['side']) {
echo '<div id="index_main_blocks">';
} else {
echo '<div id="index_full_blocks">';
}
foreach ($blocks['main'] as $block_id => $module_name) {
$class_name = $module_name.'_KT_Module';
$module = new $class_name;
if ($SEARCH_SPIDER || !$module->loadAjax()) {
// Load the block directly
$module->getBlock($block_id);
} else {
// Load the block asynchronously
echo '
<div id="block_', $block_id, '">
<div class="loading-image"> </div>
</div>
';
$controller->addInlineJavascript(
'jQuery("#block_'.$block_id.'").load("index.php?ctype=' . $ctype . '&action=ajax&block_id=' . $block_id . '");'
);
}
}
echo '</div>';
}
if ($blocks['side']) {
if ($blocks['main']) {
echo '<div id="index_small_blocks">';
} else {
echo '<div id="index_full_blocks">';
}
foreach ($blocks['side'] as $block_id => $module_name) {
$class_name = $module_name.'_KT_Module';
$module = new $class_name;
if ($SEARCH_SPIDER || !$module->loadAjax()) {
// Load the block directly
$module->getBlock($block_id);
} else {
// Load the block asynchronously
echo '
<div id="block_', $block_id, '">
<div class="loading-image"> </div>
</div>
';
$controller->addInlineJavascript(
'jQuery("#block_'.$block_id.'").load("index.php?ctype=' . $ctype . '&action=ajax&block_id=' . $block_id . '");'
);
}
}
echo '</div>';
}
// link for changing blocks
if (KT_USER_ID || $SHOW_COUNTER) {
echo '<div id="link_change_blocks">';
if (KT_USER_GEDCOM_ADMIN) echo '<a href="index_edit.php?gedcom_id=' . KT_GED_ID . '" onclick="return modalDialog(\'index_edit.php?gedcom_id=' . KT_GED_ID . '\', \'' . KT_I18N::translate('Change the blocks on this page') . '\');">', KT_I18N::translate('Change the blocks on this page'), '</a>';
if ($SHOW_COUNTER) {echo '<span>'.KT_I18N::translate('Hit Count:').' '.$hitCount.'</span>';}
echo '</div>'; // <div id="link_change_blocks">
} else {
echo '<div class="clearfloat"></div>';
}
echo '</div>'; // <div id="home-page">