From d8e93e9e1a0420343f93e4c44d6539d8c851ffed Mon Sep 17 00:00:00 2001 From: wlx Date: Fri, 18 May 2012 08:39:41 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9wiki=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E9=97=AE=E9=A2=98=E5=8F=8A=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/MetainfoController.php | 28 ++++++++++++------- .../default/views/scripts/data/view.phtml | 2 +- 2 files changed, 19 insertions(+), 11 deletions(-) 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; }?>">数据说明文档