當前位置: 首頁>>代碼示例>>PHP>>正文


PHP file::create_folder方法代碼示例

本文整理匯總了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;
 }
開發者ID:uwitec,項目名稱:p-oa,代碼行數:36,代碼來源:NodeAction.class.php

示例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;
 }
開發者ID:uwitec,項目名稱:p-oa,代碼行數:14,代碼來源:ActionAction.class.php

示例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);
//.........這裏部分代碼省略.........
開發者ID:uwitec,項目名稱:p-oa,代碼行數:101,代碼來源:IndexAction.class.php

示例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();
//.........這裏部分代碼省略.........
開發者ID:NavigateCMS,項目名稱:Navigate-CMS,代碼行數:101,代碼來源:theme.class.php

示例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;
 }
開發者ID:uwitec,項目名稱:p-oa,代碼行數:17,代碼來源:AppAction.class.php

示例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();
//.........這裏部分代碼省略.........
開發者ID:NavigateCMS,項目名稱:Navigate-CMS,代碼行數:101,代碼來源:files.php


注:本文中的file::create_folder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。