View source
<?php
function views_pdf_views_api() {
return array(
'api' => 3,
);
}
function views_pdf_menu() {
$items = array();
$items['admin/structure/views/pdfs'] = array(
'title' => t('PDF Templates'),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'views_pdf_templates',
),
'access arguments' => array(
'administer views',
),
'file' => 'views_pdf.admin.inc',
'type' => MENU_LOCAL_TASK,
'weight' => 10,
);
$items['admin/structure/views/pdfs/delete/%'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array(
'views_pdf_template_delete',
5,
),
'access arguments' => array(
'administer views',
),
'file' => 'views_pdf.admin.inc',
'type' => MENU_CALLBACK,
);
return $items;
}
function views_pdf_theme() {
return array(
'views_pdf_plugin_style_table' => array(
'render element' => 'form',
'file' => 'views_pdf.admin.inc',
),
'views_pdf_icon' => array(
'render element' => 'form',
'variables' => array(
'url' => NULL,
'title' => NULL,
),
),
);
}
define('VIEWS_PDF_PHP', module_exists('php'));
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);
}
function theme_views_pdf_icon($vars) {
$title = $vars['title'];
$path = $vars['path'];
$options = $vars['options'];
$options['html'] = TRUE;
$options['attributes']['class'] = 'pdf-icon';
$imagePath = drupal_get_path('module', 'views_pdf') . '/images/pdf.png';
if ($image = theme('image', array(
'path' => $imagePath,
'title' => $title,
'alt' => $title,
))) {
return l($image, $path, $options);
}
}
function views_pdf_get_font_list() {
_views_pdf_include_pdf_lib();
return PdfTemplate::getAvailableFontsCleanList();
}
function views_pdf_get_library($name) {
if (function_exists('libraries_get_path')) {
return libraries_get_path($name);
}
else {
return 'sites/all/libraries/' . $name;
}
}
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();
}
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';
$format['MEMO'] = 'MEMO';
return $format;
}
function _views_pdf_include_pdf_lib() {
module_load_include('php', 'views_pdf', 'views_pdf_template');
}
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) {
if (!isset($array[$key]) || isset($array[$key]) && !is_array($array[$key])) {
$array[$key] = array();
}
if (is_array($value)) {
$value = recurse($array[$key], $value);
}
$array[$key] = $value;
}
return $array;
}
$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;
}
}
}