You are here

class FrxBean in Forena Reports 7.3

Same name and namespace in other branches
  1. 7.5 bean/FrxBean.inc \FrxBean
  2. 7.4 bean/FrxBean.inc \FrxBean

@file bean plugin for with a forena report

Hierarchy

Expanded class hierarchy of FrxBean

1 string reference to 'FrxBean'
forena_bean_types in ./forena.module
Implements hook_bean_types().

File

bean/FrxBean.inc, line 7
bean plugin for with a forena report

View source
class FrxBean extends BeanPlugin {
  public function values() {
    $values = array(
      'settings' => array(
        'selected_report' => FALSE,
      ),
    );
    return array_merge(parent::values(), $values);
  }
  public function form($bean, $form, &$form_state) {
    $form = array();
    $form['settings'] = array(
      '#type' => 'fieldset',
      '#tree' => 1,
      '#title' => t('Settings'),
    );

    // ask politely which node to show
    $form['settings']['selected_report'] = array(
      '#type' => 'textfield',
      '#title' => t('Select a report'),
      '#autocomplete_path' => 'forena/reports/autocomplete',
      '#default_value' => isset($bean->settings['selected_report']) ? $bean->settings['selected_report'] : '',
      '#required' => TRUE,
      '#multiple' => FALSE,
    );
    $form['settings']['include_url_parameters'] = array(
      '#type' => 'checkbox',
      '#title' => t('Use menu parameters from url'),
      '#description' => t('If checked, parameters from url or in menu path will be used when rendering this report.'),
      '#default_value' => @$bean->settings['include_url_parameters'],
      '#multiple' => FALSE,
    );
    $form['settings']['parms'] = array(
      '#type' => 'textfield',
      '#title' => 'URL Parameters',
      '#description' => 'Specify parameters as they would appear on the url (e.g. state=wa&county=foo) ',
      '#default_value' => @$bean->settings['parms'],
      '#multiple' => FALSE,
    );
    return $form;
  }
  public function view($bean, $content, $view_mode = 'default', $langcode = NULL) {
    $parms = array();
    parse_str($bean->settings['parms'], $parms);
    if (!$parms) {
      $parms = array();
    }
    $report = $bean->settings['selected_report'];
    if ($bean->settings['include_url_parameters']) {
      $query = $_GET;
      unset($query['q']);
      $parms = array_merge($parms, $query);
      if (Frx::Data()
        ->contextExists('parm')) {
        $parms = array_merge($parms, Frx::Data()
          ->getContext('parm'));
      }
    }
    $output = forena_report_include($report, $parms);
    return array(
      'content' => array(
        '#markup' => $output,
      ),
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BeanPlugin::$plugin_info protected property
BeanPlugin::$type public property
BeanPlugin::buildURL public function Build the URL string Overrides BeanTypePluginInterface::buildURL
BeanPlugin::getDescription public function Get the description Overrides BeanTypePluginInterface::getDescription
BeanPlugin::getInfo public function Get Plugin info Overrides BeanTypePluginInterface::getInfo
BeanPlugin::getLabel public function Get the label Overrides BeanTypePluginInterface::getLabel
BeanPlugin::isEditable public function Is the bean type editable Overrides BeanTypePluginInterface::isEditable
BeanPlugin::setBean public function Add a Bean to the plugin Overrides BeanTypePluginInterface::setBean
BeanPlugin::submit public function React to the saving of the bean Overrides BeanTypePluginInterface::submit
BeanPlugin::validate public function THe plugin validation function Overrides BeanTypePluginInterface::validate
BeanPlugin::__construct public function Constructor Overrides BeanTypePluginInterface::__construct
FrxBean::form public function The Plugin Form Overrides BeanPlugin::form
FrxBean::values public function Define the form values and their defaults Overrides BeanPlugin::values
FrxBean::view public function Return the block content. Overrides BeanPlugin::view