forked from cdtoews/12-step-meeting-pdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeeting.php
179 lines (158 loc) · 6.69 KB
/
meeting.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
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
<?php
class meeting {
public function __construct(array $meeting_array) {
$this->meeting_array = $meeting_array;
//echo 'inside constructor, day is ' . $this->meeting_array['day'] . "\n";
}
public function get_formatted_day(){
echo 'inside formatted_day, day is ' . $this->meeting_array['day'] . "\n";
$day = $this->meeting_array['day'];
if($day == 0){
return "Sunday";
}elseif ($day == 1){
return "Monday";
}elseif ($day == 2){
return "Tuesday";
}elseif ($day == 3){
return "Wednesday";
}elseif ($day == 4){
return "Thursday";
}elseif ($day == 5){
return "Friday";
}elseif ($day == 6){
return "Saturday";
}else{
return "Unknown Day";
}
}
//this function is fairly useless at the moment, since adding the custom meeting html thingie
public function get_text($layout_type){
if($layout_type == 1){
return $this->get_full_meeting_text();
}elseif($layout_type == 2){
return $this->get_full_meeting_text();
}
}
// public function get_meeting_table(){
// $meetingtext = "";
// $meetingtext .= @$this->meeting_array['name'] . ". ";
// $meetingtext .= @$this->meeting_array['location'] . ". ";
// $meetingtext .= @$parts[0] . ". "; //street address
// //let's only add notes and location notes if they exists. this was adding extra punctuation
// if(strlen(@$this->meeting_array['notes']) > 0){
// $meetingtext .= @$this->meeting_array['notes'] . ". ";
// }
// if(strlen(@$this->meeting_array['location_notes']) > 0){
// $meetingtext .= @$this->meeting_array['location_notes'] . ". ";
// }
//
//
// //let's strip carriage returns that might be in location notes and notes
// $meetingtext = str_replace("\r", "", $meetingtext);
// $meetingtext = str_replace("\n", "", $meetingtext);
// $meetingtext = str_replace("\t", "", $meetingtext);
//
// $table_text = '
// <table width="100%" border="0" cellspacing="0" cellpadding="0">
// <tbody>
// <tr>
// <td rowspan="1" colspan="2" valign="top"><b>' . $this->get_state() . ', ' . $this->get_city() . ' ' . $this->meeting_array['time_formatted'] . '</b>
// </td>
// </tr>
// <tr>
// <td width="30" valign="top"><b>' . implode (',' , $this->meeting_array['types']) . '</b><br>
// </td>
// <td valign="top">' . $meetingtext . '<br>
// </td>
// </tr>
// </tbody>
// </table>';
// write_log( $table_text );
// return $table_text;
// }
public function get_full_meeting_text(){
//first let's check if we will be using custom text, shall we
$custom_meeting_set = get_option('tsmp_set_custom_meeting_html');
//write_log("custom_meeting_set = " . $globals[$custom_meeting_set]);
if($custom_meeting_set == 1){
$this_meeting_html = get_option('tsmp_custom_meeting_html');
@$parts = explode(', ', $this->meeting_array['formatted_address']);
$meeting_variables = array
(
array("__types__", implode (',' , $this->meeting_array['types']) ),
array("__time__", $this->meeting_array['time_formatted'] ),
array("__day_of_week__",$this->get_formatted_day() ),
array("__street_address__", @$parts[0] ),
array("__city__", @$parts[1] ),
array("__title__", $this->meeting_array['name'] ),
array("__state__", $this->get_state() ),
array("__region__", $this->meeting_array['region'] ),
array("__subregion__", $this->meeting_array['sub_region']),
array("__location__", @$this->meeting_array['location'] ),
array("__notes__", @$this->meeting_array['notes'] ),
array("__location_notes__", @$this->meeting_array['location_notes'] ),
array("__formatted_address__", @$this->meeting_array['formatted_address']),
array("__conference_url__", @$this->meeting_array['conference_url']),
array("__conference_phone__", @$this->meeting_array['conference_phone'])
);
foreach($meeting_variables as $item) {
$this_meeting_html = str_replace($item[0], $item[1], $this_meeting_html);
}
return $this_meeting_html;
}else{
//used for debugging:
// foreach($this->meeting_array as $key => $value) {
// write_log( "[$key] => $value");
// }
// write_log("\n\n");
//cobble the meeting text together
@$parts = explode(', ', $this->meeting_array['formatted_address']);
$meetingtext = "";
$meetingtext .= "<font='+1'><b>" . $this->get_state() . " ";
$meetingtext .= $this->get_city() . "</b></font>, ";
$meetingtext .= $this->meeting_array['time_formatted'] . ", ";
$meetingtext .= "(" . implode (',' , $this->meeting_array['types']) . ") ";
$meetingtext .= @$this->meeting_array['name'] . ". ";
$meetingtext .= @$this->meeting_array['location'] . ". ";
$meetingtext .= @$parts[0] . ". "; //street address
//let's only add notes and location notes if they exists. this was adding extra punctuation
if(strlen(@$this->meeting_array['notes']) > 0){
$meetingtext .= @$this->meeting_array['notes'];
// if notes doesn't end with a period, add one. otherwise add just a space
$meetingtext .= (strcmp(substr( @$this->meeting_array['notes'], -1) , '.') == 0 ? ' ' : '. ');
}
if(strlen(@$this->meeting_array['location_notes']) > 0){
$meetingtext .= @$this->meeting_array['location_notes'];
//if location_notes doesn't end with a period, add one, otherwise just add a space
$meetingtext .= (strcmp(substr( @$this->meeting_array['location_notes'], -1) , '.') == 0 ? ' ' : '. ');
}
//let's strip carriage returns that might be in location notes and notes
$meetingtext = str_replace("\r", "", $meetingtext);
$meetingtext = str_replace("\n", "", $meetingtext);
$meetingtext = str_replace("\t", "", $meetingtext);
return $meetingtext;
}
}// end of get_full_meeting_text
public function get_state(){
$formatted_adddress = @$this->meeting_array['formatted_address'];
$address_split = explode(", ", $formatted_adddress);
if(sizeof($address_split) == 4){
return explode(" ", trim($address_split[2]))[0];
}elseif(sizeof($address_split) == 3){
return $address_split[1];
}else{
return "unknown State";
}
}
public function get_city(){
$formatted_adddress = @$this->meeting_array['formatted_address'];
$address_split = explode(", ", $formatted_adddress);
if(sizeof($address_split) == 4){
return $address_split[1];
}elseif(sizeof($address_split) == 3){
return $address_split[0];
}else{
return "unknown City";
}
}
}