예제 #1
0
/**
 * Prints Html For Display Import options : file property
 *
 * @param int            $max_upload_size   Max upload size
 * @param ImportPlugin[] $import_list       import list
 * @param String         $local_import_file from upload directory
 *
 * @return string
 */
function PMA_getHtmlForImportOptionsFile($max_upload_size, $import_list, $local_import_file)
{
    global $cfg;
    $html = '    <div class="importoptions">';
    $html .= '         <h3>' . __('File to import:') . '</h3>';
    $html .= PMA_getHtmlForImportCompressions();
    $html .= '        <div class="formelementrow" id="upload_form">';
    if ($GLOBALS['is_upload'] && !empty($cfg['UploadDir'])) {
        $html .= '            <ul>';
        $html .= '            <li>';
        $html .= '                <input type="radio" name="file_location" ' . 'id="radio_import_file" required="required" />';
        $html .= PMA\libraries\Util::getBrowseUploadFileBlock($max_upload_size);
        $html .= '<br />' . __('You may also drag and drop a file on any page.');
        $html .= '            </li>';
        $html .= '            <li>';
        $html .= '               <input type="radio" name="file_location" ' . 'id="radio_local_import_file"';
        if (!empty($GLOBALS['timeout_passed']) && !empty($local_import_file)) {
            $html .= ' checked="checked"';
        }
        $html .= ' />';
        $html .= PMA\libraries\Util::getSelectUploadFileBlock($import_list, $cfg['UploadDir']);
        $html .= '            </li>';
        $html .= '            </ul>';
    } elseif ($GLOBALS['is_upload']) {
        $html .= PMA\libraries\Util::getBrowseUploadFileBlock($max_upload_size);
        $html .= '<br />' . __('You may also drag and drop a file on any page.');
    } elseif (!$GLOBALS['is_upload']) {
        $html .= Message::notice(__('File uploads are not allowed on this server.'))->getDisplay();
    } elseif (!empty($cfg['UploadDir'])) {
        $html .= PMA\libraries\Util::getSelectUploadFileBlock($import_list, $cfg['UploadDir']);
    }
    // end if (web-server upload directory)
    $html .= '        </div>';
    $html .= PMA_getHtmlForImportCharset();
    $html .= '   </div>';
    return $html;
}
 /**
  * Test for PMA\libraries\Util::getBrowseUploadFileBlock
  *
  * @param int    $size Size
  * @param string $unit Unit
  * @param string $res  Result
  *
  * @return void
  *
  * @dataProvider dataProvider
  */
 function testBrowseUploadFile($size, $unit, $res)
 {
     $this->assertEquals(PMA\libraries\Util::getBrowseUploadFileBlock($size), '<label for="input_import_file">' . __("Browse your computer:") . '</label>' . '<div id="upload_form_status" style="display: none;"></div>' . '<div id="upload_form_status_info" style="display: none;"></div>' . '<input type="file" name="import_file" id="input_import_file" />' . "(" . __('Max: ') . $res . $unit . ")" . "\n" . '<input type="hidden" name="MAX_FILE_SIZE" value="' . $size . '" />' . "\n");
 }