Skip to content

Commit

Permalink
Merge pull request #207 from ThaDafinser/feature/getPost
Browse files Browse the repository at this point in the history
Allow GET instead of POST
  • Loading branch information
ThaDafinser committed Aug 31, 2015
2 parents 434223d + 17a5935 commit ccbcae3
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 29 deletions.
4 changes: 4 additions & 0 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
'sortDirections' => 'sortDirections',

'massIds' => 'ids',

'method' => 'POST',
],

'daterange' => [
Expand All @@ -80,6 +82,8 @@
'isSearch' => 'isSearch',

'massIds' => 'ids',

'method' => 'POST',
],
],

Expand Down
2 changes: 1 addition & 1 deletion config/zfcdatagrid.local.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ return array(
),

// The output+save directory
'path' => 'public/download',
'path' => getcwd() . 'public/download',

'mode' => 'direct'
)
Expand Down
20 changes: 7 additions & 13 deletions src/ZfcDatagrid/Renderer/AbstractRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

use Doctrine\Common\Proxy\Exception\InvalidArgumentException;
use Zend\Cache;
use Zend\Console\Request as ConsoleRequest;
use Zend\Http\PhpEnvironment\Request as HttpRequest;
use Zend\I18n\Translator\Translator;
use Zend\Mvc\MvcEvent;
use Zend\Paginator\Paginator;
Expand Down Expand Up @@ -580,18 +578,14 @@ public function getFiltersDefault()
{
$filters = [];

// @todo skip this, if $grid->isUserFilterEnabled() ?
if ($this->getRequest() instanceof ConsoleRequest || ($this->getRequest() instanceof HttpRequest && ! $this->getRequest()->isPost())) {
foreach ($this->getColumns() as $column) {
/* @var $column \ZfcDatagrid\Column\AbstractColumn */
if ($column->hasFilterDefaultValue() === true) {
$filter = new Filter();
$filter->setFromColumn($column, $column->getFilterDefaultValue());
$filters[] = $filter;
foreach ($this->getColumns() as $column) {
/* @var $column \ZfcDatagrid\Column\AbstractColumn */
if ($column->hasFilterDefaultValue() === true) {
$filter = new Filter();
$filter->setFromColumn($column, $column->getFilterDefaultValue());
$filters[] = $filter;

$column->setFilterActive($filter->getDisplayColumnValue());
}
$column->setFilterActive($filter->getDisplayColumnValue());
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/ZfcDatagrid/Renderer/BootstrapTable/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public function getFilters()
$request = $this->getRequest();

$filters = [];
if ($request->isPost() === true && $request->getPost('toolbarFilters') !== null) {
foreach ($request->getPost('toolbarFilters') as $uniqueId => $value) {
if (($request->isPost() === true || $request->isGet() === true) && $request->getPost('toolbarFilters', $request->getQuery('toolbarFilters')) !== null) {
foreach ($request->getPost('toolbarFilters', $request->getQuery('toolbarFilters')) as $uniqueId => $value) {
if ($value != '') {
foreach ($this->getColumns() as $column) {
/* @var $column \ZfcDatagrid\Column\AbstractColumn */
Expand Down Expand Up @@ -144,9 +144,9 @@ public function getCurrentPageNumber()
$optionsRenderer = $this->getOptionsRenderer();
$parameterNames = $optionsRenderer['parameterNames'];

if ($this->getRequest() instanceof HttpRequest) {
$this->currentPageNumber = (int) $this->getRequest()->getPost($parameterNames['currentPage'], $this->getRequest()
->getQuery($parameterNames['currentPage'], 1));
$request = $this->getRequest();
if ($request instanceof HttpRequest) {
$this->currentPageNumber = (int) $request->getPost($parameterNames['currentPage'], $request->getQuery($parameterNames['currentPage'], 1));
}

return (int) $this->currentPageNumber;
Expand Down
14 changes: 7 additions & 7 deletions src/ZfcDatagrid/Renderer/JqGrid/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public function getSortConditions()

$sortConditions = [];

$sortColumns = $request->getPost($parameterNames['sortColumns']);
$sortDirections = $request->getPost($parameterNames['sortDirections']);
$sortColumns = $request->getPost($parameterNames['sortColumns'], $request->getQuery($parameterNames['sortColumns']));
$sortDirections = $request->getPost($parameterNames['sortDirections'], $request->getQuery($parameterNames['sortDirections']));
if ($sortColumns != '') {
$sortColumns = explode(',', $sortColumns);
$sortDirections = explode(',', $sortDirections);
Expand Down Expand Up @@ -110,13 +110,13 @@ public function getFilters()
$parameterNames = $optionsRenderer['parameterNames'];

$request = $this->getRequest();
$isSearch = $request->getPost($parameterNames['isSearch']);
$isSearch = $request->getPost($parameterNames['isSearch'], $request->getQuery($parameterNames['isSearch']));
if ('true' == $isSearch) {
// User filtering
foreach ($this->getColumns() as $column) {
/* @var $column \ZfcDatagrid\Column\AbstractColumn */
if ($request->getPost($column->getUniqueId()) != '') {
$value = $request->getPost($column->getUniqueId());
if ($request->getPost($column->getUniqueId(), $request->getQuery($column->getUniqueId())) != '') {
$value = $request->getPost($column->getUniqueId(), $request->getQuery($column->getUniqueId()));

$filter = new \ZfcDatagrid\Filter();
$filter->setFromColumn($column, $value);
Expand Down Expand Up @@ -145,7 +145,7 @@ public function getCurrentPageNumber()

$request = $this->getRequest();
if ($request instanceof HttpRequest) {
$currentPage = $request->getPost($parameterNames['currentPage']);
$currentPage = $request->getPost($parameterNames['currentPage'], $request->getQuery($parameterNames['currentPage']));
if ($currentPage != '') {
$this->currentPageNumber = (int) $currentPage;
}
Expand All @@ -157,7 +157,7 @@ public function getCurrentPageNumber()
public function execute()
{
$request = $this->getRequest();
if ($request->isXmlHttpRequest() === true && $request->isPost() === true && $request->getPost('nd') != '') {
if ($request->isXmlHttpRequest() === true && $request->getPost('nd', $request->getQuery('nd')) != '') {
// AJAX Request...load only data...
$viewModel = new JsonModel();
$viewModel->setVariable('data', $this->getDataJqGrid());
Expand Down
7 changes: 6 additions & 1 deletion view/zfc-datagrid/renderer/bootstrapTable/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ if(count($this->massActions) > 0){
<?php $this->inlineScript()->captureEnd(); ?>
<?php endif; ?>

<form name="form_<?php echo $this->gridId; ?>" method="post" action="<?php echo $this->url(null, array(), array(), true); ?>">
<form name="form_<?php echo $this->gridId; ?>" method="<?= $this->parameterNames['method']; ?>" action="<?php echo $this->url(null, array(), array(), true); ?>">

<input type="submit" style="width: 0px; height:0px; margin: 0; padding: 0; border: 0;" name="hiddenSubmit" />
<input type="hidden" name="<?php echo $this->parameterNames['sortColumns']; ?>" value="<?php echo $this->activeParameters[$this->parameterNames['sortColumns']]; ?>" />
<input type="hidden" name="<?php echo $this->parameterNames['sortDirections']; ?>" value="<?php echo $this->activeParameters[$this->parameterNames['sortDirections']]; ?>" />

<?php
foreach($this->parameters as $name => $value){
echo '<input type="hidden" name="' . $name . '" value="' . $value . '" />';
}
?>

<?php echo $this->toolbar; ?>

Expand Down
2 changes: 1 addition & 1 deletion view/zfc-datagrid/renderer/jqGrid/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ var grid_<?php echo $this->gridId; ?> = $('#<?php echo $this->gridId; ?>').jqGri

rowNum: <?php echo $itemCountPerPage; ?>,

mtype : 'POST',
mtype : '<?= $parameterNames['method']; ?>',
postData: {
<?php
echo implode(',', $parametersHtml);
Expand Down
2 changes: 1 addition & 1 deletion view/zfc-datagrid/toolbar/export.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ foreach($this->parameters as $name => $value){
foreach($this->exportRenderers as $type => $name){
$urlExport = $url . '?' . $this->generalParameterNames['rendererType'] . '=' . $type . $parametersAdd;
?>
<a class="btn" href="<?php echo $urlExport; ?>">
<a class="btn btn-default" href="<?php echo $urlExport; ?>">
<?php echo $name; ?>
</a>
<?php
Expand Down

0 comments on commit ccbcae3

Please sign in to comment.