<?php defined('BASEPATH') OR exit('No direct script access allowed');
header("Content-Type: text/html; charset=UTF-8");
ini_set('max_execution_time', 120);
/**
 * PURPOSE		 Controller에서 공통 함수 호출을 위해 Class 확장
 */
class cm_controller extends CI_Controller {
	function __construct() {
        parent::__construct();
		$this->load->library('session');
		$this->load->library('user_agent');
        $this->load->helper('crossmap/tool_helper');
		$this->load->helper('crossmap/exception_helper');

		if($this->session->userdata('Adm_Id') == '') {
			gf_alert('잘못된 접근입니다.', '/admin/');
            exit;
		}


	}

	function _remap($method, $params = array()) {
		# model - header 이미지
        $this->load->model('admin/setting/m_setting_site');
        $return_data    = $this->m_setting_site->site_info_select();
        if($return_data == '') {
            $return_data['admin_logo'] = '';
        }

		// Method가 있으면 해당 함수 실행
		if (method_exists($this, 'fn_'.$method)) {
			// Skin
			$data['Skin_Header'] = $this->load->view('skin/admin/_header', $return_data, TRUE);
			$data['Skin_Footer'] = $this->load->view('skin/admin/_footer', '', TRUE);

			$data['Skin_Content']     = call_user_func_array(array($this, 'fn_'.$method), $params);

			$this->load->view('skin/admin/_body', $data);

        } else if (method_exists($this, 'fn_popup_'.$method))  {
            // Skin
            $data['Skin_Header'] = '';
			$data['Skin_Footer'] = '';
			$data['Skin_Content']     = call_user_func_array(array($this, 'fn_popup_'.$method), $params);

			$this->load->view('skin/admin/_body', $data);

		} else if (method_exists($this, 'fn_ajax_'.$method))  {                 // Ajax페이지는 Skin 필요없음
			call_user_func_array(array($this, 'fn_ajax_'.$method), $params);
        } else if (method_exists($this, 'fn_doc_'.$method))  {                 // Skin 필요없음
			call_user_func_array(array($this, 'fn_doc_'.$method), $params);
		} else {                                                                // 없으면 잘못된 URL
			show_404();
		}
	}
}

