Permalink
Browse files

Remove Twig php function extensions

Signed-off-by: Leonardo Strozzi <laps15@inf.ufpr.br>
  • Loading branch information...
laps15 committed May 23, 2018
1 parent 0785c57 commit 5d0fd81e674464c4ba79f40a84974b1129b350e4
Showing with 236 additions and 183 deletions.
  1. +2 −2 browse_foreigners.php
  2. +9 −9 libraries/classes/Controllers/Database/DatabaseStructureController.php
  3. +38 −0 libraries/classes/Controllers/Server/ServerDatabasesController.php
  4. +12 −1 libraries/classes/Controllers/Server/ServerPluginsController.php
  5. +26 −3 libraries/classes/Controllers/Table/TableSearchController.php
  6. +58 −0 libraries/classes/Controllers/Table/TableStructureController.php
  7. +29 −2 libraries/classes/Database/Designer.php
  8. +1 −1 libraries/classes/Display/Results.php
  9. +0 −2 libraries/classes/Template.php
  10. +0 −40 libraries/classes/Twig/PhpFunctionsExtension.php
  11. +1 −1 libraries/classes/Types.php
  12. +25 −1 libraries/tbl_columns_definition_form.inc.php
  13. +0 −2 scripts/generate-twig-cache
  14. +1 −0 templates/columns_definitions/column_attributes.twig
  15. +0 −11 templates/columns_definitions/column_default.twig
  16. +2 −1 templates/columns_definitions/column_virtuality.twig
  17. +1 −1 templates/columns_definitions/transformation.twig
  18. +2 −19 templates/database/designer/database_tables.twig
  19. +3 −3 templates/database/structure/body_for_table_summary.twig
  20. +3 −3 templates/database/structure/structure_table_row.twig
  21. +3 −13 templates/server/databases/databases_footer.twig
  22. +3 −13 templates/server/databases/table_row.twig
  23. +1 −1 templates/server/plugins/section.twig
  24. +1 −1 templates/server/plugins/section_links.twig
  25. +1 −0 templates/table/search/fields_table.twig
  26. +2 −2 templates/table/search/rows_zoom.twig
  27. +3 −3 templates/table/search/search_and_replace.twig
  28. +3 −1 templates/table/search/selection_form.twig
  29. +6 −47 templates/table/structure/display_structure.twig
View
@@ -68,8 +68,8 @@
$table,
$_REQUEST['field'],
$foreignData,
isset($fieldkey) ? $fieldkey : null,
isset($data) ? $data : null
isset($fieldkey) ? $fieldkey : '',
isset($data) ? $data : ''
);
$response->addHtml($html);
@@ -681,12 +681,12 @@ protected function displayTableList()
'formatted_size' => $formatted_size,
'unit' => $unit,
'overhead' => $overhead,
'create_time' => isset($create_time)
? $create_time : '',
'update_time' => isset($update_time)
? $update_time : '',
'check_time' => isset($check_time)
? $check_time : '',
'create_time' => (isset($create_time) && $create_time
? Util::localisedDate(strtotime($create_time)) : '-'),
'update_time' => (isset($update_time) && $update_time
? Util::localisedDate(strtotime($update_time)) : '-'),
'check_time' => (isset($check_time) && $check_time
? Util::localisedDate(strtotime($check_time)) : '-'),
'charset' => isset($charset)
? $charset : '',
'is_show_stats' => $this->_is_show_stats,
@@ -730,9 +730,9 @@ protected function displayTableList()
'db_charset' => $db_charset,
'sum_size' => $sum_size,
'overhead_size' => $overhead_size,
'create_time_all' => $create_time_all,
'update_time_all' => $update_time_all,
'check_time_all' => $check_time_all,
'create_time_all' => ($create_time_all ? Util::localisedDate(strtotime($create_time_all)) : '-'),
'update_time_all' => ($update_time_all ? Util::localisedDate(strtotime($update_time_all)) : '-'),
'check_time_all' => ($check_time_all ? Util::localisedDate(strtotime($check_time_all)) : '-'),
'approx_rows' => $overall_approx_rows,
'num_favorite_tables' => $GLOBALS['cfg']['NumFavoriteTables'],
'db' => $GLOBALS['db'],
@@ -1,5 +1,6 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds the PhpMyAdmin\Controllers\Server\ServerDatabasesController
*
@@ -14,6 +15,7 @@
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
use PhpMyAdmin\Server\Common;
use PhpMyAdmin\Template;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -273,6 +275,22 @@ private function _getHtmlForDatabases(array $replication_types)
}
}
$values = array();
$units = array();
foreach ($column_order as $stat_name => $stat) {
if (array_key_exists($stat_name,$first_database)) {
if ($stat['format'] == 'byte') {
$byte_format = Util_formatByteDown($stat['footer'], 3, 1);
$values[$stat_name] = $byte_format[0];
$units[$stat_name] = $byte_format[1];
} elseif ($stat['format'] == 'number') {
$values[$stat_name] = Util::formatNumber($stat['footer'], 0);
} else{
$values[$stat_name] = htmlentities($stat['footer'], 0);
}
}
}
$_url_params = array(
'pos' => $this->_pos,
'dbstats' => $this->_dbstats,
@@ -308,6 +326,8 @@ private function _getHtmlForDatabases(array $replication_types)
'pma_theme_image' => $GLOBALS['pmaThemeImage'],
'text_dir' => $GLOBALS['text_dir'],
'dbstats' => $this->_dbstats,
'values' => $values,
'units' => $units,
]);
return $html;
@@ -446,6 +466,22 @@ function _buildHtmlForDb(
}
}
$values = array();
$units = array();
foreach ($column_order as $stat_name => $stat) {
if (array_key_exists($stat_name,$current)) {
if ($stat['format'] == 'byte') {
$byte_format = Util::formatByteDown($stat['footer'], 3, 1);
$values[$stat_name] = $byte_format[0];
$units[$stat_name] = $byte_format[1];
} elseif ($stat['format'] == 'number') {
$values[$stat_name] = Util_formatNumber($stat['footer'], 0);
} else{
$values[$stat_name] = htmlentities($stat['footer'], 0);
}
}
}
return Template::get('server/databases/table_row')->render([
'current' => $current,
'tr_class' => $tr_class,
@@ -458,6 +494,8 @@ function _buildHtmlForDb(
'allow_user_drop_database' => $GLOBALS['cfg']['AllowUserDropDatabase'],
'is_system_schema' => $this->dbi->isSystemSchema($current['SCHEMA_NAME'], true),
'default_tab_database' => $GLOBALS['cfg']['DefaultTabDatabase'],
'values' => $values,
'units' => $units,
]);
}
}
@@ -96,15 +96,26 @@ private function _setServerPlugins()
*/
private function _getPluginsHtml()
{
$plugins_type_clean = array();
$keys = array_keys($this->plugins);
foreach ($keys as $plugin_type) {
$plugins_type_clean[$plugin_type] = preg_replace(
'/[^a-z]/', '', mb_strtolower($plugin_type)
);
}
$html = '<div id="plugins_plugins">';
$html .= Template::get('server/plugins/section_links')
->render(array('plugins' => $this->plugins));
->render(array(
'plugins' => $this->plugins,
'plugins_type_clean' => $plugins_type_clean,
));
foreach ($this->plugins as $plugin_type => $plugin_list) {
$html .= Template::get('server/plugins/section')
->render(
array(
'plugin_type' => $plugin_type,
'plugin_type_clean' => $plugins_type_clean[$plugin_type],
'plugin_list' => $plugin_list,
)
);
@@ -525,6 +525,27 @@ public function displaySelectionFormAction($dataLabel = null)
)
)
);
$column_names = $this->_columnNames;
$column_types = $this->_columnTypes;
$types = array();
if ($this->_searchType == 'replace') {
$num_cols = count($column_names);
for ($i= 0; $i < $num_cols; $i++) {
$types[$column_names[$i]] = preg_replace('@\\(.*@s', '', $column_types[$i]);
}
}
$criteria_column_names = isset($_POST['criteriaColumnNames']) ? $_POST['criteriaColumnNames'] : null;
$keys = array();
for ($i= 0; $i < 4; $i++) {
if (isset($criteria_column_names[$i])) {
if ($criteria_column_names[$i] != 'pma_null') {
$keys[$criteria_column_names[$i]] = array_search($criteria_column_names[$i], $column_names);
}
}
}
$this->response->addHTML(
Template::get('table/search/selection_form')->render(array(
'search_type' => $this->_searchType,
@@ -533,11 +554,13 @@ public function displaySelectionFormAction($dataLabel = null)
'goto' => $goto,
'self' => $this,
'geom_column_flag' => $this->_geomColumnFlag,
'column_names' => $this->_columnNames,
'column_types' => $this->_columnTypes,
'column_names' => $column_names,
'column_types' => $column_types,
'types' => $types,
'column_collations' => $this->_columnCollations,
'data_label' => $dataLabel,
'criteria_column_names' => isset($_POST['criteriaColumnNames']) ? $_POST['criteriaColumnNames'] : null,
'keys' => $keys,
'criteria_column_names' => $criteria_column_names,
'criteria_column_types' => isset($_POST['criteriaColumnTypes']) ? $_POST['criteriaColumnTypes'] : null,
'sql_types' => $this->dbi->types,
'max_rows' => intval($GLOBALS['cfg']['MaxRows']),
@@ -1308,6 +1308,58 @@ function ($key, $val) {
$hideStructureActions = true;
}
// logic removed from Template
$rownum = 0;
$columns_list = array();
$attributes = array();
$displayed_field_names = array();
$displayed_field_names_replaced = array();
$row_comments = array();
$extracted_columnspecs = array();
foreach ($fields as $field) {
$rownum += 1;
$columns_list[] = $field['Field'];
$extracted_columnspecs[$rownum] = Util::extractColumnSpec($field['Type']);
$attributes[$rownum] = $extracted_columnspecs[$rownum]['attribute'];
if (strpos($field['Extra'], 'on update CURRENT_TIMESTAMP') !== false) {
$attributes[$rownum] = 'on update CURRENT_TIMESTAMP';
}
if (isset($field['Default'])) {
if ($field['Null'] == 'Yes') {
$field = array_merge($field, array('Default' => '<em>NULL</em>'));
}
} else {
$field = array_merge($field, array('Default' => $field['Default']));
}
$displayed_field_names[$rownum] = $field['Field'];
$row_comments[$rownum] = '';
if (isset($comments_map[$field['Field']])) {
$displayed_field_names[$rownum] = '<span ' .
'class="commented_column" title="' . $comments_map[$field['Field']] .
'">' . htmlspecialchars($field['Field']) . "</span>";
$row_comments[$rownum] = $comments_map[$field['Field']];
}
if ($primary_index && $primary_index->hasColumn($field['Field'])) {
$displayed_field_names[$rownum] = $displayed_field_names[$rownum] .
Util::getImage('b_primary', __('Primary'));
}
if (in_array($field['Field'], $columns_with_index)) {
$displayed_field_names[$rownum] = $displayed_field_names[$rownum] .
Util::getImage('b_key', __('Index'));
}
$displayed_field_names_replaced[$rownum] = preg_replace(
'/[\\x00-\\x1F]/',
'&#x2051;',
$displayed_field_names[$rownum]
);
}
return Template::get('table/structure/display_structure')->render(
array(
'hide_structure_actions' => $hideStructureActions,
@@ -1325,6 +1377,7 @@ function ($key, $val) {
'columns_list' => $columns_list,
'table_stats' => isset($tablestats) ? $tablestats : null,
'fields' => $fields,
'extracted_columnspecs' => $extracted_columnspecs,
'columns_with_index' => $columns_with_index,
'central_list' => $central_list,
'comments_map' => $comments_map,
@@ -1340,6 +1393,11 @@ function ($key, $val) {
'is_active' => Tracker::isActive(),
'have_partitioning' => Partition::havePartitioning(),
'partition_names' => Partition::getPartitionNames($this->db, $this->table),
'columns_list' => $columns_list,
'attributes' => $attributes,
'displayed_field_names' => $displayed_field_names,
'displayed_field_names_replaced' => $displayed_field_names_replaced,
'row_comments' => $row_comments,
)
);
}
@@ -212,7 +212,7 @@ private function getSideMenuParamsArray()
$result = $this->dbi->fetchSingleRow($query);
$params = json_decode($result['settings_data'], true);
$params = json_decode((string)$result['settings_data'], true);
}
return $params;
@@ -328,6 +328,32 @@ public function getDatabaseTables(
array $tables_all_keys,
array $tables_pk_or_unique_keys
) {
$table_names = $GLOBALS['designer']['TABLE_NAME'];
$columns_type = array();
foreach ($table_names as $table_name) {
$limit = count($tab_column[$table_name]['COLUMN_ID']);
for ($j = 0; $j < $limit; $j++) {
$table_column_name = $table_name . '.' . $tab_column[$table_name]['COLUMN_NAME'][$j];
if (isset($tables_pk_or_unique_keys[$table_column_name])) {
$columns_type[$table_column_name] = 'designer/FieldKey_small';
} else {
$columns_type[$table_column_name] = 'designer/Field_small';
if (strstr($tab_column[$table_name]['TYPE'][$j], 'char')
|| strstr($tab_column[$table_name]['TYPE'][$j], 'text')) {
$columns_type[$table_column_name] .= '_char';
} elseif (strstr($tab_column[$table_name]['TYPE'][$j], 'int')
|| strstr($tab_column[$table_name]['TYPE'][$j], 'float')
|| strstr($tab_column[$table_name]['TYPE'][$j], 'double')
|| strstr($tab_column[$table_name]['TYPE'][$j], 'decimal')) {
$columns_type[$table_column_name] .= '_int';
} elseif (strstr($tab_column[$table_name]['TYPE'][$j], 'date')
|| strstr($tab_column[$table_name]['TYPE'][$j], 'time')
|| strstr($tab_column[$table_name]['TYPE'][$j], 'year')) {
$columns_type[$table_column_name] .= '_date';
}
}
}
}
return Template::get('database/designer/database_tables')->render([
'db' => $GLOBALS['db'],
'get_db' => $_GET['db'],
@@ -337,13 +363,14 @@ public function getDatabaseTables(
'tab_column' => $tab_column,
'tables_all_keys' => $tables_all_keys,
'tables_pk_or_unique_keys' => $tables_pk_or_unique_keys,
'table_names' => $GLOBALS['designer']['TABLE_NAME'],
'table_names' => $table_names,
'table_names_url' => $GLOBALS['designer_url']['TABLE_NAME'],
'table_names_small' => $GLOBALS['designer']['TABLE_NAME_SMALL'],
'table_names_small_url' => $GLOBALS['designer_url']['TABLE_NAME_SMALL'],
'table_names_small_out' => $GLOBALS['designer_out']['TABLE_NAME_SMALL'],
'table_types' => $GLOBALS['designer']['TABLE_TYPE'],
'owner_out' => $GLOBALS['designer_out']['OWNER'],
'columns_type' => $columns_type,
'theme' => $GLOBALS['PMA_Theme'],
]);
}
@@ -4448,7 +4448,7 @@ private function _getSortedColumnMessage(
$column_for_first_row = mb_strtoupper(
mb_substr(
$column_for_first_row, 0, $GLOBALS['cfg']['LimitChars']
(string) $column_for_first_row, 0, $GLOBALS['cfg']['LimitChars']
) . '...'
);
@@ -15,7 +15,6 @@
use PhpMyAdmin\Twig\IndexExtension;
use PhpMyAdmin\Twig\MessageExtension;
use PhpMyAdmin\Twig\PartitionExtension;
use PhpMyAdmin\Twig\PhpFunctionsExtension;
use PhpMyAdmin\Twig\PluginsExtension;
use PhpMyAdmin\Twig\RelationExtension;
use PhpMyAdmin\Twig\SanitizeExtension;
@@ -77,7 +76,6 @@ protected function __construct($name)
$twig->addExtension(new IndexExtension());
$twig->addExtension(new MessageExtension());
$twig->addExtension(new PartitionExtension());
$twig->addExtension(new PhpFunctionsExtension());
$twig->addExtension(new PluginsExtension());
$twig->addExtension(new RelationExtension());
$twig->addExtension(new SanitizeExtension());

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 5d0fd81

Please sign in to comment.