public function indexAction() { $_request = new Request(); $title = MetaHelper::setPageTitle('Главная(admin)'); $login_form = new LoginForm($_request); $errors = array(); if ($_request->isPost()) { if ($login_form->validate()) { $user = new UserModel(); $login = $_request->post('login'); $hash_password = new Password($_request->post('password')); $res = $user->getUser($login, $hash_password); if (!$res) { $msg = "No such user"; } else { Session::set('user', $res); $msg = "You have successfully logged in!"; } Session::setFlash($msg); } else { $errors = $login_form->showErrors(); } } $model = new WeatherModel(); $data = $model->getSourcelist(); $args = ['errors' => $errors, 'data' => $data, 'page_title' => $title]; return $this->render('index.phtml', $args, 'admin'); }
public function __construct() { $_request = new Request(); $this->firstName = $_request->post('firstName'); $this->lastName = $_request->post('lastName'); $this->email = $_request->post('email'); $this->phone = $_request->post('phone'); $this->address = $_request->post('address'); $this->message = $_request->post('message'); }
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); }
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'); }