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 121Syaroslav@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'); 234Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/parser/parser.php'); 244Syaroslav@ivinco.com 250Syaroslav@ivinco.com 260Syaroslav@ivinco.comrequire_once(DOKU_PLUGIN.'sphinxsearch/PageMapper.php'); 276Syaroslav@ivinco.comrequire_once(DOKU_PLUGIN.'sphinxsearch/functions.php'); 280Syaroslav@ivinco.com 291Syaroslav@ivinco.comif (!file_exists(DOKU_INC.$conf['savedir']."/sphinxsearch/")){ 301Syaroslav@ivinco.com mkdir(DOKU_INC.$conf['savedir']."/sphinxsearch/"); 311Syaroslav@ivinco.com} 321Syaroslav@ivinco.com 330Syaroslav@ivinco.com$pagesList = getPagesList(); 340Syaroslav@ivinco.com 350Syaroslav@ivinco.comecho '<?xml version="1.0" encoding="utf-8"?> 360Syaroslav@ivinco.com<sphinx:docset> 370Syaroslav@ivinco.com 380Syaroslav@ivinco.com<sphinx:schema> 390Syaroslav@ivinco.com<sphinx:field name="title"/> 400Syaroslav@ivinco.com<sphinx:field name="body"/> 4180Syaroslav@ivinco.com<sphinx:field name="namespace"/> 4280Syaroslav@ivinco.com<sphinx:field name="pagename"/> 434Syaroslav@ivinco.com<sphinx:field name="level"/> 440Syaroslav@ivinco.com<sphinx:field name="modified"/> 454Syaroslav@ivinco.com<sphinx:attr name="level" type="int" bits="8" default="1"/> 460Syaroslav@ivinco.com</sphinx:schema> 470Syaroslav@ivinco.com'; 480Syaroslav@ivinco.com 490Syaroslav@ivinco.com$pageMapper = new PageMapper(); 500Syaroslav@ivinco.comforeach($pagesList as $row){ 510Syaroslav@ivinco.com $dokuPageId = $row['id']; 5211Syaroslav@ivinco.com resolve_pageid('',$page,$exists); 5311Syaroslav@ivinco.com if (empty($dokuPageId) || !$exists){ //do not include not exists page 5410Syaroslav@ivinco.com continue; 5510Syaroslav@ivinco.com } 560Syaroslav@ivinco.com //get meta data 5743Syaroslav@ivinco.com $metadata = p_get_metadata($dokuPageId); 5839Syaroslav@ivinco.com 594Syaroslav@ivinco.com $sections = getDocumentsByHeadings($dokuPageId, $metadata); 6017Syaroslav@ivinco.com 614Syaroslav@ivinco.com if (!empty($sections)){ 624Syaroslav@ivinco.com foreach($sections as $hid => $section){ 634Syaroslav@ivinco.com //parse meta data for headers, abstract, date, authors 644Syaroslav@ivinco.com $data = array(); 654Syaroslav@ivinco.com $data['id'] = crc32($dokuPageId.$hid); 6680Syaroslav@ivinco.com $data['namespace'] = getCategories($dokuPageId); 6780Syaroslav@ivinco.com $data['pagename'] = getPagename($dokuPageId); 684Syaroslav@ivinco.com $data['level'] = $section['level']; 694Syaroslav@ivinco.com $data['modified'] = $metadata['date']['modified']; 7019Syaroslav@ivinco.com $data['title'] = strip_tags($section['title_text']); 7156Syaroslav@ivinco.com $data['title_to_index'] = $section['title_to_index']; 72*82Syaroslav@ivinco.com $data['body'] = $section['section']; //strip_tags(p_render('xhtml',p_get_instructions($section['section']),$info)); 730Syaroslav@ivinco.com 744Syaroslav@ivinco.com echo formatXml($data)."\n"; 7556Syaroslav@ivinco.com $pageMapper->add($dokuPageId, $data['title'], $section['title'], $hid); 764Syaroslav@ivinco.com } 7743Syaroslav@ivinco.com } else { 7843Syaroslav@ivinco.com $data = array(); 7943Syaroslav@ivinco.com $data['id'] = crc32($dokuPageId); 8080Syaroslav@ivinco.com $data['namespace'] = getCategories($dokuPageId); 8180Syaroslav@ivinco.com $data['pagename'] = getPagename($dokuPageId); 8243Syaroslav@ivinco.com $data['level'] = 1; 8343Syaroslav@ivinco.com $data['modified'] = $metadata['date']['modified']; 8443Syaroslav@ivinco.com $data['title'] = strip_tags($metadata['title']); 8556Syaroslav@ivinco.com $data['title_to_index'] = $metadata['title']; 8668Syaroslav@ivinco.com $data['body'] = io_readFile(wikiFN($dokuPageId)); //strip_tags(p_wiki_xhtml($dokuPageId,$metadata['date']['modified'],false)); 8743Syaroslav@ivinco.com 8843Syaroslav@ivinco.com echo formatXml($data)."\n"; 8943Syaroslav@ivinco.com $pageMapper->add($dokuPageId, $metadata['title'], $metadata['title']); 9043Syaroslav@ivinco.com } 9112Syaroslav@ivinco.com 920Syaroslav@ivinco.com} 9317Syaroslav@ivinco.comecho '</sphinx:docset>'; 94