本文整理汇总了PHP中file::file_exists_i方法的典型用法代码示例。如果您正苦于以下问题:PHP file::file_exists_i方法的具体用法?PHP file::file_exists_i怎么用?PHP file::file_exists_i使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file
的用法示例。
在下文中一共展示了file::file_exists_i方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: meta_data
/**
* Load addon Information from readme.txt file
*
* @param string addon name
* @param string addon type
* @param array default meta data
* @return array
*/
public static function meta_data($addon, $type, $defaults = array())
{
$base = $type == 'plugin' ? PLUGINPATH : THEMEPATH;
// Determine if readme.txt (Case Insensitive) exists
$file = $base . $addon . "/readme.txt";
if (file::file_exists_i($file, $file)) {
$fp = fopen($file, 'r');
// Pull only the first 8kiB of the file in.
$file_data = fread($fp, 8192);
fclose($fp);
preg_match_all('/^(.*):(.*)$/mU', $file_data, $matches, PREG_PATTERN_ORDER);
$meta_data = array_combine(array_map('trim', $matches[1]), array_map('trim', $matches[2]));
foreach (array('png', 'gif', 'jpg', 'jpeg') as $ext) {
if (file_exists($base . $addon . "/screenshot.{$ext}")) {
$meta_data['Screenshot'] = "screenshot.{$ext}";
break;
}
}
return arr::merge($defaults, $meta_data);
}
return false;
}
示例2: index
public function index()
{
$this->template->content = new View('admin/addons/plugins');
$this->template->content->title = 'Addons';
if (isset($_GET['status']) && !empty($_GET['status'])) {
$status = $_GET['status'];
if (strtolower($status) == 'a') {
$filter = 'plugin_active = 1';
} elseif (strtolower($status) == 'i') {
$filter = 'plugin_active = 0';
} else {
$status = "0";
$filter = '1=1';
}
} else {
$status = "0";
$filter = '1=1';
}
// Add the hidden plugins to the list of plugins to filter out
if (count(Kohana::config('plugins.hide_from_list')) != 0) {
$hide_from_list = array_map('mysql_real_escape_string', Kohana::config('plugins.hide_from_list'));
$filter .= ' AND plugin_name NOT IN (\'' . implode("','", $hide_from_list) . '\')';
}
$db = new Database();
// Update the plugin list in the database
$d = dir(PLUGINPATH);
$directories = array();
while (($entry = $d->read()) !== FALSE) {
// Set the plugin to not enabled by default
// Don't include hidden folders
if ($entry[0] != '.') {
$directories[$entry] = FALSE;
}
}
// Sync the folder with the database
foreach ($directories as $dir => $found) {
// Only include the plugin if it contains readme.txt
$file = PLUGINPATH . $dir . "/readme.txt";
if (file::file_exists_i($file) and !count($db->from('plugin')->where('plugin_name', $dir)->limit(1)->get())) {
$plugin = ORM::factory('plugin');
$plugin->plugin_name = $dir;
$plugin->save();
}
}
// Remove Any Plugins not found in the plugins folder from the database
foreach (ORM::factory('plugin')->find_all() as $plugin) {
$file = PLUGINPATH . $plugin->plugin_name . "/readme.txt";
if (!array_key_exists($plugin->plugin_name, $directories) or !file::file_exists_i($file)) {
$plugin->delete();
}
}
// check, has the form been submitted?
$form_error = FALSE;
$form_saved = FALSE;
$form_action = "";
if ($_POST) {
$post = Validation::factory($_POST);
// Add some filters
$post->pre_filter('trim', TRUE);
// Add some rules, the input field, followed by a list of checks, carried out in order
$post->add_rules('action', 'required', 'alpha', 'length[1,1]');
$post->add_rules('comment_id.*', 'required', 'numeric');
if ($post->validate()) {
if ($post->action == 'a') {
// Activate Action
foreach ($post->plugin_id as $item) {
$plugin = ORM::factory('plugin', $item);
// Make sure we run the installer if it hasnt been installed yet.
// Then mark it as installed
if ($plugin->loaded and $plugin->plugin_name) {
Kohana::config_set('core.modules', array_merge(Kohana::config('core.modules'), array(PLUGINPATH . $plugin->plugin_name)));
// Name of the class (First letter of class should be capitalized)
$class = ucfirst($plugin->plugin_name) . '_Install';
// Find the Library File
$path = $this->_find_install($plugin->plugin_name);
if ($path) {
include $path;
// Run the installer
$install = new $class();
$install->run_install();
}
// Mark as Active and Mark as Installed
$plugin->plugin_active = 1;
$plugin->plugin_installed = 1;
$plugin->save();
}
}
} elseif ($post->action == 'i') {
// Deactivate Action
foreach ($post->plugin_id as $item) {
$plugin = ORM::factory('plugin', $item);
if ($plugin->loaded) {
$plugin->plugin_active = 0;
$plugin->save();
}
}
} elseif ($post->action == 'd') {
// Delete Action
foreach ($post->plugin_id as $item) {
$plugin = ORM::factory('plugin', $item);
//.........这里部分代码省略.........
示例3: settings
/**
* Discover Plugin Settings Controller
*
* @param string plugin name
* @return mixed Plugin settings page on success, FALSE otherwise
*/
public static function settings($plugin = NULL)
{
// Determine if readme.txt (Case Insensitive) exists
$file = PLUGINPATH . $plugin . "/controllers/admin/" . $plugin . "_settings.php";
if (file::file_exists_i($file)) {
return $plugin . "_settings";
} else {
return FALSE;
}
}
示例4: find_install
/**
* Find plugin install file
* Using this function because someone somewhere will name this file wrong!!!
* @param string $plugin
*/
public static function find_install($plugin, $type = 'plugin')
{
$base = $type == 'plugin' ? PLUGINPATH : THEMEPATH;
// Determine if readme.txt (Case Insensitive) exists
$file = $base . "{$plugin}/libraries/{$plugin}_install.php";
$real_path = null;
if (file::file_exists_i($file, $real_path)) {
return $real_path;
} else {
return FALSE;
}
}