Processors
6 years ago
AssetsLoader.php
6 years ago
DPTAjaxHandler.php
7 years ago
DSTemplateLoader.php
7 years ago
DailyShortCode.php
6 years ago
DigitalScreen.php
6 years ago
HijriDate.php
7 years ago
Init.php
6 years ago
MonthlyShortCode.php
7 years ago
MonthlyTimeTable.php
6 years ago
UpdateStyles.php
7 years ago
Validator.php
7 years ago
db.php
6 years ago
dptWidget.php
7 years ago
Init.php
74 lines
| 1 | <?php |
| 2 | |
| 3 | require_once(__DIR__. '/db.php'); |
| 4 | |
| 5 | class Init |
| 6 | { |
| 7 | /** |
| 8 | * A reference to an instance of this class. |
| 9 | */ |
| 10 | private static $instance; |
| 11 | |
| 12 | /** |
| 13 | * Returns an instance of this class. |
| 14 | */ |
| 15 | public static function get_instance() { |
| 16 | |
| 17 | if ( null == self::$instance ) { |
| 18 | self::$instance = new Init(); |
| 19 | } |
| 20 | |
| 21 | return self::$instance; |
| 22 | } |
| 23 | |
| 24 | /** @var DatabaseConnection */ |
| 25 | private $db; |
| 26 | |
| 27 | public function __construct() |
| 28 | { |
| 29 | $this->db = new DatabaseConnection(); |
| 30 | $this->importSampleCsv(); |
| 31 | } |
| 32 | |
| 33 | private function importSampleCsv() |
| 34 | { |
| 35 | foreach ($this->getYearlyData() as $dateInYear) { |
| 36 | $row = array ( |
| 37 | 'd_date' => $dateInYear, |
| 38 | 'fajr_begins' => '00:00', |
| 39 | 'fajr_jamah' => '00:00', |
| 40 | 'sunrise' => '00:00', |
| 41 | 'zuhr_begins' => '00:00', |
| 42 | 'zuhr_jamah' => '00:00', |
| 43 | 'asr_mithl_1' => '00:00', |
| 44 | 'asr_mithl_2' => '00:00', |
| 45 | 'asr_jamah' => '00:00', |
| 46 | 'maghrib_begins' => '00:00', |
| 47 | 'maghrib_jamah' => '00:00', |
| 48 | 'isha_begins' => '00:00', |
| 49 | 'isha_jamah' => '00:00', |
| 50 | 'is_ramadan' => 0, |
| 51 | 'hijri_date' => 0 |
| 52 | ); |
| 53 | $this->db->insertRow($row); |
| 54 | } |
| 55 | add_option('dpt-init', '1'); |
| 56 | |
| 57 | } |
| 58 | |
| 59 | private function getYearlyData() |
| 60 | { |
| 61 | $year = date('Y'); |
| 62 | |
| 63 | $range = array(); |
| 64 | $start = strtotime($year.'-01-01'); |
| 65 | $end = strtotime($year.'-12-31'); |
| 66 | |
| 67 | do { |
| 68 | $range[] = date('Y-m-d',$start); |
| 69 | $start = strtotime("+ 1 day",$start); |
| 70 | } while ( $start <= $end ); |
| 71 | |
| 72 | return $range; |
| 73 | } |
| 74 | } |