当前位置: 首页>>代码示例>>PHP>>正文


PHP PMA_Util::extractColumnSpec方法代码示例

本文整理汇总了PHP中PMA_Util::extractColumnSpec方法的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Util::extractColumnSpec方法的具体用法?PHP PMA_Util::extractColumnSpec怎么用?PHP PMA_Util::extractColumnSpec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PMA_Util的用法示例。


在下文中一共展示了PMA_Util::extractColumnSpec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: PMA_getHtmlForColumnsList

/**
 * build the html for columns of $colTypeCategory category
 * in form of given $listType in a table
 *
 * @param string $db              current database
 * @param string $table           current table
 * @param string $colTypeCategory supported all|Numeric|String|Spatial
 *                                |Date and time using the _pgettext() format
 * @param string $listType        type of list to build, supported dropdown|checkbox
 *
 * @return HTML for list of columns in form of given list types
 */
function PMA_getHtmlForColumnsList($db, $table, $colTypeCategory = 'all', $listType = 'dropdown')
{
    $columnTypeList = array();
    if ($colTypeCategory != 'all') {
        $types = $GLOBALS['PMA_Types']->getColumns();
        $columnTypeList = $types[$colTypeCategory];
    }
    $GLOBALS['dbi']->selectDb($db, $GLOBALS['userlink']);
    $columns = (array) $GLOBALS['dbi']->getColumns($db, $table, null, true, $GLOBALS['userlink']);
    $type = "";
    $selectColHtml = "";
    foreach ($columns as $column => $def) {
        if (isset($def['Type'])) {
            $extracted_columnspec = PMA_Util::extractColumnSpec($def['Type']);
            $type = $extracted_columnspec['type'];
        }
        if (empty($columnTypeList) || in_array(mb_strtoupper($type), $columnTypeList)) {
            if ($listType == 'checkbox') {
                $selectColHtml .= '<input type="checkbox" value="' . htmlspecialchars($column) . '"/>' . htmlspecialchars($column) . ' [ ' . htmlspecialchars($def['Type']) . ' ]</br>';
            } else {
                $selectColHtml .= '<option value="' . htmlspecialchars($column) . '' . '">' . htmlspecialchars($column) . ' [ ' . htmlspecialchars($def['Type']) . ' ]' . '</option>';
            }
        }
    }
    return $selectColHtml;
}
开发者ID:graurus,项目名称:testgit_t37,代码行数:38,代码来源:normalization.lib.php

示例2: PMA_getHtmlForInsertEditFormColumn

/**
 * Function to get html for each insert/edit column
 *
 * @param array  $table_columns         table columns
 * @param int    $column_number         column index in table_columns
 * @param array  $comments_map          comments map
 * @param bool   $timestamp_seen        whether timestamp seen
 * @param array  $current_result        current result
 * @param string $chg_evt_handler       javascript change event handler
 * @param string $jsvkey                javascript validation key
 * @param string $vkey                  validation key
 * @param bool   $insert_mode           whether insert mode
 * @param array  $current_row           current row
 * @param bool   $odd_row               whether odd row
 * @param int    &$o_rows               row offset
 * @param int    &$tabindex             tab index
 * @param int    $columns_cnt           columns count
 * @param bool   $is_upload             whether upload
 * @param int    $tabindex_for_function tab index offset for function
 * @param array  $foreigners            foreigners
 * @param int    $tabindex_for_null     tab index offset for null
 * @param int    $tabindex_for_value    tab index offset for value
 * @param string $table                 table
 * @param string $db                    database
 * @param int    $row_id                row id
 * @param array  $titles                titles
 * @param int    $biggest_max_file_size biggest max file size
 * @param string $default_char_editing  default char editing mode which is stored
 *                                      in the config.inc.php script
 * @param string $text_dir              text direction
 * @param array  $repopulate            the data to be repopulated
 * @param array  $column_mime           the mime information of column
 * @param string $where_clause          the where clause
 *
 * @return string
 */
function PMA_getHtmlForInsertEditFormColumn($table_columns, $column_number, $comments_map, $timestamp_seen, $current_result, $chg_evt_handler, $jsvkey, $vkey, $insert_mode, $current_row, $odd_row, &$o_rows, &$tabindex, $columns_cnt, $is_upload, $tabindex_for_function, $foreigners, $tabindex_for_null, $tabindex_for_value, $table, $db, $row_id, $titles, $biggest_max_file_size, $default_char_editing, $text_dir, $repopulate, $column_mime, $where_clause)
{
    $column = $table_columns[$column_number];
    if (!isset($column['processed'])) {
        $column = PMA_analyzeTableColumnsArray($column, $comments_map, $timestamp_seen);
    }
    $as_is = false;
    if (!empty($repopulate) && !empty($current_row)) {
        $current_row[$column['Field']] = $repopulate[$column['Field_md5']];
        $as_is = true;
    }
    $extracted_columnspec = PMA_Util::extractColumnSpec($column['Type']);
    if (-1 === $column['len']) {
        $column['len'] = $GLOBALS['dbi']->fieldLen($current_result, $column_number);
        // length is unknown for geometry fields,
        // make enough space to edit very simple WKTs
        if (-1 === $column['len']) {
            $column['len'] = 30;
        }
    }
    //Call validation when the form submitted...
    $onChangeClause = $chg_evt_handler . "=\"return verificationsAfterFieldChange('" . PMA_escapeJsString($column['Field_md5']) . "', '" . PMA_escapeJsString($jsvkey) . "','" . $column['pma_type'] . "')\"";
    // Use an MD5 as an array index to avoid having special characters
    // in the name attribute (see bug #1746964 )
    $column_name_appendix = $vkey . '[' . $column['Field_md5'] . ']';
    if ($column['Type'] === 'datetime' && !isset($column['Default']) && !is_null($column['Default']) && $insert_mode) {
        $column['Default'] = date('Y-m-d H:i:s', time());
    }
    $html_output = PMA_getHtmlForFunctionOption($odd_row, $column, $column_name_appendix);
    if ($GLOBALS['cfg']['ShowFieldTypesInDataEditView']) {
        $html_output .= PMA_getHtmlForInsertEditColumnType($column);
    }
    //End if
    // Get a list of GIS data types.
    $gis_data_types = PMA_Util::getGISDatatypes();
    // Prepares the field value
    $real_null_value = false;
    $special_chars_encoded = '';
    if (!empty($current_row)) {
        // (we are editing)
        list($real_null_value, $special_chars_encoded, $special_chars, $data, $backup_field) = PMA_getSpecialCharsAndBackupFieldForExistingRow($current_row, $column, $extracted_columnspec, $real_null_value, $gis_data_types, $column_name_appendix, $as_is);
    } else {
        // (we are inserting)
        // display default values
        $tmp = $column;
        if (isset($repopulate[$column['Field_md5']])) {
            $tmp['Default'] = $repopulate[$column['Field_md5']];
        }
        list($real_null_value, $data, $special_chars, $backup_field, $special_chars_encoded) = PMA_getSpecialCharsAndBackupFieldForInsertingMode($tmp, $real_null_value);
        unset($tmp);
    }
    $idindex = $o_rows * $columns_cnt + $column_number + 1;
    $tabindex = $idindex;
    // Get a list of data types that are not yet supported.
    $no_support_types = PMA_Util::unsupportedDatatypes();
    // The function column
    // -------------------
    if ($GLOBALS['cfg']['ShowFunctionFields']) {
        $html_output .= PMA_getFunctionColumn($column, $is_upload, $column_name_appendix, $onChangeClause, $no_support_types, $tabindex_for_function, $tabindex, $idindex, $insert_mode);
    }
    // The null column
    // ---------------
    $foreignData = PMA_getForeignData($foreigners, $column['Field'], false, '', '');
    $html_output .= PMA_getNullColumn($column, $column_name_appendix, $real_null_value, $tabindex, $tabindex_for_null, $idindex, $vkey, $foreigners, $foreignData);
//.........这里部分代码省略.........
开发者ID:hewenhao2008,项目名称:phpmyadmin,代码行数:101,代码来源:insert_edit.lib.php

示例3: PMA_moveColumns

/**
 * Moves columns in the table's structure based on $_REQUEST
 *
 * @param string $db    database name
 * @param string $table table name
 *
 * @return void
 */
function PMA_moveColumns($db, $table)
{
    $GLOBALS['dbi']->selectDb($db);
    /*
     * load the definitions for all columns
     */
    $columns = $GLOBALS['dbi']->getColumnsFull($db, $table);
    $column_names = array_keys($columns);
    $changes = array();
    $we_dont_change_keys = array();
    // move columns from first to last
    for ($i = 0, $l = count($_REQUEST['move_columns']); $i < $l; $i++) {
        $column = $_REQUEST['move_columns'][$i];
        // is this column already correctly placed?
        if ($column_names[$i] == $column) {
            continue;
        }
        // it is not, let's move it to index $i
        $data = $columns[$column];
        $extracted_columnspec = PMA_Util::extractColumnSpec($data['Type']);
        if (isset($data['Extra']) && $data['Extra'] == 'on update CURRENT_TIMESTAMP') {
            $extracted_columnspec['attribute'] = $data['Extra'];
            unset($data['Extra']);
        }
        $current_timestamp = false;
        if (($data['Type'] == 'timestamp' || $data['Type'] == 'datetime') && $data['Default'] == 'CURRENT_TIMESTAMP') {
            $current_timestamp = true;
        }
        $default_type = $data['Null'] === 'YES' && $data['Default'] === null ? 'NULL' : ($current_timestamp ? 'CURRENT_TIMESTAMP' : ($data['Default'] === null ? 'NONE' : 'USER_DEFINED'));
        $changes[] = 'CHANGE ' . PMA_Table::generateAlter($column, $column, strtoupper($extracted_columnspec['type']), $extracted_columnspec['spec_in_brackets'], $extracted_columnspec['attribute'], isset($data['Collation']) ? $data['Collation'] : '', $data['Null'] === 'YES' ? 'NULL' : 'NOT NULL', $default_type, $current_timestamp ? '' : $data['Default'], isset($data['Extra']) && $data['Extra'] !== '' ? $data['Extra'] : false, isset($data['COLUMN_COMMENT']) && $data['COLUMN_COMMENT'] !== '' ? $data['COLUMN_COMMENT'] : false, $we_dont_change_keys, $i, $i === 0 ? '-first' : $column_names[$i - 1]);
        // update current column_names array, first delete old position
        for ($j = 0, $ll = count($column_names); $j < $ll; $j++) {
            if ($column_names[$j] == $column) {
                unset($column_names[$j]);
            }
        }
        // insert moved column
        array_splice($column_names, $i, 0, $column);
    }
    $response = PMA_Response::getInstance();
    if (empty($changes)) {
        // should never happen
        $response->isSuccess(false);
        exit;
    }
    $move_query = 'ALTER TABLE ' . PMA_Util::backquote($table) . ' ';
    $move_query .= implode(', ', $changes);
    // move columns
    $GLOBALS['dbi']->tryQuery($move_query);
    $tmp_error = $GLOBALS['dbi']->getError();
    if ($tmp_error) {
        $response->isSuccess(false);
        $response->addJSON('message', PMA_Message::error($tmp_error));
    } else {
        $message = PMA_Message::success(__('The columns have been moved successfully.'));
        $response->addJSON('message', $message);
        $response->addJSON('columns', $column_names);
    }
    exit;
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:68,代码来源:structure.lib.php

示例4: dataDictionaryDoc


//.........这里部分代码省略.........
          * Displays the comments of the table if MySQL >= 3.23
          */
         $break = false;
         if (!empty($show_comment)) {
             $this->diagram->Cell(0, 3, __('Table comments:') . ' ' . $show_comment, 0, 1);
             $break = true;
         }
         if (!empty($create_time)) {
             $this->diagram->Cell(0, 3, __('Creation:') . ' ' . $create_time, 0, 1);
             $break = true;
         }
         if (!empty($update_time)) {
             $this->diagram->Cell(0, 3, __('Last update:') . ' ' . $update_time, 0, 1);
             $break = true;
         }
         if (!empty($check_time)) {
             $this->diagram->Cell(0, 3, __('Last check:') . ' ' . $check_time, 0, 1);
             $break = true;
         }
         if ($break == true) {
             $this->diagram->Cell(0, 3, '', 0, 1);
             $this->diagram->Ln();
         }
         $this->diagram->SetFont($this->_ff, 'B');
         if (isset($this->orientation) && $this->orientation == 'L') {
             $this->diagram->Cell(25, 8, __('Column'), 1, 0, 'C');
             $this->diagram->Cell(20, 8, __('Type'), 1, 0, 'C');
             $this->diagram->Cell(20, 8, __('Attributes'), 1, 0, 'C');
             $this->diagram->Cell(10, 8, __('Null'), 1, 0, 'C');
             $this->diagram->Cell(20, 8, __('Default'), 1, 0, 'C');
             $this->diagram->Cell(25, 8, __('Extra'), 1, 0, 'C');
             $this->diagram->Cell(45, 8, __('Links to'), 1, 0, 'C');
             if ($this->paper == 'A4') {
                 $comments_width = 67;
             } else {
                 // this is really intended for 'letter'
                 /**
                  * @todo find optimal width for all formats
                  */
                 $comments_width = 50;
             }
             $this->diagram->Cell($comments_width, 8, __('Comments'), 1, 0, 'C');
             $this->diagram->Cell(45, 8, 'MIME', 1, 1, 'C');
             $this->diagram->SetWidths(array(25, 20, 20, 10, 20, 25, 45, $comments_width, 45));
         } else {
             $this->diagram->Cell(20, 8, __('Column'), 1, 0, 'C');
             $this->diagram->Cell(20, 8, __('Type'), 1, 0, 'C');
             $this->diagram->Cell(20, 8, __('Attributes'), 1, 0, 'C');
             $this->diagram->Cell(10, 8, __('Null'), 1, 0, 'C');
             $this->diagram->Cell(15, 8, __('Default'), 1, 0, 'C');
             $this->diagram->Cell(15, 8, __('Extra'), 1, 0, 'C');
             $this->diagram->Cell(30, 8, __('Links to'), 1, 0, 'C');
             $this->diagram->Cell(30, 8, __('Comments'), 1, 0, 'C');
             $this->diagram->Cell(30, 8, 'MIME', 1, 1, 'C');
             $this->diagram->SetWidths(array(20, 20, 20, 10, 15, 15, 30, 30, 30));
         }
         $this->diagram->SetFont($this->_ff, '');
         foreach ($columns as $row) {
             $extracted_columnspec = PMA_Util::extractColumnSpec($row['Type']);
             $type = $extracted_columnspec['print_type'];
             $attribute = $extracted_columnspec['attribute'];
             if (!isset($row['Default'])) {
                 if ($row['Null'] != '' && $row['Null'] != 'NO') {
                     $row['Default'] = 'NULL';
                 }
             }
             $field_name = $row['Field'];
             // $this->diagram->Ln();
             $this->diagram->PMA_links['RT'][$table][$field_name] = $this->diagram->AddLink();
             $this->diagram->Bookmark($field_name, 1, -1);
             $this->diagram->SetLink($this->diagram->PMA_links['doc'][$table][$field_name], -1);
             $foreigner = PMA_searchColumnInForeigners($res_rel, $field_name);
             $linksTo = '';
             if ($foreigner) {
                 $linksTo = '-> ';
                 if ($foreigner['foreign_db'] != $this->db) {
                     $linksTo .= $foreigner['foreign_db'] . '.';
                 }
                 $linksTo .= $foreigner['foreign_table'] . '.' . $foreigner['foreign_field'];
                 if (isset($foreigner['on_update'])) {
                     // not set for internal
                     $linksTo .= "\n" . 'ON UPDATE ' . $foreigner['on_update'];
                     $linksTo .= "\n" . 'ON DELETE ' . $foreigner['on_delete'];
                 }
             }
             $this->diagram_row = array($field_name, $type, $attribute, $row['Null'] == '' || $row['Null'] == 'NO' ? __('No') : __('Yes'), isset($row['Default']) ? $row['Default'] : '', $row['Extra'], $linksTo, isset($comments[$field_name]) ? $comments[$field_name] : '', isset($mime_map) && isset($mime_map[$field_name]) ? str_replace('_', '/', $mime_map[$field_name]['mimetype']) : '');
             $links = array();
             $links[0] = $this->diagram->PMA_links['RT'][$table][$field_name];
             if ($foreigner && isset($this->diagram->PMA_links['doc'][$foreigner['foreign_table']][$foreigner['foreign_field']])) {
                 $links[6] = $this->diagram->PMA_links['doc'][$foreigner['foreign_table']][$foreigner['foreign_field']];
             } else {
                 unset($links[6]);
             }
             $this->diagram->Row($this->diagram_row, $links);
         }
         // end foreach
         $this->diagram->SetFont($this->_ff, '', 14);
     }
     //end each
 }
开发者ID:TheBlackBloodyUnicorn,项目名称:pico_wanderblog,代码行数:101,代码来源:Pdf_Relation_Schema.class.php

示例5: exportStructure

 /**
  * Outputs table's structure
  *
  * @param string $db          database name
  * @param string $table       table name
  * @param string $crlf        the end of line sequence
  * @param string $error_url   the url to go back in case of error
  * @param string $export_mode 'create_table', 'triggers', 'create_view',
  *                            'stand_in'
  * @param string $export_type 'server', 'database', 'table'
  * @param bool   $do_relation whether to include relation comments
  * @param bool   $do_comments whether to include the pmadb-style column
  *                                comments as comments in the structure;
  *                                this is deprecated but the parameter is
  *                                left here because export.php calls
  *                                exportStructure() also for other
  *                                export types which use this parameter
  * @param bool   $do_mime     whether to include mime comments
  * @param bool   $dates       whether to include creation/update/check dates
  * @param array  $aliases     Aliases of db/table/columns
  *
  * @return bool Whether it succeeded
  */
 public function exportStructure($db, $table, $crlf, $error_url, $export_mode, $export_type, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $aliases = array())
 {
     $db_alias = $db;
     $table_alias = $table;
     $this->initAlias($aliases, $db_alias, $table_alias);
     global $cfgRelation;
     /* We do not export triggers */
     if ($export_mode == 'triggers') {
         return true;
     }
     /**
      * Get the unique keys in the table
      */
     $unique_keys = array();
     $keys = $GLOBALS['dbi']->getTableIndexes($db, $table);
     foreach ($keys as $key) {
         if ($key['Non_unique'] == 0) {
             $unique_keys[] = $key['Column_name'];
         }
     }
     /**
      * Gets fields properties
      */
     $GLOBALS['dbi']->selectDb($db);
     // Check if we can use Relations
     list($res_rel, $have_rel) = PMA_getRelationsAndStatus($do_relation && !empty($cfgRelation['relation']), $db, $table);
     /**
      * Displays the table structure
      */
     $buffer = $crlf . '%' . $crlf . '% ' . __('Structure:') . ' ' . $table_alias . $crlf . '%' . $crlf . ' \\begin{longtable}{';
     if (!PMA_exportOutputHandler($buffer)) {
         return false;
     }
     $alignment = '|l|c|c|c|';
     if ($do_relation && $have_rel) {
         $alignment .= 'l|';
     }
     if ($do_comments) {
         $alignment .= 'l|';
     }
     if ($do_mime && $cfgRelation['mimework']) {
         $alignment .= 'l|';
     }
     $buffer = $alignment . '} ' . $crlf;
     $header = ' \\hline ';
     $header .= '\\multicolumn{1}{|c|}{\\textbf{' . __('Column') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Type') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Null') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Default') . '}}';
     if ($do_relation && $have_rel) {
         $header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . __('Links to') . '}}';
     }
     if ($do_comments) {
         $header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . __('Comments') . '}}';
         $comments = PMA_getComments($db, $table);
     }
     if ($do_mime && $cfgRelation['mimework']) {
         $header .= ' & \\multicolumn{1}{|c|}{\\textbf{MIME}}';
         $mime_map = PMA_getMIME($db, $table, true);
     }
     // Table caption for first page and label
     if (isset($GLOBALS['latex_caption'])) {
         $buffer .= ' \\caption{' . PMA_Util::expandUserString($GLOBALS['latex_structure_caption'], array('texEscape', get_class($this), 'libraries/plugins/export/' . get_class($this) . ".class.php"), array('table' => $table_alias, 'database' => $db_alias)) . '} \\label{' . PMA_Util::expandUserString($GLOBALS['latex_structure_label'], null, array('table' => $table_alias, 'database' => $db_alias)) . '} \\\\' . $crlf;
     }
     $buffer .= $header . ' \\\\ \\hline \\hline' . $crlf . '\\endfirsthead' . $crlf;
     // Table caption on next pages
     if (isset($GLOBALS['latex_caption'])) {
         $buffer .= ' \\caption{' . PMA_Util::expandUserString($GLOBALS['latex_structure_continued_caption'], array('texEscape', get_class($this), 'libraries/plugins/export/' . get_class($this) . ".class.php"), array('table' => $table_alias, 'database' => $db_alias)) . '} \\\\ ' . $crlf;
     }
     $buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . $crlf;
     if (!PMA_exportOutputHandler($buffer)) {
         return false;
     }
     $fields = $GLOBALS['dbi']->getColumns($db, $table);
     foreach ($fields as $row) {
         $extracted_columnspec = PMA_Util::extractColumnSpec($row['Type']);
         $type = $extracted_columnspec['print_type'];
         if (empty($type)) {
             $type = ' ';
         }
//.........这里部分代码省略.........
开发者ID:TheBlackBloodyUnicorn,项目名称:pico_wanderblog,代码行数:101,代码来源:ExportLatex.class.php

示例6: testParsing

 /**
  * Test case for parsing SHOW COLUMNS output
  *
  * @dataProvider provider
  */
 public function testParsing($in, $out)
 {
     $this->assertEquals(
         $out, PMA_Util::extractColumnSpec($in)
     );
 }
开发者ID:roccivic,项目名称:phpmyadmin,代码行数:11,代码来源:PMA_extractColumnSpec_test.php

示例7: PMA_getHtmlForPrintViewColumns

/**
 * return html for Print View Columns
 *
 * @param bool   $tbl_is_view  whether table is a view
 * @param array  $columns      columns list
 * @param array  $analyzed_sql analyzed sql
 * @param bool   $have_rel     have relation?
 * @param array  $res_rel      relations array
 * @param string $db           database name
 * @param string $table        table name
 * @param array  $cfgRelation  config from PMA_getRelationsParam
 *
 * @return string
 */
function PMA_getHtmlForPrintViewColumns($tbl_is_view, $columns, $analyzed_sql, $have_rel, $res_rel, $db, $table, $cfgRelation)
{
    $html = '';
    $primary = PMA_Index::getPrimary($table, $db);
    foreach ($columns as $row) {
        $extracted_columnspec = PMA_Util::extractColumnSpec($row['Type']);
        $type = $extracted_columnspec['print_type'];
        if (!isset($row['Default'])) {
            if ($row['Null'] != '' && $row['Null'] != 'NO') {
                $row['Default'] = '<i>NULL</i>';
            }
        } else {
            $row['Default'] = htmlspecialchars($row['Default']);
        }
        $field_name = htmlspecialchars($row['Field']);
        if (!$tbl_is_view) {
            // here, we have a TIMESTAMP that SHOW FULL COLUMNS reports as having
            // the NULL attribute, but SHOW CREATE TABLE says the contrary.
            // Believe the latter.
            /**
             * @todo merge this logic with the one in tbl_structure.php
             * or move it in a function similar to $GLOBALS['dbi']->getColumnsFull()
             * but based on SHOW CREATE TABLE because information_schema
             * cannot be trusted in this case (MySQL bug)
             */
            $analyzed_for_field = $analyzed_sql[0]['create_table_fields'][$field_name];
            if (!empty($analyzed_for_field['type']) && $analyzed_for_field['type'] == 'TIMESTAMP' && $analyzed_for_field['timestamp_not_null']) {
                $row['Null'] = '';
            }
        }
        $html .= "\n";
        $html .= '<tr><td>';
        $html .= '    ' . $field_name . "\n";
        if ($primary && $primary->hasColumn($field_name)) {
            $html .= '    <em>(' . __('Primary') . ')</em>';
        }
        $html .= "\n";
        $html .= '</td>';
        $html .= '<td>' . htmlspecialchars($type) . '<bdo dir="ltr"></bdo></td>';
        $html .= '<td>';
        $html .= $row['Null'] == '' || $row['Null'] == 'NO' ? __('No') : __('Yes');
        $html .= '&nbsp;</td>';
        $html .= '<td>';
        if (isset($row['Default'])) {
            $html .= $row['Default'];
        }
        $html .= '&nbsp;</td>';
        if ($have_rel) {
            $html .= '    <td>';
            $foreigner = PMA_searchColumnInForeigners($res_rel, $field_name);
            if ($foreigner) {
                $html .= htmlspecialchars($foreigner['foreign_table'] . ' -> ' . $foreigner['foreign_field']);
            }
            $html .= '&nbsp;</td>' . "\n";
        }
        $html .= '    <td>';
        $comments = PMA_getComments($db, $table);
        if (isset($comments[$field_name])) {
            $html .= htmlspecialchars($comments[$field_name]);
        }
        $html .= '&nbsp;</td>' . "\n";
        if ($cfgRelation['mimework']) {
            $mime_map = PMA_getMIME($db, $table, true);
            $html .= '    <td>';
            if (isset($mime_map[$field_name])) {
                $html .= htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype']));
            }
            $html .= '&nbsp;</td>' . "\n";
        }
        $html .= '</tr>';
    }
    // end foreach
    return $html;
}
开发者ID:mercysmart,项目名称:naikelas,代码行数:88,代码来源:tbl_printview.lib.php

示例8: formatOneColumnDefinition

 /**
  * Formats the definition for one column
  *
  * @param array  $column      info about this column
  * @param array  $unique_keys unique keys for this table
  * @param string $col_alias   Column Alias
  *
  * @return string Formatted column definition
  */
 public function formatOneColumnDefinition($column, $unique_keys, $col_alias = '')
 {
     if (empty($col_alias)) {
         $col_alias = $column['Field'];
     }
     $extracted_columnspec = PMA_Util::extractColumnSpec($column['Type']);
     $type = $extracted_columnspec['print_type'];
     if (empty($type)) {
         $type = '&nbsp;';
     }
     if (!isset($column['Default'])) {
         if ($column['Null'] != 'NO') {
             $column['Default'] = 'NULL';
         }
     }
     $fmt_pre = '';
     $fmt_post = '';
     if (in_array($column['Field'], $unique_keys)) {
         $fmt_pre = '**' . $fmt_pre;
         $fmt_post = $fmt_post . '**';
     }
     if ($column['Key'] == 'PRI') {
         $fmt_pre = '//' . $fmt_pre;
         $fmt_post = $fmt_post . '//';
     }
     $definition = '|' . $fmt_pre . htmlspecialchars($col_alias) . $fmt_post;
     $definition .= '|' . htmlspecialchars($type);
     $definition .= '|' . ($column['Null'] == '' || $column['Null'] == 'NO' ? __('No') : __('Yes'));
     $definition .= '|' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '');
     return $definition;
 }
开发者ID:nobodypb,项目名称:phpmyadmin,代码行数:40,代码来源:ExportTexytext.class.php

示例9: formatOneColumnDefinition

 /**
  * Formats the definition for one column
  *
  * @param array $column info about this column
  *
  * @return string Formatted column definition
  */
 protected function formatOneColumnDefinition($column)
 {
     $field_name = $column['Field'];
     $definition = '<table:table-row>';
     $definition .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($field_name) . '</text:p>' . '</table:table-cell>';
     $extracted_columnspec = PMA_Util::extractColumnSpec($column['Type']);
     $type = htmlspecialchars($extracted_columnspec['print_type']);
     if (empty($type)) {
         $type = '&nbsp;';
     }
     $definition .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($type) . '</text:p>' . '</table:table-cell>';
     if (!isset($column['Default'])) {
         if ($column['Null'] != 'NO') {
             $column['Default'] = 'NULL';
         } else {
             $column['Default'] = '';
         }
     } else {
         $column['Default'] = $column['Default'];
     }
     $definition .= '<table:table-cell office:value-type="string">' . '<text:p>' . ($column['Null'] == '' || $column['Null'] == 'NO' ? __('No') : __('Yes')) . '</text:p>' . '</table:table-cell>';
     $definition .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($column['Default']) . '</text:p>' . '</table:table-cell>';
     return $definition;
 }
开发者ID:mindfeederllc,项目名称:openemr,代码行数:31,代码来源:ExportOdt.class.php

示例10: dataDictionaryDoc


//.........这里部分代码省略.........
         // Check if we can use Relations
         if (!empty($cfgRelation['relation'])) {
             // Find which tables are related with the current one and write it in
             // an array
             $res_rel = PMA_getForeigners($db, $table);
             if (count($res_rel) > 0) {
                 $have_rel = true;
             } else {
                 $have_rel = false;
             }
         } else {
             $have_rel = false;
         }
         // end if
         /**
          * Displays the comments of the table if MySQL >= 3.23
          */
         $break = false;
         if (!empty($show_comment)) {
             $pdf->Cell(0, 3, __('Table comments:') . ' ' . $show_comment, 0, 1);
             $break = true;
         }
         if (!empty($create_time)) {
             $pdf->Cell(0, 3, __('Creation:') . ' ' . $create_time, 0, 1);
             $break = true;
         }
         if (!empty($update_time)) {
             $pdf->Cell(0, 3, __('Last update:') . ' ' . $update_time, 0, 1);
             $break = true;
         }
         if (!empty($check_time)) {
             $pdf->Cell(0, 3, __('Last check:') . ' ' . $check_time, 0, 1);
             $break = true;
         }
         if ($break == true) {
             $pdf->Cell(0, 3, '', 0, 1);
             $pdf->Ln();
         }
         $pdf->SetFont($this->_ff, 'B');
         if (isset($orientation) && $orientation == 'L') {
             $pdf->Cell(25, 8, __('Column'), 1, 0, 'C');
             $pdf->Cell(20, 8, __('Type'), 1, 0, 'C');
             $pdf->Cell(20, 8, __('Attributes'), 1, 0, 'C');
             $pdf->Cell(10, 8, __('Null'), 1, 0, 'C');
             $pdf->Cell(20, 8, __('Default'), 1, 0, 'C');
             $pdf->Cell(25, 8, __('Extra'), 1, 0, 'C');
             $pdf->Cell(45, 8, __('Links to'), 1, 0, 'C');
             if ($paper == 'A4') {
                 $comments_width = 67;
             } else {
                 // this is really intended for 'letter'
                 /**
                  * @todo find optimal width for all formats
                  */
                 $comments_width = 50;
             }
             $pdf->Cell($comments_width, 8, __('Comments'), 1, 0, 'C');
             $pdf->Cell(45, 8, 'MIME', 1, 1, 'C');
             $pdf->SetWidths(array(25, 20, 20, 10, 20, 25, 45, $comments_width, 45));
         } else {
             $pdf->Cell(20, 8, __('Column'), 1, 0, 'C');
             $pdf->Cell(20, 8, __('Type'), 1, 0, 'C');
             $pdf->Cell(20, 8, __('Attributes'), 1, 0, 'C');
             $pdf->Cell(10, 8, __('Null'), 1, 0, 'C');
             $pdf->Cell(15, 8, __('Default'), 1, 0, 'C');
             $pdf->Cell(15, 8, __('Extra'), 1, 0, 'C');
             $pdf->Cell(30, 8, __('Links to'), 1, 0, 'C');
             $pdf->Cell(30, 8, __('Comments'), 1, 0, 'C');
             $pdf->Cell(30, 8, 'MIME', 1, 1, 'C');
             $pdf->SetWidths(array(20, 20, 20, 10, 15, 15, 30, 30, 30));
         }
         $pdf->SetFont($this->_ff, '');
         foreach ($columns as $row) {
             $extracted_columnspec = PMA_Util::extractColumnSpec($row['Type']);
             $type = $extracted_columnspec['print_type'];
             $attribute = $extracted_columnspec['attribute'];
             if (!isset($row['Default'])) {
                 if ($row['Null'] != '' && $row['Null'] != 'NO') {
                     $row['Default'] = 'NULL';
                 }
             }
             $field_name = $row['Field'];
             // $pdf->Ln();
             $pdf->PMA_links['RT'][$table][$field_name] = $pdf->AddLink();
             $pdf->Bookmark($field_name, 1, -1);
             $pdf->SetLink($pdf->PMA_links['doc'][$table][$field_name], -1);
             $pdf_row = array($field_name, $type, $attribute, $row['Null'] == '' || $row['Null'] == 'NO' ? __('No') : __('Yes'), isset($row['Default']) ? $row['Default'] : '', $row['Extra'], isset($res_rel[$field_name]) ? $res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'] : '', isset($comments[$field_name]) ? $comments[$field_name] : '', isset($mime_map) && isset($mime_map[$field_name]) ? str_replace('_', '/', $mime_map[$field_name]['mimetype']) : '');
             $links[0] = $pdf->PMA_links['RT'][$table][$field_name];
             if (isset($res_rel[$field_name]['foreign_table']) && isset($res_rel[$field_name]['foreign_field']) && isset($pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']])) {
                 $links[6] = $pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']];
             } else {
                 unset($links[6]);
             }
             $pdf->Row($pdf_row, $links);
         }
         // end foreach
         $pdf->SetFont($this->_ff, '', 14);
     }
     //end each
 }
开发者ID:AtomPy,项目名称:AtomPySite,代码行数:101,代码来源:Pdf_Relation_Schema.class.php

示例11: PMA_getInsertQuery

/**
 * build the insert query for central columns list given PMA storage
 * db, central_columns table, column name and corresponding definition to be added
 *
 * @param string $column             column to add into central list
 * @param array  $def                list of attributes of the column being added
 * @param string $db                 PMA configuration storage database name
 * @param string $central_list_table central columns configuration storage table name
 *
 * @return string query string to insert the given column
 * with definition into central list
 */
function PMA_getInsertQuery($column, $def, $db, $central_list_table)
{
    $type = "";
    $length = 0;
    $attribute = "";
    if (isset($def['Type'])) {
        $extracted_columnspec = PMA_Util::extractColumnSpec($def['Type']);
        $attribute = trim($extracted_columnspec['attribute']);
        $type = $extracted_columnspec['type'];
        $length = $extracted_columnspec['spec_in_brackets'];
    }
    if (isset($def['Attribute'])) {
        $attribute = $def['Attribute'];
    }
    $collation = isset($def['Collation']) ? $def['Collation'] : "";
    $isNull = $def['Null'] == "NO" ? 0 : 1;
    $extra = isset($def['Extra']) ? $def['Extra'] : "";
    $default = isset($def['Default']) ? $def['Default'] : "";
    $insQuery = 'INSERT INTO ' . PMA_Util::backquote($central_list_table) . ' ' . 'VALUES ( \'' . PMA_Util::sqlAddSlashes($db) . '\' ,' . '\'' . PMA_Util::sqlAddSlashes($column) . '\',\'' . PMA_Util::sqlAddSlashes($type) . '\',' . '\'' . PMA_Util::sqlAddSlashes($length) . '\',\'' . PMA_Util::sqlAddSlashes($collation) . '\',' . '\'' . PMA_Util::sqlAddSlashes($isNull) . '\',' . '\'' . implode(',', array($extra, $attribute)) . '\',\'' . PMA_Util::sqlAddSlashes($default) . '\');';
    return $insQuery;
}
开发者ID:szepeviktor,项目名称:phpmyadmin,代码行数:33,代码来源:central_columns.lib.php

示例12: PMA_getHtmlForInsertEditFormColumn

/**
 * Function to get html for each insert/edit column
 *
 * @param array  $table_columns         table columns
 * @param int    $i                     row counter
 * @param array  $column                column
 * @param array  $comments_map          comments map
 * @param bool   $timestamp_seen        whether timestamp seen
 * @param array  $current_result        current result
 * @param string $chg_evt_handler       javascript change event handler
 * @param string $jsvkey                javascript validation key
 * @param string $vkey                  validation key
 * @param bool   $insert_mode           whether insert mode
 * @param array  $current_row           current row
 * @param bool   $odd_row               whether odd row
 * @param int    &$o_rows               row offset
 * @param int    &$tabindex             tab index
 * @param int    $columns_cnt           columns count
 * @param bool   $is_upload             whether upload
 * @param int    $tabindex_for_function tab index offset for function
 * @param array  $foreigners            foreigners
 * @param int    $tabindex_for_null     tab index offset for null
 * @param int    $tabindex_for_value    tab index offset for value
 * @param string $table                 table
 * @param string $db                    database
 * @param int    $row_id                row id
 * @param array  $titles                titles
 * @param int    $biggest_max_file_size biggest max file size
 * @param string $default_char_editing  default char editing mode which is stroe
 *                                      in the config.inc.php script
 * @param string $text_dir              text direction
 *
 * @return string
 */
function PMA_getHtmlForInsertEditFormColumn($table_columns, $i, $column, $comments_map, $timestamp_seen, $current_result, $chg_evt_handler, $jsvkey, $vkey, $insert_mode, $current_row, $odd_row, &$o_rows, &$tabindex, $columns_cnt, $is_upload, $tabindex_for_function, $foreigners, $tabindex_for_null, $tabindex_for_value, $table, $db, $row_id, $titles, $biggest_max_file_size, $default_char_editing, $text_dir)
{
    if (!isset($table_columns[$i]['processed'])) {
        $column = $table_columns[$i];
        $column = PMA_analyzeTableColumnsArray($column, $comments_map, $timestamp_seen);
    }
    $extracted_columnspec = PMA_Util::extractColumnSpec($column['Type']);
    if (-1 === $column['len']) {
        $column['len'] = $GLOBALS['dbi']->fieldLen($current_result, $i);
        // length is unknown for geometry fields,
        // make enough space to edit very simple WKTs
        if (-1 === $column['len']) {
            $column['len'] = 30;
        }
    }
    //Call validation when the form submitted...
    $unnullify_trigger = $chg_evt_handler . "=\"return verificationsAfterFieldChange('" . PMA_escapeJsString($column['Field_md5']) . "', '" . PMA_escapeJsString($jsvkey) . "','" . $column['pma_type'] . "')\"";
    // Use an MD5 as an array index to avoid having special characters
    // in the name atttibute (see bug #1746964 )
    $column_name_appendix = $vkey . '[' . $column['Field_md5'] . ']';
    if ($column['Type'] == 'datetime' && !isset($column['Default']) && !is_null($column['Default']) && ($insert_mode || !isset($current_row[$column['Field']]))) {
        // INSERT case or
        // UPDATE case with an NULL value
        $current_row[$column['Field']] = date('Y-m-d H:i:s', time());
    }
    $html_output = PMA_getHtmlForFunctionOption($odd_row, $column, $column_name_appendix);
    if ($GLOBALS['cfg']['ShowFieldTypesInDataEditView']) {
        $html_output .= PMA_getHtmlForInsertEditColumnType($column);
    }
    //End if
    // Get a list of GIS data types.
    $gis_data_types = PMA_Util::getGISDatatypes();
    // Prepares the field value
    $real_null_value = false;
    $special_chars_encoded = '';
    if (isset($current_row)) {
        // (we are editing)
        list($real_null_value, $special_chars_encoded, $special_chars, $data, $backup_field) = PMA_getSpecialCharsAndBackupFieldForExistingRow($current_row, $column, $extracted_columnspec, $real_null_value, $gis_data_types, $column_name_appendix);
    } else {
        // (we are inserting)
        // display default values
        list($real_null_value, $data, $special_chars, $backup_field, $special_chars_encoded) = PMA_getSpecialCharsAndBackupFieldForInsertingMode($column, $real_null_value);
    }
    $idindex = $o_rows * $columns_cnt + $i + 1;
    $tabindex = $idindex;
    // Get a list of data types that are not yet supported.
    $no_support_types = PMA_Util::unsupportedDatatypes();
    // The function column
    // -------------------
    if ($GLOBALS['cfg']['ShowFunctionFields']) {
        $html_output .= PMA_getFunctionColumn($column, $is_upload, $column_name_appendix, $unnullify_trigger, $no_support_types, $tabindex_for_function, $tabindex, $idindex, $insert_mode);
    }
    // The null column
    // ---------------
    $foreignData = PMA_getForeignData($foreigners, $column['Field'], false, '', '');
    $html_output .= PMA_getNullColumn($column, $column_name_appendix, $real_null_value, $tabindex, $tabindex_for_null, $idindex, $vkey, $foreigners, $foreignData);
    // The value column (depends on type)
    // ----------------
    // See bug #1667887 for the reason why we don't use the maxlength
    // HTML attribute
    $html_output .= '        <td>' . "\n";
    // Will be used by js/tbl_change.js to set the default value
    // for the "Continue insertion" feature
    $html_output .= '<span class="default_value hide">' . $special_chars . '</span>';
    $html_output .= PMA_getValueColumn($column, $backup_field, $column_name_appendix, $unnullify_trigger, $tabindex, $tabindex_for_value, $idindex, $data, $special_chars, $foreignData, $odd_row, array($table, $db), $row_id, $titles, $text_dir, $special_chars_encoded, $vkey, $is_upload, $biggest_max_file_size, $default_char_editing, $no_support_types, $gis_data_types, $extracted_columnspec);
    $html_output .= '</td>' . '</tr>';
//.........这里部分代码省略.........
开发者ID:roccivic,项目名称:phpmyadmin,代码行数:101,代码来源:insert_edit.lib.php

示例13: PMA_analyzeTableColumnsArray

    // (as zero cannot be used, advance the counter plus one)
    $m_rows = $o_rows + 1;
    //store the default value for CharEditing
    $default_char_editing  = $cfg['CharEditing'];

    $odd_row = true;
    for ($i = 0; $i < $columns_cnt; $i++) {
        if (! isset($table_fields[$i]['processed'])) {
            $column = $table_fields[$i];
            $column = PMA_analyzeTableColumnsArray(
                $column, $comments_map, $timestamp_seen
            );
        }

        $extracted_columnspec
            = PMA_Util::extractColumnSpec($column['Type']);

        if (-1 === $column['len']) {
            $column['len'] = PMA_DBI_field_len($current_result, $i);
            // length is unknown for geometry fields,
            // make enough space to edit very simple WKTs
            if (-1 === $column['len']) {
                $column['len'] = 30;
            }
        }
        //Call validation when the form submited...
        $unnullify_trigger = $chg_evt_handler
            . "=\"return verificationsAfterFieldChange('"
            . PMA_escapeJsString($column['Field_md5']) . "', '"
            . PMA_escapeJsString($jsvkey) . "','".$column['pma_type'] . "')\"";
开发者ID:nhodges,项目名称:phpmyadmin,代码行数:30,代码来源:tbl_change.php

示例14: testPMAGetHtmlForPrintViewColumns

 /**
  * Tests for PMA_getHtmlForPrintViewColumns() method.
  *
  * @return void
  * @test
  */
 public function testPMAGetHtmlForPrintViewColumns()
 {
     $columns = array(array("Type" => "Type1", "Default" => "Default1", "Null" => "Null1", "Field" => "Field1"));
     $analyzed_sql = array(array('create_table_fields' => array("Field1" => array("type" => "TIMESTAMP", "timestamp_not_null" => true))));
     $pk_array = array("Field1" => "pk_array");
     $have_rel = false;
     $res_rel = array();
     $db = "pma_db";
     $table = "pma_table";
     $cfgRelation = array('mimework' => true);
     $html = PMA_getHtmlForPrintViewColumns($columns, $analyzed_sql, $pk_array, $have_rel, $res_rel, $db, $table, $cfgRelation);
     //validation 1 : $row
     $row = $columns[0];
     $this->assertContains(htmlspecialchars($row['Default']), $html);
     $this->assertContains(htmlspecialchars($row['Field']), $html);
     //validation 2 : $pk_array
     $field_name = htmlspecialchars($row['Field']);
     $comments = PMA_getComments($db, $table);
     $this->assertContains($field_name, $html);
     //validation 3 : $extracted_columnspec
     $extracted_columnspec = PMA_Util::extractColumnSpec($row['Type']);
     $type = $extracted_columnspec['print_type'];
     $attribute = $extracted_columnspec['attribute'];
     $this->assertContains($type, $html);
 }
开发者ID:kfjihailong,项目名称:phpMyAdmin,代码行数:31,代码来源:PMA_tbl_printview_test.php

示例15: getTableDef


//.........这里部分代码省略.........
     if ($do_comments) {
         $comments = PMA_getComments($db, $table);
     }
     if ($do_mime && $cfgRelation['mimework']) {
         $mime_map = PMA_getMIME($db, $table, true);
     }
     $columns = $GLOBALS['dbi']->getColumns($db, $table);
     /**
      * Get the unique keys in the table.
      * Presently, this information is not used. We will have to find out
      * way of displaying it.
      */
     $unique_keys = array();
     $keys = $GLOBALS['dbi']->getTableIndexes($db, $table);
     foreach ($keys as $key) {
         if ($key['Non_unique'] == 0) {
             $unique_keys[] = $key['Column_name'];
         }
     }
     // some things to set and 'remember'
     $l = $this->lMargin;
     $startheight = $h = $this->dataY;
     $startpage = $currpage = $this->page;
     // calculate the whole width
     $fullwidth = 0;
     foreach ($this->tablewidths as $width) {
         $fullwidth += $width;
     }
     $row = 0;
     $tmpheight = array();
     $maxpage = $this->page;
     // fun begin
     foreach ($columns as $column) {
         $extracted_columnspec = PMA_Util::extractColumnSpec($column['Type']);
         $type = $extracted_columnspec['print_type'];
         if (empty($type)) {
             $type = ' ';
         }
         if (!isset($column['Default'])) {
             if ($column['Null'] != 'NO') {
                 $column['Default'] = 'NULL';
             }
         }
         $data[] = $column['Field'];
         $data[] = $type;
         $data[] = $column['Null'] == '' || $column['Null'] == 'NO' ? 'No' : 'Yes';
         $data[] = isset($column['Default']) ? $column['Default'] : '';
         $field_name = $column['Field'];
         if ($do_relation && $have_rel) {
             $data[] = isset($res_rel[$field_name]) ? $res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')' : '';
         }
         if ($do_comments) {
             $data[] = isset($comments[$field_name]) ? $comments[$field_name] : '';
         }
         if ($do_mime) {
             $data[] = isset($mime_map[$field_name]) ? $mime_map[$field_name]['mimetype'] : '';
         }
         $this->page = $currpage;
         // write the horizontal borders
         $this->Line($l, $h, $fullwidth + $l, $h);
         // write the content and remember the height of the highest col
         foreach ($data as $col => $txt) {
             $this->page = $currpage;
             $this->SetXY($l, $h);
             if ($this->tablewidths[$col] > 0) {
                 $this->MultiCell($this->tablewidths[$col], $this->FontSizePt, $txt, 0, $this->colAlign[$col]);
开发者ID:saisai,项目名称:phpmyadmin,代码行数:67,代码来源:PMA_ExportPdf.class.php


注:本文中的PMA_Util::extractColumnSpec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。