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