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