当前位置: 首页>>代码示例>>PHP>>正文


PHP file::read_file方法代码示例

本文整理汇总了PHP中file::read_file方法的典型用法代码示例。如果您正苦于以下问题:PHP file::read_file方法的具体用法?PHP file::read_file怎么用?PHP file::read_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在file的用法示例。


在下文中一共展示了file::read_file方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create_module

 /**
  * 创建模块
  *
  * @param unknown_type $module_info
  */
 private function create_module($module_info, $table_name = 'demo', $app_name = '')
 {
     import("@.ORG.file");
     $file = new file();
     if ($app_name == '') {
         $db_node = M('node');
         $app_name = $db_node->where("id='{$module_info['pid']}'")->getField('name');
     }
     //创建模块的文件
     $content = $file->read_file("/Lib/Action/DemoAction.class.php");
     $content = str_replace('[应用名称]', $module_info['title'], $content);
     $content = str_replace('[描述]', $module_info['remark'], $content);
     $content = str_replace('[demo]', $_SESSION['nickname'], $content);
     $content = str_replace('[日期]', date('Y-m-d'), $content);
     $content = str_replace('[数据表名]', $table_name, $content);
     $content = str_replace('class DemoAction extends', "class {$module_info['name']}Action extends", $content);
     $file->write_file("/Lib/Action/{$app_name}/{$module_info['name']}Action.class.php", $content);
     return $module_info;
 }
开发者ID:uwitec,项目名称:p-oa,代码行数:24,代码来源:ModuleAction.class.php

示例2: action_create_code

    /**
     * 生成操作节点为的代码,要在“/Tpl/应用/”中生成“模块-index.html、模块-add.html、模块-edit.html”
     *
     * @param unknown_type $node_info
     */
    private function action_create_code($action_info, $table_name, $demo_type = 'index')
    {
        //找出模块
        $db_node = M('node');
        $module_info = $db_node->where("id='{$action_info['pid']}'")->find();
        //找出应用
        $app_info = $db_node->where("id='{$module_info['pid']}'")->find();
        $lib_file = "/Lib/Action/{$app_info['name']}/{$module_info['name']}Action.class.php";
        if (!file_exists($_SERVER['DOCUMENT_ROOT'] . $lib_file)) {
            echo '不存在此模块';
            return false;
        }
        import("@.ORG.file");
        $file = new file();
        $content = $file->read_file($lib_file);
        //删除代码的最后一个字符,然后连接在一起
        $content = substr($content, 0, -1);
        $date = date('Y-m-d');
        $function = <<<EOF
    /**
     * {$action_info['title']}
     * {$action_info['remark']}
     * @author {$_SESSION['loginUserName']}
     * @date  {$date}
     */
    public function {$action_info['name']}(){
    
    }
}
EOF;
        $content = $content . $function;
        $rs = $file->write_file($lib_file, $content);
        if (!$rs) {
            return false;
        }
        //HTML文件写入
        $table_name = $table_name ? $table_name : $module_info['name'];
        $this->create_html($app_info['name'], $module_info['name'], $action_info['name'], $demo_type, $table_name);
        return true;
    }
开发者ID:uwitec,项目名称:p-oa,代码行数:45,代码来源:NodeAction.class.php

示例3: create_html

    /**
     * 创建代码
     *
     */
    private function create_html($app_name, $module_name, $action_name, $demo_type, $table_name)
    {
        import("@.ORG.file");
        $file = new file();
        $db_field = M('field');
        $field_list = $db_field->where("table_name='{$table_name}'")->order('listorder ASC ,id ASC')->select();
        $content = $file->read_file("/Tpl/Public/Demo-{$demo_type}.html");
        switch ($demo_type) {
            case 'index':
                $textarea_height = 0;
                foreach ($field_list as $val) {
                    $name_th .= '<th><a href="?_order=' . $val['field'] . '&_sort={$sort}">' . $val['name'] . '</a><if condition="$order eq \'' . $val['field'] . '\'"><img src="__PUBLIC__/images/{$sortImg}.gif" width="9px" height="9px" alt="{$sortAlt}" /></if></th>';
                    $field_td .= '<td>{$info[' . $val['field'] . ']}</td>';
                    if ($val['formtype'] == 'textarea') {
                        //当是多行文本时要增加多2行的高度
                        $textarea_height = $textarea_height + 40;
                    }
                    if ($val['issearch']) {
                        switch ($val['formtype']) {
                            case 'select':
                            case 'radio':
                            case 'checkbox':
                                eval('$setting=' . $val['setting'] . ';');
                                $search_form .= "<select name='{$val['field']}'><option value='-1'>请选择{$val['name']}</option>";
                                foreach ($setting as $v) {
                                    $search_form .= "<option value='{$v['value']}' <if condition=\"\$_REQUEST['{$val['field']}'] eq '{$v['value']}'\">selected=\"selected\"</if>\">{$v['name']}</option>\n";
                                }
                                $search_form .= "</select>\n";
                                break;
                            default:
                                $search_form .= "{$val['name']}:<input name='{$val['field']}' type='text' value='{\$Think.request.{$val['field']}}' />\n";
                                break;
                        }
                    }
                }
                if ($search_form) {
                    $search_form = '<div class="form-div">
					  <form name="searchForm" action="">
					    <img width="26" height="22" border="0" alt="SEARCH" src="__PUBLIC__/images/icon_search.gif">
					    ' . $search_form . '
					    <input type="submit" class="button" value=" 搜索 ">
					  </form>
					</div>';
                }
                $field_num = count($field_list);
                //计算出话框的宽和高
                $column_num = $field_num < 12 ? 2 : ($field_num % 3 == 0 ? 3 : 4);
                //可以根据字段的数量来决定有多少列
                $row_num = ceil($field_num / $column_num);
                $dialog_width = 120 * $column_num * 2;
                //因为每一个字段要占2列数据界面
                $dialog_height = 100 + 25 * $row_num + $textarea_height;
                //设置添加、修改的对话框URL参数,只要同一个list的action的curd操作都是和list的前缀一样时有效
                if (strstr($action_name, 'list')) {
                    $action_pre = str_replace('list', '', $action_name);
                } else {
                    $action_pre = '';
                }
                $select = array('[¥name]', '[¥field]', '[¥search]', '[¥dialog_width]', '[¥dialog_height]', '[¥action_pre]');
                $content = str_replace($select, array($name_th, $field_td, $search_form, $dialog_width, $dialog_height, $action_pre), $content);
                $file->write_file("/Tpl/{$app_name}/{$module_name}-{$action_name}.html", $content);
            case 'export':
                foreach ($field_list as $val) {
                    $name_th .= ',' . $val['name'];
                    $field_td .= ',{$info[' . $val['field'] . ']}';
                }
                $select = array('[¥name]', '[¥field]');
                $content = str_replace($select, array($name_th, $field_td), $content);
                $file->write_file("/Tpl/{$app_name}/{$module_name}-{$action_name}.html", $content);
                break;
            case 'import':
                foreach ($field_list as $val) {
                    $field_key .= "<input name=\"field_key[{$val['name']}]\" type=\"hidden\" value=\"{$val['field']}\" />";
                }
                $content = str_replace('[¥field_key]', $field_key, $content);
                $file->write_file("/Tpl/{$app_name}/{$module_name}-{$action_name}.html", $content);
                break;
            case 'add':
                $field_num = count($field_list);
                $column_num = $field_num < 12 ? 2 : ($field_num % 3 == 0 ? 3 : 4);
                //可以根据字段的数量来决定有多少列
                $tr = 1;
                foreach ($field_list as $val) {
                    $formtype = '';
                    switch ($val['formtype']) {
                        case 'text':
                            $formtype = "<input name='{$val['field']}' type='text' class='{$val['field']}'>{$val['tips']}";
                            break;
                        case 'password':
                            $formtype = "<input name='{$val['field']}' type='password' class='{$val['field']}'>{$val['tips']}";
                            break;
                        case 'textarea':
                            $formtype = "<textarea name='{$val['field']}' class='{$val['field']}'></textarea>{$val['tips']}";
                            break;
                        case 'select':
                            $formtype = '<select name="' . $val['field'] . '" class="' . $val['field'] . '">';
//.........这里部分代码省略.........
开发者ID:uwitec,项目名称:p-oa,代码行数:101,代码来源:ActionAction.class.php

示例4: analysis_file

 /**
  * 分析出类中的说明,和操作的类
  * 第一个是模型 的一些信息
  * @param unknown_type $file
  * @return $arr=array(
  * 					array('level'=>2,'title'=>'在文件中是用[title][/title]包围 的','name'=>'类名','remark'=>'在系统中是用[des][/des]包围的'),
  * 					array('level'=>3,'title'=>'每一个public函数前面的注释用[title][/title]包围的','name'=>'函数名','remark'=>'每一个public函数前面的注释')
  * 				);
  */
 private function analysis_file($file)
 {
     import("@.ORG.file");
     $obj_file = new file();
     $content = $obj_file->read_file($file);
     $arr = explode('Action extends', $content);
     $module_str = $arr[0];
     $action_str = $arr[1];
     $module_arr = explode('class', $module_str);
     preg_match("/(\\[title\\])[^(\\[\\/title\\])]*(\\[\\/title\\])/", $module_str, $title);
     $title = str_replace('[title]', '', str_replace('[/title]', '', $title[0]));
     preg_match("/(\\[des\\])[^(\\[\\/des\\])]*(\\[\\/des\\])/", $module_str, $des);
     $des = str_replace('[des]', '', str_replace('[/des]', '', $des[0]));
     $title = trim($title) ? trim($title) . '模块' : trim($module_arr[1]);
     $module_info = array(array('level' => 2, 'title' => $title, 'name' => trim($module_arr[1]), 'remark' => $des));
     //模块的信息
     //分析操作的信息
     preg_match_all("/(public function)\\s+\\w+/", $action_str, $match_action);
     $delete_action = array('__construct');
     foreach ($match_action[0] as $action) {
         $action_name = trim(str_replace('public function', '', $action));
         if (!in_array($action_name, $delete_action)) {
             //排除开一些自动生成的必需的方法
             $name = trim(str_replace('_before_', '', $action_name));
             $title = $name;
             $remark = $name;
             $action_info[] = array('level' => 3, 'name' => $name, 'title' => $title, 'remark' => $remark);
         }
     }
     return array_merge($module_info, $action_info);
 }
开发者ID:uwitec,项目名称:p-oa,代码行数:40,代码来源:IndexAction.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


注:本文中的file::read_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。