public function getResultsForPresentation() { global $lng; $results = array(); $offset_counter = 0; $counter = 0; $objects_with_topics = array(); $objects_with_no_topcis = array(); foreach ($this->getResults() as $result) { if ($this->getMaxHits() * ($this->getResultPageNumber() - 1) > $offset_counter) { ++$offset_counter; continue; } $results[] = $result; ++$counter; if ($counter >= $this->getMaxHits()) { break; } } foreach ($this->getTopics() as $oTopic) { foreach ($results as $result) { $topic_id = ilPaymentObject::_lookupTopicId($result['ref_id']); if (!(int) $topic_id && !array_key_exists($result['ref_id'], $objects_with_no_topcis)) { $objects_with_no_topcis[$result['ref_id']] = $result; continue; } if ((int) $topic_id != $oTopic->getId()) { continue; } if (!array_key_exists($result['ref_id'], $objects_with_topics)) { $objects_with_topics[$result['ref_id']] = $result; } switch ($result['type']) { // learning material case "sahs": case "lm": case "dbk": case "htlm": $type = "lres"; break; default: $type = $result['type']; break; } $title = ilObject::_lookupTitle($result['obj_id']); $description = ilObject::_lookupDescription($result['obj_id']); $subtype = ''; if ($result['type'] == 'exc') { $check_sub = ilPaymentObject::_checkExcSubtype($result['ref_id']); $subtype = ' (' . $lng->txt($check_sub[0]) . ')'; } $presentation_results[$oTopic->getId()][$type][] = array('ref_id' => $result['ref_id'], 'title' => $title . ' ' . $subtype, 'description' => $description, 'type' => $result['type'], 'obj_id' => $result['obj_id'], 'topic_id' => $topic_id, 'child' => $result['child']); $this->addPresentationResult($presentation_results[$oTopic->getId()][$type][count($presentation_results[$oTopic->getId()][$type]) - 1]); } } foreach ($results as $result) { if (!array_key_exists($result['ref_id'], $objects_with_topics) && !array_key_exists($result['ref_id'], $objects_with_no_topcis)) { $objects_with_no_topcis[$result['ref_id']] = $result; } } foreach ($objects_with_no_topcis as $result) { switch ($result['type']) { // learning material case "sahs": case "lm": case "dbk": case "htlm": $type = "lres"; break; default: $type = $result['type']; break; } $title = ilObject::_lookupTitle($result['obj_id']); $description = ilObject::_lookupDescription($result['obj_id']); $presentation_results[0][$type][] = array('ref_id' => $result['ref_id'], 'title' => $title, 'description' => $description, 'type' => $result['type'], 'obj_id' => $result['obj_id'], 'child' => $result['child']); $this->addPresentationResult($presentation_results[0][$type][count($presentation_results[0][$type]) - 1]); } return $presentation_results ? $presentation_results : array(); }