Skip to content

Commit

Permalink
Updates to release v1.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Oct 13, 2018
1 parent 451e999 commit ca14256
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 49 deletions.
7 changes: 7 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Change Log: `yii2-export`
=========================

## version 1.3.5

**Date:** 13-Oct-2018

- Enhance PDF output rendering by cleaning HTML for unwanted tags.
- (enh #274): Correctly parse UTF-8 filename.

## version 1.3.4

**Date:** 12-Oct-2018
Expand Down
2 changes: 1 addition & 1 deletion src/ExportColumnAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2018
* @package yii2-export
* @version 1.3.4
* @version 1.3.5
*/

namespace kartik\export;
Expand Down
12 changes: 9 additions & 3 deletions src/ExportMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-export
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.3.4
* @version 1.3.5
*/

namespace kartik\export;
Expand Down Expand Up @@ -793,7 +793,8 @@ public function run()
"Invalid permissions to write to '{$this->folder}' as set in `ExportMenu::folder` property."
);
}
$file = self::slash($this->folder) . iconv("UTF-8", "ISO-8859-1//TRANSLIT", $this->filename) . '.' . $config['extension'];
$filename = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $this->filename);
$file = self::slash($this->folder) . $filename . '.' . $config['extension'];
$writer->save($file);
if ($this->stream) {
$this->clearOutputBuffers();
Expand Down Expand Up @@ -1221,7 +1222,12 @@ public function setVisibleColumns()
{
$columns = [];
foreach ($this->columns as $key => $column) {
if (!empty($column->hiddenFromExport) || $column instanceof ActionColumn || in_array($key, $this->noExportColumns)) {
$isActionColumn = $column instanceof ActionColumn;
$isNoExport = in_array($key, $this->noExportColumns);
if ($isActionColumn && !$isNoExport) {
$this->noExportColumns[] = $key;
}
if (!empty($column->hiddenFromExport) || $isActionColumn || $isNoExport) {
continue;
}
$columns[] = $column;
Expand Down
2 changes: 1 addition & 1 deletion src/ExportMenuAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @package yii2-export
* @version 1.3.4
* @version 1.3.5
*/

namespace kartik\export;
Expand Down
47 changes: 39 additions & 8 deletions src/ExportWriterPdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @package yii2-export
* @version 1.3.4
* @version 1.3.5
*/

namespace kartik\export;

use DOMDocument;
use kartik\mpdf\Pdf;
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf;
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
Expand All @@ -24,7 +25,7 @@ class ExportWriterPdf extends Mpdf
/**
* @var string the exported output file name. Defaults to 'grid-export';
*/
public $filename;
public $filename = '';

/**
* @var array kartik\mpdf\Pdf component configuration settings
Expand Down Expand Up @@ -53,7 +54,7 @@ public function save($pFilename)
$fileHandle = parent::prepareForSave($pFilename);

// Default PDF paper size
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
$paperSize = 'LETTER'; // Letter (8.5"x11")

// Check for paper size and page orientation
if (null === $this->getSheetIndex()) {
Expand Down Expand Up @@ -104,12 +105,42 @@ public function save($pFilename)
$lib->DefOrientation = $orientation;
/** @noinspection PhpUndefinedMethodInspection */
$lib->AddPage($orientation);
$content = strtr($this->generateHTMLHeader(false) . $this->generateSheetData() . $this->generateHTMLFooter(), [
'@page { margin-left: 0.7in; margin-right: 0.7in; margin-top: 0.75in; margin-bottom: 0.75in; }' => '',
'body { margin-left: 0.7in; margin-right: 0.7in; margin-top: 0.75in; margin-bottom: 0.75in; }' => '',
]);
$content = $this->generateHTMLHeader(false) . $this->generateSheetData() . $this->generateHTMLFooter();
// Write to file
fwrite($fileHandle, $pdf->Output($content, $this->filename, Pdf::DEST_STRING));
fwrite($fileHandle, $pdf->Output(static::cleanHTML($content), $this->filename, Pdf::DEST_STRING));
parent::restoreStateAfterSave($fileHandle);
}

/**
* Cleans HTML of embedded script, style, and link tags
*
* @param string $content the source HTML content
* @return string the cleaned HTML content
*/
protected static function cleanHTML($content)
{
if (empty($content)) {
return $content;
}
$doc = new DOMDocument();
$doc->loadHTML($content);
static::removeElementsByTagName('script', $doc);
static::removeElementsByTagName('style', $doc);
static::removeElementsByTagName('link', $doc);
return $doc->saveHTML();
}

/**
* Remove DOM elements by tag name
* @param string $tagName the tag name to parse and remove
* @param DOMDocument $document the DomDocument object
*/
protected static function removeElementsByTagName($tagName, $document)
{
$nodeList = $document->getElementsByTagName($tagName);
for ($nodeIdx = $nodeList->length; --$nodeIdx >= 0;) {
$node = $nodeList->item($nodeIdx);
$node->parentNode->removeChild($node);
}
}
}
11 changes: 3 additions & 8 deletions src/assets/css/kv-export-columns.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@
* @package yii2-export
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.3.4
* @version 1.3.5
*
* Export Columns Selector Style Sheet
*
* Author: Kartik Visweswaran
* Copyright: 2015, Kartik Visweswaran, Krajee.com
* For more JQuery plugins visit http://plugins.krajee.com
* For more Yii related demos visit http://demos.krajee.com
*/

.dropdown-menu.kv-checkbox-list {
max-height: 350px;
min-width: 225px;
max-height: 360px;
min-width: 240px;
overflow: auto;
}

Expand Down
8 changes: 2 additions & 6 deletions src/assets/css/kv-export-columns.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
* @package yii2-export
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.3.4
* @version 1.3.5
*
* Export Columns Selector Style Sheet
*
* Author: Kartik Visweswaran
* Copyright: 2015, Kartik Visweswaran, Krajee.com
* For more JQuery plugins visit http://plugins.krajee.com
* For more Yii related demos visit http://demos.krajee.com
*/.dropdown-menu.kv-checkbox-list{max-height:350px;min-width:225px;overflow:auto}.kv-checkbox-list .checkbox{padding:0 20px}.kv-checkbox-list label{width:100%}.kv-checkbox-list label.disabled{cursor:not-allowed;filter:alpha(opacity=65);opacity:.65}.kv-toggle-all{font-style:italic;color:#337ab7}.kv-toggle-all:hover{color:#286090}
*/.dropdown-menu.kv-checkbox-list{max-height:360px;min-width:240px;overflow:auto}.kv-checkbox-list .checkbox{padding:0 20px}.kv-checkbox-list label{width:100%}.kv-checkbox-list label.disabled{cursor:not-allowed;filter:alpha(opacity=65);opacity:.65}.kv-toggle-all{font-style:italic;color:#337ab7}.kv-toggle-all:hover{color:#286090}
6 changes: 1 addition & 5 deletions src/assets/js/kv-export-columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
* @package yii2-export
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.3.4
* @version 1.3.5
*
* Export Columns Selector Validation Module.
*
* Author: Kartik Visweswaran
* Copyright: 2015, Kartik Visweswaran, Krajee.com
* For more JQuery plugins visit http://plugins.krajee.com
* For more Yii related demos visit http://demos.krajee.com
*/
(function ($) {
"use strict";
Expand Down
6 changes: 1 addition & 5 deletions src/assets/js/kv-export-columns.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
* @package yii2-export
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.3.4
* @version 1.3.5
*
* Export Columns Selector Validation Module.
*
* Author: Kartik Visweswaran
* Copyright: 2015, Kartik Visweswaran, Krajee.com
* For more JQuery plugins visit http://plugins.krajee.com
* For more Yii related demos visit http://demos.krajee.com
*/
!function(t){"use strict";var n=function(n,o){var e=this;e.$element=t(n),e.options=o,e.listen()};n.prototype={constructor:n,listen:function(){var t=this,n=t.$element,o=n.find('input[name="export_columns_toggle"]');n.off("click").on("click",function(t){t.stopPropagation()}),o.off("change").on("change",function(){var t=o.is(":checked");n.find('input[name="export_columns_selector[]"]:not([disabled])').prop("checked",t)})}},t.fn.exportcolumns=function(o){var e=Array.apply(null,arguments);return e.shift(),this.each(function(){var c=t(this),i=c.data("exportcolumns"),s="object"==typeof o&&o;i||c.data("exportcolumns",i=new n(this,t.extend({},t.fn.exportcolumns.defaults,s,t(this).data()))),"string"==typeof o&&i[o].apply(i,e)})},t.fn.exportcolumns.defaults={}}(window.jQuery);
6 changes: 1 addition & 5 deletions src/assets/js/kv-export-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
* @package yii2-export
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.3.4
* @version 1.3.5
*
* Export Data Validation Module.
*
* Author: Kartik Visweswaran
* Copyright: 2015, Kartik Visweswaran, Krajee.com
* For more JQuery plugins visit http://plugins.krajee.com
* For more Yii related demos visit http://demos.krajee.com
*/
(function ($) {
"use strict";
Expand Down
6 changes: 1 addition & 5 deletions src/assets/js/kv-export-data.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/views/_columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package yii2-export
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.3.4
* @version 1.3.5
*
* Column Selector View
*
Expand Down
2 changes: 1 addition & 1 deletion src/views/_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package yii2-export
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.3.4
* @version 1.3.5
*
* Export Submission View
*
Expand Down

0 comments on commit ca14256

Please sign in to comment.