commit 11b6350558487f4e925fa977ddd7b6c48416e810
Author: Assos Assos <assos+forge@centrale-marseille.fr>
Date:   Wed Nov 5 22:49:30 2014 +0100

    Weekly update of contrib modules

diff --git a/drupal7/sites/all/modules/views_pdf/field_plugins/views_pdf_handler_page_break.inc b/drupal7/sites/all/modules/views_pdf/field_plugins/views_pdf_handler_page_break.inc
index a197d985..b1b24542 100644
--- a/drupal7/sites/all/modules/views_pdf/field_plugins/views_pdf_handler_page_break.inc
+++ b/drupal7/sites/all/modules/views_pdf/field_plugins/views_pdf_handler_page_break.inc
@@ -14,8 +14,6 @@
  */
 class views_pdf_handler_page_break extends views_handler_field {
 
-  protected $countRecords = 0;
-
   /**
    * This method  is used to query data. In our case
    * we want that no data is queried.
@@ -63,29 +61,24 @@ class views_pdf_handler_page_break extends views_handler_field {
   }
 
   /**
-   * This method renders the page break. It uses the PDF class to
-   * add a page break.
+   * This method renders the page break.
+   *
+   * Various settings from options form are taken into an account before
+   * deciding whether to add pagebreak or not.
    */
   function render($values) {
-    if (isset($this->view->pdf) && is_object($this->view->pdf)) {
-      if ($this->options['last_row'] == TRUE && ($this->countRecords + 1 >= $this->view->total_rows)) {
-        return '';
-      }
+    // Row index starts from 0 so substract 1 one from result count.
+    $last_row = $this->view->row_index == count($this->view->result) - 1;
+    // Calculate if 'every_nth' rule matches for this row.
+    $add_pagebreak = ($this->view->row_index + 1) % $this->options['every_nth'] == 0;
 
-      $this->countRecords++;
-      if ($this->countRecords == $this->view->total_rows + 1) {
-        $this->countRecords = 1;
-      }
-
-      $output = '';
-      if ($this->countRecords % $this->options['every_nth'] == 0) {
-        $output .= '<br pagebreak="true" />';
-      }
-      else {
-        $output .= '';
-      }
-      return $output;
+    // Last row setting takes priority over 'every_nth' rule if we're infact
+    // rendering last row.
+    if (($this->options['last_row'] == FALSE || !$last_row) && $add_pagebreak) {
+      return '<br pagebreak="true" />';
     }
+
+    return '';
   }
 
   /**
diff --git a/drupal7/sites/all/modules/views_pdf/modules/views_append/views_append.info b/drupal7/sites/all/modules/views_pdf/modules/views_append/views_append.info
index e6125231..5285c06f 100644
--- a/drupal7/sites/all/modules/views_pdf/modules/views_append/views_append.info
+++ b/drupal7/sites/all/modules/views_pdf/modules/views_append/views_append.info
@@ -7,9 +7,9 @@ core = 7.x
 files[] = views_append_handler_append_view.inc
 
 
-; Information added by  packaging script on 2013-11-18
-version = "7.x-1.3"
+; Information added by Drupal.org packaging script on 2014-10-30
+version = "7.x-1.4"
 core = "7.x"
 project = "views_pdf"
-datestamp = "1384819110"
+datestamp = "1414683531"
 
diff --git a/drupal7/sites/all/modules/views_pdf/modules/views_view_field/views_view_field.info b/drupal7/sites/all/modules/views_pdf/modules/views_view_field/views_view_field.info
index d737e92e..887f37c7 100644
--- a/drupal7/sites/all/modules/views_pdf/modules/views_view_field/views_view_field.info
+++ b/drupal7/sites/all/modules/views_pdf/modules/views_view_field/views_view_field.info
@@ -7,9 +7,9 @@ core = 7.x
 files[] = views_view_field_handler_include_view.inc
 
 
-; Information added by  packaging script on 2013-11-18
-version = "7.x-1.3"
+; Information added by Drupal.org packaging script on 2014-10-30
+version = "7.x-1.4"
 core = "7.x"
 project = "views_pdf"
-datestamp = "1384819110"
+datestamp = "1414683531"
 
diff --git a/drupal7/sites/all/modules/views_pdf/modules/views_view_field/views_view_field_handler_include_view.inc b/drupal7/sites/all/modules/views_pdf/modules/views_view_field/views_view_field_handler_include_view.inc
index bb4c1f72..53969f31 100644
--- a/drupal7/sites/all/modules/views_pdf/modules/views_view_field/views_view_field_handler_include_view.inc
+++ b/drupal7/sites/all/modules/views_pdf/modules/views_view_field/views_view_field_handler_include_view.inc
@@ -145,6 +145,7 @@ class views_view_field_handler_include_view extends views_handler_field {
     $view = views_get_view($view_name);
 
     // look for a display named pdf_X.
+    $pdf_display = NULL;
     foreach($view->display as $display) {
       if (preg_match('/^pdf_/', $display->id)) {
         // found a PDF display so break out of loop.
diff --git a/drupal7/sites/all/modules/views_pdf/views_pdf.info b/drupal7/sites/all/modules/views_pdf/views_pdf.info
index ae6ed895..ed92e6f9 100644
--- a/drupal7/sites/all/modules/views_pdf/views_pdf.info
+++ b/drupal7/sites/all/modules/views_pdf/views_pdf.info
@@ -15,9 +15,9 @@ files[] = views_pdf_plugin_row_fields.inc
 files[] = field_plugins/views_pdf_handler_page_number.inc
 files[] = field_plugins/views_pdf_handler_page_break.inc
 
-; Information added by  packaging script on 2013-11-18
-version = "7.x-1.3"
+; Information added by Drupal.org packaging script on 2014-10-30
+version = "7.x-1.4"
 core = "7.x"
 project = "views_pdf"
-datestamp = "1384819110"
+datestamp = "1414683531"
 
diff --git a/drupal7/sites/all/modules/views_pdf/views_pdf_plugin_display.inc b/drupal7/sites/all/modules/views_pdf/views_pdf_plugin_display.inc
index 5b5bf9b5..ac4c4b55 100644
--- a/drupal7/sites/all/modules/views_pdf/views_pdf_plugin_display.inc
+++ b/drupal7/sites/all/modules/views_pdf/views_pdf_plugin_display.inc
@@ -120,6 +120,7 @@ class views_pdf_plugin_display extends views_plugin_display_page {
 
     if (empty($path_to_store_pdf)) {
       $path_to_store_pdf = $this->view->get_title();
+      $this->view->pdf->SetTitle($this->view->get_title());
     }
 
     if (!preg_match('/\.pdf$/', $path_to_store_pdf)) {
diff --git a/drupal7/sites/all/modules/views_pdf/views_pdf_template.php b/drupal7/sites/all/modules/views_pdf/views_pdf_template.php
index 585ad90b..a3e16d09 100644
--- a/drupal7/sites/all/modules/views_pdf/views_pdf_template.php
+++ b/drupal7/sites/all/modules/views_pdf/views_pdf_template.php
@@ -14,7 +14,14 @@
  * Get the depending classes.
  */
 require_once views_pdf_get_library('tcpdf') . '/tcpdf.php';
-require_once views_pdf_get_library('fpdi') . '/fpdi2tcpdf_bridge.php';
+
+if (file_exists(views_pdf_get_library('fpdi') . '/fpdi_bridge.php')) {
+  require_once views_pdf_get_library('fpdi') . '/fpdi_bridge.php';
+}
+else {
+  require_once views_pdf_get_library('fpdi') . '/fpdi2tcpdf_bridge.php';
+}
+
 require_once views_pdf_get_library('fpdi') . '/fpdi.php';
 
 
@@ -194,8 +201,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, ', ');
@@ -400,7 +410,7 @@ class PdfTemplate extends FPDI {
     $pageDim = $this->getPageDimensions();
 
     // Render the content if it is not already:
-    if (is_object($view) && $key != NULL && isset($view->field[$key]) && is_object($view->field[$key])) {
+    if (is_object($view) && $key != NULL && isset($view->field[$key]) && is_object($view->field[$key]) && !is_string($row)) {
       $content = $view->field[$key]->theme($row);
     }
     elseif (is_string($row)) {
@@ -523,7 +533,12 @@ class PdfTemplate extends FPDI {
     }
 
     // Write the content of a field to the pdf file:
-    $this->MultiCell($w, $h, $prefix . $content, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml, $autopadding, $maxh, $valign, $fitcell);
+    if (!empty($content)) {
+      $this->MultiCell($w, $h, $prefix . $content, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml, $autopadding, $maxh, $valign, $fitcell);
+    }
+    else {
+      $this->MultiCell($w, $h, $prefix, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml, $autopadding, $maxh, $valign, $fitcell);
+    }
 
     // Reset font to default.
     $this->SetFont($this->defaultFontFamily, implode('', $this->defaultFontStyle), $this->defaultFontSize);
@@ -692,7 +707,7 @@ class PdfTemplate extends FPDI {
       $this->SetX($x);
       $this->setPage($page);
 
-      $this->renderRow($x, $y, $column->options['label'], $headerOptions);
+      $this->renderRow($x, $y, $column->options['label'], $headerOptions, $view, $id, FALSE);
       $x += $headerOptions['position']['width'];
     }
 
