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
DigitalScreen.php
446 lines
| 1 | <?php |
| 2 | |
| 3 | class DigitalScreen extends DailyShortCode |
| 4 | { |
| 5 | /** @var array */ |
| 6 | protected $row = array(); |
| 7 | |
| 8 | /** @var bool */ |
| 9 | private $isPortrait; |
| 10 | |
| 11 | private $isPresentation; |
| 12 | |
| 13 | /** @var int */ |
| 14 | private $screenTimeout; |
| 15 | |
| 16 | /** @var string */ |
| 17 | private $scrollText; |
| 18 | |
| 19 | /** @var array */ |
| 20 | private $presentationSlides; |
| 21 | |
| 22 | |
| 23 | /** @var string */ |
| 24 | private $blinkText = 'WELCOME TO HOUSE OF ALLAH'; |
| 25 | |
| 26 | /** @var string */ |
| 27 | private $blinkUrl; |
| 28 | |
| 29 | /** @var string */ |
| 30 | private $scrollUrl; |
| 31 | |
| 32 | public function __construct($attr=array()) |
| 33 | { |
| 34 | parent::__construct(); |
| 35 | if ( isset($attr['view']) ) { |
| 36 | $this->isPortrait = ( strtolower($attr['view']) == 'vertical' ); |
| 37 | $this->isPresentation = ( strtolower($attr['view']) == 'presentation' ); |
| 38 | } |
| 39 | |
| 40 | if ( isset($attr['dim']) ) { |
| 41 | $this->screenTimeout = $attr['dim']; |
| 42 | } |
| 43 | |
| 44 | if ( isset($attr['scroll']) ) { |
| 45 | $this->scrollText = $attr['scroll']; |
| 46 | } |
| 47 | |
| 48 | if ( isset($attr['scroll_link']) ) { |
| 49 | $this->scrollUrl = $attr['scroll_link']; |
| 50 | } |
| 51 | |
| 52 | if ( isset($attr['blink']) ) { |
| 53 | $this->blinkText = $attr['blink']; |
| 54 | } |
| 55 | |
| 56 | if ( isset($attr['blink_link']) ) { |
| 57 | $this->blinkUrl = $attr['blink_link']; |
| 58 | } |
| 59 | |
| 60 | if ( isset($attr['slides']) ) { |
| 61 | $this->presentationSlides = explode(',', $attr['slides']); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | public function displayDigitalScreen() |
| 66 | { |
| 67 | $html = $this->getTopRow(); |
| 68 | |
| 69 | if ($this->isPresentation) { |
| 70 | $html .= $this->getPresentationRow(); |
| 71 | } else { |
| 72 | $html .= $this->getMiddleRow(); |
| 73 | } |
| 74 | |
| 75 | $html .= $this->getBottomRow(); |
| 76 | |
| 77 | return $html; |
| 78 | } |
| 79 | |
| 80 | private function getTopRow() |
| 81 | { |
| 82 | $timeClass = "col-sm-3 "; |
| 83 | $dateClass = "col-sm-7 "; |
| 84 | $height = "height-100"; |
| 85 | $verticalClass = ""; |
| 86 | if ( $this->isPortrait ) { |
| 87 | $timeClass = "col-xs-12 vertical-time "; |
| 88 | $dateClass = "col-xs-12 vertical-date"; |
| 89 | $height = "height-50 "; |
| 90 | $verticalClass = "vertical"; |
| 91 | } |
| 92 | |
| 93 | if ( get_option('hijri-chbox')) { |
| 94 | $date = date_i18n( 'D jS M' ); |
| 95 | } else { |
| 96 | $date = date_i18n( 'l ' . get_option( 'date_format' ) ); |
| 97 | } |
| 98 | |
| 99 | $html = ' |
| 100 | <div class="container-fluid x-board"> |
| 101 | <input type="hidden" value="' . $this->screenTimeout . '" id="screenTimeout"> |
| 102 | <input type="hidden" value="' . htmlspecialchars(json_encode($this->getRefreshPoints())) . '" id="refreshPoint"> |
| 103 | <input type="hidden" value="' . htmlspecialchars(json_encode($this->getOtherAdhanTimes())) . '" id="otherAdhanTimes"> |
| 104 | <input type="hidden" value="' . htmlspecialchars(json_encode($this->getFajrAdhanTime())) . '" id="fajrAdhanTime"> |
| 105 | <div class="row top-row"> |
| 106 | <div class="time ' . $timeClass . 'col-xs-12 text-center ' . $height . '"> |
| 107 | <div class="clock align-middle"> |
| 108 | <ul class="clock"> |
| 109 | <li id="hours"></li> |
| 110 | <li id="point">:</li> |
| 111 | <li id="min"></li> |
| 112 | <li id="ampm"></li> |
| 113 | </ul> |
| 114 | </div> |
| 115 | </div> |
| 116 | <div class="' . $dateClass . ' col-xs-12 text-center bg-white ' . $height . '"> |
| 117 | <div class="align-middle"> |
| 118 | <span id="dsDate" class="date-eng h6 ' . $verticalClass . '">' . $date. '</span> |
| 119 | <span id="dsHijriDate" class="'. $verticalClass . 'hijri"> |
| 120 | ' . $this->getHijriDate(date("d"), date("m"), date("Y"), $this->getRow()) . ' |
| 121 | </span> |
| 122 | </div> |
| 123 | </div> |
| 124 | <div class="col-sm-2 col-xs-12 text-right align-middle padding-null">'; |
| 125 | $isLogo = get_option('ds-logo'); |
| 126 | if ( $isLogo && ! $this->isPortrait) { |
| 127 | $html .= '<img class="logo" src="' . $isLogo . '">'; |
| 128 | } |
| 129 | $html .= |
| 130 | '</div> |
| 131 | </div>'; |
| 132 | return $html; |
| 133 | } |
| 134 | |
| 135 | private function getPresentationRow() |
| 136 | { |
| 137 | $transitionEffect = get_option('transitionEffect'); |
| 138 | $transitionSpeed = get_option('transitionSpeed'); |
| 139 | |
| 140 | $html =' |
| 141 | <div class="row middle-row bg-red"> |
| 142 | <div class="col-sm-12 col-xs-12 padding-null text-center bg-green height-100 padding-null"> |
| 143 | <div id="text-carousel" class="carousel slide ' . $transitionEffect . ' |
| 144 | height-100" data-ride="carousel" data-interval="'. $transitionSpeed .'" data-pause="false"> |
| 145 | <div class="carousel-inner height-100"> |
| 146 | ' . $this->getPresentationSlides() . ' |
| 147 | </div> |
| 148 | </div> |
| 149 | </div> |
| 150 | </div> |
| 151 | '; |
| 152 | |
| 153 | return $html; |
| 154 | } |
| 155 | |
| 156 | private function getPresentationSlides() |
| 157 | { |
| 158 | if (!$this->presentationSlides) { |
| 159 | return "<h1>add slides option, ie. <br/> |
| 160 | <i><pre> [digital_screen view='presentation' slides=imageLink,imageLink,imageLink]</pre></i></h1>"; |
| 161 | } |
| 162 | |
| 163 | $html = ' |
| 164 | <div class="item active" > |
| 165 | <img class="carousel-slide" src="' . array_shift($this->presentationSlides) . '"> |
| 166 | </div>'; |
| 167 | |
| 168 | foreach ($this->presentationSlides as $i => $slideUrl) { |
| 169 | $html .= ' |
| 170 | <div class="item" > |
| 171 | <img class="carousel-slide" src="' . $slideUrl . '"> |
| 172 | </div> |
| 173 | '; |
| 174 | } |
| 175 | |
| 176 | return $html; |
| 177 | } |
| 178 | |
| 179 | private function getMiddleRow() |
| 180 | { |
| 181 | $leftClass = "col-sm-5 col-xs-12 bg-red height-100 padding-null text-center"; |
| 182 | $rightClass = "col-sm-7 col-xs-12 padding-null text-center bg-green height-100 padding-null"; |
| 183 | $verticalClass = ""; |
| 184 | |
| 185 | if ( $this->isPortrait ) { |
| 186 | $verticalClass = "vertical"; |
| 187 | $leftClass = "col-sm-12 bg-red padding-null text-center height-60"; |
| 188 | $rightClass = "col-sm-12 padding-null text-center bg-green height-40"; |
| 189 | } |
| 190 | |
| 191 | $html = ' |
| 192 | <div class="row middle-row bg-red"> |
| 193 | <div class="'. $leftClass .'"> |
| 194 | <table id="dsPrayerTimetable" class="table height-100 '. $verticalClass .'"> |
| 195 | <thead class="bg-dark"> |
| 196 | <tr> |
| 197 | <th class="dsPrayerName"> |
| 198 | <span class="dpt_start">' . strtoupper($this->getLocalHeaders()['prayer']) . '</span> |
| 199 | </th> |
| 200 | <th class="dsBegins"> |
| 201 | <span class="dpt_start">' . strtoupper($this->getLocalHeaders()['begins']) . '</span> |
| 202 | </th> |
| 203 | <th class="dsIqamah"> |
| 204 | <span class="dpt_jamah">' . strtoupper($this->getLocalHeaders()['iqamah']) . '</span> |
| 205 | </th> |
| 206 | </tr> |
| 207 | </thead> |
| 208 | <tbody> |
| 209 | <tr> |
| 210 | <td class="prayerName"> |
| 211 | <span>' . $this->getLocalPrayerNames()['fajr'] . '</span> |
| 212 | </td> |
| 213 | <td class="l-red">' . do_shortcode("[fajr_start]") . '</td> |
| 214 | <td>' . do_shortcode("[fajr_prayer]") . '</td> |
| 215 | </tr> |
| 216 | <tr> |
| 217 | <td class="prayerName"><span>' . $this->getLocalPrayerNames()['sunrise'] . '</span></td> |
| 218 | <td class="prayerName sunrise" colspan="2">' . do_shortcode("[sunrise]") . '</td> |
| 219 | </tr>'; |
| 220 | |
| 221 | if ( get_option('jumuah') && $this->todayIsFriday() && $this->isJumahDisplay($this->row)) { |
| 222 | $html .= '<tr> |
| 223 | <td class="prayerName"><span>' . stripslashes($this->getLocalHeaders()['jumuah']) . '</span></td> |
| 224 | <td colspan="2" class="prayerName sunrise"><span>' . get_option('jumuah') . '</span></td> |
| 225 | </tr>'; |
| 226 | } else { |
| 227 | $html .= ' |
| 228 | <tr> |
| 229 | <td class="prayerName"><span>' . $this->getLocalPrayerNames()['zuhr'] . '</span></td> |
| 230 | <td class="l-red">' . do_shortcode("[zuhr_start]") . '</td> |
| 231 | <td>' . do_shortcode("[zuhr_prayer]") . '</td> |
| 232 | </tr> |
| 233 | '; |
| 234 | } |
| 235 | |
| 236 | $html .= '<tr> |
| 237 | <td class="prayerName"><span>' . $this->getLocalPrayerNames()['asr'] . '</span></td> |
| 238 | <td class="l-red">' . do_shortcode("[asr_start]") . '</td> |
| 239 | <td>' . do_shortcode("[asr_prayer]") . '</td> |
| 240 | </tr> |
| 241 | <tr> |
| 242 | <td class="prayerName"><span>' . $this->getLocalPrayerNames()['maghrib'] . '</span></td> |
| 243 | <td class="l-red">' . do_shortcode("[maghrib_start]") . '</td> |
| 244 | <td>' . do_shortcode("[maghrib_prayer]") . '</td> |
| 245 | </tr> |
| 246 | <tr> |
| 247 | <td class="prayerName"><span>' . $this->getLocalPrayerNames()['isha'] . '</span></td> |
| 248 | <td class="l-red">' . do_shortcode("[isha_start]") . '</td> |
| 249 | <td>' . do_shortcode("[isha_prayer]") . '</td> |
| 250 | </tr>'; |
| 251 | if ( get_option('jumuah') && (! $this->todayIsFriday() || ! $this->isJumahDisplay($this->row)) ) { |
| 252 | $html .= ' |
| 253 | <tr> |
| 254 | <td class="prayerName"><span>' . stripslashes($this->getLocalHeaders()['jumuah']) . '</span></td> |
| 255 | <td colspan="2" class="prayerName sunrise"><span>' . get_option('jumuah') . '</span></td> |
| 256 | </tr>'; |
| 257 | } |
| 258 | $html .= ' |
| 259 | </tbody> |
| 260 | </table> |
| 261 | </div>'; |
| 262 | |
| 263 | $transitionEffect = get_option('transitionEffect'); |
| 264 | $transitionSpeed = get_option('transitionSpeed'); |
| 265 | $html .=' |
| 266 | <div class="'. $rightClass .'"> |
| 267 | <div id="text-carousel" class="carousel slide ' . $transitionEffect . ' |
| 268 | height-100" data-ride="carousel" data-interval="'. $transitionSpeed .'" data-pause="false"> |
| 269 | <div class="carousel-inner height-100"> |
| 270 | <div class="item active height-100"> |
| 271 | ' . $this->getFirstSlide() . ' |
| 272 | </div> |
| 273 | ' . $this->getOtherSlides() . ' |
| 274 | </div> |
| 275 | </div> |
| 276 | </div> |
| 277 | </div> |
| 278 | '; |
| 279 | |
| 280 | return $html; |
| 281 | } |
| 282 | |
| 283 | private function getBottomRow() |
| 284 | { |
| 285 | $verticalClass = ""; |
| 286 | |
| 287 | if ( $this->isPortrait ) { |
| 288 | $verticalClass = "vertical"; |
| 289 | } |
| 290 | |
| 291 | $html = ' |
| 292 | <div class="row bottom-row"> |
| 293 | <div class="notificationBackground col-sm-3 col-xs-12 text-center height-100 align-middle"> |
| 294 | <div class="align-middle"> |
| 295 | <span id="dsBlink" class="blink">' . $this->getBlink() . '</span> |
| 296 | </div> |
| 297 | </div> |
| 298 | <div class="col-sm-9 col-xs-12 height-100"> |
| 299 | <div class="align-middle"> |
| 300 | <h3 class="text-primary scrolling"> |
| 301 | <marquee id="dsIqamahUpdate" scrollamount="11">' . $this->getIqamahUpdate() . '</marquee> |
| 302 | </h3> |
| 303 | </div> |
| 304 | </div> |
| 305 | </div> |
| 306 | </div> |
| 307 | '; |
| 308 | |
| 309 | if ($this->isPortrait) { |
| 310 | $html = ' |
| 311 | <div class="row bottom-row"> |
| 312 | <div class="col-sm-12 col-xs-12 height-24"> |
| 313 | <div class="align-middle"> |
| 314 | <h3 class="text-primary scrolling-vertical"> |
| 315 | <marquee id="dsIqamahUpdate" scrollamount="11">' . $this->getIqamahUpdate() . '</marquee> |
| 316 | </h3> |
| 317 | </div> |
| 318 | </div> |
| 319 | <div class="notificationBackground col-sm-12 col-xs-12 text-center height-50 align-middle"> |
| 320 | <div class="align-middle"> |
| 321 | <span id="dsBlink" class="blink-'.$verticalClass.'">' . $this->getBlink() . '</span> |
| 322 | </div> |
| 323 | </div> |
| 324 | </div> |
| 325 | </div> |
| 326 | '; |
| 327 | } |
| 328 | |
| 329 | return $html; |
| 330 | } |
| 331 | |
| 332 | private function getIqamahUpdate() |
| 333 | { |
| 334 | if ( $this->scrollText ) { |
| 335 | return '<a target="_new" href="'. $this->scrollUrl .'">'. $this->scrollText .'</a>'; |
| 336 | } else { |
| 337 | return do_shortcode("[display_iqamah_update orientation='horizontal']"); |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | private function getBlink() |
| 342 | { |
| 343 | return '<a target="_new" href="'. $this->blinkUrl .'">'. $this->blinkText .'</a>'; |
| 344 | } |
| 345 | |
| 346 | private function getFirstSlide() |
| 347 | { |
| 348 | $verticalClass = ""; |
| 349 | if ( $this->isPortrait ) { |
| 350 | $verticalClass = "vertical"; |
| 351 | } |
| 352 | |
| 353 | if (get_option('ramadan-chbox')) { |
| 354 | $h3 = '<div class="dsRamadan"> |
| 355 | |
| 356 | <div class="sehri">' . $this->getLocalHeaders()['fast_begins'] . ': ' . $this->formatDateForPrayer($this->row['fajr_begins'], true) . '</div> |
| 357 | <div class="iftar pull-right">' . $this->getLocalHeaders()['fast_ends']. ': ' . do_shortcode("[maghrib_start]") . '</div> |
| 358 | </div>'; |
| 359 | } else { |
| 360 | $h3 = '<h3 class="'.$verticalClass.'">'. $this->getLocalTimes()['next prayer'] . '</h3>'; |
| 361 | } |
| 362 | |
| 363 | $html = ' |
| 364 | <div class="nextPrayer height-100"> |
| 365 | <div class="align-middle">' |
| 366 | . $h3 . |
| 367 | '<h2 id="dsNextPrayer" class="dsNextPrayer '.$verticalClass.'"></h2> |
| 368 | </div> |
| 369 | </div>'; |
| 370 | |
| 371 | return $html; |
| 372 | } |
| 373 | |
| 374 | private function getOtherSlides() |
| 375 | { |
| 376 | $isSlide = get_option('slider-chbox'); |
| 377 | if ( $isSlide ) { |
| 378 | $html = ""; |
| 379 | $slides = array(); |
| 380 | |
| 381 | foreach (range(1, 11) as $item) { |
| 382 | $slides[] = get_option('slider' . $item . 'Url'); |
| 383 | } |
| 384 | |
| 385 | $slides = array_filter($slides); |
| 386 | foreach ($slides as $i => $slideUrl) { |
| 387 | $html .= ' |
| 388 | <div class="item" > |
| 389 | <img class="carousel-slide" src="' . $slideUrl . '"> |
| 390 | </div> |
| 391 | '; |
| 392 | |
| 393 | $nextPrayerSlide = (int)get_option('nextPrayerSlide'); |
| 394 | if (!$this->isPresentation && $nextPrayerSlide > 0) { |
| 395 | $count = $i + 1; |
| 396 | if ( $count % $nextPrayerSlide == 0 ) { |
| 397 | $html .= ' |
| 398 | <div class="item"> |
| 399 | ' . $this->getFirstSlide() . ' |
| 400 | </div> |
| 401 | '; |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | return $html; |
| 407 | } |
| 408 | |
| 409 | return null; |
| 410 | } |
| 411 | |
| 412 | private function getRefreshPoints() |
| 413 | { |
| 414 | $result = $this->db->getPrayerTimeForToday(); |
| 415 | $iqamahTimes = array($result['fajr_jamah'], $result['sunrise'], $result['zuhr_jamah'], $result['asr_jamah'], $result['maghrib_jamah'], $result['isha_jamah']); |
| 416 | |
| 417 | $refreshPoints = array(); |
| 418 | foreach($iqamahTimes as $iqamah) { |
| 419 | $refreshPoints[] = date( "H:i:s", strtotime( $iqamah . "-16 minutes" ) ); |
| 420 | } |
| 421 | |
| 422 | return $refreshPoints; |
| 423 | } |
| 424 | |
| 425 | private function getOtherAdhanTimes() |
| 426 | { |
| 427 | $result = $this->db->getPrayerTimeForToday(); |
| 428 | $iqamahTimes = array($result['zuhr_jamah'], $result['asr_jamah'], $result['maghrib_begins'], $result['isha_jamah']); |
| 429 | |
| 430 | $adhanTimes = array(); |
| 431 | $adhanTimes[] = date( "H:i:s", strtotime( $iqamahTimes[0] . "-15 minutes" ) ); // zuhr |
| 432 | $adhanTimes[] = date( "H:i:s", strtotime( $iqamahTimes[1] . "-15 minutes" ) ); // asr |
| 433 | $adhanTimes[] = date( "H:i:s", strtotime( $iqamahTimes[2] . "0 minutes" ) ); // maghrib |
| 434 | $adhanTimes[] = date( "H:i:s", strtotime( $iqamahTimes[3] . "-15 minutes" ) ); // isha |
| 435 | |
| 436 | return $adhanTimes; |
| 437 | } |
| 438 | |
| 439 | private function getFajrAdhanTime() |
| 440 | { |
| 441 | $result = $this->db->getPrayerTimeForToday(); |
| 442 | |
| 443 | return date( "H:i:s", strtotime( $result['fajr_jamah'] . "-15 minutes" ) ); // fajr |
| 444 | } |
| 445 | } |
| 446 |