Struggeling with relocating
Dieser Commit ist enthalten in:
Commit
89ea01c429
301 geänderte Dateien mit 59926 neuen und 0 gelöschten Zeilen
115
inc/sqlbrowser/table/edit_table.php
Normale Datei
115
inc/sqlbrowser/table/edit_table.php
Normale Datei
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @version SVN: $rev: 1205 $
|
||||
* @author $Author$
|
||||
* @lastmodified $Date$
|
||||
*/
|
||||
|
||||
if (!defined('MSD_VERSION')) die('No direct access.');
|
||||
/*
|
||||
* Fetch and check _GET variables
|
||||
*/
|
||||
$db = isset($_GET['db']) ? base64_decode($_GET['db']) : $config['db_actual'];
|
||||
$tablename = isset($_GET['tablename']) ? base64_decode($_GET['tablename']) : '';
|
||||
$dbo->selectDb($db);
|
||||
$tableInfos=$dbo->getTableColumns($tablename, $db);
|
||||
|
||||
$tplSqlbrowserTableEditTable = new MSDTemplate();
|
||||
$tplSqlbrowserTableEditTable->set_filenames(
|
||||
array(
|
||||
'tplSqlbrowserTableEditTable' => 'tpl/sqlbrowser/table/edit_table.tpl'
|
||||
)
|
||||
);
|
||||
|
||||
$tplSqlbrowserTableEditTable->assign_vars(
|
||||
array(
|
||||
'DB' => $db,
|
||||
'TABLE' => $tablename
|
||||
)
|
||||
);
|
||||
|
||||
$sumSize = 0;
|
||||
$i = 0;
|
||||
foreach ($tableInfos as $key => $tableInfo) {
|
||||
if ($key != 'primary_keys') {
|
||||
$type = $tableInfo['Type'];
|
||||
$typeTemp = array();
|
||||
|
||||
// ENUM-/SET-Handling
|
||||
if (strpos($type, 'enum') !== false || strpos($type, 'set') !== false) {
|
||||
$toBeReplaced = array(
|
||||
'set(',
|
||||
'enum(',
|
||||
')',
|
||||
'\'');
|
||||
$typeTemp = str_replace($toBeReplaced, '', $type);
|
||||
$typeTemp = explode(',', $typeTemp);
|
||||
sort($typeTemp);
|
||||
if (strpos($type, 'enum') !== false) {
|
||||
$type = 'enum';
|
||||
} else {
|
||||
$type = 'set';
|
||||
}
|
||||
}
|
||||
$tplSqlbrowserTableEditTable->assign_block_vars(
|
||||
'ROW',
|
||||
array(
|
||||
'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1',
|
||||
'NR' => ($i + 1),
|
||||
'NAME' => $tableInfo['Field'],
|
||||
'TYPE' => $type,
|
||||
'NULL' => $tableInfo['Null']=='NO' ? $lang['L_NO']:$lang['L_YES'],
|
||||
'KEY' => $tableInfo['Key'],
|
||||
'DEFAULT' => $tableInfo['Default'],
|
||||
'EXTRA' => $tableInfo['Extra'],
|
||||
'SORTIERUNG' => $tableInfo['Collation']
|
||||
)
|
||||
);
|
||||
|
||||
if (count($typeTemp) > 0) {
|
||||
$tplSqlbrowserTableEditTable->assign_block_vars(
|
||||
'ROW.ENUM_SET',
|
||||
array(
|
||||
'SIZE' => count($typeTemp) < 5 ? count($typeTemp) : 5,
|
||||
'ICON_BROWSE' => $icon['browse'],
|
||||
'NR' => $i
|
||||
)
|
||||
);
|
||||
foreach ($typeTemp as $val) {
|
||||
$tplSqlbrowserTableEditTable->assign_block_vars(
|
||||
'ROW.ENUM_SET.ENUM_SET_ELEMENT',
|
||||
array('ELEMENT' => $val)
|
||||
);
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
// Output list of tables of the selected database
|
||||
|
||||
$tplSqlbrowserTableEditTable->assign_vars(
|
||||
array(
|
||||
'DB_NAME_URLENCODED' => base64_encode($db),
|
||||
'TABLE_NAME_URLENCODED' => base64_encode($tablename),
|
||||
'ICON_VIEW' => $icon['view'],
|
||||
'ICON_EDIT' => $icon['edit'],
|
||||
'ICON_OK' => $icon['ok'],
|
||||
'ICON_NOT_OK' => $icon['not_ok'],
|
||||
'ICON_DELETE' => $icon['delete'],
|
||||
'ICON_UP' => $icon['arrow_up'],
|
||||
'ICON_DOWN' => $icon['arrow_down'],
|
||||
'ICON_PLUS' => $icon['plus'],
|
||||
'ICON_MINUS' => $icon['minus'],
|
||||
'ICON_CANCEL' => $icon['cancel'],
|
||||
'DB' => $db,
|
||||
'DB_ENCODED' => base64_encode($db),
|
||||
'TABLE_ENCODED' => base64_encode($tablename),
|
||||
'ICONPATH' => $config['files']['iconpath']
|
||||
)
|
||||
);
|
||||
|
||||
259
inc/sqlbrowser/table/list_tables.php
Normale Datei
259
inc/sqlbrowser/table/list_tables.php
Normale Datei
|
|
@ -0,0 +1,259 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @version SVN: $rev: 1207 $
|
||||
* @author $Author$
|
||||
* @lastmodified $Date$
|
||||
*/
|
||||
|
||||
if (!defined('MSD_VERSION')) die('No direct access.');
|
||||
$checkit = (isset($_GET['checkit'])) ? base64_decode($_GET['checkit']) : '';
|
||||
$repair = (isset($_GET['repair'])) ? base64_decode($_GET['repair']) : 0;
|
||||
$tables = isset($_POST['table']) ? $_POST['table'] : array();
|
||||
$sortColumn = isset($_POST['sort_by_column']) ? $_POST['sort_by_column'] : 'name';
|
||||
$sortDirection = isset($_POST['sort_direction']) ? $_POST['sort_direction'] : 'a';
|
||||
$dbo->selectDb($db);
|
||||
$tableInfos = array();
|
||||
// is there any operation to do?
|
||||
if (isset($_POST['do']) && $_POST['do']>'' && sizeof($tables) > 0) {
|
||||
// which action should we perform?
|
||||
$queryResultType = MsdDbFactory::ARRAY_ASSOC;
|
||||
switch ($_POST['do'])
|
||||
{
|
||||
case 'analyze':
|
||||
$query = 'ANALYZE TABLE `%s`.`%s`';
|
||||
$actionOutput = $lang['L_ANALYZE'];
|
||||
break;
|
||||
case 'check':
|
||||
$query = 'CHECK TABLE `%s`.`%s`';
|
||||
$actionOutput = $lang['L_CHECK'];
|
||||
break;
|
||||
case 'repair':
|
||||
$query = 'REPAIR TABLE `%s`.`%s`';
|
||||
$actionOutput = $lang['L_REPAIR'];
|
||||
break;
|
||||
case 'drop':
|
||||
$query = 'DROP TABLE `%s`.`%s`';
|
||||
$actionOutput = $lang['L_DELETE'];
|
||||
$queryResultType = MsdDbFactory::SIMPLE;
|
||||
break;
|
||||
case 'truncate':
|
||||
$query = 'TRUNCATE TABLE `%s`.`%s`';
|
||||
$actionOutput = $lang['L_EMPTY'];
|
||||
$queryResultType = MsdDbFactory::SIMPLE;
|
||||
break;
|
||||
default:
|
||||
$query = 'OPTIMIZE TABLE `%s`.`%s`';
|
||||
$actionOutput = $lang['L_OPTIMIZE'];
|
||||
break;
|
||||
}
|
||||
|
||||
$tplSqlbrowserTableOperation = new MSDTemplate();
|
||||
$tplSqlbrowserTableOperation->set_filenames(
|
||||
array(
|
||||
'tplSqlbrowserTableOperation' => 'tpl/sqlbrowser/table/operation.tpl'
|
||||
)
|
||||
);
|
||||
$tplSqlbrowserTableOperation->assign_vars(
|
||||
array(
|
||||
'ACTION' => $actionOutput,
|
||||
'ICON_DELETE' => $icon['delete'],
|
||||
'ICON_OK' => $icon['ok'],
|
||||
'ICON_NOTOK' => $icon['not_ok'],
|
||||
)
|
||||
);
|
||||
$i = 0;
|
||||
foreach ($tables as $table) {
|
||||
$table = base64_decode($table);
|
||||
$res = $dbo->query(sprintf($query, $db, $table), $queryResultType);
|
||||
if ($res) {
|
||||
if (!is_array($res)) {
|
||||
// simple action without result (delete, truncate, ..)
|
||||
$tplSqlbrowserTableOperation->assign_block_vars(
|
||||
'ROW',
|
||||
array(
|
||||
'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1',
|
||||
'NR' => $i + 1,
|
||||
'TABLENAME' => $table,
|
||||
'ACTION' => $actionOutput,
|
||||
'TYPE' => sprintf($query, $db, $table),
|
||||
'MESSAGE' => ''
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$row = $res[0];
|
||||
// mainatining functions with result
|
||||
// (optimize, repair, analyze,..
|
||||
$msgType = isset($row['Msg_type']) ? $row['Msg_type'] : '';
|
||||
$msgTxt = isset($row['Msg_text']) ? $row['Msg_text'] : '';
|
||||
$tplSqlbrowserTableOperation->assign_block_vars(
|
||||
'ROW',
|
||||
array(
|
||||
'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1',
|
||||
'NR' => $i + 1,
|
||||
'TABLENAME' => $table,
|
||||
'ACTION' => isset($row['Op']) ? $row['Op'] : '',
|
||||
'TYPE' => $msgType,
|
||||
'MESSAGE' => $msgTxt
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// error
|
||||
$tplSqlbrowserTableOperation->assign_block_vars(
|
||||
'ERROR',
|
||||
array(
|
||||
'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1',
|
||||
'NR' => $i + 1,
|
||||
'TABLENAME' => $table,
|
||||
'ERROR' => mysql_error(),
|
||||
'QUERY' => sprintf($query, $db, $table)
|
||||
)
|
||||
);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
// Output list of tables of the selected database
|
||||
$tableInfos = getTableInfo($db);
|
||||
// extract sorted one-dimensional array with infos we need
|
||||
$orderArray = get_orderarray($sortColumn . ',' . $sortDirection . '|name,a');
|
||||
$sortedTableInfos = arfsort($tableInfos[$db]['tables'], $orderArray);
|
||||
$tplSqlbrowserTableListTables = new MSDTemplate();
|
||||
$tplSqlbrowserTableListTables->set_filenames(
|
||||
array(
|
||||
'tplSqlbrowserTableListTables' => 'tpl/sqlbrowser/table/listTables.tpl'
|
||||
)
|
||||
);
|
||||
$numrows = $tableInfos[$db]['table_count'];
|
||||
$up = $icon['arrow_up'];
|
||||
$down = $icon['arrow_down'];
|
||||
$sortName = $sortColumn == 'name' ? ($sortDirection == 'd' ? $down : $up) : '';
|
||||
$sD = $sortDirection;
|
||||
$sC = $sortColumn;
|
||||
$tplSqlbrowserTableListTables->assign_vars(
|
||||
array(
|
||||
'ICON_VIEW' => $icon['view'],
|
||||
'ICON_EDIT' => $icon['edit'],
|
||||
'ICON_OK' => $icon['ok'],
|
||||
'ICON_NOT_OK' => $icon['not_ok'],
|
||||
'ICON_DELETE' => $icon['delete'],
|
||||
'ICON_TRUNCATE' => $icon['truncate'],
|
||||
'ICON_UP' => $up,
|
||||
'ICON_DOWN' => $down,
|
||||
'ICON_PLUS' => $icon['plus'],
|
||||
'ICON_MINUS' => $icon['minus'],
|
||||
'ICON_CANCEL' => $icon['cancel'],
|
||||
'DB_NAME' => $db,
|
||||
'DB_NAME_URLENCODED' => base64_encode($db),
|
||||
'TABLE_COUNT' => String::formatNumber($numrows),
|
||||
'ICONPATH' => $config['files']['iconpath'],
|
||||
'SORT_BY_COLUMN' => $sC,
|
||||
'SORT_DIRECTION' => $sD,
|
||||
'SORT_NAME' => $sortName,
|
||||
'SORT_RECORDS' => $sC == 'records' ? ($sD == 'D' ? $down : $up) : '',
|
||||
'SORT_DATA_LENGTH' =>
|
||||
$sC == 'data_length' ? ($sD == 'D' ? $down : $up) : '',
|
||||
'SORT_INDEX_LENGTH' =>
|
||||
$sC == 'index_length' ? ($sD == 'D' ? $down : $up) : '',
|
||||
'SORT_AUTO_INCREMENT' =>
|
||||
$sC == 'auto_increment' ? ($sD == 'D' ? $down : $up) : '',
|
||||
'SORT_DATA_FREE' =>
|
||||
$sC == 'data_free' ? ($sD == 'D' ? $down : $up) : '',
|
||||
'SORT_UPDATE_TIME' =>
|
||||
$sC == 'update_time' ? ($sD == 'd' ? $down : $up) : '',
|
||||
'SORT_ENGINE' =>
|
||||
$sC == 'engine' ? ($sD == 'd' ? $down : $up) : '',
|
||||
'SORT_COLLATION' =>
|
||||
$sC == 'collation' ? ($sD == 'd' ? $down : $up) : '',
|
||||
'SORT_COMMENT' => $sC == 'comment' ? ($sD == 'd' ? $down : $up) : '',
|
||||
'CONFIRM_TRUNCATE_TABLES' =>
|
||||
Html::getJsQuote($lang['L_CONFIRM_TRUNCATE_TABLES']),
|
||||
'CONFIRM_DELETE_TABLES' =>
|
||||
Html::getJsQuote($lang['L_CONFIRM_DELETE_TABLES']),
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
if ($numrows > 1) {
|
||||
$tplSqlbrowserTableListTables->assign_block_vars('MORE_TABLES', array());
|
||||
} elseif ($numrows == 1) {
|
||||
$tplSqlbrowserTableListTables->assign_block_vars('1_TABLE', array());
|
||||
} elseif ($numrows == 0) {
|
||||
$tplSqlbrowserTableListTables->assign_block_vars(
|
||||
'NO_TABLE',
|
||||
array(
|
||||
'HIDE' => ' style="display:none;"'
|
||||
)
|
||||
);
|
||||
}
|
||||
$lastUpdate = 0; // remember the latest update for sum-line
|
||||
$i = 0;
|
||||
foreach ($sortedTableInfos as $val) {
|
||||
if ($val['update_time'] > $lastUpdate) {
|
||||
$lastUpdate = $val['update_time'];
|
||||
}
|
||||
$updateTime = $val['update_time'] > '' ? $val['update_time'] : ' ';
|
||||
$autoIncrement = '-';
|
||||
if ((int) $val['auto_increment'] > 0) {
|
||||
$autoIncrement = String::formatNumber($val['auto_increment']);
|
||||
}
|
||||
$tplSqlbrowserTableListTables->assign_block_vars(
|
||||
'ROW',
|
||||
array(
|
||||
'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1',
|
||||
'NR' => ($i + 1),
|
||||
'TABLE_NAME' => $val['name'],
|
||||
'TABLE_NAME_URLENCODED' => base64_encode($val['name']),
|
||||
'RECORDS' => String::formatNumber($val['records']),
|
||||
'DATA_LENGTH' => byteOutput($val['data_length']),
|
||||
'INDEX_LENGTH' => byteOutput($val['index_length']),
|
||||
'LAST_UPDATE' => $updateTime,
|
||||
'ENGINE' => $val['engine'],
|
||||
'COLLATION' => $val['collation'],
|
||||
'COMMENT' => $val['comment'] > '' ? $val['comment'] : '',
|
||||
'AUTO_INCREMENT' => $autoIncrement
|
||||
)
|
||||
);
|
||||
// re-check table if it was checked before
|
||||
if (in_array(base64_encode($val['name']), $tables)) {
|
||||
$tplSqlbrowserTableListTables->assign_block_vars(
|
||||
'ROW.TABLE_CHECKED', array()
|
||||
);
|
||||
}
|
||||
|
||||
// is table optimized?
|
||||
if (in_array($val['engine'], array('MyISAM', 'ARCHIVE'))) {
|
||||
if ($val['data_free'] == 0) {
|
||||
$tplSqlbrowserTableListTables->assign_block_vars(
|
||||
'ROW.OPTIMIZED', array()
|
||||
);
|
||||
} else {
|
||||
$tplSqlbrowserTableListTables->assign_block_vars(
|
||||
'ROW.NOT_OPTIMIZED',
|
||||
array('VALUE' => byteOutput($val['data_free']))
|
||||
);
|
||||
}
|
||||
}
|
||||
else // optimize is not supported for this engine
|
||||
$tplSqlbrowserTableListTables->assign_block_vars(
|
||||
'ROW.OPTIMIZE_NOT_SUPPORTED', array()
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Output sum-line
|
||||
$indexLen = $tableInfos[$db]['size_total'] - $tableInfos[$db]['datasize_total'];
|
||||
$tplSqlbrowserTableListTables->assign_block_vars(
|
||||
'SUM',
|
||||
array(
|
||||
'RECORDS' => String::formatNumber($tableInfos[$db]['records_total']),
|
||||
'DATA_LENGTH' => byteOutput($tableInfos[$db]['datasize_total']),
|
||||
'INDEX_LENGTH' => byteOutput($indexLen),
|
||||
'LAST_UPDATE' => $lastUpdate
|
||||
)
|
||||
);
|
||||
230
inc/sqlbrowser/table/show_tabledata.php
Normale Datei
230
inc/sqlbrowser/table/show_tabledata.php
Normale Datei
|
|
@ -0,0 +1,230 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @version $Rev$
|
||||
* @author $Author$
|
||||
* @lastmodified $Date$
|
||||
*/
|
||||
|
||||
if (!defined('MSD_VERSION')) die('No direct access.');
|
||||
$tablename = isset($_POST['tablename']) ? base64_decode($_POST['tablename']) : '';
|
||||
if (isset($_GET['tablename'])) {
|
||||
$tablename = base64_decode($_GET['tablename']);
|
||||
}
|
||||
$dbo->selectDb($db);
|
||||
$tableInfos = $dbo->getTableColumns($tablename);
|
||||
if ($tablename == '') {
|
||||
$tablenames = array_keys($tableInfos[$db]['tables']);
|
||||
$tablename = $tablenames[0];
|
||||
}
|
||||
//v($_POST);
|
||||
$tableInfos = $dbo->getTableColumns($tablename);
|
||||
$sortByColumn = '';
|
||||
if (isset($_POST['sort_by_column']) && isset($tableInfos[$sortByColumn])) {
|
||||
$sortByColumn = base64_decode($_POST['sort_by_column']);
|
||||
}
|
||||
$sortDirection = 'ASC';
|
||||
if (isset($_POST['sort_direction'])) {
|
||||
$sortDirection = (string) $_POST['sort_direction'];
|
||||
}
|
||||
if (in_array($sortDirection, array('d', 'D'))) {
|
||||
$desc = 'DESC';
|
||||
}
|
||||
$maxEntries = $config['resultsPerPage'];
|
||||
if (isset($_GET['limit_max_entries'])) {
|
||||
$maxEntries =(int) $_GET['limit_max_entries'];
|
||||
}
|
||||
$showAll = 0;
|
||||
$limitStart = 0;
|
||||
if (isset($_GET['limit_start']) && $_GET['limit_start'] > 0 && !$showAll) {
|
||||
$limitStart = $_GET['limit_start'];
|
||||
}
|
||||
|
||||
$tplSqlbrowserTableShowTabledata = new MSDTemplate();
|
||||
$tplSqlbrowserTableShowTabledata->set_filenames(
|
||||
array(
|
||||
'tplSqlbrowserTableShowTabledata' =>
|
||||
'tpl/sqlbrowser/table/show_tabledata.tpl'
|
||||
)
|
||||
);
|
||||
|
||||
//TODO: Language_vars im Sprachlabor anlegen und hier entfernen.
|
||||
$languageVars =
|
||||
array(
|
||||
'L_SQL_DATAOFTABLE' => 'Datensätze der Tabelle',
|
||||
'L_SQL_SHOW_NUM_ENTRIES' => 'Zeige Datensätze: ',
|
||||
'L_SHOW' => 'Zeige',
|
||||
'L_ENTRIES_PER_PAGE' => 'pro Seite (0 = alle anzeigen)',
|
||||
'L_STARTING_WITH' => 'beginnend mit Eintrag',
|
||||
'L_EDIT_ENTRY' => 'Eintrag editieren',
|
||||
'L_VIEW_ENTRY' => 'Eintrag anzeigen',
|
||||
'L_NEW_ENTRY' => 'Eintrag anlegen',
|
||||
'L_EXECUTED_QUERY' => 'Ausgeführte MySQL-Query:',
|
||||
'L_ROWS_AFFECTED' => 'Zeilen betroffen',
|
||||
'L_QUERY_FAILED' => 'Query fehlgeschlagen'
|
||||
);
|
||||
$tplSqlbrowserTableShowTabledata->assign_vars($languageVars);
|
||||
|
||||
if (isset($_POST['action'])) {
|
||||
processPostAction($tplSqlbrowserTableShowTabledata, $db, $tablename);
|
||||
}
|
||||
$query = "SELECT COUNT(*) as count FROM `$tablename`";
|
||||
$res=$dbo->query($query, MsdDbFactory::ARRAY_ASSOC);
|
||||
$numRecords=(int) $res[0];
|
||||
|
||||
if (isset($_GET['pager'])) {
|
||||
switch ($_GET['pager'])
|
||||
{
|
||||
case '<':
|
||||
$limitStart -= $maxEntries;
|
||||
break;
|
||||
case '<<':
|
||||
$limitStart = 0;
|
||||
break;
|
||||
case '>>':
|
||||
$limitStart = $showAll ? 0 : $numRecords - $maxEntries;
|
||||
break;
|
||||
case '>':
|
||||
$limitStart += $maxEntries;
|
||||
break;
|
||||
}
|
||||
$limitStart = min($numRecords - $maxEntries, $limitStart);
|
||||
$limitStart = max($limitStart, 0);
|
||||
}
|
||||
|
||||
$templateVars =
|
||||
array(
|
||||
'DB_NAME' => $db,
|
||||
'TABLE_NAME' => $tablename,
|
||||
'DB_NAME_URLENCODED' => base64_encode($db),
|
||||
'TABLE_NAME_URLENCODED' => base64_encode($tablename),
|
||||
'ENTRY_COUNT' => $numRecords,
|
||||
'LIMIT_START' => $limitStart,
|
||||
'FIRST_ENTRY_NUM' => $limitStart + 1,
|
||||
'LAST_ENTRY_NUM' => $showAll ? $num["count"] : $limitStart + $maxEntries,
|
||||
'MAX_ENTRIES' => $maxEntries,
|
||||
'SORT_DIRECTION' => $sortDirection == 'ASC' ? 'd':'a',
|
||||
'SORT_BY_COLUMN' => $sortByColumn,
|
||||
'ICON_VIEW' => $icon['view'],
|
||||
'ICON_EDIT' => $icon['edit'],
|
||||
'ICON_PLUS' => $icon['plus'],
|
||||
'ICON_MINUS' => $icon['minus'],
|
||||
'ICON_DELETE' => $icon['delete'],
|
||||
'ICON_EDIT' => $icon['edit']
|
||||
);
|
||||
$tplSqlbrowserTableShowTabledata->assign_vars($templateVars);
|
||||
|
||||
/*
|
||||
* Build the Table-Header columns
|
||||
*/
|
||||
$field_infos = getExtendedFieldInfo($db, $tablename);
|
||||
foreach ($field_infos as $field => $val) {
|
||||
$sD = '';
|
||||
if ($val['field'] == $sortByColumn) {
|
||||
$sD = $desc == 'DESC' ? $icon['arrow_down'] : $icon['arrow_up'];
|
||||
}
|
||||
$tplSqlbrowserTableShowTabledata->assign_block_vars(
|
||||
'COL_HEADER',
|
||||
array(
|
||||
'LABEL' => $val['field'],
|
||||
'NAME' => base64_encode($val['field']),
|
||||
'COMMENT' => $val['comment'],
|
||||
'SORT' => $sD
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the Datarows
|
||||
*/
|
||||
$query = "SELECT * FROM `$tablename`";
|
||||
if ($sortByColumn>'') {
|
||||
$query .= ' ORDER BY `'.$sortByColumn.'` '.$sortDirection;
|
||||
}
|
||||
if ($limitStart>0) {
|
||||
$query .= " LIMIT $limitStart, $maxEntries";
|
||||
}
|
||||
$result = $dbo->query($query, MsdDbFactory::ARRAY_ASSOC);
|
||||
$entryNum = $limitStart;
|
||||
//echo $order;
|
||||
|
||||
//Daten holen:
|
||||
$nr_of_fields = 0;
|
||||
$i = 1;
|
||||
foreach ($result as $row) {
|
||||
$nr_of_fields = sizeof($row);
|
||||
$tplSqlbrowserTableShowTabledata->assign_block_vars(
|
||||
'ROW',
|
||||
array(
|
||||
'NR' => $i,
|
||||
'RECORD_KEY_ENCODED' => base64_encode(getRecordIdentifier($db, $tablename, $row)),
|
||||
'ROW_CLASS' => $i % 2 ? 'dbrow' : 'dbrow1'
|
||||
)
|
||||
);
|
||||
foreach ($row as $val) {
|
||||
$tplSqlbrowserTableShowTabledata->assign_block_vars(
|
||||
'ROW.COL',
|
||||
array(
|
||||
'VAL' => htmlentities($val, ENT_COMPAT, 'utf-8'),
|
||||
'CLASS' => is_numeric($val) ? ' right' : ''
|
||||
)
|
||||
);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
$tplSqlbrowserTableShowTabledata->assign_vars(
|
||||
array('BUTTONBAR_COLSPAN' => $nr_of_fields + 3)
|
||||
);
|
||||
|
||||
function processPostAction($tplSqlbrowserTableShowTabledata, $db, $tablename)
|
||||
{
|
||||
global $dbo;
|
||||
$action = $_POST['action'];
|
||||
if (!in_array($action, array('edit', 'new'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fields = implode(', ', fetchSetFields($_POST, 'field_'));
|
||||
|
||||
$sql = "INSERT INTO `$tablename` SET " . $fields . ";";
|
||||
if ($action == 'edit') {
|
||||
$sql = "UPDATE `$tablename` SET " . $fields . " WHERE "
|
||||
. base64_decode($_POST['key']) . ' LIMIT 1;';
|
||||
}
|
||||
$result = $dbo->query($sql,MsdDbFactory::SIMPLE);
|
||||
if (!$result) {
|
||||
$tplSqlbrowserTableShowTabledata->assign_block_vars(
|
||||
'MYSQL_ERROR',
|
||||
array(
|
||||
'QUERY' => htmlspecialchars($sql),
|
||||
'ERROR' => mysql_error()
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
$tplSqlbrowserTableShowTabledata->assign_block_vars(
|
||||
'POSTED_MYSQL_QUERY',
|
||||
array(
|
||||
'QUERY' => htmlspecialchars($sql),
|
||||
'ROWS_AFFECTED' => $dbo->getAffectedRows()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function fetchSetFields($arr, $prefix)
|
||||
{
|
||||
global $dbo;
|
||||
$answer = array();
|
||||
foreach ($arr as $key => $value) {
|
||||
if (strpos($key, $prefix) === 0) {
|
||||
$field = base64_decode(substr($key, strlen($prefix)));
|
||||
$answer[] = "`$field` = \"" . $dbo->escape($value) . "\"";
|
||||
}
|
||||
}
|
||||
return $answer;
|
||||
}
|
||||
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren