修改wiki文档查看功能,修复跳转问题及图片问题

This commit is contained in:
wlx 2012-05-18 08:39:41 +00:00
parent dac47e7469
commit d8e93e9e1a
2 changed files with 19 additions and 11 deletions

View File

@ -3,7 +3,7 @@ class MetainfoController extends Zend_Controller_Action {
function indexAction() {
$title=$this->_request->getParam('title');
$filePath="http://wiki.westgis.ac.cn/api.php?format=php&action=query&prop=revisions&titles=$title&rvprop=content&redirects";
$wikifp=fopen($filePath,r);
$wikifp=fopen($filePath,'r');
while (!feof($wikifp)) {
$wikiLines=fgets($wikifp);
$yuchuli=array('";}}}}}}','**','*');
@ -18,6 +18,12 @@ class MetainfoController extends Zend_Controller_Action {
$this->wikitransform($wikiLine,$content);
}
}
/*$wikicontent=unserialize(file_get_contents($filePath));
$wiki_keys=array_keys($wikicontent['query']['pages']);
$content= $wikicontent['query']['pages'][$wiki_keys[0]];
$this->view->title=$content['title'];
$c1=explode('\n',$content['revisions'][0]['*']);
foreach ($c1 as $c2) $this->wikitransform($c2,$tcontent);*/
$this->view->content=$content;
$this->view->config = Zend_Registry::get('config');
}
@ -37,25 +43,27 @@ class MetainfoController extends Zend_Controller_Action {
$wikiFont=str_replace('==','',$text);
$result.="<h2>$wikiFont</h2>";
}elseif(strpos($text,'[[image:')!== false||strpos($text,'[[Image:')!== false) {
$wimag=array('[[image:',']]','[[Image:');
$wimag=array('[[image:',']]','[[Image:','<center>','</center>');
$imag=str_replace($wimag,'',$text);
$fname="http://wiki.westgis.ac.cn/api.php?format=php&action=query&prop=imageinfo&titles=image:$imag&iiprop=url&redirects";
$imagfp=fopen($fname,r);
$imagfiles=fread($imagfp,1024);
$imagfile=strstr($imagfiles,'http');
$imagurl=mb_strstr($imagfile,'"',true);
$imag=str_replace(' ','_',$imag);
$fname="http://wiki.westgis.ac.cn/api.php?format=php&action=query&prop=imageinfo&titles=image:".$imag."&iiprop=url";
$image1=unserialize(file_get_contents($fname));
$image1_keys=array_keys($image1['query']['pages']);
$image2=$image1['query']['pages'][$image1_keys[count($image1_keys)-1]];
$imagurl=@$image2['imageinfo'][0]['url'];
$result.="<img src=$imagurl>";
//$result.=print_r($image1);
}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>';
$result.='<p><a href="/data/wiki/'.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).'">';
$alink='<a href="/data/wiki/'.urlencode($name).'">';
$c=array($alink,'</a>');
$result.='<p>'.str_replace($a,$c,$text).'</p>';
}elseif(strpos($text,'[http://')!== false||strpos($text,'[ http://')!== false){

View File

@ -86,7 +86,7 @@ else
<li id="datadoc"><a href="<?php $wikiTitle = $this->doc;
if(strpos($wikiTitle,'http://wiki.westgis.ac.cn/index.php/')!==false){
$title=str_replace('http://wiki.westgis.ac.cn/index.php/','',$wikiTitle);
echo "/metainfo/$title";
echo "/data/wiki/$title";
}else{
echo $this->doc;
}?>">数据说明文档</a></li>