function uc_option_image_values in Ubercart Option Images 7
Get the value to use for this instance
Parameters
$type: uc_attribute, uc_option, uc_product or uc_class
$ids: The instance ids of the object, since each row contains multiple ids, according to the specificity of the data If this is NULL, all objects of the given type will be returned
Return value
An array containing keys corresponding to the requested values. Each key's value is itself an array, containing value and is_default.
4 calls to uc_option_image_values()
- theme_uc_option_image_selected in ./
uc_option_image.theme.inc - @file Theme functions for displaying option images
- uc_option_image_form in ./
uc_option_image.module - Add a form element to allow the admin to insert a default image which applies to all options, unless an option is overridden.
- uc_option_image_form_uc_object_options_form_alter in ./
uc_option_image.module - Implements hook_uc_object_options_form_alter()
- _uc_option_image_modify_attributes in ./
uc_option_image.module
File
- ./
uc_option_image.module, line 596 - Allow store administrators to add images to attribute options.
Code
function uc_option_image_values($type, $ids) {
$query = db_select('uc_option_image', 'uoi');
$query
->fields('uoi');
foreach ($ids as $field => $id) {
if ($id) {
$or = db_or();
$or
->condition($field, $id);
$or
->condition($field, 0);
$query
->condition($or);
}
}
$result = $query
->execute();
$objects = array();
foreach ($result as $row) {
$objects[$row->type][] = $row;
}
$return = array();
foreach (array(
'fid',
'inline_active',
'inline_style',
'selected_active',
'selected_style',
) as $value) {
if (!empty($objects[$type]) && !empty($objects[$type][0]->{$value})) {
$return[$value] = array(
'value' => $objects[$type][0]->{$value},
'is_default' => FALSE,
);
}
else {
foreach (array(
'uc_product',
'uc_class',
'uc_option',
'uc_attribute',
) as $test_type) {
if (!empty($objects[$test_type]) && !empty($objects[$test_type][0]->{$value})) {
$return[$value] = array(
'value' => $objects[$test_type][0]->{$value},
'is_default' => TRUE,
);
break;
}
}
}
}
return $return;
}