CI Framework extension System core class method analysis, CI framework _php Tutorial

Source: Internet
Author: User
Tags codeigniter zend framework

CI Framework extension System core class method analysis, CI framework


This paper describes the method of CI framework extending system core class. Share to everyone for your reference, as follows:

First of all, your system extension class is placed under Application/core, the system core class is Ci_controller, so you can not start with ci_, you need to open application/config/config.php modify:

$config [' subclass_prefix '] = ' my_ ';

The prefix for you!

Some common modules can unload their own core class inside!

These days read the DILICMS (Lightweight backend architecture), such as his background extension class:

<?php if (! defined (' BasePath ')) exit (' No Direct script access allowed '); abstract class Admin_controller extends Ci_co  ntroller{/** * _admin * Save current logged on user's information * * @var Object * @access public **/public $_admin = NULL;    /** * Constructor * * @access public * @return void */Public function __construct () {parent::__construct ();    $this->load->library (' Session ');    $this->settings->load (' backend ');    $this->load->switch_theme (Setting (' Backend_theme '));    $this->_check_login ();    $this->load->library (' ACL ');  $this->load->library (' Plugin_manager '); /** * Check if the user is logged in * * @access protected * @return void */protected function _check_login () {if (! $this->se Ssion->userdata (' uid ')) {redirect (' Setting (' Backend_access_point ').    '/login '); } else {$this->_admin = $this->user_mdl->get_full_user_by_username ($this->session->userdata (' UI      d '), ' uid '); if ($this->_admin->status! = 1)     {$this->session->set_flashdata (' Error ', "This account has been frozen, please contact the Administrator!"); Redirect (setting (' Backend_access_point ').      '/login '); }}}/** * Load View * * @access protected * @param string * @param array * @return void */protected function _te    Mplate ($template, $data = Array ()) {$data [' tpl '] = $template;  $this->load->view (' Sys_entry ', $data);  }/** * Check permissions * * @access protected * @param string * @return void */protected function _check_permit ($action = ", $folder = ') {if (! $this->acl->permit ($action, $folder)) {$this->_message (' Sorry, you don't have permission to access here!    ', ', FALSE); }}/** * information hint * * @access public * @param String * @param string * @param bool * @param string * @return void * /Public Function _message ($msg, $goto = ', $auto = TRUE, $fix = ') {if ($goto = = ') {$goto = Isset ($_ser ver[' Http_referer ')?    $_server[' Http_referer ': Site_url (); } else {$goto = Strpos ($goto, ' http ')!= = False?      $goto: Backend_url ($goto);    } $goto. = $fix;    $this->_template (' Sys_message ', Array (' msg ' = = $msg, ' goto ' + $goto, ' auto ' = $auto));    echo $this->output->get_output ();  Exit (); }}

It put some public information into the verification, landing, jump in the admin_controller inside, so I write the foreground is also the same operation, extended the Font_controller:

Abstract class Font_controller extends ci_controller{public function __construct () {  parent::__construct ();}// Foreground load View method public function _template ($template, $data = Array ()) {  $data [' nav '] = $this->get_nav ();  $data [' tpl '] = $template;  $this->load->view (' Default ', $data); }//Common navigation information public Function Get_nav () {}//Common link information public function Get_friendlink () {}}

Tips, some often used tools and functions can be placed in the helper!

More interested in CodeIgniter related content readers can view this site topic: "CodeIgniter Introductory Tutorial", "CI (codeigniter) Framework Advanced Tutorial", "PHP Excellent Development Framework Summary", "thinkphp Getting Started", " Summary of common methods of thinkphp, "Introduction to Zend Framework Frame", "Introduction to PHP Object-oriented Programming", "Introduction to Php+mysql Database Operation" and "PHP common database Operation Skills Summary"

It is hoped that this article is helpful to the PHP program design based on CodeIgniter framework.

http://www.bkjia.com/PHPjc/1133108.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133108.html techarticle CI Framework extension System core class method analysis, CI framework This paper describes the CI Framework extension system core class method. Share to everyone for your reference, as follows: First you system ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.