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