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> 45124Syaroslav@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 } 62127Syaroslav@ivinco.com if (!empty($conf['hidepages'])){ 63127Syaroslav@ivinco.com //check hidepages pattern to exclude hidden pages 64127Syaroslav@ivinco.com $testName = ':'.$dokuPageId; 65127Syaroslav@ivinco.com if (preg_match("/".$conf['hidepages']."/", $testName)){ 66127Syaroslav@ivinco.com continue; 67127Syaroslav@ivinco.com } 68126Syaroslav@ivinco.com } 69130Syaroslav@ivinco.com 700Syaroslav@ivinco.com //get meta data 71124Syaroslav@ivinco.com $metadata = p_get_metadata($dokuPageId); 72124Syaroslav@ivinco.com 734Syaroslav@ivinco.com $sections = getDocumentsByHeadings($dokuPageId, $metadata); 74124Syaroslav@ivinco.com 754Syaroslav@ivinco.com if (!empty($sections)){ 764Syaroslav@ivinco.com foreach($sections as $hid => $section){ 77124Syaroslav@ivinco.com if (empty($section['section'])){ 78124Syaroslav@ivinco.com continue; 79124Syaroslav@ivinco.com } 804Syaroslav@ivinco.com //parse meta data for headers, abstract, date, authors 814Syaroslav@ivinco.com $data = array(); 82121Syaroslav@ivinco.com $data['id'] = sprintf('%u', crc32($dokuPageId.$hid)); 8380Syaroslav@ivinco.com $data['namespace'] = getCategories($dokuPageId); 8480Syaroslav@ivinco.com $data['pagename'] = getPagename($dokuPageId); 854Syaroslav@ivinco.com $data['level'] = $section['level']; 864Syaroslav@ivinco.com $data['modified'] = $metadata['date']['modified']; 8719Syaroslav@ivinco.com $data['title'] = strip_tags($section['title_text']); 8856Syaroslav@ivinco.com $data['title_to_index'] = $section['title_to_index']; 8982Syaroslav@ivinco.com $data['body'] = $section['section']; //strip_tags(p_render('xhtml',p_get_instructions($section['section']),$info)); 900Syaroslav@ivinco.com 9199Syaroslav@ivinco.com //convert to utf-8 encoding 9299Syaroslav@ivinco.com $data['title_to_index'] = mb_convert_encoding($data['title_to_index'], "UTF-8", mb_detect_encoding($data['title_to_index'], "auto")); 9399Syaroslav@ivinco.com $data['body'] = mb_convert_encoding($data['body'], "UTF-8", mb_detect_encoding($data['body'], "auto")); 9499Syaroslav@ivinco.com 954Syaroslav@ivinco.com echo formatXml($data)."\n"; 9656Syaroslav@ivinco.com $pageMapper->add($dokuPageId, $data['title'], $section['title'], $hid); 974Syaroslav@ivinco.com } 9843Syaroslav@ivinco.com } else { 9943Syaroslav@ivinco.com $data = array(); 100*132Syaroslav@ivinco.com $data['id'] = sprintf('%u', crc32($dokuPageId)); 10180Syaroslav@ivinco.com $data['namespace'] = getCategories($dokuPageId); 10280Syaroslav@ivinco.com $data['pagename'] = getPagename($dokuPageId); 10343Syaroslav@ivinco.com $data['level'] = 1; 10443Syaroslav@ivinco.com $data['modified'] = $metadata['date']['modified']; 10543Syaroslav@ivinco.com $data['title'] = strip_tags($metadata['title']); 10656Syaroslav@ivinco.com $data['title_to_index'] = $metadata['title']; 10768Syaroslav@ivinco.com $data['body'] = io_readFile(wikiFN($dokuPageId)); //strip_tags(p_wiki_xhtml($dokuPageId,$metadata['date']['modified'],false)); 10843Syaroslav@ivinco.com 109124Syaroslav@ivinco.com if (empty($data['body'])){ 110124Syaroslav@ivinco.com continue; 111124Syaroslav@ivinco.com } 112124Syaroslav@ivinco.com 11399Syaroslav@ivinco.com //convert to utf-8 encoding 11499Syaroslav@ivinco.com $data['title_to_index'] = mb_convert_encoding($data['title_to_index'], "UTF-8", mb_detect_encoding($data['title_to_index'], "auto")); 11599Syaroslav@ivinco.com $data['body'] = mb_convert_encoding($data['body'], "UTF-8", mb_detect_encoding($data['body'], "auto")); 11699Syaroslav@ivinco.com 11743Syaroslav@ivinco.com echo formatXml($data)."\n"; 11843Syaroslav@ivinco.com $pageMapper->add($dokuPageId, $metadata['title'], $metadata['title']); 11943Syaroslav@ivinco.com } 120124Syaroslav@ivinco.com 1210Syaroslav@ivinco.com} 12217Syaroslav@ivinco.comecho '</sphinx:docset>'; 123102Syaroslav@ivinco.com 124*132Syaroslav@ivinco.comini_set('display_errors', $deStatus); 125