entity_print_views.module in Entity Print 7
Same filename and directory in other branches
Entity Print Views module file.
File
modules/entity_print_views/entity_print_views.moduleView source
<?php
/**
* @file
* Entity Print Views module file.
*/
/**
* Inject the relevant css for the template.
*
* You can specify CSS files to be included for all views of per view in your
* themes css file. This code uses your current theme which is likely to be the
* front end theme.
*
* Examples:
*
* entity_print[views][all] = 'css/all-pdfs.css'
* entity_print[views][view_id] = 'css/this-view.css'
*
* @param object $view
* The view we're rendering to a PDF.
*
* @return array
* An array of stylesheets to be used for this template.
*/
function _entity_print_views_get_css($view) {
// Allow other modules to add their own CSS.
module_invoke_all('entity_print_views_css', $view);
global $theme;
$theme_path = drupal_get_path('theme', $theme);
$theme_info = drupal_parse_info_file($theme_path . "/{$theme}.info");
// Parse out the CSS for all views.
if (isset($theme_info['entity_print']['views']['all'])) {
entity_print_add_css("{$theme_path}/" . $theme_info['entity_print']['views']['all']);
unset($theme_info['entity_print']['views']['all']);
}
// Add any per view CSS files.
foreach ($theme_info['entity_print']['views'] as $view_name => $css) {
if ($view->name === $view_name) {
entity_print_add_css("{$theme_path}/{$css}");
}
}
// Grab all the css files and filter by group so we only have css defined to
// be used in entity print.
$entity_print_css = array_filter(drupal_add_css(), function ($a) {
return $a['group'] === ENTITY_PRINT_CSS_GROUP;
});
return $entity_print_css;
}
/**
* Implements hook_theme().
*/
function entity_print_views_theme($existing, $type, $theme, $path) {
return array(
'entity_print_views' => array(
'path' => $path . '/templates',
'template' => 'entity-print-views',
'variables' => array(
'view_html' => NULL,
'view' => NULL,
'entity_print_css' => NULL,
),
),
);
}
/**
* Implements hook_views_plugins().
*/
function entity_print_views_views_plugins() {
return array(
'display' => array(
'entity_print_views_pdf' => array(
'title' => t('PDF'),
'help' => t('Display the view as a PDF.'),
'handler' => 'views_plugin_display_entity_print_views_pdf',
'uses hook menu' => TRUE,
'use ajax' => FALSE,
'use pager' => TRUE,
'accept attachments' => TRUE,
'admin' => t('PDF'),
'theme' => 'views_view',
'use more' => TRUE,
'contextual links locations' => array(),
),
),
);
}
/**
* Implements hook_views_api().
*/
function entity_print_views_views_api() {
return array(
'api' => 3,
'path' => drupal_get_path('module', 'entity_print_views') . '/includes/views',
);
}
Functions
Name | Description |
---|---|
entity_print_views_theme | Implements hook_theme(). |
entity_print_views_views_api | Implements hook_views_api(). |
entity_print_views_views_plugins | Implements hook_views_plugins(). |
_entity_print_views_get_css | Inject the relevant css for the template. |