diff --git a/application/default/controllers/MetainfoController.php b/application/default/controllers/MetainfoController.php index 9cdd7e61..c895d039 100644 --- a/application/default/controllers/MetainfoController.php +++ b/application/default/controllers/MetainfoController.php @@ -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('";}}}}}}','**','*'); @@ -17,7 +17,13 @@ class MetainfoController extends Zend_Controller_Action { }else { $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.="

$wikiFont

"; }elseif(strpos($text,'[[image:')!== false||strpos($text,'[[Image:')!== false) { - $wimag=array('[[image:',']]','[[Image:'); + $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&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.=""; + //$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.='

'.$wikiname.'

'; + $result.='

'.$wikiname.'

'; }elseif(strpos($text,'[[')!== false) { $a=array('[[',']]'); $b=array('',''); $test=str_replace($a,$b,$text); preg_match_all("|<[^>]+>(.*)]+>|U",$test,$out,PREG_PATTERN_ORDER); $name=$out[1][0];//还有问题,测试遇到再解决! - $alink=''; + $alink=''; $c=array($alink,''); $result.='

'.str_replace($a,$c,$text).'

'; }elseif(strpos($text,'[http://')!== false||strpos($text,'[ http://')!== false){ diff --git a/application/default/views/scripts/data/view.phtml b/application/default/views/scripts/data/view.phtml index 823db4bc..4f6921cc 100755 --- a/application/default/views/scripts/data/view.phtml +++ b/application/default/views/scripts/data/view.phtml @@ -86,7 +86,7 @@ else
  • doc; }?>">数据说明文档