Commit 66a6a60e authored by hj's avatar hj

更新提交

parent f051c008
...@@ -33,23 +33,7 @@ class ChemicalsMsdsService ...@@ -33,23 +33,7 @@ class ChemicalsMsdsService
$msds_html = preg_replace('/<dt>联系电话:<\/dt>[\s\S]*?<dd>[\s\S]*?<\/dd>/i', '<dt>联系电话:</dt> <dd>'.$platformParams['company_phone'].'</dd>', $msds_html); $msds_html = preg_replace('/<dt>联系电话:<\/dt>[\s\S]*?<dd>[\s\S]*?<\/dd>/i', '<dt>联系电话:</dt> <dd>'.$platformParams['company_phone'].'</dd>', $msds_html);
} }
/*if(preg_match('/<div[\s]*?class=[\\\'|\"]sds-cn-content[\\\'|\"]>(?<content>[\s\S]+?)<\/div><\/body>/i', $msds_html, $content)){
if($content['content']){
preg_match('/(?<title>[\s\S]*?)<dl><\/dl>/i')
}
}*/
$msds_html = preg_replace('/<html>/i', '<html lang="zh_CN no-js">', $msds_html);
$msds_html = preg_replace('/<meta[\s]*?charset=[\"]UTF\-8[\"]/i', '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">', $msds_html);
preg_match('/<body>[\s]*?<style>(?<bodyStyle>[\s\S]*?)<\/style>/i',$msds_html, $bodyStyle); preg_match('/<body>[\s]*?<style>(?<bodyStyle>[\s\S]*?)<\/style>/i',$msds_html, $bodyStyle);
$msds_html = preg_replace('/<dd>[\s]*?/i', '<dd><p>', $msds_html);
$msds_html = preg_replace('/<\/dd>/i', '</p></dd>', $msds_html);
$msds_html = preg_replace('/<body>[\s]*?<style>(?<bodyStyle>[\s\S]*?)<\/style>/i', '@body@', $msds_html);
$bodyStyle['bodyStyle'] = "<style>body{ font-family: 'msyh'; font-size: 0.8rem; font-weight: bold; display: block;}.container { padding-right: 5px;padding-left: 5px;margin-right: auto;margin-left: auto;width: 90%;} " . $bodyStyle['bodyStyle'] = "<style>body{ font-family: 'msyh'; font-size: 0.8rem; font-weight: bold; display: block;}.container { padding-right: 5px;padding-left: 5px;margin-right: auto;margin-left: auto;width: 90%;} " .
$bodyStyle['bodyStyle']."</style><body><div class='container'>"; $bodyStyle['bodyStyle']."</style><body><div class='container'>";
...@@ -58,10 +42,46 @@ class ChemicalsMsdsService ...@@ -58,10 +42,46 @@ class ChemicalsMsdsService
$bodyStyle['bodyStyle'] = preg_replace('/\.sds-cn[\s]*?dd.clearfix[\s]*?\{ margin-left: 20px;[\s]*?\}/i', '.sds-cn dd.clearfix { width:80% }', $bodyStyle['bodyStyle']); $bodyStyle['bodyStyle'] = preg_replace('/\.sds-cn[\s]*?dd.clearfix[\s]*?\{ margin-left: 20px;[\s]*?\}/i', '.sds-cn dd.clearfix { width:80% }', $bodyStyle['bodyStyle']);
$bodyStyle['bodyStyle'] = preg_replace('/\.sds-cn[\s]*?\.list-line[\s]*?li:before[\s]*?\{ content: " —— " \}/i', '.sds-cn .list-line li:before { content: " -- " }', $bodyStyle['bodyStyle']); $bodyStyle['bodyStyle'] = preg_replace('/\.sds-cn[\s]*?\.list-line[\s]*?li:before[\s]*?\{ content: " —— " \}/i', '.sds-cn .list-line li:before { content: " -- " }', $bodyStyle['bodyStyle']);
//$msds_html = preg_replace('/11123/', $bodyStyle['bodyStyle'], $msds_html);
$msds_html = preg_replace('/<html>/i', '<html lang="zh_CN no-js">', $msds_html);
$msds_html = preg_replace('/<meta[\s]*?charset=[\"]UTF\-8[\"]/i', '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">', $msds_html);
//$msds_html = preg_replace('/<dd>[\s]*?/i', '<dd><p>', $msds_html);
//$msds_html = preg_replace('/<\/dd>/i', '</p></dd>', $msds_html);
$msds_html = preg_replace('/<body><style>(?<bodyStyle>[\s\S]*?)<\/style>/i', '@body@', $msds_html);
$msds_html = preg_replace('/<\/body>/', '</div></body>', preg_replace('/@body@/', $bodyStyle['bodyStyle'], $msds_html)); $msds_html = preg_replace('/<\/body>/', '</div></body>', preg_replace('/@body@/', $bodyStyle['bodyStyle'], $msds_html));
//$msds_html = preg_replace('/@body@/', $newMsdsHtml, $msds_html);
if(preg_match('/<div[\s]*?class=[\\\'|\"]sds-cn-content[\\\'|\"]>(?<content>[\s\S]+?)<\/div><\/body>/i', $msds_html, $content)){
if($content['content']){
preg_match_all('/(?<title>[\s\S]*?)<dl>(?<dlContent>[\s\S]*?)<\/dl>/i', $content['content'], $dlContent);
if($dlContent['dlContent']){
$newMsdsHtml = '';
foreach($dlContent['dlContent'] as $key => $dl){
if($key == 0){
$dlHtml = '';
if($dlContent['title'][$key]){
//$dlHtml = '<h2 style="font-size: 20px; text-align: center;" align="center">'.$dlContent['title'][$key].'</h2>';
preg_match_all('/<dt>(?<cTitle>[\s\S]*?)<\/dt>[\s]*?<dd>(?<cContent>[\s\S]*?)<\/dd>/i', $dl, $content);
if($content){
foreach($content['cTitle'] as $k => $c){
$dlHtml .= '<div><span style="font-size: 14px; font-weight: bold; margin: 0;">'.$c.'</span>';
$dlHtml .= '<span>'.$content['cContent'][$k].'</span></div>';
}
}
}
$msds_html = str_replace($dl, $dlHtml, $msds_html);
}
}
}
}
}
//file_put_contents('./test.html', $msds_html); file_put_contents('./test.html', $msds_html);
//$msds_html = file_get_contents('./test.html'); //$msds_html = file_get_contents('./test.html');
$this->getPdfApp()->loadHTML($msds_html, 'utf-8'); $this->getPdfApp()->loadHTML($msds_html, 'utf-8');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment