1<?php 2/** 3 * XML feed export 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8 9 10/* Initialization */ 11 12if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../../'); 13if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 14 15require_once(DOKU_INC.'inc/init.php'); 16require_once(DOKU_INC.'inc/common.php'); 17require_once(DOKU_INC.'inc/events.php'); 18require_once(DOKU_INC.'inc/parserutils.php'); 19require_once(DOKU_INC.'inc/feedcreator.class.php'); 20require_once(DOKU_INC.'inc/auth.php'); 21require_once(DOKU_INC.'inc/pageutils.php'); 22require_once(DOKU_INC.'inc/search.php'); 23require_once(DOKU_INC.'inc/parser/parser.php'); 24 25 26require_once(DOKU_PLUGIN.'sphinxsearch/PageMapper.php'); 27require_once(DOKU_PLUGIN.'sphinxsearch/functions.php'); 28 29if (!file_exists(DOKU_INC.$conf['savedir']."/sphinxsearch/")){ 30 mkdir(DOKU_INC.$conf['savedir']."/sphinxsearch/"); 31} 32 33$pagesList = getPagesList(); 34 35echo '<?xml version="1.0" encoding="utf-8"?> 36<sphinx:docset> 37 38<sphinx:schema> 39<sphinx:field name="title"/> 40<sphinx:field name="body"/> 41<sphinx:field name="categories"/> 42<sphinx:field name="level"/> 43<sphinx:field name="modified"/> 44<sphinx:attr name="level" type="int" bits="8" default="1"/> 45</sphinx:schema> 46'; 47 48$pageMapper = new PageMapper(); 49foreach($pagesList as $row){ 50 $dokuPageId = $row['id']; 51 resolve_pageid('',$page,$exists); 52 if (empty($dokuPageId) || !$exists){ //do not include not exists page 53 continue; 54 } 55 //get meta data 56 $metadata = p_get_metadata($dokuPageId); 57 58 $sections = getDocumentsByHeadings($dokuPageId, $metadata); 59 60 if (!empty($sections)){ 61 foreach($sections as $hid => $section){ 62 //parse meta data for headers, abstract, date, authors 63 $data = array(); 64 $data['id'] = crc32($dokuPageId.$hid); 65 $data['categories'] = getCategories($dokuPageId) . '#' . $hid; 66 $data['level'] = $section['level']; 67 $data['modified'] = $metadata['date']['modified']; 68 $data['title'] = strip_tags($section['title_text']); 69 $data['title_to_index'] = $section['title_to_index']; 70 $data['body'] = $section['section']; //strip_tags(my_p_render('xhtml',p_get_instructions($section['section']),$info)); 71 72 echo formatXml($data)."\n"; 73 $pageMapper->add($dokuPageId, $data['title'], $section['title'], $hid); 74 } 75 } else { 76 $data = array(); 77 $data['id'] = crc32($dokuPageId); 78 $data['categories'] = getCategories($dokuPageId); 79 $data['level'] = 1; 80 $data['modified'] = $metadata['date']['modified']; 81 $data['title'] = strip_tags($metadata['title']); 82 $data['title_to_index'] = $metadata['title']; 83 $data['body'] = io_readFile(wikiFN($dokuPageId)); //strip_tags(p_wiki_xhtml($dokuPageId,$metadata['date']['modified'],false)); 84 85 echo formatXml($data)."\n"; 86 $pageMapper->add($dokuPageId, $metadata['title'], $metadata['title']); 87 } 88 89} 90echo '</sphinx:docset>'; 91