diff --git a/uc_views/.DS_Store b/uc_views/.DS_Store deleted file mode 100644 index ee357bd..0000000 Binary files a/uc_views/.DS_Store and /dev/null differ diff --git a/uc_views/draggableviews_handler_ubercart.inc b/uc_views/draggableviews_handler_ubercart.inc deleted file mode 100644 index 5b618e5..0000000 --- a/uc_views/draggableviews_handler_ubercart.inc +++ /dev/null @@ -1,22 +0,0 @@ -type) { - case 'order': - db_query("UPDATE {uc_products} SET ordering = %d WHERE nid = %d AND vid = %d", $value, $node->nid, $node->vid); - break; - } - } -} diff --git a/uc_views/uc_views_attribute/.DS_Store b/uc_views/uc_views_attribute/.DS_Store deleted file mode 100644 index 355158e..0000000 Binary files a/uc_views/uc_views_attribute/.DS_Store and /dev/null differ diff --git a/uc_views/uc_views_attribute/uc_views_attribute.info b/uc_views/uc_views_attribute/uc_views_attribute.info index edca74b..01d70e2 100644 --- a/uc_views/uc_views_attribute/uc_views_attribute.info +++ b/uc_views/uc_views_attribute/uc_views_attribute.info @@ -14,4 +14,8 @@ files[] = views/uc_views_attribute_handler_field_order_product_attribute.inc files[] = views/uc_views_attribute_handler_field_combination.inc files[] = views/uc_views_attribute_handler_field_combination_price.inc files[] = views/uc_views_attribute_handler_filter_attr.inc +files[] = views/uc_views_handler_field_attributes.inc + +files[] = views/uc_views_attribute_handler_field_order_product_attribute01.inc +files[] = views/uc_views_attribute_handler_field_order_product_attribute02.inc diff --git a/uc_views/uc_views_attribute/views/uc_views_attribute.views.inc b/uc_views/uc_views_attribute/views/uc_views_attribute.views.inc index 40bd1fc..35af658 100644 --- a/uc_views/uc_views_attribute/views/uc_views_attribute.views.inc +++ b/uc_views/uc_views_attribute/views/uc_views_attribute.views.inc @@ -101,6 +101,30 @@ foreach($result as $row) { 'handler' => 'uc_views_attribute_handler_field_order_product_attribute', ), ); + +// Add viewhandler for uc_order_product attributes: Attribute 01 + $data['uc_order_products']['attributes01'] = array( + 'title' => t('Product attribute 01'), + 'help' => t('The first attribute selection for the ordered product.'), + 'group' => t('Ubercart order product'), + 'field' => array( + 'table' => 'uc_order_products', + 'real field' => 'data', + 'handler' => 'uc_views_attribute_handler_field_order_product_attribute01', + ), + ); + + // Add viewhandler for uc_order_product attributes: Attribute 02 + $data['uc_order_products']['attributes02'] = array( + 'title' => t('Product attribute 02'), + 'help' => t('The second attribute selection for the ordered product.'), + 'group' => t('Ubercart order product'), + 'field' => array( + 'table' => 'uc_order_products', + 'real field' => 'data', + 'handler' => 'uc_views_attribute_handler_field_order_product_attribute02', + ), + ); return $data; } diff --git a/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute01.inc b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute01.inc new file mode 100644 index 0000000..69904b4 --- /dev/null +++ b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute01.inc @@ -0,0 +1,35 @@ +{$this->field_alias}); + $result = "heck yeah"; + if (is_array($data['attributes'])) { + $result = 'even better'; + $rows = array(); + foreach ($data['attributes'] as $attribute => $option) { + $rows[] = t('@option', array('@attribute' => $attribute, '@option' => implode(', ', (array) $option))); + if (count($rows)) { + //Grab the value for the first attribute. + $result = $rows[0]; + //$result = theme('item_list', array('items' => $rows, 'title' => NULL, 'type' => 'ul', 'attributes' => array('class' => 'product-description'))); + } + } + } + return $result; + } +} diff --git a/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute02.inc b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute02.inc new file mode 100644 index 0000000..0a25c87 --- /dev/null +++ b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute02.inc @@ -0,0 +1,35 @@ +{$this->field_alias}); + $result = "heck yeah"; + if (is_array($data['attributes'])) { + $result = 'even better'; + $rows = array(); + foreach ($data['attributes'] as $attribute => $option) { + $rows[] = t('@option', array('@attribute' => $attribute, '@option' => implode(', ', (array) $option))); + if (count($rows)) { + //Grab the value for the second attribute. + $result = $rows[1]; + //$result = theme('item_list', array('items' => $rows, 'title' => NULL, 'type' => 'ul', 'attributes' => array('class' => 'product-description'))); + } + } + } + return $result; + } +} diff --git a/uc_views/uc_views_attribute/views/uc_views_attribute_handler_filter_attr.inc b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_filter_attr.inc index 350cf84..c1f22e6 100644 --- a/uc_views/uc_views_attribute/views/uc_views_attribute_handler_filter_attr.inc +++ b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_filter_attr.inc @@ -24,7 +24,7 @@ class uc_views_attribute_handler_filter_attr extends views_handler_filter_in_ope $this->value_title = t('Options'); $result = db_query("SELECT name, oid FROM {uc_attribute_options} WHERE aid = :aid ORDER BY ordering", array(':aid' => $aid)); - while ($row = db_fetch_object($result)) { + foreach ($result as $row) { $options[$row->oid] = $row->name; } if (count($options) == 0) { diff --git a/uc_views/uc_views_attribute/views/uc_views_attribute_handler_filter_product_attr.inc b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_filter_product_attr.inc deleted file mode 100644 index f2bd4fd..0000000 --- a/uc_views/uc_views_attribute/views/uc_views_attribute_handler_filter_product_attr.inc +++ /dev/null @@ -1,117 +0,0 @@ - 'select'); - - return $options; - } - - function get_value_options() { - if (!isset($this->value_options)) { - $aid = explode('_', $this->field); - $aid = $aid[1]; - - $this->value_title = t('Options'); - $result = db_query("SELECT name, oid FROM {uc_attribute_options} WHERE aid = %d ORDER BY ordering", $aid); - - while ($row = db_fetch_object($result)) { - $options[$row->oid] = $row->name; - } - if (count($options) == 0) { - $options[] = t('No options found.'); - } - $this->value_options = $options; - } - } - - function extra_options_form(&$form, &$form_state) { - $form['type'] = array( - '#type' => 'radios', - '#title' => t('Selection type'), - '#options' => array('select' => t('Checkboxes/Dropdown'), 'textfield' => t('Textfield')), - '#default_value' => $this->options['type'], - ); - } - - function value_form(&$form, &$form_state) { - parent::value_form($form, $form_state); - if ($this->options['type'] == 'textfield') { - $form['value'] = array ( - '#type' => 'textfield', - '#title' => 'Text search', - ); - } - } - - function query() { - $aid = explode('_', $this->field); - $aid = $aid[1]; - - $this->ensure_my_table(); - $this->real_field = 'combination'; - $field = "{$this->table_alias}.{$this->real_field}"; - if ($this->operator == 'not in') { - $not = 'NOT'; - } - if(!is_array($this->value)) { - $this->value = array($this->value); - } - $add = FALSE; - $optval = array(); - foreach ($this->value as &$value) { - if($this->options['type'] == 'textfield') { - $optval[] = db_result(db_query("SELECT oid FROM {uc_attribute_options} WHERE UPPER(name) = UPPER('%s')", $value)); - } - else { - $optval[] = $value; - } - if (!empty($optval)) { - $add = TRUE; - } - else { - //If we let the query get added, only products with the attribute enabled & with the value of that attribute empty - //will return. By default, I think it makes more sense to allow any product to return despite whether or not it - //has the attribute if the user put nothing in to search for. - //Adding a new type of filter that merely captures whether or not the attribute exists at all for the product may - //be the best way to capture the alternative. Or, perhaps a config option could be added to this filter : - //"Show products only if they have this attribute enabled". If this option is unchecked, a blank value returns all - //products. If checked, a blank value at least filters out products that dont have this attribute available. - continue; - } - } - if ($add) { - $match = ''; - foreach ($optval as &$oneopt) { - $var = array($aid => $oneopt); - $servar = serialize($var); - $l = strpos($servar, '{') + 1; - $r = strpos($servar, '}') - $l; - $value = substr($servar, $l, $r); - if (!empty($match)) { - if ($this->operator == 'not in') { - $match .= ' AND '; - } - else { - $match .= ' OR '; - } - } - $match .= "($field $not LIKE '%{$value}%')"; - } - $this->query->add_where($this->options['group'], $match); - if (is_null($this->query->get_table_info('uc_product_stock'))) { - $stock_alias = $this->query->ensure_table('uc_product_stock'); - $this->query->add_where($this->options['group'], "{$stock_alias}.sku = {$this->table_alias}.model"); - $this->query->add_where($this->options['group'], "({$stock_alias}.active = 0) OR ({$stock_alias}.stock > 0)"); - } - } - } -} diff --git a/uc_views/views/uc_views_handler_field_order_id.inc b/uc_views/views/uc_views_handler_field_order_id.inc index 08b6fb2..e69de29 100644 --- a/uc_views/views/uc_views_handler_field_order_id.inc +++ b/uc_views/views/uc_views_handler_field_order_id.inc @@ -1,49 +0,0 @@ - FALSE); - return $options; - } - - /** - * Provide link to order adminstration page - */ - function options_form(&$form, &$form_state) { - parent::options_form($form, $form_state); - $form['link_to_order'] = array( - '#title' => t('Link this field to the order view.'), - '#description' => t('The link will go to the admin view if the user has "view all orders" permission, or the user view if the order belongs to the current user and they have "view own orders" permission. This will override any other link you have set.'), - '#type' => 'checkbox', - '#default_value' => !empty($this->options['link_to_order']), - ); - } - - function render($values) { - global $user; - - $this->options['alter']['make_link'] = FALSE; - - if (!empty($this->options['link_to_order']) && $values->{$this->field_alias}) { - if (user_access('view all orders')) { - $this->options['alter']['make_link'] = TRUE; - $this->options['alter']['path'] = "admin/store/orders/" . $values->{$this->field_alias}; - } - elseif ($values->{$this->aliases['uid']} == $user->uid && user_access('view own orders')) { - $this->options['alter']['make_link'] = TRUE; - $this->options['alter']['path'] = 'user/' . $user->uid . '/order/' . $values->{$this->field_alias}; - } - } - - return parent::render($values); - } -}