Ejemplo n.º 1
0
 public function informerAction()
 {
     $model = new WeatherModel();
     $yandex_xml = $model->getXmlYandexForecast();
     $yandex_default_values = $model->getDefaultYandexValues();
     $default_value = Cookie::get('city_id') ? Cookie::get('city_id') : $yandex_default_values['default_value'];
     $weather = new Weather($yandex_xml['weather_source'], $default_value);
     $data = $weather->xmlProcessing();
     $city_name = array_shift($data);
     $args = ['data' => $data, 'city_name' => $city_name];
     return $this->weatherRender('informer.phtml', $args);
 }
Ejemplo n.º 2
0
 public function changeCityAction()
 {
     $request = new Request();
     $model = new WeatherModel();
     $yandex_xml = $model->getXmlYandexForecast();
     $city_id = $request->post('city_id');
     /*
      * Getting weather report for city
      */
     $weather = new Weather($yandex_xml['weather_source'], $city_id);
     $data = $weather->xmlProcessing();
     $city_name = array_shift($data);
     $args = ['data' => $data, 'city_name' => $city_name];
     /*
      * Rendering page with city
      */
     return $this->weatherRender('result.phtml', $args);
 }
Ejemplo n.º 3
0
 public function saveCitiesFromXmlAction()
 {
     $title = MetaHelper::setPageTitle('Загрузить города');
     $request = new Request();
     $model = new WeatherModel();
     $msg = '';
     if ($request->isPost()) {
         if ($request->post('submit')) {
             $data = Weather::parseXmlCitiesList($request->post('cities_source'));
             ini_set('max_execution_time', 900);
             foreach ($data as $value) {
                 $model->saveCitiesInDb($value['id'], $value, $value['country']);
             }
             if ($model == true) {
                 $msg = 'Загружено';
             } else {
                 $msg = 'Ошибка загрузки';
             }
         }
     }
     $args = ['page_title' => $title, 'msg' => $msg];
     return $this->render('saveCitiesFromXml.phtml', $args, 'admin');
 }