forked from hypercities/hypercities
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getCollectionList.php
82 lines (66 loc) · 2.47 KB
/
getCollectionList.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
<?php
// vim: ts=4:sw=4:fdc=2:nu:nospell
/**
* @file
* HyperCities query script for Main Collection List.
*
* Return the KML file that contain all collections in View and Timespan
*
* @author HyperCities Tech Team
* @copyright Copyright 2008-2009, The Regents of the University of California
* @date 2009-08-21
* @version $Id$
*
*/
include_once('includes/dbUtil.inc');
include_once('includes/HCCollection.inc');
include_once('includes/HCKmlDocument.inc');
include_once('includes/serverSession.inc');
cServerSession::start();
HC_checkReferer();
$HC_POST = HC_sanitizeInput($_POST,
array('func'=>'str', 'dateFrom'=>'dtime', 'dateTo'=>'dtime',
'dateFromIsBC'=>'int', 'dateToIsBC'=>'int', 'zoom'=>'int',
'swLat'=>'float', 'swLng'=>'float', 'neLat'=>'float', 'neLng'=>'float',),
array('func', 'swLat', 'swLng', 'neLat', 'neLng', 'zoom',
'dateFrom', 'dateTo', 'dateFromIsBC', 'dateToIsBC'));
$neLat = $HC_POST['neLat'];
$neLng = $HC_POST['neLng'];
$swLat = $HC_POST['swLat'];
$swLng = $HC_POST['swLng'];
$dateFromIsBC = $HC_POST['dateFromIsBC'];
$dateFrom = $HC_POST['dateFrom'];
$dateToIsBC = $HC_POST['dateToIsBC'];
$dateTo = $HC_POST['dateTo'];
$userId = cServerSession::getUserId();
$isLogin = !empty($userId);
$isAdmin = cServerSession::isAdmin();
// Create HyperCities KML Document
$dom = new HCKmlDocument();
$dom->setName("HyperCities Collection List");
// Part 1 : If user is login, generate User's Collection Folder
if ( $isLogin ) {
$userCollectionId = cServerSession::getUserCollectionId() ;
// Get User's Collections
$totalCollections = HCCollection::getCollectionChildrenNumber($userCollectionId, $userId, $isAdmin);
// Create Folder Dom
$userCollectionDom = $dom->appendFolder($dom->docNode,
$userCollectionId, HC_USER_COLLECTIONS_NAME,
$totalCollections, null, true, false);
}
// Part 2 : Generate Meta-Collection Folders
foreach ( $HC_BASE_COLLECTIONS as $collection) {
// Count total children of collections
$totalChildren = HCCollection::getCollectionChildrenNumber($collection['id'], $userId, $isAdmin);
// Create Folder Dom
// appendFolder($dom, $folderId, $folderName, $totalChildren, $boundChildren, $isOpen, $hasCheckBox)
$metaCollectionDom = $dom->appendFolder($dom->docNode,
$collection['id'], $collection['name'],
$totalChildren, null, false, false);
}
// Output Final KML Files
$dom->formatOutput = true;
$collection_xml = $dom->saveXML($dom->documentElement);
header('Content-type: application/xml');
echo $collection_xml;
?>