views_data_export_pdf.module in Views Data Export PDF 7
Same filename and directory in other branches
Main module functions and hooks.
File
views_data_export_pdf.moduleView source
<?php
/**
* @file
* Main module functions and hooks.
*/
/**
* Implements hook_menu().
*/
function views_data_export_pdf_menu() {
$items['admin/config/content/views_data_export_pdf'] = [
'title' => 'Views data export PDF',
'description' => 'Configure the settings for Views data export PDF.',
'page callback' => 'drupal_get_form',
'page arguments' => [
'views_data_export_pdf_settings_form',
],
'type' => MENU_NORMAL_ITEM,
'access arguments' => [
'administer views_data_export_pdf',
],
'file' => 'views_data_export_pdf.admin.inc',
];
return $items;
}
/**
* Implements hook_permission().
*/
function views_data_export_permission() {
$permissions['administer views_data_export_pdf'] = [
'title' => t('Administer Views data export PDF'),
'description' => t('Allow users to administer the Views data export PDF settings.'),
// We make this restricted because you can set the path to the wkhtmltopdf
// binary from the settings page. It isn't vulnerable to injection but
// it's probably not a setting you want everyone configuring anyway.
'restrict access' => TRUE,
];
return $permissions;
}
/**
* Implements hook_views_api().
*/
function views_data_export_pdf_views_api() {
// Using version 2 because Views Data Export still uses it too.
return [
'api' => 2,
];
}
/**
* Implements hook_theme().
*/
function views_data_export_pdf_theme($existing, $type, $theme, $path) {
$hooks = [];
$hooks['views_data_export_pdf_theader'] = [
'variables' => [
'view' => NULL,
'header_row' => '',
],
'file' => 'theme/views_data_export_pdf.theme.inc',
'template' => 'theme/views-data-export-pdf-theader',
];
$hooks['views_data_export_pdf_tfooter'] = [
'variables' => [],
'file' => 'theme/views_data_export_pdf.theme.inc',
'template' => 'theme/views-data-export-pdf-tfooter',
];
$hooks['views_data_export_pdf_pheader'] = [
'variables' => [],
'file' => 'theme/views_data_export_pdf.theme.inc',
'template' => 'theme/views-data-export-pdf-pheader',
];
$hooks['views_data_export_pdf_pfooter'] = [
'variables' => [],
'file' => 'theme/views_data_export_pdf.theme.inc',
'template' => 'theme/views-data-export-pdf-pfooter',
];
return $hooks;
}
/**
* Gets the path of this module relative to the site base.
*
* @return string
*/
function views_data_export_pdf_get_module_path() {
return drupal_get_path('module', 'views_data_export_pdf');
}
/**
* Gets all of the renderers defined on this site.
*
* @see hook_pdf_export_renderers()
*
* @return array
* An associative array of all PDF renderers exposed by modules. Each renderer
* is keyed by its machine name, and the array is sorted by machine name.
*/
function views_data_export_pdf_get_renderer_types() {
$renderers = drupal_static(__FUNCTION__);
if ($renderers === NULL) {
$renderers = [];
foreach (module_implements('pdf_export_renderers') as $module_name) {
$new_renderers = module_invoke($module_name, 'pdf_export_renderers');
foreach ($new_renderers as &$new_renderer) {
// Sanity check/validation
if (!isset($new_renderer['class'])) {
throw new InvalidArgumentException("Renderer '%s' definition is missing the required 'class' value.");
}
if (empty($new_renderer['file path'])) {
$new_renderer['file path'] = drupal_get_path('module', $module_name);
}
}
$renderers = array_merge($renderers, $new_renderers);
ksort($renderers);
}
}
return $renderers;
}
/**
* Returns the relative path to the default stylesheet for PDF output.
*
* @return string
* The render array.
*/
function _views_data_export_pdf_get_default_stylesheet_path() {
$module_path = views_data_export_pdf_get_module_path();
/** @noinspection PhpUnnecessaryLocalVariableInspection */
$css_path = sprintf('%s/css/default_pdf.css', $module_path);
return $css_path;
}
Functions
Name![]() |
Description |
---|---|
views_data_export_pdf_get_module_path | Gets the path of this module relative to the site base. |
views_data_export_pdf_get_renderer_types | Gets all of the renderers defined on this site. |
views_data_export_pdf_menu | Implements hook_menu(). |
views_data_export_pdf_theme | Implements hook_theme(). |
views_data_export_pdf_views_api | Implements hook_views_api(). |
views_data_export_permission | Implements hook_permission(). |
_views_data_export_pdf_get_default_stylesheet_path | Returns the relative path to the default stylesheet for PDF output. |