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> 450Syaroslav@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 6343Syaroslav@ivinco.com $metadata = p_get_metadata($dokuPageId); 6439Syaroslav@ivinco.com 654Syaroslav@ivinco.com $sections = getDocumentsByHeadings($dokuPageId, $metadata); 6617Syaroslav@ivinco.com 674Syaroslav@ivinco.com if (!empty($sections)){ 684Syaroslav@ivinco.com foreach($sections as $hid => $section){ 694Syaroslav@ivinco.com //parse meta data for headers, abstract, date, authors 704Syaroslav@ivinco.com $data = array(); 71*121Syaroslav@ivinco.com $data['id'] = sprintf('%u', crc32($dokuPageId.$hid)); 7280Syaroslav@ivinco.com $data['namespace'] = getCategories($dokuPageId); 7380Syaroslav@ivinco.com $data['pagename'] = getPagename($dokuPageId); 744Syaroslav@ivinco.com $data['level'] = $section['level']; 754Syaroslav@ivinco.com $data['modified'] = $metadata['date']['modified']; 7619Syaroslav@ivinco.com $data['title'] = strip_tags($section['title_text']); 7756Syaroslav@ivinco.com $data['title_to_index'] = $section['title_to_index']; 7882Syaroslav@ivinco.com $data['body'] = $section['section']; //strip_tags(p_render('xhtml',p_get_instructions($section['section']),$info)); 790Syaroslav@ivinco.com 8099Syaroslav@ivinco.com //convert to utf-8 encoding 8199Syaroslav@ivinco.com $data['title_to_index'] = mb_convert_encoding($data['title_to_index'], "UTF-8", mb_detect_encoding($data['title_to_index'], "auto")); 8299Syaroslav@ivinco.com $data['body'] = mb_convert_encoding($data['body'], "UTF-8", mb_detect_encoding($data['body'], "auto")); 8399Syaroslav@ivinco.com 844Syaroslav@ivinco.com echo formatXml($data)."\n"; 8556Syaroslav@ivinco.com $pageMapper->add($dokuPageId, $data['title'], $section['title'], $hid); 864Syaroslav@ivinco.com } 8743Syaroslav@ivinco.com } else { 8843Syaroslav@ivinco.com $data = array(); 89*121Syaroslav@ivinco.com $data['id'] = sprintf('%u', crc32($dokuPageId.$hid)); 9080Syaroslav@ivinco.com $data['namespace'] = getCategories($dokuPageId); 9180Syaroslav@ivinco.com $data['pagename'] = getPagename($dokuPageId); 9243Syaroslav@ivinco.com $data['level'] = 1; 9343Syaroslav@ivinco.com $data['modified'] = $metadata['date']['modified']; 9443Syaroslav@ivinco.com $data['title'] = strip_tags($metadata['title']); 9556Syaroslav@ivinco.com $data['title_to_index'] = $metadata['title']; 9668Syaroslav@ivinco.com $data['body'] = io_readFile(wikiFN($dokuPageId)); //strip_tags(p_wiki_xhtml($dokuPageId,$metadata['date']['modified'],false)); 9743Syaroslav@ivinco.com 9899Syaroslav@ivinco.com //convert to utf-8 encoding 9999Syaroslav@ivinco.com $data['title_to_index'] = mb_convert_encoding($data['title_to_index'], "UTF-8", mb_detect_encoding($data['title_to_index'], "auto")); 10099Syaroslav@ivinco.com $data['body'] = mb_convert_encoding($data['body'], "UTF-8", mb_detect_encoding($data['body'], "auto")); 10199Syaroslav@ivinco.com 10243Syaroslav@ivinco.com echo formatXml($data)."\n"; 10343Syaroslav@ivinco.com $pageMapper->add($dokuPageId, $metadata['title'], $metadata['title']); 10443Syaroslav@ivinco.com } 10512Syaroslav@ivinco.com 1060Syaroslav@ivinco.com} 10717Syaroslav@ivinco.comecho '</sphinx:docset>'; 108102Syaroslav@ivinco.com 109102Syaroslav@ivinco.comini_set('display_errors', $deStatus);