|
技术大牛,请教下,如何将这2段连起来作为一段代码?
网上找的:
if($this->TotalPage > 1) {
//用正则匹配把分页符去掉
$this->Fields['body2'] = preg_replace('/#p#分页标题#e#/U', '',$this->Fields['body2']);
$this->SplitFields = explode("#p2222#",$this->Fields['body2']);
$this->Fields['tmptitle'] = (empty($this->Fields['tmptitle']) ? $this->Fields['title'] : $this->Fields['tmptitle']);
$this->Fields['title'] = $this->Fields['tmptitle'];
$this->TotalPage = count($this->SplitFields);
$this->Fields['totalpage'] = $this->TotalPage;
$TRUEfilenameall = $this->GetTruePath().$fileFirst."_all.".$this->ShortName;
$this->ParseDMFields(1,0);
$this->dtp->SaveTo($TRUEfilenameall);
if($cfg_remote_site=='Y' && $isremote == 1)
{
//分析远程文件路径
$remotefile = str_replace(DEDEROOT, '', $TRUEfilename);
$localfile = '..'.$remotefile;
//创建远程文件夹
$remotedir = preg_replace("#[^\/]*\.html#", '', $remotefile);
$this->ftp->rmkdir($remotedir);
$this->ftp->upload($localfile, $remotefile, 'ascii');
}
}
我在后面增加一段生成移动端阅读全文的代码变成:
- if($this->TotalPage > 1) {
- //用正则匹配把分页符去掉
- $this->Fields['body2'] = preg_replace('/#p#分页标题#e#/U', '',$this->Fields['body2']);
- $this->SplitFields = explode("#p2222#",$this->Fields['body2']);
- $this->Fields['tmptitle'] = (empty($this->Fields['tmptitle']) ? $this->Fields['title'] : $this->Fields['tmptitle']);
- $this->Fields['title'] = $this->Fields['tmptitle'];
- $this->TotalPage = count($this->SplitFields);
- $this->Fields['totalpage'] = $this->TotalPage;
- $TRUEfilenameall = $this->GetTruePath().$fileFirst."_all.".$this->ShortName;
- $this->ParseDMFields(1,0);
- $this->dtp->SaveTo($TRUEfilenameall);
- if($cfg_remote_site=='Y' && $isremote == 1)
- {
- //分析远程文件路径
- $remotefile = str_replace(DEDEROOT, '', $TRUEfilename);
- $localfile = '..'.$remotefile;
- //创建远程文件夹
- $remotedir = preg_replace("#[^\/]*\.html#", '', $remotefile);
- $this->ftp->rmkdir($remotedir);
- $this->ftp->upload($localfile, $remotefile, 'ascii');
- }
- }
- if($this->TotalPage > 1) {
- $tempfile = $this->GetTempletFile();//引入移动端模板
- $tempfile = str_replace('default','wap',$tempfile);//前面的PC端,后面是手机端将其替换
- if(!file_exists($tempfile) || !is_file($tempfile))
- {
- }
- $this->Fields["displaytype"] = "st";
- //预编译$th
- //用正则匹配把分页符去掉
- $this->dtp->LoadTemplate($tempfile);
- $this->Fields['body2'] = preg_replace('/#p#分页标题#e#/U', '',$this->Fields['body2']);
- $this->SplitFields = explode("#p2222#",$this->Fields['body2']);
- $this->Fields['tmptitle'] = (empty($this->Fields['tmptitle']) ? $this->Fields['title'] : $this->Fields['tmptitle']);
- $this->Fields['title'] = $this->Fields['tmptitle'];
- $this->TotalPage = count($this->SplitFields);
- $this->Fields['totalpage'] = $this->TotalPage;
- $TRUEfilenameallm = $this->GetTruePath()."/m/".$fileFirst."_all.".$this->ShortName;// 移动端
- $this->ParseDMFields(1,0);
- $this->dtp->SaveTo($TRUEfilenameallm);// 移动端
- if($cfg_remote_site=='Y' && $isremote == 1)
- {
- //分析远程文件路径
- $remotefile = str_replace(DEDEROOT, '', $TRUEfilename);
- $localfile = '..'.$remotefile;
- //创建远程文件夹
- $remotedir = preg_replace("#[^\/]*\.html#", '', $remotefile);
- $this->ftp->rmkdir($remotedir);
- $this->ftp->upload($localfile, $remotefile, 'ascii');
- }
- }
复制代码
结果就只有移动端没有PC端的生成,
怎样才能把2个语句串起来既可以生成PC端同时生成移动端?
技术太菜了,悲剧啊 |
|