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);
 }
Beispiel #2
0
 public function indexAction()
 {
     $msg = '';
     $title = MetaHelper::setPageTitle('Погода');
     $request = new Request();
     $model = new WeatherModel();
     /*
      * Getting Yandex weather data xml file
      * Getting default values
      */
     $yandex_xml = $model->getXmlYandexForecast();
     $yandex_default_values = $model->getDefaultYandexValues();
     if ($request->get('submit')) {
         $result = $model->searchByCityName($request->get('city_search'));
         if ($result) {
             $city_id = $result['city_id'];
             Cookie::set('city_id', $city_id);
         } else {
             $city_id = $yandex_default_values['default_value'];
             $msg = 'Город не найден в списке';
         }
     } else {
         $city_id = Cookie::get('city_id') ? Cookie::get('city_id') : $yandex_default_values['default_value'];
     }
     /*
      * Yandex xml data parsing
      */
     $weather = new Weather($yandex_xml['weather_source'], $city_id);
     $data = $weather->xmlProcessing();
     $city_name = array_shift($data);
     /*
      * Getting Yandex cities data
      */
     $yandex_cities_xml = $model->getXmlYandexCities();
     $countries = simplexml_load_file($yandex_cities_xml['cities_source'] . '.xml');
     /*
      * Getting Yandex data informer
      */
     $informer = $model->getInformerData();
     $args = ['page_title' => $title, 'data' => $data, 'countries' => $countries, 'city_name' => $city_name, 'informer' => $informer, 'msg' => $msg];
     /*
      * Rendering starting page
      */
     return $this->render("index.phtml", $args);
 }