<无详细内容>
- 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 {
- You can comment out the following line because we can already load the view automatically from the road
- $_ci_ext = PathInfo ($_ci_view, pathinfo_extension);//Gets the suffix name of the view file, by default it does not pass the suffix name
- Stitching View Path
- Load configuration for easy access to MCA (M: module, C: Controller, A:action) values
- $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, use the 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 common head/bottom)
- $slasharr = explode ('/', $_ci_view);
- if (count ($slasharr) > 1) {
- $_ci_file = $m. '/' . $slasharr [' 0 ']. ' /'. $slasharr [' 1 ']. $_ci_ext;
- } else {
- Default view name (does not include a suffix name)
- $view _name = $_ci_view = = "? $a: $_ci_view; If there is no name for the pass-through view, 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 types and cache them so, views of that is embedded within
- * Other views can has 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 both reasons:
- * 1. Speed. You get a significant speed boost.
- * 2. So, the final rendered template can be
- * Post-processed by the output class. Why do we
- * Need post processing? For one thing, in order to
- * Show the elapsed page load time. Unless we
- * Can intercept the content right before it's sent to
- * 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 nested within
- * Other views, we need to flush the content back out whenever
- * We are beyond the first level of output buffering so
- * It can seen and included properly by the first included
- * 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 ();
- }
- }
Copy Code |