public function editAction()
 {
     if (Session::hasUser('admin')) {
         $indexModel = new IndexModel();
         $data_page = $indexModel->getPage(Router::getId(), Router::getLanguage(), $this->material_type);
         $menuModel = new MenuModel();
         $data = $menuModel->getMainMenu('uk');
         $menuController = new MenuController();
         $main_menu_array = $menuController->menuArray($data);
         $data_menu_item = $menuModel->getMenuDatePage($data_page[0]['id']);
         $redirect_status = null;
         $request = new Request();
         $editModel = new AddEditModel($request, $this->material_type);
         if ($request->isPost()) {
             if ($editModel->isValid()) {
                 if ($editModel->isAliasExist($data_page[0]['id'])) {
                     if ($editModel->inMenu()) {
                         $file_data = array('max_image_size' => Config::get('max_image_size'), 'max_image_width' => Config::get('max_image_width'), 'max_image_height' => Config::get('max_image_height'));
                         $fileUpload = new UploadFile($request, $file_data);
                         $redirect_status = $fileUpload->uploadImg($request, $this->material_type);
                         if ($redirect_status) {
                             $editModel->edit($data_page[0]['id']);
                         }
                     } else {
                         $with_without_menu = 1;
                         $editModel->edit($data_page[0]['id'], $with_without_menu);
                     }
                 } else {
                     Session::setFlash('Документ с таким псевдонимом уже существует!');
                 }
             } else {
                 Session::setFlash('Поле "Заголовок" обязательно для заполнения');
             }
         }
         $this->rewrite_file_alias();
         $args = array('data_page' => $data_page, 'data_menu' => $main_menu_array, 'edit_model' => $editModel, 'data_menu_item' => $data_menu_item, 'redirect' => $request->post('redirect'), 'redirect_status' => $redirect_status, 'without_menu' => $request->post('without_menu'), 'menu_disable' => Config::get('menu_disable'), 'id' => $data_page[0]['id']);
         $tpl = 'edit' . str_replace(' ', '', ucwords(str_replace('_', ' ', $this->material_type)));
         return $this->render_admin($args, $tpl);
     } else {
         throw new Exception('Access  denied', 403);
     }
 }