PluginProbe ʕ •ᴥ•ʔ
Daily Prayer Time / 2019.4.5
Daily Prayer Time v2019.4.5
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 7 years ago DSTemplateLoader.php 7 years ago DailyShortCode.php 7 years ago DailyTimeTable.php 8 years ago HijriDate.php 7 years ago Init.php 7 years ago MonthlyShortCode.php 7 years ago MonthlyTimeTable.php 10 years ago UpdateStyles.php 7 years ago Validator.php 7 years ago db.php 7 years ago dptWidget.php 7 years ago
DailyShortCode.php
532 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 private $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 private $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 return $this->timetablePrinter->displayNextPrayer($row, $nextFajr);
167 }
168
169
170 public function scRamadanTime($attr)
171 {
172 $row = $this->getRow($attr);
173
174 return $this->timetablePrinter->displayRamadanTime($row);
175 }
176
177 public function scFajr($attr)
178 {
179 $result = "<span class='dpt_jamah'>" . $this->formatDateForPrayer($this->row['fajr_jamah']) . "</span>";
180 if ( isset($attr['start_time']) ) {
181 $result = "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['fajr_begins']) . "</span>" . $result;
182 }
183 return $result;
184 }
185
186 public function scFajrStart($attr)
187 {
188 return "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['fajr_begins']) . "</span>";
189 }
190
191 public function scSunrise($attr)
192 {
193 return "<span class='dpt_sunrise'>" . $this->formatDateForPrayer($this->row['sunrise']) . "</span>";
194 }
195
196 public function scZuhr($attr)
197 {
198 $result = "<span class='dpt_jamah'>" . $this->formatDateForPrayer($this->row['zuhr_jamah']) . "</span>";
199 if ( isset($attr['start_time']) ) {
200 $result = "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['zuhr_begins']) . "</span>" . $result;
201 }
202 return $result;
203 }
204
205 public function scZuhrStart($attr)
206 {
207 return "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['zuhr_begins']) . "</span>";
208 }
209
210 public function scAsr($attr)
211 {
212 $result = "<span class='dpt_jamah'>" . $this->formatDateForPrayer($this->row['asr_jamah']) . "</span>";
213 if ( isset($attr['start_time']) ) {
214 $result = "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['asr_mithl_1']) . "</span>" . $result;
215 }
216 return $result;
217 }
218
219 public function scAsrStart($attr)
220 {
221 return "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['asr_mithl_1']) . "</span>";
222 }
223
224 public function scMaghrib($attr)
225 {
226 $result = "<span class='dpt_jamah'>" . $this->formatDateForPrayer($this->row['maghrib_jamah']) . "</span>";
227 if ( isset($attr['start_time']) ) {
228 $result = "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['maghrib_begins']) . "</span>" . $result;
229 }
230 return $result;
231 }
232
233 public function scMaghribStart($attr)
234 {
235 return "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['maghrib_begins']) . "</span>";
236 }
237
238 public function scIsha($attr)
239 {
240 $result = "<span class='dpt_jamah'>" . $this->formatDateForPrayer($this->row['isha_jamah']) . "</span>";
241 if ( isset($attr['start_time']) ) {
242 $result = "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['isha_begins']) . "</span>" . $result;
243 }
244 return $result;
245 }
246
247 public function scIshaStart($attr)
248 {
249 return "<span class='dpt_start'>" . $this->formatDateForPrayer($this->row['isha_begins']) . "</span>";
250 }
251
252 public function scDigitalScreen($attr)
253 {
254 $html = $this->getTopRow($attr)
255 . $this->getMiddleRow()
256 .$this->getBottomRow();
257
258 return $html;
259 }
260
261 private function getTopRow($attr)
262 {
263 $html = '
264 <div class="container-fluid x-board">
265 <div class="row top-row">
266 <div class="time col-sm-3 col-xs-12 text-center height-100">
267 <div class="align-middle">
268 <span>' . date_i18n( 'g:i A' ) . '</span>
269 </div>
270 </div>
271 <div class="col-sm-7 col-xs-12 text-center height-100">
272 <div class="align-middle">
273 <span class="date-eng h6">' . date_i18n( 'D jS M' ) . '</span>
274 <span>' . $this->getHijriDate(date("d"), date("m"), date("Y"), $this->getRow($attr)) . '</span>
275 </div>
276 </div>
277 <div class="col-sm-2 col-xs-12 text-right align-middle padding-null">';
278 $isLogo = get_option('ds-logo');
279 if ( $isLogo ) {
280 $html .= '<img class="logo" src="' . $isLogo . '">';
281 }
282 $html .=
283 '</div>
284 </div>';
285 return $html;
286 }
287 private function getMiddleRow()
288 {
289 $leftClass = "col-sm-5 col-xs-12 bg-red height-100 padding-null text-center";
290 $rightClass = "col-sm-7 col-xs-12 padding-null text-center bg-green height-100 padding-null";
291
292 $isVertical = get_option('vertical-chbox');
293 if ($isVertical) {
294 $leftClass = "col-sm-12 bg-red height-100 padding-null text-center";
295 $rightClass = "col-sm-12 padding-null text-center bg-green height-100";
296 }
297
298 $html = '
299 <div class="row middle-row bg-red">
300 <div class="'. $leftClass .'">
301 <table class="table height-100">
302 <thead class="bg-dark">
303 <tr>
304 <td>
305 <span class="dpt_start">' . strtoupper($this->getLocalHeaders()['prayer']) . '</span>
306 </td>
307 <td>
308 <span class="dpt_start">' . strtoupper($this->getLocalHeaders()['begins']) . '</span>
309 </td>
310 <td>
311 <span class="dpt_jamah">' . strtoupper($this->getLocalHeaders()['iqamah']) . '</span>
312 </td>
313 </tr>
314 </thead>
315 <tr>
316 <td class="prayerName">
317 <span>' . $this->getLocalPrayerNames()['fajr'] . '</span>
318 </td>
319 <td class="l-red">' . do_shortcode("[fajr_start]") . '</td>
320 <td>' . do_shortcode("[fajr_prayer]") . '</td>
321 </tr>
322 <tr>
323 <td class="prayerName"><span>' . $this->getLocalPrayerNames()['sunrise'] . '</span></td>
324 <td class="l-red" colspan="2">' . do_shortcode("[sunrise]") . '</td>
325 </tr>';
326 if ( get_option('jumuah') && $this->todayIsFriday()) {
327 $html .= '<tr>
328 <td class="prayerName"><span>' . stripslashes($this->getLocalHeaders()['jumuah']) . '</span></td>
329 <td colspan="2" class="l-red">' . get_option('jumuah') . '</td>
330 </tr>';
331 } else {
332 $html .= '
333 <tr>
334 <td class="prayerName"><span>' . $this->getLocalPrayerNames()['zuhr'] . '</span></td>
335 <td class="l-red">' . do_shortcode("[zuhr_start]") . '</td>
336 <td>' . do_shortcode("[zuhr_prayer]") . '</td>
337 </tr>
338 ';
339 }
340
341 $html .= '<tr>
342 <td class="prayerName"><span>' . $this->getLocalPrayerNames()['asr'] . '</span></td>
343 <td class="l-red">' . do_shortcode("[asr_start]") . '</td>
344 <td>' . do_shortcode("[asr_prayer]") . '</td>
345 </tr>
346 <tr>
347 <td class="prayerName"><span>' . $this->getLocalPrayerNames()['maghrib'] . '</span></td>
348 <td class="l-red">' . do_shortcode("[maghrib_start]") . '</td>
349 <td>' . do_shortcode("[maghrib_prayer]") . '</td>
350 </tr>
351 <tr>
352 <td class="prayerName"><span>' . $this->getLocalPrayerNames()['isha'] . '</span></td>
353 <td class="l-red">' . do_shortcode("[isha_start]") . '</td>
354 <td>' . do_shortcode("[isha_prayer]") . '</td>
355 </tr>';
356 if ( get_option('jumuah') && ! $this->todayIsFriday()) {
357 $html .= '<tr>
358 <td class="prayerName"><span>' . stripslashes($this->getLocalHeaders()['jumuah']) . '</span></td>
359 <td colspan="2" class="l-red">' . get_option('jumuah') . '</td>
360 </tr>';
361 }
362
363 $html .='
364 </table>
365 </div>
366 <div class="'. $rightClass .'">
367 <div id="text-carousel" class="carousel slide height-100" data-ride="carousel">
368 <div class="carousel-inner height-100">
369 <div class="item active height-100">
370 ' . $this->getFirstSlide() . '
371 </div>
372 ' . $this->getOtherSlides() . '
373 </div>
374 </div>
375 </div>
376 </div>
377 ';
378
379 return $html;
380 }
381
382 private function getBottomRow()
383 {
384 return '
385 <div class="row bottom-row">
386 <div class="bg-dark col-sm-3 col-xs-12 text-center height-100 align-middle">
387 <div class="align-middle">
388 <span class="blink">' . get_option('blink-text', 'SILENT YOUR MOBILE') . '</span>
389 </div>
390 </div>
391 <div class="col-sm-9 col-xs-12 height-100">
392 <div class="align-middle">
393 <h3 class="text-primary scrolling">
394 <marquee scrollamount="11">'
395 . do_shortcode("[display_iqamah_update]")
396 . get_option('scrolling-text') . '
397 </marquee>
398 </h3>
399 </div>
400 </div>
401 </div>
402 </div>
403 ';
404 }
405
406 private function getFirstSlide()
407 {
408 $html = '
409 <div class="nextPrayer height-100">
410 <div class="align-middle">
411 <h3>'. $this->getLocalTimes()['next prayer'] . '</h3>
412 <h2>' . do_shortcode("[daily_next_prayer]") . '</h2>
413 </div>
414 </div>';
415
416 return $html;
417 }
418
419 private function getOtherSlides()
420 {
421 $isSlide = get_option('slider-chbox');
422 if ( $isSlide ) {
423 $html = "";
424 $slides = array();
425
426 $slides[] = get_option('slider1Url');
427 $slides[] = get_option('slider2Url');
428 $slides[] = get_option('slider3Url');
429 $slides[] = get_option('slider4Url');
430 $slides[] = get_option('slider5Url');
431
432 $slides = array_filter($slides);
433 foreach ($slides as $slideUrl) {
434 $html .= '
435 <div class="item">
436 <img class="carousel-slide" src="' . $slideUrl . '">
437 </div>
438 ';
439 }
440
441 return $html;
442 }
443
444 return null;
445 }
446
447 public function scIqamahUpdate($attr)
448 {
449 $jamahChanges = $this->db->getJamahChanges(1);
450 if (empty($jamahChanges)) { return; }
451
452 $timeRelated = $this->getLocalTimes();
453 $print = "<span class='jamahChanges'><span class='tomorrow'>" . $timeRelated['iqamah update'] . "</span>";
454 $prayerNames = $this->getLocalPrayerNames();
455
456 foreach($jamahChanges as $key=>$time) {
457 if (! empty($key) ){
458 $prayer = explode('_', $key);
459 if ( $this->tomorrowIsFriday() ) {
460 $prayerNames['zuhr'] = $this->getLocalHeaders()['jumuah'];
461 } else {
462 $prayerNames['zuhr'] = $this->prayerLocal['zuhr'];
463 }
464 $print .= "<span class='x-time-change'>" . $prayerNames[$prayer[0]] . " " . $this->formatDateForPrayer($time) . "</span>";
465 }
466 }
467 $print .= "</span>";
468
469 return $print;
470 }
471
472 private function getRow($attr)
473 {
474
475 $this->setDisplayForShortCode($attr);
476
477 if (isset($attr['asr'])) {
478 $this->setHanafiAsr();
479 }
480
481 if (isset($attr['heading'])) {
482 $this->setTitle($attr['heading']);
483 }
484
485 $row = $this->row;
486
487 if (isset($attr['announcement'])) {
488 $day = isset($attr['day']) ? $attr['day'] : 'everyday';
489 $row['announcement'] = $this->getAnnouncement($attr['announcement'], $day);
490 }
491
492 if ( $row['jamah_changes']) {
493 $row['announcement'] .= $this->timetablePrinter->getJamahChange($this->row);
494 }
495
496 $row['widgetTitle'] = $this->title;
497 $row['asr_begins'] = $this->isHanafiAsr ? $this->row['asr_mithl_2'] : $this->row['asr_mithl_1'];
498
499 $row['hideRamadan'] = $this->hideRamadan;
500 $row['hideTimeRemaining'] = $this->hideTimeRemaining;
501 $row['displayHijriDate'] = $this->displayHijriDate;
502
503 return $row;
504 }
505
506 /**
507 * @param array $attr
508 */
509 private function setDisplayForShortCode($attr)
510 {
511 if (isset($attr['display'])) {
512 if ( $attr['display'] === 'iqamah_only' ) {
513 $this->setJamahOnly();
514 } elseif ( $attr['display'] === 'azan_only' ) {
515 $this->setAzanOnly();
516 }
517 }
518
519 if (isset($attr['hide_time_remaining'])) {
520 $this->hideTimeRemaining();
521 }
522
523 if (isset($attr['hide_ramadan'])) {
524 $this->hideRamadan();
525 }
526
527 $hijriCheckbox = get_option('hijri-chbox');
528 if (! empty($hijriCheckbox)) {
529 $this->displayHijriDate();
530 }
531 }
532 }