/**
  * Test for PMA_getUsersOverview
  *
  * @return void
  */
 public function testPMAGetUsersOverview()
 {
     $result = array();
     $db_rights = array();
     $pmaThemeImage = "pmaThemeImage";
     $text_dir = "text_dir";
     $GLOBALS['cfgRelation']['menuswork'] = true;
     $html = PMA_getUsersOverview($result, $db_rights, $pmaThemeImage, $text_dir);
     //PMA_URL_getHiddenInputs
     $this->assertContains(PMA_URL_getHiddenInputs('', ''), $html);
     //items
     $this->assertContains(__('User'), $html);
     $this->assertContains(__('Host'), $html);
     $this->assertContains(__('Password'), $html);
     $this->assertContains(__('Global privileges'), $html);
     //PMA\libraries\Util::showHint
     $this->assertContains(PMA\libraries\Util::showHint(__('Note: MySQL privilege names are expressed in English.')), $html);
     //__('User group')
     $this->assertContains(__('User group'), $html);
     $this->assertContains(__('Grant'), $html);
     $this->assertContains(__('Action'), $html);
     //$pmaThemeImage
     $this->assertContains($pmaThemeImage, $html);
     //$text_dir
     $this->assertContains($text_dir, $html);
     //PMA_getFieldsetForAddDeleteUser
     $this->assertContains(PMA_getFieldsetForAddDeleteUser(), $html);
 }
Пример #2
0
/**
 * get Submit button and Reset button for action panel
 *
 * @param integer $tabindex           tab index
 * @param integer $tabindex_for_value offset for the values tabindex
 *
 * @return string an html snippet
 */
function PMA_getSubmitAndResetButtonForActionsPanel($tabindex, $tabindex_for_value)
{
    return '<td>' . PMA\libraries\Util::showHint(__('Use TAB key to move from value to value,' . ' or CTRL+arrows to move anywhere')) . '</td>' . '<td colspan="3" class="right vmiddle">' . '<input type="submit" class="control_at_footer" value="' . __('Go') . '"' . ' tabindex="' . ($tabindex + $tabindex_for_value + 6) . '" id="buttonYes" />' . '<input type="button" class="preview_sql" value="' . __('Preview SQL') . '"' . ' tabindex="' . ($tabindex + $tabindex_for_value + 7) . '" />' . '<input type="reset" class="control_at_footer" value="' . __('Reset') . '"' . ' tabindex="' . ($tabindex + $tabindex_for_value + 8) . '" />' . '</td>';
}
Пример #3
0
/**
 * Prints Html For Export Options
 *
 * @param String $export_type Selected Export Type
 *
 * @return string
 */
function PMA_getHtmlForExportOptionsOutputFormat($export_type)
{
    $html = '<li>';
    $html .= '<label for="filename_template" class="desc">';
    $html .= __('File name template:');
    $trans = new Message();
    $trans->addText(__('@SERVER@ will become the server name'));
    if ($export_type == 'database' || $export_type == 'table') {
        $trans->addText(__(', @DATABASE@ will become the database name'));
        if ($export_type == 'table') {
            $trans->addText(__(', @TABLE@ will become the table name'));
        }
    }
    $msg = new Message(__('This value is interpreted using %1$sstrftime%2$s, ' . 'so you can use time formatting strings. ' . 'Additionally the following transformations will happen: %3$s. ' . 'Other text will be kept as is. See the %4$sFAQ%5$s for details.'));
    $msg->addParamHtml('<a href="' . PMA_linkURL(PMA_getPHPDocLink('function.strftime.php')) . '" target="documentation" title="' . __('Documentation') . '">');
    $msg->addParamHtml('</a>');
    $msg->addParam($trans);
    $doc_url = PMA\libraries\Util::getDocuLink('faq', 'faq6-27');
    $msg->addParamHtml('<a href="' . $doc_url . '" target="documentation">');
    $msg->addParamHtml('</a>');
    $html .= PMA\libraries\Util::showHint($msg);
    $html .= '</label>';
    $html .= '<input type="text" name="filename_template" id="filename_template" ';
    $html .= ' value="';
    if (isset($_GET['filename_template'])) {
        $html .= htmlspecialchars($_GET['filename_template']);
    } else {
        if ($export_type == 'database') {
            $html .= htmlspecialchars($GLOBALS['PMA_Config']->getUserValue('pma_db_filename_template', $GLOBALS['cfg']['Export']['file_template_database']));
        } elseif ($export_type == 'table') {
            $html .= htmlspecialchars($GLOBALS['PMA_Config']->getUserValue('pma_table_filename_template', $GLOBALS['cfg']['Export']['file_template_table']));
        } else {
            $html .= htmlspecialchars($GLOBALS['PMA_Config']->getUserValue('pma_server_filename_template', $GLOBALS['cfg']['Export']['file_template_server']));
        }
    }
    $html .= '"';
    $html .= '/>';
    $html .= '<input type="checkbox" name="remember_template" ';
    $html .= 'id="checkbox_remember_template" ';
    $html .= PMA_exportCheckboxCheck('remember_file_template');
    $html .= '/>';
    $html .= '<label for="checkbox_remember_template">';
    $html .= __('use this for future exports');
    $html .= '</label>';
    $html .= '</li>';
    return $html;
}
 /**
  * Tests for displayFormAction()
  *
  * @return void
  * @test
  */
 public function testDisplayFormAction()
 {
     $table = $this->getMockBuilder('PMA\\libraries\\Table')->disableOriginalConstructor()->getMock();
     $table->expects($this->any())->method('getStatusInfo')->will($this->returnValue(""));
     $table->expects($this->any())->method('isView')->will($this->returnValue(false));
     $table->expects($this->any())->method('getNameAndTypeOfTheColumns')->will($this->returnValue(array("field_name" => "field_type")));
     $GLOBALS['dbi']->expects($this->any())->method('getTable')->will($this->returnValue($table));
     $container = Container::getDefaultContainer();
     $container->set('db', 'db');
     $container->set('table', 'table');
     $container->set('dbi', $GLOBALS['dbi']);
     $response = new \PMA\Test\Stubs\Response();
     $container->set('PMA\\libraries\\Response', $response);
     $container->alias('response', 'PMA\\libraries\\Response');
     $index = new PMA\libraries\Index();
     $ctrl = new TableIndexesController($index);
     $_REQUEST['create_index'] = true;
     $_REQUEST['added_fields'] = 3;
     $ctrl->displayFormAction();
     $html = $response->getHTMLResult();
     //PMA_URL_getHiddenInputs
     $this->assertContains(PMA_URL_getHiddenInputs(array('db' => 'db', 'table' => 'table', 'create_index' => 1)), $html);
     $doc_html = PMA\libraries\Util::showHint(PMA\libraries\Message::notice(__('"PRIMARY" <b>must</b> be the name of' . ' and <b>only of</b> a primary key!')));
     $this->assertContains($doc_html, $html);
     $this->assertContains(PMA\libraries\Util::showMySQLDocu('ALTER_TABLE'), $html);
     // generateIndexSelector
     $this->assertContains(PMA\libraries\Template::trim($index->generateIndexChoiceSelector(false)), $html);
     $this->assertContains(sprintf(__('Add %s column(s) to index'), 1), $html);
     //$field_name & $field_type
     $this->assertContains("field_name", $html);
     $this->assertContains("field_type", $html);
 }
Пример #5
0
/**
 * Prints server state traffic information
 *
 * @param ServerStatusData $ServerStatusData Server status data
 *
 * @return string
 */
function PMA_getHtmlForServerStateTraffic($ServerStatusData)
{
    $hour_factor = 3600 / $ServerStatusData->status['Uptime'];
    $retval = '<table id="serverstatustraffic" class="data noclick">';
    $retval .= '<thead>';
    $retval .= '<tr>';
    $retval .= '<th>';
    $retval .= __('Traffic') . '&nbsp;';
    $retval .= PMA\libraries\Util::showHint(__('On a busy server, the byte counters may overrun, so those statistics ' . 'as reported by the MySQL server may be incorrect.'));
    $retval .= '</th>';
    $retval .= '<th>#</th>';
    $retval .= '<th>&oslash; ' . __('per hour') . '</th>';
    $retval .= '</tr>';
    $retval .= '</thead>';
    $retval .= '<tbody>';
    $retval .= '<tr>';
    $retval .= '<th class="name">' . __('Received') . '</th>';
    $retval .= '<td class="value">';
    $retval .= implode(' ', PMA\libraries\Util::formatByteDown($ServerStatusData->status['Bytes_received'], 3, 1));
    $retval .= '</td>';
    $retval .= '<td class="value">';
    $retval .= implode(' ', PMA\libraries\Util::formatByteDown($ServerStatusData->status['Bytes_received'] * $hour_factor, 3, 1));
    $retval .= '</td>';
    $retval .= '</tr>';
    $retval .= '<tr>';
    $retval .= '<th class="name">' . __('Sent') . '</th>';
    $retval .= '<td class="value">';
    $retval .= implode(' ', PMA\libraries\Util::formatByteDown($ServerStatusData->status['Bytes_sent'], 3, 1));
    $retval .= '</td>';
    $retval .= '<td class="value">';
    $retval .= implode(' ', PMA\libraries\Util::formatByteDown($ServerStatusData->status['Bytes_sent'] * $hour_factor, 3, 1));
    $retval .= '</td>';
    $retval .= '</tr>';
    $retval .= '<tr>';
    $retval .= '<th class="name">' . __('Total') . '</th>';
    $retval .= '<td class="value">';
    $bytes_received = $ServerStatusData->status['Bytes_received'];
    $bytes_sent = $ServerStatusData->status['Bytes_sent'];
    $retval .= implode(' ', PMA\libraries\Util::formatByteDown($bytes_received + $bytes_sent, 3, 1));
    $retval .= '</td>';
    $retval .= '<td class="value">';
    $bytes_received = $ServerStatusData->status['Bytes_received'];
    $bytes_sent = $ServerStatusData->status['Bytes_sent'];
    $retval .= implode(' ', PMA\libraries\Util::formatByteDown(($bytes_received + $bytes_sent) * $hour_factor, 3, 1));
    $retval .= '</td>';
    $retval .= '</tr>';
    $retval .= '</tbody>';
    $retval .= '</table>';
    return $retval;
}
/**
 * returns HTML for TableInfoForm
 *
 * @param int $hostname_length Selected hostname length
 *
 * @return String HTML code
 */
function PMA_getHtmlForTableInfoForm($hostname_length)
{
    $html = '        <option value="hosttable"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'hosttable' ? ' selected="selected"' : '') . '>' . __('Use Host Table') . '</option>' . '        <option value="userdefined"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'userdefined' ? ' selected="selected"' : '') . '>' . __('Use text field:') . '</option>' . '    </select>' . '</span>' . '<input type="text" name="hostname" maxlength="' . $hostname_length . '" value="' . (isset($_REQUEST['hostname']) ? $_REQUEST['hostname'] : '') . '" title="' . __('Host') . '" onchange="pred_hostname.value = \'userdefined\';" />' . PMA\libraries\Util::showHint(__('When Host table is used, this field is ignored ' . 'and values stored in Host table are used instead.')) . '</div>' . '<div class="item">' . '<label for="select_pred_password">' . '    ' . __('Password:'******'</label>' . '<span class="options">' . '    <select name="pred_password" id="select_pred_password" title="' . __('Password') . '"' . '            onchange="if (this.value == \'none\') ' . '{ pma_pw.value = \'\'; pma_pw2.value = \'\'; } ' . 'else if (this.value == \'userdefined\') ' . '{ pma_pw.focus(); pma_pw.select(); }">' . '        <option value="none"';
    if (isset($_REQUEST['username'])) {
        $html .= '  selected="selected"';
    }
    $html .= '>' . __('No Password') . '</option>' . '        <option value="userdefined"' . (isset($_REQUEST['username']) ? '' : ' selected="selected"') . '>' . __('Use text field:') . '</option>' . '    </select>' . '</span>' . '<input type="password" id="text_pma_pw" name="pma_pw" title="' . __('Password') . '" onchange="pred_password.value = \'userdefined\';" />' . '</div>' . '<div class="item">' . '<label for="text_pma_pw2">' . '    ' . __('Re-type:') . '</label>' . '<span class="options">&nbsp;</span>' . '<input type="password" name="pma_pw2" id="text_pma_pw2" title="' . __('Re-type') . '" onchange="pred_password.value = \'userdefined\';" />' . '</div>' . '<div class="item">' . '<label for="button_generate_password">' . '    ' . __('Generate password:'******'</label>' . '<span class="options">' . '    <input type="button" class="button" ' . 'id="button_generate_password" value="' . __('Generate') . '" onclick="suggestPassword(this.form)" />' . '</span>' . '<input type="text" name="generated_pw" id="generated_pw" />' . '</div>' . '</fieldset>';
    $html .= '<fieldset id="fieldset_user_privtable_footer" class="tblFooters">' . '    <input type="hidden" name="adduser_submit" value="1" />' . '    <input type="submit" id="adduser_submit" value="' . __('Go') . '" />' . '</fieldset>';
    return $html;
}