10Syaroslav@ivinco.com<?php 20Syaroslav@ivinco.com/** 30Syaroslav@ivinco.com * XML feed export 40Syaroslav@ivinco.com * 50Syaroslav@ivinco.com * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 60Syaroslav@ivinco.com * @author Andreas Gohr <andi@splitbrain.org> 70Syaroslav@ivinco.com */ 80Syaroslav@ivinco.com 90Syaroslav@ivinco.com 100Syaroslav@ivinco.com/* Initialization */ 110Syaroslav@ivinco.com 12*1Syaroslav@ivinco.comif(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../../'); 130Syaroslav@ivinco.comif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 140Syaroslav@ivinco.com 150Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/init.php'); 160Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/common.php'); 170Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/events.php'); 180Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/parserutils.php'); 190Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/feedcreator.class.php'); 200Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/auth.php'); 210Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/pageutils.php'); 220Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/search.php'); 230Syaroslav@ivinco.com 240Syaroslav@ivinco.comrequire_once(DOKU_PLUGIN.'sphinxsearch/PageMapper.php'); 250Syaroslav@ivinco.com 26*1Syaroslav@ivinco.comif (!file_exists(DOKU_INC.$conf['savedir']."/sphinxsearch/")){ 27*1Syaroslav@ivinco.com mkdir(DOKU_INC.$conf['savedir']."/sphinxsearch/"); 28*1Syaroslav@ivinco.com} 29*1Syaroslav@ivinco.com 300Syaroslav@ivinco.com$pagesList = getPagesList(); 310Syaroslav@ivinco.com 320Syaroslav@ivinco.comecho '<?xml version="1.0" encoding="utf-8"?> 330Syaroslav@ivinco.com<sphinx:docset> 340Syaroslav@ivinco.com 350Syaroslav@ivinco.com<sphinx:schema> 360Syaroslav@ivinco.com<sphinx:field name="title"/> 370Syaroslav@ivinco.com<sphinx:field name="body"/> 380Syaroslav@ivinco.com<sphinx:field name="headings"/> 390Syaroslav@ivinco.com<sphinx:field name="categories"/> 400Syaroslav@ivinco.com<sphinx:field name="modified"/> 410Syaroslav@ivinco.com<sphinx:field name="created"/> 420Syaroslav@ivinco.com<sphinx:field name="creator"/> 430Syaroslav@ivinco.com<sphinx:field name="extra"/> 440Syaroslav@ivinco.com<sphinx:attr name="modified" type="timestamp"/> 450Syaroslav@ivinco.com</sphinx:schema> 460Syaroslav@ivinco.com'; 470Syaroslav@ivinco.com 480Syaroslav@ivinco.com$pageMapper = new PageMapper(); 490Syaroslav@ivinco.com 500Syaroslav@ivinco.comforeach($pagesList as $row){ 510Syaroslav@ivinco.com $dokuPageId = $row['id']; 520Syaroslav@ivinco.com //get meta data 530Syaroslav@ivinco.com $metadata = p_get_metadata($dokuPageId); 540Syaroslav@ivinco.com //parse meta data for headers, abstract, date, authors 55*1Syaroslav@ivinco.com $data = array(); 560Syaroslav@ivinco.com $data['id'] = crc32($dokuPageId); 570Syaroslav@ivinco.com $data['headings'] = strip_tags(getHeadings($metadata)); 580Syaroslav@ivinco.com $data['categories'] = getCategories($dokuPageId); 590Syaroslav@ivinco.com $data['created'] = $metadata['date']['created']; 600Syaroslav@ivinco.com $data['modified'] = $metadata['date']['modified']; 610Syaroslav@ivinco.com $data['creator'] = $metadata['creator']; 620Syaroslav@ivinco.com $data['title'] = strip_tags($metadata['title']); 630Syaroslav@ivinco.com $data['extra'] = strip_tags($metadata['description']['abstract']); 640Syaroslav@ivinco.com $data['body'] = strip_tags(p_wiki_xhtml($dokuPageId,$metadata['date']['modified'],false)); 650Syaroslav@ivinco.com 660Syaroslav@ivinco.com echo formatXml($data)."\n"; 670Syaroslav@ivinco.com 680Syaroslav@ivinco.com $pageMapper->add($dokuPageId); 690Syaroslav@ivinco.com} 700Syaroslav@ivinco.com 710Syaroslav@ivinco.comecho '</sphinx:docset>'; 720Syaroslav@ivinco.com 730Syaroslav@ivinco.com 740Syaroslav@ivinco.com 750Syaroslav@ivinco.comfunction formatXml($data) 760Syaroslav@ivinco.com{ 770Syaroslav@ivinco.com $xmlFormat = ' 780Syaroslav@ivinco.com<sphinx:document id="{id}"> 790Syaroslav@ivinco.com<title><![CDATA[[{title}]]></title> 800Syaroslav@ivinco.com<body><![CDATA[[{body}]]></body> 810Syaroslav@ivinco.com<headings><![CDATA[[{headings}]]></headings> 820Syaroslav@ivinco.com<categories><![CDATA[[{categories}]]></categories> 830Syaroslav@ivinco.com<modified>{modified}</modified> 840Syaroslav@ivinco.com<created>{created}</created> 850Syaroslav@ivinco.com<creator>{creator}</creator> 860Syaroslav@ivinco.com<extra><![CDATA[[{extra}]]></extra> 870Syaroslav@ivinco.com</sphinx:document> 880Syaroslav@ivinco.com 890Syaroslav@ivinco.com'; 900Syaroslav@ivinco.com 910Syaroslav@ivinco.com return str_replace( array('{id}', '{title}', '{body}', '{headings}', '{categories}', '{modified}', '{created}', '{creator}', '{extra}'), 920Syaroslav@ivinco.com array($data['id'], $data['title'], $data['body'], $data['headings'], 930Syaroslav@ivinco.com $data['categories'], $data['modified'], $data['created'], $data['creator'], $data['extra']), 940Syaroslav@ivinco.com $xmlFormat 950Syaroslav@ivinco.com ); 960Syaroslav@ivinco.com} 970Syaroslav@ivinco.com 980Syaroslav@ivinco.comfunction getHeadings($metadata) 990Syaroslav@ivinco.com{ 1000Syaroslav@ivinco.com if (empty($metadata) || empty($metadata['description']['tableofcontents'])) return ''; 1010Syaroslav@ivinco.com 1020Syaroslav@ivinco.com $result = array(); 1030Syaroslav@ivinco.com foreach($metadata['description']['tableofcontents'] as $row){ 1040Syaroslav@ivinco.com $result[] = $row['title']; 1050Syaroslav@ivinco.com } 1060Syaroslav@ivinco.com return implode(", ", $result); 1070Syaroslav@ivinco.com} 1080Syaroslav@ivinco.com 1090Syaroslav@ivinco.comfunction getCategories($id) 1100Syaroslav@ivinco.com{ 1110Syaroslav@ivinco.com if (empty($id)) return ''; 1120Syaroslav@ivinco.com 1130Syaroslav@ivinco.com if (false === strpos($id, ":")){ 1140Syaroslav@ivinco.com return $id; 1150Syaroslav@ivinco.com } 1160Syaroslav@ivinco.com 1170Syaroslav@ivinco.com $ns = explode(":", $id); 1180Syaroslav@ivinco.com $nsCount = count($ns); 1190Syaroslav@ivinco.com 1200Syaroslav@ivinco.com $result = ''; 1210Syaroslav@ivinco.com do{ 1220Syaroslav@ivinco.com for($i = 0; $i < $nsCount; $i++){ 1230Syaroslav@ivinco.com $name = $ns[$i]; 1240Syaroslav@ivinco.com $result .= $name; 1250Syaroslav@ivinco.com if ($i < $nsCount - 1){ 1260Syaroslav@ivinco.com $result .= ':'; 1270Syaroslav@ivinco.com } 1280Syaroslav@ivinco.com } 1290Syaroslav@ivinco.com $result .= ' '; 1300Syaroslav@ivinco.com }while($nsCount--); 1310Syaroslav@ivinco.com return $result; 1320Syaroslav@ivinco.com} 1330Syaroslav@ivinco.com 1340Syaroslav@ivinco.com 1350Syaroslav@ivinco.com /** 1360Syaroslav@ivinco.com * Method return all wiki page names 1370Syaroslav@ivinco.com * @global array $conf 1380Syaroslav@ivinco.com * @return array 1390Syaroslav@ivinco.com */ 1400Syaroslav@ivinco.com function getPagesList() 1410Syaroslav@ivinco.com { 1420Syaroslav@ivinco.com global $conf; 1430Syaroslav@ivinco.com 1440Syaroslav@ivinco.com $data = array(); 1450Syaroslav@ivinco.com sort($data); 1460Syaroslav@ivinco.com search($data,$conf['datadir'],'search_allpages','',''); 1470Syaroslav@ivinco.com 1480Syaroslav@ivinco.com return $data; 1490Syaroslav@ivinco.com} 1500Syaroslav@ivinco.com 1510Syaroslav@ivinco.com/** 1520Syaroslav@ivinco.com * Array 1530Syaroslav@ivinco.com( 1540Syaroslav@ivinco.com [date] => Array 1550Syaroslav@ivinco.com ( 1560Syaroslav@ivinco.com [created] => 1239181434 1570Syaroslav@ivinco.com [modified] => 1239202933 1580Syaroslav@ivinco.com ) 1590Syaroslav@ivinco.com 1600Syaroslav@ivinco.com [creator] => Sergey Nikolaev 1610Syaroslav@ivinco.com [last_change] => Array 1620Syaroslav@ivinco.com ( 1630Syaroslav@ivinco.com [date] => 1239202933 1640Syaroslav@ivinco.com [ip] => 85.118.229.162 1650Syaroslav@ivinco.com [type] => E 1660Syaroslav@ivinco.com [id] => cal:minutes:boardreader:200904:20090408 1670Syaroslav@ivinco.com [user] => snikolaev 1680Syaroslav@ivinco.com [sum] => 1690Syaroslav@ivinco.com [extra] => 1700Syaroslav@ivinco.com ) 1710Syaroslav@ivinco.com 1720Syaroslav@ivinco.com [contributor] => Array 1730Syaroslav@ivinco.com ( 1740Syaroslav@ivinco.com [snikolaev] => Sergey Nikolaev 1750Syaroslav@ivinco.com ) 1760Syaroslav@ivinco.com 1770Syaroslav@ivinco.com [title] => BoardReader call of Apr 8 2009 1780Syaroslav@ivinco.com [description] => Array 1790Syaroslav@ivinco.com ( 1800Syaroslav@ivinco.com [tableofcontents] => Array 1810Syaroslav@ivinco.com ( 1820Syaroslav@ivinco.com [0] => Array 1830Syaroslav@ivinco.com ( 1840Syaroslav@ivinco.com [hid] => boardreader_call_of_apr_8_2009 1850Syaroslav@ivinco.com [title] => BoardReader call of Apr 8 2009 1860Syaroslav@ivinco.com [type] => ul 1870Syaroslav@ivinco.com [level] => 1 1880Syaroslav@ivinco.com ) 1890Syaroslav@ivinco.com 1900Syaroslav@ivinco.com [1] => Array 1910Syaroslav@ivinco.com ( 1920Syaroslav@ivinco.com [hid] => sergey 1930Syaroslav@ivinco.com [title] => Sergey 1940Syaroslav@ivinco.com [type] => ul 1950Syaroslav@ivinco.com [level] => 2 1960Syaroslav@ivinco.com ) 1970Syaroslav@ivinco.com 1980Syaroslav@ivinco.com [2] => Array 1990Syaroslav@ivinco.com ( 2000Syaroslav@ivinco.com [hid] => slava 2010Syaroslav@ivinco.com [title] => Slava 2020Syaroslav@ivinco.com [type] => ul 2030Syaroslav@ivinco.com [level] => 2 2040Syaroslav@ivinco.com ) 2050Syaroslav@ivinco.com 2060Syaroslav@ivinco.com [3] => Array 2070Syaroslav@ivinco.com ( 2080Syaroslav@ivinco.com [hid] => roman 2090Syaroslav@ivinco.com [title] => Roman 2100Syaroslav@ivinco.com [type] => ul 2110Syaroslav@ivinco.com [level] => 2 2120Syaroslav@ivinco.com ) 2130Syaroslav@ivinco.com 2140Syaroslav@ivinco.com [4] => Array 2150Syaroslav@ivinco.com ( 2160Syaroslav@ivinco.com [hid] => nikita 2170Syaroslav@ivinco.com [title] => Nikita 2180Syaroslav@ivinco.com [type] => ul 2190Syaroslav@ivinco.com [level] => 2 2200Syaroslav@ivinco.com ) 2210Syaroslav@ivinco.com 2220Syaroslav@ivinco.com [5] => Array 2230Syaroslav@ivinco.com ( 2240Syaroslav@ivinco.com [hid] => discussion 2250Syaroslav@ivinco.com [title] => Discussion 2260Syaroslav@ivinco.com [type] => ul 2270Syaroslav@ivinco.com [level] => 2 2280Syaroslav@ivinco.com ) 2290Syaroslav@ivinco.com 2300Syaroslav@ivinco.com ) 2310Syaroslav@ivinco.com 2320Syaroslav@ivinco.com [abstract] => Participants: Mindaugas, Sergey, Slava, Roman, Nikita 2330Syaroslav@ivinco.com 2340Syaroslav@ivinco.comDuration: 23 min 2350Syaroslav@ivinco.com 2360Syaroslav@ivinco.comSergey 2370Syaroslav@ivinco.com 2380Syaroslav@ivinco.comStatus: 2390Syaroslav@ivinco.com 2400Syaroslav@ivinco.com * published Roman's changes 2410Syaroslav@ivinco.com * started reviewing Slava's changes 2420Syaroslav@ivinco.com 2430Syaroslav@ivinco.com 2440Syaroslav@ivinco.comPlans: 2450Syaroslav@ivinco.com 2460Syaroslav@ivinco.com * start altering (singature field) 2470Syaroslav@ivinco.com * select server error handling 2480Syaroslav@ivinco.com * publish Slava's and Roman's changes 2490Syaroslav@ivinco.com ) 2500Syaroslav@ivinco.com 2510Syaroslav@ivinco.com [internal] => Array 2520Syaroslav@ivinco.com ( 2530Syaroslav@ivinco.com [cache] => 1 2540Syaroslav@ivinco.com [toc] => 1 2550Syaroslav@ivinco.com ) 2560Syaroslav@ivinco.com 2570Syaroslav@ivinco.com) 2580Syaroslav@ivinco.com 2590Syaroslav@ivinco.com */ 2600Syaroslav@ivinco.com 261