class uc_addresses_views_plugin_row_address_view in Ubercart Addresses 7
Same name and namespace in other branches
- 6.2 views/uc_addresses_views_plugin_row_address_view.inc \uc_addresses_views_plugin_row_address_view
Plugin which performs a address_view on the resulting object.
Most of the code on this object is in the theme function.
Hierarchy
- class \views_object
- class \views_plugin
Expanded class hierarchy of uc_addresses_views_plugin_row_address_view
1 string reference to 'uc_addresses_views_plugin_row_address_view'
- uc_addresses_views_plugins in views/
uc_addresses.views.inc - Implements hook_views_plugins().
File
- views/
uc_addresses_views_plugin_row_address_view.inc, line 13 - Contains the address view row style plugin.
View source
class uc_addresses_views_plugin_row_address_view extends views_plugin_row {
// Basic properties that let the row style follow relationships.
public $base_table = 'uc_addresses';
public $base_field = 'aid';
/**
* The assumed name of the uid field in the Views' results.
*
* @var string
* @access protected
*/
protected $uid_field_alias = 'unknown';
/**
* Overrides views_plugin_row::option_definition().
*
* @return array
* The available options and their default values.
*/
public function option_definition() {
$options = parent::option_definition();
$options['view_link'] = array(
'default' => FALSE,
);
$options['edit_link'] = array(
'default' => TRUE,
);
$options['delete_link'] = array(
'default' => TRUE,
);
$options['default_flags'] = array(
'default' => FALSE,
);
return $options;
}
/**
* Overrides views_plugin_row::options_form().
*
* @return void
*/
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['view_link'] = array(
'#type' => 'checkbox',
'#title' => t('Display view links'),
'#default_value' => $this->options['view_link'],
);
$form['edit_link'] = array(
'#type' => 'checkbox',
'#title' => t('Display edit links'),
'#description' => t('Note that edit links are only shown for addresses that the current user may edit.'),
'#default_value' => $this->options['edit_link'],
);
$form['delete_link'] = array(
'#type' => 'checkbox',
'#title' => t('Display delete links'),
'#description' => t('Note that delete links are only shown for addresses that the current user may delete.'),
'#default_value' => $this->options['delete_link'],
);
$form['default_flags'] = array(
'#type' => 'checkbox',
'#title' => t('Display default flags'),
'#description' => t('This adds the "default" label to default addresses. For example, the default billing address will get the label "!label".', array(
'!label' => t('Default billing address'),
)),
'#default_value' => $this->options['default_flags'],
);
}
/**
* Overrides views_plugin_row::query().
*
* Ensures the 'uid' field is added to the query.
*
* @return void
*/
public function query() {
parent::query();
$this->uid_field_alias = $this->view->query
->add_field($this->view->query->base_table, 'uid');
}
/**
* Implements views_plugin_row::pre_render().
*
* Loads all addresses.
*
* @return void
*/
public function pre_render($values) {
$aid_field_alias = $this->field_alias;
$uid_field_alias = $this->uid_field_alias;
$this->addresses = array();
if (!empty($values)) {
foreach ($values as $row) {
$addressBook = UcAddressesAddressBook::get($row->{$uid_field_alias});
// Set performance hint to load all addresses.
$addressBook
->setPerformanceHint(UcAddressesAddressBook::PERF_HINT_LOAD_ALL);
$address = $addressBook
->getAddressById($row->{$aid_field_alias});
$this->addresses[$address
->getId()] = $address;
}
}
}
/**
* Overrides views_plugin_row::render().
*
* Renders a single address.
*
* @return string
* Rendered HTML.
*/
function render($row) {
if (isset($this->addresses[$row->{$this->field_alias}])) {
$address = $this->addresses[$row->{$this->field_alias}];
$address->view = $this->view;
return theme('uc_addresses_list_address', array(
'address' => $address,
'options' => $this->options,
));
}
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
uc_addresses_views_plugin_row_address_view:: |
public | property | ||
uc_addresses_views_plugin_row_address_view:: |
public | property | ||
uc_addresses_views_plugin_row_address_view:: |
protected | property | The assumed name of the uid field in the Views' results. | |
uc_addresses_views_plugin_row_address_view:: |
public | function |
Overrides views_plugin_row::options_form(). Overrides views_plugin_row:: |
|
uc_addresses_views_plugin_row_address_view:: |
public | function |
Overrides views_plugin_row::option_definition(). Overrides views_plugin_row:: |
|
uc_addresses_views_plugin_row_address_view:: |
public | function |
Implements views_plugin_row::pre_render(). Overrides views_plugin_row:: |
|
uc_addresses_views_plugin_row_address_view:: |
public | function |
Overrides views_plugin_row::query(). Overrides views_plugin_row:: |
|
uc_addresses_views_plugin_row_address_view:: |
function |
Overrides views_plugin_row::render(). Overrides views_plugin_row:: |
||
views_object:: |
public | property | Handler's definition. | |
views_object:: |
public | property | Except for displays, options for the object will be held here. | 1 |
views_object:: |
function | Collect this handler's option definition and alter them, ready for use. | ||
views_object:: |
public | function | Views handlers use a special construct function. | 4 |
views_object:: |
public | function | Destructor. | 2 |
views_object:: |
public | function | 1 | |
views_object:: |
public | function | ||
views_object:: |
public | function | Always exports the option, regardless of the default value. | |
views_object:: |
public | function | Set default options on this object. | 1 |
views_object:: |
public | function | Set default options. | |
views_object:: |
public | function | Let the handler know what its full definition is. | |
views_object:: |
public | function | Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away. | |
views_object:: |
public | function | Unpack a single option definition. | |
views_object:: |
public | function | Unpacks each handler to store translatable texts. | |
views_object:: |
public | function | ||
views_plugin:: |
public | property | The current used views display. | |
views_plugin:: |
public | property | The plugin name of this plugin, for example table or full. | |
views_plugin:: |
public | property | The plugin type of this plugin, for example style or query. | |
views_plugin:: |
public | property |
The top object of a view. Overrides views_object:: |
1 |
views_plugin:: |
public | function | Provide a list of additional theme functions for the theme info page. | |
views_plugin:: |
public | function | Return the human readable name of the display. | |
views_plugin:: |
public | function | Returns the summary of the settings in the display. | 8 |
views_plugin:: |
public | function | Provide a full list of possible theme templates used by this style. | |
views_plugin:: |
public | function | Validate that the plugin is correct and can be saved. | 3 |
views_plugin_row:: |
public | function | 2 | |
views_plugin_row:: |
public | function |
Perform any necessary changes to the form values prior to storage.
There is no need for this function to actually store the data. Overrides views_plugin:: |
1 |
views_plugin_row:: |
public | function |
Validate the options form. Overrides views_plugin:: |
|
views_plugin_row:: |
public | function |