PluginProbe ʕ •ᴥ•ʔ
Daily Prayer Time / 2020.07.03
Daily Prayer Time v2020.07.03
2026.05.20 2026.05.11 2026.05.09 2026.05.05 2026.05.04 2026.05.03 2026.04.28 2026.04.28.1 trunk 2019.10.16 2019.11.19 2019.2.16 2019.3.1 2019.4.1 2019.4.5 2019.5.12 2019.5.13 2019.5.14 2019.5.19 2019.5.19.1 2019.5.21 2019.5.30 2019.5.5 2019.5.6 2019.5.7 2019.5.8 2019.5.9 2019.6.10 2019.6.2 2019.6.22 2019.7.10 2019.7.25 2019.8.1 2019.8.4 2019.9.16 2020.04.25 2020.04.26 2020.05.01 2020.05.04 2020.05.08 2020.05.17 2020.07.03 2021.01.10 2021.03.28 2021.07.20 2021.07.23 2021.07.24 2021.07.28 2021.08.01 2021.08.06 2021.08.07 2021.08.10 2021.09.12 2021.09.18 2021.09.23 2021.09.24 2021.10.01 2021.10.02 2021.10.10 2021.10.11 2021.10.15 2021.10.21 2021.10.27 2021.10.29 2022.03.24 2022.04.04 2022.04.14 2022.04.15 2022.04.21 2022.04.22 2022.05.04 2022.09.19 2022.11.14 2022.11.16 2022.12.18 2022.12.20 2023.01.27 2023.02.04 2023.02.09 2023.02.21 2023.03.08 2023.03.17 2023.03.18 2023.03.20 2023.05.04 2023.08.03 2023.08.08.16 2023.08.19 2023.08.19.1 2023.10.13 2023.10.21 2023.11.26 2023.12.28 2023.12.31 2024.03.28 2024.03.29 2024.03.30 2024.04.18 2024.04.20 2024.04.22 2024.04.26 2024.08.26 2024.09.12 2024.09.14 2024.09.17 2024.12.29 2024.12.30 2025.01.02 2025.01.17 2025.02.02 2025.03.04 2025.03.06 2025.03.08 2025.03.15 2025.03.20 2025.03.26 2025.03.27 2025.04.03 2025.06.16 2025.06.29 2025.07.15 2025.08.09 2025.10.26 2026.04.26
daily-prayer-time-for-mosques / Models / DailyShortCode.php
daily-prayer-time-for-mosques / Models Last commit date
Processors 5 years ago StartTime 5 years ago AdminMenu.php 5 years ago AssetsLoader.php 5 years ago DPTAjaxHandler.php 5 years ago DSTemplateLoader.php 7 years ago DailyShortCode.php 5 years ago DigitalScreen.php 4 years ago HijriDate.php 7 years ago Init.php 5 years ago MonthlyShortCode.php 7 years ago MonthlyTimeTable.php 6 years ago Shortcodes.php 5 years ago UpdateStyles.php 7 years ago Validator.php 7 years ago db.php 5 years ago dptWidget.php 7 years ago
DailyShortCode.php
334 lines
1 <?php
2 require_once('db.php');
3 require_once(__DIR__.'/../Views/DailyTimetablePrinter.php');
4 require_once(__DIR__.'/../Views/TimetablePrinter.php' );
5
6
7 class DailyShortCode extends TimetablePrinter
8 {
9 /** @var boolean */
10 private $isJamahOnly = false;
11
12 /** @var boolean */
13 private $isAzanOnly = false;
14
15 /** @var boolean */
16 private $isHanafiAsr = false;
17
18 /** @var array */
19 protected $row = array();
20
21 /** @var DailyTimetablePrinter */
22 private $timetablePrinter;
23
24 /** @var string */
25 private $title;
26
27 /** @var bool */
28 private $hideRamadan = false;
29
30 /** @var bool */
31 private $hideTimeRemaining = false;
32
33 /** @var bool */
34 private $displayHijriDate = false;
35
36 /** $var db */
37 protected $db;
38
39 public function __construct()
40 {
41 $this->db = new DatabaseConnection();
42 $this->row = $this->db->getPrayerTimeForToday();
43 $this->timetablePrinter = new DailyTimetablePrinter();
44 parent::__construct();
45 }
46
47 public function setAnnouncement($text, $day)
48 {
49 $this->row['announcement'] = $this->getAnnouncement( $text, $day);
50
51 }
52
53 public function setJamahOnly()
54 {
55 $this->isJamahOnly = true;
56 }
57
58 public function setAzanOnly()
59 {
60 $this->isAzanOnly = true;
61 }
62
63 public function setHanafiAsr()
64 {
65 $this->isHanafiAsr = true;
66 }
67
68 public function hideRamadan()
69 {
70 $this->hideRamadan = true;
71 }
72
73 public function hideTimeRemaining()
74 {
75 $this->hideTimeRemaining = true;
76 }
77
78 public function displayHijriDate()
79 {
80 $this->displayHijriDate = true;
81 }
82
83 /**
84 * @param array $attr
85 * @return string
86 */
87 public function verticalTime($attr=array())
88 {
89 $this->timetablePrinter->setVertical(true);
90
91 $row = $this->getRow($attr);
92
93 if ($this->isJamahOnly) {
94 return $this->timetablePrinter->verticalTimeJamahOnly($row);
95 }
96
97 if ($this->isAzanOnly) {
98 return $this->timetablePrinter->verticalTimeAzanOnly($row);
99 }
100
101 return $this->timetablePrinter->printVerticalTime($row);
102 }
103
104 /**
105 * @param array $attr
106 * @return string
107 */
108 public function horizontalTime($attr=array())
109 {
110 $this->timetablePrinter->setHorizontal(true);
111
112 $row = $this->getRow($attr);
113
114 if ($this->isJamahOnly) {
115 return $this->timetablePrinter->horizontalTimeJamahOnly($row);
116 }
117
118 if ($this->isAzanOnly) {
119 return $this->timetablePrinter->horizontalTimeAzanOnly($row);
120 }
121
122 if (isset($attr['use_div_layout'])) {
123 return $this->timetablePrinter->horizontalTimeDiv($row);
124 }
125
126 return $this->timetablePrinter->printHorizontalTime($row);
127 }
128
129 /**
130 * @param string $widgetNotice
131 * @return string
132 */
133 public function getAnnouncement($widgetNotice="", $day)
134 {
135 $widgetNotice = trim( $widgetNotice );
136 $day = trim($day);
137
138 if (empty($widgetNotice)) {
139 return "";
140 }
141
142 $today = date('l');
143 $announcement = "";
144 $exploded = explode(PHP_EOL, $widgetNotice);
145 foreach($exploded as $line) {
146 $announcement .= $line . "</br>";
147 }
148 if ( $today == ucfirst( $day ) || $day == 'everyday' ) {
149 return trim($announcement);
150 }
151 }
152
153 /**
154 * @param string $title
155 */
156 public function setTitle($title)
157 {
158 $this->title = $title;
159 }
160
161 public function scNextPrayer($attr)
162 {
163 $row = $this->getRow($attr);
164 $nextFajr = $this->db->getFajrJamahForTomorrow();
165 $row['displayHijriDate'] = $this->displayHijriDate;
166 $row['nextFajr'] = $nextFajr;
167 if (isset($attr['display_dates'])) {
168 return $this->getNextIqamahTime($row, true);
169 }
170 return $this->getNextIqamahTime($row);
171 }
172
173
174 public function scRamadanTime($attr)
175 {
176 $row = $this->getRow($attr);
177
178 return $this->timetablePrinter->displayRamadanTime($row);
179 }
180
181 public function scFajr($attr)
182 {
183 $result = "<span class='dpt_jamah'>" . $this->formatDateForPrayer($this->row['fajr_jamah']) . "</span>";
184 if ( isset($attr['start_time']) ) {
185 $result = "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['fajr_begins']) . "</span>" . $result;
186 }
187 return $result;
188 }
189
190 public function scFajrStart($attr)
191 {
192 return "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['fajr_begins']) . "</span>";
193 }
194
195 public function scSunrise($attr)
196 {
197 return "<span class='dpt_sunrise'>" . $this->formatDateForPrayer($this->row['sunrise']) . "</span>";
198 }
199
200 public function scZuhr($attr)
201 {
202 $result = "<span class='dpt_jamah'>" . $this->formatDateForPrayer($this->row['zuhr_jamah']) . "</span>";
203 if ( isset($attr['start_time']) ) {
204 $result = "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['zuhr_begins']) . "</span>" . $result;
205 }
206 return $result;
207 }
208
209 public function scZuhrStart($attr)
210 {
211 return "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['zuhr_begins']) . "</span>";
212 }
213
214 public function scAsr($attr)
215 {
216 $result = "<span class='dpt_jamah'>" . $this->formatDateForPrayer($this->row['asr_jamah']) . "</span>";
217 if ( isset($attr['start_time']) ) {
218 $result = "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['asr_mithl_1']) . "</span>" . $result;
219 }
220 return $result;
221 }
222
223 public function scAsrStart($attr)
224 {
225 return "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['asr_mithl_1']) . "</span>";
226 }
227
228 public function scMaghrib($attr)
229 {
230 $result = "<span class='dpt_jamah'>" . $this->formatDateForPrayer($this->row['maghrib_jamah']) . "</span>";
231 if ( isset($attr['start_time']) ) {
232 $result = "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['maghrib_begins']) . "</span>" . $result;
233 }
234 return $result;
235 }
236
237 public function scMaghribStart($attr)
238 {
239 return "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['maghrib_begins']) . "</span>";
240 }
241
242 public function scIsha($attr)
243 {
244 $result = "<span class='dpt_jamah'>" . $this->formatDateForPrayer($this->row['isha_jamah']) . "</span>";
245 if ( isset($attr['start_time']) ) {
246 $result = "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['isha_begins']) . "</span>" . $result;
247 }
248 return $result;
249 }
250
251 public function scIshaStart($attr)
252 {
253 return "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['isha_begins']) . "</span>";
254 }
255
256 public function scIqamahUpdate($attr)
257 {
258 $min = isset($attr['threshold']) ? (int) $attr['threshold'] : 1;
259 $row['jamah_changes'] = $this->db->getJamahChanges($min);
260 if (empty($row['jamah_changes'])) { return; }
261
262 $orientation = isset($attr['orientation']) ? $attr['orientation'] : '';
263 return $this->getJamahChange($row, true, $orientation);
264 }
265
266 public function scDigitalScreen($attr)
267 {
268 $ds = new DigitalScreen($attr);
269
270 return $ds->displayDigitalScreen();
271 }
272
273 protected function getRow($attr=array())
274 {
275
276 $this->setDisplayForShortCode($attr);
277
278 if (isset($attr['asr'])) {
279 $this->setHanafiAsr();
280 }
281
282 if (isset($attr['heading'])) {
283 $this->setTitle($attr['heading']);
284 }
285
286 $row = $this->row;
287
288 if (isset($attr['announcement'])) {
289 $day = isset($attr['day']) ? $attr['day'] : 'everyday';
290 $row['announcement'] = $this->getAnnouncement($attr['announcement'], $day);
291 }
292
293 if ( $row['jamah_changes']) {
294 $row['announcement'] .= $this->timetablePrinter->getJamahChange($this->row);
295 }
296
297 $row['widgetTitle'] = $this->title;
298 $row['asr_begins'] = $this->isHanafiAsr ? $this->row['asr_mithl_2'] : $this->row['asr_mithl_1'];
299
300 $row['hideRamadan'] = $this->hideRamadan;
301 $row['hideTimeRemaining'] = $this->hideTimeRemaining;
302 $row['displayHijriDate'] = $this->displayHijriDate;
303 $row['nextFajr'] = $this->db->getFajrJamahForTomorrow();
304
305 return $row;
306 }
307
308 /**
309 * @param array $attr
310 */
311 private function setDisplayForShortCode($attr)
312 {
313 if (isset($attr['display'])) {
314 if ( $attr['display'] === 'iqamah_only' ) {
315 $this->setJamahOnly();
316 } elseif ( $attr['display'] === 'azan_only' ) {
317 $this->setAzanOnly();
318 }
319 }
320
321 if (isset($attr['hide_time_remaining'])) {
322 $this->hideTimeRemaining();
323 }
324
325 if (isset($attr['hide_ramadan'])) {
326 $this->hideRamadan();
327 }
328
329 $hijriCheckbox = get_option('hijri-chbox');
330 if (! empty($hijriCheckbox)) {
331 $this->displayHijriDate();
332 }
333 }
334 }