Exemplo n.º 1
0
 public function lang_newsAction()
 {
     $model = new AdminModel();
     $form = Call::form('Lang_news');
     $news = $model->getNewsByID(Request::getUri()[0]);
     if (!$news->id) {
         error404();
     }
     if (isPost()) {
         $dataPost = array('name' => post('name'), 'lang' => 'en', 'text' => post('text'));
         // allPost()
         $lnid = post('lnid', 'int');
         if ($form->isValid($dataPost)) {
             $data = $form->data;
             $data['nid'] = $news->id;
             $data['uid'] = Request::getParam('user')->id;
             $data['time'] = time();
             if ($lnid) {
                 $model->update('news_lang', $data, "`id` = '{$lnid}'");
                 setNotice(Lang::translate('LANG_NEWS_EDITED'));
             } else {
                 $id = $model->insert('news_lang', $data);
                 $lnid = $id;
                 if ($id) {
                     setNotice(Lang::translate('LANG_NEWS_ADDED'));
                 }
             }
             $dataImg['path'] = 'public/news/';
             $dataImg['new_name'] = $lnid;
             $dataImg['resize'] = 2;
             $dataImg['mkdir'] = true;
             $dataImg['min_width'] = 600;
             $dataImg['min_height'] = 400;
             if ($_FILES['image']['name']) {
                 $f = File::LoadImg($_FILES['image'], $dataImg);
             }
         } else {
             setNotice(Lang::translate('SOME_ERROR'));
         }
         //redirect(url('admin', 'lang_news', $news->id));
     }
     $this->view->list = $model->getLangNewsList($news->id);
     $this->view->news = $news;
     $this->view->title = $news->name;
 }