resource_subjects; $subject_ids = split(",", $chosen_subjects); $limit = 5; $subject_titles = array(); $subjects_shown = false; // See if we can show any subjects foreach ($subject_ids as $sid) { $real_subj = getSubject($sid); if ($real_subj) $subject_titles[] = $real_subj->title; } if ($subject_titles && sizeof($subject_titles) > 0) { $subjects_shown = true; /*translation:Selected subjects*/ echo "
". elgg_echo("koolielu:widget_resources_view_allsubjects") .": " . implode(", ", $subject_titles) . "
"; } // if no subjects chosen, get subjects from profile if (count($subject_ids) == 1 && $subject_ids[0] == '') { $owner_guid = $vars['entity']->owner_guid; $owner = get_user($owner_guid); $owner_subjects = $owner->subjects; // if there's no subjects marked in profile, then get from all subjects if ($owner_subjects == '') { $resources = get_data("SELECT * FROM {$CONFIG->dbprefix}koolielu_waramu_resources WHERE koolielu_resource = 1 ORDER BY time DESC limit $limit;"); foreach ($resources as $resource) { $rid = $resource->waramu_id; try { $res = waramu_getResource('', $rid); echo elgg_view('object/waramuresource', array('entity' => $res, 'additional_icons' => false)); } catch ( Exception $e) { } } } else { if (is_string($owner_subjects)) { $owner_subjects = array($owner_subjects); } $subject_ids = $owner_subjects; } } // In case there were no subjects if (is_array($subject_ids) && !$subjects_shown) { foreach ($subject_ids as $sid) { $real_subj = getSubject($sid); if ($real_subj) $subject_titles[] = $real_subj->title; } if ($subject_titles && sizeof($subject_titles) > 0) { /*translation:Selected subjects*/ echo "
". elgg_echo("koolielu:widget_resources_view_allsubjects") .": " . implode(", ", $subject_titles) . "
"; } } if (!(count($subject_ids) == 1 && $subject_ids[0] == '')) { $resources = get_data("SELECT * FROM {$CONFIG->dbprefix}koolielu_waramu_resources WHERE koolielu_resource = 1 ORDER BY time DESC;"); $count = 0; foreach($resources as $resource) { if ($count < $limit) { try { $rid = $resource->waramu_id; $res = waramu_getResource('', $rid); $res_subjects = $res->getCurriculumSubjects(); $common_elements = array_intersect($res_subjects, $subject_ids); if (count($common_elements) > 0) { echo elgg_view('object/waramuresource', array('entity' => $res, 'additional_icons' => false)); $count = $count + 1; } } catch ( Exception $e ) { } } } } ?>