<?php if (!defined('BASEPATH')) exit ('No direct script access allowed'); /** * 2012-6-30:程序打包工具 */ class Dabao extends MY_Controller { public function show_list(){ $out_datas["mclst"]=$this->mcom_model->query_field_object("name mc,demo_uri dm ",mymsg::M_TEMPLATE); $out_datas["dm"]=""; $out_datas["mc"]=""; $this->load->view("me/dabao/list",$out_datas); } public function quanxian(){ $sql="SELECT id,pid,name,title,i_order,op_type FROM ".mymsg::M_MENU." WHERE root_id!=0 and root_show!=0 ORDER BY i_order DESC"; $data['datas']=$this->mcom_model->query_sql_object($sql); //取出所有菜单信息 $data['dm']=urldecode($this->input->post("dm")); //传过来的DM $data['mc']=urldecode($this->input->post("mc")); //传过来的DM $data["mclst"]=$this->mcom_model->query_field_object("name mc,demo_uri dm ",mymsg::M_TEMPLATE); $sql="select cdid from ".mymsg::M_AUTHORITY." where dm='".$data['dm']."'"; //根据DM判断是否已存在此数据,如果存在,是在树初始化后被选中 $cdid=$this->mcom_model->query_sql_object($sql); $qxb=$cdid; $data['cdid']=array(); if(!empty($qxb)){ $data['cdid']=preg_split('/,/',$qxb[0]->cdid); //分隔cdid(是以,号连在一起的字符串) } $this->load->view('me/dabao/list',$data); } //将程序进行打包 /** * 1、将页面复制到指定的目录 * 2、将控制器代码 */ function do_pack(){ $this->load->library('mfile'); $this->load->helper('file'); $template_dm=$this->input->post("dm"); $template_mc=$this->input->post("mc"); $src_dir="F:\\c30";//源目录 $dest_dir="F:\\wwwroot";//目标目录 $base_dir="D:\\Program Files\\XAMPP\\htdocs\\c30"; //1、将源目录的文件复制到目录目录下。 $this->mfile->copyDir($src_dir,$dest_dir); //ok //2、将C30下面的web目录中的webX放入 resource(资源目录表) $src_resource_dir=$base_dir."/web/$template_dm";//资源目录文件 $dest_resource_dir=$dest_dir."/resource";//目标资源目录下 $this->mfile->copyDir($src_resource_dir,$dest_resource_dir);//界面的JS,CSS资源文件移动 ok //3、将application/controllers/template/webX 放入 application/controller/目录下,并改名 $src_controller_name=$base_dir."/application/controllers/template/$template_dm.php"; $dest_controller_name=$dest_dir."/application/controllers/indexs.php"; $this->mfile->copyFile($src_controller_name,$dest_controller_name); //移动控制器 ok $string = read_file($dest_controller_name); $controller_info=str_replace("$template_dm","Indexs",$string); $controller_info=str_replace("\$controller=\$this->uri->rsegment(1);","",$controller_info); $controller_info=str_replace("\$controller","indexs",$controller_info); write_file($dest_controller_name,$controller_info); //4、将application/views/web/webX放入 application/views/resource目录下.(改名) $src_views_path=$base_dir."/application/views/web/$template_dm"; $dest_views_path=$dest_dir."/application/views/resource"; $this->mfile->copyDir($src_views_path,$dest_views_path); //移动视图文件 ok //5、在application/config/下创建me.php文件,并写入信息 $dest_config_path=$dest_dir."/application/config/me.php"; $this->mfile->createFile($dest_config_path); $config_info="<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); \$config[\"indexs\"][\"controller\"] = \"indexs\"; \$config[\"indexs\"][\"resource\"] = \"resource\"; ?>"; write_file($dest_config_path,$config_info); //6、最好将mytool.php,mylib.php,mymsg.php 移动过去 $library_path=$base_dir."/application/libraries/"; $src_library_mytool=$library_path."Mytool.php"; $src_library_mylib=$library_path."Mylib.php"; $src_library_mymsg=$library_path."Mymsg.php"; $dest_library_path=$dest_dir."/application/libraries/"; $dest_library_mytool=$dest_library_path."Mytool.php"; $dest_library_mylib=$dest_library_path."Mylib.php"; $dest_library_mymsg=$dest_library_path."Mymsg.php"; $this->mfile->copyFile($src_library_mytool,$dest_library_mytool); $this->mfile->copyFile($src_library_mylib,$dest_library_mylib); $this->mfile->copyFile($src_library_mymsg,$dest_library_mymsg); //7、将选中的文件存放在 application/controllers/sys views/sys 目录下。需要用于SQL $cdid=$this->input->post("cdid"); $cdid=rtrim($cdid,","); $sql="SELECT DISTINCT SUBSTRING(SUBSTRING_INDEX(url, '/', 2),INSTR(url,'/')+1) url FROM m_menu WHERE id IN($cdid) AND url LIKE 'sys%'"; $QuanxinLst=$this->mcom_model->query_sql_object($sql); foreach($QuanxinLst as $row){ $sys_controller_src_path=$base_dir."/application/controllers/sys/".$row->url.".php"; $sys_controller_dest_path=$dest_dir."/application/controllers/sys/".$row->url.".php";; $this->mfile->copyFile($sys_controller_src_path,$sys_controller_dest_path); //Sys下的Controller $sys_views_src_path=$base_dir."/application/views/sys/".$row->url; $sys_views_dest_path=$dest_dir."/application/views/sys/".$row->url; $this->mfile->copyDir($sys_views_src_path,$sys_views_dest_path); //Sys下的 views } //8数据库 $dest_sql=$dest_dir."/wwwroot.sql"; $del_sql="DELETE FROM m_menu WHERE id NOT IN($cdid)"; write_file($dest_sql,$del_sql,"a+"); $this->mytool->alert_msg("ok,已完成数据导出.",site_url("me/dabao/show_list")); exit(); } }
来源地址:http://www.xiuxiandou.com/blog-32
-----------广告区
休闲豆,IT资讯,IT新闻资讯,电影BT下载,高清电影下载,电影下载,单机游戏下载,游戏下载,电子书下载,电子书PDF下载