10Syaroslav@ivinco.com<?php 20Syaroslav@ivinco.com/** 30Syaroslav@ivinco.com * XML feed export 40Syaroslav@ivinco.com * 5118Syaroslav * @author Ivinco <opensource@ivinco.com> 60Syaroslav@ivinco.com */ 70Syaroslav@ivinco.com 8102Syaroslav@ivinco.com$deStatus = ini_get('display_errors'); 9102Syaroslav@ivinco.comini_set('display_errors', 0); 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 29119Syaroslav$dataPath = fullpath($conf['savedir']); 30119Syaroslavif (!@file_exists($dataPath)) { 31119Syaroslav $dataPath = fullpath(DOKU_INC . $conf['savedir']); 32119Syaroslav if (!@file_exists($dataPath)) die('invalid DokuWiki savedir'); 33119Syaroslav} 34119Syaroslav$fullSphinxPath = $dataPath . '/sphinxsearch/'; 35119Syaroslavif (!@file_exists($fullSphinxPath)) { 36119Syaroslav mkdir($fullSphinxPath); 371Syaroslav@ivinco.com} 381Syaroslav@ivinco.com 390Syaroslav@ivinco.com$pagesList = getPagesList(); 400Syaroslav@ivinco.com 410Syaroslav@ivinco.comecho '<?xml version="1.0" encoding="utf-8"?> 420Syaroslav@ivinco.com<sphinx:docset> 430Syaroslav@ivinco.com 440Syaroslav@ivinco.com<sphinx:schema> 45*124Syaroslav@ivinco.com<sphinx:field name="title"/> 460Syaroslav@ivinco.com<sphinx:field name="body"/> 4780Syaroslav@ivinco.com<sphinx:field name="namespace"/> 4880Syaroslav@ivinco.com<sphinx:field name="pagename"/> 494Syaroslav@ivinco.com<sphinx:field name="level"/> 500Syaroslav@ivinco.com<sphinx:field name="modified"/> 514Syaroslav@ivinco.com<sphinx:attr name="level" type="int" bits="8" default="1"/> 520Syaroslav@ivinco.com</sphinx:schema> 530Syaroslav@ivinco.com'; 540Syaroslav@ivinco.com 550Syaroslav@ivinco.com$pageMapper = new PageMapper(); 560Syaroslav@ivinco.comforeach($pagesList as $row){ 570Syaroslav@ivinco.com $dokuPageId = $row['id']; 5811Syaroslav@ivinco.com resolve_pageid('',$page,$exists); 5911Syaroslav@ivinco.com if (empty($dokuPageId) || !$exists){ //do not include not exists page 6010Syaroslav@ivinco.com continue; 6110Syaroslav@ivinco.com } 620Syaroslav@ivinco.com //get meta data 63*124Syaroslav@ivinco.com $metadata = p_get_metadata($dokuPageId); 64*124Syaroslav@ivinco.com 654Syaroslav@ivinco.com $sections = getDocumentsByHeadings($dokuPageId, $metadata); 66*124Syaroslav@ivinco.com 674Syaroslav@ivinco.com if (!empty($sections)){ 684Syaroslav@ivinco.com foreach($sections as $hid => $section){ 69*124Syaroslav@ivinco.com if (empty($section['section'])){ 70*124Syaroslav@ivinco.com continue; 71*124Syaroslav@ivinco.com } 724Syaroslav@ivinco.com //parse meta data for headers, abstract, date, authors 734Syaroslav@ivinco.com $data = array(); 74121Syaroslav@ivinco.com $data['id'] = sprintf('%u', crc32($dokuPageId.$hid)); 7580Syaroslav@ivinco.com $data['namespace'] = getCategories($dokuPageId); 7680Syaroslav@ivinco.com $data['pagename'] = getPagename($dokuPageId); 774Syaroslav@ivinco.com $data['level'] = $section['level']; 784Syaroslav@ivinco.com $data['modified'] = $metadata['date']['modified']; 7919Syaroslav@ivinco.com $data['title'] = strip_tags($section['title_text']); 8056Syaroslav@ivinco.com $data['title_to_index'] = $section['title_to_index']; 8182Syaroslav@ivinco.com $data['body'] = $section['section']; //strip_tags(p_render('xhtml',p_get_instructions($section['section']),$info)); 820Syaroslav@ivinco.com 8399Syaroslav@ivinco.com //convert to utf-8 encoding 8499Syaroslav@ivinco.com $data['title_to_index'] = mb_convert_encoding($data['title_to_index'], "UTF-8", mb_detect_encoding($data['title_to_index'], "auto")); 8599Syaroslav@ivinco.com $data['body'] = mb_convert_encoding($data['body'], "UTF-8", mb_detect_encoding($data['body'], "auto")); 8699Syaroslav@ivinco.com 874Syaroslav@ivinco.com echo formatXml($data)."\n"; 8856Syaroslav@ivinco.com $pageMapper->add($dokuPageId, $data['title'], $section['title'], $hid); 894Syaroslav@ivinco.com } 9043Syaroslav@ivinco.com } else { 9143Syaroslav@ivinco.com $data = array(); 92*124Syaroslav@ivinco.com $data['id'] = sprintf('%u', crc32($dokuPageId.$hid)); 9380Syaroslav@ivinco.com $data['namespace'] = getCategories($dokuPageId); 9480Syaroslav@ivinco.com $data['pagename'] = getPagename($dokuPageId); 9543Syaroslav@ivinco.com $data['level'] = 1; 9643Syaroslav@ivinco.com $data['modified'] = $metadata['date']['modified']; 9743Syaroslav@ivinco.com $data['title'] = strip_tags($metadata['title']); 9856Syaroslav@ivinco.com $data['title_to_index'] = $metadata['title']; 9968Syaroslav@ivinco.com $data['body'] = io_readFile(wikiFN($dokuPageId)); //strip_tags(p_wiki_xhtml($dokuPageId,$metadata['date']['modified'],false)); 10043Syaroslav@ivinco.com 101*124Syaroslav@ivinco.com if (empty($data['body'])){ 102*124Syaroslav@ivinco.com continue; 103*124Syaroslav@ivinco.com } 104*124Syaroslav@ivinco.com 10599Syaroslav@ivinco.com //convert to utf-8 encoding 10699Syaroslav@ivinco.com $data['title_to_index'] = mb_convert_encoding($data['title_to_index'], "UTF-8", mb_detect_encoding($data['title_to_index'], "auto")); 10799Syaroslav@ivinco.com $data['body'] = mb_convert_encoding($data['body'], "UTF-8", mb_detect_encoding($data['body'], "auto")); 10899Syaroslav@ivinco.com 10943Syaroslav@ivinco.com echo formatXml($data)."\n"; 11043Syaroslav@ivinco.com $pageMapper->add($dokuPageId, $metadata['title'], $metadata['title']); 11143Syaroslav@ivinco.com } 112*124Syaroslav@ivinco.com 1130Syaroslav@ivinco.com} 11417Syaroslav@ivinco.comecho '</sphinx:docset>'; 115102Syaroslav@ivinco.com 116102Syaroslav@ivinco.comini_set('display_errors', $deStatus);