public function titleSearch($params_r) { $titleMaskCfg = new TitleMask('item_listing'); // if no limit provided, provide one! if (empty($params_r['limit'])) { $params_r['limit'] = 10; } if (empty($params_r['title_match'])) { $params_r['title_match'] = 'partial'; } $results = fetch_item_listing_rs($params_r, array(), 'title', 'ASC', 0, $params_r['limit']); while ($item_r = db_fetch_assoc($results)) { $item_r['title'] = $titleMaskCfg->expand_item_title($item_r); $jsonResults[] = $item_r; } db_free_result($results); return $jsonResults; }
function fetch_available_item_parents($HTTP_VARS, $item_r, $filter = null, $include_parents = true) { $current_parents = array(); if ($HTTP_VARS['parent_item_id'] > 0) { $current_parents[] = $HTTP_VARS['parent_item_id']; } else { $parent_instance_rs = fetch_item_instance_relationship_rs($item_r['item_id'], $item_r['instance_no'], RELATED_PARENTS_MODE); if ($parent_instance_rs !== false) { foreach ($parent_instance_rs as $parent_instance_r) { $current_parents[] = $parent_instance_r['item_id']; } } db_free_result($parent_instance_rs); } $children_rs = fetch_item_instance_relationship_rs($item_r['item_id'], $item_r['instance_no']); $children = array(); while ($child = db_fetch_assoc($children_rs)) { $children[] = $child; } db_free_result($children_rs); $items = array(); if (is_null($filter)) { // Fetch every item. $items_rs = fetch_item_listing_rs(null, null, 'title', 'asc'); } elseif ($filter == '%parent_only%') { // Fetch parent items only. foreach ($current_parents as $parent) { $item = fetch_item_r($parent); $item['current_parent'] = true; $items[] = $item; } return $items; } else { // Filter items. $items_rs = fetch_item_listing_rs(array('title' => $filter, 'title_match' => 'partial'), array(), 'title', 'asc'); } while ($item = db_fetch_assoc($items_rs)) { if ($item['item_id'] != $item_r['item_id']) { $is_child = false; foreach ($children as $child) { if ($item['item_id'] == $child['item_id']) { $is_child = true; } } if (!$is_child) { foreach ($current_parents as $parent) { if ($item['item_id'] == $parent) { $item['current_parent'] = true; } } } if (!$item['current_parent'] || $item['current_parent'] && $include_parents) { $items[] = $item; } } } db_free_result($items_rs); return $items; }
$listingObject = new HTML_Listing($PHP_SELF, $HTTP_VARS); $listingObject->startListing($page_title); if ($show_checkbox_column) { $listingObject->addHeaderColumn(NULL, 'item_id_instance_no', FALSE, 'checkbox'); } for ($i = 0; $i < count($v_column_display_config_rs); $i++) { if ($v_column_display_config_rs[$i]['include_in_listing'] !== FALSE) { $listingObject->addHeaderColumn($v_column_display_config_rs[$i]['prompt'], $v_column_display_config_rs[$i]['fieldname'], $v_column_display_config_rs[$i]['orderby_support_ind'] === 'Y'); } } // If no items Per Page - we are listing everything. if (is_numeric($listingObject->getItemsPerPage())) { $listingObject->setTotalItems(fetch_item_listing_cnt($HTTP_VARS, $v_column_display_config_rs)); } // -------------------------------------- Process the Query here ----------------------------------------------------------------- if ($result = fetch_item_listing_rs($HTTP_VARS, $v_column_display_config_rs, $listingObject->getCurrentOrderBy(), $listingObject->getCurrentSortOrder(), $listingObject->getStartIndex(), $listingObject->getItemsPerPage())) { // ---------------------------------------------------------------------------- // Save current url string, so we can return to last listings page if required. // ---------------------------------------------------------------------------- // The Listing class has already removed any $HTTP_VARS which should not // be passed onto the next request. $v_listing_url_vars = $HTTP_VARS; $v_listing_url_vars['mode'] = NULL; // These are listing specific - we do not want to save them. $v_listing_url_vars['item_id_instance_no'] = NULL; $v_listing_url_vars['checked_item_id_instance_no'] = NULL; $v_listing_url_vars['checked_item_id_instance_no_list'] = NULL; register_opendb_session_var('listing_url_vars', $v_listing_url_vars); while ($item_r = db_fetch_assoc($result)) { $listingObject->startRow(); // Get the Status Type config for the current item_instance.s_status_type, but grab it once.
function get_last_num_items_rs($num_of_items, $owner_id = NULL, $s_item_type = NULL, $update_on = NULL, $not_owner_id = NULL, $site_url_prefix = NULL, $title_mask_id = NULL) { if (strlen($owner_id) > 0) { $search_vars_r['owner_id'] = $owner_id; } if (strlen($s_item_type) > 0) { $search_vars_r['s_item_type'] = $s_item_type; } if (strlen($update_on) > 0) { $search_vars_r['update_on'] = $update_on; } if (strlen($not_owner_id) > 0) { $search_vars_r['not_owner_id'] = $not_owner_id; } $dummy_r = NULL; $results = fetch_item_listing_rs($search_vars_r, $dummy_r, 'update_on', 'DESC', 0, $num_of_items); if ($results) { if ($title_mask_id == 'feeds') { $title_mask_group = array('feeds', 'item_display'); } else { $title_mask_group = array('last_items_list', 'item_listing'); } $titleMaskCfg = new TitleMask($title_mask_group); $image_attribute_type_rs = NULL; while ($item_r = db_fetch_assoc($results)) { $item_r['title'] = $titleMaskCfg->expand_item_title($item_r); $item_r['update_on'] = get_localised_timestamp(get_opendb_config_var('welcome.last_items_list', 'datetime_mask'), $item_r['update_on']); $item_r['item_display_url'] = 'item_display.php?item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no']; if ($site_url_prefix != NULL) { $item_r['item_display_url'] = $site_url_prefix . $item_r['item_display_url']; } $item_type_r = fetch_item_type_r($item_r['s_item_type']); $itemtypeimagesrc = theme_image_src($item_type_r['image']); $size = @getimagesize($itemtypeimagesrc); if (is_array($size)) { $item_r['itemtypeimage']['width'] = $size[0]; $item_r['itemtypeimage']['height'] = $size[1]; } $item_r['itemtypeimage']['url'] = $itemtypeimagesrc; if ($site_url_prefix != NULL) { $item_r['itemtypeimage']['url'] = $site_url_prefix . $item_r['itemtypeimage']['url']; } $item_r['itemtypeimage']['title'] = $item_type_r['description']; $item_r['itemtypeimage']['s_item_type'] = $item_r['s_item_type']; if (get_opendb_config_var('welcome.last_items_list', 'show_item_image') !== FALSE) { if (!is_array($image_attribute_type_rs) || !is_array($image_attribute_type_rs[$item_r['s_item_type']])) { $image_attribute_type_rs[$item_r['s_item_type']] = fetch_sfieldtype_item_attribute_type_r($item_r['s_item_type'], 'IMAGE'); } // of a IMAGE s_attribute defined for this s_item_type if (is_array($image_attribute_type_rs[$item_r['s_item_type']])) { $attribute_type_r = $image_attribute_type_rs[$item_r['s_item_type']]; $imageurl = fetch_attribute_val($item_r['item_id'], NULL, $attribute_type_r['s_attribute_type']); $file_r = file_cache_get_image_r($imageurl, 'display'); $item_r['imageurl']['url'] = $file_r['thumbnail']['url']; if ($site_url_prefix != NULL) { $item_r['imageurl']['url'] = $site_url_prefix . $item_r['imageurl']['url']; } $item_r['imageurl']['width'] = $file_r['thumbnail']['width']; $item_r['imageurl']['height'] = $file_r['thumbnail']['height']; $item_r['imageurl']['title'] = $item_r['title']; } } $item_rs[] = $item_r; unset($item_r); } //while db_free_result($results); } return $item_rs; }