diff --git a/views_pdf_plugin_row_fields.inc b/views_pdf_plugin_row_fields.inc index 03a4281..06e7883 100644 --- a/views_pdf_plugin_row_fields.inc +++ b/views_pdf_plugin_row_fields.inc @@ -11,48 +11,44 @@ */ class views_pdf_plugin_row_fields extends views_plugin_row { /** - * Renders the views. + * Renders the rows. */ - function render($records) { + function render($row) { $options = $this->option_definition(); - foreach ($records as $row_index => $row) { - $this->view->row_index = $row_index; - - // Header of a record - $path = $this->view->pdf->getTemplatePath($this->options['leading_template']); - $this->view->pdf->addPdfDocument($path); - - // Set row page template - $path = $this->view->pdf->getTemplatePath($this->options['template'], $row, $this->view); - $this->view->pdf->setDefaultPageTemplate($path, 'row', 'row'); - - // Due of limitations of field renderer, we invoke them - // here and not in the field render function. - foreach ($this->view->field as $id => $field) { - if (isset($this->options['formats'][$id])) { - $options = $this->options['formats'][$id]; - } - else { - $options = array(); - } - - $this->view->pdf->drawContent($row, $options, $this->view, $id); - - // Set or update header / footer options per row - // this ensures that we write the last record for each page - // in the cache. - $this->view->pdf->setHeaderFooter($row, $this->options, $this->view); + // Header of a record + $path = $this->view->pdf->getTemplatePath($this->options['leading_template']); + $this->view->pdf->addPdfDocument($path); + + // Set row page template + $path = $this->view->pdf->getTemplatePath($this->options['template'], $row, $this->view); + $this->view->pdf->setDefaultPageTemplate($path, 'row', 'row'); + + // Due of limitations of field renderer, we invoke them + // here and not in the field render function. + foreach ($this->view->field as $id => $field) { + if (isset($this->options['formats'][$id])) { + $options = $this->options['formats'][$id]; + } + else { + $options = array(); } - // Footer of a record - $path = $this->view->pdf->getTemplatePath($this->options['succeed_template']); - $this->view->pdf->addPdfDocument($path); + $this->view->pdf->drawContent($row, $options, $this->view, $id); - // Reset the row page number - $this->view->pdf->resetRowPageNumber(); + // Set or update header / footer options per row + // this ensures that we write the last record for each page + // in the cache. + $this->view->pdf->setHeaderFooter($row, $this->options, $this->view); } + // Footer of a record + $path = $this->view->pdf->getTemplatePath($this->options['succeed_template']); + $this->view->pdf->addPdfDocument($path); + + // Reset the row page number + $this->view->pdf->resetRowPageNumber(); + } /** @@ -131,10 +127,6 @@ class views_pdf_plugin_row_fields extends views_plugin_row { foreach ($options as $field => $option) { - if (isset($fields[$field]['exclude']) && $fields[$field]['exclude'] == 1) { - continue; - } - $form['formats'][$field] = array( '#type' => 'fieldset', diff --git a/views_pdf_plugin_style_unformatted.inc b/views_pdf_plugin_style_unformatted.inc index 8e7143a..2f4b4e6 100644 --- a/views_pdf_plugin_style_unformatted.inc +++ b/views_pdf_plugin_style_unformatted.inc @@ -11,25 +11,59 @@ * This class holds all the funtionality used for the unformatted style plugin. */ class views_pdf_plugin_style_unformatted extends views_plugin_style { + /** - * Rendering function + * Render the grouping sets. + * + * Plugins may override this method if they wish some other way of handling + * grouping. + * + * @param $sets + * Array containing the grouping sets to render. + * @param $level + * Integer indicating the hierarchical level of the grouping. + * + * @return string + * Rendered output of given grouping sets. */ - function render() { - if ($this->uses_row_plugin() && empty($this->row_plugin)) { - vpr('views_plugin_style_default: Missing row plugin'); - return; - } - + function render_grouping_sets($sets, $level = 0) { $output = ''; + $next_level = $level + 1; + foreach ($sets as $set) { + $row = reset($set['rows']); + // Render as a grouping set. + if (is_array($row) && isset($row['group'])) { + $field_id = $this->options['grouping'][$level]['field']; + $options = array(); + if(isset($this->row_plugin->options['formats'][$field_id])) { + $options = $this->row_plugin->options['formats'][$field_id]; + } + $this->view->pdf->drawContent($set['group'], $options, $this->view); + $this->render_grouping_sets($set['rows'], $next_level); + } + // Render as a record set. + else { + if (isset($set['group'])) { + $field_id = $this->options['grouping'][$level]['field']; + $options = array(); + if(isset($this->row_plugin->options['formats'][$field_id])) { + $options = $this->row_plugin->options['formats'][$field_id]; + } + $this->view->pdf->drawContent($set['group'], $options, $this->view); + } - $this->view->numberOfRecords = count($this->view->result); - if ($this->uses_row_plugin()) { - $this->row_plugin->render($this->view->result); + if ($this->uses_row_plugin()) { + foreach ($set['rows'] as $index => $row) { + $this->view->row_index = $index; + $set['rows'][$index] = $this->row_plugin->render($row); + } + } + } } - + unset($this->view->row_index); return $output; } - + /** * Attach this view to another display as a feed. *