fix metadata document error
This commit is contained in:
parent
8423678e9e
commit
c00b2edece
|
@ -90,6 +90,10 @@ routes.dataseries.defaults.controller = "data"
|
|||
routes.dataseries.defaults.action = "series"
|
||||
//routes.dataseries.reqs.code = "\d+"
|
||||
|
||||
routes.mddoc.route = "metainfo/:title"
|
||||
routes.mddoc.defaults.controller = "metainfo"
|
||||
routes.mddoc.defaults.action = "index"
|
||||
|
||||
routes.admin.type = "Zend_Controller_Router_Route_Static"
|
||||
routes.admin.route = admin
|
||||
routes.admin.defaults.module = admin
|
||||
|
|
|
@ -4,6 +4,107 @@ class MetainfoController extends Zend_Controller_Action {
|
|||
$title=$this->_request->getParam('title');
|
||||
$filePath="http://wiki.westgis.ac.cn/api.php?format=php&action=query&prop=revisions&titles=$title&rvprop=content";
|
||||
$wikifp=fopen($filePath,r);
|
||||
$this->view->title=$wikifp;
|
||||
while (!feof($wikifp)) {
|
||||
$wikiLines=fgets($wikifp);
|
||||
$yuchuli=array('";}}}}}}','**','*');
|
||||
$chulihou=array('',' ·','·');
|
||||
$wikiLine=str_replace($yuchuli,$chulihou,$wikiLines);
|
||||
if(substr($wikiLine,0,2)=='a:') {
|
||||
if(strpos($wikiLine,'==')!== false){
|
||||
$wikititle=mb_strstr($wikiLine,'==',false);
|
||||
$this->wikitransform($wikititle,$content);
|
||||
}
|
||||
}else {
|
||||
$this->wikitransform($wikiLine,$content);
|
||||
}
|
||||
}
|
||||
$this->view->content=$content;
|
||||
$this->view->config = Zend_Registry::get('config');
|
||||
}
|
||||
|
||||
//transform mediawiki text to local text
|
||||
function wikitransform($text,&$result) {
|
||||
if(strpos($text,'=====')!== false&&substr($text,0,1)=='=') {
|
||||
$wikiFont=str_replace('=====','',$text);
|
||||
$result.="<h5>$wikiFont</h5>";
|
||||
}elseif(strpos($text,'====')!== false&&substr($text,0,1)=='=') {
|
||||
$wikiFont=str_replace('====','',$text);
|
||||
$result.="<h4>$wikiFont</h4>";
|
||||
}elseif(strpos($text,'===')!== false&&substr($text,0,1)=='=') {
|
||||
$wikiFont=str_replace('===','',$text);
|
||||
$result.="<h3>$wikiFont</h3>";
|
||||
}elseif(strpos($text,'==')!== false&&substr($text,0,1)=='=') {
|
||||
$wikiFont=str_replace('==','',$text);
|
||||
$result.="<h2>$wikiFont</h2>";
|
||||
}elseif(strpos($text,'[[image:')!== false||strpos($text,'[[Image:')!== false) {
|
||||
$wimag=array('[[image:',']]','[[Image:');
|
||||
$imag=str_replace($wimag,'',$text);
|
||||
$fname="http://wiki.westgis.ac.cn/api.php?format=php&action=query&prop=imageinfo&titles=image:$imag&iiprop=url";
|
||||
$imagfp=fopen($fname,r);
|
||||
$imagfiles=fread($imagfp,1024);
|
||||
$imagfile=strstr($imagfiles,'http');
|
||||
$imagurl=mb_strstr($imagfile,'"',true);
|
||||
$result.="<img src=$imagurl>";
|
||||
}elseif(substr($text,0,3)=='·[['||substr($text,0,4)=='· [['||substr($text,0,2)=='[[') {
|
||||
$wikia=array('·[[','· [[','[[',']]');
|
||||
$wikiname=str_replace($wikia,'',$text);
|
||||
$result.='<p><a href="/metainfo/'.urlencode($wikiname).'">'.$wikiname.'</a></p>';
|
||||
}elseif(strpos($text,'[[')!== false) {
|
||||
$a=array('[[',']]');
|
||||
$b=array('<b>','</b>');
|
||||
$test=str_replace($a,$b,$text);
|
||||
preg_match_all("|<[^>]+>(.*)</[^>]+>|U",$test,$out,PREG_PATTERN_ORDER);
|
||||
$name=$out[1][0];//还有问题,测试遇到再解决!
|
||||
$alink='<a href="/metainfo/'.urlencode($name).'">';
|
||||
$c=array($alink,'</a>');
|
||||
$result.='<p>'.str_replace($a,$c,$text).'</p>';
|
||||
}elseif(strpos($text,'[http://')!== false||strpos($text,'[ http://')!== false){
|
||||
$a=array('[',']');
|
||||
$b=array('<b>','</b>');
|
||||
$test=str_replace($a,$b,$text);
|
||||
preg_match_all("|<[^>]+>(.*)</[^>]+>|U",$test,$out,PREG_PATTERN_ORDER);
|
||||
$name=$out[1][0];//还有问题,测试遇到再解决!
|
||||
$href='<a href="'.mb_strstr($name,' ',true).'">';
|
||||
$value=mb_strstr($name,' ',false).'</a>';
|
||||
$result.=str_replace($name,$href.$value,$test);
|
||||
}elseif(strpos($text,'{|')!== false) {
|
||||
$wikitable=str_replace("{|",'<table ',$text);
|
||||
$result.=$wikitable.'>';
|
||||
}elseif(strpos($text,'colspan')) {
|
||||
if(substr($text,-2)=='| '||substr($text,-2)==' |') {
|
||||
$wikicolspan=array(' |','| ');
|
||||
$colspan=array('></td>','<td ');
|
||||
$result.= str_replace($wikicolspan,$colspan,$text);
|
||||
}else {
|
||||
$wikicolspan=array(' | ','| ');
|
||||
$colspan=array('>','<td ');
|
||||
$result.= str_replace($wikicolspan,$colspan,$text).'</td>';
|
||||
}
|
||||
}elseif(strpos($text,'|+ ')!== false) {
|
||||
$wikitr=str_replace('|+ ','<caption>',$text);
|
||||
$result.= $wikitr.'</caption><tbody>';
|
||||
}elseif(strpos($text,'!!')!== false||substr($text,0,1)=='!') {
|
||||
$thh=str_replace("!!",'</th><th>',$text);
|
||||
$wikith=str_replace('!','<th>',$thh);
|
||||
$result.= $wikith.'</th>';
|
||||
}elseif(strpos($text,'||')!== false||substr($text,0,1)=='|'&&substr($text,0,2)!=='||'&&substr($text,0,2)!=='|+'&&substr($text,0,2)!=='|-'&&substr($text,0,2)!=='|}') {
|
||||
$tdd=str_replace('||','</td><td>',$text);
|
||||
$wikitd=str_replace('|','<td>',$tdd);
|
||||
$result.= $wikitd.'</td>';
|
||||
}elseif(substr($text,0,2)=='|-') {
|
||||
$wikitrr=str_replace('|-','</tr><tr>',$text);
|
||||
$result.=$wikitrr;
|
||||
}elseif(substr($text,0,2)=='|}') {
|
||||
$wikitables=str_replace("|}",'</tr></tbody></table>',$text);
|
||||
$result.= $wikitables;
|
||||
}elseif(substr($text,0,1)=='#') {
|
||||
$result.= str_replace('#',' ',$text);
|
||||
}elseif(strpos($text,"'''")!==false) {
|
||||
$result.= str_replace("'''",'',$text);
|
||||
}elseif(substr($text,0,1)=="*") {
|
||||
$result.= str_replace('*','',$text);
|
||||
}else {
|
||||
$result.= "<p>$text</p>";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,106 +1,14 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle($this->config->title->data);
|
||||
$this->headTitle('数据文档');
|
||||
$this->headTitle('特色推荐');
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
//$this->headLink()->appendStylesheet('/css/feature.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/data">'.$this->config->title->data.'</a>');
|
||||
$this->breadcrumb('数据文档');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
<div id="divContent">
|
||||
<?php
|
||||
function wikitransform($text) {
|
||||
if(strpos($text,'=====')!== false&&substr($text,0,1)=='=') {
|
||||
$wikiFont=str_replace('=====','',$text);
|
||||
echo "<h5>$wikiFont</h5>";
|
||||
}elseif(strpos($text,'====')!== false&&substr($text,0,1)=='=') {
|
||||
$wikiFont=str_replace('====','',$text);
|
||||
echo "<h4>$wikiFont</h4>";
|
||||
}elseif(strpos($text,'===')!== false&&substr($text,0,1)=='=') {
|
||||
$wikiFont=str_replace('===','',$text);
|
||||
echo "<h3>$wikiFont</h3>";
|
||||
}elseif(strpos($text,'==')!== false&&substr($text,0,1)=='=') {
|
||||
$wikiFont=str_replace('==','',$text);
|
||||
echo "<h2>$wikiFont</h2>";
|
||||
}elseif(strpos($text,'[[image:')!== false||strpos($text,'[[Image:')!== false) {
|
||||
$wimag=array('[[image:',']]','[[Image:');
|
||||
$imag=str_replace($wimag,'',$text);
|
||||
$fname="http://wiki.westgis.ac.cn/api.php?format=php&action=query&prop=imageinfo&titles=image:$imag&iiprop=url";
|
||||
$imagfp=fopen($fname,r);
|
||||
$imagfiles=fread($imagfp,1024);
|
||||
$imagfile=strstr($imagfiles,'http');
|
||||
$imagurl=mb_strstr($imagfile,'"',true);
|
||||
echo "<img src=$imagurl>";
|
||||
}elseif(substr($text,0,3)=='·[['||substr($text,0,4)=='· [['||substr($text,0,2)=='[[') {
|
||||
$wikia=array('·[[','· [[','[[',']]');
|
||||
$wikiname=str_replace($wikia,'',$text);
|
||||
echo '<p><a href="/metainfo/'.urlencode($wikiname).'">'.$wikiname.'</a></p>';
|
||||
}elseif(strpos($text,'[[')!== false) {
|
||||
$a=array('[[',']]');
|
||||
$b=array('<b>','</b>');
|
||||
$test=str_replace($a,$b,$text);
|
||||
preg_match_all("|<[^>]+>(.*)</[^>]+>|U",$test,$out,PREG_PATTERN_ORDER);
|
||||
$name=$out[1][0];//还有问题,测试遇到再解决!
|
||||
$alink='<a href="/metainfo/'.urlencode($name).'">';
|
||||
$c=array($alink,'</a>');
|
||||
echo '<p>'.str_replace($a,$c,$text).'</p>';
|
||||
}elseif(strpos($text,'[http://')!== false||strpos($text,'[ http://')!== false){
|
||||
$a=array('[',']');
|
||||
$b=array('<b>','</b>');
|
||||
$test=str_replace($a,$b,$text);
|
||||
preg_match_all("|<[^>]+>(.*)</[^>]+>|U",$test,$out,PREG_PATTERN_ORDER);
|
||||
$name=$out[1][0];//还有问题,测试遇到再解决!
|
||||
$href='<a href="'.mb_strstr($name,' ',true).'">';
|
||||
$value=mb_strstr($name,' ',false).'</a>';
|
||||
echo str_replace($name,$href.$value,$test);
|
||||
}elseif(strpos($text,'{|')!== false) {
|
||||
$wikitable=str_replace("{|",'<table ',$text);
|
||||
echo $wikitable.'>';
|
||||
}elseif(strpos($text,'colspan')) {
|
||||
if(substr($text,-2)=='| '||substr($text,-2)==' |') {
|
||||
$wikicolspan=array(' |','| ');
|
||||
$colspan=array('></td>','<td ');
|
||||
echo str_replace($wikicolspan,$colspan,$text);
|
||||
}else {
|
||||
$wikicolspan=array(' | ','| ');
|
||||
$colspan=array('>','<td ');
|
||||
echo str_replace($wikicolspan,$colspan,$text).'</td>';
|
||||
}
|
||||
}elseif(strpos($text,'|+ ')!== false) {
|
||||
$wikitr=str_replace('|+ ','<caption>',$text);
|
||||
echo $wikitr.'</caption><tbody>';
|
||||
}elseif(strpos($text,'!!')!== false||substr($text,0,1)=='!') {
|
||||
$thh=str_replace("!!",'</th><th>',$text);
|
||||
$wikith=str_replace('!','<th>',$thh);
|
||||
echo $wikith.'</th>';
|
||||
}elseif(strpos($text,'||')!== false||substr($text,0,1)=='|'&&substr($text,0,2)!=='||'&&substr($text,0,2)!=='|+'&&substr($text,0,2)!=='|-'&&substr($text,0,2)!=='|}') {
|
||||
$tdd=str_replace('||','</td><td>',$text);
|
||||
$wikitd=str_replace('|','<td>',$tdd);
|
||||
echo $wikitd.'</td>';
|
||||
}elseif(substr($text,0,2)=='|-') {
|
||||
$wikitrr=str_replace('|-','</tr><tr>',$text);
|
||||
echo$wikitrr;
|
||||
}elseif(substr($text,0,2)=='|}') {
|
||||
$wikitables=str_replace("|}",'</tr></tbody></table>',$text);
|
||||
echo $wikitables;
|
||||
}elseif(substr($text,0,1)=='#') {
|
||||
echo str_replace('#',' ',$text);
|
||||
}elseif(strpos($text,"'''")!==false) {
|
||||
echo str_replace("'''",'',$text);
|
||||
}elseif(substr($text,0,1)=="*") {
|
||||
echo str_replace('*','',$text);
|
||||
}else {
|
||||
echo "<p>$text</p>";
|
||||
}
|
||||
}
|
||||
$wikifp=$this->title;
|
||||
while (!feof($wikifp)) {
|
||||
$wikiLines=fgets($wikifp);
|
||||
$yuchuli=array('";}}}}}}','**','*');
|
||||
$chulihou=array('',' ·','·');
|
||||
$wikiLine=str_replace($yuchuli,$chulihou,$wikiLines);
|
||||
if(substr($wikiLine,0,2)=='a:') {
|
||||
if(strpos($wikiLine,'==')!== false){
|
||||
$wikititle=mb_strstr($wikiLine,'==',false);
|
||||
wikitransform($wikititle);
|
||||
}
|
||||
}else { wikitransform($wikiLine);}
|
||||
}
|
||||
?>
|
||||
<?php echo $this->content; ?>
|
||||
</div>
|
Loading…
Reference in New Issue