-
Notifications
You must be signed in to change notification settings - Fork 4
/
load_data.php
102 lines (82 loc) · 3.25 KB
/
load_data.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
<?php
require_once '../../../wp-blog-header.php';
require_once 'lib/plaza-php/lib/the_city.php';
require_once 'lib/plaza_collection.php';
require_once 'lib/plaza_wordpress_cache.php';
if( empty( $_GET['subdomain_key'] ) ) {
echo 'Subdomain not set';
} else {
global $wpdb;
$cacher = new PlazaWordPressCache( $_GET['subdomain_key'] );
$cacher->set_db_connection($wpdb);
$the_city = new TheCity( $_GET['subdomain_key'], true, $cacher);
$the_city->add_url_params('wp=1');
if( isset($_GET['group_nickname']) ) { $the_city->set_group_nickname($_GET['group_nickname']); }
$subdomain_key = $_GET['subdomain_key'];
$plaza_choice = $_GET['plaza_display'];
$items_to_display = $_GET['items_to_display'];
$show_dates = isset($_GET['show_dates']) ? $_GET['show_dates'] : '';
$show_type = isset($_GET['show_type']) ? $_GET['show_type'] : '';
$plaza_choice_key = '';
$plaza_display = '';
switch($_GET['plaza_display']) {
case 'all':
$plaza_display = new PlazaCollection($the_city, $items_to_display);
break;
case 'topics':
$plaza_display = $the_city->topics($items_to_display);
break;
case 'events':
$plaza_display = $the_city->events($items_to_display);
break;
case 'prayers':
$plaza_display = $the_city->prayers($items_to_display);
break;
case 'needs':
$plaza_display = $the_city->needs($items_to_display);
break;
case 'albums':
$plaza_display = $the_city->albums($items_to_display);
break;
default:
$plaza_choice = 'topics';
$plaza_display = $the_city->topics($items_to_display);
}
$html = array();
$plaza_titles = $plaza_display->titles();
if( empty($plaza_titles) ) {
$html[] = "No $plaza_choice found";
} else {
foreach($plaza_titles as $indx => $title) {
$item = $plaza_display->select($indx);
if($plaza_choice == 'all') {
$str = get_class($item);
$item_type_path = strtolower($str) . 's';
} else {
$item_type_path = $plaza_choice;
}
$plaza_link_base = 'https://'.$_GET['subdomain_key'].'.onthecity.org/plaza/'.$item_type_path.'/';
$plaza_link = $plaza_link_base . $item->id();
$item_date = '';
if(!empty($show_dates)) {
$item_created_at = get_class($item) == 'Event' ? $item->starting_at() : $item->created_at();
if( !empty($item_created_at) ) {
$item_created_at = date_parse($item_created_at);
$item_date = implode( array($item_created_at['month'], $item_created_at['day'], $item_created_at['year']), '-');
}
}
if(!empty($show_type)) {
$item_type = get_class($item);
if(empty($item_date)) {
$item_date = $item_type;
} else {
$item_date .= ' :: ' . $item_type;
}
}
$item_display_date = empty($item_date) ? '' : '<div class="tc_wp_date">' . $item_date . '</div>';
$html[] = "<li class='tc_wp_item'>$item_display_date<a class='tc_wp_link' href='$plaza_link' target='_blank'>$title</a></li>";
}
}
echo implode($html, '');
}
?>