首页 > 代码库 > 扩展Codeigniter控制器

扩展Codeigniter控制器

<?php
class MY_Controller extends CI_Controller {

	 public function __construct() {
		parent::__construct();
		if(intval($this->session->userdata(‘id‘)) == 0)
			redirect(site_url(‘login/index‘));
	}

    //前台加载视图方法
	public function _template($template, $data = http://www.mamicode.com/array()){"current">‘;
		$config[‘cur_tag_close‘] = ‘</span>‘;

		// $config[‘num_tag_open‘] = ‘<a>‘;
		// $config[‘num_tag_close‘] = ‘</a>‘;

		$this->pagination->initialize($config); 

		//return $this->pagination->create_links();
	}

	/**
	 * um 加载编辑器 百度
	 * @param  [string]  $info   [须要默认显示的内容]
	 * @param  integer $width  [宽度]
	 * @param  integer $height [调试]
	 * @return string[type]          [返回内容]
	 */
	public function um($info,$name="content",$width=800,$height=300)
	{
		$um = ‘‘;
		$um .= ‘<link href="http://www.mamicode.com/source/um/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">‘;
	    $um .= ‘<script type="text/javascript" src="http://www.mamicode.com/source/um/third-party/jquery.min.js"></script>‘;
	    $um .= ‘<script type="text/javascript" charset="utf-8" src="http://www.mamicode.com/source/um/umeditor.config.js"></script>‘;
	    $um .= ‘<script type="text/javascript" charset="utf-8" src="http://www.mamicode.com/source/um/umeditor.min.js"></script>‘;
	    $um .= ‘<script type="text/javascript" src="http://www.mamicode.com/source/um/lang/zh-cn/zh-cn.js"></script>‘;
		$um .= ‘<script type="text/plain" id="myEditor" name="‘.$name.‘" style="width:‘.$width.‘px;height:‘.$height.‘px;"><p>‘.$info.‘</p></script>‘;
		$um .= ‘<script type="text/javascript">var um = UM.getEditor("myEditor"); </script>‘;
		return $um;
	}

}




/**
 * @author [author] <[solon.ring2011@gmail.com]>
 * /admin/core/MY_Controller.php
 */



扩展Codeigniter控制器