예제 #1
0
파일: view.php 프로젝트: sajans/cms
 /**
  * Prepare the view data, keeping this in here helps clean up
  * the controller.
  *
  * @return void
  */
 public function view()
 {
     $this->article = $this->article;
     $this->admin = $this->admin;
     $this->fields = Model_Article_Detail::getFields();
     $this->uploads = $this->article->getUploads(7, 1);
     $this->related = Model_Article::getRelatedArticle();
 }
예제 #2
0
파일: article__.php 프로젝트: sajans/cms
 public function action_edit_info($article_id = null, $save = null)
 {
     $article = Model_Article::find($article_id);
     if ($save) {
         if (Input::method() == "POST") {
             $postData = Input::post();
             #validation
             $val = Validation::forge();
             $val->add('mother_tongue', 'Mother Tounge')->add_rule('required');
             #validation
             if ($val->run()) {
                 foreach ($postData as $key => $p) {
                     $article->detail->{$key} = $p;
                 }
                 if ($article->save()) {
                     $data1['status'] = "success";
                     $data1['refresh'] = 'true';
                     $data1['msg'] = "Updated Successfully";
                 } else {
                     $data1['status'] = "false";
                     $data1['msg'] = "Cannot Update";
                 }
             } else {
                 $errors = $val->error();
                 $data1['status'] = 'false';
                 $data1['validation'] = 'true';
                 $data1['validation_fields'] = array('mother_tongue');
                 $data1['mother_tongue'] = isset($errors['mother_tongue']) ? $errors['mother_tongue']->get_message() : null;
             }
         }
         $data2['response'] = json_encode($data1);
         $view = View::forge('admin/response', $data2, false);
     } else {
         $data['data'] = $article->detail;
         $data['article'] = $article;
         $data['form_id'] = "form_edit_info";
         $data['form_title'] = "Edit Information";
         $data['form_action'] = Uri::create('article/edit_info/' . $article->id . "/save");
         $data['fields'] = Model_Article_Detail::getFields();
         $view = View::forge('article/edit_info', $data, false);
     }
     $this->template = $view;
 }