You are here

function forena_get_templates in Forena Reports 7

Same name and namespace in other branches
  1. 6 forena.common.inc \forena_get_templates()

Returns an object of the template class that has a method named templates.

If it fails it returns a 0;

1 call to forena_get_templates()
forena_data_block_form_submit in ./forena.admin.inc
The Preview submit handler for forena_add_block_form Renders datablock into a report

File

./forena.common.inc, line 791
Common functions used throughout the project but loaded in this file to keep the module file lean.

Code

function forena_get_templates($fkey) {
  $controls = forena_define_controls();
  foreach ($controls as $k => $r) {
    $provider = $r;
    if ($provider && method_exists($provider, 'templates')) {
      $f = $provider
        ->templates();
      if ($f[$fkey] && method_exists($provider, $fkey)) {

        // We found an object with the advertised method, return it
        return $provider;
      }
    }
  }
  return 0;
}