1*0Syaroslav@ivinco.com<?php 2*0Syaroslav@ivinco.com/** 3*0Syaroslav@ivinco.com * XML feed export 4*0Syaroslav@ivinco.com * 5*0Syaroslav@ivinco.com * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6*0Syaroslav@ivinco.com * @author Andreas Gohr <andi@splitbrain.org> 7*0Syaroslav@ivinco.com */ 8*0Syaroslav@ivinco.com 9*0Syaroslav@ivinco.com// dokuwiki folder (absolute system path) 10*0Syaroslav@ivinco.com$dokuwiki_folder = '/www/dokuwiki/htdocs'; 11*0Syaroslav@ivinco.com 12*0Syaroslav@ivinco.com// dokuwiki url 13*0Syaroslav@ivinco.com$dokuwiki_url = 'http://dokuwiki.home'; 14*0Syaroslav@ivinco.com 15*0Syaroslav@ivinco.com// link prefix to another page 16*0Syaroslav@ivinco.com$link_prefix = 'http://dokuwiki.home/doc.php/'; 17*0Syaroslav@ivinco.com 18*0Syaroslav@ivinco.com/* Initialization */ 19*0Syaroslav@ivinco.com 20*0Syaroslav@ivinco.comdefine('DOKU_PATH', $dokuwiki_folder); 21*0Syaroslav@ivinco.comdefine('DOKU_INC', DOKU_PATH . '/'); 22*0Syaroslav@ivinco.comdefine('DOKU_CONF', DOKU_PATH . '/conf/'); 23*0Syaroslav@ivinco.comdefine('DOKU_URL', $dokuwiki_url . '/'); 24*0Syaroslav@ivinco.com 25*0Syaroslav@ivinco.comif(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/'); 26*0Syaroslav@ivinco.comif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 27*0Syaroslav@ivinco.com 28*0Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/init.php'); 29*0Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/common.php'); 30*0Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/events.php'); 31*0Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/parserutils.php'); 32*0Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/feedcreator.class.php'); 33*0Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/auth.php'); 34*0Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/pageutils.php'); 35*0Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/search.php'); 36*0Syaroslav@ivinco.com 37*0Syaroslav@ivinco.comrequire_once(DOKU_PLUGIN.'sphinxsearch/PageMapper.php'); 38*0Syaroslav@ivinco.com 39*0Syaroslav@ivinco.com$pagesList = getPagesList(); 40*0Syaroslav@ivinco.com 41*0Syaroslav@ivinco.comecho '<?xml version="1.0" encoding="utf-8"?> 42*0Syaroslav@ivinco.com<sphinx:docset> 43*0Syaroslav@ivinco.com 44*0Syaroslav@ivinco.com<sphinx:schema> 45*0Syaroslav@ivinco.com<sphinx:field name="title"/> 46*0Syaroslav@ivinco.com<sphinx:field name="body"/> 47*0Syaroslav@ivinco.com<sphinx:field name="headings"/> 48*0Syaroslav@ivinco.com<sphinx:field name="categories"/> 49*0Syaroslav@ivinco.com<sphinx:field name="modified"/> 50*0Syaroslav@ivinco.com<sphinx:field name="created"/> 51*0Syaroslav@ivinco.com<sphinx:field name="creator"/> 52*0Syaroslav@ivinco.com<sphinx:field name="extra"/> 53*0Syaroslav@ivinco.com<sphinx:attr name="modified" type="timestamp"/> 54*0Syaroslav@ivinco.com</sphinx:schema> 55*0Syaroslav@ivinco.com'; 56*0Syaroslav@ivinco.com 57*0Syaroslav@ivinco.com$pageMapper = new PageMapper(); 58*0Syaroslav@ivinco.com 59*0Syaroslav@ivinco.comforeach($pagesList as $row){ 60*0Syaroslav@ivinco.com $dokuPageId = $row['id']; 61*0Syaroslav@ivinco.com //get meta data 62*0Syaroslav@ivinco.com $metadata = p_get_metadata($dokuPageId); 63*0Syaroslav@ivinco.com //parse meta data for headers, abstract, date, authors 64*0Syaroslav@ivinco.com $data['id'] = crc32($dokuPageId); 65*0Syaroslav@ivinco.com $data['headings'] = strip_tags(getHeadings($metadata)); 66*0Syaroslav@ivinco.com $data['categories'] = getCategories($dokuPageId); 67*0Syaroslav@ivinco.com $data['created'] = $metadata['date']['created']; 68*0Syaroslav@ivinco.com $data['modified'] = $metadata['date']['modified']; 69*0Syaroslav@ivinco.com $data['creator'] = $metadata['creator']; 70*0Syaroslav@ivinco.com $data['title'] = strip_tags($metadata['title']); 71*0Syaroslav@ivinco.com $data['extra'] = strip_tags($metadata['description']['abstract']); 72*0Syaroslav@ivinco.com $data['body'] = strip_tags(p_wiki_xhtml($dokuPageId,$metadata['date']['modified'],false)); 73*0Syaroslav@ivinco.com 74*0Syaroslav@ivinco.com echo formatXml($data)."\n"; 75*0Syaroslav@ivinco.com 76*0Syaroslav@ivinco.com $pageMapper->add($dokuPageId); 77*0Syaroslav@ivinco.com} 78*0Syaroslav@ivinco.com 79*0Syaroslav@ivinco.comecho '</sphinx:docset>'; 80*0Syaroslav@ivinco.com 81*0Syaroslav@ivinco.com 82*0Syaroslav@ivinco.com 83*0Syaroslav@ivinco.comfunction formatXml($data) 84*0Syaroslav@ivinco.com{ 85*0Syaroslav@ivinco.com $xmlFormat = ' 86*0Syaroslav@ivinco.com<sphinx:document id="{id}"> 87*0Syaroslav@ivinco.com<title><![CDATA[[{title}]]></title> 88*0Syaroslav@ivinco.com<body><![CDATA[[{body}]]></body> 89*0Syaroslav@ivinco.com<headings><![CDATA[[{headings}]]></headings> 90*0Syaroslav@ivinco.com<categories><![CDATA[[{categories}]]></categories> 91*0Syaroslav@ivinco.com<modified>{modified}</modified> 92*0Syaroslav@ivinco.com<created>{created}</created> 93*0Syaroslav@ivinco.com<creator>{creator}</creator> 94*0Syaroslav@ivinco.com<extra><![CDATA[[{extra}]]></extra> 95*0Syaroslav@ivinco.com</sphinx:document> 96*0Syaroslav@ivinco.com 97*0Syaroslav@ivinco.com'; 98*0Syaroslav@ivinco.com 99*0Syaroslav@ivinco.com return str_replace( array('{id}', '{title}', '{body}', '{headings}', '{categories}', '{modified}', '{created}', '{creator}', '{extra}'), 100*0Syaroslav@ivinco.com array($data['id'], $data['title'], $data['body'], $data['headings'], 101*0Syaroslav@ivinco.com $data['categories'], $data['modified'], $data['created'], $data['creator'], $data['extra']), 102*0Syaroslav@ivinco.com $xmlFormat 103*0Syaroslav@ivinco.com ); 104*0Syaroslav@ivinco.com} 105*0Syaroslav@ivinco.com 106*0Syaroslav@ivinco.comfunction getHeadings($metadata) 107*0Syaroslav@ivinco.com{ 108*0Syaroslav@ivinco.com if (empty($metadata) || empty($metadata['description']['tableofcontents'])) return ''; 109*0Syaroslav@ivinco.com 110*0Syaroslav@ivinco.com $result = array(); 111*0Syaroslav@ivinco.com foreach($metadata['description']['tableofcontents'] as $row){ 112*0Syaroslav@ivinco.com $result[] = $row['title']; 113*0Syaroslav@ivinco.com } 114*0Syaroslav@ivinco.com return implode(", ", $result); 115*0Syaroslav@ivinco.com} 116*0Syaroslav@ivinco.com 117*0Syaroslav@ivinco.comfunction getCategories($id) 118*0Syaroslav@ivinco.com{ 119*0Syaroslav@ivinco.com if (empty($id)) return ''; 120*0Syaroslav@ivinco.com 121*0Syaroslav@ivinco.com if (false === strpos($id, ":")){ 122*0Syaroslav@ivinco.com return $id; 123*0Syaroslav@ivinco.com } 124*0Syaroslav@ivinco.com 125*0Syaroslav@ivinco.com $ns = explode(":", $id); 126*0Syaroslav@ivinco.com $nsCount = count($ns); 127*0Syaroslav@ivinco.com 128*0Syaroslav@ivinco.com $result = ''; 129*0Syaroslav@ivinco.com do{ 130*0Syaroslav@ivinco.com for($i = 0; $i < $nsCount; $i++){ 131*0Syaroslav@ivinco.com $name = $ns[$i]; 132*0Syaroslav@ivinco.com $result .= $name; 133*0Syaroslav@ivinco.com if ($i < $nsCount - 1){ 134*0Syaroslav@ivinco.com $result .= ':'; 135*0Syaroslav@ivinco.com } 136*0Syaroslav@ivinco.com } 137*0Syaroslav@ivinco.com $result .= ' '; 138*0Syaroslav@ivinco.com }while($nsCount--); 139*0Syaroslav@ivinco.com return $result; 140*0Syaroslav@ivinco.com} 141*0Syaroslav@ivinco.com 142*0Syaroslav@ivinco.com 143*0Syaroslav@ivinco.com /** 144*0Syaroslav@ivinco.com * Method return all wiki page names 145*0Syaroslav@ivinco.com * @global array $conf 146*0Syaroslav@ivinco.com * @return array 147*0Syaroslav@ivinco.com */ 148*0Syaroslav@ivinco.com function getPagesList() 149*0Syaroslav@ivinco.com { 150*0Syaroslav@ivinco.com global $conf; 151*0Syaroslav@ivinco.com 152*0Syaroslav@ivinco.com $data = array(); 153*0Syaroslav@ivinco.com sort($data); 154*0Syaroslav@ivinco.com search($data,$conf['datadir'],'search_allpages','',''); 155*0Syaroslav@ivinco.com 156*0Syaroslav@ivinco.com return $data; 157*0Syaroslav@ivinco.com} 158*0Syaroslav@ivinco.com 159*0Syaroslav@ivinco.com/** 160*0Syaroslav@ivinco.com * Array 161*0Syaroslav@ivinco.com( 162*0Syaroslav@ivinco.com [date] => Array 163*0Syaroslav@ivinco.com ( 164*0Syaroslav@ivinco.com [created] => 1239181434 165*0Syaroslav@ivinco.com [modified] => 1239202933 166*0Syaroslav@ivinco.com ) 167*0Syaroslav@ivinco.com 168*0Syaroslav@ivinco.com [creator] => Sergey Nikolaev 169*0Syaroslav@ivinco.com [last_change] => Array 170*0Syaroslav@ivinco.com ( 171*0Syaroslav@ivinco.com [date] => 1239202933 172*0Syaroslav@ivinco.com [ip] => 85.118.229.162 173*0Syaroslav@ivinco.com [type] => E 174*0Syaroslav@ivinco.com [id] => cal:minutes:boardreader:200904:20090408 175*0Syaroslav@ivinco.com [user] => snikolaev 176*0Syaroslav@ivinco.com [sum] => 177*0Syaroslav@ivinco.com [extra] => 178*0Syaroslav@ivinco.com ) 179*0Syaroslav@ivinco.com 180*0Syaroslav@ivinco.com [contributor] => Array 181*0Syaroslav@ivinco.com ( 182*0Syaroslav@ivinco.com [snikolaev] => Sergey Nikolaev 183*0Syaroslav@ivinco.com ) 184*0Syaroslav@ivinco.com 185*0Syaroslav@ivinco.com [title] => BoardReader call of Apr 8 2009 186*0Syaroslav@ivinco.com [description] => Array 187*0Syaroslav@ivinco.com ( 188*0Syaroslav@ivinco.com [tableofcontents] => Array 189*0Syaroslav@ivinco.com ( 190*0Syaroslav@ivinco.com [0] => Array 191*0Syaroslav@ivinco.com ( 192*0Syaroslav@ivinco.com [hid] => boardreader_call_of_apr_8_2009 193*0Syaroslav@ivinco.com [title] => BoardReader call of Apr 8 2009 194*0Syaroslav@ivinco.com [type] => ul 195*0Syaroslav@ivinco.com [level] => 1 196*0Syaroslav@ivinco.com ) 197*0Syaroslav@ivinco.com 198*0Syaroslav@ivinco.com [1] => Array 199*0Syaroslav@ivinco.com ( 200*0Syaroslav@ivinco.com [hid] => sergey 201*0Syaroslav@ivinco.com [title] => Sergey 202*0Syaroslav@ivinco.com [type] => ul 203*0Syaroslav@ivinco.com [level] => 2 204*0Syaroslav@ivinco.com ) 205*0Syaroslav@ivinco.com 206*0Syaroslav@ivinco.com [2] => Array 207*0Syaroslav@ivinco.com ( 208*0Syaroslav@ivinco.com [hid] => slava 209*0Syaroslav@ivinco.com [title] => Slava 210*0Syaroslav@ivinco.com [type] => ul 211*0Syaroslav@ivinco.com [level] => 2 212*0Syaroslav@ivinco.com ) 213*0Syaroslav@ivinco.com 214*0Syaroslav@ivinco.com [3] => Array 215*0Syaroslav@ivinco.com ( 216*0Syaroslav@ivinco.com [hid] => roman 217*0Syaroslav@ivinco.com [title] => Roman 218*0Syaroslav@ivinco.com [type] => ul 219*0Syaroslav@ivinco.com [level] => 2 220*0Syaroslav@ivinco.com ) 221*0Syaroslav@ivinco.com 222*0Syaroslav@ivinco.com [4] => Array 223*0Syaroslav@ivinco.com ( 224*0Syaroslav@ivinco.com [hid] => nikita 225*0Syaroslav@ivinco.com [title] => Nikita 226*0Syaroslav@ivinco.com [type] => ul 227*0Syaroslav@ivinco.com [level] => 2 228*0Syaroslav@ivinco.com ) 229*0Syaroslav@ivinco.com 230*0Syaroslav@ivinco.com [5] => Array 231*0Syaroslav@ivinco.com ( 232*0Syaroslav@ivinco.com [hid] => discussion 233*0Syaroslav@ivinco.com [title] => Discussion 234*0Syaroslav@ivinco.com [type] => ul 235*0Syaroslav@ivinco.com [level] => 2 236*0Syaroslav@ivinco.com ) 237*0Syaroslav@ivinco.com 238*0Syaroslav@ivinco.com ) 239*0Syaroslav@ivinco.com 240*0Syaroslav@ivinco.com [abstract] => Participants: Mindaugas, Sergey, Slava, Roman, Nikita 241*0Syaroslav@ivinco.com 242*0Syaroslav@ivinco.comDuration: 23 min 243*0Syaroslav@ivinco.com 244*0Syaroslav@ivinco.comSergey 245*0Syaroslav@ivinco.com 246*0Syaroslav@ivinco.comStatus: 247*0Syaroslav@ivinco.com 248*0Syaroslav@ivinco.com * published Roman's changes 249*0Syaroslav@ivinco.com * started reviewing Slava's changes 250*0Syaroslav@ivinco.com 251*0Syaroslav@ivinco.com 252*0Syaroslav@ivinco.comPlans: 253*0Syaroslav@ivinco.com 254*0Syaroslav@ivinco.com * start altering (singature field) 255*0Syaroslav@ivinco.com * select server error handling 256*0Syaroslav@ivinco.com * publish Slava's and Roman's changes 257*0Syaroslav@ivinco.com ) 258*0Syaroslav@ivinco.com 259*0Syaroslav@ivinco.com [internal] => Array 260*0Syaroslav@ivinco.com ( 261*0Syaroslav@ivinco.com [cache] => 1 262*0Syaroslav@ivinco.com [toc] => 1 263*0Syaroslav@ivinco.com ) 264*0Syaroslav@ivinco.com 265*0Syaroslav@ivinco.com) 266*0Syaroslav@ivinco.com 267*0Syaroslav@ivinco.com */ 268*0Syaroslav@ivinco.com 269