views_pdf.module in Views PDF 6
Same filename and directory in other branches
PDF Views allows the creation of PDF's directly from a view. Without the creation of HTML first.
File
views_pdf.moduleView source
<?php
/**
* @file
* PDF Views allows the creation of PDF's directly from a view. Without the
* creation of HTML first.
*/
/**
* Implementation of hook_views_api().
*/
function views_pdf_views_api() {
return array(
'api' => 2,
);
}
/**
* Implementation of hook_theme()
*/
function views_pdf_theme() {
return array(
'views_pdf_plugin_style_table' => array(
'arguments' => array(
'form' => NULL,
),
'file' => 'views_pdf.admin.inc',
),
'views_pdf_icon' => array(
'arguments' => array(
'url' => NULL,
'title' => NULL,
),
),
);
}
/**
* This method can be used to load the PDF library class.
*/
function views_pdf_get_new_pdf_instance($orientation = 'P', $unit = 'mm', $format = 'A4', $unicode = TRUE, $encoding = 'UTF-8', $diskcache = FALSE) {
_views_pdf_include_pdf_lib();
return new PdfTemplate($orientation, $unit, $format, $unicode, $encoding, $diskcache);
}
/**
* Theme function for the PDF icon of appended PDFs.
*/
function theme_views_pdf_icon($url, $title) {
$path = drupal_get_path('module', 'views_pdf') . '/images/pdf.png';
if ($image = theme('image', $path, t('PDF content'), $title)) {
return '<a href="' . check_url($url) . '" class="pdf-icon">' . $image . '</a>';
}
}
/**
* This method can be used to get all available fonts.
*/
function views_pdf_get_font_list() {
_views_pdf_include_pdf_lib();
return PdfTemplate::getAvailableFontsCleanList();
}
/**
* This function returns the path to a given library.
*
* @param $name Name of the Library
*
*/
function views_pdf_get_library($name) {
if (function_exists('libraries_get_path')) {
return libraries_get_path($name);
}
else {
return 'sites/all/libraries/' . $name;
}
}
/**
* This method can be used to get all available templates.
*/
function views_pdf_get_pdf_templates() {
_views_pdf_include_pdf_lib();
return PdfTemplate::getAvailableTemplates();
}
function views_pdf_get_hyphenations() {
_views_pdf_include_pdf_lib();
return PdfTemplate::getAvailableHyphenatePatterns();
}
/**
* This method can be used to return a list of posible page formats.
*/
function views_pdf_get_page_formats() {
$format['custom'] = t('Custom');
$format['4A0'] = '4A0';
$format['2A0'] = '2A0';
$format['A0'] = 'A0';
$format['A1'] = 'A1';
$format['A2'] = 'A2';
$format['A3'] = 'A3';
$format['A4'] = 'A4';
$format['A5'] = 'A5';
$format['A6'] = 'A6';
$format['A7'] = 'A7';
$format['A8'] = 'A8';
$format['A9'] = 'A9';
$format['A10'] = 'A10';
$format['B0'] = 'B0';
$format['B1'] = 'B1';
$format['B2'] = 'B2';
$format['B3'] = 'B3';
$format['B4'] = 'B4';
$format['B5'] = 'B5';
$format['B6'] = 'B6';
$format['B7'] = 'B7';
$format['B8'] = 'B8';
$format['B9'] = 'B9';
$format['B10'] = 'B10';
$format['C0'] = 'C0';
$format['C1'] = 'C1';
$format['C2'] = 'C2';
$format['C3'] = 'C3';
$format['C4'] = 'C4';
$format['C5'] = 'C5';
$format['C6'] = 'C6';
$format['C7'] = 'C7';
$format['C8'] = 'C8';
$format['C9'] = 'C9';
$format['C10'] = 'C10';
$format['RA0'] = 'RA0';
$format['RA1'] = 'RA1';
$format['RA2'] = 'RA2';
$format['RA3'] = 'RA3';
$format['RA4'] = 'RA4';
$format['SRA0'] = 'SRA0';
$format['SRA1'] = 'SRA1';
$format['SRA2'] = 'SRA2';
$format['SRA3'] = 'SRA3';
$format['SRA4'] = 'SRA4';
$format['LETTER'] = 'LETTER';
$format['LEGAL'] = 'LEGAL';
$format['EXECUTIVE'] = 'EXECUTIVE';
$format['FOLIO'] = 'FOLIO';
return $format;
}
/**
* Get the PDF class.
*/
function _views_pdf_include_pdf_lib() {
$path = drupal_get_path('module', 'views_pdf');
require_once $path . '/views_pdf_template.php';
}
/**
* For backward compatibilty (< 5.3) we implemented
* this function by our self. If we are in a newer
* environment, then this is obsolete.
*
*/
if (!function_exists('array_replace_recursive')) {
function array_replace_recursive($array, $array1) {
if (!function_exists('recurse')) {
function recurse($array, $array1) {
foreach ($array1 as $key => $value) {
// create new key in $array, if it is empty or not an array
if (!isset($array[$key]) || isset($array[$key]) && !is_array($array[$key])) {
$array[$key] = array();
}
// overwrite the value in the base array
if (is_array($value)) {
$value = recurse($array[$key], $value);
}
$array[$key] = $value;
}
return $array;
}
// handle the arguments, merge one by one
$args = func_get_args();
$array = $args[0];
if (!is_array($array)) {
return $array;
}
for ($i = 1; $i < count($args); $i++) {
if (is_array($args[$i])) {
$array = recurse($array, $args[$i]);
}
}
return $array;
}
}
}
Functions
Name | Description |
---|---|
theme_views_pdf_icon | Theme function for the PDF icon of appended PDFs. |
views_pdf_get_font_list | This method can be used to get all available fonts. |
views_pdf_get_hyphenations | |
views_pdf_get_library | This function returns the path to a given library. |
views_pdf_get_new_pdf_instance | This method can be used to load the PDF library class. |
views_pdf_get_page_formats | This method can be used to return a list of posible page formats. |
views_pdf_get_pdf_templates | This method can be used to get all available templates. |
views_pdf_theme | Implementation of hook_theme() |
views_pdf_views_api | Implementation of hook_views_api(). |
_views_pdf_include_pdf_lib | Get the PDF class. |