From efaf626b6c597882def312c9eaf111595643a8aa Mon Sep 17 00:00:00 2001 From: mattbk Date: Tue, 6 Oct 2015 20:17:36 -0500 Subject: [PATCH] Added views handlers for up to seven attributes --- .../uc_views_attribute.info | 5 +- .../views/uc_views_attribute.views.inc | 49 ++++++++++++++++++- ...andler_field_order_product_attribute04.inc | 32 ++++++++++++ ...andler_field_order_product_attribute05.inc | 32 ++++++++++++ ...andler_field_order_product_attribute06.inc | 32 ++++++++++++ ...andler_field_order_product_attribute07.inc | 32 ++++++++++++ 6 files changed, 180 insertions(+), 2 deletions(-) create mode 100644 uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute04.inc create mode 100644 uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute05.inc create mode 100644 uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute06.inc create mode 100644 uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute07.inc diff --git a/uc_views/uc_views_attribute/uc_views_attribute.info b/uc_views/uc_views_attribute/uc_views_attribute.info index ffe7cf7..8407d27 100644 --- a/uc_views/uc_views_attribute/uc_views_attribute.info +++ b/uc_views/uc_views_attribute/uc_views_attribute.info @@ -18,4 +18,7 @@ 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 files[] = views/uc_views_attribute_handler_field_order_product_attribute03.inc - +files[] = views/uc_views_attribute_handler_field_order_product_attribute04.inc +files[] = views/uc_views_attribute_handler_field_order_product_attribute05.inc +files[] = views/uc_views_attribute_handler_field_order_product_attribute06.inc +files[] = views/uc_views_attribute_handler_field_order_product_attribute07.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 6c130b0..cf05944 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 @@ -1,5 +1,4 @@ 'data', 'handler' => 'uc_views_attribute_handler_field_order_product_attribute03', ), + ); + + // Add viewhandler for uc_order_product attributes: Attribute 04 + $data['uc_order_products']['attributes04'] = array( + 'title' => t('Product attribute 04'), + 'help' => t('The fourth 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_attribute04', + ), + ); + + // Add viewhandler for uc_order_product attributes: Attribute 05 + $data['uc_order_products']['attributes05'] = array( + 'title' => t('Product attribute 05'), + 'help' => t('The fifth 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_attribute05', + ), + ); + + // Add viewhandler for uc_order_product attributes: Attribute 06 + $data['uc_order_products']['attributes06'] = array( + 'title' => t('Product attribute 06'), + 'help' => t('The sixth 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_attribute06', + ), + ); + + // Add viewhandler for uc_order_product attributes: Attribute 07 + $data['uc_order_products']['attributes07'] = array( + 'title' => t('Product attribute 07'), + 'help' => t('The seventh 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_attribute07', + ), ); diff --git a/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute04.inc b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute04.inc new file mode 100644 index 0000000..792fe09 --- /dev/null +++ b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute04.inc @@ -0,0 +1,32 @@ +{$this->field_alias}); + $result = ""; + if (is_array($data['attributes'])) { + $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 fourth attribute. + $result = $rows[3]; + } + } + } + return $result; + } +} diff --git a/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute05.inc b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute05.inc new file mode 100644 index 0000000..a4fdd76 --- /dev/null +++ b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute05.inc @@ -0,0 +1,32 @@ +{$this->field_alias}); + $result = ""; + if (is_array($data['attributes'])) { + $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 fifth attribute. + $result = $rows[4]; + } + } + } + return $result; + } +} diff --git a/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute06.inc b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute06.inc new file mode 100644 index 0000000..e3b8135 --- /dev/null +++ b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute06.inc @@ -0,0 +1,32 @@ +{$this->field_alias}); + $result = ""; + if (is_array($data['attributes'])) { + $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 sixth attribute. + $result = $rows[5]; + } + } + } + return $result; + } +} diff --git a/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute07.inc b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute07.inc new file mode 100644 index 0000000..b9623fa --- /dev/null +++ b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute07.inc @@ -0,0 +1,32 @@ +{$this->field_alias}); + $result = ""; + if (is_array($data['attributes'])) { + $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 sixth attribute. + $result = $rows[5]; + } + } + } + return $result; + } +}