Port zoom_result_form template to Twig
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
parent
1ffa2e1b77
commit
1a33f062de
@ -354,20 +354,20 @@ class TableSearchController extends TableController
|
||||
)
|
||||
);
|
||||
$this->response->addHTML(
|
||||
Template::get('table/search/zoom_result_form')
|
||||
->render(
|
||||
array(
|
||||
'_db' => $this->db,
|
||||
'_table' => $this->table,
|
||||
'_columnNames' => $this->_columnNames,
|
||||
'_foreigners' => $this->_foreigners,
|
||||
'_columnNullFlags' => $this->_columnNullFlags,
|
||||
'_columnTypes' => $this->_columnTypes,
|
||||
'titles' => $titles,
|
||||
'goto' => $goto,
|
||||
'data' => $data,
|
||||
)
|
||||
)
|
||||
Template::get('table/search/zoom_result_form')->render([
|
||||
'db' => $this->db,
|
||||
'table' => $this->table,
|
||||
'column_names' => $this->_columnNames,
|
||||
'foreigners' => $this->_foreigners,
|
||||
'column_null_flags' => $this->_columnNullFlags,
|
||||
'column_types' => $this->_columnTypes,
|
||||
'titles' => $titles,
|
||||
'goto' => $goto,
|
||||
'data' => $data,
|
||||
'data_json' => json_encode($data),
|
||||
'zoom_submit' => isset($_POST['zoom_submit']),
|
||||
'foreign_max_limit' => $GLOBALS['cfg']['ForeignKeyMaxLimit'],
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ namespace PhpMyAdmin;
|
||||
use PhpMyAdmin\Twig\CharsetsExtension;
|
||||
use PhpMyAdmin\Twig\I18nExtension;
|
||||
use PhpMyAdmin\Twig\MessageExtension;
|
||||
use PhpMyAdmin\Twig\PhpFunctionsExtension;
|
||||
use PhpMyAdmin\Twig\RelationExtension;
|
||||
use PhpMyAdmin\Twig\SanitizeExtension;
|
||||
use PhpMyAdmin\Twig\ServerPrivilegesExtension;
|
||||
@ -65,6 +66,7 @@ class Template
|
||||
$twig->addExtension(new CharsetsExtension());
|
||||
$twig->addExtension(new I18nExtension());
|
||||
$twig->addExtension(new MessageExtension());
|
||||
$twig->addExtension(new PhpFunctionsExtension());
|
||||
$twig->addExtension(new RelationExtension());
|
||||
$twig->addExtension(new SanitizeExtension());
|
||||
$twig->addExtension(new ServerPrivilegesExtension());
|
||||
|
||||
31
libraries/classes/Twig/PhpFunctionsExtension.php
Normal file
31
libraries/classes/Twig/PhpFunctionsExtension.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* hold PhpMyAdmin\Twig\PhpFunctionsExtension class
|
||||
*
|
||||
* @package PhpMyAdmin\Twig
|
||||
*/
|
||||
namespace PhpMyAdmin\Twig;
|
||||
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFunction;
|
||||
|
||||
/**
|
||||
* Class PhpFunctionsExtension
|
||||
*
|
||||
* @package PhpMyAdmin\Twig
|
||||
*/
|
||||
class PhpFunctionsExtension 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('md5', 'md5'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -25,15 +25,19 @@ class RelationExtension extends Twig_Extension
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new Twig_SimpleFunction(
|
||||
'Relation_searchColumnInForeigners',
|
||||
'PhpMyAdmin\Relation::searchColumnInForeigners'
|
||||
),
|
||||
new Twig_SimpleFunction(
|
||||
'Relation_foreignDropdown',
|
||||
'PhpMyAdmin\Relation::foreignDropdown',
|
||||
array('is_safe' => array('html'))
|
||||
),
|
||||
new Twig_SimpleFunction(
|
||||
'Relation_getForeignData',
|
||||
'PhpMyAdmin\Relation::getForeignData'
|
||||
),
|
||||
new Twig_SimpleFunction(
|
||||
'Relation_searchColumnInForeigners',
|
||||
'PhpMyAdmin\Relation::searchColumnInForeigners'
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ require_once AUTOLOAD_FILE;
|
||||
use PhpMyAdmin\Twig\CharsetsExtension;
|
||||
use PhpMyAdmin\Twig\I18nExtension;
|
||||
use PhpMyAdmin\Twig\MessageExtension;
|
||||
use PhpMyAdmin\Twig\PhpFunctionsExtension;
|
||||
use PhpMyAdmin\Twig\RelationExtension;
|
||||
use PhpMyAdmin\Twig\SanitizeExtension;
|
||||
use PhpMyAdmin\Twig\ServerPrivilegesExtension;
|
||||
@ -25,6 +26,7 @@ $twig = new Twig_Environment($loader, array(
|
||||
$twig->addExtension(new CharsetsExtension());
|
||||
$twig->addExtension(new I18nExtension());
|
||||
$twig->addExtension(new MessageExtension());
|
||||
$twig->addExtension(new PhpFunctionsExtension());
|
||||
$twig->addExtension(new RelationExtension());
|
||||
$twig->addExtension(new SanitizeExtension());
|
||||
$twig->addExtension(new ServerPrivilegesExtension());
|
||||
|
||||
@ -1,98 +0,0 @@
|
||||
<form method="post" action="tbl_zoom_select.php" name="displayResultForm" id="zoom_display_form" class="ajax">
|
||||
<?= \PhpMyAdmin\Url::getHiddenInputs($_db, $_table); ?>
|
||||
<input type="hidden" name="goto" value="<?= $goto; ?>" />
|
||||
<input type="hidden" name="back" value="tbl_zoom_select.php" />
|
||||
|
||||
<fieldset id="displaySection">
|
||||
<legend><?= __('Browse/Edit the points');?></legend>
|
||||
|
||||
<!-- JSON encode the data(query result) -->
|
||||
<center>
|
||||
<?php if (isset($_POST['zoom_submit']) && ! empty($data)): ?>
|
||||
<div id="resizer">
|
||||
<center>
|
||||
<a id="help_dialog" href="#">
|
||||
<?= __('How to use'); ?>
|
||||
</a>
|
||||
</center>
|
||||
<div id="querydata" class="hide">
|
||||
<?= htmlspecialchars(json_encode($data)); ?>
|
||||
</div>
|
||||
<div id="querychart"></div>
|
||||
<button class="button-reset">
|
||||
<?= __('Reset zoom'); ?></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</center>
|
||||
|
||||
<!-- Displays rows in point edit form -->
|
||||
<div id="dataDisplay" class="hide">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= __('Column'); ?> </th>
|
||||
<th><?= __('Null'); ?> </th>
|
||||
<th><?= __('Value'); ?> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php for (
|
||||
$column_index = 0, $nb = count($_columnNames);
|
||||
$column_index < $nb;
|
||||
$column_index++
|
||||
): ?>
|
||||
<?php
|
||||
$foreignData = PhpMyAdmin\Relation::getForeignData(
|
||||
$_foreigners,
|
||||
$_columnNames[$column_index],
|
||||
false,
|
||||
'',
|
||||
''
|
||||
); ?>
|
||||
<?php endfor; ?>
|
||||
<?php for (
|
||||
$column_index = 0, $nb = count($_columnNames);
|
||||
$column_index < $nb;
|
||||
$column_index++
|
||||
): ?>
|
||||
<?php
|
||||
$fieldpopup = $_columnNames[$column_index];
|
||||
$foreignData = PhpMyAdmin\Relation::getForeignData($_foreigners, $fieldpopup, false, '', '' );?>
|
||||
<tr class="noclick">
|
||||
<!-- Display column Names -->
|
||||
<th><?= htmlspecialchars($_columnNames[$column_index]); ?></th>
|
||||
<!-- Null checkbox if column can be null -->
|
||||
<th>
|
||||
<?php if ($_columnNullFlags[$column_index] == 'YES'): ?>
|
||||
<input type="checkbox" class="checkbox_null"
|
||||
name="criteriaColumnNullFlags[<?= $column_index; ?>]"
|
||||
id="edit_fields_null_id_'<?= $column_index;?>" />
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<!-- Column's Input box-->
|
||||
<th>
|
||||
<?= PhpMyAdmin\Template::get('table/search/input_box')->render(array(
|
||||
'str' => '',
|
||||
'column_type' => $_columnTypes[$column_index],
|
||||
'column_id' => ($_columnTypes[$column_index]) ? 'edit_fieldID_' : 'fieldID_',
|
||||
'in_zoom_search_edit' => true,
|
||||
'foreigners' => $_foreigners,
|
||||
'column_name' => $fieldpopup,
|
||||
'column_name_hash' => md5($fieldpopup),
|
||||
'foreign_data' => $foreignData,
|
||||
'table' => $_table,
|
||||
'column_index' => $column_index,
|
||||
'foreign_max_limit' => $GLOBALS['cfg']['ForeignKeyMaxLimit'],
|
||||
'criteria_values' => '',
|
||||
'db' => $_db,
|
||||
'titles' => $titles,
|
||||
'in_fbs' => false
|
||||
));?>
|
||||
</th>
|
||||
</tr>
|
||||
<?php endfor; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<input type="hidden" id="queryID" name="sql_query" />
|
||||
</form>
|
||||
85
templates/table/search/zoom_result_form.twig
Normal file
85
templates/table/search/zoom_result_form.twig
Normal file
@ -0,0 +1,85 @@
|
||||
<form method="post" action="tbl_zoom_select.php" name="displayResultForm" id="zoom_display_form" class="ajax">
|
||||
{{ Url_getHiddenInputs(db, table) }}
|
||||
<input type="hidden" name="goto" value="{{ goto }}" />
|
||||
<input type="hidden" name="back" value="tbl_zoom_select.php" />
|
||||
|
||||
<fieldset id="displaySection">
|
||||
<legend>{% trans 'Browse/Edit the points' %}</legend>
|
||||
|
||||
{# JSON encode the data(query result) #}
|
||||
<center>
|
||||
{% if zoom_submit and data is not empty %}
|
||||
<div id="resizer">
|
||||
<center>
|
||||
<a id="help_dialog" href="#">
|
||||
{% trans 'How to use' %}
|
||||
</a>
|
||||
</center>
|
||||
<div id="querydata" class="hide">
|
||||
{{ data_json }}
|
||||
</div>
|
||||
<div id="querychart"></div>
|
||||
<button class="button-reset">
|
||||
{% trans 'Reset zoom' %}
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</center>
|
||||
|
||||
{# Displays rows in point edit form #}
|
||||
<div id="dataDisplay" class="hide">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans 'Column' %}</th>
|
||||
<th>{% trans 'Null' %}</th>
|
||||
<th>{% trans 'Value' %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for column_index in 0..column_names|length - 1 %}
|
||||
{% set field_popup = column_names[column_index] %}
|
||||
{% set foreign_data = Relation_getForeignData(
|
||||
foreigners,
|
||||
field_popup,
|
||||
false,
|
||||
'',
|
||||
''
|
||||
) %}
|
||||
<tr class="noclick">
|
||||
<th>{{ column_names[column_index] }}</th>
|
||||
{# Null checkbox if column can be null #}
|
||||
<th>
|
||||
{% if column_null_flags[column_index] == 'YES' %}
|
||||
<input type="checkbox" class="checkbox_null"
|
||||
name="criteriaColumnNullFlags[{{ column_index }}]"
|
||||
id="edit_fields_null_id_{{ column_index }}" />
|
||||
{% endif %}
|
||||
</th>
|
||||
{# Column's Input box #}
|
||||
<th>
|
||||
{% include 'table/search/input_box.twig' with {
|
||||
'str': '',
|
||||
'column_type': column_types[column_index],
|
||||
'column_id': column_types[column_index] ? 'edit_fieldID_' : 'fieldID_',
|
||||
'in_zoom_search_edit': true,
|
||||
'foreigners': foreigners,
|
||||
'column_name': field_popup,
|
||||
'column_name_hash': md5(field_popup),
|
||||
'foreign_data': foreign_data,
|
||||
'table': table,
|
||||
'column_index': column_index,
|
||||
'foreign_max_limit': foreign_max_limit,
|
||||
'criteria_values': '',
|
||||
'db': db,
|
||||
'titles': titles,
|
||||
'in_fbs': false
|
||||
} only %}
|
||||
</th>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<input type="hidden" id="queryID" name="sql_query" />
|
||||
</form>
|
||||
Loading…
Reference in New Issue
Block a user