getIcon() публичный статический Метод

This function takes into account the ActionLinksMode configuration setting and wraps the image tag in a span tag.
public static getIcon ( string $icon, string $alternate = '', boolean $force_text = false, boolean $menu_icon = false, string $control_param = 'ActionLinksMode' ) : string
$icon string name of icon file
$alternate string alternate text
$force_text boolean whether to force alternate text to be displayed
$menu_icon boolean whether this icon is for the menu bar or not
$control_param string which directive controls the display
Результат string an html snippet
Пример #1
0
 /**
  * Provides a column's type, collation, operators list, and criteria value
  * to display in table search form
  *
  * @param integer $search_index Row number in table search form
  * @param integer $column_index Column index in ColumnNames array
  *
  * @return array Array containing column's properties
  */
 public function getColumnProperties($search_index, $column_index)
 {
     $selected_operator = isset($_POST['criteriaColumnOperators']) ? $_POST['criteriaColumnOperators'][$search_index] : '';
     $entered_value = isset($_POST['criteriaValues']) ? $_POST['criteriaValues'] : '';
     $titles = array('Browse' => Util::getIcon('b_browse.png', __('Browse foreign values')));
     //Gets column's type and collation
     $type = $this->_columnTypes[$column_index];
     $collation = $this->_columnCollations[$column_index];
     //Gets column's comparison operators depending on column type
     $func = Template::get('table/search/column_comparison_operators')->render(array('search_index' => $search_index, 'columnTypes' => $this->_columnTypes, 'column_index' => $column_index, 'columnNullFlags' => $this->_columnNullFlags, 'selected_operator' => $selected_operator));
     //Gets link to browse foreign data(if any) and criteria inputbox
     $foreignData = PMA_getForeignData($this->_foreigners, $this->_columnNames[$column_index], false, '', '');
     $value = Template::get('table/search/input_box')->render(array('str' => '', 'column_type' => (string) $type, 'column_id' => 'fieldID_', 'in_zoom_search_edit' => false, '_foreigners' => $this->_foreigners, 'column_name' => $this->_columnNames[$column_index], 'foreignData' => $foreignData, 'table' => $this->table, 'column_index' => $search_index, 'foreignMaxLimit' => $GLOBALS['cfg']['ForeignKeyMaxLimit'], 'criteriaValues' => $entered_value, 'db' => $this->db, 'titles' => $titles, 'in_fbs' => true));
     return array('type' => $type, 'collation' => $collation, 'func' => $func, 'value' => $value);
 }
Пример #2
0
 /**
  * Get operations that are available on results.
  *
  * @param array   $displayParts         the parts to display
  * @param array   $analyzed_sql_results analyzed sql results
  * @param boolean $only_view            Whether to show only view
  *
  * @return string $results_operations_html  html content
  *
  * @access  private
  *
  * @see     getTable()
  */
 private function _getResultsOperations($displayParts, $analyzed_sql_results, $only_view = false)
 {
     global $printview;
     $results_operations_html = '';
     $fields_meta = $this->__get('fields_meta');
     // To safe use in foreach
     $header_shown = false;
     $header = '<fieldset class="print_ignore" ><legend>' . __('Query results operations') . '</legend>';
     $_url_params = array('db' => $this->__get('db'), 'table' => $this->__get('table'), 'printview' => '1', 'sql_query' => $this->__get('sql_query'));
     $url_query = PMA_URL_getCommon($_url_params);
     if (!$header_shown) {
         $results_operations_html .= $header;
         $header_shown = true;
     }
     // if empty result set was produced we need to
     // show only view and not other options
     if ($only_view) {
         $results_operations_html .= $this->_getLinkForCreateView($analyzed_sql_results, $url_query);
         if ($header_shown) {
             $results_operations_html .= '</fieldset><br />';
         }
         return $results_operations_html;
     }
     // Displays "printable view" link if required
     if ($displayParts['pview_lnk'] == '1') {
         $results_operations_html .= $this->_getPrintviewLinks();
     }
     // end displays "printable view"
     // Export link
     // (the url_query has extra parameters that won't be used to export)
     // (the single_table parameter is used in PMA_getExportDisplay()
     //  to hide the SQL and the structure export dialogs)
     // If the parser found a PROCEDURE clause
     // (most probably PROCEDURE ANALYSE()) it makes no sense to
     // display the Export link).
     if ($analyzed_sql_results['querytype'] == self::QUERY_TYPE_SELECT && !isset($printview) && empty($analyzed_sql_results['procedure'])) {
         if (count($analyzed_sql_results['select_tables']) == 1) {
             $_url_params['single_table'] = 'true';
         }
         if (!$header_shown) {
             $results_operations_html .= $header;
             $header_shown = true;
         }
         $_url_params['unlim_num_rows'] = $this->__get('unlim_num_rows');
         /**
          * At this point we don't know the table name; this can happen
          * for example with a query like
          * SELECT bike_code FROM (SELECT bike_code FROM bikes) tmp
          * As a workaround we set in the table parameter the name of the
          * first table of this database, so that tbl_export.php and
          * the script it calls do not fail
          */
         if (empty($_url_params['table']) && !empty($_url_params['db'])) {
             $_url_params['table'] = $GLOBALS['dbi']->fetchValue("SHOW TABLES");
             /* No result (probably no database selected) */
             if ($_url_params['table'] === false) {
                 unset($_url_params['table']);
             }
         }
         $results_operations_html .= Util::linkOrButton('tbl_export.php' . PMA_URL_getCommon($_url_params), Util::getIcon('b_tblexport.png', __('Export'), true), '', true, true, '') . "\n";
         // prepare chart
         $results_operations_html .= Util::linkOrButton('tbl_chart.php' . PMA_URL_getCommon($_url_params), Util::getIcon('b_chart.png', __('Display chart'), true), '', true, true, '') . "\n";
         // prepare GIS chart
         $geometry_found = false;
         // If at least one geometry field is found
         foreach ($fields_meta as $meta) {
             if ($meta->type == self::GEOMETRY_FIELD) {
                 $geometry_found = true;
                 break;
             }
         }
         if ($geometry_found) {
             $results_operations_html .= Util::linkOrButton('tbl_gis_visualization.php' . PMA_URL_getCommon($_url_params), Util::getIcon('b_globe.gif', __('Visualize GIS data'), true), '', true, true, '') . "\n";
         }
     }
     // CREATE VIEW
     /**
      *
      * @todo detect privileges to create a view
      *       (but see 2006-01-19 note in display_create_table.lib.php,
      *        I think we cannot detect db-specific privileges reliably)
      * Note: we don't display a Create view link if we found a PROCEDURE clause
      */
     if (!$header_shown) {
         $results_operations_html .= $header;
         $header_shown = true;
     }
     $results_operations_html .= $this->_getLinkForCreateView($analyzed_sql_results, $url_query);
     if ($header_shown) {
         $results_operations_html .= '</fieldset><br />';
     }
     return $results_operations_html;
 }
/**
 * build html for a row in central columns table
 *
 * @param array   $row     array contains complete information of
 * a particular row of central list table
 * @param boolean $odd_row set true if the row is at odd number position
 * @param int     $row_num position the row in the table
 * @param string  $db      current database
 *
 * @return string html of a particular row in the central columns table.
 */
function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
{
    $tableHtml = '<tr data-rownum="' . $row_num . '" id="f_' . $row_num . '" ' . 'class="' . ($odd_row ? 'odd' : 'even') . '">' . PMA_URL_getHiddenInputs($db) . '<input type="hidden" name="edit_save" value="save">' . '<td class="nowrap">' . '<input type="checkbox" class="checkall" name="selected_fld[]" ' . 'value="' . htmlspecialchars($row['col_name']) . '" ' . 'id="checkbox_row_' . $row_num . '"/>' . '</td>' . '<td id="edit_' . $row_num . '" class="edit center">' . '<a href="#">' . Util::getIcon('b_edit.png', __('Edit')) . '</a></td>' . '<td class="del_row" data-rownum = "' . $row_num . '">' . '<a hrf="#">' . Util::getIcon('b_drop.png', __('Delete')) . '</a>' . '<input type="submit" data-rownum = "' . $row_num . '"' . ' class="edit_cancel_form" value="Cancel"></td>' . '<td id="save_' . $row_num . '" style="display:none">' . '<input type="submit" data-rownum = "' . $row_num . '"' . ' class="edit_save_form" value="Save"></td>';
    $tableHtml .= '<td name="col_name" class="nowrap">' . '<span>' . htmlspecialchars($row['col_name']) . '</span>' . '<input name="orig_col_name" type="hidden" ' . 'value="' . htmlspecialchars($row['col_name']) . '">' . PMA\libraries\Template::get('columns_definitions/column_name')->render(array('columnNumber' => $row_num, 'ci' => 0, 'ci_offset' => 0, 'columnMeta' => array('Field' => $row['col_name']), 'cfgRelation' => array('centralcolumnswork' => false))) . '</td>';
    $tableHtml .= '<td name = "col_type" class="nowrap"><span>' . htmlspecialchars($row['col_type']) . '</span>' . PMA\libraries\Template::get('columns_definitions/column_type')->render(array('columnNumber' => $row_num, 'ci' => 1, 'ci_offset' => 0, 'type_upper' => mb_strtoupper($row['col_type']), 'columnMeta' => array())) . '</td>';
    $tableHtml .= '<td class="nowrap" name="col_length">' . '<span>' . ($row['col_length'] ? htmlspecialchars($row['col_length']) : "") . '</span>' . PMA\libraries\Template::get('columns_definitions/column_length')->render(array('columnNumber' => $row_num, 'ci' => 2, 'ci_offset' => 0, 'length_values_input_size' => 8, 'length_to_display' => $row['col_length'])) . '</td>';
    $meta = array();
    if (!isset($row['col_default']) || $row['col_default'] == '') {
        $meta['DefaultType'] = 'NONE';
    } else {
        if ($row['col_default'] == 'CURRENT_TIMESTAMP' || $row['col_default'] == 'NULL') {
            $meta['DefaultType'] = $row['col_default'];
        } else {
            $meta['DefaultType'] = 'USER_DEFINED';
            $meta['DefaultValue'] = $row['col_default'];
        }
    }
    $tableHtml .= '<td class="nowrap" name="col_default"><span>' . (isset($row['col_default']) ? htmlspecialchars($row['col_default']) : 'None') . '</span>' . PMA\libraries\Template::get('columns_definitions/column_default')->render(array('columnNumber' => $row_num, 'ci' => 3, 'ci_offset' => 0, 'type_upper' => mb_strtoupper($row['col_type']), 'columnMeta' => $meta)) . '</td>';
    $tableHtml .= '<td name="collation" class="nowrap">' . '<span>' . htmlspecialchars($row['col_collation']) . '</span>' . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $row_num . ']', 'field_' . $row_num . '_4', $row['col_collation'], false) . '</td>';
    $tableHtml .= '<td class="nowrap" name="col_attribute">' . '<span>' . ($row['col_attribute'] ? htmlspecialchars($row['col_attribute']) : "") . '</span>' . PMA\libraries\Template::get('columns_definitions/column_attribute')->render(array('columnNumber' => $row_num, 'ci' => 5, 'ci_offset' => 0, 'extracted_columnspec' => array(), 'columnMeta' => $row['col_attribute'], 'submit_attribute' => false)) . '</td>';
    $tableHtml .= '<td class="nowrap" name="col_isNull">' . '<span>' . ($row['col_isNull'] ? __('Yes') : __('No')) . '</span>' . PMA\libraries\Template::get('columns_definitions/column_null')->render(array('columnNumber' => $row_num, 'ci' => 6, 'ci_offset' => 0, 'columnMeta' => array('Null' => $row['col_isNull']))) . '</td>';
    $tableHtml .= '<td class="nowrap" name="col_extra"><span>' . htmlspecialchars($row['col_extra']) . '</span>' . PMA\libraries\Template::get('columns_definitions/column_extra')->render(array('columnNumber' => $row_num, 'ci' => 7, 'ci_offset' => 0, 'columnMeta' => array('Extra' => $row['col_extra']))) . '</td>';
    $tableHtml .= '</tr>';
    return $tableHtml;
}
/**
 * Get HTML snippet for display user overview page
 *
 * @param string $pmaThemeImage a image source link
 * @param string $text_dir      text directory
 *
 * @return string $html_output
 */
function PMA_getHtmlForUserOverview($pmaThemeImage, $text_dir)
{
    $html_output = '<h2>' . "\n" . Util::getIcon('b_usrlist.png') . __('User accounts overview') . "\n" . '</h2>' . "\n";
    $password_column = 'Password';
    if (Util::getServerType() == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50706) {
        $password_column = 'authentication_string';
    }
    // $sql_query is for the initial-filtered,
    // $sql_query_all is for counting the total no. of users
    $sql_query = $sql_query_all = 'SELECT *,' . " IF(`" . $password_column . "` = _latin1 '', 'N', 'Y') AS 'Password'" . ' FROM `mysql`.`user`';
    $sql_query .= isset($_REQUEST['initial']) ? PMA_rangeOfUsers($_REQUEST['initial']) : '';
    $sql_query .= ' ORDER BY `User` ASC, `Host` ASC;';
    $sql_query_all .= ' ;';
    $res = $GLOBALS['dbi']->tryQuery($sql_query, null, PMA\libraries\DatabaseInterface::QUERY_STORE);
    $res_all = $GLOBALS['dbi']->tryQuery($sql_query_all, null, PMA\libraries\DatabaseInterface::QUERY_STORE);
    if (!$res) {
        // the query failed! This may have two reasons:
        // - the user does not have enough privileges
        // - the privilege tables use a structure of an earlier version.
        // so let's try a more simple query
        $GLOBALS['dbi']->freeResult($res);
        $GLOBALS['dbi']->freeResult($res_all);
        $sql_query = 'SELECT * FROM `mysql`.`user`';
        $res = $GLOBALS['dbi']->tryQuery($sql_query, null, PMA\libraries\DatabaseInterface::QUERY_STORE);
        if (!$res) {
            $html_output .= PMA_getHtmlForViewUsersError();
            $html_output .= PMA_getAddUserHtmlFieldset();
        } else {
            // This message is hardcoded because I will replace it by
            // a automatic repair feature soon.
            $raw = 'Your privilege table structure seems to be older than' . ' this MySQL version!<br />' . 'Please run the <code>mysql_upgrade</code> command' . '(<code>mysql_fix_privilege_tables</code> on older systems)' . ' that should be included in your MySQL server distribution' . ' to solve this problem!';
            $html_output .= Message::rawError($raw)->getDisplay();
        }
        $GLOBALS['dbi']->freeResult($res);
    } else {
        $db_rights = PMA_getDbRightsForUserOverview();
        // for all initials, even non A-Z
        $array_initials = array();
        foreach ($db_rights as $right) {
            foreach ($right as $account) {
                if (empty($account['User']) && $account['Host'] == 'localhost') {
                    $html_output .= Message::notice(__('A user account allowing any user from localhost to ' . 'connect is present. This will prevent other users ' . 'from connecting if the host part of their account ' . 'allows a connection from any (%) host.') . Util::showMySQLDocu('problems-connecting'))->getDisplay();
                    break 2;
                }
            }
        }
        /**
         * Displays the initials
         * Also not necessary if there is less than 20 privileges
         */
        if ($GLOBALS['dbi']->numRows($res_all) > 20) {
            $html_output .= PMA_getHtmlForInitials($array_initials);
        }
        /**
         * Display the user overview
         * (if less than 50 users, display them immediately)
         */
        if (isset($_REQUEST['initial']) || isset($_REQUEST['showall']) || $GLOBALS['dbi']->numRows($res) < 50) {
            $html_output .= PMA_getUsersOverview($res, $db_rights, $pmaThemeImage, $text_dir);
        } else {
            $html_output .= PMA_getAddUserHtmlFieldset();
        }
        // end if (display overview)
        if (!$GLOBALS['is_ajax_request'] || !empty($_REQUEST['ajax_page_request'])) {
            if (isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']) {
                $flushnote = new Message(__('Note: phpMyAdmin gets the users\' privileges directly ' . 'from MySQL\'s privilege tables. The content of these ' . 'tables may differ from the privileges the server uses, ' . 'if they have been changed manually. In this case, ' . 'you should %sreload the privileges%s before you continue.'), Message::NOTICE);
                $flushLink = '<a href="server_privileges.php' . PMA_URL_getCommon(array('flush_privileges' => 1)) . '" id="reload_privileges_anchor">';
                $flushnote->addParam($flushLink, false);
                $flushnote->addParam('</a>', false);
            } else {
                $flushnote = new Message(__('Note: phpMyAdmin gets the users\' privileges directly ' . 'from MySQL\'s privilege tables. The content of these ' . 'tables may differ from the privileges the server uses, ' . 'if they have been changed manually. In this case, ' . 'the privileges have to be reloaded but currently, you ' . 'don\'t have the RELOAD privilege.') . Util::showMySQLDocu('privileges-provided', false, 'priv_reload'), Message::NOTICE);
            }
            $html_output .= $flushnote->getDisplay();
        }
    }
    return $html_output;
}
 /**
  * Displays the table structure ('show table' works correct since 3.23.03)
  *
  * @param array       $cfgRelation               current relation parameters
  * @param array       $columns_with_unique_index Columns with unique index
  * @param mixed       $url_params                Contains an associative
  *                                               array with url params
  * @param Index|false $primary_index             primary index or false if
  *                                               no one exists
  * @param array       $fields                    Fields
  * @param array       $columns_with_index        Columns with index
  * @param array       $create_table_fields       Fields of the table.
  *
  * @return string
  */
 protected function displayStructure($cfgRelation, $columns_with_unique_index, $url_params, $primary_index, $fields, $columns_with_index, $create_table_fields)
 {
     /* TABLE INFORMATION */
     $HideStructureActions = '';
     if ($GLOBALS['cfg']['HideStructureActions'] === true) {
         $HideStructureActions .= ' HideStructureActions';
     }
     // prepare comments
     $comments_map = array();
     $mime_map = array();
     if ($GLOBALS['cfg']['ShowPropertyComments']) {
         include_once 'libraries/transformations.lib.php';
         $comments_map = PMA_getComments($this->db, $this->table);
         if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
             $mime_map = PMA_getMIME($this->db, $this->table, true);
         }
     }
     include_once 'libraries/central_columns.lib.php';
     $central_list = PMA_getCentralColumnsFromTable($this->db, $this->table);
     $columns_list = array();
     $titles = array('Change' => Util::getIcon('b_edit.png', __('Change')), 'Drop' => Util::getIcon('b_drop.png', __('Drop')), 'NoDrop' => Util::getIcon('b_drop.png', __('Drop')), 'Primary' => Util::getIcon('b_primary.png', __('Primary')), 'Index' => Util::getIcon('b_index.png', __('Index')), 'Unique' => Util::getIcon('b_unique.png', __('Unique')), 'Spatial' => Util::getIcon('b_spatial.png', __('Spatial')), 'IdxFulltext' => Util::getIcon('b_ftext.png', __('Fulltext')), 'NoPrimary' => Util::getIcon('bd_primary.png', __('Primary')), 'NoIndex' => Util::getIcon('bd_index.png', __('Index')), 'NoUnique' => Util::getIcon('bd_unique.png', __('Unique')), 'NoSpatial' => Util::getIcon('bd_spatial.png', __('Spatial')), 'NoIdxFulltext' => Util::getIcon('bd_ftext.png', __('Fulltext')), 'DistinctValues' => Util::getIcon('b_browse.png', __('Distinct values')));
     /**
      * Work on the table
      */
     if ($this->_tbl_is_view && !$this->_db_is_system_schema) {
         $item = $this->dbi->fetchSingleRow(sprintf("SELECT `VIEW_DEFINITION`, `CHECK_OPTION`, `DEFINER`,\n                      `SECURITY_TYPE`\n                    FROM `INFORMATION_SCHEMA`.`VIEWS`\n                    WHERE TABLE_SCHEMA='%s'\n                    AND TABLE_NAME='%s';", Util::sqlAddSlashes($this->db), Util::sqlAddSlashes($this->table)));
         $createView = $this->dbi->getTable($this->db, $this->table)->showCreate();
         // get algorithm from $createView of the form
         // CREATE ALGORITHM=<ALGORITHM> DE...
         $parts = explode(" ", substr($createView, 17));
         $item['ALGORITHM'] = $parts[0];
         $view = array('operation' => 'alter', 'definer' => $item['DEFINER'], 'sql_security' => $item['SECURITY_TYPE'], 'name' => $this->table, 'as' => $item['VIEW_DEFINITION'], 'with' => $item['CHECK_OPTION'], 'algorithm' => $item['ALGORITHM']);
         $edit_view_url = 'view_create.php' . PMA_URL_getCommon($url_params) . '&amp;' . implode('&amp;', array_map(function ($key, $val) {
             return 'view[' . urlencode($key) . ']=' . urlencode($val);
         }, array_keys($view), $view));
     }
     /**
      * Displays Space usage and row statistics
      */
     // BEGIN - Calc Table Space
     // Get valid statistics whatever is the table type
     if ($GLOBALS['cfg']['ShowStats']) {
         //get table stats in HTML format
         $tablestats = $this->getTableStats();
         //returning the response in JSON format to be used by Ajax
         $this->response->addJSON('tableStat', $tablestats);
     }
     // END - Calc Table Space
     return Template::get('table/structure/display_structure')->render(array('HideStructureActions' => $HideStructureActions, 'db' => $this->db, 'table' => $this->table, 'db_is_system_schema' => $this->_db_is_system_schema, 'tbl_is_view' => $this->_tbl_is_view, 'mime_map' => $mime_map, 'url_query' => $this->_url_query, 'titles' => $titles, 'tbl_storage_engine' => $this->_tbl_storage_engine, 'primary' => $primary_index, 'columns_with_unique_index' => $columns_with_unique_index, 'edit_view_url' => isset($edit_view_url) ? $edit_view_url : null, 'columns_list' => $columns_list, 'tablestats' => isset($tablestats) ? $tablestats : null, 'fields' => $fields, 'columns_with_index' => $columns_with_index, 'central_list' => $central_list, 'create_table_fields' => $create_table_fields, 'comments_map' => $comments_map));
 }
Пример #6
0
$biggest_max_file_size = 0;
$url_params['db'] = $db;
$url_params['table'] = $table;
$url_params = PMA_urlParamsInEditMode($url_params, $where_clause_array, $where_clause);
$has_blob_field = false;
foreach ($table_columns as $column) {
    if (PMA_isColumn($column, array('blob', 'tinyblob', 'mediumblob', 'longblob'))) {
        $has_blob_field = true;
        break;
    }
}
//Insert/Edit form
//If table has blob fields we have to disable ajax.
$html_output .= PMA_getHtmlForInsertEditFormHeader($has_blob_field, $is_upload);
$html_output .= URL::getHiddenInputs($_form_params);
$titles['Browse'] = Util::getIcon('b_browse.png', __('Browse foreign values'));
// user can toggle the display of Function column and column types
// (currently does not work for multi-edits)
if (!$cfg['ShowFunctionFields'] || !$cfg['ShowFieldTypesInDataEditView']) {
    $html_output .= __('Show');
}
if (!$cfg['ShowFunctionFields']) {
    $html_output .= PMA_showTypeOrFunction('function', $url_params, false);
}
if (!$cfg['ShowFieldTypesInDataEditView']) {
    $html_output .= PMA_showTypeOrFunction('type', $url_params, false);
}
$GLOBALS['plugin_scripts'] = array();
foreach ($rows as $row_id => $current_row) {
    if (empty($current_row)) {
        $current_row = array();
Пример #7
0
/**
 * build the html contents of various html elements in step 1.2
 *
 * @param string $db    current database
 * @param string $table current table
 *
 * @return string HTML contents for step 1.2
 */
function PMA_getHtmlContentsFor1NFStep2($db, $table)
{
    $step = 2;
    $stepTxt = __('Have a primary key');
    $primary = PMA\libraries\Index::getPrimary($table, $db);
    $hasPrimaryKey = "0";
    $legendText = __('Step 1.') . $step . " " . $stepTxt;
    $extra = '';
    if ($primary) {
        $headText = __("Primary key already exists.");
        $subText = __("Taking you to next step…");
        $hasPrimaryKey = "1";
    } else {
        $headText = __("There is no primary key; please add one.<br/>" . "Hint: A primary key is a column " . "(or combination of columns) that uniquely identify all rows.");
        $subText = '<a href="#" id="createPrimaryKey">' . Util::getIcon('b_index_add.png', __('Add a primary key on existing column(s)')) . '</a>';
        $extra = __("If it's not possible to make existing " . "column combinations as primary key") . "<br/>" . '<a href="#" id="addNewPrimary">' . __('+ Add a new primary key column') . '</a>';
    }
    $res = array('legendText' => $legendText, 'headText' => $headText, 'subText' => $subText, 'hasPrimaryKey' => $hasPrimaryKey, 'extra' => $extra);
    return $res;
}
 /**
  * Builds the HTML for one database to display in the list
  * of databases from server_databases.php
  *
  * @param array  $current           current database
  * @param string $url_query         url query
  * @param array  $column_order      column order
  * @param array  $replication_types replication types
  * @param array  $replication_info  replication info
  * @param string $tr_class          HTMl class for the row
  *
  * @return array $column_order, $out
  */
 function _buildHtmlForDb($current, $url_query, $column_order, $replication_types, $replication_info, $tr_class = '')
 {
     $master_replication = $slave_replication = '';
     foreach ($replication_types as $type) {
         if ($replication_info[$type]['status']) {
             $out = '';
             $key = array_search($current["SCHEMA_NAME"], $replication_info[$type]['Ignore_DB']);
             if (mb_strlen($key) > 0) {
                 $out = Util::getIcon('s_cancel.png', __('Not replicated'));
             } else {
                 $key = array_search($current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']);
                 if (mb_strlen($key) > 0 || isset($replication_info[$type]['Do_DB'][0]) && $replication_info[$type]['Do_DB'][0] == "" && count($replication_info[$type]['Do_DB']) == 1) {
                     // if ($key != null) did not work for index "0"
                     $out = Util::getIcon('s_success.png', __('Replicated'));
                 }
             }
             if ($type == 'master') {
                 $master_replication = $out;
             } elseif ($type == 'slave') {
                 $slave_replication = $out;
             }
         }
     }
     return Template::get('server/databases/table_row')->render(array('current' => $current, 'tr_class' => $tr_class, 'url_query' => $url_query, 'column_order' => $column_order, 'master_replication_status' => $GLOBALS['replication_info']['master']['status'], 'master_replication' => $master_replication, 'slave_replication_status' => $GLOBALS['replication_info']['slave']['status'], 'slave_replication' => $slave_replication));
 }
Пример #9
0
 /**
  * Returns HTML for the dialog to show hidden navigation items.
  *
  * @param string $dbName    database name
  * @param string $itemType  type of the items to include
  * @param string $tableName table name
  *
  * @return string HTML for the dialog to show hidden navigation items
  */
 public function getItemUnhideDialog($dbName, $itemType = null, $tableName = null)
 {
     $html = '<form method="post" action="navigation.php" class="ajax">';
     $html .= '<fieldset>';
     $html .= URL::getHiddenInputs($dbName, $tableName);
     $navTable = Util::backquote($GLOBALS['cfgRelation']['db']) . "." . Util::backquote($GLOBALS['cfgRelation']['navigationhiding']);
     $sqlQuery = "SELECT `item_name`, `item_type` FROM " . $navTable . " WHERE `username`='" . Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "'" . " AND `db_name`='" . Util::sqlAddSlashes($dbName) . "'" . " AND `table_name`='" . (!empty($tableName) ? Util::sqlAddSlashes($tableName) : '') . "'";
     $result = PMA_queryAsControlUser($sqlQuery, false);
     $hidden = array();
     if ($result) {
         while ($row = $GLOBALS['dbi']->fetchArray($result)) {
             $type = $row['item_type'];
             if (!isset($hidden[$type])) {
                 $hidden[$type] = array();
             }
             $hidden[$type][] = $row['item_name'];
         }
     }
     $GLOBALS['dbi']->freeResult($result);
     $typeMap = array('group' => __('Groups:'), 'event' => __('Events:'), 'function' => __('Functions:'), 'procedure' => __('Procedures:'), 'table' => __('Tables:'), 'view' => __('Views:'));
     if (empty($tableName)) {
         $first = true;
         foreach ($typeMap as $t => $lable) {
             if ((empty($itemType) || $itemType == $t) && isset($hidden[$t])) {
                 $html .= (!$first ? '<br/>' : '') . '<strong>' . $lable . '</strong>';
                 $html .= '<table width="100%"><tbody>';
                 $odd = true;
                 foreach ($hidden[$t] as $hiddenItem) {
                     $html .= '<tr class="' . ($odd ? 'odd' : 'even') . '">';
                     $html .= '<td>' . htmlspecialchars($hiddenItem) . '</td>';
                     $html .= '<td style="width:80px"><a href="navigation.php' . URL::getCommon() . '&unhideNavItem=true' . '&itemType=' . urlencode($t) . '&itemName=' . urlencode($hiddenItem) . '&dbName=' . urlencode($dbName) . '"' . ' class="unhideNavItem ajax">' . Util::getIcon('show.png', __('Show')) . '</a></td>';
                     $odd = !$odd;
                 }
                 $html .= '</tbody></table>';
                 $first = false;
             }
         }
     }
     $html .= '</fieldset>';
     $html .= '</form>';
     return $html;
 }
Пример #10
0
 /**
  * Show index data
  *
  * @param string  $table      The table name
  * @param string  $schema     The schema name
  * @param boolean $print_mode Whether the output is for the print mode
  *
  * @return string HTML for showing index
  *
  * @access  public
  */
 public static function getHtmlForIndexes($table, $schema, $print_mode = false)
 {
     $indexes = Index::getFromTable($table, $schema);
     $no_indexes_class = count($indexes) > 0 ? ' hide' : '';
     $no_indexes = "<div class='no_indexes_defined{$no_indexes_class}'>";
     $no_indexes .= Message::notice(__('No index defined!'))->getDisplay();
     $no_indexes .= '</div>';
     if (!$print_mode) {
         $r = '<fieldset class="index_info">';
         $r .= '<legend id="index_header">' . __('Indexes');
         $r .= Util::showMySQLDocu('optimizing-database-structure');
         $r .= '</legend>';
         $r .= $no_indexes;
         if (count($indexes) < 1) {
             $r .= '</fieldset>';
             return $r;
         }
         $r .= Index::findDuplicates($table, $schema);
     } else {
         $r = '<h3>' . __('Indexes') . '</h3>';
         $r .= $no_indexes;
         if (count($indexes) < 1) {
             return $r;
         }
     }
     $r .= '<table id="table_index">';
     $r .= '<thead>';
     $r .= '<tr>';
     if (!$print_mode) {
         $r .= '<th colspan="2" class="print_ignore">' . __('Action') . '</th>';
     }
     $r .= '<th>' . __('Keyname') . '</th>';
     $r .= '<th>' . __('Type') . '</th>';
     $r .= '<th>' . __('Unique') . '</th>';
     $r .= '<th>' . __('Packed') . '</th>';
     $r .= '<th>' . __('Column') . '</th>';
     $r .= '<th>' . __('Cardinality') . '</th>';
     $r .= '<th>' . __('Collation') . '</th>';
     $r .= '<th>' . __('Null') . '</th>';
     $r .= '<th>' . __('Comment') . '</th>';
     $r .= '</tr>';
     $r .= '</thead>';
     $r .= '<tbody>';
     foreach ($indexes as $index) {
         $row_span = ' rowspan="' . $index->getColumnCount() . '" ';
         $r .= '<tr class="noclick" >';
         if (!$print_mode) {
             $this_params = $GLOBALS['url_params'];
             $this_params['index'] = $index->getName();
             $r .= '<td class="edit_index print_ignore';
             $r .= ' ajax';
             $r .= '" ' . $row_span . '>' . '    <a class="';
             $r .= 'ajax';
             $r .= '" href="tbl_indexes.php' . URL::getCommon($this_params) . '">' . Util::getIcon('b_edit.png', __('Edit')) . '</a>' . '</td>' . "\n";
             $this_params = $GLOBALS['url_params'];
             if ($index->getName() == 'PRIMARY') {
                 $this_params['sql_query'] = 'ALTER TABLE ' . Util::backquote($table) . ' DROP PRIMARY KEY;';
                 $this_params['message_to_show'] = __('The primary key has been dropped.');
                 $js_msg = Sanitize::jsFormat('ALTER TABLE ' . $table . ' DROP PRIMARY KEY');
             } else {
                 $this_params['sql_query'] = 'ALTER TABLE ' . Util::backquote($table) . ' DROP INDEX ' . Util::backquote($index->getName()) . ';';
                 $this_params['message_to_show'] = sprintf(__('Index %s has been dropped.'), htmlspecialchars($index->getName()));
                 $js_msg = Sanitize::jsFormat('ALTER TABLE ' . $table . ' DROP INDEX ' . $index->getName() . ';');
             }
             $r .= '<td ' . $row_span . ' class="print_ignore">';
             $r .= '<input type="hidden" class="drop_primary_key_index_msg"' . ' value="' . $js_msg . '" />';
             $r .= '    <a class="drop_primary_key_index_anchor';
             $r .= ' ajax';
             $r .= '" href="sql.php' . URL::getCommon($this_params) . '" >' . Util::getIcon('b_drop.png', __('Drop')) . '</a>' . '</td>' . "\n";
         }
         if (!$print_mode) {
             $r .= '<th ' . $row_span . '>' . htmlspecialchars($index->getName()) . '</th>';
         } else {
             $r .= '<td ' . $row_span . '>' . htmlspecialchars($index->getName()) . '</td>';
         }
         $r .= '<td ' . $row_span . '>';
         $type = $index->getType();
         if (!empty($type)) {
             $r .= htmlspecialchars($type);
         } else {
             $r .= htmlspecialchars($index->getChoice());
         }
         $r .= '</td>';
         $r .= '<td ' . $row_span . '>' . $index->isUnique(true) . '</td>';
         $r .= '<td ' . $row_span . '>' . $index->isPacked() . '</td>';
         foreach ($index->getColumns() as $column) {
             if ($column->getSeqInIndex() > 1) {
                 $r .= '<tr class="noclick" >';
             }
             $r .= '<td>' . htmlspecialchars($column->getName());
             if ($column->getSubPart()) {
                 $r .= ' (' . htmlspecialchars($column->getSubPart()) . ')';
             }
             $r .= '</td>';
             $r .= '<td>' . htmlspecialchars($column->getCardinality()) . '</td>';
             $r .= '<td>' . htmlspecialchars($column->getCollation()) . '</td>';
             $r .= '<td>' . htmlspecialchars($column->getNull(true)) . '</td>';
             if ($column->getSeqInIndex() == 1) {
                 $r .= '<td ' . $row_span . '>' . htmlspecialchars($index->getComments()) . '</td>';
             }
             $r .= '</tr>';
         }
         // end foreach $index['Sequences']
     }
     // end while
     $r .= '</tbody>';
     $r .= '</table>';
     if (!$print_mode) {
         $r .= '</fieldset>';
     }
     return $r;
 }
Пример #11
0
 /**
  * Return HTML ul.
  *
  * @return string
  */
 public function getHtmlList()
 {
     $html = '';
     if (count($this->_tables)) {
         if ($this->_tableType == 'recent') {
             foreach ($this->_tables as $table) {
                 $html .= '<li class="warp_link">';
                 $recent_params = array('db' => $table['db'], 'table' => $table['table']);
                 $recent_url = 'tbl_recent_favorite.php' . URL::getCommon($recent_params);
                 $html .= '<a href="' . $recent_url . '">`' . htmlspecialchars($table['db']) . '`.`' . htmlspecialchars($table['table']) . '`</a>';
                 $html .= '</li>';
             }
         } else {
             foreach ($this->_tables as $table) {
                 $html .= '<li class="warp_link">';
                 $html .= '<a class="ajax favorite_table_anchor" ';
                 $fav_params = array('db' => $table['db'], 'ajax_request' => true, 'favorite_table' => $table['table'], 'remove_favorite' => true);
                 $fav_rm_url = 'db_structure.php' . URL::getCommon($fav_params);
                 $html .= 'href="' . $fav_rm_url . '" title="' . __("Remove from Favorites") . '" data-favtargetn="' . md5($table['db'] . "." . $table['table']) . '" >' . Util::getIcon('b_favorite.png') . '</a>';
                 $fav_params = array('db' => $table['db'], 'table' => $table['table']);
                 $table_url = 'tbl_recent_favorite.php' . URL::getCommon($fav_params);
                 $html .= '<a href="' . $table_url . '">`' . htmlspecialchars($table['db']) . '`.`' . htmlspecialchars($table['table']) . '`</a>';
                 $html .= '</li>';
             }
         }
     } else {
         $html .= '<li class="warp_link">' . ($this->_tableType == 'recent' ? __('There are no recent tables.') : __('There are no favorite tables.')) . '</li>';
     }
     return $html;
 }