Commit 88581dec authored by hj's avatar hj

更新提交

parent 46a31a3f
......@@ -131,4 +131,37 @@ trait MsdsTrait
return $msds_html;
}
public function getEnMsds($msds_html, $params)
{
if(!empty($params)) {
$msds_html = preg_replace('/<th[\s]*?class=[\\\'|\"]width-pc-30[\\\'|\"]>Company:<\/th>[\s\S]*?<td[\s]*?class=[\\\'|\"]width-pc-70[\\\'|\"]>[\s\S]*?<\/td>/i', '<th class="width-pc-30">Company:</th> <td class="width-pc-70">' . $params['company_name'] . '</td>', $msds_html);
$msds_html = preg_replace('/<th[\s]*?class=[\\\'|\"]width-pc-30[\\\'|\"]>Address:<\/th>[\s\S]*?<td[\s]*?class=[\\\'|\"]width-pc-70[\\\'|\"]>[\s\S]*?<\/td>/i', '<th class="width-pc-30">Address:</dt> <td>' . $params['company_address'] . '</td>', $msds_html);
$msds_html = preg_replace('/<th[\s]*?class=[\\\'|\"]width-pc-30[\\\'|\"]>Fax:<\/th>[\s\S]*?<td[\s]*?class=[\\\'|\"]width-pc-70[\\\'|\"]>[\s\S]*?<\/td>/i', '<th class="width-pc-30">Fax:</dt> <td>' . $params['company_fax'] . '</td>', $msds_html);
$msds_html = preg_replace('/<th[\s]*?class=[\\\'|\"]width-pc-30[\\\'|\"]>Telephone:<\/th>[\s\S]*?<td[\s]*?class=[\\\'|\"]width-pc-70[\\\'|\"]>[\s\S]*?<\/td>/i', '<th class="width-pc-30">Telephone:</dt> <td>' . $params['company_phone'] . '</td>', $msds_html);
}
preg_match('/<body>[\s]*?<style>(?<bodyStyle>[\s\S]*?)<\/style>/i',$msds_html, $bodyStyle);
$bodyStyle['bodyStyle'] = "<style>body{ font-family: 'msyh'; font-size: 0.8rem; font-weight: normal; display: block;} h2{font-size: 2.0rem; text-align: center;}.container { padding-right: 5px;padding-left: 5px;margin-right: auto;margin-left: auto;width: 100%;} .sds-cn dd p { font-weight: normal; margin-left: 20px; }" .
$bodyStyle['bodyStyle']."</style><body>";
// 格式化处理
$bodyStyle['bodyStyle'] = preg_replace('/\.sds-cn[\s]*?\{[\s]*?line-height: 1.5;[\s]*?\}/i', '.sds-cn{line-height: 2.5;}', $bodyStyle['bodyStyle']);
$bodyStyle['bodyStyle'] = preg_replace('/\.sds-cn[\s]*?\.b-a[\s]*?\{[\s]*?border: 1px solid #000000;[\s]*?\}/i', '.sds-cn .b-a { border: 1px solid #000000; margin-left:10px;}', $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]*?dt[\s]*?\{[\s]*?float: left; font-weight: bold; clear: left; [\s]*?\}/i', '.sds-cn dt { float: left; font-weight: normal; clear: left; }', $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]*?p[\s]*?\{[\s]*?margin:[\s]*?0; \}/i', '.sds-cn p { margin: 0 15px;word-wrap:break-word; }', $bodyStyle['bodyStyle']);
$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('/<body><style>(?<bodyStyle>[\s\S]*?)<\/style>/i', '@body@', $msds_html);
$msds_html = preg_replace('/<\/body>/', '</body>', preg_replace('/@body@/', $bodyStyle['bodyStyle'], $msds_html));
//$msds_html = preg_replace('/@body@/', $newMsdsHtml, $msds_html);
return $msds_html;
}
}
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