本文整理汇总了PHP中Finder::find_file方法的典型用法代码示例。如果您正苦于以下问题:PHP Finder::find_file方法的具体用法?PHP Finder::find_file怎么用?PHP Finder::find_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Finder
的用法示例。
在下文中一共展示了Finder::find_file方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Loads a view as a string
* Used by Base_Controller->render() method to load a view
*
* @param string View name to load
* @param sring Directory where is the view
*
* @return string The load view
*
*/
public static function load($name, $directory = 'views')
{
$file = Finder::find_file($name, $directory, true);
if (empty($file)) {
show_error('Theme error : <b>The file "' . $directory . '/' . $name . '" cannot be found.</b>');
}
$string = file_get_contents(array_shift($file));
return $string;
}
示例2: load
/**
* Load a language file
* Modified to take the config->default_language in account
*
* @access public
* @param mixed the name of the language file to be loaded. Can be an array
* @param string the language (english, etc.)
* @return mixed
*/
function load($langfile = '', $idiom = '', $return = FALSE)
{
$CI =& get_instance();
// REMOVED EXT ON THE LINE BELOW, Martin Wernståhl
$langfile = str_replace(EXT, '', str_replace('_lang.', '', $langfile)) . '_lang';
if (in_array($langfile, $this->is_loaded, TRUE)) {
return;
}
if ($idiom == '') {
if (isset($CI->config)) {
$deft_lang = $CI->config->item('language_abbr');
$idiom = $deft_lang == '' ? 'en' : $deft_lang;
} else {
$idiom = 'english';
}
}
// find the files to load, allow extended lang files
$files = Finder::find_file($idiom . '/' . $langfile, 'language', 99);
if (empty($files)) {
// Try with the last defualt language...
$idiom = $CI->config->item('language');
$files = Finder::find_file($idiom . '/' . $langfile, 'language', 99);
/*
* Do not display the error, so the views can be loaded, even the content isn't translated
*
if(empty($files))
{
show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
}
*/
}
// reverse the array, so we let the extending language files load last
foreach (array_reverse($files) as $f) {
include $f;
}
// End addition
if (!isset($lang)) {
log_message('error', 'Language file contains no data: language/' . $idiom . '/' . $langfile);
return;
}
if ($return == TRUE) {
return $lang;
}
$this->is_loaded[] = $langfile;
$this->language = array_merge($this->language, $lang);
unset($lang);
log_message('debug', 'Language file loaded: language/' . $idiom . '/' . $langfile);
return TRUE;
}
示例3: load
/**
* Load a language file
* Modified to take the config->default_language in account
*
* @access public
* @param mixed the name of the language file to be loaded. Can be an array
* @param string the language (english, etc.)
* @param boolean value to return : FALSE by default
* @param String
* @param String
*
* @return mixed
*/
function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
{
$CI =& get_instance();
// Remove extension
$langfile = str_replace(EXT, '', str_replace('_lang.', '', $langfile)) . '_lang';
if (in_array($langfile, $this->is_loaded, TRUE)) {
return FALSE;
}
if ($idiom == '') {
if (isset($CI->config)) {
$deft_lang = $CI->config->item('detected_lang_code');
$idiom = $deft_lang == '' ? $CI->config->item('default_lang_code') : $deft_lang;
} else {
$idiom = 'english';
}
}
// find the files to load, allow extended lang files
$files = Finder::find_file($idiom . '/' . $langfile, 'language', 99);
/*
if(empty($files))
{
// Try with the last default language...
$idiom = $CI->config->item('language');
$files = Finder::find_file($idiom . '/' . $langfile, 'language', 99);
}
*/
// reverse the array, so we let the extending language files load last
foreach (array_reverse($files) as $f) {
include $f;
}
// End addition
if (!isset($lang)) {
log_message('error', 'Language file contains no data: language/' . $idiom . '/' . $langfile);
return FALSE;
}
if ($return == TRUE) {
return $lang;
}
$this->is_loaded[] = $langfile;
$this->language = array_merge($this->language, $lang);
unset($lang);
log_message('debug', 'Language file loaded: language/' . $idiom . '/' . $langfile);
return TRUE;
}
示例4: load_model
/**
* Loads a CI model
*
* @param String Model name to load
* @param String Logical model name
*
*/
protected static function load_model($model_name, $new_name = '')
{
$found = Finder::find_file($model_name, 'models');
if (!empty($found)) {
self::$ci->load->model($model_name, $new_name, TRUE);
}
// if (!isset(self::$ci->{$new_name})) self::$ci->load->model($model_name, $new_name, TRUE);
}
示例5: match_to_routes
/**
* Tries to match the segments to a route.
*
* @return array
*/
public function match_to_routes($segments)
{
// get the routes, reverse so we load the module's routes.php last - overwriting the others
$files = array_reverse(Finder::find_file('routes', 'config', false, true));
foreach ($files as $f) {
include $f;
// merge the route : module's route overwrite other routes
$this->routes = (!isset($route) or !is_array($route)) ? $this->routes : array_merge($this->routes, $route);
unset($route);
}
// we may have an empty route here, because the first segment could have been a module
if (empty($segments)) {
// $default = empty($routes['default_controller']) ? false : $routes['default_controller'];
$default = empty($this->routes['default_controller']) ? false : $this->routes['default_controller'];
if (!$default) {
show_error("Unable to determine what should be displayed. A default route has not been specified in the module '{$this->module}' routing file.");
}
$segments = explode('/', $default);
}
///////////////////////////////////////////
// FROM CodeIgniter, slightly modified by Martin Wernstahl
///////////////////////////////////////////
// Turn the segment array into a URI string
$uri = implode('/', $this->uri->segments);
// Is there a literal match? If so we're done
if (isset($this->routes[$uri])) {
return explode('/', $this->routes[$uri]);
}
// Loop through the route array looking for wild-cards
foreach ($this->routes as $key => $val) {
// Convert wild-cards to RegEx
$key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
// Does the RegEx match?
if (preg_match('#^' . $key . '$#', $uri)) {
// Do we have a back-reference?
if (strpos($val, '$') !== FALSE and strpos($key, '(') !== FALSE) {
$val = preg_replace('#^' . $key . '$#', $val, $uri);
}
return explode('/', $val);
}
}
return $this->uri->segments;
}
示例6: Plugin
/**
* Loads a plugin.
*
* @param string
* @return void
*/
function Plugin($plugin)
{
static $plugins = array();
$plugin = str_replace(EXT, '', str_replace('_pi', '', $plugin)) . '_pi';
if (in_array($plugin, $plugins)) {
return;
}
$files = Finder::find_file($plugin, 'plugins', 100);
if (empty($files)) {
show_error('Unable to load the requested file: plugins/' . $plugin . EXT);
}
foreach ($files as $f) {
include_once $f;
}
$plugins[] = $plugin;
log_message('debug', 'Plugin loaded: ' . $plugin);
}