You are here

public function ReportEditor::blockLinks in Forena Reports 8

Same name and namespace in other branches
  1. 7.5 src/Editor/ReportEditor.php \Drupal\forena\Editor\ReportEditor::blockLinks()

File

src/Editor/ReportEditor.php, line 1069
ReportEditor.inc Wrapper XML class for working with DOM object. It provides helper Enter description here ... @author metzlerd

Class

ReportEditor

Namespace

Drupal\forena\Editor

Code

public function blockLinks($block_name, $frx, $attrs, $id = '', $context = array()) {
  $o = '';
  if (!$context) {
    $context = array();
  }
  $parms = FrxAPI::Data()
    ->getContext('parm');
  if ($parms && is_array($context)) {
    $context = array_merge($parms, $context);
  }
  $class = @(string) $attrs['class'];
  $frx_class = strpos($class, 'FrxAPI') !== FALSE;
  if ($frx_class) {
    $frx_class = FALSE;
    foreach ($this
      ->templateOptions() as $key => $label) {
      if (strpos($class, $key) !== FALSE) {
        $frx_class = TRUE;
      }
    }
  }
  $block_tag = (string) $frx['block'];
  if ($frx_class || $block_tag) {
    $block_label = (string) $frx['block'] ? $block_name : '#' . $id;
    $block_link = str_replace('/', '.', $block_name);
    $report_name = str_replace('/', '.', $this->desc['base_name']);
    $b = $this
      ->dataManager()
      ->loadBlock($block_name);
    $options = array();
    if ($context) {
      $options['query'] = $context;
    }

    // Add the prepend link.
    if ($block_tag) {

      // If we have a block tag we're going to prepend another data block?
      $o .= '<div class="forena-edit-links">' . $this
        ->l_icon("reports/{$report_name}/edit/select-data/prepend-data/{$id}", 'plus.svg', 'Insert Data', null, t("Data")) . "</div>";
    }
    else {

      //$o .= '<div class="forena-edit-links">' . $this->l_icon("reports/$report_name/edit/prepend-section/$block_link/$id", 'plus.svg', 'Add Data').  "</div>";
    }

    // Add the block or ID link
    $o .= '<div class="forena-edit-links">' . l($block_label, "reports/{$report_name}/edit/edit-data/{$block_link}/{$id}", $options) . ' ' . $this
      ->l_icon("reports/{$report_name}/edit/delete-data/{$id}", 'minus.svg', 'Remove Data', $context) . "</div>";
  }
  return $o;
}