<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

// TODO: find out a way to access the APIs.
class Comment extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('Comment_model');
    }

    public function listing()
    {
        $comments = $this->Comment_model->listing();
        $chi = array();
        $eng = array();
        foreach ($comments as $k => $v) {
            if (strlen($v['comment']) != strlen(utf8_decode($v['comment']))) {
                $eng[] = $v;
            } else {
                $chi[] = $v;
            }
        }
        echo json_encode(array('comments' => array_merge($eng, $chi)));
    }
}
