xref: /plugin/sphinxsearch-was/xmlall.php (revision 6:27deea028915)
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:field name="creator"/>
45<sphinx:attr name="level" type="int" bits="8" default="1"/>
46</sphinx:schema>
47';
48
49$pageMapper = new PageMapper();
50
51foreach($pagesList as $row){
52    $dokuPageId = $row['id'];
53    //get meta data
54    $metadata = p_get_metadata($dokuPageId);
55    $sections = getDocumentsByHeadings($dokuPageId, $metadata);
56    if (!empty($sections)){
57        foreach($sections as $hid => $section){
58            //parse meta data for headers, abstract, date, authors
59            $data = array();
60            $data['id'] = crc32($dokuPageId.$hid);
61            $data['categories'] = getCategories($dokuPageId) . '#' . $hid;
62            $data['level'] = $section['level'];
63            $data['modified'] = $metadata['date']['modified'];
64            $data['creator'] = $metadata['creator'];
65            $data['title'] = strip_tags($section['title']);
66            $data['body'] = strip_tags(p_render('xhtml',p_get_instructions($section['section']),$info));
67
68            echo formatXml($data)."\n";
69            $pageMapper->add($dokuPageId, $section['title'], $hid);
70        }
71    } else {
72        //parse meta data for headers, abstract, date, authors
73        $data = array();
74        $data['id'] = crc32($dokuPageId);
75        $data['categories'] = getCategories($dokuPageId);
76        $data['level'] = 1;
77        $data['modified'] = $metadata['date']['modified'];
78        $data['creator'] = $metadata['creator'];
79        $data['title'] = strip_tags($metadata['title']);
80        $data['body'] = strip_tags(p_wiki_xhtml($dokuPageId,$metadata['date']['modified'],false));
81
82        echo formatXml($data)."\n";
83        $pageMapper->add($dokuPageId, $metadata['title']);
84    }
85}
86
87echo '</sphinx:docset>';
88
89
90
91
92
93/**
94 * Array
95(
96    [date] => Array
97        (
98            [created] => 1239181434
99            [modified] => 1239202933
100        )
101
102    [creator] => Sergey Nikolaev
103    [last_change] => Array
104        (
105            [date] => 1239202933
106            [ip] => 85.118.229.162
107            [type] => E
108            [id] => cal:minutes:boardreader:200904:20090408
109            [user] => snikolaev
110            [sum] =>
111            [extra] =>
112        )
113
114    [contributor] => Array
115        (
116            [snikolaev] => Sergey Nikolaev
117        )
118
119    [title] => BoardReader call of Apr 8 2009
120    [description] => Array
121        (
122            [tableofcontents] => Array
123                (
124                    [0] => Array
125                        (
126                            [hid] => boardreader_call_of_apr_8_2009
127                            [title] => BoardReader call of Apr 8 2009
128                            [type] => ul
129                            [level] => 1
130                        )
131
132                    [1] => Array
133                        (
134                            [hid] => sergey
135                            [title] => Sergey
136                            [type] => ul
137                            [level] => 2
138                        )
139
140                    [2] => Array
141                        (
142                            [hid] => slava
143                            [title] => Slava
144                            [type] => ul
145                            [level] => 2
146                        )
147
148                    [3] => Array
149                        (
150                            [hid] => roman
151                            [title] => Roman
152                            [type] => ul
153                            [level] => 2
154                        )
155
156                    [4] => Array
157                        (
158                            [hid] => nikita
159                            [title] => Nikita
160                            [type] => ul
161                            [level] => 2
162                        )
163
164                    [5] => Array
165                        (
166                            [hid] => discussion
167                            [title] => Discussion
168                            [type] => ul
169                            [level] => 2
170                        )
171
172                )
173
174            [abstract] => Participants: Mindaugas, Sergey, Slava, Roman, Nikita
175
176Duration: 23 min
177
178Sergey
179
180Status:
181
182	*  published Roman's changes
183	*  started reviewing Slava's changes
184
185
186Plans:
187
188	*  start altering (singature field)
189	*  select server error handling
190	*  publish Slava's and Roman's changes
191        )
192
193    [internal] => Array
194        (
195            [cache] => 1
196            [toc] => 1
197        )
198
199)
200
201 */
202
203