This repository was archived by the owner on Aug 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpnajax.php
executable file
·62 lines (55 loc) · 1.88 KB
/
pnajax.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
<?php
/**
* locations
*
* @copyright (c) 2008,2010, Locations Development Team
* @link http://code.zikula.org/locations
* @author Steffen Voß
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @package locations
*/
function locations_ajax_get()
{
$dom = ZLanguage::getModuleDomain('locations');
$fragment = FormUtil::getpassedValue('fragment');
$field = FormUtil::getpassedValue('field');
// load the object array class corresponding to $objectType
if (!($class = Loader::loadArrayClassFromModule('locations', 'location'))) {
pn_exit(__f('Error! Unable to load class [%s].', 'location', $dom));
}
// instantiate the object-array
$objectArray = new $class();
$results = $objectArray->get();
$temp = array();
if (is_array($results) && count($results) > 0) {
foreach($results as $result) {
if (eregi($fragment, $result[$field])) {
if($field == 'street') {
//remove housenumbers
$result[$field] = preg_replace('/\s[0-9]+[a-z]?/i', '', $result[$field]);
$result[$field] = trim($result[$field]);
}
$temp[] = $result[$field];
}
}
}
//eliminate duplicates
$temp = array_unique($temp);
if (count($temp)!=0) {
asort($temp);
$out = '<ul>';
if($field == 'name') {
$out .= '<li class="dupe">' . __('Locations dupe', $dom) .'</li>';
}
foreach($temp as $key => $li) {
$out .= '<li';
if($field == 'name') {
$out .= ' class="dupe"';
}
$out .= '>' . DataUtil::formatForDisplay($li) .'<input type="hidden" id="' . DataUtil::formatForDisplay($li) . '" value="' . DataUtil::formatForDisplay($key) . '" /></li>';
}
$out .= '</ul>';
echo $out;
}
return true;
}