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 9*102Syaroslav@ivinco.com$deStatus = ini_get('display_errors'); 10*102Syaroslav@ivinco.comini_set('display_errors', 0); 110Syaroslav@ivinco.com/* Initialization */ 120Syaroslav@ivinco.com 131Syaroslav@ivinco.comif(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../../'); 140Syaroslav@ivinco.comif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 150Syaroslav@ivinco.com 160Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/init.php'); 170Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/common.php'); 180Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/events.php'); 190Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/parserutils.php'); 200Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/feedcreator.class.php'); 210Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/auth.php'); 220Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/pageutils.php'); 230Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/search.php'); 244Syaroslav@ivinco.comrequire_once(DOKU_INC.'inc/parser/parser.php'); 254Syaroslav@ivinco.com 260Syaroslav@ivinco.com 270Syaroslav@ivinco.comrequire_once(DOKU_PLUGIN.'sphinxsearch/PageMapper.php'); 286Syaroslav@ivinco.comrequire_once(DOKU_PLUGIN.'sphinxsearch/functions.php'); 290Syaroslav@ivinco.com 301Syaroslav@ivinco.comif (!file_exists(DOKU_INC.$conf['savedir']."/sphinxsearch/")){ 311Syaroslav@ivinco.com mkdir(DOKU_INC.$conf['savedir']."/sphinxsearch/"); 321Syaroslav@ivinco.com} 331Syaroslav@ivinco.com 340Syaroslav@ivinco.com$pagesList = getPagesList(); 350Syaroslav@ivinco.com 360Syaroslav@ivinco.comecho '<?xml version="1.0" encoding="utf-8"?> 370Syaroslav@ivinco.com<sphinx:docset> 380Syaroslav@ivinco.com 390Syaroslav@ivinco.com<sphinx:schema> 400Syaroslav@ivinco.com<sphinx:field name="title"/> 410Syaroslav@ivinco.com<sphinx:field name="body"/> 4280Syaroslav@ivinco.com<sphinx:field name="namespace"/> 4380Syaroslav@ivinco.com<sphinx:field name="pagename"/> 444Syaroslav@ivinco.com<sphinx:field name="level"/> 450Syaroslav@ivinco.com<sphinx:field name="modified"/> 464Syaroslav@ivinco.com<sphinx:attr name="level" type="int" bits="8" default="1"/> 470Syaroslav@ivinco.com</sphinx:schema> 480Syaroslav@ivinco.com'; 490Syaroslav@ivinco.com 500Syaroslav@ivinco.com$pageMapper = new PageMapper(); 510Syaroslav@ivinco.comforeach($pagesList as $row){ 520Syaroslav@ivinco.com $dokuPageId = $row['id']; 5311Syaroslav@ivinco.com resolve_pageid('',$page,$exists); 5411Syaroslav@ivinco.com if (empty($dokuPageId) || !$exists){ //do not include not exists page 5510Syaroslav@ivinco.com continue; 5610Syaroslav@ivinco.com } 570Syaroslav@ivinco.com //get meta data 5843Syaroslav@ivinco.com $metadata = p_get_metadata($dokuPageId); 5939Syaroslav@ivinco.com 604Syaroslav@ivinco.com $sections = getDocumentsByHeadings($dokuPageId, $metadata); 6117Syaroslav@ivinco.com 624Syaroslav@ivinco.com if (!empty($sections)){ 634Syaroslav@ivinco.com foreach($sections as $hid => $section){ 644Syaroslav@ivinco.com //parse meta data for headers, abstract, date, authors 654Syaroslav@ivinco.com $data = array(); 664Syaroslav@ivinco.com $data['id'] = crc32($dokuPageId.$hid); 6780Syaroslav@ivinco.com $data['namespace'] = getCategories($dokuPageId); 6880Syaroslav@ivinco.com $data['pagename'] = getPagename($dokuPageId); 694Syaroslav@ivinco.com $data['level'] = $section['level']; 704Syaroslav@ivinco.com $data['modified'] = $metadata['date']['modified']; 7119Syaroslav@ivinco.com $data['title'] = strip_tags($section['title_text']); 7256Syaroslav@ivinco.com $data['title_to_index'] = $section['title_to_index']; 7382Syaroslav@ivinco.com $data['body'] = $section['section']; //strip_tags(p_render('xhtml',p_get_instructions($section['section']),$info)); 740Syaroslav@ivinco.com 7599Syaroslav@ivinco.com //convert to utf-8 encoding 7699Syaroslav@ivinco.com $data['title_to_index'] = mb_convert_encoding($data['title_to_index'], "UTF-8", mb_detect_encoding($data['title_to_index'], "auto")); 7799Syaroslav@ivinco.com $data['body'] = mb_convert_encoding($data['body'], "UTF-8", mb_detect_encoding($data['body'], "auto")); 7899Syaroslav@ivinco.com 794Syaroslav@ivinco.com echo formatXml($data)."\n"; 8056Syaroslav@ivinco.com $pageMapper->add($dokuPageId, $data['title'], $section['title'], $hid); 814Syaroslav@ivinco.com } 8243Syaroslav@ivinco.com } else { 8343Syaroslav@ivinco.com $data = array(); 8443Syaroslav@ivinco.com $data['id'] = crc32($dokuPageId); 8580Syaroslav@ivinco.com $data['namespace'] = getCategories($dokuPageId); 8680Syaroslav@ivinco.com $data['pagename'] = getPagename($dokuPageId); 8743Syaroslav@ivinco.com $data['level'] = 1; 8843Syaroslav@ivinco.com $data['modified'] = $metadata['date']['modified']; 8943Syaroslav@ivinco.com $data['title'] = strip_tags($metadata['title']); 9056Syaroslav@ivinco.com $data['title_to_index'] = $metadata['title']; 9168Syaroslav@ivinco.com $data['body'] = io_readFile(wikiFN($dokuPageId)); //strip_tags(p_wiki_xhtml($dokuPageId,$metadata['date']['modified'],false)); 9243Syaroslav@ivinco.com 9399Syaroslav@ivinco.com //convert to utf-8 encoding 9499Syaroslav@ivinco.com $data['title_to_index'] = mb_convert_encoding($data['title_to_index'], "UTF-8", mb_detect_encoding($data['title_to_index'], "auto")); 9599Syaroslav@ivinco.com $data['body'] = mb_convert_encoding($data['body'], "UTF-8", mb_detect_encoding($data['body'], "auto")); 9699Syaroslav@ivinco.com 9743Syaroslav@ivinco.com echo formatXml($data)."\n"; 9843Syaroslav@ivinco.com $pageMapper->add($dokuPageId, $metadata['title'], $metadata['title']); 9943Syaroslav@ivinco.com } 10012Syaroslav@ivinco.com 1010Syaroslav@ivinco.com} 10217Syaroslav@ivinco.comecho '</sphinx:docset>'; 103*102Syaroslav@ivinco.com 104*102Syaroslav@ivinco.comini_set('display_errors', $deStatus);