I changed the ci loader function. could you help me?

Source: Internet
Author: User
I changed the ci loader function. could you help me?
<无详细内容>

  1. Protected function _ ci_load ($ _ ci_data ){
  2. // Set the default data variables
  3. Foreach (array ('_ ci_view', '_ ci_vars', '_ ci_path', '_ ci_return') as $ _ ci_val ){
  4. $ _ Ci_val = (! Isset ($ _ ci_data [$ _ ci_val])? FALSE: $ _ ci_data [$ _ ci_val];
  5. }
  6. $ File_exists = FALSE;
  7. $ _ Ci_ext = '.html ';
  8. // Set the path to the requested file
  9. If ($ _ ci_path! = ''){
  10. $ _ Ci_x = explode ('/', $ _ ci_path );
  11. $ _ Ci_file = end ($ _ ci_x). $ _ ci_ext;
  12. } Else {
  13. // Comment out the following line, because we can automatically load the view through routing.
  14. // $ _ Ci_ext = pathinfo ($ _ ci_view, PATHINFO_EXTENSION); // get the extension name of the view file. by default, the extension name is not passed.
  15. // Splice the View path
  16. // Load the configuration to conveniently obtain the value of the mca (m: Module, c: Controller, a: action)
  17. $ This-> config = & load_class ('config', 'core ');
  18. $ Directory_trigger = $ this-> config-> item ('directory _ trigger ');
  19. $ Controller_trigger = $ this-> config-> item ('Controller _ trigger ');
  20. $ Function_trigger = $ this-> config-> item ('function _ trigger ');
  21. // If the user does not configure pseudo-static data, use pathinfo
  22. $ Urlinfo = explode ('/', $ _ SERVER ['request _ URI ']);
  23. $ Urlinfo ['module'] = @ $ urlinfo [1]? $ Urlinfo [1]: 'home ';
  24. $ Urlinfo ['controller'] = @ $ urlinfo [2]? $ Urlinfo [2]: 'index ';
  25. $ Urlinfo ['action'] = @ $ urlinfo [3]? $ Urlinfo [3]: 'index ';
  26. $ M = isset ($ _ GET [$ directory_trigger]) & $ _ GET [$ directory_trigger]! = ''? $ _ GET [$ directory_trigger]: $ urlinfo ['module'];
  27. $ C = isset ($ _ GET [$ controller_trigger]) & $ _ GET [$ controller_trigger]! = ''? $ _ GET [$ controller_trigger]: $ urlinfo ['controller'];
  28. $ A = isset ($ _ GET [$ function_trigger]) & $ _ GET [$ function_trigger]! = ''? $ _ GET [$ function_trigger]: $ urlinfo ['action'];
  29. // Special handling of common/header (including public header/bottom)
  30. $ Slasharr = explode ('/', $ _ ci_view );
  31. If (count ($ slasharr)> 1 ){
  32. $ _ Ci_file = $ m. '/'. $ slasharr ['0']. '/'. $ slasharr ['1']. $ _ ci_ext;
  33. } Else {
  34. // Default View Name (excluding the extension name)
  35. $ View_name = $ _ ci_view = ''? $ A: $ _ ci_view; // if no View name is displayed, the action name is used by default.
  36. $ _ Ci_file = $ m. '/'. $ c. '/'. $ view_name. $ _ ci_ext;
  37. }
  38. Foreach ($ this-> _ ci_view_paths as $ view_file => $ cascade ){
  39. If (file_exists ($ view_file. $ _ ci_file )){
  40. $ _ Ci_path = $ view_file. $ _ ci_file;
  41. $ File_exists = TRUE;
  42. Break;
  43. }
  44. If (! $ Cascade ){
  45. Break;
  46. }
  47. }
  48. }
  49. If (! $ File_exists &&! File_exists ($ _ ci_path )){
  50. Show_error ('unable to load the requested file: '. $ _ ci_file );
  51. }
  52. // This allows anything loaded using $ this-> load (views, files, etc .)
  53. // To become accessible from within the Controller and Model functions.
  54. $ _ Ci_CI = & get_instance ();
  55. Foreach (get_object_vars ($ _ ci_CI) as $ _ ci_key = >$ _ ci_var ){
  56. If (! Isset ($ this-> $ _ ci_key )){
  57. $ This-> $ _ ci_key = & $ _ ci_CI-> $ _ ci_key;
  58. }
  59. }
  60. /*
  61. * Extract and cache variables
  62. *
  63. * You can either set variables using the dedicated $ this-> load_vars ()
  64. * Function or via the second parameter of this function. We'll merge
  65. * The two types and cache them so that views that are embedded
  66. * Other views can have access to these variables.
  67. */
  68. If (is_array ($ _ ci_vars )){
  69. $ This-> _ ci_cached_vars = array_merge ($ this-> _ ci_cached_vars, $ _ ci_vars );
  70. }
  71. Extract ($ this-> _ ci_cached_vars );
  72. /*
  73. * Buffer the output
  74. *
  75. * We buffer the output for two reasons:
  76. * 1. Speed. You get a significant speed boost.
  77. * 2. So that the final rendered template can be
  78. * Post-processed by the output class. Why do we
  79. * Need post processing? For one thing, in order
  80. * Show the elapsed page load time. Unless we
  81. * Can intercept the content right before it's sent
  82. * The browser and then stop the timer it won't be accurate.
  83. */
  84. Ob_start ();
  85. // If the PHP installation does not support short tags we'll
  86. // Do a little string replacement, changing the short tags
  87. // To standard PHP echo statements.
  88. If (bool) @ ini_get ('Short _ open_tag ') === false and config_item ('rewrite _ short_tags') = TRUE ){
  89. Echo eval ('?> '. Preg_replace ("/; * \ s * \?> /",";?> ", Str_replace (' } Else {
  90. Include ($ _ ci_path); // include () vs include_once () allows for multiple views with the same name
  91. }
  92. Log_message ('debug', 'File loaded: '. $ _ ci_path );
  93. // Return the file data if requested
  94. If ($ _ ci_return === TRUE ){
  95. $ Buffer = ob_get_contents ();
  96. @ Ob_end_clean ();
  97. Return $ buffer;
  98. }
  99. /*
  100. * Flush the buffer... or buff the flusher?
  101. *
  102. * In order to permit views to be nested
  103. * Other views, we need to flush the content back out whenever
  104. * We are beyond the first level of output buffering so that
  105. * It can be seen and attached Ded properly by the first encoded ded
  106. * Template and any subsequent ones. Oy!
  107. *
  108. */
  109. If (ob_get_level ()> $ this-> _ ci_ob_level + 1 ){
  110. Ob_end_flush ();
  111. } Else {
  112. $ _ Ci_CI-> output-> append_output (ob_get_contents ());
  113. @ Ob_end_clean ();
  114. }
  115. }

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.