Skip to content

Commit 32fddd5

Browse files
committed
Send Lens JSON, get items returned
1 parent 1b50921 commit 32fddd5

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

system/application/models/lens_model.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,28 @@ public function get_nodes_from_json($book_id=0, $json='', $prefix='') {
148148
$version = $CI->versions->get_single($page->content_id, $page->recent_version_id, null, false);
149149
if (empty($version)) continue;
150150
$types = $modifier['content-types'];
151+
$parent_or_child = (isset($modifier['relationship']) && 'parent'==$modifier['relationship']) ? 'parent' : 'child';
151152
$content = array();
152153
foreach ($types as $type) {
153154
$type_p = $type.'s';
154155
if ($type_p== 'replys') $type_p= 'replies';
155156
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+
}
162173
}
163174
}
164175
$contents = $this->combine_by_operator($contents, $content, $operator);
@@ -343,10 +354,11 @@ public function get_latlng_from_item($item) {
343354
public function combine_by_operator($contents, $content, $operator) {
344355

345356
switch ($operator) {
346-
case "and":
357+
case "and": // exclusive
358+
// TODO
359+
return array_merge($contents, $content);
360+
default: // inclusive
347361
return array_merge($contents, $content);
348-
default: // or
349-
// TODO: "or" operator
350362
}
351363

352364
}

0 commit comments

Comments
 (0)