/** * return HTML for the sql query boxes * * @param boolean|string $query query to display in the textarea * or true to display last executed * @param boolean|string $display_tab sql|files|history|full|false * what part to display * false if not inside querywindow * @param string $delimiter delimiter * * @return string * * @usedby server_sql.php * @usedby db_sql.php * @usedby tbl_sql.php * @usedby tbl_structure.php * @usedby tbl_tracking.php */ function PMA_getHtmlForSqlQueryForm($query = true, $display_tab = false, $delimiter = ';') { $html = ''; if (!$display_tab) { $display_tab = 'full'; } // query to show if (true === $query) { $query = $GLOBALS['sql_query']; } // set enctype to multipart for file uploads if ($GLOBALS['is_upload']) { $enctype = ' enctype="multipart/form-data"'; } else { $enctype = ''; } $table = ''; $db = ''; if (!mb_strlen($GLOBALS['db'])) { // prepare for server related $goto = empty($GLOBALS['goto']) ? 'server_sql.php' : $GLOBALS['goto']; } elseif (!mb_strlen($GLOBALS['table'])) { // prepare for db related $db = $GLOBALS['db']; $goto = empty($GLOBALS['goto']) ? 'db_sql.php' : $GLOBALS['goto']; } else { $table = $GLOBALS['table']; $db = $GLOBALS['db']; $goto = empty($GLOBALS['goto']) ? 'tbl_sql.php' : $GLOBALS['goto']; } // start output $html .= '<form method="post" action="import.php" ' . $enctype; $html .= ' class="ajax lock-page"'; $html .= ' id="sqlqueryform" name="sqlform">' . "\n"; $html .= '<input type="hidden" name="is_js_confirmed" value="0" />' . "\n" . PMA_URL_getHiddenInputs($db, $table) . "\n" . '<input type="hidden" name="pos" value="0" />' . "\n" . '<input type="hidden" name="goto" value="' . htmlspecialchars($goto) . '" />' . "\n" . '<input type="hidden" name="message_to_show" value="' . __('Your SQL query has been executed successfully.') . '" />' . "\n" . '<input type="hidden" name="prev_sql_query" value="' . htmlspecialchars($query) . '" />' . "\n"; // display querybox if ($display_tab === 'full' || $display_tab === 'sql') { $html .= PMA_getHtmlForSqlQueryFormInsert($query, $delimiter); } // display uploads if ($display_tab === 'files' && $GLOBALS['is_upload']) { $html .= PMA_getHtmlForSqlQueryFormUpload(); } // Bookmark Support if ($display_tab === 'full' || $display_tab === 'history') { $cfgBookmark = PMA_Bookmark_getParams(); if ($cfgBookmark) { $html .= PMA_getHtmlForSqlQueryFormBookmark(); } } // Encoding setting form appended by Y.Kawada if (function_exists('PMA_Kanji_encodingForm')) { $html .= PMA_Kanji_encodingForm(); } $html .= '</form>' . "\n"; // print an empty div, which will be later filled with // the sql query results by ajax $html .= '<div id="sqlqueryresults"></div>'; return $html; }
/** * Test for PMA_getHtmlForSqlQueryFormInsert * * @return void */ public function testPMAGetHtmlForSqlQueryFormInsert() { //Call the test function $query = "select * from PMA"; $html = PMA_getHtmlForSqlQueryFormInsert($query); //validate 1: query $this->assertContains(htmlspecialchars($query), $html); //validate 2: enable auto select text in textarea $auto_sel = ' onclick="selectContent(this, sql_box_locked, true);"'; $this->assertContains($auto_sel, $html); //validate 3: showMySQLDocu $this->assertContains(PMA_Util::showMySQLDocu('SELECT'), $html); //validate 4: $fields_list $this->assertContains('<input type="button" value="DELETE" id="delete"', $html); $this->assertContains('<input type="button" value="UPDATE" id="update"', $html); $this->assertContains('<input type="button" value="INSERT" id="insert"', $html); $this->assertContains('<input type="button" value="SELECT" id="select"', $html); $this->assertContains('<input type="button" value="SELECT *" id="selectall"', $html); //validate 5: Clear button $this->assertContains('<input type="button" value="DELETE" id="delete"', $html); $this->assertContains(__('Clear'), $html); }