You are here

class HtmlListExporter in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/aklump/loft_data_grids/src/AKlump/LoftDataGrids/HtmlListExporter.php \AKlump\LoftDataGrids\HtmlListExporter

Class HtmlListExporter

Hierarchy

Expanded class hierarchy of HtmlListExporter

File

vendor/aklump/loft_data_grids/src/AKlump/LoftDataGrids/HtmlListExporter.php, line 7

Namespace

AKlump\LoftDataGrids
View source
class HtmlListExporter extends Exporter implements ExporterInterface {
  protected $extension = '.html';
  protected function setSettingsDefault() {
    parent::setSettingsDefault();
    $this->settings->pageTag = 'h2';
    return $this;
  }
  public function getInfo() {
    $info = parent::getInfo();
    $info = array(
      'name' => 'HTML List',
      'shortname' => 'HTML List',
      'description' => 'Export data in HTML list format.',
    ) + $info;
    return $info;
  }
  public function compile($page_id = NULL) {
    $pages = $this
      ->getData()
      ->get();
    $this->output = array();

    // Apply spacing and build output
    foreach ($pages as $page_id => $page) {
      if ($this
        ->getShowPageIds()) {
        $tag = $this
          ->getSettings()->pageTag;
        $this->output[] = "<{$tag}>{$page_id}</{$tag}>";
      }
      foreach ($page as $record) {
        $this->output[] = "<hr />";
        $class = $this
          ->cssSafe($page_id);
        $data = str_replacE('"', '\\"', $page_id);
        $this->output[] = "<table class=\"page {$class}\" data-page=\"{$data}\">";
        $this->output[] = "<tbody>";
        $odd = TRUE;
        foreach ($record as $key => $value) {
          $zebra = $odd ? 'odd' : 'even';
          $odd = !$odd;
          $this->output[] = "<tr class=\"{$zebra}\"><td class=\"key\">{$key}</td><td class=\"value\">{$value}</td></tr>";
        }
        $this->output[] = "</tbody>";
        $this->output[] = "</table>";
      }
    }
    $this->output = implode(PHP_EOL, $this->output);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Exporter::$export_data protected property
Exporter::$header protected property
Exporter::$settings protected property
Exporter::addSetting public function Adds/Updates a single setting by name. Overrides ExporterInterface::addSetting
Exporter::cssSafe protected function
Exporter::export public function Export data as a string Overrides ExporterInterface::export 1
Exporter::filenameSafe protected function Return a string as a safe filename
Exporter::formatColumn public function Format a single column with format by string Overrides ExporterInterface::formatColumn 1
Exporter::getData public function Return the ExportDataInterface object Overrides ExporterInterface::getData
Exporter::getFilename public function Get the filename Overrides ExporterInterface::getFilename
Exporter::getHeader public function Return an array containing the header row values for a page Overrides ExporterInterface::getHeader
Exporter::getSettings public function Return the settings object. Overrides ExporterInterface::getSettings
Exporter::getShowPageIds public function Return the showPageIds. Overrides ExporterInterface::getShowPageIds
Exporter::getTitle public function Overrides ExporterInterface::getTitle
Exporter::hidePageIds public function Set the exporter to hide page ids. Overrides ExporterInterface::hidePageIds
Exporter::save public function Save as a file to the server Overrides ExporterInterface::save 1
Exporter::setData public function Set the export data object Overrides ExporterInterface::setData
Exporter::setFilename public function Getter/Setter for the filename Overrides ExporterInterface::setFilename
Exporter::setSettings public function Set the settings object. Overrides ExporterInterface::setSettings
Exporter::setTitle public function Set a title for the exported document Overrides ExporterInterface::setTitle 1
Exporter::showPageIds public function Set the exporter to display page ids. Overrides ExporterInterface::showPageIds
Exporter::__construct public function Constructor 4
HtmlListExporter::$extension protected property
HtmlListExporter::compile public function Build $this->output in prep for export/save Overrides Exporter::compile
HtmlListExporter::getInfo public function Return info about this class Overrides Exporter::getInfo
HtmlListExporter::setSettingsDefault protected function Setup default values on object data. Overrides Exporter::setSettingsDefault