本文整理汇总了PHP中path::decode方法的典型用法代码示例。如果您正苦于以下问题:PHP path::decode方法的具体用法?PHP path::decode怎么用?PHP path::decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类path
的用法示例。
在下文中一共展示了path::decode方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* 删除文件夹
*/
public static function delete($path, $deleteSelf = true)
{
$path = path::decode($path);
// 判断是否是文件夹
if (!is_dir($path)) {
return false;
}
// 删除文件夹下的全部文件
$files = folder::files($path, false, true, '', array());
if (count($files)) {
if (file::delete($files) !== true) {
return false;
}
}
// 删除全部子文件夹
$folders = folder::folders($path, false, true, '.', array());
foreach ($folders as $folder) {
if (folder::delete($folder) !== true) {
return false;
}
}
//删除自身,如果不删除自身,则为清理文件夹
if ($deleteSelf === true) {
if (@rmdir($path)) {
return true;
}
return false;
}
return true;
}
示例2: install
public function install($path = '')
{
$path = empty($path) ? $this->path : $path;
$module = @(include path::decode($path . DS . 'module.php'));
if (is_array($module)) {
$module['path'] = $path;
$module['url'] = $path;
if (!isset($module['icon'])) {
if (file::exists($path . '/icon.png')) {
$module['icon'] = $module['url'] . '/icon.png';
}
}
$module['type'] = empty($module['type']) ? 'plugin' : $module['type'];
$module['status'] = 0;
$module['order'] = $this->max('order') + 1;
$module['installtime'] = TIME;
$module['updatetime'] = TIME;
$insert = $this->insert($module);
}
if ($insert) {
$driver = $this->db()->config('driver');
$sqls = file::read($path . DS . 'install' . DS . $driver . '.sql');
if ($sqls) {
$this->db()->run($sqls);
}
}
return true;
}
示例3: hooks
/**
* 打包全部的hook文件
*
*/
public static function hooks()
{
$modules = zotop::data('module');
foreach ((array) $modules as $module) {
if ((int) $module['status'] >= 0 && folder::exists($module['path'])) {
//加载hook文件
runtime::$hooks[] = $module['path'] . DS . 'hooks' . DS . ZOTOP_APPLICATION_GROUP . '.php';
//加载库文件
zotop::register(@(include path::decode($module['path']) . DS . 'classes.php'));
}
}
}
示例4: hook
public static function hook()
{
//打包全部hook
$hooks = array();
$modules = zotop::data('module');
foreach ($modules as $module) {
$path = $module['path'] . DS . 'hook';
$path = path::decode($path);
$hook = (array) dir::files($path, '', true, true);
$hooks = array_merge($hooks, $hook);
}
$content = runtime::compile($hooks);
if (!empty($content)) {
file::write(ZPATH_RUNTIME . DS . 'hook.php', $content, true);
}
}
示例5: actionInstall
public function actionInstall($path)
{
$module = zotop::model('zotop.module');
if (form::isPostBack()) {
$install = $module->install($path);
if ($install) {
$module->cache(true);
msg::success(zotop::t('模块安装成功'), zotop::url('zotop/module'));
}
}
$moduleFile = $path . DS . 'module.php';
if (!file::exists($moduleFile)) {
msg::error(array('content' => zotop::t('未找到模块标记文件<b>module.php</b>,请检查?')));
}
$m = @(include path::decode($moduleFile));
$id = $m['id'];
$modules = $module->getUnInstalled();
$page = new dialog();
$page->set('title', '安装模块');
$page->set('module', $modules[$id]);
$page->display();
}
示例6: module
/**
* 模块的配置获取
*
* @param string|array $id 应用的ID,如:admin
* @param string $key 键名称,如:name
* @return mix
*/
public function module($id = '', $key = '')
{
static $modules = array();
//fetch config
if (empty($modules)) {
$modules = zotop::config('zotop.module');
}
//fetch default config
if (empty($modules)) {
$modules = (include ZPATH_CONFIG . DS . 'module.php');
//set config
zotop::config('zotop.module', $modules);
}
if (is_array($modules)) {
foreach ($modules as $k => $m) {
$modules[$k]['path'] = path::decode($modules[$k]['path']);
$modules[$k]['url'] = url::decode($modules[$k]['url']);
}
}
//return modules
if (empty($id)) {
return $modules;
}
//set and return modules
if (is_array($id)) {
$modules = array_merge($modules, $id);
zotop::config('zotop.module', $modules);
return $modules;
}
//return module
if (is_string($id)) {
$module = array();
if (isset($modules[strtolower($id)])) {
$module = $modules[strtolower($id)];
}
if (empty($key)) {
return $module;
}
return $module[strtolower($key)];
}
}
示例7: module
/**
* 模块的配置获取
*
* @param string|array $id 应用的ID,如:admin
* @param string $key 键名称,如:name
* @return mix
*/
public function module($id = '', $key = '')
{
static $modules = array();
//fetch config
if (empty($modules)) {
$modules = zotop::config('zotop.module');
}
//fetch default config
if (empty($modules)) {
$modules = (include ZOTOP_CONFIG . DS . 'module.php');
//set config
zotop::config('zotop.module', $modules);
}
//return modules
if (empty($id)) {
return $modules;
}
//set and return modules
if (is_array($id)) {
$modules = array_merge($modules, $id);
zotop::config('zotop.module', $modules);
return $modules;
}
//return module
$module = array();
if (isset($modules[strtolower($id)])) {
$module = $modules[strtolower($id)];
}
if (empty($module['path'])) {
$module['path'] = $module['id'];
}
if ($module['path'][0] !== '%') {
$module['path'] = '%modules%' . DS . $module['path'];
}
$module['path'] = path::decode($module['path']);
if (empty($key)) {
return $module;
}
return $module[strtolower($key)];
}
示例8: rename
/**
* 文件重命名
*
* @param string $file 文件路径
* @param string $newname 新文件名称,含文件扩展名
*
* @return bool
* @since 0.1
*/
public static function rename($file, $newname)
{
$file = path::decode($file);
$path = dirname($file);
$newfile = $path . DS . file::safename($newname);
if ($file == $newfile) {
zotop::error(zotop::t('目标文件名称和原文件名称相同'));
return false;
} elseif (file::exists($newfile)) {
zotop::error(zotop::t('目标文件已经存在'));
return false;
} elseif (rename($file, $newfile)) {
return true;
}
return false;
}
示例9: module
/**
* 模块的配置获取
*
* @param string|array $id 应用的ID,如:admin
* @param string $key 键名称,如:name
* @return mix
*/
public function module($id = '', $key = '')
{
static $modules = array();
if (empty($modules)) {
$modules = (array) zotop::config('zotop.module');
}
if (is_array($modules)) {
$modules += array('zotop' => array('id' => 'zotop', 'title' => 'zotop', 'path' => '$modules/zotop', 'url' => '$modules/zotop', 'status' => 1), 'system' => array('id' => 'system', 'title' => 'system', 'path' => '$modules/system', 'url' => '$modules/system', 'status' => 1));
foreach ($modules as $k => $m) {
$modules[$k]['path'] = path::decode($modules[$k]['path']);
$modules[$k]['url'] = url::decode($modules[$k]['url']);
}
}
if (empty($id)) {
return $modules;
}
if (is_array($id)) {
$modules = array_merge($modules, $id);
zotop::config('zotop.module', $modules);
return $modules;
}
//return module
if (is_string($id)) {
$module = array();
if (isset($modules[strtolower($id)])) {
$module = $modules[strtolower($id)];
} else {
return null;
}
if (empty($key)) {
return $module;
}
return $module[strtolower($key)];
}
}
示例10: read
/**
* 读取文件内容
*
* @param string $file
* @return string
*/
public static function read($file)
{
$file = path::decode($file);
return @file_get_contents($file);
}
示例11: delete
/**
* 删除文件
* @param string $file
* @return boolean
*/
public static function delete($file)
{
$file = path::decode($file);
return @unlink($file);
}
示例12: reboot
/**
* 应用程序重启
*
*
* @return null
*/
public static function reboot()
{
//清理运行时文件
folder::clear(ZOTOP_PATH_RUNTIME);
//加载全部配置
zotop::config(@(include ZOTOP_PATH_DATA . DS . 'config.php'));
zotop::config('zotop.database', @(include ZOTOP_PATH_DATA . DS . 'database.php'));
zotop::config('zotop.application', @(include ZOTOP_PATH_DATA . DS . 'application.php'));
zotop::config('zotop.module', @(include ZOTOP_PATH_DATA . DS . 'module.php'));
zotop::config('zotop.router', @(include ZOTOP_PATH_DATA . DS . 'router.php'));
zotop::register(@(include ZOTOP_PATH_MODULES . DS . 'system' . DS . 'libraries.php'));
zotop::register(@(include ZOTOP_PATH_APPLICATION . DS . 'libraries.php'));
//加载全部开启模块的hook以及注册类文件
$modules = zotop::config('zotop.module');
foreach ((array) $modules as $module) {
if ((int) $module['status'] >= 0 && folder::exists($module['path'])) {
//加载库文件
zotop::register(@(include path::decode($module['path']) . DS . 'libraries.php'));
//加载hook文件
application::$hooks[] = $module['path'] . DS . 'hooks' . DS . ZOTOP_APPLICATION . '.php';
}
}
//打包配置文件
zotop::data(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.config.php', zotop::config());
//打包hook文件
file::write(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.hooks.php', application::compile(application::$hooks), true);
//加载hooks以便核心文件使用
zotop::load(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.hooks.php');
//打包类文件
file::write(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.core.php', application::compile(zotop::register()), true);
}
示例13: delete
/**
* 删除文件夹
*/
public static function delete($dir, $subfolder = true)
{
$dir = path::decode($dir);
}