<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * @Cscms 3.5 open source management system
 * @copyright 2009-2013 chshcms.com. All rights reserved.
 * @Author:Cheng Jie
 * @Dtime:2013-04-27
 */
class Module_proxy extends CI_Controller {

	function _remap($method)
	{
		$total = $this->uri->total_rsegments();

		if ($total < 1)
		{
			show_404('Module Not Found.');

			return;
		}

		$param = array();
		$segments = $this->uri->rsegment_array();
		$uri = implode($segments, '/');

		// 判断是否请求的子目录下的模块
		if ($total > 1 && is_dir('plugins/'.$segments[1].'/'.$segments[2].'/controllers'))
		{
			if ($total > 4)
			{
				$param = array_slice($segments, 4);
				$uri = implode(array_slice($segments, 0, 4), '/');
			}
		}
		else
		{
			if ($total > 3)
			{
				$param = array_slice($segments, 3);
				$uri = implode(array_slice($segments, 0, 3), '/');
			}
		}

		// 直接转发给相应的 Module 处理
		$this->load->module($uri, $param);
	}

	function index()
	{
		$this->_remap('index');
	}

}

/* End of file module_proxy.php */
/* Location: ./application/third_party/module_proxy.php */

