I changed the loader function of CI to the big God to help me see?

Source: Internet
Author: User
<无详细内容>
  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. You can comment out the following line because we can already load the view automatically from the road
  14. $_ci_ext = PathInfo ($_ci_view, pathinfo_extension);//Gets the suffix name of the view file, by default it does not pass the suffix name
  15. Stitching View Path
  16. Load configuration for easy access to MCA (M: module, C: Controller, A:action) values
  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, use the 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 common head/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 (does not include a suffix name)
  35. $view _name = $_ci_view = = "? $a: $_ci_view; If there is no name for the pass-through view, 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 types and cache them so, views of that is embedded within
  66. * Other views can has 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 both reasons:
  76. * 1. Speed. You get a significant speed boost.
  77. * 2. So, 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 to
  80. * Show the elapsed page load time. Unless we
  81. * Can intercept the content right before it's sent to
  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 nested within
  103. * Other views, we need to flush the content back out whenever
  104. * We are beyond the first level of output buffering so
  105. * It can seen and included properly by the first included
  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. }
Copy Code
  • 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.