生成ini文件
来源:互联网 发布:js 取数组前几个元素 编辑:程序博客网 时间:2024/06/16 06:11
<?
class create
{
private $file_type;
private $file_name;
private $file_handle;
private $file_path;
function create($param){
$this->file_name= $param['file_name'];
$this->file_type= $param['file_type'];
$this->file_path = $param['file_path'];
}
private function get_data($class,$method,$id) {
$model = new $class();
$data = $model->$method($id);
$data['company'] = Basesetting::get_company();
return $data;
}
public function create_file($class,$method,$id,$note) {
$data = $this->get_data($class,$method,$id);
$this->open_file();
$this->create_note($note);
$this->write_file('[template]');
$this->write_file(' ');
$this->create_data($data['company'], '## this is the template company info', 'company');
$this->write_file(' ');
$this->create_data($data['master'], '## this is the template master ', 'master');
$this->write_file(' ');
$this->create_data($data['slave'][0], '## this is the template slave ', 'slave.0');
$this->close_file();
}
private function create_note($bill_name){
$note = "#################################################";
$this->write_file($note);
$note = "### 本配置文件是 $bill_name 单据打印 配置模板";
$this->write_file($note);
$note = "### 如需要添加字段请在配置文件中添加相应的字段项";
$this->write_file($note);
$note = "### “
$this->write_file($note);
$note = "#################################################";
$this->write_file($note);
}
private function create_data($data,$note,$title){
$this->write_file($note);
foreach ($data as $key => $value) {
$this->create_row($title.'.'.$key,$value);
}
}
private function create_row($key , $val){
$str = str_pad($key,35);
$str .=' = '.$val;
$this->write_file($str);
}
private function open_file(){
$this->file_handle = fopen($this->file_path.'/'.$this->file_name.'.'.$this->file_type, 'wb');
}
private function close_file(){
fclose($this->file_handle);
}
private function write_file($str){
fwrite($this->file_handle,$str."\r\n");
}
public function create_files($arr) {
foreach ($arr as $value) {
$this->file_name = $value['file_name'];
$this->create_file($value['class'], $value['method'], $value['id'],$value['note']);
}
}
}
class create
{
private $file_type;
private $file_name;
private $file_handle;
private $file_path;
function create($param){
$this->file_name= $param['file_name'];
$this->file_type= $param['file_type'];
$this->file_path = $param['file_path'];
}
private function get_data($class,$method,$id) {
$model = new $class();
$data = $model->$method($id);
$data['company'] = Basesetting::get_company();
return $data;
}
public function create_file($class,$method,$id,$note) {
$data = $this->get_data($class,$method,$id);
$this->open_file();
$this->create_note($note);
$this->write_file('[template]');
$this->write_file(' ');
$this->create_data($data['company'], '## this is the template company info', 'company');
$this->write_file(' ');
$this->create_data($data['master'], '## this is the template master ', 'master');
$this->write_file(' ');
$this->create_data($data['slave'][0], '## this is the template slave ', 'slave.0');
$this->close_file();
}
private function create_note($bill_name){
$note = "#################################################";
$this->write_file($note);
$note = "### 本配置文件是 $bill_name 单据打印 配置模板";
$this->write_file($note);
$note = "### 如需要添加字段请在配置文件中添加相应的字段项";
$this->write_file($note);
$note = "### “
$this->write_file($note);
$note = "#################################################";
$this->write_file($note);
}
private function create_data($data,$note,$title){
$this->write_file($note);
foreach ($data as $key => $value) {
$this->create_row($title.'.'.$key,$value);
}
}
private function create_row($key , $val){
$str = str_pad($key,35);
$str .=' = '.$val;
$this->write_file($str);
}
private function open_file(){
$this->file_handle = fopen($this->file_path.'/'.$this->file_name.'.'.$this->file_type, 'wb');
}
private function close_file(){
fclose($this->file_handle);
}
private function write_file($str){
fwrite($this->file_handle,$str."\r\n");
}
public function create_files($arr) {
foreach ($arr as $value) {
$this->file_name = $value['file_name'];
$this->create_file($value['class'], $value['method'], $value['id'],$value['note']);
}
}
}
- 生成ini文件
- 生成Unicode版本的Ini文件
- C++数据库操作并生成ini文件。
- 将TexturePacker生成的xml文件转成ini文件
- 读取INI文件调用DLL动态生成菜单
- Visual C++ 2005 利用ini文件生成Tree Control
- java关于ini文件的生成与修改
- python之自动化生成解析ini文件的Qt类
- INI文件
- ini文件
- INI文件
- INI文件
- INI文件
- INI文件
- ini文件
- INI文件
- INI文件
- C# .net 读取INI文件 ini文件
- 程序员必知:C/C++面试题(10)
- ACM算法列表
- 数据库 lag和lead函数 查询上/下一条记录中字段
- 程序员必知:C/C++面试题(9)
- 导入导出数据库
- 生成ini文件
- 创建型模式(2)
- Ubuntu10.04中文输入法ibus最新稳定版本ibus-pinyin 1.37
- DNS随笔3-脆弱的安全性
- silverlight 乐动魔方 实战五
- 在delphi中如何调用SQL Server的存储过程(转贴)
- 在.NET中 DAL+IDAL+Model+BLL+Web
- 选择正版windows7给你好处
- 线程同步和异步 实例(一)