Tabs
2 years ago
DSTemplate.php
3 years ago
DailyTimetablePrinter.php
3 years ago
HelpsAndTips.php
3 years ago
MonthlyTimetablePrinter.php
2 years ago
TimetablePrinter.php
3 years ago
dptWidgetForm.php
4 years ago
horizontal-div.php
4 years ago
widget-admin.php
3 years ago
MonthlyTimetablePrinter.php
341 lines
| 1 | <?php |
| 2 | require_once( 'TimetablePrinter.php' ); |
| 3 | |
| 4 | class MonthlyTimetablePrinter extends TimetablePrinter |
| 5 | { |
| 6 | /** |
| 7 | * @param $rows |
| 8 | * @param $options |
| 9 | * |
| 10 | * @return string |
| 11 | */ |
| 12 | public function displayTable($rows, $options) |
| 13 | { |
| 14 | $table = $this->printFullTableTop($options); |
| 15 | |
| 16 | $table .= $this->printFullTableRow( $rows, $options, 'both' ); |
| 17 | |
| 18 | return $table; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * @param $options |
| 23 | * |
| 24 | * @return string |
| 25 | */ |
| 26 | private function printFullTableTop($options) |
| 27 | { |
| 28 | if ($options['isRamadan']) { |
| 29 | $monthName = 'Ramadan'; |
| 30 | if ((int)get_option('imsaq') > 0 ) { |
| 31 | $fajrBegins = esc_attr($this->localHeaders['begins']); |
| 32 | $fajrColspan = 4; |
| 33 | } else { |
| 34 | $fajrBegins = esc_attr($this->localHeaders['fast_begins']); |
| 35 | $fajrColspan = 3; |
| 36 | } |
| 37 | $maghribBegins = esc_attr($this->localHeaders['fast_ends']); |
| 38 | } else { |
| 39 | $fajrBegins = esc_attr($this->localHeaders['begins']); |
| 40 | $maghribBegins = esc_attr($this->localHeaders['begins']); |
| 41 | $fajrColspan = 3; |
| 42 | $dt = DateTime::createFromFormat('!m', $options['monthNumber']); |
| 43 | $monthName = $dt->format('F'); |
| 44 | } |
| 45 | |
| 46 | $fastingClass = $this->getFastingClass( $options ); |
| 47 | $prayers = $this->getLocalPrayerNames(true); |
| 48 | |
| 49 | $table = " |
| 50 | <table class='dptTimetable customStyles dptUserStyles'> |
| 51 | <thead class='prayerName'> |
| 52 | <th class='prayerName' colspan='2'>" . $monthName . "</th> |
| 53 | |
| 54 | <th class='prayerName' colspan='$fajrColspan'>" . esc_attr($prayers['fajr']) . "</th> |
| 55 | <th class='prayerName' colspan='2'>" . esc_attr($prayers['zuhr']) . "</th>"; |
| 56 | $table .= "<th class='prayerName' colspan=".$this->getAsrMethodColspan().">" . esc_attr($prayers['asr']) . "</th>"; |
| 57 | $table .= " |
| 58 | <th class='prayerName' colspan='2'>" . esc_attr($prayers['maghrib']) . "</th> |
| 59 | <th class='prayerName' colspan='2'>" . esc_attr($prayers['isha']) . "</th> |
| 60 | </thead> |
| 61 | <thead> |
| 62 | <th class='tableHeading'>" . esc_attr($this->localTimes['date']) . "</th> |
| 63 | <th class='tableHeading'>" . esc_attr($this->localTimes['day']) . "</th> |
| 64 | "; |
| 65 | |
| 66 | if ($options['isRamadan'] && (int)get_option('imsaq') > 0) { |
| 67 | $table .="<th class='tableHeading ". $fastingClass ."'>" . esc_attr($this->localHeaders['fast_begins']) . "</th>"; |
| 68 | } |
| 69 | |
| 70 | $table.=" |
| 71 | <th class='tableHeading ". $fastingClass ."'>" . $fajrBegins . "</th> |
| 72 | <th class='tableHeading'>" . esc_attr($this->localHeaders['iqamah']) . "</th> |
| 73 | <th class='tableHeading'>" . esc_attr($prayers['sunrise']) . "</th> |
| 74 | |
| 75 | <th class='tableHeading'>" . esc_attr($this->localHeaders['begins']) . "</th> |
| 76 | <th class='tableHeading'>" . esc_attr($this->localHeaders['iqamah']) . "</th>"; |
| 77 | |
| 78 | $table .= $this->getAsrMethodTh(); |
| 79 | |
| 80 | $table .= "<th class='tableHeading'>" . esc_attr($this->localHeaders['iqamah']) . "</th> |
| 81 | |
| 82 | <th class='tableHeading ". $fastingClass ."'>" . $maghribBegins . "</th> |
| 83 | <th class='tableHeading'>" . esc_attr($this->localHeaders['iqamah']) . "</th> |
| 84 | |
| 85 | <th class='tableHeading'>" . esc_attr($this->localHeaders['begins']) . "</th> |
| 86 | <th class='tableHeading'>" . esc_attr($this->localHeaders['iqamah']) . "</th> |
| 87 | </thead>"; |
| 88 | |
| 89 | return $table; |
| 90 | } |
| 91 | |
| 92 | |
| 93 | /** |
| 94 | * @param array $rows |
| 95 | * @param $options |
| 96 | * @param string $display |
| 97 | * |
| 98 | * @return string |
| 99 | */ |
| 100 | private function printFullTableRow(array $rows, $options, $display='both') |
| 101 | { |
| 102 | $table = ''; |
| 103 | $asrMethod = get_option('asrSelect'); |
| 104 | $classFasting = $this->getClassFasting( $options ); |
| 105 | |
| 106 | foreach($rows as $day) { |
| 107 | $day['asr_begins'] = ($asrMethod == 'hanafi') ? $day['asr_mithl_2'] : $day['asr_mithl_1']; |
| 108 | |
| 109 | $today = explode('-', $day['d_date']); |
| 110 | $weekday = date_i18n("l", strtotime($day['d_date']), wp_timezone_string()); |
| 111 | |
| 112 | $table .= " |
| 113 | <tr " . $this->getClass($today[1], $today[2]) . "> |
| 114 | <td>" . date_i18n(get_option( 'date_format' ), strtotime($day['d_date'])). ' '. $this->getHijriDate($today[2], $today[1], $today[0], $day, true) ."</td> |
| 115 | <td class=" . $weekday . ">" . $weekday . "</td> |
| 116 | "; |
| 117 | |
| 118 | if ($options['isRamadan'] && (int)get_option('imsaq') > 0) { |
| 119 | $table .="<td ". $classFasting .">" . $this->formatDateForPrayer($day['fajr_begins'], true). "</td>"; |
| 120 | } |
| 121 | |
| 122 | $table .= " |
| 123 | <td ". $classFasting .">" . $this->formatDateForPrayer($day['fajr_begins']). "</td> |
| 124 | <td class='highlight'>" . $this->formatDateForPrayer($day['fajr_jamah']). "</td> |
| 125 | <td>" . $this->formatDateForPrayer($day['sunrise']). "</td> |
| 126 | |
| 127 | <td>" . $this->formatDateForPrayer($day['zuhr_begins']). "</td> |
| 128 | <td class='highlight'>" . $this->formatDateForPrayer($day['zuhr_jamah']). "</td>"; |
| 129 | |
| 130 | if ($asrMethod != 'both') { |
| 131 | $table .= "<td>" . $this->formatDateForPrayer($day['asr_begins']). "</td>"; |
| 132 | } else { |
| 133 | $table .= "<td>" . $this->formatDateForPrayer($day['asr_mithl_1']). "</td> |
| 134 | <td>" . $this->formatDateForPrayer($day['asr_mithl_2']). "</td>"; |
| 135 | } |
| 136 | $table .= " |
| 137 | <td class='highlight'>" . $this->formatDateForPrayer($day['asr_jamah']). "</td> |
| 138 | |
| 139 | <td ". $classFasting .">" . $this->formatDateForPrayer($day['maghrib_begins']). "</td> |
| 140 | <td class='highlight'>" . $this->formatDateForPrayer($day['maghrib_jamah']). "</td> |
| 141 | |
| 142 | <td>" . $this->formatDateForPrayer($day['isha_begins']). "</td> |
| 143 | <td class='highlight'>" . $this->formatDateForPrayer($day['isha_jamah']). "</td> |
| 144 | </tr>"; |
| 145 | } |
| 146 | |
| 147 | return $table; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * @param $rows |
| 152 | * @param $options |
| 153 | * |
| 154 | * @return string |
| 155 | */ |
| 156 | public function displayTableJamahOnly($rows, $options) |
| 157 | { |
| 158 | $table = $this->printTableTop( $options ); |
| 159 | |
| 160 | $table .= $this->printTableRow( $rows, $options ); |
| 161 | |
| 162 | return $table; |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * @param $rows |
| 167 | * @param $options |
| 168 | * |
| 169 | * @return string |
| 170 | */ |
| 171 | public function displayTableAzanOnly($rows, $options) |
| 172 | { |
| 173 | $table = $this->printTableTop( $options, true ); |
| 174 | $asrMethod = get_option('asrSelect'); |
| 175 | |
| 176 | foreach($rows as $day) { |
| 177 | $day['asr_begins'] = ($asrMethod == 'hanafi') ? $day['asr_mithl_2'] : $day['asr_mithl_1']; |
| 178 | |
| 179 | $today = explode('-', $day['d_date']); |
| 180 | $weekday = date("D", strtotime($day['d_date'])); |
| 181 | |
| 182 | $table .= " |
| 183 | <tr " . $this->getClass($today[1], $today[2]) . "> |
| 184 | <td>" . date_i18n(get_option( 'date_format' ), strtotime($day['d_date'])). ' '. $this->getHijriDate($today[2], $today[1], $today[0], $day, true) ."</td> |
| 185 | |
| 186 | <td class=" . $weekday . ">" . $weekday . "</td>" |
| 187 | . $this->getFastingTdWithData($options['isRamadan'], $day['fajr_begins'], true, true )." |
| 188 | <td>" . $this->formatDateForPrayer($day['sunrise']). "</td> |
| 189 | <td>" . $this->formatDateForPrayer($day['zuhr_begins']). "</td> |
| 190 | <td>" . $this->formatDateForPrayer($day['asr_begins']). "</td>" |
| 191 | . $this->getFastingTdWithData($options['isRamadan'], $day['maghrib_begins'], true )." |
| 192 | <td>" . $this->formatDateForPrayer($day['isha_begins']). "</td> |
| 193 | </tr>"; |
| 194 | } |
| 195 | |
| 196 | return $table; |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * @param $options |
| 201 | * @param bool $isAzanOnly |
| 202 | * |
| 203 | * @return string |
| 204 | */ |
| 205 | private function printTableTop($options, $isAzanOnly=false) |
| 206 | { |
| 207 | $fajr = ''; |
| 208 | $maghrib = ''; |
| 209 | $sunrise = ''; |
| 210 | $fajrJamah = ''; |
| 211 | $maghribJamah = ''; |
| 212 | $azanOnlyClass = ''; |
| 213 | |
| 214 | $prayers = $this->getLocalPrayerNames(true); |
| 215 | if ($isAzanOnly) { |
| 216 | $fajr = esc_attr($prayers['fajr']); |
| 217 | $maghrib = esc_attr($prayers['maghrib']); |
| 218 | $sunrise = "<th class='tableHeading'>" . esc_attr($prayers['sunrise']) . "</th>"; |
| 219 | $azanOnlyClass = 'azanOnly'; |
| 220 | } else { |
| 221 | $fajrJamah = "<th class='tableHeading'>" . esc_attr($prayers['fajr']) . "</th>"; |
| 222 | $maghribJamah = "<th class='tableHeading'>" . esc_attr($prayers['maghrib']) . "</th>"; |
| 223 | } |
| 224 | |
| 225 | if ($options['isRamadan'] && !$isAzanOnly) { |
| 226 | $fajr = ''; |
| 227 | $maghrib = ''; |
| 228 | $fajrHeading = "<th class='tableHeading fasting ".$azanOnlyClass."'>" . esc_attr($this->localHeaders['fast_begins']) . $fajr . "</th>"; |
| 229 | $maghribHeading = "<th class='tableHeading fasting ".$azanOnlyClass."'>" . esc_attr($this->localHeaders['fast_ends']) . $maghrib . "</th>"; |
| 230 | } elseif ($options['isRamadan'] && $isAzanOnly) { |
| 231 | $fajrHeading = "<th class='tableHeading fasting ".$azanOnlyClass."'>" . esc_attr($this->localHeaders['fast_begins']) . "</th>"; |
| 232 | $fajrHeading .= "<th class='tableHeading ".$azanOnlyClass."'>" . $fajr . "</th>"; |
| 233 | $maghribHeading = "<th class='tableHeading fasting ".$azanOnlyClass."'>" . esc_attr($this->localHeaders['fast_ends']) . '/'. $maghrib . "</th>"; |
| 234 | } elseif ($isAzanOnly) { |
| 235 | $fajrHeading = "<th class='tableHeading'>" . $fajr . "</th>"; |
| 236 | $maghribHeading = "<th class='tableHeading'>" . $maghrib . "</th>";; |
| 237 | } |
| 238 | |
| 239 | $table = " |
| 240 | <table class='dptTimetable customStyles'> |
| 241 | <tr> |
| 242 | <th class='tableHeading'>" . esc_attr($this->localTimes['date']) ."</th> |
| 243 | <th class='tableHeading'>" . esc_attr($this->localTimes['day']) ."</th>" |
| 244 | . $fajrHeading ."" |
| 245 | .$fajrJamah."" |
| 246 | .$sunrise. |
| 247 | "<th class='tableHeading'>" . esc_attr($prayers['zuhr']) . "</th> |
| 248 | <th class='tableHeading'>" . esc_attr($prayers['asr']) . "</th>" |
| 249 | . $maghribHeading . "" |
| 250 | .$maghribJamah ."". |
| 251 | "<th class='tableHeading'>" . esc_attr($prayers['isha']) . "</th> |
| 252 | </tr>"; |
| 253 | |
| 254 | return $table; |
| 255 | } |
| 256 | |
| 257 | /** |
| 258 | * @param array $rows |
| 259 | * @param $options |
| 260 | * |
| 261 | * @return string |
| 262 | */ |
| 263 | private function printTableRow(array $rows, $options) |
| 264 | { |
| 265 | $table = ''; |
| 266 | |
| 267 | foreach($rows as $day) { |
| 268 | |
| 269 | $today = explode('-', $day['d_date']); |
| 270 | $weekday = date("D", strtotime($day['d_date'])); |
| 271 | |
| 272 | $table .= " |
| 273 | <tr " . $this->getClass($today[1], $today[2]) . "> |
| 274 | <td>" . date_i18n(get_option( 'date_format' ), strtotime($day['d_date'])). ' '. $this->getHijriDate($today[2], $today[1], $today[0], $day, true) ."</td> |
| 275 | |
| 276 | <td class=" . $weekday . ">" . $weekday . "</td>" |
| 277 | . $this->getFastingTdWithData($options['isRamadan'], $day['fajr_begins'], false, true ) . " |
| 278 | <td>" . $this->formatDateForPrayer($day['fajr_jamah']). "</td> |
| 279 | <td>" . $this->formatDateForPrayer($day['zuhr_jamah']). "</td> |
| 280 | <td>" . $this->formatDateForPrayer($day['asr_jamah']). "</td>" |
| 281 | . $this->getFastingTdWithData($options['isRamadan'], $day['maghrib_begins'] ) . " |
| 282 | <td>" . $this->formatDateForPrayer($day['maghrib_jamah']). "</td> |
| 283 | <td>" . $this->formatDateForPrayer($day['isha_jamah']). "</td> |
| 284 | </tr>"; |
| 285 | } |
| 286 | |
| 287 | return $table; |
| 288 | } |
| 289 | |
| 290 | /** |
| 291 | * @param $options |
| 292 | * |
| 293 | * @return string |
| 294 | */ |
| 295 | private function getFastingClass($options) |
| 296 | { |
| 297 | if ( $options['isRamadan'] ) { |
| 298 | return 'fasting'; |
| 299 | } |
| 300 | return ''; |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * @param $options |
| 305 | * |
| 306 | * @return string |
| 307 | */ |
| 308 | private function getClassFasting($options) |
| 309 | { |
| 310 | if ( $options['isRamadan'] ) { |
| 311 | return "class='fasting'"; |
| 312 | } |
| 313 | return ''; |
| 314 | } |
| 315 | |
| 316 | /** |
| 317 | * @return int |
| 318 | */ |
| 319 | private function getAsrMethodColspan() |
| 320 | { |
| 321 | $asrMethod = get_option('asrSelect'); |
| 322 | if ($asrMethod != 'both') { |
| 323 | return 2; |
| 324 | } |
| 325 | return 3; |
| 326 | } |
| 327 | |
| 328 | /** |
| 329 | * @return string |
| 330 | */ |
| 331 | private function getAsrMethodTh() |
| 332 | { |
| 333 | $asrMethod = get_option('asrSelect'); |
| 334 | |
| 335 | if ($asrMethod != 'both') { |
| 336 | return "<th class='tableHeading'>" .$this->localHeaders['begins']. "</th>"; |
| 337 | } |
| 338 | return "<th class='tableHeading'>" .$this->localHeaders['standard']. "</th><th class='tableHeading'>" .$this->localHeaders['hanafi']. "</th>"; |
| 339 | } |
| 340 | } |
| 341 |