Added views handlers for up to seven attributes
This commit is contained in:
@ -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_attribute01.inc
|
||||||
files[] = views/uc_views_attribute_handler_field_order_product_attribute02.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_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
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
// $Id: uc_views_attribute.views.inc,v 1.1.2.5 2010/04/29 13:38:55 hanoii Exp $
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* Views 2 hooks and callback registries.
|
* Views 2 hooks and callback registries.
|
||||||
@ -136,6 +135,54 @@ foreach($result as $row) {
|
|||||||
'real field' => 'data',
|
'real field' => 'data',
|
||||||
'handler' => 'uc_views_attribute_handler_field_order_product_attribute03',
|
'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',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field handler to provide a human-readable version of the selected combination of attributes
|
||||||
|
*/
|
||||||
|
class uc_views_attribute_handler_field_order_product_attribute04 extends views_handler_field {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a few default options for the combination field
|
||||||
|
*/
|
||||||
|
function option_definition() {
|
||||||
|
$options = parent::option_definition();
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
$data = unserialize($values->{$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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field handler to provide a human-readable version of the selected combination of attributes
|
||||||
|
*/
|
||||||
|
class uc_views_attribute_handler_field_order_product_attribute05 extends views_handler_field {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a few default options for the combination field
|
||||||
|
*/
|
||||||
|
function option_definition() {
|
||||||
|
$options = parent::option_definition();
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
$data = unserialize($values->{$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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field handler to provide a human-readable version of the selected combination of attributes
|
||||||
|
*/
|
||||||
|
class uc_views_attribute_handler_field_order_product_attribute06 extends views_handler_field {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a few default options for the combination field
|
||||||
|
*/
|
||||||
|
function option_definition() {
|
||||||
|
$options = parent::option_definition();
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
$data = unserialize($values->{$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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field handler to provide a human-readable version of the selected combination of attributes
|
||||||
|
*/
|
||||||
|
class uc_views_attribute_handler_field_order_product_attribute07 extends views_handler_field {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a few default options for the combination field
|
||||||
|
*/
|
||||||
|
function option_definition() {
|
||||||
|
$options = parent::option_definition();
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
$data = unserialize($values->{$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;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user