You are here

vbo_export.module in VBO export 8.3

Same filename and directory in other branches
  1. 8 vbo_export.module
  2. 8.2 vbo_export.module
  3. 7 vbo_export.module

Delivers an action to export view results to csv.

File

vbo_export.module
View source
<?php

/**
 * @file
 * Delivers an action to export view results to csv.
 */
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function vbo_export_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.vbo_export':
      $filepath = dirname(__FILE__) . '/README.md';
      if (file_exists($filepath)) {
        $readme = file_get_contents($filepath);
        $output = '<pre>' . $readme . '</pre>';
        return $output;
      }
  }
}

/**
 * Library loader function.
 *
 * Loads the library if not already available and
 * optionally checks its version.
 */
function _vbo_export_library_exists($classname, $details = FALSE) {
  static $output;
  if (!isset($output[$classname])) {
    $output[$classname] = FALSE;

    // If composer was used to add dependancy, the class should exist,
    // Otherwise check given path.
    if (class_exists($classname)) {
      if ($details) {
        $reflector = new ReflectionClass($classname);
        $path = dirname(dirname(dirname($reflector
          ->getFileName())));
        if (file_exists($path . '/CHANGELOG.md') && ($content = file_get_contents($path . '/CHANGELOG.md'))) {
          preg_match('/##\\s+\\[(\\d+\\.\\d+\\.\\d+)\\]\\s+-?\\s+\\d{4}-\\d{2}-\\d{2}/', $content, $matches);
          if (!empty($matches[1])) {
            $output[$classname] = trim($matches[1]);
          }
          else {
            $output[$classname] = 'undetected';
          }
        }
      }
      else {
        $output[$classname] = TRUE;
      }
    }
  }
  return $output[$classname];
}

Functions

Namesort descending Description
vbo_export_help Implements hook_help().
_vbo_export_library_exists Library loader function.