<commit_before><?php
/**
 * Created by PhpStorm.
 * User: YueLyu
 * Date: 11/14/15
 * Time: 9:45 PM
 */

class HouseInformation extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this->load->database();
        $this->load->model(array('Houseinfo','RatingInfo'));
        $this->load->library(array('session','form_validation'));
        $this->load->helper(array('form','url','date'));
    }

    public function index() {
        $data['houseInformation'] = $this->Houseinfo->getHouseInformation();
    }

    public function view($id,$msg='',$update_view_times=1) {
        if($update_view_times === 1){
          $this->Houseinfo->addViewTimes($id);
        }
        $data['id'] = $id;
        $data['houseInformation_item'] = $this->Houseinfo->getHouseInformation($id);
        $data['title'] = "House Information";
        $data['msg'] = $msg;

        $data['tagStatistics'] = $this->Houseinfo->getTagStatistics($id);
        $data['sellerInformation'] = $this->Houseinfo->getSellerInformation($id);
        $data['corpInformation'] = $this->Houseinfo->getCorpInformation($id);

        $this->load->view('templates/header', $data);
        $this->load->view('house_information', $data);
        $this->load->view('templates/footer');
    }

    public function viewMyPosts() {
        $data['title'] = 'My Posts';
        $this->load->view('templates/header',$data);
        $this->load->view('my_posts',$data);
        $this->load->view('templates/footer');
    }

    public function myPosts() {
        $id = $_SESSION['id'];
        echo $this->Houseinfo->getMyPosts($id);
    }

    # post a new House
    public function newPost($msg='') {
      $data['title'] = "House Information";
      $data['msg'] = $msg;

      $this->load->view('templates/header', $data);
      $this->load->view('new_post', $data);
      $this->load->view('templates/footer');
    }

    # submit a new post
    public function submitNewPost() {
        $this->form_validation->set_rules('buildYear', 'BuildYear', 'required|exact_length[10]');
        $this->form_validation->set_rules('location', 'Location', 'required');
        $this->form_validation->set_rules('brNumber', 'BrNumber', 'required|integer');
        $this->form_validation->set_rules('price', 'Price', 'required|greater_than[0]');
        $this->form_validation->set_rules('description', 'Description', 'required');
        $this->form_validation->set_rules('typeName', 'TypeName', 'required|in_list[1,2]');

        if ($this->form_validation->run() == FALSE)
          { $this->newPost('Error in input data. Input again.');
          }
          else
          { $id=$this->Houseinfo->newPost($_SESSION['id']);
            $msg = "New a post successfully.";
            $this->uploadImage($id,$msg);
          }
    }

    # upload image for post $id
    public function uploadImage($id,$msg=''){
      $config['upload_path']      = './images/';
      $config['allowed_types']    = 'jpg|png';
      $this->load->library('upload', $config);

      if ( ! $this->upload->do_upload('userfile'))
      { $data['error'] = array('error' => $this->upload->display_errors());
        $data['id'] = $id;
        $this->load->view('upload_image', $data);<commit_msg>update newPost result page<commit_after><?php
/**
 * Created by PhpStorm.
 * User: YueLyu
 * Date: 11/14/15
 * Time: 9:45 PM
 */

class HouseInformation extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this->load->database();
        $this->load->model(array('Houseinfo','RatingInfo'));
        $this->load->library(array('session','form_validation'));
        $this->load->helper(array('form','url','date'));
    }

    public function index() {
        $data['houseInformation'] = $this->Houseinfo->getHouseInformation();
    }

    public function view($id,$msg='',$update_view_times=1) {
        if($update_view_times === 1){
          $this->Houseinfo->addViewTimes($id);
        }
        $data['id'] = $id;
        $data['houseInformation_item'] = $this->Houseinfo->getHouseInformation($id);
        $data['title'] = "House Information";
        $data['msg'] = $msg;

        $data['tagStatistics'] = $this->Houseinfo->getTagStatistics($id);
        $data['sellerInformation'] = $this->Houseinfo->getSellerInformation($id);
        $data['corpInformation'] = $this->Houseinfo->getCorpInformation($id);

        $this->load->view('templates/header', $data);
        $this->load->view('house_information', $data);
        $this->load->view('templates/footer');
    }

    public function viewMyPosts() {
        $data['title'] = 'My Posts';
        $this->load->view('templates/header',$data);
        $this->load->view('my_posts',$data);
        $this->load->view('templates/footer');
    }

    public function myPosts() {
        $id = $_SESSION['id'];
        echo $this->Houseinfo->getMyPosts($id);
    }

    # post a new House
    public function newPost($msg='') {
      $data['title'] = "House Information";
      $data['msg'] = $msg;

      $this->load->view('templates/header', $data);
      $this->load->view('new_post', $data);
      $this->load->view('templates/footer');
    }

    # submit a new post
    public function submitNewPost() {
        $this->form_validation->set_rules('buildYear', 'BuildYear', 'required|exact_length[10]');
        $this->form_validation->set_rules('location', 'Location', 'required');
        $this->form_validation->set_rules('brNumber', 'BrNumber', 'required|integer');
        $this->form_validation->set_rules('price', 'Price', 'required|greater_than[0]');
        $this->form_validation->set_rules('description', 'Description', 'required');
        $this->form_validation->set_rules('typeName', 'TypeName', 'required|in_list[1,2]');

        if ($this->form_validation->run() == FALSE)
          { $this->newPost('Error in input data. Input again.');
          }
          else
          { $id=$this->Houseinfo->newPost($_SESSION['id']);
            $msg = "New a post successfully. Wait for the approval of administrator.";
            $this->newPost($msg);
          }
    }

    # upload image for post $id
    public function uploadImage($id,$msg=''){
      $config['upload_path']      = './images/';
      $config['allowed_types']    = 'jpg|png';
      $this->load->library('upload', $config);

      if ( ! $this->upload->do_upload('userfile'))
      { $data['error'] = array('error' => $this->upload->display_errors());
        $data['id'] = $id;
        $this->load->view('upload_image', $data);
{'fraction_non_alphanumeric': 0.19841873194465562, 'fraction_numerical': 0.004865440170290406, 'mean_word_length': 3.1241379310344826, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 137, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5001920', 'n_tokens_mistral': 2039, 'n_tokens_neox': 1953, 'n_words': 312}