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