Tabs
7 years ago
DSTemplate.php
7 years ago
DailyTimetablePrinter.php
7 years ago
HelpsAndTips.php
7 years ago
MonthlyTimetablePrinter.php
7 years ago
TimetablePrinter.php
7 years ago
dptWidgetForm.php
7 years ago
horizontal-div.php
9 years ago
widget-admin.php
7 years ago
DailyTimetablePrinter.php
402 lines
| 1 | <?php |
| 2 | require_once( 'TimetablePrinter.php' ); |
| 3 | |
| 4 | class DailyTimetablePrinter extends TimetablePrinter |
| 5 | { |
| 6 | |
| 7 | public function horizontalTimeDiv($row) |
| 8 | { |
| 9 | ob_start(); |
| 10 | include 'horizontal-div.php'; |
| 11 | return ob_get_clean(); |
| 12 | } |
| 13 | |
| 14 | /** |
| 15 | * @param $row |
| 16 | * @return string |
| 17 | */ |
| 18 | public function printHorizontalTime($row) |
| 19 | { |
| 20 | $table = $this->printHorizontalTableTop( $row ); |
| 21 | |
| 22 | $table .= ' |
| 23 | <tr> |
| 24 | <th class="tableHeading">' .$this->localHeaders['prayer']. '</th>' |
| 25 | . $this->printTableHeading($row) . |
| 26 | '</tr> |
| 27 | <tr> |
| 28 | <th class="tableHeading">' .$this->localHeaders['begins']. '</th>' |
| 29 | .$this->printAzanTime($row). |
| 30 | '</tr> |
| 31 | <tr><th class="tableHeading">' .$this->localHeaders['iqamah']. '</th>' |
| 32 | .$this->printJamahTime($row, false). |
| 33 | '</tr> |
| 34 | </table>'; |
| 35 | |
| 36 | return $table; |
| 37 | } |
| 38 | |
| 39 | public function horizontalTimeJamahOnly($row) |
| 40 | { |
| 41 | $table = $this->printHorizontalTableTop( $row ); |
| 42 | |
| 43 | $table .= ' |
| 44 | <tr><th>' .$this->localHeaders['prayer']. '</th>' |
| 45 | . $this->printTableHeading($row) . |
| 46 | '</tr> |
| 47 | <tr> |
| 48 | <th>'.$this->localHeaders['iqamah'].'</th>' |
| 49 | .$this->printJamahTime($row). |
| 50 | '</tr> |
| 51 | </table>'; |
| 52 | |
| 53 | return $table; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * @param $row |
| 58 | * |
| 59 | * @return string |
| 60 | */ |
| 61 | public function horizontalTimeAzanOnly($row) |
| 62 | { |
| 63 | $table = $this->printHorizontalTableTop( $row, true ); |
| 64 | |
| 65 | $table .= ' |
| 66 | <tr><th>' .$this->localHeaders['prayer']. '</th>' |
| 67 | . $this->printTableHeading($row) . |
| 68 | '</tr> |
| 69 | <tr> |
| 70 | <th>'.$this->localHeaders['begins'].'</th>' |
| 71 | .$this->printAzanTime($row). |
| 72 | '</tr> |
| 73 | </table>'; |
| 74 | |
| 75 | return $table; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * @param $row |
| 80 | * @return string |
| 81 | */ |
| 82 | public function printVerticalTime($row) |
| 83 | { |
| 84 | $table = $this->printVerticalTableTop( $row , true); |
| 85 | |
| 86 | $table .= |
| 87 | '<tr> |
| 88 | <th class="tableHeading">' .$this->localHeaders['prayer']. '</th> |
| 89 | <th class="tableHeading">' .$this->localHeaders['begins']. '</th> |
| 90 | <th class="tableHeading">' .$this->localHeaders['iqamah']. '</th> |
| 91 | </tr>' |
| 92 | . $this->printVerticalRow( $row, 'both' ) . |
| 93 | '</table>'; |
| 94 | |
| 95 | return $table; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * @param array $row |
| 100 | * @return string |
| 101 | */ |
| 102 | public function verticalTimeJamahOnly($row) |
| 103 | { |
| 104 | $table = $this->printVerticalTableTop( $row ); |
| 105 | |
| 106 | $table .= |
| 107 | '<tr> |
| 108 | <th class="tableHeading">' .$this->localHeaders['prayer']. '</th> |
| 109 | <th class="tableHeading">' .$this->localHeaders['iqamah']. '</th> |
| 110 | </tr>' |
| 111 | .$this->printVerticalRow( $row, 'iqamah' ) . |
| 112 | '</table>'; |
| 113 | |
| 114 | return $table; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * @param array $row |
| 119 | * @return string |
| 120 | */ |
| 121 | public function verticalTimeAzanOnly($row) |
| 122 | { |
| 123 | $table = $this->printVerticalTableTop( $row, false, true ); |
| 124 | |
| 125 | $table .= |
| 126 | '<tr> |
| 127 | <th class="tableHeading">' .$this->localHeaders['prayer']. '</th> |
| 128 | <th class="tableHeading">' .$this->localHeaders['begins']. '</th> |
| 129 | </tr>' |
| 130 | .$this->printVerticalRow( $row, 'azan' ) . |
| 131 | '</table>'; |
| 132 | |
| 133 | return $table; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * @param $row |
| 138 | * |
| 139 | * @param bool $isAzanOnly |
| 140 | * |
| 141 | * @return string |
| 142 | */ |
| 143 | private function printHorizontalTableTop($row, $isAzanOnly=false) |
| 144 | { |
| 145 | if (! $row['hideTimeRemaining']) { |
| 146 | $nextIqamah = $isAzanOnly == true ? '' : $this->getNextIqamahTime( $row ); |
| 147 | } |
| 148 | |
| 149 | if (get_option('ramadan-chbox') && ! $row['hideRamadan']) { |
| 150 | $ramadan = ' |
| 151 | <tr class=""> |
| 152 | <td colspan="3" class="highlight">'. $this->localHeaders['fast_begins'].': '.$this->formatDateForPrayer($row['fajr_begins'], true).'</td> |
| 153 | <td></td> |
| 154 | <td colspan="3" class="highlight">'. $this->localHeaders['fast_ends'].': '.$this->formatDateForPrayer($row['maghrib_begins']).'</td> |
| 155 | </tr>'; |
| 156 | } |
| 157 | |
| 158 | if(isset($row['announcement']) && ! empty( $row['announcement'] )) { |
| 159 | $announcement = "<tr><th colspan='7' style='text-align:center' class='notificationBackground'>".$row['announcement']. "</th></tr>"; |
| 160 | } |
| 161 | $table = ""; |
| 162 | $table .= |
| 163 | '<table class="customStyles dptUserStyles dptTimetable ' .$this->getTableClass().'"> '.$announcement.' |
| 164 | <tr> |
| 165 | <th colspan="7" style="text-align:center">' |
| 166 | .$row['widgetTitle']. ' ' . date_i18n( get_option( 'date_format' ) ) .' '. $this->getHijriDate(date("d"), date("m"), date("Y"),$row) .' ' . $nextIqamah .' |
| 167 | </th> |
| 168 | </tr>'. $ramadan; |
| 169 | |
| 170 | return $table; |
| 171 | } |
| 172 | |
| 173 | public function displayRamadanTime($row) |
| 174 | { |
| 175 | return ' <table class="customStyles dptUserStyles"> |
| 176 | <tr style="text-align:center"> |
| 177 | <td colspan="3" class="fasting highlight">'. $this->localHeaders['fast_begins'].': '.$this->formatDateForPrayer($row['fajr_begins'], true).'</td> |
| 178 | <td style="border:0px;"></td> |
| 179 | <td colspan="3" class="fasting highlight">'. $this->localHeaders['fast_ends'].': '.$this->formatDateForPrayer($row['maghrib_begins']).'</td> |
| 180 | </tr></table>'; |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * @param $row |
| 185 | * |
| 186 | * @return string |
| 187 | */ |
| 188 | private function printTableHeading($row) |
| 189 | { |
| 190 | $ths = ''; |
| 191 | $nextPrayer = $this->getNextPrayer( $row ); |
| 192 | foreach ($this->localPrayerNames as $key=>$prayerName) { |
| 193 | $class = $nextPrayer == $key ? 'highlight' : ''; |
| 194 | $ths .= "<th class='tableHeading" . $this->tableClass . " ". $class."'>".$prayerName."</th>"; |
| 195 | } |
| 196 | |
| 197 | return $ths; |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * @param $row |
| 202 | * |
| 203 | * @return string |
| 204 | */ |
| 205 | private function printAzanTime($row) |
| 206 | { |
| 207 | $tds = ''; |
| 208 | $nextPrayer = ucfirst( $this->getNextPrayer( $row ) ); |
| 209 | foreach ($this->getAzanTime( $row ) as $key => $azan) { |
| 210 | $class = $nextPrayer == $key ? 'class=highlight' : ''; |
| 211 | $rowspan = ucfirst($key) == 'Sunrise' ? "rowspan='2'" : ''; |
| 212 | $tds .= "<td ". $rowspan ." ".$class.">".$this->formatDateForPrayer( $azan )."</th>"; |
| 213 | } |
| 214 | |
| 215 | return $tds; |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * @param $row |
| 220 | * @param bool $isSunrise |
| 221 | * |
| 222 | * @return string |
| 223 | */ |
| 224 | private function printJamahTime($row, $isSunrise=true) |
| 225 | { |
| 226 | $jamahTimes = $this->getJamahTime( $row ); |
| 227 | if (! $isSunrise) { |
| 228 | unset( $jamahTimes['Sunrise'] ); |
| 229 | } |
| 230 | $tds = ''; |
| 231 | $nextPrayer = ucfirst( $this->getNextPrayer( $row ) ); |
| 232 | foreach ($jamahTimes as $key => $azan) { |
| 233 | $class = $nextPrayer == $key ? 'class=highlight' : 'class=jamah'; |
| 234 | $tds .= "<td ".$class.">".$this->formatDateForPrayer( $azan )."</th>"; |
| 235 | } |
| 236 | |
| 237 | return $tds; |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * @param $row |
| 242 | * @param bool $isFullTable |
| 243 | * |
| 244 | * @return string |
| 245 | */ |
| 246 | private function printVerticalTableTop($row, $isFullTable=false, $isAzanOnly=false) |
| 247 | { |
| 248 | if (! $row['hideTimeRemaining']) { |
| 249 | $nextIqamah = $isAzanOnly == true ? '' : $this->getNextIqamahTime($row); |
| 250 | } |
| 251 | |
| 252 | $colspan = ( $isFullTable == true ) ? 3 : 2; |
| 253 | |
| 254 | $colspanRamadan = $isFullTable == true ? "colspan='2'" : ''; |
| 255 | |
| 256 | |
| 257 | if (get_option('ramadan-chbox') && ! $row['hideRamadan']) { |
| 258 | $ramadan = ' |
| 259 | <tr> |
| 260 | <th class="highlight">' .$this->localHeaders['fast_begins']. '</th> |
| 261 | <th '.$colspanRamadan.' class="highlight">' .$this->formatDateForPrayer($row['fajr_begins'], true). '</th> |
| 262 | </tr> |
| 263 | <tr> |
| 264 | <th class="highlight">'.$this->localHeaders['fast_ends'].'</th> |
| 265 | <th '.$colspanRamadan.' class="highlight">'.$this->formatDateForPrayer($row['maghrib_begins']).'</th> |
| 266 | </tr> |
| 267 | '; |
| 268 | } |
| 269 | $table = ""; |
| 270 | if(isset($row['announcement']) && ! empty( $row['announcement'] )) { |
| 271 | $announcement = "<tr><th colspan=".$colspan." style='text-align:center' class='notificationBackground'>".$row['announcement']. "</th></tr>"; |
| 272 | } |
| 273 | |
| 274 | $table .= |
| 275 | '<table class="dptTimetable ' .$this->getTableClass().' customStyles dptUserStyles"> '.$announcement.' |
| 276 | <tr> |
| 277 | <th colspan='.$colspan.' style="text-align:center">' |
| 278 | .$row['widgetTitle']. ' '. date_i18n( get_option( 'date_format' ) ) .' '. $this->getHijriDate(date("d"), date("m"), date("Y"), $row).'' . $nextIqamah . ' |
| 279 | </th> |
| 280 | </tr>' |
| 281 | .$ramadan; |
| 282 | |
| 283 | return $table; |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * @param $row |
| 288 | * @param $display // i.e both, azan, iqamah |
| 289 | * |
| 290 | * @return string |
| 291 | */ |
| 292 | private function printVerticalRow($row, $display) |
| 293 | { |
| 294 | $trs = ''; |
| 295 | $nextPrayer = $this->getNextPrayer( $row ); |
| 296 | |
| 297 | foreach ($this->localPrayerNames as $key=>$prayerName) { |
| 298 | $begins = $key != 'sunrise' ? lcfirst( $key ).'_begins' : 'sunrise'; |
| 299 | $jamah = $key != 'sunrise' ? lcfirst( $key ).'_jamah' : 'sunrise'; |
| 300 | |
| 301 | $class = $nextPrayer == $key ? 'highlight' : ''; |
| 302 | $highlightForJamah = $nextPrayer == $key ? 'highlight' : ''; |
| 303 | |
| 304 | $trs .= '<tr> |
| 305 | <th class="prayerName ' .$class.'">' . $prayerName . '</th>'; |
| 306 | if ($key == 'sunrise' && $display == 'both') { |
| 307 | $trs .= '<td colspan="2" ' . $class . '>'.$this->formatDateForPrayer($row[$jamah]).'</td>'; |
| 308 | } elseif ($display == 'azan') { |
| 309 | $trs .='<td class="begins '.$class.'">'.$this->formatDateForPrayer($row[$begins]).'</td> |
| 310 | </tr>'; |
| 311 | } elseif ($display == 'iqamah') { |
| 312 | $trs .='<td class="begins '.$class.'">'.$this->formatDateForPrayer($row[$jamah]).'</td> |
| 313 | </tr>'; |
| 314 | } else { |
| 315 | $trs .='<td class="begins '.$class.'">'.$this->formatDateForPrayer($row[$begins]).'</td> |
| 316 | <td class="jamah '.$highlightForJamah.'">'.$this->formatDateForPrayer($row[$jamah]).'</td> |
| 317 | </tr>'; |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | return $trs; |
| 322 | } |
| 323 | |
| 324 | public function displayNextPrayer($row, $nextFajr) |
| 325 | { |
| 326 | $nextPrayer = $this->getNextPrayer( $row ); |
| 327 | $nextIqamah = $this->getNextIqamahTimeDiff($row); |
| 328 | $key = ($nextPrayer == 'sunrise') ? $nextPrayer : strtolower($nextPrayer.'_jamah'); |
| 329 | $iqamah = ($nextPrayer == 'sunrise') ? '' : $this->localHeaders['iqamah']; |
| 330 | $nextPrayerName = $row[$key]; |
| 331 | |
| 332 | if ( is_null($nextPrayer) ) { |
| 333 | $nextPrayerName = $nextFajr; |
| 334 | } |
| 335 | if ($nextIqamah) { |
| 336 | $timeLeftText = $this->getLocalizedNumber( $nextIqamah ) .':00'; |
| 337 | $minLeftText = '<span class="timeLeft '.$this->getIqamahClass( $nextIqamah ).'">'. $this->localTimes["minute"] .'</span>'; |
| 338 | if ($nextIqamah > 60) { |
| 339 | $hours = $nextIqamah / 60; |
| 340 | $hours = (int)$hours; |
| 341 | $mins = $nextIqamah % 60; |
| 342 | $mins = (int)$mins; |
| 343 | $timeLeftText = $this->getLocalizedNumber( $hours ) .' '.$this->localTimes["hours"] .' '. $this->getLocalizedNumber( $mins ); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | $nextPrayerString = ""; |
| 348 | |
| 349 | $nextPrayerString .=' |
| 350 | <div class="scNextPrayer"> |
| 351 | <span class="dptScNextPrayer"> |
| 352 | '. $this->getHeading($row, $nextPrayer, $iqamah) .' |
| 353 | <h2 class="dptScTime"> |
| 354 | '. $this->getNextPrayerTime($nextPrayerName, $row) |
| 355 | .'</h2> |
| 356 | </span> |
| 357 | '; |
| 358 | if (! $this->isJumahDisplay($row)) { |
| 359 | $nextPrayerString .= '<span class="green"> |
| 360 | <span class="timeLeftCountDown timeLeft '.$this->getIqamahClass( $nextIqamah ).'">'. $timeLeftText .' </span> |
| 361 | ' . $minLeftText . ' |
| 362 | </span> |
| 363 | </div>'; |
| 364 | } |
| 365 | |
| 366 | return $nextPrayerString; |
| 367 | } |
| 368 | |
| 369 | private function getHeading($dbRow, $nextPrayer, $iqamah) |
| 370 | { |
| 371 | if ( is_null($nextPrayer)) { |
| 372 | return $this->localPrayerNames['fajr'].' '. $iqamah; |
| 373 | } |
| 374 | if ( $this->isJumahDisplay($dbRow) ) { |
| 375 | return $this->localPrayerNames['zuhr'] = $this->getLocalHeaders()['jumuah']; |
| 376 | } |
| 377 | |
| 378 | return $this->localPrayerNames[$nextPrayer] .' '. $iqamah; |
| 379 | } |
| 380 | |
| 381 | private function getNextPrayerTime($nextPrayerName, $dbRow) |
| 382 | { |
| 383 | if ( $this->isJumahDisplay($dbRow) ) { |
| 384 | return get_option('jumuah'); |
| 385 | } |
| 386 | return $this->formatDateForPrayer($nextPrayerName); |
| 387 | } |
| 388 | |
| 389 | public function isJumahDisplay($dbRow) |
| 390 | { |
| 391 | if ( date('D') == 'Fri' && |
| 392 | current_time('timestamp') > strtotime($dbRow['sunrise']) && |
| 393 | current_time('timestamp') <= strtotime($dbRow['zuhr_jamah']) + 60 |
| 394 | ) { |
| 395 | return true; |
| 396 | } |
| 397 | |
| 398 | return false; |
| 399 | } |
| 400 | |
| 401 | } |
| 402 |