function get_item_image($s_item_type, $item_id = NULL) { if (strlen($s_item_type) > 0 || ($s_item_type = fetch_item_type($item_id))) { $item_type_r = fetch_item_type_r($s_item_type); if (is_array($item_type_r)) { // default $imagetext = $s_item_type; // Get image block. if (strlen($item_type_r['image']) > 0) { if (strlen($item_type_r['description']) > 0) { $title_text = htmlspecialchars($item_type_r['description']); } else { $title_text = NULL; } $imagetext = theme_image($item_type_r['image'], $title_text, 's_item_type'); } return $imagetext; } } return FALSE; }
function writeRowImpl($row_column_rs) { if ($this->_toggle) { $this->rowclass = "oddRow"; } else { $this->rowclass = "evenRow"; } $this->_write("\n<tr class=\"" . $this->rowclass . "\">"); for ($i = 0; $i < count($row_column_rs); $i++) { $header_column_r = $this->_header_column_rs[$i]; $columnClass = NULL; if (strlen($header_column_r['fieldname']) > 0) { $columnClass = $header_column_r['fieldname']; } switch ($row_column_rs[$i]['column_type']) { case 'action_links': $this->_write('<td class="action_links ' . $columnClass . '">'); $this->_write(ifempty(format_action_links($row_column_rs[$i]['action_links']), get_opendb_lang_var('not_applicable'))); $this->_write('</td>'); break; case 'username': $this->_write('<td class="username ' . $columnClass . '">'); $user_id = $row_column_rs[$i]['user_id']; $fullname = $row_column_rs[$i]['fullname']; if ($user_id == get_opendb_session_var('user_id')) { $this->_write(get_opendb_lang_var('current_user', array('fullname' => $fullname, 'user_id' => $user_id))); } else { $user_name = get_opendb_lang_var('user_name', array('fullname' => $fullname, 'user_id' => $user_id)); if ($this->_include_href_links && is_user_granted_permission(PERM_VIEW_USER_PROFILE)) { $item_title = ''; // lets find the title column. for ($j = 0; $j < count($row_column_rs); $j++) { if ($row_column_rs[$j]['column_type'] == 'title') { $item_title = trim(strip_tags($row_column_rs[$j]['item_title'])); break; } } $url = "user_profile.php?uid=" . $user_id; if (is_array($row_column_rs[$i]['extra_http_vars'])) { $url .= "&" . get_url_string($row_column_rs[$i]['extra_http_vars']); } $url .= "&subject=" . urlencode(ifempty($item_title, get_opendb_lang_var('no_subject'))); $this->_write("<a href=\"{$url}\" title=\"" . htmlspecialchars(get_opendb_lang_var('user_profile')) . "\">{$user_name}</a>"); } else { $this->_write($user_name); } } $this->_write('</td>'); break; case 'interest': // opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, "_xajax=" . $_xajax===NULL?"nulles":"nonnul"); $item_id = $row_column_rs[$i]['item_id']; $instance_no = $row_column_rs[$i]['instance_no']; $level = $row_column_rs[$i]['level']; if ($level > 0) { $this->addHelpEntry(get_opendb_lang_var('interest_help'), 'interest_1.gif', 'interest'); $new_level_value = 0; $level_display .= "<img" . " id=\"interest_level_{$item_id}" . "_{$instance_no}\"" . " src=\"" . theme_image_src('interest_1.gif') . "\"" . " alt=\"" . get_opendb_lang_var('interest_remove') . "\"" . " title=\"" . get_opendb_lang_var('interest_remove') . "\"" . " onclick=\"xajax_ajax_update_interest_level('{$item_id}', '{$instance_no}', document.getElementById('new_level_value_{$item_id}\\_{$instance_no}').value);\"" . " style=\"cursor:pointer;\"" . " >"; } else { $new_level_value = 1; $level_display .= "<img" . " id=\"interest_level_{$item_id}" . "_{$instance_no}\"" . " src=\"" . theme_image_src('interest_0.gif') . "\"" . " alt=\"" . get_opendb_lang_var('interest_mark') . "\"" . " title=\"" . get_opendb_lang_var('interest_mark') . "\"" . " onclick=\"xajax_ajax_update_interest_level('{$item_id}','{$instance_no}', document.getElementById('new_level_value_{$item_id}\\_{$instance_no}').value);\"" . " style=\"cursor:pointer;\"" . " >"; } $this->_write('<td class="interest ' . $columnClass . '">'); $this->_write("<input id=\"new_level_value_{$item_id}" . "_{$instance_no}\" type=\"hidden\" value=\"{$new_level_value}\" />"); $this->_write($level_display); $this->_write('</td>'); break; case 'item_type_image': $this->_write('<td class="item_type_image ' . $columnClass . '">'); $s_item_type = $row_column_rs[$i]['s_item_type']; if (!is_array($this->_item_type_rs[$s_item_type]) || strlen($this->_item_type_rs[$s_item_type]['image']) == 0) { $this->_item_type_rs[$s_item_type] = fetch_item_type_r($s_item_type); // expand to the actual location once only. if (strlen($this->_item_type_rs[$s_item_type]['image']) > 0) { $this->_item_type_rs[$s_item_type]['image'] = theme_image_src($this->_item_type_rs[$s_item_type]['image']); } else { $this->_item_type_rs[$s_item_type]['image'] = 'none'; } if (strlen($this->_item_type_rs[$s_item_type]['description']) > 0) { $this->_item_type_rs[$s_item_type]['description'] = htmlspecialchars($this->_item_type_rs[$s_item_type]['description']); } else { $this->_item_type_rs[$s_item_type]['description'] = NULL; } } if (strlen($this->_item_type_rs[$s_item_type]['image']) > 0 && $this->_item_type_rs[$s_item_type]['image'] != 'none') { $this->_write(theme_image($this->_item_type_rs[$s_item_type]['image'], $this->_item_type_rs[$s_item_type]['description'], 's_item_type')); } else { // otherwise write the item type itself in place of the image. $this->_write($s_item_type); } $this->_write('</td>'); break; case 'theme_image': $this->_write('<td class="' . $columnClass . '">'); $this->_write(theme_image($row_column_rs[$i]['src'], htmlspecialchars($row_column_rs[$i]['title']), $row_column_rs[$i]['type'])); $this->_write('</td>'); break; case 'title': $title_href_link = $row_column_rs[$i]['title_href_link']; $is_item_reviewed = $row_column_rs[$i]['is_item_reviewed']; $is_borrowed_or_returned = $row_column_rs[$i]['is_borrowed_or_returned']; $item_title = ''; if ($this->_include_href_links && is_user_granted_permission(PERM_VIEW_ITEM_DISPLAY)) { $item_title = '<a href="' . $title_href_link . '">' . $row_column_rs[$i]['item_title'] . '</a>'; } else { $item_title = $row_column_rs[$i]['item_title']; } if ($is_item_reviewed) { // show star if rated - Add it to the actual title, so we can do a bit more with title masks $this->addHelpEntry(get_opendb_lang_var('item_reviewed'), 'rs.gif', 'item_reviewed'); $item_title .= theme_image('rs.gif', get_opendb_lang_var('item_reviewed'), 'item_reviewed'); } if ($is_borrowed_or_returned) { $this->addHelpEntry(get_opendb_lang_var('youve_borrow_or_return'), 'tick.gif', 'borrow_or_return'); $item_title .= theme_image("tick.gif", get_opendb_lang_var('youve_borrow_or_return'), 'borrow_or_return'); // show tick if previously borrowed or returned. } $this->_write('<td class="title ' . $columnClass . '">'); $this->_write($item_title); $this->_write('</td>'); break; case 'coverimage': $item_cover_image = $row_column_rs[$i]['item_cover_image']; $title_href_link = $row_column_rs[$i]['title_href_link']; $this->_write('<td class="coverimage ' . $columnId . 'Column">'); $file_r = file_cache_get_image_r($item_cover_image, 'listing'); if (is_array($file_r)) { $cover_image_tag = '<img src="' . $file_r['thumbnail']['url'] . '"'; if (is_numeric($file_r['thumbnail']['width'])) { $cover_image_tag .= ' width="' . $file_r['thumbnail']['width'] . '"'; } if (is_numeric($file_r['thumbnail']['height'])) { $cover_image_tag .= ' height="' . $file_r['thumbnail']['height'] . '"'; } $cover_image_tag .= '>'; if ($this->_mode != 'printable' && $this->_include_href_links) { $cover_image_tag = '<a href="' . $title_href_link . '">' . $cover_image_tag . '</a>'; } $this->_write($cover_image_tag); } $this->_write('</td>'); break; case 'display': $this->_write('<td class="' . $columnClass . '">'); $this->_write(get_display_field($row_column_rs[$i]['attribute_type'], $row_column_rs[$i]['prompt'], $row_column_rs[$i]['display_type'], $row_column_rs[$i]['value'], FALSE)); $this->_write('</td>'); break; case 'attribute_display': $this->_write('<td class="' . $columnClass . '">'); $this->_write(get_item_display_field($row_column_rs[$i]['item_r'], $row_column_rs[$i]['attribute_type_r'], $row_column_rs[$i]['value'], FALSE)); $this->_write('</td>'); break; case 'checkbox': $this->_write('<td class="checkbox">'); $value = $row_column_rs[$i]['value']; $this->_write('<input type="checkbox" class="checkbox" name="' . $this->_header_column_rs[$i]['fieldname'] . '[]" value="' . $value . '">'); $this->_write('</td>'); break; default: $this->_write('<td class="' . $columnClass . '">'); $this->_write($row_column_rs[$i]['value']); $this->_write('</td>'); break; } } $this->_write("\n</tr>"); }
function get_search_query_matrix($HTTP_VARS) { function get_match_type($match) { if ($match == 'word') { return get_opendb_lang_var('word_match'); } else { if ($match == 'partial') { return get_opendb_lang_var('partial_match'); } else { if ($match == 'exact') { return get_opendb_lang_var('exact_match'); } else { return NULL; } } } } $searches = array(); if (strlen($HTTP_VARS['title']) > 0) { // Default title match is exact match. $HTTP_VARS['title_match'] = ifempty($HTTP_VARS['title_match'], 'exact'); if ($HTTP_VARS['title_match'] == 'word' || $HTTP_VARS['title_match'] == 'partial') { if (is_null($HTTP_VARS['title_case'])) { $searches[] = array(prompt => get_opendb_lang_var('title') . ' (<em>' . get_match_type($HTTP_VARS['title_match']) . '</em>)', field => $HTTP_VARS['title']); } else { $searches[] = array(prompt => get_opendb_lang_var('title') . ' (<em>' . get_match_type($HTTP_VARS['title_match']) . ', ' . get_opendb_lang_var('case_sensitive') . '</em>)', field => $HTTP_VARS['title']); } } else { $searches[] = array(prompt => get_opendb_lang_var('title'), field => $HTTP_VARS['title']); } } if (strlen($HTTP_VARS['category']) > 0) { // If s_item_type defined, we can get at the s_attribute_type of the category value. if (strlen($HTTP_VARS['s_item_type']) > 0) { $attribute_type_r = fetch_sfieldtype_item_attribute_type_r($HTTP_VARS['s_item_type'], 'CATEGORY'); $searches[] = array(prompt => get_opendb_lang_var('category'), field => get_item_display_field(NULL, $attribute_type_r, $HTTP_VARS['category'], FALSE)); } else { $searches[] = array(prompt => get_opendb_lang_var('category'), field => $HTTP_VARS['category']); } } if (strlen($HTTP_VARS['owner_id']) > 0) { $username = fetch_user_name($HTTP_VARS['owner_id']); if (strlen($username) > 0) { $searches[] = array(prompt => get_opendb_lang_var('owner'), field => $username . ' (' . $HTTP_VARS['owner_id'] . ')'); } } if (strlen($HTTP_VARS['s_item_type_group']) > 0) { $searches[] = array(prompt => get_opendb_lang_var('s_item_type_group'), field => $HTTP_VARS['s_item_type_group']); } if (is_array($HTTP_VARS['s_item_type'])) { $field = ''; for ($i = 0; $i < count($HTTP_VARS['s_item_type']); $i++) { $item_type_r = fetch_item_type_r($HTTP_VARS['s_item_type'][$i]); $field .= theme_image($item_type_r['image'], $item_type_r['description'], 's_item_type'); } $searches[] = array(prompt => get_opendb_lang_var('s_item_type'), field => $field); } else { if (strlen($HTTP_VARS['s_item_type']) > 0) { $item_type_r = fetch_item_type_r($HTTP_VARS['s_item_type']); $searches[] = array(prompt => get_opendb_lang_var('s_item_type'), field => theme_image($item_type_r['image'], $item_type_r['description'], 's_item_type')); } } if (is_numeric($HTTP_VARS['rating'])) { $attribute_type_r = fetch_cached_attribute_type_r('S_RATING'); $searches[] = array(prompt => $attribute_type_r['prompt'], field => get_display_field($attribute_type_r['s_attribute_type'], NULL, 'review()', $HTTP_VARS['rating'], FALSE)); } $attribute_type_r = NULL; if (strlen($HTTP_VARS['attribute_type']) > 0) { $attribute_type_r = fetch_cached_attribute_type_r($HTTP_VARS['attribute_type']); if (is_not_empty_array($attribute_type_r)) { $attribute_type_r['listing_link_ind'] = 'N'; // Default title match is exact match. $HTTP_VARS['attr_match'] = ifempty($HTTP_VARS['attr_match'], 'exact'); // Special category search, but ignore if category variable actually specified. if (strlen($HTTP_VARS['category']) == 0 && strlen($HTTP_VARS['attribute_val']) > 0 && $HTTP_VARS['attr_match'] == 'category') { // We do not want the Listing Link to be added to this display field $searches[] = array(prompt => $attribute_type_r['prompt'], field => get_item_display_field(NULL, $attribute_type_r, stripslashes($HTTP_VARS['attribute_val']), FALSE)); } else { if (strlen($HTTP_VARS['attribute_val']) > 0) { $HTTP_VARS['attribute_val'] = stripslashes($HTTP_VARS['attribute_val']); if (starts_with($HTTP_VARS['attribute_val'], '"') && ends_with($HTTP_VARS['attribute_val'], '"')) { $HTTP_VARS['attribute_val'] = substr($HTTP_VARS['attribute_val'], 1, -1); } $search = ifempty(get_item_display_field(NULL, $attribute_type_r, $HTTP_VARS['attribute_val'], FALSE), $HTTP_VARS['attribute_val']); } else { if (strlen($HTTP_VARS['lookup_attribute_val']) > 0) { $search = get_item_display_field(NULL, $attribute_type_r, stripslashes($HTTP_VARS['lookup_attribute_val']), FALSE); } } if (!is_lookup_attribute_type($HTTP_VARS['attribute_type']) && $HTTP_VARS['attr_match'] != 'exact') { $searches[] = array(prompt => $attribute_type_r['prompt'] . ' (<em>' . get_match_type($HTTP_VARS['attr_match']) . '</em>)', field => $search); } else { $searches[] = array(prompt => $attribute_type_r['prompt'], field => $search); } } } //if(is_not_empty_array($attribute_type_r)) } else { if (strlen($HTTP_VARS['attribute_val']) > 0) { // specified a search term without attribute type, this is a global search. if (is_null($HTTP_VARS['attr_case'])) { $searches[] = array(prompt => get_opendb_lang_var('attribute_val') . ' (<em>' . get_match_type(ifempty($HTTP_VARS['attr_match'], 'exact')) . '</em>)', field => stripslashes($HTTP_VARS['attribute_val'])); } else { $searches[] = array(prompt => get_opendb_lang_var('attribute_val') . ' (<em>' . get_match_type(ifempty($HTTP_VARS['attr_match'], 'exact')) . ', ' . get_opendb_lang_var('case_sensitive') . '</em>)', field => stripslashes($HTTP_VARS['attribute_val'])); } } } // add another search field if update_on value also specified. if (strlen($HTTP_VARS['attr_update_on']) > 0) { if (is_not_empty_array($attribute_type_r)) { $prompt = get_opendb_lang_var('attribute_prompt_updated', array('s_attribute_type' => $attribute_type_r['s_attribute_type'], 'prompt' => $attribute_type_r['prompt'])); } else { $prompt = get_opendb_lang_var('attributes_updated'); } if (strlen($HTTP_VARS['datetimemask']) > 0) { $searches[] = array(prompt => $prompt, field => $HTTP_VARS['attr_update_on'] . ' (' . $HTTP_VARS['datetimemask'] . ')'); } else { $searches[] = array(prompt => $prompt, field => $HTTP_VARS['attr_update_on']); } } else { if (is_numeric($HTTP_VARS['attr_update_on_days'])) { if (is_not_empty_array($attribute_type_r)) { $prompt = get_opendb_lang_var('attribute_prompt_updated', array('s_attribute_type' => $attribute_type_r['s_attribute_type'], 'prompt' => $attribute_type_r['prompt'])); } else { $prompt = get_opendb_lang_var('attributes_updated'); } if ($HTTP_VARS['attr_update_on_days'] == '1') { $field = get_opendb_lang_var('one_day_ago'); } else { if ($HTTP_VARS['attr_update_on_days'] == '7') { $field = get_opendb_lang_var('one_week_ago'); } else { if ($HTTP_VARS['attr_update_on_days'] == '28') { $field = get_opendb_lang_var('one_month_ago'); } else { if ($HTTP_VARS['attr_update_on_days'] == '365') { $field = get_opendb_lang_var('one_year_ago'); } } } } $searches[] = array(prompt => $prompt, field => $field); } } if (strlen($HTTP_VARS['update_on']) > 0) { if (strlen($HTTP_VARS['datetimemask']) > 0) { $searches[] = array(prompt => get_opendb_lang_var('updated'), field => $HTTP_VARS['update_on'] . ' (' . $HTTP_VARS['datetimemask'] . ')'); } else { $searches[] = array(prompt => get_opendb_lang_var('updated'), field => $HTTP_VARS['update_on']); } } else { if (is_numeric($HTTP_VARS['update_on_days'])) { if ($HTTP_VARS['update_on_days'] == '1') { $field = get_opendb_lang_var('one_day_ago'); } else { if ($HTTP_VARS['update_on_days'] == '7') { $field = get_opendb_lang_var('one_week_ago'); } else { if ($HTTP_VARS['update_on_days'] == '28') { $field = get_opendb_lang_var('one_month_ago'); } else { if ($HTTP_VARS['update_on_days'] == '365') { $field = get_opendb_lang_var('one_year_ago'); } } } } $searches[] = array(prompt => get_opendb_lang_var('updated'), field => $field); } } if (is_not_empty_array($HTTP_VARS['s_status_type']) > 0) { $search = ''; for ($i = 0; $i < count($HTTP_VARS['s_status_type']); $i++) { if (strlen($search) > 0) { $search .= ' '; } $status_type_r = fetch_status_type_r($HTTP_VARS['s_status_type'][$i]); if (is_not_empty_array($status_type_r)) { $search .= format_display_value('%img%', $status_type_r['img'], 'Y', $status_type_r['description'], 's_status_type'); } } if (strlen($search) > 0) { $searches[] = array(prompt => get_opendb_lang_var('s_status_type'), field => $search); } } if (strlen($HTTP_VARS['status_comment']) > 0) { // Default status_comment match is exact match. $HTTP_VARS['status_comment_match'] = ifempty($HTTP_VARS['status_comment_match'], 'exact'); if ($HTTP_VARS['status_comment_match'] == 'word' || $HTTP_VARS['status_comment_match'] == 'partial' || $HTTP_VARS['status_comment_match'] == 'exact') { if (is_null($HTTP_VARS['status_comment_case'])) { $searches[] = array(prompt => get_opendb_lang_var('status_comment') . ' (<em>' . get_match_type($HTTP_VARS['status_comment_match']) . '</em>)', field => $HTTP_VARS['status_comment']); } else { $searches[] = array(prompt => get_opendb_lang_var('status_comment') . ' (<em>' . get_match_type($HTTP_VARS['status_comment_match']) . ', ' . get_opendb_lang_var('case_sensitive') . '</em>)', field => $HTTP_VARS['status_comment']); } } else { $searches[] = array(prompt => get_opendb_lang_var('status_comment'), field => $HTTP_VARS['status_comment']); } } if (is_numeric($HTTP_VARS['interest_level']) && $HTTP_VARS['interest_level'] > 0) { $searches[] = array(prompt => get_opendb_lang_var('interest'), field => theme_image("interest_1.gif", get_opendb_lang_var('interest'), 's_item_type')); } return $searches; }
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; }