Tabs
1 month ago
DSTemplate.php
1 month ago
DailyTimetablePrinter.php
1 month ago
DptApiDoc.php
2 months ago
HelpsAndTips.php
1 month ago
MonthlyTimetablePrinter.php
2 months ago
TimetablePrinter.php
1 month ago
dptWidgetForm.php
4 years ago
horizontal-div.php
1 month ago
widget-admin.php
1 month ago
TimetablePrinter.php
714 lines
| 1 | <?php |
| 2 | |
| 3 | require_once(__DIR__ . '/../Models/HijriDate.php'); |
| 4 | require_once(__DIR__ . '/../Models/DPTHelper.php'); |
| 5 | |
| 6 | class TimetablePrinter |
| 7 | { |
| 8 | protected $prayerLocal = array( |
| 9 | "fajr" => "Fajr", |
| 10 | "sunrise" => "Sunrise", |
| 11 | "ishraq" => "Ishraq", |
| 12 | "zuhr" => "Zuhr", |
| 13 | "asr" => "Asr", |
| 14 | "maghrib" => "Maghrib", |
| 15 | "isha" => "Isha", |
| 16 | "zawal" => "Zawal" |
| 17 | ); |
| 18 | |
| 19 | protected $headersLocal = array( |
| 20 | "prayer" => "Prayer", |
| 21 | "begins" => "Begins", |
| 22 | "iqamah" => "Iqamah", |
| 23 | "standard" => "Standard", |
| 24 | "hanafi" => "Hanafi", |
| 25 | "fast_begins" => "Suhoor End", |
| 26 | "fast_ends" => "Iftar Start", |
| 27 | "jumuah" => "Jumuah" |
| 28 | ); |
| 29 | |
| 30 | protected $numbersLocal = array( |
| 31 | 0 => '0', |
| 32 | 1 => '1', |
| 33 | 2 => '2', |
| 34 | 3 => '3', |
| 35 | 4 => '4', |
| 36 | 5 => '5', |
| 37 | 6 => '6', |
| 38 | 7 => '7', |
| 39 | 8 => '8', |
| 40 | 9 => '9' |
| 41 | ); |
| 42 | |
| 43 | protected $monthsLocal = array( |
| 44 | 'january' => 'January', |
| 45 | 'february' => 'February', |
| 46 | 'march' => 'March', |
| 47 | 'april' => 'April', |
| 48 | 'may' => 'May', |
| 49 | 'june' => 'June', |
| 50 | 'july' => 'July', |
| 51 | 'august' => 'August', |
| 52 | 'september' => 'September', |
| 53 | 'october' => 'October', |
| 54 | 'november' => 'November', |
| 55 | 'december' => 'December' |
| 56 | ); |
| 57 | |
| 58 | |
| 59 | /** @var array */ |
| 60 | protected $timesLocal = array( |
| 61 | 'date' => 'Date', |
| 62 | 'day' => 'Day', |
| 63 | 'minute' => 'Minute', |
| 64 | 'minutes' => 'Minutes', |
| 65 | 'hour' => 'Hour', |
| 66 | 'hours' => 'Hours', |
| 67 | 'second' => 's', |
| 68 | 'iqamah update' => 'IQAMAH CHANGES:', |
| 69 | 'next prayer' => 'Next ...' |
| 70 | ); |
| 71 | |
| 72 | /** @var string */ |
| 73 | protected $tableClass; |
| 74 | |
| 75 | /** @var array */ |
| 76 | protected $localPrayerNames; |
| 77 | |
| 78 | /** @var array */ |
| 79 | protected $localHeaders; |
| 80 | |
| 81 | /** @var array */ |
| 82 | protected $localNumbers; |
| 83 | |
| 84 | /** @var array */ |
| 85 | protected $localTimes; |
| 86 | |
| 87 | /** @var HijriDate */ |
| 88 | protected $hijriDate; |
| 89 | |
| 90 | /** @var string */ |
| 91 | protected $hijridateString; |
| 92 | |
| 93 | /** $var bool */ |
| 94 | protected $isVertical = false; |
| 95 | |
| 96 | /** $var bool */ |
| 97 | protected $isHorizontal = false; |
| 98 | |
| 99 | /** @var DPTHelper */ |
| 100 | private $dptHelper; |
| 101 | |
| 102 | public function __construct() |
| 103 | { |
| 104 | $this->localPrayerNames = $this->getLocalPrayerNames(); |
| 105 | $this->localHeaders = $this->getLocalHeaders(); |
| 106 | $this->localNumbers = $this->getLocalNumbers(); |
| 107 | $this->localTimes = $this->getLocalTimes(); |
| 108 | $this->dptHelper = new DPTHelper(); |
| 109 | $this->hijriDate = new HijriDate(); |
| 110 | $this->hijridateString = $this->hijriDate->getDate(date("d"), date("m"), date("Y"), true, true); |
| 111 | } |
| 112 | |
| 113 | public function getTableClass() |
| 114 | { |
| 115 | return get_option('hideTableBorder'); |
| 116 | } |
| 117 | |
| 118 | public function getLocalPrayerNames($forAdmin=false, $enableJumuah=false) |
| 119 | { |
| 120 | $prayers_local = get_option('prayersLocal'); |
| 121 | $localPrayerName = $prayers_local; |
| 122 | |
| 123 | if ( empty($prayers_local)) { |
| 124 | $localPrayerName = $this->prayerLocal; |
| 125 | } |
| 126 | |
| 127 | if (is_array($localPrayerName)) { |
| 128 | $localPrayerName = array_map( 'sanitize_text_field', $localPrayerName); |
| 129 | $localPrayerName = array_map('stripslashes', $localPrayerName); |
| 130 | } |
| 131 | |
| 132 | if (!isset($localPrayerName['ishraq'])) { |
| 133 | $localPrayerName['ishraq'] = 'Israq'; |
| 134 | } |
| 135 | |
| 136 | return $localPrayerName; |
| 137 | } |
| 138 | |
| 139 | public function getLocalHeaders() |
| 140 | { |
| 141 | $headers_local = get_option('headersLocal'); |
| 142 | |
| 143 | if ( empty($headers_local)) { |
| 144 | return $this->headersLocal; |
| 145 | } elseif (count($headers_local) != count($this->headersLocal)) { |
| 146 | delete_option( 'headersLocal' ); |
| 147 | return $this->headersLocal; |
| 148 | } |
| 149 | |
| 150 | if (is_array($headers_local)) { |
| 151 | $headers_local = array_map( 'sanitize_text_field', $headers_local); |
| 152 | $headers_local = array_map('stripslashes', $headers_local); |
| 153 | } |
| 154 | |
| 155 | return $headers_local; |
| 156 | } |
| 157 | |
| 158 | public function getLocalMonths() |
| 159 | { |
| 160 | $monthsLocal = get_option('monthsLocal'); |
| 161 | |
| 162 | if ( empty( $monthsLocal )) { |
| 163 | $monthsLocal = $this->monthsLocal; |
| 164 | } |
| 165 | |
| 166 | if ( $this->isRamadan() ) { |
| 167 | $monthsLocal['ramadan'] = 'Ramadan'; |
| 168 | } else { |
| 169 | unset( $monthsLocal['ramadan'] ); |
| 170 | } |
| 171 | |
| 172 | if (is_array($monthsLocal)) { |
| 173 | $monthsLocal = array_map( 'sanitize_text_field', $monthsLocal); |
| 174 | $monthsLocal = array_map('stripslashes', $monthsLocal); |
| 175 | } |
| 176 | |
| 177 | return $monthsLocal; |
| 178 | } |
| 179 | |
| 180 | public function getLocalNumbers() |
| 181 | { |
| 182 | $numbers_local = get_option('numbersLocal'); |
| 183 | |
| 184 | if (is_array($numbers_local)) { |
| 185 | $numbers_local = array_map( 'sanitize_text_field', $numbers_local); |
| 186 | } |
| 187 | |
| 188 | return empty($numbers_local) ? $this->numbersLocal : $numbers_local; |
| 189 | } |
| 190 | |
| 191 | |
| 192 | public function getLocalTimes() |
| 193 | { |
| 194 | $times = get_option('timesLocal'); |
| 195 | if (is_array($times)) { |
| 196 | $times = array_map( 'sanitize_text_field', $times); |
| 197 | } |
| 198 | |
| 199 | if ( empty($times)) { |
| 200 | return $this->timesLocal; |
| 201 | } elseif (count($times) != count($this->timesLocal)) { |
| 202 | delete_option( 'timesLocal' ); |
| 203 | return $this->timesLocal; |
| 204 | } |
| 205 | |
| 206 | return $times; |
| 207 | } |
| 208 | |
| 209 | public function getLocalTimesKeys() |
| 210 | { |
| 211 | return array_keys($this->timesLocal); |
| 212 | } |
| 213 | |
| 214 | public function setVertical($value=true) |
| 215 | { |
| 216 | $this->isVertical = $value; |
| 217 | } |
| 218 | |
| 219 | public function setHorizontal($value=true) |
| 220 | { |
| 221 | $this->isHorizontal = $value; |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * @param string $mysqlDate |
| 226 | * @param string $format |
| 227 | * @return string |
| 228 | */ |
| 229 | public function formatDate($mysqlDate, $format=null) |
| 230 | { |
| 231 | return $this->dptHelper->formatDate($mysqlDate, $format); |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * @param string $mysqlDate |
| 236 | * @return string |
| 237 | */ |
| 238 | public function formatDateForPrayer($mysqlDate, $imsak=false) |
| 239 | { |
| 240 | $phpDate = strtotime($mysqlDate); |
| 241 | if ($imsak) { |
| 242 | $phpDate = $phpDate - ((int)get_option('imsaq') * 60); |
| 243 | } |
| 244 | $wpDate = date(get_option('time_format'), $phpDate); |
| 245 | |
| 246 | $result = str_split($wpDate); |
| 247 | $intlDate = ''; |
| 248 | $this->localNumbers = $this->getLocalNumbers(); |
| 249 | |
| 250 | foreach ($result as $char) { |
| 251 | if (array_key_exists($char, $this->localNumbers)) { |
| 252 | $intlDate .= $this->localNumbers[$char]; |
| 253 | } else { |
| 254 | $intlDate .= $char; |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | return $intlDate; |
| 259 | } |
| 260 | |
| 261 | public function formatDateForPrayer24Hour($mysqlDate, $imsak=false) |
| 262 | { |
| 263 | $phpDate = strtotime($mysqlDate); |
| 264 | if ($imsak) { |
| 265 | $phpDate = $phpDate - ((int)get_option('imsaq') * 60); |
| 266 | } |
| 267 | return date('H:i', $phpDate); |
| 268 | } |
| 269 | |
| 270 | public function getIntlNumber($numbers) |
| 271 | { |
| 272 | $intlDate = ''; |
| 273 | |
| 274 | $this->localNumbers = $this->getLocalNumbers(); |
| 275 | $result = str_split($numbers); |
| 276 | foreach ($result as $number) { |
| 277 | $intlDate .= $this->localNumbers[$number]; |
| 278 | if (empty($this->localNumbers[$number]) && $number !== '0') { |
| 279 | $intlDate .= $number; |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | return $intlDate; |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * @param string $month |
| 288 | * @param string $day |
| 289 | * @return string |
| 290 | */ |
| 291 | protected function getClass($month, $day, $weekday='') |
| 292 | { |
| 293 | if ($day == user_current_time('j') && $month == user_current_time('m')){ |
| 294 | return "class = highlight"; |
| 295 | } elseif($weekday=='Friday') { |
| 296 | return "class = Fri"; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * @param array $data |
| 302 | * @param bool $azanOnly |
| 303 | * @return string|null |
| 304 | */ |
| 305 | protected function getFastingTdWithData($data, $azanOnly=null, $imsaq=false) |
| 306 | { |
| 307 | $html = ""; |
| 308 | |
| 309 | if ($this->isRamadan() && ! $azanOnly && $imsaq) { |
| 310 | $html = "<td class='fasting'>" . $this->formatDateForPrayer($data, $imsaq) . "</td>"; |
| 311 | } elseif ($this->isRamadan() && $imsaq) { |
| 312 | $html = "<td class='fasting'>" . $this->formatDateForPrayer($data, $imsaq). "</td>"; |
| 313 | $html .= "<td>" . $this->formatDateForPrayer($data). "</td>"; |
| 314 | |
| 315 | } elseif ($this->isRamadan() && ! $imsaq) { |
| 316 | $html = "<td class='fasting'>" . $this->formatDateForPrayer($data). "</td>"; |
| 317 | } elseif ($this->isRamadan() && ! $azanOnly && $imsaq) { |
| 318 | $html = "<td class='fasting'>" . $this->formatDateForPrayer($data). "</td>"; |
| 319 | } elseif ($azanOnly) { |
| 320 | $html = "<td>" . $this->formatDateForPrayer($data). "</td>"; |
| 321 | } |
| 322 | |
| 323 | return $html; |
| 324 | } |
| 325 | |
| 326 | /** |
| 327 | * @param array $row |
| 328 | * @param bool $displayDates |
| 329 | * @param bool $apiCall |
| 330 | * @return string |
| 331 | */ |
| 332 | public function getNextIqamahTime(array $row, $displayDates=false, $apiCall=false) |
| 333 | { |
| 334 | $diff = $this->getNextIqamahTimeDiff($row); |
| 335 | $nextPrayer = $this->getNextPrayer($row); |
| 336 | |
| 337 | if ($apiCall) { |
| 338 | $nextPrayerTime = $this->getNextPrayerActualTime($row, $nextPrayer); |
| 339 | $nextAzanTime = $this->getNextAzanActualTime($row, $nextPrayer); |
| 340 | |
| 341 | return [ |
| 342 | 'prayerName' => $nextPrayer, |
| 343 | 'timeLeft' => $diff, |
| 344 | 'iqamahTime' => $nextPrayerTime, |
| 345 | 'azanTime' => $nextAzanTime |
| 346 | ]; |
| 347 | } |
| 348 | |
| 349 | $hijriDate = ''; |
| 350 | if($row['displayHijriDate']) { |
| 351 | $hijriDate = $this->hijriDate->getDate(date("d"), date("m"), date("Y"), true, true); |
| 352 | } |
| 353 | |
| 354 | $printDates = ''; |
| 355 | if ($displayDates) { |
| 356 | $printDates = '<div> |
| 357 | <span class="scDate"> |
| 358 | ' . date_i18n( get_option( 'date_format' ) ) . ' |
| 359 | </span> |
| 360 | <span class="scHijri"> |
| 361 | ' . $hijriDate . ' |
| 362 | </span>'; |
| 363 | } |
| 364 | |
| 365 | return |
| 366 | $printDates . ' |
| 367 | <div class="dptScNextPrayer"> |
| 368 | <span class="nextPrayer">' . $this->getHeading($row, $nextPrayer). '</span> ' . |
| 369 | $this->getTimeLeftString($diff, $row); |
| 370 | } |
| 371 | |
| 372 | protected function getTimeLeftString($nextIqamah, $row) |
| 373 | { |
| 374 | $timeLeftText = ''; |
| 375 | $minLeftText = ''; |
| 376 | if ($nextIqamah) { |
| 377 | $timeLeftText = $this->getLocalizedNumber( $nextIqamah ) .':00'; |
| 378 | $minLeftText = $this->localTimes["minute"]; |
| 379 | if ($nextIqamah > 60) { |
| 380 | $hours = $nextIqamah / 60; |
| 381 | $hours = (int)$hours; |
| 382 | $mins = $nextIqamah % 60; |
| 383 | $mins = (int)$mins; |
| 384 | $timeLeftText = $this->getLocalizedNumber( $hours ) .' '.$this->localTimes["hour"] .' ' |
| 385 | . $this->getLocalizedNumber( $mins ) .' ' |
| 386 | .$this->localTimes["minute"]; |
| 387 | } |
| 388 | |
| 389 | } |
| 390 | return $this->getNextPrayerTime($row, $nextIqamah, $timeLeftText, $minLeftText); |
| 391 | } |
| 392 | |
| 393 | protected function getNextIqamahTimeDiff(array $row) |
| 394 | { |
| 395 | $jamahTime = $this->getJamahTime( $row ); |
| 396 | $now = current_time( 'H:i'); |
| 397 | foreach ($jamahTime as $key=>$jamah) { |
| 398 | if ($jamah > $now ) { |
| 399 | if ($key == 'Sunrise') { |
| 400 | $this->localPrayerNames[lcfirst($key)] . ':'; |
| 401 | } |
| 402 | if ($key == 'Zuhr' && $this->isJumahDisplay($row)) { |
| 403 | $this->localPrayerNames[lcfirst($key)] . ':'; |
| 404 | } |
| 405 | $toTime = strtotime( $jamah ); |
| 406 | $fromTime = strtotime( $now ); |
| 407 | $diff = round(abs($toTime - $fromTime)/60,2); |
| 408 | |
| 409 | return $diff; |
| 410 | } |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | /** |
| 415 | * @param $row |
| 416 | * |
| 417 | * @return string |
| 418 | */ |
| 419 | protected function getNextPrayer($row) |
| 420 | { |
| 421 | return $this->dptHelper->getNextPrayer($row); |
| 422 | } |
| 423 | |
| 424 | protected function getHeading($dbRow, $nextPrayer) |
| 425 | { |
| 426 | $iqamah = ($nextPrayer == 'sunrise') ? '' : $this->localHeaders['iqamah']; |
| 427 | if ($nextPrayer == 'zawal') { |
| 428 | return $this->localPrayerNames['zuhr'].' '. $iqamah; |
| 429 | } |
| 430 | if ($nextPrayer == 'ishraq') { |
| 431 | return $this->localPrayerNames['ishraq']; |
| 432 | } |
| 433 | if ($nextPrayer == 'jumuah') { |
| 434 | return $this->localHeaders['jumuah']; |
| 435 | } |
| 436 | if ( is_null($nextPrayer)) { |
| 437 | return $this->localPrayerNames['fajr'].' '. $iqamah; |
| 438 | } |
| 439 | if ( $this->isJumahDisplay($dbRow) ) { |
| 440 | return $this->getLocalHeaders()['jumuah']; |
| 441 | } |
| 442 | |
| 443 | return $this->localPrayerNames[$nextPrayer] .' '. $iqamah; |
| 444 | } |
| 445 | |
| 446 | protected function getNextPrayerTime($dbRow, $nextIqamah, $timeLeftText, $minLeftText) |
| 447 | { |
| 448 | $nextPrayer = $this->getNextPrayer($dbRow); |
| 449 | |
| 450 | if ($nextPrayer == 'zawal') { |
| 451 | $nextPrayer = 'zuhr'; |
| 452 | } |
| 453 | |
| 454 | if ($nextPrayer == 'jumuah') { |
| 455 | $nextPrayerTime = $dbRow['zuhr_jamah']; |
| 456 | } elseif ($nextPrayer == 'ishraq') { |
| 457 | $nextPrayerTime = $this->dptHelper->getIshraqTime($dbRow['sunrise']); |
| 458 | } else { |
| 459 | $key = ($nextPrayer == 'sunrise') ? $nextPrayer : strtolower($nextPrayer.'_jamah'); |
| 460 | |
| 461 | if (isset($dbRow[$key])) { |
| 462 | $nextPrayerTime = $dbRow[$key]; |
| 463 | } |
| 464 | |
| 465 | if (empty($nextPrayerTime)) { |
| 466 | $nextPrayerTime = $dbRow['nextFajr']; |
| 467 | } |
| 468 | } |
| 469 | $nextPrayerTime24Hours = $this->formatDateForPrayer24Hour($nextPrayerTime); |
| 470 | |
| 471 | return |
| 472 | ' |
| 473 | <input type="hidden" id="timezoneOffset" value="' . get_option('gmt_offset') .'"> |
| 474 | <h2 id="dptScTimeCountDown" style="display: none">' . $nextPrayerTime24Hours. '</h2> |
| 475 | <h2 class="dptScTime"> |
| 476 | <input type="hidden" value="' . htmlentities($this->getTimesLocalJson()) . '" id="localizedNumbers"> |
| 477 | <input type="hidden" value="' . htmlentities($this->getTimesLocalJson()) . '" id="localizedTimes"> ' . |
| 478 | $this->formatDateForPrayer($nextPrayerTime). ' |
| 479 | </h2> |
| 480 | <span class="timeLeftCountDown timeLeft '.$this->getIqamahClass( $nextIqamah ).'"> |
| 481 | '. $timeLeftText .' |
| 482 | </span> |
| 483 | </div>'; |
| 484 | } |
| 485 | |
| 486 | /** |
| 487 | * @param array $row |
| 488 | * |
| 489 | * @return array |
| 490 | */ |
| 491 | protected function getJamahTime(array $row) |
| 492 | { |
| 493 | $jamahTimes = array( $row["fajr_jamah"], $row['sunrise'], $row["zuhr_jamah"], $row["asr_jamah"], $row["maghrib_jamah"], $row["isha_jamah"]); |
| 494 | $jamahNames = array("fajr", "sunrise", "zuhr", "asr", "maghrib", "isha"); |
| 495 | return array_combine( $jamahNames, $jamahTimes ); |
| 496 | |
| 497 | } |
| 498 | |
| 499 | protected function getNextPrayerActualTime(array $row, $nextPrayer) |
| 500 | { |
| 501 | if ($nextPrayer == 'zawal' || $nextPrayer == 'sunrise') { |
| 502 | return $row['sunrise']; |
| 503 | } |
| 504 | |
| 505 | $key = strtolower($nextPrayer . '_jamah'); |
| 506 | |
| 507 | if (isset($row[$key])) { |
| 508 | return $row[$key]; |
| 509 | } |
| 510 | |
| 511 | return null; |
| 512 | } |
| 513 | |
| 514 | protected function getNextAzanActualTime(array $row, $nextPrayer) |
| 515 | { |
| 516 | if ($nextPrayer == 'zawal' || $nextPrayer == 'sunrise') { |
| 517 | return $row['sunrise']; |
| 518 | } |
| 519 | |
| 520 | $key = strtolower($nextPrayer . '_begins'); |
| 521 | |
| 522 | if (isset($row[$key])) { |
| 523 | return $row[$key]; |
| 524 | } |
| 525 | |
| 526 | return null; |
| 527 | } |
| 528 | |
| 529 | /** |
| 530 | * @param array $row |
| 531 | * |
| 532 | * @return array |
| 533 | */ |
| 534 | protected function getAzanTime(array $row) |
| 535 | { |
| 536 | $jamahTimes = array( $row["fajr_begins"], $row['sunrise'], $row["zuhr_begins"], $row["asr_begins"], $row["maghrib_begins"], $row["isha_begins"]); |
| 537 | $jamahNames = array_keys($this->prayerLocal); |
| 538 | $jamahNames = array_filter($jamahNames, function($key) { |
| 539 | return !in_array($key, ['zawal', 'ishraq']); |
| 540 | }); // remove zawal and ishraq (they have no begins/jamah) |
| 541 | return array_combine( $jamahNames, $jamahTimes ); |
| 542 | } |
| 543 | |
| 544 | /** |
| 545 | * @param $numbers |
| 546 | * |
| 547 | * @return string |
| 548 | */ |
| 549 | public function getLocalizedNumber($numbers) |
| 550 | { |
| 551 | $numbers = str_split( $numbers ); |
| 552 | $localNumber = ""; |
| 553 | foreach ($numbers as $number) { |
| 554 | $localNumber .= $this->localNumbers[$number]; |
| 555 | } |
| 556 | |
| 557 | return $localNumber; |
| 558 | } |
| 559 | |
| 560 | /** |
| 561 | * @param $number |
| 562 | * |
| 563 | * @return string |
| 564 | */ |
| 565 | protected function getIqamahClass($number) |
| 566 | { |
| 567 | return $this->dptHelper->getIqamahClass($number); |
| 568 | } |
| 569 | |
| 570 | protected function getJamahChange(array $row, $isDigitalScreen=false, $orientation="") |
| 571 | { |
| 572 | $style = null; |
| 573 | |
| 574 | if ($this->isVertical && ! $isDigitalScreen) { |
| 575 | $style = "style='display: block;'"; |
| 576 | } |
| 577 | |
| 578 | $timeClass = ""; |
| 579 | $digitalScreenClass = ""; |
| 580 | |
| 581 | if ($isDigitalScreen) { |
| 582 | $timeClass = "class='x-time-change bg-dark'"; |
| 583 | $digitalScreenClass = "jamahChanges-" . $orientation; |
| 584 | |
| 585 | } |
| 586 | |
| 587 | $timeRelated = $this->getLocalTimes(); |
| 588 | |
| 589 | $print = |
| 590 | "<span class='jamahChanges " . $digitalScreenClass . "'> |
| 591 | <span class='x-time-text'>" |
| 592 | . stripslashes($timeRelated['iqamah update']) . |
| 593 | "</span>"; |
| 594 | |
| 595 | $prayerNames = $this->getLocalPrayerNames(); |
| 596 | |
| 597 | foreach($row['jamah_changes'] as $key=>$time) { |
| 598 | if (! empty($key) ){ |
| 599 | $prayer = explode('_', $key); |
| 600 | if ( $this->tomorrowIsFriday() ) { |
| 601 | $prayerNames['zuhr'] = $this->getLocalHeaders()['jumuah']; |
| 602 | } |
| 603 | $print .= "<span " . $style . $timeClass ." >" . $prayerNames[$prayer[0]] . ": " . $this->getTimeForIqamahUpdate($prayerNames[$prayer[0]], $time) . "</span>"; |
| 604 | } |
| 605 | } |
| 606 | $print .= "</span>"; |
| 607 | |
| 608 | return $print; |
| 609 | } |
| 610 | |
| 611 | private function getTimeForIqamahUpdate($key, $time) |
| 612 | { |
| 613 | $jumuahTime = get_option('jumuah1'); |
| 614 | if ( $key === $this->getLocalHeaders()['jumuah'] && $jumuahTime) { |
| 615 | return $jumuahTime; |
| 616 | } |
| 617 | return $this->formatDateForPrayer($time); |
| 618 | } |
| 619 | |
| 620 | protected function todayIsFriday() |
| 621 | { |
| 622 | return $this->dptHelper->todayIsFriday(); |
| 623 | } |
| 624 | |
| 625 | protected function tomorrowIsFriday() |
| 626 | { |
| 627 | return $this->dptHelper->tomorrowIsFriday(); |
| 628 | } |
| 629 | |
| 630 | public function getHijriDate($day, $month, $year, $dbRow, $forMonth=false) |
| 631 | { |
| 632 | return $this->dptHelper->getHijriDate($day, $month, $year, $dbRow, $forMonth); |
| 633 | } |
| 634 | |
| 635 | public function isJumahDisplay($dbRow) |
| 636 | { |
| 637 | return $this->dptHelper->isJumahDisplay($dbRow); |
| 638 | } |
| 639 | |
| 640 | private function isSunset($dbRow, $forMonth=false) |
| 641 | { |
| 642 | return $this->dptHelper->isSunset($dbRow, $forMonth); |
| 643 | } |
| 644 | |
| 645 | /** |
| 646 | * dim display overnight between Isha and Fajr start |
| 647 | */ |
| 648 | protected function canDimOvernight($dbRow, $disableOvernightDim=false) |
| 649 | { |
| 650 | return $this->dptHelper->canDimOvernight($dbRow, $disableOvernightDim); |
| 651 | } |
| 652 | |
| 653 | /** |
| 654 | * set khutbah dimming time on friday between sunrise and Asr |
| 655 | */ |
| 656 | protected function getKhutbahDim(array $dbRow): int |
| 657 | { |
| 658 | return $this->dptHelper->getKhutbahDim($dbRow); |
| 659 | } |
| 660 | |
| 661 | /** |
| 662 | * get diming time for taraweeh during ramadan after isha and before fajr |
| 663 | */ |
| 664 | protected function getTaraweehDim(array $dbRow): int |
| 665 | { |
| 666 | return $this->dptHelper->getTaraweehDim($dbRow); |
| 667 | } |
| 668 | |
| 669 | protected function getNextPrayerClass($prayerName, $row, $isFajr=false) |
| 670 | { |
| 671 | return $this->dptHelper->getNextPrayerClass($prayerName, $row, $isFajr); |
| 672 | } |
| 673 | |
| 674 | public function isRamadan() |
| 675 | { |
| 676 | return $this->dptHelper->isRamadan(); |
| 677 | } |
| 678 | |
| 679 | public function getJumuahTimesArray($isVertical = false, $separator = " | ") |
| 680 | { |
| 681 | $class = 'dsJumuah'; |
| 682 | if ($isVertical) { |
| 683 | $class = 'dsJumuah-vertical'; |
| 684 | } |
| 685 | $jumuahText = []; |
| 686 | $jumuahArray = [get_option('jumuah1'), get_option('jumuah2'), get_option('jumuah3')]; |
| 687 | $jumuahArray = array_filter($jumuahArray); |
| 688 | foreach ($jumuahArray as $jumuah) { |
| 689 | $jumuahText[] = '<span class="' . $class . '">' . $this->formatDateForPrayer($jumuah) . '</span>'; |
| 690 | } |
| 691 | return implode($separator, $jumuahText); |
| 692 | } |
| 693 | |
| 694 | public function getTimesLocalJson(): string |
| 695 | { |
| 696 | return |
| 697 | json_encode([ |
| 698 | 'minute' => $this->getLocalTimes()['minute'] ?? 'minute', |
| 699 | 'minutes' => $this->getLocalTimes()['minutes'], |
| 700 | 'hour' => $this->getLocalTimes()['hour'] ?? 'hour', |
| 701 | 'hours' => $this->getLocalTimes()['hours'], |
| 702 | 'second' => $this->getLocalTimes()['second'], |
| 703 | ], |
| 704 | JSON_UNESCAPED_UNICODE); |
| 705 | } |
| 706 | |
| 707 | public function getNumbersLocalJson(): string |
| 708 | { |
| 709 | $localNumbers = $this->getLocalNumbers(); |
| 710 | $localNumbers = array_combine(array_keys($localNumbers), $localNumbers); |
| 711 | return json_encode($localNumbers, JSON_UNESCAPED_UNICODE); |
| 712 | } |
| 713 | } |
| 714 |