function &_fetch(&$counter, $params) { $result =& parent::_fetch($counter, $params); if (!count($result)) { return $result; } $parent_node_ids = array(); foreach ($result as $key => $data) { if (!isset($parent_node_ids[$data['parent_node_id']])) { $parent_node_ids[$data['parent_node_id']] = $data['parent_node_id']; } } $fetcher =& fetcher::instance(); $access_policy =& access_policy::instance(); $params = array('restrict_by_class' => false); $parents =& $fetcher->fetch_by_node_ids($parent_node_ids, 'site_object', $parents_counter, $params, 'fetch_by_ids'); foreach ($result as $key => $data) { $parent_data = $parents[$data['parent_node_id']]; $result[$key]['parent_title'] = $parent_data['title']; $result[$key]['parent_path'] = $parent_data['path']; } return $result; }
function &_fetch(&$counter, $params) { $limit = DEFAULT_RANDOM_LIMIT; if (isset($params['limit'])) { $limit = $params['limit']; unset($params['limit']); } if (!($all_objects =& parent::_fetch($counter, $params))) { return array(); } $result = array(); if ($limit >= count($all_objects)) { $limit = count($all_objects); } $max_index = count($all_objects) - 1; $indexes = array_keys($all_objects); while (count($result) < $limit) { $index = mt_rand(0, $max_index); if (!isset($result[$index])) { $result[$index] = $all_objects[$indexes[$index]]; } } return $result; }