diff --git a/modules/views_append/views_append.module b/modules/views_append/views_append.module
index f3590a0..6390b56 100644
--- a/modules/views_append/views_append.module
+++ b/modules/views_append/views_append.module
@@ -4,18 +4,18 @@
* @file
* Module for appending PDF views to other PDF views
*
- * The module adds a field which can be used to append another view. The view is
+ * The module adds a field which can be used to append another view. The view is
* created by calling the View over a HTTP request.
*
*/
-
+
/**
* Implementation of hook_views_api().
*/
function views_append_views_api() {
return array(
- 'api' => '3.0-alpha1',
+ 'api' => 3,
);
}
@@ -26,7 +26,7 @@ function views_append_views_api() {
function views_append_request_with_cookie($url, $save_path) {
$urlComponents = parse_url($url);
-
+
// Define the specified port
if ($urlComponents['scheme'] == 'http') {
$port = 80;
@@ -37,10 +37,10 @@ function views_append_request_with_cookie($url, $save_path) {
else {
$port = 80;
}
-
+
// Define the host
$host = $urlComponents['host'];
-
+
// Define the path
if (!empty($urlComponents['query'])) {
$path = $urlComponents['path'] . '?' . $urlComponents['query'];
@@ -48,7 +48,7 @@ function views_append_request_with_cookie($url, $save_path) {
else {
$path = $urlComponents['path'];
}
-
+
// Change host if ssl is used:
if ($port == 443) {
$hostUrl = "ssl://" . $host;
@@ -56,12 +56,12 @@ function views_append_request_with_cookie($url, $save_path) {
else {
$hostUrl = $host;
}
-
+
$fp = fsockopen($hostUrl, $port, $errno, $errstr, 30);
-
+
$method = 'GET';
$content = '';
-
+
if (!$fp) {
echo "$errstr ($errno)
\n";
}
@@ -75,17 +75,17 @@ function views_append_request_with_cookie($url, $save_path) {
$out .= "Cookie: " . session_name() . '=' . session_id() . "; \r\n";
$out .= "Connection: Close\r\n\r\n";
-
+
if ($method == 'POST') {
$out .= $content;
}
-
+
fwrite($fp, $out);
-
+
$newFile = fopen($save_path, 'w');
-
+
$header = TRUE;
-
+
while (!feof($fp)) {
$content = fgets($fp, 8096);
if ($content == "\r\n") {
@@ -94,18 +94,18 @@ function views_append_request_with_cookie($url, $save_path) {
elseif (!$header) {
fwrite($newFile, $content);
}
-
+
}
fclose($fp);
fclose($newFile);
}
-
+
}
function _views_append_parse_array_to_string($array) {
-
+
if (is_array($array)) {
foreach ($array as $key => $value) {
$string .= $key . '=' . $value . '&';
@@ -113,7 +113,7 @@ function _views_append_parse_array_to_string($array) {
if (!empty($string)) {
$string = substr($string, 0, -1);
}
-
+
return $string;
}
else {
diff --git a/modules/views_view_field/views_view_field.module b/modules/views_view_field/views_view_field.module
index 2bf3554..1aef40d 100644
--- a/modules/views_view_field/views_view_field.module
+++ b/modules/views_view_field/views_view_field.module
@@ -1,17 +1,17 @@
'3.0-alpha1',
+ 'api' => 3,
);
}
diff --git a/modules/views_view_field/views_view_field_handler_include_view.inc b/modules/views_view_field/views_view_field_handler_include_view.inc
index 0e31e14..054f081 100644
--- a/modules/views_view_field/views_view_field_handler_include_view.inc
+++ b/modules/views_view_field/views_view_field_handler_include_view.inc
@@ -8,7 +8,6 @@
/**
* This class contains the functionality to add a view as a new field in
* another view.
- *
*/
class views_view_field_handler_include_view extends views_handler_field {
@@ -34,7 +33,7 @@ class views_view_field_handler_include_view extends views_handler_field {
}
/**
- * Settings form
+ * Settings form.
*/
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
@@ -65,7 +64,7 @@ class views_view_field_handler_include_view extends views_handler_field {
for ($i = 0; $this->options['number_of_args'] > $i; $i++) {
$form['args'][$i] = array(
'#type' => 'textfield',
- '#title' => t('Argument #%number', array('%number' => ($i+1))),
+ '#title' => t('Argument #%number', array('%number' => ($i + 1))),
'#default_value' => $this->options['args'][$i],
'#description' => t('Enter here the argument to pass to the view. If you want to use a value from a field, then use the replacement patterns in Rewrite results below.'),
);
@@ -81,7 +80,8 @@ class views_view_field_handler_include_view extends views_handler_field {
}
$options[t('Fields')]["[$field]"] = $handler->ui_name();
}
- $count = 0; // This lets us prepare the key as we want it printed.
+ // This lets us prepare the key as we want it printed.
+ $count = 0;
foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) {
$options[t('Arguments')]['%' . ++$count] = t('@argument title', array('@argument' => $handler->ui_name()));
$options[t('Arguments')]['!' . $count] = t('@argument input', array('@argument' => $handler->ui_name()));
@@ -113,18 +113,14 @@ class views_view_field_handler_include_view extends views_handler_field {
'#type' => 'hidden',
'#id' => 'views-tokens-help',
'#prefix' => '
',
- /* '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-alter-make-link' => array(1),
- 'edit-options-alter-alter-text' => array(1),
- ), */
);
}
/**
- * Renders the field. For rendering the new views is created an added. For
- * PDF displays the two PDF classes where merged.
+ * Renders the field. For rendering the new views is created an added.
+ *
+ * For PDF displays the two PDF classes where merged.
*/
function render($values) {
@@ -144,23 +140,26 @@ class views_view_field_handler_include_view extends views_handler_field {
$view_name = $this->options['view'];
$view = views_get_view($view_name);
- //$view->set_arguments($args);
-
- // Try same display as the current
- if (!$view->set_display($currentDisplay)) {
- // Try the display type
- if (!$view->set_display($displayType . '_1')) {
- // Use the default:
- $view->init_display();
+
+ // Look for a display named pdf_X.
+ foreach ($view->display as $display) {
+ if (preg_match('/^pdf_/', $display->id)) {
+ // Found a PDF display so break out of loop.
+ $pdf_display = $display->id;
+ break;
}
}
+ // Set the found pdf display or automatically revert to default if it's
+ // not found.
+ $view->set_display($pdf_display);
+
$view->pre_execute($args);
$view->init_style();
// Important only for pdf views. With this action we assign the
- // PDF document to the new view
+ // PDF document to the new view.
if (isset($this->view->pdf) && is_object($this->view->pdf)) {
$view->pdf =& $this->view->pdf;
diff --git a/views_pdf.info b/views_pdf.info
index 702bd21..dffbd5e 100644
--- a/views_pdf.info
+++ b/views_pdf.info
@@ -1,6 +1,7 @@
name = Views PDF Display
description = "Views plugin to export a view as a PDF file."
dependencies[] = views
+dependencies[] = php
package = Views
core = 7.x
diff --git a/views_pdf.install b/views_pdf.install
index fb15aaa..61cf919 100644
--- a/views_pdf.install
+++ b/views_pdf.install
@@ -1,17 +1,20 @@
'3.0-alpha1',
+ 'api' => 3,
);
}
/**
- * Implemenation of hook_theme()
+ * Implements hook_theme().
*/
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),
@@ -35,7 +31,7 @@ function views_pdf_theme() {
/**
* 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) {
+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);
@@ -51,9 +47,14 @@ function theme_views_pdf_icon($vars) {
$options['html'] = TRUE;
$options['attributes']['class'] = 'pdf-icon';
- $imagePath = drupal_get_path('module', 'views_pdf') . '/images/pdf.png';
+ $image_path = drupal_get_path('module', 'views_pdf') . '/images/pdf.png';
+ $image = theme('image', array(
+ 'path' => $image_path,
+ 'title' => $title,
+ 'alt' => $title,
+ ));
- if ($image = theme('image', array('path' => $imagePath, 'title' => $title, 'alt' => $title))) {
+ if (!empty($image)) {
return l($image, $path, $options);
}
}
@@ -70,20 +71,18 @@ function views_pdf_get_font_list() {
/**
* This function returns the path to a given library.
*
- * @param $name Name of the Library
- *
+ * @param string $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;
- }
+ 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.
*/
@@ -93,8 +92,7 @@ function views_pdf_get_pdf_templates() {
}
/**
- * This method returns all available hyphenation
- * patterns (paths to files).
+ * This method returns all available hyphenation patterns (paths to files).
*/
function views_pdf_get_hyphenations() {
_views_pdf_include_pdf_lib();
@@ -169,24 +167,26 @@ function _views_pdf_include_pdf_lib() {
}
-
-/**
- * For backward compatibilty (< 5.3) we implemented
- * this function by our self. If we are in a newer
- * environment, then this is obsolete.
- *
- */
+// See: http://www.php.net/manual/en/function.array-replace-recursive.php#92574.
if (!function_exists('array_replace_recursive')) {
+ /**
+ * For backward compatibilty (< 5.3) we implemented this function by our self.
+ *
+ * If we are in a newer environment, then this is obsolete.
+ */
function array_replace_recursive($array, $array1) {
if (!function_exists('recurse')) {
+ /**
+ * Helper functions.
+ */
function recurse($array, $array1) {
foreach ($array1 as $key => $value) {
- // create new key in $array, if it is empty or not an array
+ // 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
+ // Overwrite the value in the base array.
if (is_array($value)) {
$value = recurse($array[$key], $value);
}
@@ -195,7 +195,7 @@ if (!function_exists('array_replace_recursive')) {
return $array;
}
- // handle the arguments, merge one by one
+ // Handle the arguments, merge one by one.
$args = func_get_args();
$array = $args[0];
if (!is_array($array)) {
@@ -210,8 +210,3 @@ if (!function_exists('array_replace_recursive')) {
}
}
}
-
-
-
-
-
diff --git a/views_pdf_plugin_display.inc b/views_pdf_plugin_display.inc
index 69ededa..69f7c1e 100644
--- a/views_pdf_plugin_display.inc
+++ b/views_pdf_plugin_display.inc
@@ -65,7 +65,7 @@ class views_pdf_plugin_display extends views_plugin_display_page {
// Defines external configuration for TCPDF library
$tcpdf_path = drupal_realpath(views_pdf_get_library('tcpdf'));
$cache_path = 'public://views_pdf_cache/';
- if(file_prepare_directory($cache_path, FILE_CREATE_DIRECTORY) == TRUE){
+ if (file_prepare_directory($cache_path, FILE_CREATE_DIRECTORY) == TRUE) {
global $base_url;
define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
define('K_PATH_MAIN', dirname($_SERVER['SCRIPT_FILENAME']));
diff --git a/views_pdf_plugin_row_fields.inc b/views_pdf_plugin_row_fields.inc
index 03a4281..128de3e 100644
--- a/views_pdf_plugin_row_fields.inc
+++ b/views_pdf_plugin_row_fields.inc
@@ -135,77 +135,17 @@ class views_pdf_plugin_row_fields extends views_plugin_row {
continue;
}
-
$form['formats'][$field] = array(
'#type' => 'fieldset',
'#title' => check_plain($option),
- '#collapsed' => TRUE,
- '#collapsible' => TRUE,
- );
-
- $form['formats'][$field]['position'] = array(
- '#type' => 'fieldset',
- '#title' => t('Position Settings'),
'#collapsed' => FALSE,
'#collapsible' => TRUE,
);
- $form['formats'][$field]['position']['object'] = array(
- '#type' => 'select',
- '#title' => t('Position relative to'),
- '#required' => FALSE,
- '#options' => $relativeElements,
- '#default_value' => !empty($this->options['formats'][$field]['position']['object']) ? $this->options['formats'][$field]['position']['object'] : 'page',
- );
-
- $form['formats'][$field]['position']['corner'] = array(
- '#type' => 'radios',
- '#title' => t('Position relative to corner'),
- '#required' => FALSE,
- '#options' => array(
- 'top_left' => t('Top Left'),
- 'top_right' => t('Top Right'),
- 'bottom_left' => t('Bottom Left'),
- 'bottom_right' => t('Bottom Right'),
- ),
- '#default_value' => !empty($this->options['formats'][$field]['position']['corner']) ? $this->options['formats'][$field]['position']['corner'] : 'top_left',
- );
-
- $relativeElements['field_' . $field] = t('Field: !field', array('!field' => $option));
-
-
- $form['formats'][$field]['position']['x'] = array(
- '#type' => 'textfield',
- '#title' => t('Position X'),
- '#required' => FALSE,
- '#default_value' => !empty($this->options['formats'][$field]['position']['x']) ? $this->options['formats'][$field]['position']['x'] : '',
- );
-
- $form['formats'][$field]['position']['y'] = array(
- '#type' => 'textfield',
- '#title' => t('Position Y'),
- '#required' => FALSE,
- '#default_value' => !empty($this->options['formats'][$field]['position']['y']) ? $this->options['formats'][$field]['position']['y'] : '',
- );
-
- $form['formats'][$field]['position']['width'] = array(
- '#type' => 'textfield',
- '#title' => t('Width'),
- '#required' => FALSE,
- '#default_value' => !empty($this->options['formats'][$field]['position']['width']) ? $this->options['formats'][$field]['position']['width'] : '',
- );
-
- $form['formats'][$field]['position']['height'] = array(
- '#type' => 'textfield',
- '#title' => t('Height'),
- '#required' => FALSE,
- '#default_value' => !empty($this->options['formats'][$field]['position']['height']) ? $this->options['formats'][$field]['position']['height'] : '',
- );
-
$form['formats'][$field]['text'] = array(
'#type' => 'fieldset',
'#title' => t('Text Settings'),
- '#collapsed' => FALSE,
+ '#collapsed' => TRUE,
'#collapsible' => TRUE,
);
@@ -253,7 +193,7 @@ class views_pdf_plugin_row_fields extends views_plugin_row {
$form['formats'][$field]['render'] = array(
'#type' => 'fieldset',
'#title' => t('Render Settings'),
- '#collapsed' => FALSE,
+ '#collapsed' => TRUE,
'#collapsible' => TRUE,
);
$form['formats'][$field]['render']['is_html'] = array(
@@ -281,6 +221,63 @@ class views_pdf_plugin_row_fields extends views_plugin_row {
'#default_value' => isset($this->options['formats'][$field]['render']['eval_after']) ? $this->options['formats'][$field]['render']['eval_after'] : '',
);
+ $form['formats'][$field]['position'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Position Settings'),
+ '#collapsed' => FALSE,
+ '#collapsible' => TRUE,
+ );
+
+ $form['formats'][$field]['position']['object'] = array(
+ '#type' => 'select',
+ '#title' => t('Position relative to'),
+ '#required' => FALSE,
+ '#options' => $relativeElements,
+ '#default_value' => !empty($this->options['formats'][$field]['position']['object']) ? $this->options['formats'][$field]['position']['object'] : 'page',
+ );
+
+ $form['formats'][$field]['position']['corner'] = array(
+ '#type' => 'radios',
+ '#title' => t('Position relative to corner'),
+ '#required' => FALSE,
+ '#options' => array(
+ 'top_left' => t('Top Left'),
+ 'top_right' => t('Top Right'),
+ 'bottom_left' => t('Bottom Left'),
+ 'bottom_right' => t('Bottom Right'),
+ ),
+ '#default_value' => !empty($this->options['formats'][$field]['position']['corner']) ? $this->options['formats'][$field]['position']['corner'] : 'top_left',
+ );
+
+ $relativeElements['field_' . $field] = t('Field: !field', array('!field' => $option));
+
+ $form['formats'][$field]['position']['x'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Position X'),
+ '#required' => FALSE,
+ '#default_value' => !empty($this->options['formats'][$field]['position']['x']) ? $this->options['formats'][$field]['position']['x'] : '',
+ );
+
+ $form['formats'][$field]['position']['y'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Position Y'),
+ '#required' => FALSE,
+ '#default_value' => !empty($this->options['formats'][$field]['position']['y']) ? $this->options['formats'][$field]['position']['y'] : '',
+ );
+
+ $form['formats'][$field]['position']['width'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Width'),
+ '#required' => FALSE,
+ '#default_value' => !empty($this->options['formats'][$field]['position']['width']) ? $this->options['formats'][$field]['position']['width'] : '',
+ );
+
+ $form['formats'][$field]['position']['height'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Height'),
+ '#required' => FALSE,
+ '#default_value' => !empty($this->options['formats'][$field]['position']['height']) ? $this->options['formats'][$field]['position']['height'] : '',
+ );
}
$form['leading_template'] = array(
diff --git a/views_pdf_plugin_style_table.inc b/views_pdf_plugin_style_table.inc
index c4d1ab8..3b1e760 100644
--- a/views_pdf_plugin_style_table.inc
+++ b/views_pdf_plugin_style_table.inc
@@ -54,9 +54,6 @@ class views_pdf_plugin_style_table extends views_plugin_style {
'css' => array(drupal_get_path('module', 'views_pdf') . '/theme/admin.css'),
);
- $form['#theme'] = 'views_pdf_plugin_style_table';
- $form['#attached'] = $attached;
-
$columns = $this->display->handler->get_field_labels();
$fields = $this->display->handler->get_option('fields');
@@ -93,9 +90,12 @@ class views_pdf_plugin_style_table extends views_plugin_style {
// the $id of the column for dependency checking.
$id = 'edit-style-options-columns-' . $safe;
- // markup for the field name
- $form['info'][$field]['name'] = array(
- '#markup' => $column,
+ // Markup for the field name.
+ $form['info'][$field] = array(
+ '#title' => $column,
+ '#type' => 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => TRUE,
);
$form['info'][$field]['header_style']['text'] = array(
diff --git a/views_pdf_template.php b/views_pdf_template.php
index 89345a7..f7d97d5 100644
--- a/views_pdf_template.php
+++ b/views_pdf_template.php
@@ -4,9 +4,8 @@
* @file
* PDF Class to generate PDFs with native PHP. This class based on FPDF and FPDI.
*
- * A direct include of this class is not realy possible. The basic functions of drupal must be
- * present.
- *
+ * A direct include of this class is not realy possible. The basic functions of
+ * drupal must be present.
*/
@@ -98,57 +97,74 @@ class PdfTemplate extends FPDI {
'timesbi' => 'Times New Roman Bold Italic',
'timesi' => 'Times New Roman Italic',
'zapfdingbats' => 'Zapf Dingbats',
- 'zarbold' => 'ZarBold'
+ 'zarbold' => 'ZarBold',
);
/**
* This method overrides the parent constructor method.
- * this is need to reset the default values.
+ *
+ * This is need to reset the default values.
*/
- public function __construct($orientation='P', $unit='mm', $format='A4', $unicode=TRUE, $encoding='UTF-8', $diskcache=FALSE) {
+ public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4', $unicode = TRUE, $encoding = 'UTF-8', $diskcache = FALSE) {
parent::__construct($orientation, $unit, $format, $unicode, $encoding, $diskcache);
$this->defaultOrientation = $orientation;
$this->defaultFormat = $format;
}
+ /**
+ * Set the size.
+ */
public function setDefaultFontSize($size) {
$this->defaultFontSize = $size;
}
+ /**
+ * Set the Font-family.
+ */
public function setDefaultFontFamily($family) {
$this->defaultFontFamily = $family;
}
+ /**
+ * Set the Font-style.
+ */
public function setDefaultFontStyle($style) {
$this->defaultFontStyle = $style;
}
+ /**
+ * Set the text-align.
+ */
public function setDefaultTextAlign($style) {
$this->defaultTextAlign = $style;
}
+ /**
+ * Set the Font-color.
+ */
public function setDefaultFontColor($color) {
$this->defaultFontColor = $color;
}
- public function setDefaultPageTemplate($path, $key, $pageNumbering = 'main') {
+ /**
+ * Set the page template.
+ */
+ public function setDefaultPageTemplate($path, $key, $page_numbering = 'main') {
$this->defaultPageTemplateFiles[$key] = array(
'path' => $path,
- 'numbering' => $pageNumbering
+ 'numbering' => $page_numbering,
);
}
/**
- * This method must be overriden, in the other case, some
- * output is printed to the header.
+ * This method must be overriden, in the other case, some output is printed to the header.
*/
function Header() {
}
/**
- * This method must be overriden, in the other case, some
- * output is printed to the footer.
+ * This method must be overriden, in the other case, someoutput is printed to the footer.
*/
function Footer() {
@@ -180,8 +196,11 @@ class PdfTemplate extends FPDI {
/**
* Parse color input into an array.
*
- * @param string $color Color entered by the user
- * @return array color as an array
+ * @param string $color
+ * Color entered by the user.
+ *
+ * @return array
+ * Color as an array.
*/
public function parseColor($color) {
$color = trim($color, ', ');
@@ -217,8 +236,8 @@ class PdfTemplate extends FPDI {
$options['position'] += array(
'corner' => 'top_left',
'x' => 0,
- 'y' => 0,
- 'object' => '',
+ 'y' => 10,
+ 'object' => 'last_position',
'width' => 0,
'height' => 0,
);
@@ -425,7 +444,7 @@ class PdfTemplate extends FPDI {
$patternFile = views_pdf_get_library('tcpdf') . '/hyphenate_patterns/' . $patternFile;
if (file_exists($patternFile)) {
- $hyphen_patterns = $this->getHyphenPatternsFromTEX($patternFile);
+ $hyphen_patterns = TCPDF_STATIC::getHyphenPatternsFromTEX($patternFile);
// Bugfix if you like to print some html code to the PDF, we
// need to prevent the replacement of this tags.
@@ -608,7 +627,7 @@ class PdfTemplate extends FPDI {
'corner' => 'top_left',
'x' => NULL,
'y' => NULL,
- 'object' => '',
+ 'object' => 'last_position',
'width' => NULL,
'height' => NULL,
);
@@ -785,7 +804,7 @@ class PdfTemplate extends FPDI {
/**
* This method adds a new page to the PDF.
*/
- public function addPage($path = NULL, $reset = FALSE, $numbering = 'main') {
+ public function addPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false, $path = NULL, $reset = FALSE, $numbering = 'main') {
// Do not add any new page, if we are writing
// in the footer or header.