<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */


class TabPageTable extends TabPageDefault
{
  private $_columns;
  private $_buttons;

  
  public function __construct($pTabName, $pData, $pHtmlColumns, $pButtons)
  {
    parent::__construct($pTabName, $pData);
    $this->_buttons = $pButtons;
    $this->_columns = $pHtmlColumns;
  }

  
  public function _getContent()
  {
    $result = $this->_getTable($this->_data, $this->_columns);
    $result .= $this->_getButtons($this->_buttons);

    return $result;
  }

  
  private function _getTable($pData, $pColumns)
  {
    $table = new HtmlTabelle($pData);
    foreach ($pColumns as $column) {
      $table->addColumn($column);
    }

    return '<div class="tab_page_datatable_div">' . $table->getTable('', 'tab_page_datatable') . '</div>';
  }

  
  private function _getButtons($pButtons)
  {
    $result = '';
    if (count($pButtons) > 0) {
      $result .= '<div class="tab_buttonleiste">';
      foreach ($pButtons as $button) {
        $result .= '<div class="tab_button">' . $button . '</div>';
      }
      $result .= '</div>';
    }

    return $result;
  }

  public function getSpecialCss()
  {
    return array('css/tabpagetable.css');
  }

  public function getSpecialJs()
  {
    return array('../jquery/plugins/jquery.dataTables.min.js', 'js/tabpagetable.js');
  }
}