PluginProbe ʕ •ᴥ•ʔ
Daily Prayer Time / 2019.5.8
Daily Prayer Time v2019.5.8
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
585 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 if ( get_option('hijri-chbox')) {
264 $date = date_i18n( 'D jS M' );
265 } else {
266 $date = date_i18n( 'l ' . get_option( 'date_format' ) );
267 }
268
269 $timeClass = "col-sm-3 ";
270 $dateClass = "col-sm-7 ";
271 $height = "height-100";
272 $verticalClass = "";
273 if ( $isVertical = get_option('vertical-chbox') ) {
274 $timeClass = "col-xs-12 vertical-time ";
275 $dateClass = "col-xs-12 ";
276 $height = "height-50 ";
277 $verticalClass = "vertical";
278 }
279 $html = '
280 <div class="container-fluid x-board">
281 <div class="row top-row">
282 <div class="time ' . $timeClass . 'col-xs-12 text-center ' . $height . '">
283 <div class="align-middle">
284 <span>' . date_i18n( 'g:i A' ) . '</span>
285 </div>
286 </div>
287 <div class="' . $dateClass . ' col-xs-12 text-center bg-white ' . $height . '">
288 <div class="align-middle">
289 <span class="date-eng h6 ' . $verticalClass . '">' . $date . '</span>
290 <span class="'. $verticalClass . 'hijri">' . $this->getHijriDate(date("d"), date("m"), date("Y"), $this->getRow($attr)) . '</span>
291 </div>
292 </div>
293 <div class="col-sm-2 col-xs-12 text-right align-middle padding-null">';
294 $isLogo = get_option('ds-logo');
295 if ( $isLogo && ! $isVertical) {
296 $html .= '<img class="logo" src="' . $isLogo . '">';
297 }
298 $html .=
299 '</div>
300 </div>';
301 return $html;
302 }
303 private function getMiddleRow()
304 {
305 $leftClass = "col-sm-5 col-xs-12 bg-red height-100 padding-null text-center";
306 $rightClass = "col-sm-7 col-xs-12 padding-null text-center bg-green height-100 padding-null";
307 $verticalClass = "";
308
309 if ($isVertical = get_option('vertical-chbox')) {
310 $verticalClass = "vertical";
311 $leftClass = "col-sm-12 bg-red height-100 padding-null text-center height-50";
312 $rightClass = "col-sm-12 padding-null text-center bg-green height-50";
313 }
314
315 $html = '
316 <div class="row middle-row bg-red">
317 <div class="'. $leftClass .'">
318 <table class="table height-100 '. $verticalClass .'">
319 <thead class="bg-dark">
320 <tr>
321 <td>
322 <span class="dpt_start">' . strtoupper($this->getLocalHeaders()['prayer']) . '</span>
323 </td>
324 <td>
325 <span class="dpt_start">' . strtoupper($this->getLocalHeaders()['begins']) . '</span>
326 </td>
327 <td>
328 <span class="dpt_jamah">' . strtoupper($this->getLocalHeaders()['iqamah']) . '</span>
329 </td>
330 </tr>
331 </thead>
332 <tr>
333 <td class="prayerName">
334 <span>' . $this->getLocalPrayerNames()['fajr'] . '</span>
335 </td>
336 <td class="l-red">' . do_shortcode("[fajr_start]") . '</td>
337 <td>' . do_shortcode("[fajr_prayer]") . '</td>
338 </tr>
339 <tr>
340 <td class="prayerName"><span>' . $this->getLocalPrayerNames()['sunrise'] . '</span></td>
341 <td class="prayerName" colspan="2">' . do_shortcode("[sunrise]") . '</td>
342 </tr>';
343 if ( get_option('jumuah') && $this->todayIsFriday()) {
344 $html .= '<tr>
345 <td class="prayerName"><span>' . stripslashes($this->getLocalHeaders()['jumuah']) . '</span></td>
346 <td colspan="2" class="prayerName">' . get_option('jumuah') . '</td>
347 </tr>';
348 } else {
349 $html .= '
350 <tr>
351 <td class="prayerName"><span>' . $this->getLocalPrayerNames()['zuhr'] . '</span></td>
352 <td class="l-red">' . do_shortcode("[zuhr_start]") . '</td>
353 <td>' . do_shortcode("[zuhr_prayer]") . '</td>
354 </tr>
355 ';
356 }
357
358 $html .= '<tr>
359 <td class="prayerName"><span>' . $this->getLocalPrayerNames()['asr'] . '</span></td>
360 <td class="l-red">' . do_shortcode("[asr_start]") . '</td>
361 <td>' . do_shortcode("[asr_prayer]") . '</td>
362 </tr>
363 <tr>
364 <td class="prayerName"><span>' . $this->getLocalPrayerNames()['maghrib'] . '</span></td>
365 <td class="l-red">' . do_shortcode("[maghrib_start]") . '</td>
366 <td>' . do_shortcode("[maghrib_prayer]") . '</td>
367 </tr>
368 <tr>
369 <td class="prayerName"><span>' . $this->getLocalPrayerNames()['isha'] . '</span></td>
370 <td class="l-red">' . do_shortcode("[isha_start]") . '</td>
371 <td>' . do_shortcode("[isha_prayer]") . '</td>
372 </tr>';
373 if ( get_option('jumuah') && ! $this->todayIsFriday()) {
374 $html .= '<tr>
375 <td class="prayerName"><span>' . stripslashes($this->getLocalHeaders()['jumuah']) . '</span></td>
376 <td colspan="2" class="prayerName">' . get_option('jumuah') . '</td>
377 </tr>';
378 }
379
380 $html .='
381 </table>
382 </div>
383 <div class="'. $rightClass .'">
384 <div id="text-carousel" class="carousel slide height-100" data-ride="carousel">
385 <div class="carousel-inner height-100">
386 <div class="item active height-100">
387 ' . $this->getFirstSlide() . '
388 </div>
389 ' . $this->getOtherSlides() . '
390 </div>
391 </div>
392 </div>
393 </div>
394 ';
395
396 return $html;
397 }
398
399 private function getBottomRow()
400 {
401 $verticalClass = "";
402
403 if ($isVertical = get_option('vertical-chbox')) {
404 $verticalClass = "vertical";
405 }
406
407 $html = '
408 <div class="row bottom-row">
409 <div class="bg-dark col-sm-3 col-xs-12 text-center height-100 align-middle">
410 <div class="align-middle">
411 <span class="blink">' . get_option('blink-text', 'SILENT YOUR MOBILE') . '</span>
412 </div>
413 </div>
414 <div class="col-sm-9 col-xs-12 height-100">
415 <div class="align-middle">
416 <h3 class="text-primary scrolling">
417 <marquee scrollamount="11">'
418 . do_shortcode("[display_iqamah_update]")
419 . get_option('scrolling-text') . '
420 </marquee>
421 </h3>
422 </div>
423 </div>
424 </div>
425 </div>
426 ';
427
428 if ($isVertical) {
429 $html = '
430 <div class="row bottom-row">
431 <div class="col-sm-12 col-xs-12 height-30">
432 <div class="align-middle">
433 <h3 class="text-primary scrolling-vertical">
434 <marquee scrollamount="11">'
435 . do_shortcode("[display_iqamah_update]")
436 . get_option('scrolling-text') . '
437 </marquee>
438 </h3>
439 </div>
440 </div>
441 <div class="bg-dark col-sm-12 col-xs-12 text-center height-50 align-middle">
442 <div class="align-middle">
443 <span class="blink-'.$verticalClass.'">' . get_option('blink-text', 'SILENT YOUR MOBILE') . '</span>
444 </div>
445 </div>
446 </div>
447 </div>
448 ';
449 }
450
451 return $html;
452 }
453
454 private function getFirstSlide()
455 {
456 $verticalClass = "";
457 if ($isVertical = get_option('vertical-chbox')) {
458 $verticalClass = "vertical";
459 }
460
461 $html = '
462 <div class="nextPrayer height-100">
463 <div class="align-middle">
464 <h3 class="'.$verticalClass.'">'. $this->getLocalTimes()['next prayer'] . '</h3>
465 <h2 class="'.$verticalClass.'">' . do_shortcode("[daily_next_prayer]") . '</h2>
466 </div>
467 </div>';
468
469 return $html;
470 }
471
472 private function getOtherSlides()
473 {
474 $isSlide = get_option('slider-chbox');
475 if ( $isSlide ) {
476 $html = "";
477 $slides = array();
478
479 $slides[] = get_option('slider1Url');
480 $slides[] = get_option('slider2Url');
481 $slides[] = get_option('slider3Url');
482 $slides[] = get_option('slider4Url');
483 $slides[] = get_option('slider5Url');
484
485 $slides = array_filter($slides);
486 foreach ($slides as $slideUrl) {
487 $html .= '
488 <div class="item">
489 <img class="carousel-slide" src="' . $slideUrl . '">
490 </div>
491 ';
492 }
493
494 return $html;
495 }
496
497 return null;
498 }
499
500 public function scIqamahUpdate($attr)
501 {
502 $jamahChanges = $this->db->getJamahChanges(1);
503 if (empty($jamahChanges)) { return; }
504
505 $timeRelated = $this->getLocalTimes();
506 $print = "<span class='jamahChanges'><span class='tomorrow'>" . $timeRelated['iqamah update'] . "</span>";
507 $prayerNames = $this->getLocalPrayerNames();
508
509 foreach($jamahChanges as $key=>$time) {
510 if (! empty($key) ){
511 $prayer = explode('_', $key);
512 if ( $this->tomorrowIsFriday() ) {
513 $prayerNames['zuhr'] = $this->getLocalHeaders()['jumuah'];
514 } else {
515 $prayerNames['zuhr'] = $this->prayerLocal['zuhr'];
516 }
517 $print .= "<span class='x-time-change'>" . $prayerNames[$prayer[0]] . " " . $this->formatDateForPrayer($time) . "</span>";
518 }
519 }
520 $print .= "</span>";
521
522 return $print;
523 }
524
525 private function getRow($attr)
526 {
527
528 $this->setDisplayForShortCode($attr);
529
530 if (isset($attr['asr'])) {
531 $this->setHanafiAsr();
532 }
533
534 if (isset($attr['heading'])) {
535 $this->setTitle($attr['heading']);
536 }
537
538 $row = $this->row;
539
540 if (isset($attr['announcement'])) {
541 $day = isset($attr['day']) ? $attr['day'] : 'everyday';
542 $row['announcement'] = $this->getAnnouncement($attr['announcement'], $day);
543 }
544
545 if ( $row['jamah_changes']) {
546 $row['announcement'] .= $this->timetablePrinter->getJamahChange($this->row);
547 }
548
549 $row['widgetTitle'] = $this->title;
550 $row['asr_begins'] = $this->isHanafiAsr ? $this->row['asr_mithl_2'] : $this->row['asr_mithl_1'];
551
552 $row['hideRamadan'] = $this->hideRamadan;
553 $row['hideTimeRemaining'] = $this->hideTimeRemaining;
554 $row['displayHijriDate'] = $this->displayHijriDate;
555
556 return $row;
557 }
558
559 /**
560 * @param array $attr
561 */
562 private function setDisplayForShortCode($attr)
563 {
564 if (isset($attr['display'])) {
565 if ( $attr['display'] === 'iqamah_only' ) {
566 $this->setJamahOnly();
567 } elseif ( $attr['display'] === 'azan_only' ) {
568 $this->setAzanOnly();
569 }
570 }
571
572 if (isset($attr['hide_time_remaining'])) {
573 $this->hideTimeRemaining();
574 }
575
576 if (isset($attr['hide_ramadan'])) {
577 $this->hideRamadan();
578 }
579
580 $hijriCheckbox = get_option('hijri-chbox');
581 if (! empty($hijriCheckbox)) {
582 $this->displayHijriDate();
583 }
584 }
585 }