Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add latest updates from 2.1

  • Loading branch information...
commit 3acdd32ecf67d9e53b703850ae9218a982b6173d 1 parent bc43444
@Abhoryo authored
View
13 CHANGELOG.md
@@ -1,3 +1,16 @@
+`14 October 2012`
+ * Don't redirect with an AJAX request
+
+`13 October 2012`
+ * Fix bug - Fixed errors with default values in Column __initialize.
+ * Add escape option for the value of a cell
+
+`7 October 2012`
+ * Fix bug - Fix file Content-Length calculation for export.
+
+`2 October 2012`
+ * Fix bug - Fix field name in DQL for multi level entities
+
`21 September 2012`
* Fix bug - Wrong regex for the eq operator for the vector source and the setData function
* Fix bug - Fix excpetion in ArrayColumn class
View
24 Grid/Column/Column.php
@@ -97,6 +97,7 @@
protected $selectMulti;
protected $selectExpanded;
protected $searchOnClick = false;
+ protected $safe;
protected $separator;
protected $dataJunction;
@@ -181,7 +182,8 @@ public function __initialize(array $params)
$this->setDefaultOperator($this->getParam('defaultOperator', self::OPERATOR_LIKE));
// Features
- $this->setSearchOnClick($this->getParam('searchOnClick'), false);
+ $this->setSearchOnClick($this->getParam('searchOnClick', false));
+ $this->setSafe($this->getParam('safe', 'html'));
$this->setSeparator($this->getParam('separator', "<br />"));
}
@@ -913,4 +915,24 @@ public function getSearchOnClick()
{
return $this->searchOnClick;
}
+
+ /**
+ * Allows to set twig escaping parameter (html, js, css, url, html_attr)
+ * or to display raw value if type is false
+ *
+ * @param type $safeOption can be one of raw, html, js, css, url, html_attr
+ *
+ * @return \APY\DataGridBundle\Grid\Column\Column
+ */
+ public function setSafe($safeOption)
+ {
+ $this->safe = $safeOption;
+
+ return $this;
+ }
+
+ public function getSafe()
+ {
+ return $this->safe;
+ }
}
View
2  Grid/Export/Export.php
@@ -100,7 +100,7 @@ public function getResponse()
// Response
if (function_exists('mb_strlen')) {
$this->content = mb_convert_encoding($this->content, $this->charset, $this->container->getParameter('kernel.charset'));
- $filesize = mb_strlen($this->content, $this->charset);
+ $filesize = mb_strlen($this->content, '8bit');
} else {
$filesize = strlen($this->content);
$this->charset = $this->container->getParameter('kernel.charset');
View
18 Grid/Grid.php
@@ -332,7 +332,9 @@ public function isReadyForRedirect()
}
$this->redirect = true;
- } else {
+ }
+
+ if ($this->redirect === null || ($this->request->isXmlHttpRequest() && !$this->isReadyForExport)) {
if ($this->newSession) {
$this->setDefaultSessionData();
@@ -1553,11 +1555,13 @@ public function __clone()
*/
public function getGridResponse($param1 = null, $param2 = null, Response $response = null)
{
- if ($this->isReadyForRedirect()) {
- if ($this->isReadyForExport()) {
- return $this->getExportResponse();
- }
+ $isReadyForRedirect = $this->isReadyForRedirect();
+ if ($this->isReadyForExport()) {
+ return $this->getExportResponse();
+ }
+
+ if ($isReadyForRedirect) {
return new RedirectResponse($this->getRouteUrl());
} else {
if (is_array($param1) || $param1 === null) {
@@ -1567,9 +1571,9 @@ public function getGridResponse($param1 = null, $param2 = null, Response $respon
$parameters = (array) $param2;
$view = $param1;
}
-
+
$parameters = array_merge(array('grid' => $this), $parameters);
-
+
if ($view === null) {
return $parameters;
} else {
View
10 Grid/GridManager.php
@@ -132,11 +132,13 @@ public function isReadyForExport()
*/
public function getGridManagerResponse($param1 = null, $param2 = null, Response $response = null)
{
- if ($this->isReadyForRedirect()) {
- if ($this->isReadyForExport()) {
- return $this->exportGrid->getExportResponse();
- }
+ $isReadyForRedirect = $this->isReadyForRedirect();
+
+ if ($this->isReadyForExport()) {
+ return $this->exportGrid->getExportResponse();
+ }
+ if ($isReadyForRedirect) {
return new RedirectResponse($this->getRouteUrl());
} else {
if (is_array($param1) || $param1 === null) {
View
3  Grid/Source/Entity.php
@@ -116,15 +116,14 @@ protected function getFieldName($column, $withAlias = false, $forHavingClause =
$name = $column->getField();
if (strpos($name, '.') !== false ) {
- $parent = self::TABLE_ALIAS;
$previousParent = '';
$elements = explode('.', $name);
while ($element = array_shift($elements)) {
if (count($elements) > 0) {
+ $parent = ($previousParent == '') ? self::TABLE_ALIAS : $previousParent;
$previousParent .= '_' . $element;
$this->joins[$previousParent] = $parent . '.' . $element;
- $parent = '_' . $element;
} else {
$name = $previousParent . '.' . $element;
}
View
125 Resources/translations/messages.tr.xliff
@@ -0,0 +1,125 @@
+<?xml version="1.0"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file source-language="tr" datatype="plaintext" original="file.ext">
+ <body>
+ <trans-unit id="13">
+ <source>eq</source>
+ <target>Eşittir</target>
+ </trans-unit>
+ <trans-unit id="14">
+ <source>neq</source>
+ <target>Eşit değildir</target>
+ </trans-unit>
+ <trans-unit id="15">
+ <source>lt</source>
+ <target>Küçüktür</target>
+ </trans-unit>
+ <trans-unit id="16">
+ <source>lte</source>
+ <target>Küçük ya da eşittir</target>
+ </trans-unit>
+ <trans-unit id="17">
+ <source>gt</source>
+ <target>Büyüktür</target>
+ </trans-unit>
+ <trans-unit id="18">
+ <source>gte</source>
+ <target>Büyük ya da eşittir</target>
+ </trans-unit>
+ <trans-unit id="19">
+ <source>req</source>
+ <target>Düzenli ifade</target>
+ </trans-unit>
+ <trans-unit id="20">
+ <source>like</source>
+ <target>İçerir</target>
+ </trans-unit>
+ <trans-unit id="21">
+ <source>nlike</source>
+ <target>İçermez</target>
+ </trans-unit>
+ <trans-unit id="22">
+ <source>rlike</source>
+ <target>İle Başlar</target>
+ </trans-unit>
+ <trans-unit id="23">
+ <source>llike</source>
+ <target>İle biter</target>
+ </trans-unit>
+ <trans-unit id="24">
+ <source>btw</source>
+ <target>Bunları kapsamaz</target>
+ </trans-unit>
+ <trans-unit id="25">
+ <source>btwe</source>
+ <target>Bunları kapsar</target>
+ </trans-unit>
+ <trans-unit id="26">
+ <source>isNull</source>
+ <target>Tanımlanmamış</target>
+ </trans-unit>
+ <trans-unit id="27">
+ <source>isNotNull</source>
+ <target>Tanımlanmış</target>
+ </trans-unit>
+ <trans-unit id="28">
+ <source>%count% Results, </source>
+ <target>{0,1}%count% Sonuç, |[2, Inf]%count% Sonuç, </target>
+ </trans-unit>
+
+ <!-- with symbols -->
+ <!--trans-unit id="26">
+ <source>eqs</source>
+ <target>=</target>
+ </trans-unit>
+ <trans-unit id="27">
+ <source>neqs</source>
+ <target>≠</target>
+ </trans-unit>
+ <trans-unit id="28">
+ <source>lts</source>
+ <target>&lt;</target>
+ </trans-unit>
+ <trans-unit id="29">
+ <source>ltes</source>
+ <target>≤</target>
+ </trans-unit>
+ <trans-unit id="30">
+ <source>gts</source>
+ <target>&gt;</target>
+ </trans-unit>
+ <trans-unit id="31">
+ <source>gtes</source>
+ <target>≥</target>
+ </trans-unit>
+ <trans-unit id="32">
+ <source>reqs</source>
+ <target>^x$</target>
+ </trans-unit>
+ <trans-unit id="33">
+ <source>likes</source>
+ <target>(x)</target>
+ </trans-unit>
+ <trans-unit id="34">
+ <source>nlikes</source>
+ <target>()x</target>
+ </trans-unit>
+ <trans-unit id="35">
+ <source>rlikes</source>
+ <target>x*</target>
+ </trans-unit>
+ <trans-unit id="36">
+ <source>llikes</source>
+ <target>*x</target>
+ </trans-unit>
+ <trans-unit id="37">
+ <source>btws</source>
+ <target>&lt;x&lt;</target>
+ </trans-unit>
+ <trans-unit id="38">
+ <source>btwes</source>
+ <target>&lt;=x&lt;<=/target>
+ </trans-unit-->
+ </body>
+ </file>
+</xliff>
View
8 Resources/views/blocks.html.twig
@@ -29,7 +29,9 @@
{{ grid_exports(grid) }}
{% endif %}
</div>
- {{ grid_scripts(grid) }}
+ {% if withjs %}
+ {{ grid_scripts(grid) }}
+ {% endif %}
</form>
{% else %}
{{ grid_no_data(grid) }}
@@ -218,8 +220,10 @@
{% if column.filterable and column.searchOnClick %}
{% set sourceValue = sourceValue is defined ? sourceValue : row.field(column.id) %}
<a href="?{{ grid.hash }}[{{ column.id }}][from]={{ sourceValue | url_encode() }}">{{ value }}</a>
+{% elseif column.safe is sameas(false) %}
+ {{ value|raw }}
{% else %}
- {{ value }}
+ {{ value|escape(column.safe) }}
{% endif %}
{% endblock grid_column_cell %}
{# -------------------------------------------- grid_column_operator --------------------------------------- #}
View
3  Resources/views/blocks_js.jquery.html.twig
@@ -25,7 +25,8 @@ function {{ grid.hash }}_submitForm(event, form, force)
var data = '';
$('.grid-filter-operator select, .grid-filter-input-query-from, .grid-filter-input-query-to, .grid-filter-select-query-from, .grid-filter-select-query-to', form).each(function () {
if ($(this).is(':disabled') == false) {
- data += '&' + $(this).attr('name') + '=' + $(this).val();
+ var value = $(this).val() == null ? '' : $(this).val();
+ data += '&' + $(this).attr('name') + '=' + value;
}
});
View
20 Twig/DataGridExtension.php
@@ -103,6 +103,7 @@ public function getFunctions()
{
return array(
'grid' => new \Twig_Function_Method($this, 'getGrid', array('is_safe' => array('html'))),
+ 'grid_html' => new \Twig_Function_Method($this, 'getGridHtml', array('is_safe' => array('html'))),
'grid_url' => new \Twig_Function_Method($this, 'getGridUrl', array('is_safe' => array('html'))),
'grid_filter' => new \Twig_Function_Method($this, 'getGridFilter', array('is_safe' => array('html'))),
'grid_cell' => new \Twig_Function_Method($this, 'getGridCell', array('is_safe' => array('html'))),
@@ -129,16 +130,31 @@ public function initGrid($grid, $theme = null, $id = '', array $params = array()
* @param \APY\DataGridBundle\Grid\Grid $grid
* @param string $theme
* @param string $id
+ *
* @return string
*/
- public function getGrid($grid, $theme = null, $id = '', array $params = array())
+ public function getGrid($grid, $theme = null, $id = '', array $params = array(), $withjs = true)
{
$this->initGrid($grid, $theme, $id, $params);
// For export
$grid->setTemplate($theme);
- return $this->renderBlock('grid', array('grid' => $grid));
+ return $this->renderBlock('grid', array('grid' => $grid, 'withjs' => $withjs));
+ }
+
+ /**
+ * Render grid block (html only)
+ *
+ * @param \APY\DataGridBundle\Grid\Grid $grid
+ * @param string $theme
+ * @param string $id
+ *
+ * @return string
+ */
+ public function getGridHtml($grid, $theme = null, $id = '', array $params = array())
+ {
+ return getGrid($grid, $theme, $id, $params, false);
}
public function getGrid_($name, $grid)
Please sign in to comment.
Something went wrong with that request. Please try again.