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


PHP file::write_file方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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':
             foreach ($field_list as $val) {
                 $name_th .= '<th>' . $val['name'] . '</th>';
                 $field_td .= '<td>{$info[' . $val['field'] . ']}</td>';
                 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;
                     }
                 }
             }
             $select = array('[¥name]', '[¥field]', '[¥search]');
             $content = str_replace($select, array($name_th, $field_td, $search_form), $content);
             $file->write_file("/Tpl/{$app_name}/{$module_name}-{$action_name}.html", $content);
         case 'export':
             foreach ($field_list as $val) {
                 $name_th .= '<th>' . $val['name'] . '</th>';
                 $field_td .= '<td>{$info[' . $val['field'] . ']}</td>';
             }
             $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 'add':
             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 'select':
                         $formtype = '<select name="' . $val['field'] . '" class="' . $val['field'] . '">';
                         eval('$select_list=' . $val['setting'] . ';');
                         foreach ($select_list as $v) {
                             $formtype .= '<option value="' . $v['value'] . '" >' . $v['name'] . '</option>';
                         }
                         $formtype .= '</select>' . $val['tips'];
                         break;
                     case 'checkbox':
                         eval('$checkbox_list=' . $val['setting'] . ';');
                         foreach ($checkbox_list as $v) {
                             $formtype .= '<input type="checkbox" name="' . $val['field'] . '[]" class="' . $val['field'] . '" value="' . $v['value'] . '" />' . $v['name'];
                         }
                         break;
                     case 'radio':
                         eval('$radio_list=' . $val['setting'] . ';');
                         foreach ($radio_list as $v) {
                             $formtype .= '<input type="radio" name="' . $val['field'] . '[]" class="' . $val['field'] . '" value="' . $v['value'] . '" />' . $v['name'];
                         }
                         break;
                     default:
                         $formtype = "<input name='{$val['field']}' type='text' class='{$val['field']}'>{$val['tips']}";
                         break;
                 }
                 $html .= "\t<tr><th>{$val['name']}</th><td>{$formtype}</td></tr>\n";
             }
             $content = str_replace('[¥html]', $html, $content);
             $file->write_file("/Tpl/{$app_name}/{$module_name}-{$action_name}.html", $content);
             break;
         case 'edit':
             foreach ($field_list as $val) {
                 $formtype = '';
                 switch ($val['formtype']) {
                     case 'text':
                         $formtype = "<input name='{$val['field']}' type='text' class='{$val['field']}' value='" . '{$info[' . $val['field'] . ']}' . "'>{$val['tips']}";
                         break;
                     case 'password':
                         $formtype = "<input name='{$val['field']}' type='password' class='{$val['field']}' value='" . '{$info[' . $val['field'] . ']}' . "'>{$val['tips']}";
                         break;
                     case 'select':
                         $formtype = '<select name="' . $val['field'] . '" class="' . $val['field'] . '">';
                         eval('$select_list=' . $val['setting'] . ';');
                         foreach ($select_list as $v) {
                             $formtype .= '<option value="' . $v['value'] . '" <if condition="$info[' . $val['field'] . '] eq \'' . $v['value'] . '\'">selected</if>>' . $v['name'] . '</option>';
//.........这里部分代码省略.........
开发者ID:uwitec,项目名称:p-oa,代码行数:101,代码来源:IndexAction.class.php

示例5: 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


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