public function stationAction($reception = null, $item_id = null) { $this->view->setVar("TopMenuSelected", 'work'); $this->view->setVar("MenuSelected", 'stations'); $this->view->setVar("MenuItemActive", $reception); $messages = array(); if (!empty($reception)) { $view = $reception; switch ($reception) { case 'add': $this->view->setVar("CountriesAll", References::getCountries()); $this->view->setVar("StationsStatusAll", References::getStationsStatus()); $this->view->setVar("Stations", Stations::getStations()); break; case 'preview': if ($this->request->isPost()) { if ((bool) $this->request->getPost('add')) { View::addMessages($this, [Stations::addStation($this->request->getPost())]); } if ((bool) $this->request->getPost('delete')) { View::addMessages($this, [Stations::deleteStation($this->request->getPost('id'))]); } } $this->view->setVar("StationsAll", Stations::getStations()); break; case 'edit': if (empty($item_id)) { if ($this->request->isPost()) { $this->response->redirect('/administration/station/edit/' . $this->request->getPost('station_id'), '/'); } $messages[] = array('class' => 'alert-info', 'text' => "<p><b>Выберите</b> из выпадающего списка <b>станцию</b>, которую нужно изменить.</p>"); $this->view->setVar("StationsAll", Stations::getStations()); } else { if ($this->request->isPost()) { $messages[] = Stations::setStation($this->request->getPost()); } $this->view->setVar("Station", Stations::getStations($item_id)); $this->view->setVar("CountriesAll", References::getCountries()); $this->view->setVar("StationsStatusAll", References::getStationsStatus()); $this->view->setVar("Stations", Stations::getStations()); } break; } $this->view->pick('/administration/' . "station_" . $view); } $this->view->setVar("messages", $messages); }