@@ -148,17 +148,28 @@ public function get_nodes_from_json($book_id=0, $json='', $prefix='') {
148
148
$ version = $ CI ->versions ->get_single ($ page ->content_id , $ page ->recent_version_id , null , false );
149
149
if (empty ($ version )) continue ;
150
150
$ types = $ modifier ['content-types ' ];
151
+ $ parent_or_child = (isset ($ modifier ['relationship ' ]) && 'parent ' ==$ modifier ['relationship ' ]) ? 'parent ' : 'child ' ;
151
152
$ content = array ();
152
153
foreach ($ types as $ type ) {
153
154
$ type_p = $ type .'s ' ;
154
155
if ($ type_p == 'replys ' ) $ type_p = 'replies ' ;
155
156
if (!isset ($ CI ->$ type_p ) || 'object ' !=gettype ($ CI ->$ type_p )) $ CI ->load ->model ($ type .'_model ' ,$ type_p );
156
- $ items = $ CI ->$ type_p ->get_children ($ version ->version_id , '' , '' , true , null );
157
- foreach ($ items as $ item ) {
158
- $ page = $ CI ->pages ->get ($ item ->child_content_id );
159
- $ page ->versions = array ();
160
- $ page ->versions [] = $ CI ->versions ->get_single ($ page ->content_id , $ page ->recent_version_id , null , true );
161
- $ content [] = $ page ;
157
+ if ('child ' == $ parent_or_child ) {
158
+ $ items = $ CI ->$ type_p ->get_children ($ version ->version_id , '' , '' , true , null );
159
+ foreach ($ items as $ item ) {
160
+ $ page = $ CI ->pages ->get ($ item ->child_content_id );
161
+ $ page ->versions = array ();
162
+ $ page ->versions [] = $ CI ->versions ->get_single ($ page ->content_id , $ page ->recent_version_id , null , true );
163
+ $ content [] = $ page ;
164
+ }
165
+ } else {
166
+ $ items = $ CI ->$ type_p ->get_parents ($ version ->version_id , '' , '' , true , null );
167
+ foreach ($ items as $ item ) {
168
+ $ page = $ CI ->pages ->get ($ item ->parent_content_id );
169
+ $ page ->versions = array ();
170
+ $ page ->versions [] = $ CI ->versions ->get_single ($ page ->content_id , $ page ->recent_version_id , null , true );
171
+ $ content [] = $ page ;
172
+ }
162
173
}
163
174
}
164
175
$ contents = $ this ->combine_by_operator ($ contents , $ content , $ operator );
@@ -343,10 +354,11 @@ public function get_latlng_from_item($item) {
343
354
public function combine_by_operator ($ contents , $ content , $ operator ) {
344
355
345
356
switch ($ operator ) {
346
- case "and " :
357
+ case "and " : // exclusive
358
+ // TODO
359
+ return array_merge ($ contents , $ content );
360
+ default : // inclusive
347
361
return array_merge ($ contents , $ content );
348
- default : // or
349
- // TODO: "or" operator
350
362
}
351
363
352
364
}
0 commit comments