[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port some templates to Twig #13236

Merged
merged 2 commits into from
May 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Port some templates to Twig
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
  • Loading branch information
MauricioFauth committed May 4, 2017
commit a35f8798f484d60c1b533661ff978833309e3557
2 changes: 2 additions & 0 deletions libraries/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Twig_Environment;
use Twig_Loader_Filesystem;
use PMA\libraries\twig\I18nExtension;
use PMA\libraries\twig\SanitizeExtension;
use PMA\libraries\twig\UrlExtension;
use PMA\libraries\twig\UtilExtension;

Expand Down Expand Up @@ -64,6 +65,7 @@ protected function __construct($name, $data = array(), $helperFunctions = array(
'debug' => false,
));
$this->twig->addExtension(new I18nExtension());
$this->twig->addExtension(new SanitizeExtension());
$this->twig->addExtension(new UrlExtension());
$this->twig->addExtension(new UtilExtension());
}
Expand Down
35 changes: 35 additions & 0 deletions libraries/twig/SanitizeExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* hold PMA\libraries\twig\SanitizeExtension class
*
* @package PMA\libraries\twig
*/
namespace PMA\libraries\twig;

use Twig_Extension;
use Twig_SimpleFunction;

/**
* Class SanitizeExtension
*
* @package PMA\libraries\twig
*/
class SanitizeExtension extends Twig_Extension
{
/**
* Returns a list of functions to add to the existing list.
*
* @return Twig_SimpleFunction[]
*/
public function getFunctions()
{
return array(
new Twig_SimpleFunction(
'Sanitize_escapeJsString',
'PMA\libraries\Sanitize::escapeJsString',
array('is_safe' => array('html'))
),
);
}
}
24 changes: 17 additions & 7 deletions libraries/twig/UtilExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,33 @@ public function getFunctions()
{
return array(
new Twig_SimpleFunction(
'Util_showIcons',
'PMA\libraries\Util::showIcons'
'Util_formatSql',
'PMA\libraries\Util::formatSql',
array('is_safe' => array('html'))
),
new Twig_SimpleFunction(
'Util_getHtmlTab',
'PMA\libraries\Util::getHtmlTab',
array('is_safe' => array('html'))
),
new Twig_SimpleFunction(
'Util_getIcon',
'PMA\libraries\Util::getIcon',
array('is_safe' => array('html'))
),
new Twig_SimpleFunction(
'Util_getImage',
'PMA\libraries\Util::getImage',
array('is_safe' => array('html'))
),
new Twig_SimpleFunction(
'Util_formatSql',
'PMA\libraries\Util::formatSql',
'Util_getSupportedDatatypes',
'PMA\libraries\Util::getSupportedDatatypes',
array('is_safe' => array('html'))
),
new Twig_SimpleFunction(
'Util_getHtmlTab',
'PMA\libraries\Util::getHtmlTab',
array('is_safe' => array('html'))
'Util_showIcons',
'PMA\libraries\Util::showIcons'
),
);
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/generate-twig-cache
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ require_once 'vendor/autoload.php';
require_once 'libraries/vendor_config.php';

use PMA\libraries\twig\I18nExtension;
use PMA\libraries\twig\SanitizeExtension;
use PMA\libraries\twig\UrlExtension;
use PMA\libraries\twig\UtilExtension;

Expand All @@ -18,6 +19,7 @@ $twig = new Twig_Environment($loader, array(
'auto_reload' => true
));
$twig->addExtension(new I18nExtension());
$twig->addExtension(new SanitizeExtension());
$twig->addExtension(new UrlExtension());
$twig->addExtension(new UtilExtension());

Expand Down
18 changes: 0 additions & 18 deletions templates/columns_definitions/column_adjust_privileges.phtml

This file was deleted.

16 changes: 16 additions & 0 deletions templates/columns_definitions/column_adjust_privileges.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% if privs_available %}
<input name="field_adjust_privileges[{{ columnNumber }}]"
id="field_{{ columnNumber }}_{{ ci - ci_offset }}"
checked="checked"
type="checkbox"
value="NULL"
class="allow_null"/>
{% else %}
<input name="field_adjust_privileges[{{ columnNumber }}]"
id="field_{{ columnNumber }}_{{ ci - ci_offset }}"
disabled
type="checkbox"
value="NULL"
class="allow_null"
title="{% trans "You don't have sufficient privileges to perform this operation; Please refer to the documentation for more details" %}"/>
{% endif %}
8 changes: 0 additions & 8 deletions templates/columns_definitions/column_auto_increment.phtml

This file was deleted.

7 changes: 7 additions & 0 deletions templates/columns_definitions/column_auto_increment.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<input name="field_extra[{{ columnNumber }}]"
id="field_{{ columnNumber }}_{{ ci - ci_offset }}"
{% if columnMeta['Extra'] is defined and columnMeta['Extra']|lower == 'auto_increment' -%}
checked="checked"
{%- endif %}
type="checkbox"
value="AUTO_INCREMENT" />
7 changes: 0 additions & 7 deletions templates/columns_definitions/column_extra.phtml

This file was deleted.

7 changes: 7 additions & 0 deletions templates/columns_definitions/column_extra.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<input name="col_extra[{{ columnNumber }}]"
id="field_{{ columnNumber }}_{{ ci - ci_offset }}"
{% if columnMeta['Extra'] is not empty and columnMeta['Extra'] == 'auto_increment' -%}
checked="checked"
{%- endif %}
type="checkbox"
value="auto_increment" />
30 changes: 0 additions & 30 deletions templates/columns_definitions/column_indexes.phtml

This file was deleted.

24 changes: 24 additions & 0 deletions templates/columns_definitions/column_indexes.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<select name="field_key[{{ columnNumber }}]"
id="field_{{ columnNumber }}_{{ ci - ci_offset }}" data-index="">
<option value="none_{{ columnNumber }}">---</option>
<option value="primary_{{ columnNumber }}" title="{% trans "Primary" %}"
{{- columnMeta['Key'] is defined and columnMeta['Key'] == 'PRI' ? ' selected="selected"' }}>
PRIMARY
</option>
<option value="unique_{{ columnNumber }}" title="{% trans "Unique" %}"
{{- columnMeta['Key'] is defined and columnMeta['Key'] == 'UNI' ? ' selected="selected"' }}>
UNIQUE
</option>
<option value="index_{{ columnNumber }}" title="{% trans "Index" %}"
{{- columnMeta['Key'] is defined and columnMeta['Key'] == 'MUL' ? ' selected="selected"' }}>
INDEX
</option>
<option value="fulltext_{{ columnNumber }}" title="{% trans "Fulltext" %}"
{{- columnMeta['Key'] is defined and columnMeta['Key'] == 'FULLTEXT' ? ' selected="selected"' }}>
FULLTEXT
</option>
<option value="spatial_{{ columnNumber }}" title="{% trans "Spatial" %}"
{{- columnMeta['Key'] is defined and columnMeta['Key'] == 'SPATIAL' ? ' selected="selected"' }}>
SPATIAL
</option>
</select>
11 changes: 0 additions & 11 deletions templates/columns_definitions/column_length.phtml

This file was deleted.

11 changes: 11 additions & 0 deletions templates/columns_definitions/column_length.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<input id="field_{{ columnNumber }}_{{ ci - ci_offset }}"
type="text"
name="field_length[{{ columnNumber }}]"
size="{{ length_values_input_size }}"
value="{{ length_to_display }}"
class="textfield" />
<p class="enum_notice" id="enum_notice_{{ columnNumber }}_{{ ci - ci_offset }}">
<a href="#" class="open_enum_editor">
{% trans 'Edit ENUM/SET values' %}
</a>
</p>
8 changes: 0 additions & 8 deletions templates/columns_definitions/column_null.phtml

This file was deleted.

8 changes: 8 additions & 0 deletions templates/columns_definitions/column_null.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<input name="field_null[{{ columnNumber }}]"
id="field_{{ columnNumber }}_{{ ci - ci_offset }}"
{% if columnMeta['Null'] is not empty and columnMeta['Null'] != 'NO' and columnMeta['Null'] != 'NOT NULL' -%}
checked="checked"
{%- endif %}
type="checkbox"
value="NULL"
class="allow_null" />
8 changes: 0 additions & 8 deletions templates/columns_definitions/column_type.phtml

This file was deleted.

8 changes: 8 additions & 0 deletions templates/columns_definitions/column_type.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<select class="column_type"
name="field_type[{{ columnNumber }}]"
id="field_{{ columnNumber }}_{{ ci - ci_offset }}"
{%- if columnMeta['column_status'] is defined and not columnMeta['column_status']['isEditable'] -%}
disabled="disabled"
{%- endif %}>
{{ Util_getSupportedDatatypes(true, type_upper) }}
</select>
9 changes: 0 additions & 9 deletions templates/columns_definitions/transformation_option.phtml

This file was deleted.

9 changes: 9 additions & 0 deletions templates/columns_definitions/transformation_option.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% set options_key = type_prefix ~ 'transformation_options' %}
<input id="field_{{ columnNumber }}_{{ ci - ci_offset }}"
type="text"
name="field_{{ options_key }}[{{ columnNumber }}]"
size="16"
class="textfield"
value="{% if columnMeta['Field'] is defined and mime_map[columnMeta['Field']][options_key] is defined -%}
{{- mime_map[columnMeta['Field']][options_key] -}}
{%- endif %}" />
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<table id="query_Aggregate" style="display:none;"width="5%" cellpadding="0" cellspacing="0">
<table id="query_Aggregate" style="display:none;" width="5%" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="frams1" width="10px">
Expand All @@ -19,15 +19,15 @@
<tr>
<td colspan="2" class="center nowrap">
<strong>
<?= __('Aggregate'); ?>
{% trans 'Aggregate' %}
</strong>
</td>
</tr>
</thead>
<tbody>
<tr>
<td width="58" class="nowrap">
<?= __('Operator'); ?>
{% trans 'Operator' %}
</td>
<td width="102">
<select name="operator" id="e_operator">
Expand Down Expand Up @@ -56,12 +56,13 @@
<tbody>
<tr>
<td colspan="2" class="center nowrap">
<input type="button" id="ok_edit_Aggr" class="butt" name="Button" value="<?= __('OK'); ?>" />
<input type="button" id="ok_edit_Aggr" class="butt"
name="Button" value="{% trans 'OK' %}" />
<input type="button"
class="butt"
name="Button"
value="<?= __('Cancel'); ?>"
= 'none';" />
class="butt"
name="Button"
value="{% trans 'Cancel' %}"
= 'none';" />
</td>
</tr>
</tbody>
Expand All @@ -81,4 +82,4 @@
</td>
</tr>
</tbody>
</table>
</table>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div id="osn_tab">
<canvas class="pmd" id="canvas" width="100" height="100" ></canvas>
</div>
</div>
Loading