You are here

function forena_display_blocks in Forena Reports 8

Same name and namespace in other branches
  1. 7.5 forena.data.inc \forena_display_blocks()
  2. 7.4 forena.data.inc \forena_display_blocks()

@file forena.data.inc Common files for diplaying and previewing data blocks.

File

forena_ui/forena.data.inc, line 6
forena.data.inc Common files for diplaying and previewing data blocks.

Code

function forena_display_blocks() {
  $header = array(
    t('Block'),
    t('Access'),
    t('Keywords'),
    t('Actions'),
  );
  $blocks = Frx::BlockEditor()
    ->revertDBBLocks();
  $blocks = Frx::DataFile()
    ->userBlocks();
  $links[] = array(
    'href' => 'admin/structure/forena/data/add',
    'title' => 'Create New SQL Query)',
  );
  $content['add']['#markup'] = _theme('links', array(
    'links' => $links,
    'attributes' => array(
      'class' => 'action-links',
    ),
  ));
  $data = array();
  foreach ($blocks as $block_name => $block) {
    $blck = str_replace('/', '.', $block_name);
    $actions = '';
    if ($block->cache['type'] == 'sql' && \Drupal::moduleHandler()
      ->moduleExists('forena_query')) {
      if ($block->include) {

        // @FIXME Provide a valid URL, generated from a route name, as the second argument to l(). See https://www.drupal.org/node/2346779 for more information.
        // $actions = l(t('Override'), 'admin/structure/forena/data/' . $blck . '/edit');
      }
      else {

        // @FIXME Provide a valid URL, generated from a route name, as the second argument to l(). See https://www.drupal.org/node/2346779 for more information.
        // $actions = l(t('Edit'), 'admin/structure/forena/data/' . $blck . '/edit');
      }

      // @FIXME Provide a valid URL, generated from a route name, as the second argument to l(). See https://www.drupal.org/node/2346779 for more information.
      // $clone = l(t('Clone'), 'admin/structure/forena/data/clone/' . $blck);
      // Determine the nature of the report delete link.
      if ($block->override && !$block->include) {

        // @FIXME Provide a valid URL, generated from a route name, as the second argument to l(). See https://www.drupal.org/node/2346779 for more information.
        // $actions .= ' ' .l(t('Revert'), 'admin/structure/forena/data/' . $blck . '/delete', array('query' => array('destination' => 'admin/structure/forena/data')));
      }
      else {
        if (!$block->include) {

          // @FIXME Provide a valid URL, generated from a route name, as the second argument to l(). See https://www.drupal.org/node/2346779 for more information.
          // $actions .= ' ' . l(t('Delete'), 'admin/structure/forena/data/' . $blck . '/delete', array('query' => array('destination' => 'admin/structure/forena/data')));
        }
      }
    }

    // Build the table.
    // @FIXME Provide a valid URL, generated from a route name, as the second argument to l(). See https://www.drupal.org/node/2346779 for more information.
    // $data[] = array(
    //         l($block_name, "forena/data/$blck"),
    //         @$block->cache['access'],
    //         @$block->cache['keywords'],
    //         $actions,
    //     );
  }

  // Theme the table
  $output = "<div id='forena-data-block-list'>\n";
  $output .= _theme('forena_data_table', array(
    'header' => $header,
    'rows' => $data,
  ));
  $output .= "</div>\n";
  $content['data_blocks'] = array(
    '#markup' => $output,
  );
  return $content;
}