I changed the ci loader function. could you help me?
<无详细内容>
- Protected function _ ci_load ($ _ ci_data ){
- // Set the default data variables
- Foreach (array ('_ ci_view', '_ ci_vars', '_ ci_path', '_ ci_return') as $ _ ci_val ){
- $ _ Ci_val = (! Isset ($ _ ci_data [$ _ ci_val])? FALSE: $ _ ci_data [$ _ ci_val];
- }
- $ File_exists = FALSE;
- $ _ Ci_ext = '.html ';
- // Set the path to the requested file
- If ($ _ ci_path! = ''){
- $ _ Ci_x = explode ('/', $ _ ci_path );
- $ _ Ci_file = end ($ _ ci_x). $ _ ci_ext;
- } Else {
- // Comment out the following line, because we can automatically load the view through routing.
- // $ _ Ci_ext = pathinfo ($ _ ci_view, PATHINFO_EXTENSION); // get the extension name of the view file. by default, the extension name is not passed.
- // Splice the View path
- // Load the configuration to conveniently obtain the value of the mca (m: Module, c: Controller, a: action)
- $ This-> config = & load_class ('config', 'core ');
- $ Directory_trigger = $ this-> config-> item ('directory _ trigger ');
- $ Controller_trigger = $ this-> config-> item ('Controller _ trigger ');
- $ Function_trigger = $ this-> config-> item ('function _ trigger ');
- // If the user does not configure pseudo-static data, use pathinfo
- $ Urlinfo = explode ('/', $ _ SERVER ['request _ URI ']);
- $ Urlinfo ['module'] = @ $ urlinfo [1]? $ Urlinfo [1]: 'home ';
- $ Urlinfo ['controller'] = @ $ urlinfo [2]? $ Urlinfo [2]: 'index ';
- $ Urlinfo ['action'] = @ $ urlinfo [3]? $ Urlinfo [3]: 'index ';
- $ M = isset ($ _ GET [$ directory_trigger]) & $ _ GET [$ directory_trigger]! = ''? $ _ GET [$ directory_trigger]: $ urlinfo ['module'];
- $ C = isset ($ _ GET [$ controller_trigger]) & $ _ GET [$ controller_trigger]! = ''? $ _ GET [$ controller_trigger]: $ urlinfo ['controller'];
- $ A = isset ($ _ GET [$ function_trigger]) & $ _ GET [$ function_trigger]! = ''? $ _ GET [$ function_trigger]: $ urlinfo ['action'];
- // Special handling of common/header (including public header/bottom)
- $ Slasharr = explode ('/', $ _ ci_view );
- If (count ($ slasharr)> 1 ){
- $ _ Ci_file = $ m. '/'. $ slasharr ['0']. '/'. $ slasharr ['1']. $ _ ci_ext;
- } Else {
- // Default View Name (excluding the extension name)
- $ View_name = $ _ ci_view = ''? $ A: $ _ ci_view; // if no View name is displayed, the action name is used by default.
- $ _ Ci_file = $ m. '/'. $ c. '/'. $ view_name. $ _ ci_ext;
- }
- Foreach ($ this-> _ ci_view_paths as $ view_file => $ cascade ){
- If (file_exists ($ view_file. $ _ ci_file )){
- $ _ Ci_path = $ view_file. $ _ ci_file;
- $ File_exists = TRUE;
- Break;
- }
- If (! $ Cascade ){
- Break;
- }
- }
- }
- If (! $ File_exists &&! File_exists ($ _ ci_path )){
- Show_error ('unable to load the requested file: '. $ _ ci_file );
- }
- // This allows anything loaded using $ this-> load (views, files, etc .)
- // To become accessible from within the Controller and Model functions.
- $ _ Ci_CI = & get_instance ();
- Foreach (get_object_vars ($ _ ci_CI) as $ _ ci_key = >$ _ ci_var ){
- If (! Isset ($ this-> $ _ ci_key )){
- $ This-> $ _ ci_key = & $ _ ci_CI-> $ _ ci_key;
- }
- }
- /*
- * Extract and cache variables
- *
- * You can either set variables using the dedicated $ this-> load_vars ()
- * Function or via the second parameter of this function. We'll merge
- * The two types and cache them so that views that are embedded
- * Other views can have access to these variables.
- */
- If (is_array ($ _ ci_vars )){
- $ This-> _ ci_cached_vars = array_merge ($ this-> _ ci_cached_vars, $ _ ci_vars );
- }
- Extract ($ this-> _ ci_cached_vars );
- /*
- * Buffer the output
- *
- * We buffer the output for two reasons:
- * 1. Speed. You get a significant speed boost.
- * 2. So that the final rendered template can be
- * Post-processed by the output class. Why do we
- * Need post processing? For one thing, in order
- * Show the elapsed page load time. Unless we
- * Can intercept the content right before it's sent
- * The browser and then stop the timer it won't be accurate.
- */
- Ob_start ();
- // If the PHP installation does not support short tags we'll
- // Do a little string replacement, changing the short tags
- // To standard PHP echo statements.
- If (bool) @ ini_get ('Short _ open_tag ') === false and config_item ('rewrite _ short_tags') = TRUE ){
- Echo eval ('?> '. Preg_replace ("/; * \ s * \?> /",";?> ", Str_replace (' } Else {
- Include ($ _ ci_path); // include () vs include_once () allows for multiple views with the same name
- }
- Log_message ('debug', 'File loaded: '. $ _ ci_path );
- // Return the file data if requested
- If ($ _ ci_return === TRUE ){
- $ Buffer = ob_get_contents ();
- @ Ob_end_clean ();
- Return $ buffer;
- }
- /*
- * Flush the buffer... or buff the flusher?
- *
- * In order to permit views to be nested
- * Other views, we need to flush the content back out whenever
- * We are beyond the first level of output buffering so that
- * It can be seen and attached Ded properly by the first encoded ded
- * Template and any subsequent ones. Oy!
- *
- */
- If (ob_get_level ()> $ this-> _ ci_ob_level + 1 ){
- Ob_end_flush ();
- } Else {
- $ _ Ci_CI-> output-> append_output (ob_get_contents ());
- @ Ob_end_clean ();
- }
- }
|