/** * Test for PMA_getHtmlContentsFor1NFStep3 * * @return void */ public function testPMAGetHtmlContentsFor1NFStep3() { $db = "PMA_db"; $table = "PMA_table"; $result = PMA_getHtmlContentsFor1NFStep3($db, $table); $this->assertInternalType('array', $result); $this->assertArrayHasKey('legendText', $result); $this->assertArrayHasKey('headText', $result); $this->assertArrayHasKey('subText', $result); $this->assertArrayHasKey('extra', $result); $this->assertArrayHasKey('primary_key', $result); $this->assertContains(__('Step 1.') . 3, $result['legendText']); $this->assertContains(PMA_getHtmlForColumnsList($db, $table, 'all', "checkbox"), $result['extra']); $this->assertContains('<input type="submit" id="moveRepeatingGroup"', $result['extra']); $this->assertEquals(json_encode(array('id')), $result['primary_key']); }
/** * Normalization process (temporarily specific to 1NF) * * @package PhpMyAdmin */ /** * */ require_once 'libraries/common.inc.php'; require_once 'libraries/transformations.lib.php'; require_once 'libraries/normalization.lib.php'; require_once 'libraries/Index.class.php'; if (isset($_REQUEST['getColumns'])) { $html = '<option selected disabled>' . __('Select one…') . '</option>' . '<option value="no_such_col">' . __('No such column') . '</option>'; //get column whose datatype falls under string category $html .= PMA_getHtmlForColumnsList($db, $table, _pgettext('string types', 'String')); echo $html; exit; } if (isset($_REQUEST['splitColumn'])) { $num_fields = $_REQUEST['numFields']; $html = PMA_getHtmlForCreateNewColumn($num_fields, $db, $table); $html .= PMA_URL_getHiddenInputs($db, $table); echo $html; exit; } if (isset($_REQUEST['addNewPrimary'])) { $num_fields = 1; $columnMeta = array('Field' => $table . "_id", 'Extra' => 'auto_increment'); $html = PMA_getHtmlForCreateNewColumn($num_fields, $db, $table, $columnMeta); $html .= PMA_URL_getHiddenInputs($db, $table);
/** * build the html contents of various html elements in step 1.3 * * @param string $db current database * @param string $table current table * * @return string HTML contents for step 1.3 */ function PMA_getHtmlContentsFor1NFStep3($db, $table) { $step = 3; $stepTxt = __('Move repeating groups'); $legendText = __('Step 1.') . $step . " " . $stepTxt; $headText = __("Do you have a group of two or more columns that are closely " . "related and are all repeating the same attribute? For example, " . "a table that holds data on books might have columns such as book_id, " . "author1, author2, author3 and so on which form a " . "repeating group. In this case a new table (book_id, author) should " . "be created."); $subText = __("Check the columns which form a repeating group. " . "If no such group, click on 'No repeating group'"); $extra = PMA_getHtmlForColumnsList($db, $table, 'all', "checkbox") . "</br>" . '<input type="submit" id="moveRepeatingGroup" value="' . __('Done') . '"/>' . '<input type="submit" value="' . __('No repeating group') . '" onclick="goToStep4();"' . '/>'; $primary = PMA\libraries\Index::getPrimary($table, $db); $primarycols = $primary->getColumns(); $pk = array(); foreach ($primarycols as $col) { $pk[] = $col->getName(); } $res = array('legendText' => $legendText, 'headText' => $headText, 'subText' => $subText, 'extra' => $extra, 'primary_key' => json_encode($pk)); return $res; }