CI 3.x my_loader

This commit is contained in:
Claude 2015-09-02 10:26:51 +02:00
parent 8ffabdb05e
commit ef682a2c8b

View File

@ -43,15 +43,21 @@ class MY_Loader extends CI_Loader
'_ci_return' => $return
));
}
// --------------------------------------------------------------------
/**
* Loader
* Internal CI Data Loader
*
* Used to load views and files.
*
* This function is used to load views and files.
* Variables are prefixed with _ci_ to avoid symbol collision with
* variables made available to view files
* variables made available to view files.
*
* @param array
* @return void
* @used-by CI_Loader::view()
* @used-by CI_Loader::file()
* @param array $_ci_data Data to load
* @return object
*/
protected
function _ci_load($_ci_data)
@ -65,13 +71,13 @@ class MY_Loader extends CI_Loader
'_ci_return'
) as $_ci_val)
{
$$_ci_val = (!isset($_ci_data[$_ci_val])) ? FALSE : $_ci_data[$_ci_val];
$$_ci_val = isset($_ci_data[$_ci_val]) ? $_ci_data[$_ci_val] : FALSE;
}
$file_exists = FALSE;
// Set the path to the requested file
if ($_ci_path != '')
if (is_string($_ci_path) && $_ci_path !== '')
{
$_ci_x = explode('/', $_ci_path);
$_ci_file = end($_ci_x);
@ -79,8 +85,8 @@ class MY_Loader extends CI_Loader
else
{
$_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION);
$_ci_file = ($_ci_ext == '') ? $_ci_view . '.php' : $_ci_view;
foreach ($this->_ci_view_paths as $view_file => $cascade)
$_ci_file = ($_ci_ext === '') ? $_ci_view . '.php' : $_ci_view;
foreach ($this->_ci_view_paths as $_ci_view_file => $cascade)
{
/* *** modification for stikked themes ***
@ -127,7 +133,7 @@ class MY_Loader extends CI_Loader
/*
* Extract and cache variables
*
* You can either set variables using the dedicated $this->load_vars()
* 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 within
* other views can have access to these variables.
@ -144,12 +150,11 @@ class MY_Loader extends CI_Loader
*
* 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 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.
* 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 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();
@ -159,9 +164,9 @@ class MY_Loader extends CI_Loader
// to standard PHP echo statements.
if ((bool)@ini_get('short_open_tag') === FALSE AND config_item('rewrite_short_tags') == TRUE)
if (!is_php('5.4') && !ini_get('short_open_tag') && config_item('rewrite_short_tags') === TRUE)
{
echo eval('?>' . preg_replace("/;*\s*\?>/", "; ?>", str_replace('<?=', '<?php echo ', file_get_contents($_ci_path))));
echo eval('?>' . preg_replace('/;*\s*\?>/', '; ?>', str_replace('<?=', '<?php echo ', file_get_contents($_ci_path))));
}
else
{
@ -169,7 +174,7 @@ class MY_Loader extends CI_Loader
}
log_message('debug', 'File loaded: ' . $_ci_path);
log_message('info', 'File loaded: ' . $_ci_path);
// Return the file data if requested
@ -188,7 +193,6 @@ class MY_Loader extends CI_Loader
* we are beyond the first level of output buffering so that
* it can be seen and included properly by the first included
* template and any subsequent ones. Oy!
*
*/
if (ob_get_level() > $this->_ci_ob_level + 1)
@ -200,5 +204,6 @@ class MY_Loader extends CI_Loader
$_ci_CI->output->append_output(ob_get_contents());
@ob_end_clean();
}
return $this;
}
}