此版本取消了编辑器按钮支持,编辑器使用 独立插件 编辑器扩展(提供公式实时预览) 代替。同时为了兼容编辑器扩展,将直接使用mathjax定义的inline和displayed标签来标记数学公式。
注意!!!如果您的论坛已经有大量公式,建议您慎重考虑是否升级。
建议的升级方案
- 升级前备份数据库
- 执行以下php脚本
先替换inline公式
<?php
$host = "localhost";
$user = "root";
$pwd = "pass";
$dbname = "dbname";
$connID = mysql_connect($host, $user,$pwd);
mysql_select_db($dbname, $connID);
$query = mysql_query("select pid,message from pre_forum_post where message like '%[/math]%'", $connID);
$sum = 0;
$pids = array();
while($data = mysql_fetch_array($query))
{
$pids[$data["pid"]] = $data["message"];
}
#print_r($pids);
$pattern = array(
"/\[math\](.+?)\[\/math\]/s",
);
$replace = array(
"[math]$\${1}$[/math]",
);
foreach($pids as $k => $val)
{
$post = preg_replace($pattern, $replace, $val);
$post = str_replace("\\", "\\\\", $post);
print_r("\n================================================\n");
print_r($post);
// 先输出,结果正确再取消以下注释来更新数据库
//$data = mysql_query("update pre_forum_post set message='" . $post . "' where pid=$k", $connID);
}
在替换displayed公式
<?php
$host = "localhost";
$user = "root";
$pwd = "pass";
$dbname = "dbname";
$connID = mysql_connect($host, $user,$pwd);
mysql_select_db($dbname, $connID);
$query = mysql_query("select pid,message from pre_forum_post where message like '%[/math]%'", $connID);
$sum = 0;
$pids = array();
while($data = mysql_fetch_array($query))
{
$pids[$data["pid"]] = $data["message"];
}
#print_r($pids);
$pattern = array(
'/\[math\]\$(.+?\\\\.+)?\$\[\/math\]/s',
);
$replace = array(
"[math]$$\${1}$$[/math]",
);
foreach($pids as $k => $val)
{
$post = preg_replace($pattern, $replace, $val);
$post = str_replace("\\", "\\\\", $post);
print_r($post);
// 先输出,结果正确再取消以下注释来更新数据库
//$data = mysql_query("update pre_forum_post set message='" . $post . "' where pid=$k", $connID);
}
|