forked from tectronics/ChristianFlatshare
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsearch-by-church.php
More file actions
421 lines (371 loc) · 14.7 KB
/
search-by-church.php
File metadata and controls
421 lines (371 loc) · 14.7 KB
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<?php
session_start();
// Autoloader
require_once 'web/global.php';
connectToDB();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/final-1024.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Search by Church</title>
<!-- InstanceEndEditable -->
<link href="styles/web.css" rel="stylesheet" type="text/css" />
<link href="styles/headers.css" rel="stylesheet" type="text/css" />
<link href="css/global.css" rel="stylesheet" type="text/css" />
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon" />
<!-- jQUERY -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
//no conflict jquery
jQuery.noConflict();
</script>
<!-- MooTools -->
<script language="javascript" type="text/javascript" src="includes/mootools-1.2-core.js"></script>
<script language="javascript" type="text/javascript" src="includes/mootools-1.2-more.js"></script>
<script language="javascript" type="text/javascript" src="includes/icons.js"></script>
<!-- InstanceBeginEditable name="head" -->
<script type="text/javascript">
function $(obj) {
return document.getElementById(obj);
}
function trim(toTrim) {
while(''+toTrim.charAt(0) == " ") { toTrim = toTrim.substring(1,toTrim.length); }
while(''+toTrim.charAt(toTrim.length-1) == " ") { toTrim = toTrim.substring(0,toTrim.length-1); }
return toTrim;
}
function clearError(obj) {
$(obj).innerHTML = " ";
return true;
}
function toggleSearch(v) {
if (v == "url") {
$('search_by_name_canvas').style.display = "none";
$('church_name').value = "";
$('search_by_url_canvas').style.display = "";
} else {
$('search_by_url_canvas').style.display = "none";
$('c_url').value = "";
$('search_by_name_canvas').style.display = "";
}
}
function submitForm() {
// Before we do anything, validate
var proceed = true; // Initially assume that validation is successful.
var place_check = /^.+$/;
if ($('search_by_url_canvas').style.display != "none") {
// Validate the church_by_url form
// Validate place
if (!place_check.test(trim(document.search_by_church.church_url.value))) {
$('church_url_error').innerHTML = 'Please enter the internet address (URL) of your church.';
proceed = false;
}
}
if ($('search_by_name_canvas').style.display != "none") {
// Either church name or church acronym must be non-empty
if (
!place_check.test(trim(document.search_by_church.church_name.value)) &&
!place_check.test(trim(document.search_by_church.church_acronym.value))
) {
$('church_name_error').innerHTML = 'Please enter a church name or acronym to proceed.';
proceed = false;
}
}
// If no errors were encountered with the form
if (proceed) {
var v = $('location').value;
var postcode_regexp = <?php print REGEXP_UK_POSTCODE?>;
var partial_postcode_regexp = <?php print REGEXP_UK_POSTCODE_FIRST_PART?>;
// If v is a full UK postcode
if (trim(v) == "") {
// If the location is not specified, submit the form
document.search_by_church.submit();
} else {
// Hide the "Find location" link and show the "Loading" label
$('findLocationLink').style.display = "none";
$('findLocationLoadingLabel').style.display = "";
$('locationLabel').firstChild.nodeValue = v;
// Depending on what v is (full postcode, partial postcode or a string)
// we call the getLocation fuction (which does the AJAX call)
if (postcode_regexp.test(v)) {
// Strip the last three characters from the postcode (to get it's first part)
v = v.substring(0,v.length-3);
v = trim(v);
$('location').value = v;
getLocation("postcode",v);
} else if (partial_postcode_regexp.test(v)) {
getLocation("postcode",v);
} else {
getLocation("string",v);
}
}
}
}
function getLocation(type,value){
var xmlhttp = false; // Clear our fetching variable
// Internet Explorer
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
} catch (e) {
xmlhttp = false
}
}
// Gecko browsers
if (!xmlhttp) {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
// Depending on the type ("string" or "postcode")
// call the appropriate php function.
if (type == "string") {
var url = 'ajax-functions.php?action=locationSearch&location=' + value;
} else {
var url = 'ajax-functions.php?action=locationSearch&postcode=' + value;
}
xmlhttp.open('GET', url, true);
xmlhttp.onreadystatechange = function() {
switch (xmlhttp.readyState) {
case 1: /* $('debug').value += "Send() has NOT been called yet.\r"; */ break;
case 2: /* $('debug').value += "Send() has been called.\r"; */ break;
case 3: /* $('debug').value += "Downloading...\r"; */ break;
case 4:
var data = xmlhttp.responseText; //The content data which has been retrieved ***
if (data == "no results found") {
$('findLocationLink').style.display = "";
$('findLocationLoadingLabel').style.display = "none";
alert("no results found");
} else {
// Data has been returned to us.
// Stored them into the 2D array called locations
eval("var locations = "+data+";");
// We need to populate the locationsList <select> element.
// Step 1: Clear it's options
$('locationsList').options.length = 0;
// Step 2: Iterate through the 2D array and create a new <option> for each value
for (var i=0; i<locations.length; i++) {
$('locationsList').options[$('locationsList').options.length] = new Option(locations[i][0],locations[i][1]);
}
$('locationsListContainer').style.display = "";
$('findLocationLoadingLabel').style.display = "none";
$('locationsCount').firstChild.nodeValue = locations.length;
}
break;
}
}
xmlhttp.send(null)
return;
}
function chooseLocation() {
var obj = $('locationsList');
// Only proceed if a location has been chosen
if (obj.selectedIndex == -1) {
alert("Please choose a location before proceeding...");
} else {
// Hide locations list
$('locationsListContainer').style.display = "none";
// Show the "Find location" link
$('findLocationLink').style.display = "";
var text = obj.options[obj.selectedIndex].text;
// Remove the " (postcode)" from the text
text = text.substring(0,text.indexOf(" ("));
var value = obj.options[obj.selectedIndex].value;
// Change the text of the "location" text field
$('location').value = text;
// Change the value of the "postcode" hidden field
$('postcode').value = value;
document.search_by_church.submit();
}
}
function cancelChooseLocation() {
$('locationsListContainer').style.display = "none";
$('findLocationLink').style.display = "";
}
</script><!-- InstanceEndEditable -->
<!-- InstanceParam name="mainContentClass" type="text" value="" -->
</head>
<body>
<div id="canvas">
<?php print $theme['superheader']; ?>
<div id="content">
<?php print $theme['header']; ?>
<div class="" id="mainContent">
<!-- InstanceBeginEditable name="mainContent" -->
<div id="header_search_by_church" class="header">
<h1 class="m0"><span>Search by Church</span></h1>
</div>
<p class="mt0"><strong>Here you can search by a church's name or website address.</strong><br />
Please note that not all members will have included a church website in their adverts.</p>
<form name="search_by_church" method="get" action="display.php">
<input type="hidden" name="search_type" id="search_type" value="church" />
<input type="hidden" name="postcode" id="postcode" value="" />
<input type="hidden" name="summary_type" id="summary_type" value="church" />
<table cellpadding="0" cellspacing="10" border="0">
<tr>
<td width="120" align="right" valign="top">Advert type: </td>
<td>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input type="radio" name="post_type" id="post_type_offered" value="offered" checked="checked" /></td>
<td><label for="post_type_offered">Offered accommodation ads</label></td>
</tr>
<tr>
<td><input type="radio" name="post_type" id="post_type_wanted" value="wanted" /></td>
<td><label for="post_type_wanted">Wanted accommodation ads</label></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right" valign="top">Search type: </td>
<td>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input type="radio" name="church_type" id="church_type_name" value="name" checked="checked" onclick="toggleSearch('name');" /></td>
<td><label for="church_type_name">Search by church name</label></td>
</tr>
<tr>
<td><input name="church_type" type="radio" id="church_type_url" value="url" onclick="toggleSearch('url');" /></td>
<td><label for="church_type_url">Search by church website address</label></td>
</tr>
</table>
</td>
</tr>
</table>
<div id="search_by_url_canvas" style="display:<?php print "none"?>;">
<table cellpadding="0" cellspacing="10" border="0">
<tr>
<td align="right"> </td>
<td><strong>Enter Church website:</strong> </td>
</tr>
<tr>
<td width="120" align="right"><span class="obligatory">*</span> Church website:</td>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding-right:10px;"><input name="church_url" id="c_url" type="text" size="60" onclick="clearError('church_url_error');" /></td>
<td><span class="error" id="church_url_error"> </span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right"> </td>
<td class="grey"> Searches are not case sensitive. You can enter the full website address, or just a part of it:<br/>
e.g. "www.ourchurch.org", "ourchurch.org" or "ourchurch". </td>
</tr>
<tr>
<td align="right"> </td>
<td class="grey"><table cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="130">Good example:</td>
<td>"ourchurch.org"</td>
</tr>
<tr>
<td>Bad example:</td>
<td>"www.ourchurch.org/index.html"</td>
</tr>
</table></td>
</tr>
</table>
</div>
<div id="search_by_name_canvas" style="display:;">
<table cellpadding="0" cellspacing="10" border="0">
<tr>
<td align="right"> </td>
<td><strong>Enter Church name and / or acronym:</strong> </td>
</tr>
<tr>
<td width="120" align="right"><span class="obligatory">*</span> Church name: </td>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding-right:10px;"><input name="church_name" type="text" id="church_name" onclick="clearError('church_name_error');" size="60" /></td>
<td><span class="error" id="church_name_error"> </span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right">Acronym: </td>
<td class="grey"><input name="church_acronym" type="text" id="church_acronym" onclick="clearError('church_url_error');" size="60" /></td>
</tr>
<tr>
<td align="right"> </td>
<td class="grey">Searches are not case sensitive. You can enter the full name or just a word or an acronym:<br/>
e.g. for "Holy Trinity Cambridge", "Trinity Cambridge" or "Trinity", or "HTC" </td>
</tr>
</table>
</div>
<table cellpadding="0" cellspacing="10" border="0">
<tr>
<td align="right"> </td>
<td><strong>Accommodation location within 10 miles of </strong>(optional) <strong>:</strong> </td>
</tr>
<tr>
<td width="120" align="right" valign="top">Near:</td>
<td>
<p class="m0"><input type="text" name="location" id="location" value="<?php print stripslashes($location)?>" />
</p>
<p style="margin:4px 0px 0px 0px">
<input type="button" name="findLocationLink" id="findLocationLink" style="display:;" value="Show me the results" onclick="submitForm(); return false;" />
<span id="findLocationLoadingLabel" style="display:none;">Loading ...</span>
</p>
</td>
</tr>
<tr>
<td width="120"> </td>
<td>
<div id="locationsListContainer" style="display:<?php print "none"?>;" class="mb10">
<p class="mt0 mb10"><strong>CFS has found <span id="locationsCount">4</span> locations that match "<span id="locationLabel"> </span>"</strong> <br />Please choose one of the following and press the "Pick location" button to continue :</p>
<p class="mt0 mb10">
<select name="locationsList" id="locationsList" size="5" ></select>
</p>
<p class="m0">
<input type="button" name="locationsChooser" value="Pick location" onclick="chooseLocation();"/>
<input type="button" name="locationsChooserCancel" id="locationsChooserCancel" value="Cancel" onclick="cancelChooseLocation();" />
</p>
</div>
<p class="grey" style="margin:0px 0px 2px 0px;">Valid locations:</p>
<ul class="grey" style="margin:0px 0px 0px 1em; padding-left:1em;">
<li>The first part of a UK postcode (<em>e.g. W9</em>)</li>
<li>Name of a city, town or village, (<em>e.g. Nottingham, Woodbridge, Long Melford</em>)</li>
<li>Name of a city district (<em>e.g. Hammersmith, Paddington, West Bridgford</em>)</li>
<li>Name of a London tube station (<em>e.g. Westminster Station, Bow Station</em>)</li>
</ul>
</td>
</tr>
</table>
</form>
<p class="mb0"><a href="index.php">Back to welcome page</a></p>
<!-- InstanceEndEditable -->
</div>
<div class="redMenu">
<ul>
<!--<li><a href="../flat-finding-tips.php">flat finding tips</a></li>-->
<li><a href="advertising.php">advertising</a></li>
<li><a href="where-does-all-the-money-go.php">where does the money go?</a></li>
<li><a href="glossary.php">glossary</a></li>
<li><a href="terms-and-conditions.php">terms & conditions</a></li>
<li><a href="privacy-policy.php">privacy policy</a></li>
<li><a href="contact-us.php">contact us</a></li>
<li class="noSeparator"><a href="resources.php">links & resources</a></li>
</ul>
</div>
<div id="footerText">
<p class="m0"><strong>Christian Flatshare... helping accommodation seekers connect with the local church community<br />
Finding homes, growing churches and building communities </strong>© ChristianFlatShare.org 2007-<?php print date("Y")?></p>
</div>
</div>
<div id="footer"><img src="images/spacer.gif" alt="*" width="1" height="12"/></div>
</div>
<?php if (DEBUG_QUERIES && $debug) { echo sprintf(DEBUG_FORMAT,$debug); }?>
<?php print getTrackingCode();?>
</body>
<!-- InstanceEnd --></html>