本文整理汇总了PHP中file::create_folder方法的典型用法代码示例。如果您正苦于以下问题:PHP file::create_folder方法的具体用法?PHP file::create_folder怎么用?PHP file::create_folder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file
的用法示例。
在下文中一共展示了file::create_folder方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: app_create_code
/**
* 生成应用的代码
*
*/
private function app_create_code($app_info)
{
import("@.ORG.file");
$file = new file();
//建立Action里的应用文件夹
$rs = $file->create_folder("/Lib/Action/", $app_info['name']);
if (!$rs) {
return false;
}
//创建默认模块的文件
$file->copy_file('/Lib/Action/', 'DemoAction.class.php', "/Lib/Action/{$app_info['name']}/", 'IndexAction.class.php');
$content = $file->read_file("/Lib/Action/{$app_info['name']}/IndexAction.class.php");
$content = str_replace('[应用名称]', $app_info['title'], $content);
$content = str_replace('[描述]', $app_info['remark'], $content);
$content = str_replace('[demo]', $_SESSION['nickname'], $content);
$content = str_replace('[日期]', date('Y-m-d'), $content);
$content = str_replace('[数据表名]', $app_info['table_name'], $content);
$content = str_replace('class DemoAction extends', "class IndexAction extends", $content);
$file->write_file("/Lib/Action/{$app_info['name']}/IndexAction.class.php", $content);
//创建Tpl下相应模块的文件夹和默认操作HTML文件
$rs = $file->create_folder("/Tpl/", $app_info['name']);
if (!$rs) {
return false;
}
$table_name = $this->_post('table_name') ? $this->_post('table_name') : '';
$this->create_html($app_info['name'], 'Index', 'index', 'index', $table_name);
$this->create_html($app_info['name'], 'Index', 'add', 'add', $table_name);
$this->create_html($app_info['name'], 'Index', 'edit', 'edit', $table_name);
$this->create_html($app_info['name'], 'Index', 'show', 'show', $table_name);
$this->create_html($app_info['name'], 'Index', 'export', 'export', $table_name);
return true;
}
示例2: create_action
/**
* 创建操作
*
* @param unknown_type $action_info
*/
private function create_action($action_info, $tpl, $app_name, $module_name, $table_name)
{
import("@.ORG.file");
$file = new file();
//创建Tpl下相应模块的文件夹和默认操作HTML文件
$file->create_folder("/Tpl/", $app_name);
$this->create_html($app_name, $module_name, $action_info['name'], $tpl, $table_name);
return true;
}
示例3: app_add
/**
* 添加应用,当添加一个应用时,在Lib目录下生成对应的文件夹,并且生成indexAction.class.php的基本类
*
*/
public function app_add()
{
if ($this->_post('act') == 'todo') {
//先检测此应用是否存在。
$rs = $this->node_check($this->_post('name'), $this->_post('pid'), $this->_post('level'));
if (!$rs) {
//在数据库中生成应用的节点信息
$db_node = D('node');
$app_info = $this->_post();
if (false === $db_node->create()) {
$this->error($db_node->getError());
}
$app_id = $db_node->add();
//建立Action里的应用文件夹
import("@.ORG.file");
$file = new file();
$app_folder = $file->create_folder("/Lib/Action/", $app_info['name']);
$param['title'] = $app_info['title'];
$param['role_id'] = '[1][2]';
$param['app'] = $app_info['name'];
$menu_id = $this->add_menu($param);
//系统管理员\企业管理层添加到一级菜单
$app_info['id'] = $app_id;
if (count($app_info['create_data'])) {
$table_name = $this->_post('table_name') ? $this->_post('table_name') : 'demo';
//在数据库中生成默认模块
$node_module_index['name'] = 'Index';
$node_module_index['title'] = $app_info['title'];
$node_module_index['status'] = 1;
$node_module_index['remark'] = $app_info['remark'];
$node_module_index['pid'] = $app_id;
$node_module_index['level'] = 2;
$node_module_index['id'] = $module_id = $db_node->data($node_module_index)->add();
if ($app_folder) {
$this->create_module_field($node_module_index, $table_name, $app_info['name']);
}
//在数据库中生成默认的5个操作,index,add,edit,show,export
$node_action['status'] = 1;
$node_action['pid'] = $module_id;
$node_action['level'] = 3;
//创建Tpl下相应模块的文件夹和默认操作HTML文件
$file->create_folder("/Tpl/", $app_info['name']);
foreach ($app_info['create_data'] as $val) {
switch ($val) {
case 'index':
//列表
$node_action['name'] = 'index';
$node_action['title'] = '数据列表';
$node_action['remark'] = '系统自动生成的默认操作列表';
$db_node->data($node_action)->add();
$this->create_html($app_info['name'], 'Index', 'index', 'index', $table_name);
//生成列表菜单
$url = U("{$app_info['name']}/{$node_module_index['name']}/{$node_action['name']}");
$param['title'] = '数据管理';
$param['role_id'] = '[1][2]';
$param['parent_id'] = $menu_id;
$param['position'] = 'menu';
$param['target'] = 'main-frame';
$param['url'] = $url;
$param['app'] = $app_info['name'];
$param['module'] = 'Index';
$menu_id = $this->add_menu($param);
break;
case 'add':
//添加
$node_action['name'] = 'add';
$node_action['title'] = '添加信息';
$node_action['remark'] = '系统自动生成的默认添加操作';
$db_node->data($node_action)->add();
$this->create_html($app_info['name'], 'Index', 'add', 'add', $table_name);
//生成添加信息菜单
$param['title'] = '添加信息';
$param['role_id'] = '[1][2]';
$param['parent_id'] = $menu_id;
$param['position'] = 'main';
$param['target'] = '_self';
$param['url'] = "javascript:dialog_add();";
$param['app'] = $app_info['name'];
$param['module'] = 'Index';
$this->add_menu($param);
break;
case 'edit':
//修改
$node_action['name'] = 'edit';
$node_action['title'] = '修改信息';
$node_action['remark'] = '系统自动生成的默认修改操作';
$db_node->data($node_action)->add();
$this->create_html($app_info['name'], 'Index', 'edit', 'edit', $table_name);
break;
case 'show':
//显示
$node_action['name'] = 'show';
$node_action['title'] = '显示信息';
$node_action['remark'] = '系统自动生成的默认添回操作';
$db_node->data($node_action)->add();
$this->create_html($app_info['name'], 'Index', 'show', 'show', $table_name);
//.........这里部分代码省略.........
示例4: import_sample
public function import_sample($ws = null)
{
global $DB;
global $website;
global $theme;
global $events;
if (is_null($ws)) {
$ws = $website;
}
if (!file_exists(NAVIGATE_PATH . '/themes/' . $this->name . '/' . $this->name . '_sample.zip')) {
throw new Exception(t(56, 'Unexpected error'));
}
$ptf = NAVIGATE_PRIVATE . '/tmp/' . $this->name . '_sample';
core_remove_folder($ptf);
// decompress the zip file
$extracted = false;
$zip = new ZipArchive();
if ($zip->open(NAVIGATE_PATH . '/themes/' . $this->name . '/' . $this->name . '_sample.zip') === TRUE) {
@mkdir($ptf, 0777, true);
$extracted = $zip->extractTo($ptf);
if (!$extracted) {
throw new Exception(t(56, 'Unexpected error'));
}
$zip->close();
}
// website languages (add website included languages)
if (file_exists($ptf . '/languages.var_export')) {
eval('$wlangs = ' . str_replace("stdClass::__set_state", "(object)", file_get_contents($ptf . '/languages.var_export')) . ';');
} else {
$wlangs = unserialize(file_get_contents($ptf . '/languages.serialized'));
}
if (!is_array($wlangs)) {
$wlangs = array();
}
foreach ($wlangs as $lcode => $loptions) {
if (!is_array($ws->languages) || !in_array($lcode, array_keys($ws->languages))) {
$ws->languages[$lcode] = $loptions;
}
}
// theme options
if (file_exists($ptf . '/theme_options.var_export')) {
eval('$toptions = ' . str_replace("stdClass::__set_state", "(object)", file_get_contents($ptf . '/theme_options.var_export')) . ';');
} else {
$toptions = unserialize(file_get_contents($ptf . '/theme_options.serialized'));
}
$ws->theme_options = $toptions;
$ws->save();
// folders (if available)
$theme_files_parent = file::create_folder($this->name, "folder/generic", 0, $ws->id);
$folders = array();
if (file_exists($ptf . '/folders.var_export')) {
// available since v2.1.2
eval('$folders_or = ' . str_replace("stdClass::__set_state", "(object)", file_get_contents($ptf . '/folders.var_export')) . ';');
}
if (!empty($folders_or)) {
// assume folders are defined in order (first the parents, then their children)
foreach ($folders_or as $f) {
// error protection
if (empty($f->id)) {
continue;
}
$folders[$f->id] = new file();
$folders[$f->id]->load_from_resultset(array($f));
$folders[$f->id]->id = 0;
$folders[$f->id]->website = $ws->id;
if (isset($folders[$f->parent])) {
$folders[$f->id]->parent = $folders[$f->parent]->id;
} else {
$folders[$f->id]->parent = $theme_files_parent;
}
$folders[$f->id]->insert();
}
}
// files
$files = array();
if (file_exists($ptf . '/files.var_export')) {
eval('$files_or = ' . str_replace("stdClass::__set_state", "(object)", file_get_contents($ptf . '/files.var_export')) . ';');
} else {
$files_or = unserialize(file_get_contents($ptf . '/files.serialized'));
}
foreach ($files_or as $f) {
// error protection
if (empty($f->id)) {
continue;
}
$files[$f->id] = new file();
$files[$f->id]->load_from_resultset(array($f));
$files[$f->id]->id = 0;
$files[$f->id]->website = $ws->id;
if (isset($folders[$f->parent])) {
$files[$f->id]->parent = $folders[$f->parent]->id;
} else {
$files[$f->id]->parent = $theme_files_parent;
}
$files[$f->id]->insert();
// finally copy the sample file
@copy($ptf . '/files/' . $f->id, NAVIGATE_PRIVATE . '/' . $ws->id . '/files/' . $files[$f->id]->id);
}
// structure
$structure = array();
//.........这里部分代码省略.........
示例5: create_app
/**
* 创建应用的各个文件
*/
private function create_app($app_info)
{
import("@.ORG.file");
$file = new file();
//建立Action里的应用文件夹
$file->create_folder("/Lib/Action/", $app_info['name']);
//创建Tpl下相应模块的文件夹和默认操作HTML文件
$file->create_folder("/Tpl/", $app_info['name']);
//在配置文件中要自动加入这个应用
$content = $file->read_file('/Conf/sys_app_group_list.php');
$content = str_replace('";', ",{$app_info['name']}\";", $content);
$file->write_file('/Conf/sys_app_group_list.php', $content, true);
return true;
}
示例6: run
function run()
{
global $user;
global $layout;
global $DB;
global $website;
$out = '';
$item = new file();
switch ($_REQUEST['act']) {
case 1:
// json retrieval & operations
// json retrieval & operations
case "json":
if ($_REQUEST['op'] == 'upload') {
$tmp_name = $_REQUEST['tmp_name'];
if ($tmp_name == "{{BASE64}}") {
$tmp_name = base64_encode($_REQUEST['name']);
}
$file = file::register_upload($tmp_name, $_REQUEST['name'], $_REQUEST['parent']);
if (!empty($file)) {
echo json_encode(array('id' => $file->id, 'name' => $file->name));
} else {
echo json_encode(false);
}
}
switch ($_REQUEST['op']) {
case 'create_folder':
file::create_folder($_REQUEST['name'], $_REQUEST['mime'], $_REQUEST['parent']);
echo json_encode(true);
break;
case 'edit_folder':
$f = new file();
$f->load(intval($_REQUEST['id']));
$f->name = $_REQUEST['name'];
$f->mime = $_REQUEST['mime'];
$ok = $f->save();
echo json_encode($ok);
break;
case 'edit_file':
$f = new file();
$f->load(intval($_REQUEST['id']));
$f->name = $_REQUEST['name'];
$ok = $f->save();
echo json_encode($ok);
break;
case 'duplicate_file':
//error_reporting(~0);
//ini_set('display_errors', 1);
$status = false;
$f = new file();
$f->load(intval($_REQUEST['id']));
$f->id = 0;
$f->insert();
if (!empty($f->id)) {
$done = copy(NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . intval($_REQUEST['id']), NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . $f->id);
$status = "true";
if (!$done) {
$f->delete();
$status = t(56, "Unexpected error");
}
}
echo $status;
break;
case 'move':
if (is_array($_REQUEST['item'])) {
$ok = true;
for ($i = 0; $i < count($_REQUEST['item']); $i++) {
unset($item);
$item = new file();
$item->load($_REQUEST['item'][$i]);
$item->parent = $_REQUEST['folder'];
$ok = $ok & $item->update();
}
echo json_encode($ok ? true : false);
} else {
$item->load($_REQUEST['item']);
$item->parent = $_REQUEST['folder'];
echo json_encode($item->update());
}
break;
case 'delete':
try {
$item->load($_REQUEST['id']);
$status = $item->delete();
echo json_encode($status);
} catch (Exception $e) {
echo $e->getMessage();
}
break;
case 'permissions':
$item->load($_REQUEST['id']);
if (!empty($_POST)) {
$item->access = intval($_POST['access']);
$item->permission = intval($_POST['permission']);
$item->enabled = intval($_POST['enabled']);
$item->groups = $_POST['groups'];
if ($item->access < 3) {
$item->groups = array();
}
$status = $item->save();
//.........这里部分代码省略.........