| 1 | <?php |
||
| 7 | class Downloader |
||
| 8 | { |
||
| 9 | private $config; |
||
| 10 | |||
| 11 | 78 | public function __construct(Config $config) |
|
| 15 | |||
| 16 | 78 | public function sync($type = 'xml') |
|
| 17 | { |
||
| 18 | 78 | $translations = (array) $this->config->get('translations'); |
|
| 19 | |||
| 20 | // Download quran data |
||
| 21 | 78 | foreach ($translations as $tr) { |
|
| 22 | 78 | $file = $this->config->get('storage_path').'/'.$tr.'.'.$type; |
|
| 23 | |||
| 24 | 78 | if (!file_exists($file)) { |
|
| 25 | $url = 'http://tanzil.net/trans/?transID='.$tr.'&type='.$type; |
||
| 26 | $this->download($url, $file); |
||
| 27 | } |
||
| 28 | 78 | } |
|
| 29 | 78 | } |
|
| 30 | |||
| 31 | public function download($url, $destination) |
||
| 37 | } |
||
| 38 |