first import
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Field handler to translate a variable name into its readable form.
|
||||
*/
|
||||
class views_handler_field_variable_title extends views_handler_field {
|
||||
function render($values) {
|
||||
$name = $this->get_value($values);
|
||||
$variable = variable_build($name);
|
||||
return $variable['title'];
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* A handler to display data from variable_values
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_variable_value extends views_handler_field {
|
||||
function construct() {
|
||||
parent::construct();
|
||||
// Be explicit about the table we are using.
|
||||
$this->additional_fields['name'] = array('table' => 'variable', 'field' => 'name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Render value using variable name for formatting.
|
||||
*/
|
||||
function render($values) {
|
||||
$name = $this->get_value($values, 'name');
|
||||
$variable = variable_build($name);
|
||||
$variable['value'] = unserialize($this->get_value($values));
|
||||
return variable_format_value($variable);
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains the php code argument default plugin.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default argument plugin to provide a variable value.
|
||||
*/
|
||||
class views_plugin_argument_default_variable extends views_plugin_argument_default {
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['variable'] = array('default' => '');
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['variable'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Variable value'),
|
||||
'#options' => _variable_views_variable_list(),
|
||||
'#default_value' => $this->options['variable'],
|
||||
'#description' => t('Select a variable whose value will be retrieved at run time.'),
|
||||
);
|
||||
}
|
||||
|
||||
function convert_options(&$options) {
|
||||
if (!isset($options['variable']) && isset($this->argument->options['default_argument_variable'])) {
|
||||
$options['variable'] = $this->argument->options['default_argument_variable'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only let users with PHP block visibility permissions set/modify this
|
||||
* default plugin.
|
||||
*/
|
||||
function access() {
|
||||
return user_access('administer site configuration');
|
||||
}
|
||||
|
||||
function get_argument() {
|
||||
return variable_get_value($this->options['variable']);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user