[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 #13207

Merged
merged 3 commits into from
Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions libraries/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Twig_Loader_Filesystem;
use PMA\libraries\twig\I18nExtension;
use PMA\libraries\twig\UrlExtension;
use PMA\libraries\twig\UtilExtension;

/**
* Class Template
Expand Down Expand Up @@ -64,6 +65,7 @@ protected function __construct($name, $data = array(), $helperFunctions = array(
));
$this->twig->addExtension(new I18nExtension());
$this->twig->addExtension(new UrlExtension());
$this->twig->addExtension(new UtilExtension());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -4350,7 +4350,7 @@ public static function getStartAndNumberOfRowsPanel($sql_query)
}
}

return Template::get('startAndNumberOfRowsPanel')
return Template::get('start_and_number_of_rows_panel')
->render(
array(
'pos' => $pos,
Expand Down
49 changes: 49 additions & 0 deletions libraries/twig/UtilExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* hold PMA\libraries\twig\UtilExtension class
*
* @package PMA\libraries\twig
*/
namespace PMA\libraries\twig;

use Twig_Extension;
use Twig_SimpleFunction;

/**
* Class UtilExtension
*
* @package PMA\libraries\twig
*/
class UtilExtension 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(
'Util_showIcons',
'PMA\libraries\Util::showIcons'
),
new Twig_SimpleFunction(
'Util_getImage',
'PMA\libraries\Util::getImage',
array('is_safe' => array('html'))
),
new Twig_SimpleFunction(
'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'))
),
);
}
}
2 changes: 2 additions & 0 deletions scripts/generate-twig-cache
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require_once 'libraries/vendor_config.php';

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

$tplDir = dirname(__FILE__) . '/../templates';
$tmpDir = dirname(__FILE__) . '/../' . CACHE_DIR . 'twig';
Expand All @@ -18,6 +19,7 @@ $twig = new Twig_Environment($loader, array(
));
$twig->addExtension(new I18nExtension());
$twig->addExtension(new UrlExtension());
$twig->addExtension(new UtilExtension());

// iterate over all templates
foreach (new RecursiveIteratorIterator(
Expand Down
12 changes: 0 additions & 12 deletions templates/checkbox.phtml

This file was deleted.

6 changes: 6 additions & 0 deletions templates/checkbox.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<input type="checkbox" name="{{ html_field_name }}"
{%- if html_field_id is defined %} id="{{ html_field_id }}"{% endif -%}
{%- if checked is defined and checked %} checked="checked"{% endif -%}
{%- if onclick is defined and onclick %} class="autosubmit"{% endif %} /><label
{%- if html_field_id is defined %} for="{{ html_field_id }}"
{%- endif %}>{{ label }}</label>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="error">
<img src="themes/dot.gif" title="" alt="" class="icon ic_s_error" />
<?= $msg; ?>
</div>
{{ msg }}
</div>
12 changes: 0 additions & 12 deletions templates/console/query_action.phtml

This file was deleted.

12 changes: 12 additions & 0 deletions templates/console/query_action.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div class="{{ parentDivClasses }}">
{% for content in contentArray %}
{% if content is defined %}
<span class="{{ content[0] }}">
{{ content[1] }}
{% if content['extraSpan'] is defined %}
: <span>{{ content['extraSpan'] }}</span>
{% endif %}
</span>
{% endif %}
{% endfor %}
</div>
10 changes: 0 additions & 10 deletions templates/console/toolbar.phtml

This file was deleted.

10 changes: 10 additions & 0 deletions templates/console/toolbar.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="toolbar {{ parentDivClasses }}">
{% for content in contentArray %}
{% if content is defined %}
<div class="{{ content[0] }}">
{{ content['image'] ? content['image'] }}
<span>{{ content[1] }}</span>
</div>
{% endif %}
{% endfor %}
</div>
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<form id="create_table_form_minimal" method="post" action="tbl_create.php" class="lock-page">
<fieldset>
<legend>
<?php if (PMA\libraries\Util::showIcons('ActionLinksMode')): ?>
<?= PMA\libraries\Util::getImage('b_table_add.png'); ?>&nbsp
<?php endif; ?>
<?= __('Create table'); ?>
{% if Util_showIcons('ActionLinksMode') -%}
{{ Util_getImage('b_table_add.png') }}
{%- endif %}
{% trans "Create table" %}
</legend>
<?= PMA\libraries\URL::getHiddenInputs($db); ?>
{{ URL_getHiddenInputs(db) }}
<div class="formelement">
<?= __('Name'); ?>:
{% trans "Name" %}:
<input type="text" name="table" maxlength="64" size="30" required="required" />
</div>
<div class="formelement">
<?= __('Number of columns'); ?>:
{% trans "Number of columns" %}:
<input type="number" min="1" name="num_fields" value="4" required="required" />
</div>
<div class="clearfloat"></div>
</fieldset>
<fieldset class="tblFooters">
<input type="submit" value="<?= __('Go'); ?>" />
<input type="submit" value="{% trans "Go" %}" />
</fieldset>
</form>
15 changes: 0 additions & 15 deletions templates/div_for_slider_effect.phtml

This file was deleted.

16 changes: 16 additions & 0 deletions templates/div_for_slider_effect.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% if InitialSlidersState == 'disabled' %}
<div{% if id is defined %} id="{{ id }}"{% endif %}>
{% else %}
{#
Bad hack on the next line. document.write() conflicts with jQuery,
hence, opening the <div> with PHP itself instead of JavaScript.

@todo find a better solution that uses $.append(), the recommended
method maybe by using an additional param, the id of the div to
append to
#}
<div{% if id is defined %} id="{{ id }}"
{%- endif %} {% if InitialSlidersState == 'closed' -%}
style="display: none; overflow:auto;"{% endif %} class="pma_auto_slider"
{%- if message is defined %} title="{{ message }}"{% endif %}>
{% endif %}
8 changes: 0 additions & 8 deletions templates/dropdown.phtml

This file was deleted.

10 changes: 10 additions & 0 deletions templates/dropdown.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<select name="{{ select_name }}" id="{{ id }}"{{ class ? ' class="' ~ class ~ '"' }}>
{% if placeholder is not empty %}
<option value="" disabled="disabled"
{%- if not selected %} selected="selected"{% endif %}>{{ placeholder }}</option>
{% endif %}
{% for option in resultOptions %}
<option value="{{ option['value'] }}"
{{- option['selected'] ? ' selected="selected"' }}>{{ option['label'] }}</option>
{% endfor %}
</select>
34 changes: 0 additions & 34 deletions templates/error/report_form.phtml

This file was deleted.

32 changes: 32 additions & 0 deletions templates/error/report_form.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<form action="error_report.php" method="post" name="report_frm" id="report_frm"
class="ajax">
<fieldset style="padding-top:0">

<p>
{% trans %}
This report automatically includes data about the error and information about relevant configuration settings. It will be sent to the phpMyAdmin team for debugging the error.
{% endtrans %}
</p>

<div class="label"><label><strong>
{% trans "Can you tell us the steps leading to this error? It decisively helps in debugging:" %}
</strong></label>
</div>
<textarea class="report-description" name="description"
id="report_description"></textarea>

<div class="label"><label><p>
{% trans "You may examine the data in the error report:" %}
</p></label></div>
<pre class="report-data">{{ report_data }}</pre>

<input type="checkbox" name="always_send" id="always_send_checkbox" />
<label for="always_send_checkbox">
{% trans "Automatically send report next time" %}
</label>

</fieldset>

{{ hidden_inputs }}
{{ hidden_fields }}
</form>
8 changes: 0 additions & 8 deletions templates/filter.phtml

This file was deleted.

8 changes: 8 additions & 0 deletions templates/filter.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<fieldset id="tableFilter">
<legend>{% trans "Filters" %}</legend>
<div class="formelement">
<label for="filterText">{% trans "Containing the word:" %}</label>
<input name="filterText" type="text" id="filterText"
value="{{ filterValue }}" />
</div>
</fieldset>
16 changes: 0 additions & 16 deletions templates/prefs_autoload.phtml

This file was deleted.

15 changes: 15 additions & 0 deletions templates/prefs_autoload.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div id="prefs_autoload" class="notice print_ignore" style="display:none">
<form action="prefs_manage.php" method="post" class="disableAjax">
{{ hiddenInputs|raw }}
<input type="hidden" name="json" value="" />
<input type="hidden" name="submit_import" value="1" />
<input type="hidden" name="return_url" value="{{ return_url }}" />
{% trans %}
Your browser has phpMyAdmin configuration for this domain. Would you like to import it for current session?
{% endtrans %}
<br />
<a href="#yes">{% trans "Yes" %}</a>
/ <a href="#no">{% trans "No" %}</a>
/ <a href="#delete">{% trans "Delete settings" %}</a>
</form>
</div>
11 changes: 0 additions & 11 deletions templates/preview_sql.phtml

This file was deleted.

11 changes: 11 additions & 0 deletions templates/preview_sql.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="preview_sql">
{% if query_data is empty %}
{% trans 'No change' %}
{% elseif query_data is iterable %}
{% for query in query_data %}
{{ Util_formatSql(query) }}
{% endfor %}
{% else %}
{{ Util_formatSql(query_data) }}
{% endif %}
</div>
Loading