' . "\n"; $html .= '' . "\n" . Url::getHiddenInputs($db, $table) . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n"; // display querybox if ($display_tab === 'full' || $display_tab === 'sql') { $html .= self::getHtmlForInsert( $query, $delimiter ); } // Bookmark Support if ($display_tab === 'full') { $cfgBookmark = Bookmark::getParams($GLOBALS['cfg']['Server']['user']); if ($cfgBookmark) { $html .= self::getHtmlForBookmark(); } } // Japanese encoding setting if (Encoding::canConvertKanji()) { $html .= Encoding::kanjiEncodingForm(); } $html .= '' . "\n"; // print an empty div, which will be later filled with // the sql query results by ajax $html .= '
'; return $html; } /** * Get initial values for Sql Query Form Insert * * @param string $query query to display in the textarea * * @return array ($legend, $query, $columns_list) * * @usedby self::getHtmlForInsert() */ public static function init($query) { $columns_list = array(); if (strlen($GLOBALS['db']) === 0) { // prepare for server related $legend = sprintf( __('Run SQL query/queries on server ā€œ%sā€'), htmlspecialchars( ! empty($GLOBALS['cfg']['Servers'][$GLOBALS['server']]['verbose']) ? $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['verbose'] : $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host'] ) ); } elseif (strlen($GLOBALS['table']) === 0) { // prepare for db related $db = $GLOBALS['db']; // if you want navigation: $tmp_db_link = ''; $legend = sprintf(__('Run SQL query/queries on database %s'), $tmp_db_link); if (empty($query)) { $query = Util::expandUserString( $GLOBALS['cfg']['DefaultQueryDatabase'], 'backquote' ); } } else { $db = $GLOBALS['db']; $table = $GLOBALS['table']; // Get the list and number of fields // we do a try_query here, because we could be in the query window, // trying to synchronize and the table has not yet been created $columns_list = $GLOBALS['dbi']->getColumns( $db, $GLOBALS['table'], null, true ); $tmp_tbl_link = ''; $tmp_tbl_link .= htmlspecialchars($db) . '.' . htmlspecialchars($table) . ''; $legend = sprintf(__('Run SQL query/queries on table %s'), $tmp_tbl_link); if (empty($query)) { $query = Util::expandUserString( $GLOBALS['cfg']['DefaultQueryTable'], 'backquote' ); } } $legend .= ': ' . Util::showMySQLDocu('SELECT'); return array($legend, $query, $columns_list); } /** * return HTML for Sql Query Form Insert * * @param string $query query to display in the textarea * @param string $delimiter default delimiter to use * * @return string * * @usedby self::getHtml() */ public static function getHtmlForInsert( $query = '', $delimiter = ';' ) { // enable auto select text in textarea if ($GLOBALS['cfg']['TextareaAutoSelect']) { $auto_sel = ' onclick="selectContent(this, sql_box_locked, true);"'; } else { $auto_sel = ''; } $locking = ''; $height = $GLOBALS['cfg']['TextareaRows'] * 2; list($legend, $query, $columns_list) = self::init($query); if (! empty($columns_list)) { $sqlquerycontainer_id = 'sqlquerycontainer'; } else { $sqlquerycontainer_id = 'sqlquerycontainerfull'; } $html = '' . '
' . '
'; $html .= '' . $legend . ''; $html .= '
'; $html .= '
' . ''; $html .= '
'; // Add buttons to generate query easily for // select all, single select, insert, update and delete if (! empty($columns_list)) { $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; } $html .= ''; if ($GLOBALS['cfg']['CodemirrorEnable']) { $html .= ''; } $html .= ''; // parameter binding $html .= '
'; $html .= ''; $html .= ''; $html .= Util::showDocu('faq', 'faq6-40'); $html .= '
'; $html .= '
'; $html .= '
' . "\n"; if (! empty($columns_list)) { $html .= '
' . '' . '' . '
'; if (Util::showIcons('ActionLinksMode')) { $html .= ''; } else { $html .= ''; } $html .= '
' . "\n" . '
' . "\n"; } $html .= '
' . "\n"; $html .= '
' . "\n"; $cfgBookmark = Bookmark::getParams($GLOBALS['cfg']['Server']['user']); if ($cfgBookmark) { $html .= '
'; $html .= '
'; $html .= ''; $html .= ''; $html .= '
'; $html .= '
'; $html .= ''; $html .= ''; $html .= '
'; $html .= '
'; $html .= ''; $html .= ''; $html .= '
'; $html .= '
'; } $html .= '
' . "\n"; $html .= '
' . "\n" . '
' . "\n"; $html .= '
' . "\n"; $html .= '
' . "\n"; $html .= '
' . "\n"; $html .= '
'; $html .= '' . "\n"; $html .= ' ]'; $html .= '
'; $html .= '
'; $html .= '' . ''; $html .= '
'; $html .= '
'; $html .= '' . ''; $html .= '
'; $html .= '
'; $html .= '' . ''; $html .= '
'; // Disable/Enable foreign key checks $html .= '
'; $html .= Util::getFKCheckbox(); $html .= '
'; $html .= '' . "\n"; $html .= '
' . "\n"; $html .= '
' . "\n"; return $html; } /** * return HTML for sql Query Form Bookmark * * @return string|null * * @usedby self::getHtml() */ public static function getHtmlForBookmark() { $bookmark_list = Bookmark::getList( $GLOBALS['dbi'], $GLOBALS['cfg']['Server']['user'], $GLOBALS['db'] ); if (empty($bookmark_list) || count($bookmark_list) < 1) { return null; } $html = '
'; $html .= ''; $html .= __('Bookmarked SQL query') . '' . "\n"; $html .= '
'; $html .= ' ' . "\n"; $html .= '
' . "\n"; $html .= '
' . "\n"; $html .= '' . '' . "\n"; $html .= '' . '' . "\n"; $html .= '' . '' . "\n"; $html .= '
' . "\n"; $html .= '
' . "\n"; $html .= '
' . "\n"; $html .= __('Variables'); $html .= Util::showDocu('faq', 'faqbookmark'); $html .= '
'; $html .= '
' . "\n"; $html .= '
' . "\n"; $html .= '
'; $html .= ''; $html .= '
' . "\n"; $html .= '
' . "\n"; return $html; } }