merge trunk 1423.

This commit is contained in:
wlx 2011-10-23 10:53:32 +00:00
parent 6543a33b4b
commit 5b312de191
4 changed files with 106 additions and 3 deletions

View File

@ -60,6 +60,51 @@ class Admin_WatermdController extends Zend_Controller_Action
}
$this->view->form=$form;
}
//替换关键词
function keywordAction()
{
//use preg_replace to replace the string
$form=new ReplaceForm();
$form->pattern->setLabel('原关键词');
$form->replace->setLabel('替换关键词');
if ($this->_request->isPost()) {
$formdata=$this->_request->getPost();
$pattern=$formdata["pattern"];
$form->populate($formdata);
//if (substr($pattern,0,1)!='/')
{
$pattern='/\<keyword\>'.$pattern.'\<\/keyword\>/m';
}
$replace='<keyword>'.$formdata["replace"].'</keyword>';
if (isset($formdata["test"]))
{
$this->view->test=preg_replace($pattern,$replace,$formdata["source"]);
} elseif (isset($formdata["submit"]))
{
$sql="select uuid,data from metadata where istemplate = 'n'";
$rows=$this->wdb->fetchAll($sql);
foreach($rows as $k=>$row)
{
//do the replace
$new_data=preg_replace($pattern,$replace,$row['data']);
//防止正则错误
if (!empty($new_data))
{
$sql="update metadata set data=? where uuid=?";
$this->wdb->query($sql,array($new_data,$uuid));
$dom = new DOMDocument();
$dom->loadXML($formdata['source']);
$title=$dom->getElementsByTagName('resTitle')->item(0)->nodeValue;
$deal['uuid']=$uuid;
$deal['title']=$title;
$this->view->deal[]=$deal;
}
}
}
}
$this->view->form=$form;
}
//替换标题和英文标题到数据引用中,以标题为准
function citetitleAction()

View File

@ -13,8 +13,20 @@
<?= $this->partial('watermd/left.phtml'); ?>
</div>
<div id="rightPanel">
<p>此页面的所有功能都是对元数据进行直接处理!</p>
<p>请小心使用!</p>
<p>不要多次刷新!</p>
<p>此页面的所有功能都是对元数据库进行直接处理!请小心使用!不要多次刷新!</p>
<hr />
<h2>正则替换使用说明</h2>
<p>
正则表达式有很强的功能,在使用前一定要进行测试。<br />
如替换元数据中联系地址时正则表达式PATTERN可以设置为
<font color="red">
<strong>
<pre>
\&lt;delPoint\>兰州市东岗西路320号\<\/delPoint\>
</pre></strong></font>
替换表达式可以设置为:<font color="red"><strong>Donggang West Road 320</strong></font>
</p>
</div>
</div>

View File

@ -0,0 +1,45 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('<a href="/admin/watermd">WATER元数据工具</a>');
$this->breadcrumb('关键词替换');
$this->breadcrumb()->setSeparator(' > ');
?>
<div id="leftPanel">
<?= $this->partial('watermd/left.phtml'); ?>
</div>
<div id="rightPanel">
<?php if ($this->msg or $this->messages) :?>
<div id="message">
<?php if ($this->msg) : ?>
<p><?php echo $this->msg; ?></p>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<p><?php echo $msg; ?></p>
<?php endforeach;endif; ?>
</div>
<?php endif; ?>
<?php echo $this->form; ?>
<?php if ($this->deal) : ?>
<div id="mdlist">
已处理数据:
<?php foreach ($this->deal as $deal): ?>
<ul>
<li>UUID<?php echo $deal['uuid']; ?></li>
<li><a href="/water/<?= $deal['uuid']; ?>"><?= $deal['title']; ?></a></li>
</ul>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ($this->test) : ?>
<div>测试结果:<br />
<?= $this->escape($this->test) ?>
</div>
<?php endif; ?>
</div>

View File

@ -4,4 +4,5 @@
<li><a href="/admin/watermd/filesize">文件大小处理</a></li>
<li><a href="/admin/watermd/uselimit">使用声明处理</a></li>
<li><a href="/admin/watermd/contact">联系人替换</a></li>
<li><a href="/admin/watermd/keyword">关键词替换</a></li>
</ul>