PMA\libraries\Util::buildActionTitles PHP Method

buildActionTitles() public static method

Build titles and icons for action links
public static buildActionTitles ( ) : array
return array the action titles
    public static function buildActionTitles()
    {
        $titles = array();
        $titles['Browse'] = self::getIcon('b_browse.png', __('Browse'));
        $titles['NoBrowse'] = self::getIcon('bd_browse.png', __('Browse'));
        $titles['Search'] = self::getIcon('b_select.png', __('Search'));
        $titles['NoSearch'] = self::getIcon('bd_select.png', __('Search'));
        $titles['Insert'] = self::getIcon('b_insrow.png', __('Insert'));
        $titles['NoInsert'] = self::getIcon('bd_insrow.png', __('Insert'));
        $titles['Structure'] = self::getIcon('b_props.png', __('Structure'));
        $titles['Drop'] = self::getIcon('b_drop.png', __('Drop'));
        $titles['NoDrop'] = self::getIcon('bd_drop.png', __('Drop'));
        $titles['Empty'] = self::getIcon('b_empty.png', __('Empty'));
        $titles['NoEmpty'] = self::getIcon('bd_empty.png', __('Empty'));
        $titles['Edit'] = self::getIcon('b_edit.png', __('Edit'));
        $titles['NoEdit'] = self::getIcon('bd_edit.png', __('Edit'));
        $titles['Export'] = self::getIcon('b_export.png', __('Export'));
        $titles['NoExport'] = self::getIcon('bd_export.png', __('Export'));
        $titles['Execute'] = self::getIcon('b_nextpage.png', __('Execute'));
        $titles['NoExecute'] = self::getIcon('bd_nextpage.png', __('Execute'));
        // For Favorite/NoFavorite, we need icon only.
        $titles['Favorite'] = self::getIcon('b_favorite.png', '');
        $titles['NoFavorite'] = self::getIcon('b_no_favorite.png', '');
        return $titles;
    }

Usage Example

 /**
  * Displays the list of tables
  *
  * @return void
  */
 protected function displayTableList()
 {
     // table form
     $this->response->addHTML(Template::get('database/structure/table_header')->render(array('db' => $this->db, 'db_is_system_schema' => $this->_db_is_system_schema, 'replication' => $GLOBALS['replication_info']['slave']['status'])));
     $i = $sum_entries = 0;
     $overhead_check = '';
     $create_time_all = '';
     $update_time_all = '';
     $check_time_all = '';
     $num_columns = $GLOBALS['cfg']['PropertiesNumColumns'] > 1 ? ceil($this->_num_tables / $GLOBALS['cfg']['PropertiesNumColumns']) + 1 : 0;
     $row_count = 0;
     $sum_size = (double) 0;
     $overhead_size = (double) 0;
     $hidden_fields = array();
     $odd_row = true;
     $overall_approx_rows = false;
     foreach ($this->_tables as $keyname => $current_table) {
         // Get valid statistics whatever is the table type
         $drop_query = '';
         $drop_message = '';
         $overhead = '';
         $table_is_view = false;
         $table_encoded = urlencode($current_table['TABLE_NAME']);
         // Sets parameters for links
         $tbl_url_query = $this->_url_query . '&table=' . $table_encoded;
         // do not list the previous table's size info for a view
         list($current_table, $formatted_size, $unit, $formatted_overhead, $overhead_unit, $overhead_size, $table_is_view, $sum_size) = $this->getStuffForEngineTypeTable($current_table, $sum_size, $overhead_size);
         $curTable = $this->dbi->getTable($this->db, $current_table['TABLE_NAME']);
         if (!$curTable->isMerge()) {
             $sum_entries += $current_table['TABLE_ROWS'];
         }
         if (isset($current_table['Collation'])) {
             $collation = '<dfn title="' . PMA_getCollationDescr($current_table['Collation']) . '">' . $current_table['Collation'] . '</dfn>';
         } else {
             $collation = '---';
         }
         if ($this->_is_show_stats) {
             if ($formatted_overhead != '') {
                 $overhead = '<a href="tbl_structure.php' . $tbl_url_query . '#showusage">' . '<span>' . $formatted_overhead . '</span>&nbsp;' . '<span class="unit">' . $overhead_unit . '</span>' . '</a>' . "\n";
                 $overhead_check .= "markAllRows('row_tbl_" . ($i + 1) . "');";
             } else {
                 $overhead = '-';
             }
         }
         // end if
         $showtable = $this->dbi->getTable($this->db, $current_table['TABLE_NAME'])->getStatusInfo(null, true);
         if ($GLOBALS['cfg']['ShowDbStructureCreation']) {
             $create_time = isset($showtable['Create_time']) ? $showtable['Create_time'] : '';
             if ($create_time && (!$create_time_all || $create_time < $create_time_all)) {
                 $create_time_all = $create_time;
             }
         }
         if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) {
             // $showtable might already be set from ShowDbStructureCreation,
             // see above
             $update_time = isset($showtable['Update_time']) ? $showtable['Update_time'] : '';
             if ($update_time && (!$update_time_all || $update_time < $update_time_all)) {
                 $update_time_all = $update_time;
             }
         }
         if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) {
             // $showtable might already be set from ShowDbStructureCreation,
             // see above
             $check_time = isset($showtable['Check_time']) ? $showtable['Check_time'] : '';
             if ($check_time && (!$check_time_all || $check_time < $check_time_all)) {
                 $check_time_all = $check_time;
             }
         }
         $truename = htmlspecialchars(!empty($tooltip_truename) && isset($tooltip_truename[$current_table['TABLE_NAME']]) ? $tooltip_truename[$current_table['TABLE_NAME']] : $current_table['TABLE_NAME']);
         $truename = str_replace(' ', '&nbsp;', $truename);
         $i++;
         $row_count++;
         if ($table_is_view) {
             $hidden_fields[] = '<input type="hidden" name="views[]" value="' . htmlspecialchars($current_table['TABLE_NAME']) . '" />';
         }
         /*
          * Always activate links for Browse, Search and Empty, even if
          * the icons are greyed, because
          * 1. for views, we don't know the number of rows at this point
          * 2. for tables, another source could have populated them since the
          *    page was generated
          *
          * I could have used the PHP ternary conditional operator but I find
          * the code easier to read without this operator.
          */
         $may_have_rows = $current_table['TABLE_ROWS'] > 0 || $table_is_view;
         $titles = Util::buildActionTitles();
         $browse_table = Template::get('database/structure/browse_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Browse'] : $titles['NoBrowse']));
         $search_table = Template::get('database/structure/search_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Search'] : $titles['NoSearch']));
         $browse_table_label = Template::get('database/structure/browse_table_label')->render(array('tbl_url_query' => $tbl_url_query, 'title' => htmlspecialchars($current_table['TABLE_COMMENT']), 'truename' => $truename));
         $empty_table = '';
         if (!$this->_db_is_system_schema) {
             $empty_table = '&nbsp;';
             if (!$table_is_view) {
                 $empty_table = Template::get('database/structure/empty_table')->render(array('tbl_url_query' => $tbl_url_query, 'sql_query' => urlencode('TRUNCATE ' . Util::backquote($current_table['TABLE_NAME'])), 'message_to_show' => urlencode(sprintf(__('Table %s has been emptied.'), htmlspecialchars($current_table['TABLE_NAME']))), 'title' => $may_have_rows ? $titles['Empty'] : $titles['NoEmpty']));
             }
             $drop_query = sprintf('DROP %s %s', $table_is_view || $current_table['ENGINE'] == null ? 'VIEW' : 'TABLE', Util::backquote($current_table['TABLE_NAME']));
             $drop_message = sprintf($table_is_view || $current_table['ENGINE'] == null ? __('View %s has been dropped.') : __('Table %s has been dropped.'), str_replace(' ', '&nbsp;', htmlspecialchars($current_table['TABLE_NAME'])));
         }
         if ($num_columns > 0 && $this->_num_tables > $num_columns && $row_count % $num_columns == 0) {
             $row_count = 1;
             $odd_row = true;
             $this->response->addHTML('</tr></tbody></table></form>');
             $this->response->addHTML(Template::get('database/structure/table_header')->render(array('db' => $this->db, 'db_is_system_schema' => $this->_db_is_system_schema, 'replication' => $GLOBALS['replication_info']['slave']['status'])));
         }
         list($approx_rows, $show_superscript) = $this->isRowCountApproximated($current_table, $table_is_view);
         list($do, $ignored) = $this->getReplicationStatus($truename);
         $this->response->addHTML(Template::get('database/structure/structure_table_row')->render(array('db' => $this->db, 'curr' => $i, 'odd_row' => $odd_row, 'table_is_view' => $table_is_view, 'current_table' => $current_table, 'browse_table_label' => $browse_table_label, 'tracking_icon' => $this->getTrackingIcon($truename), 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'browse_table' => $browse_table, 'tbl_url_query' => $tbl_url_query, 'search_table' => $search_table, 'db_is_system_schema' => $this->_db_is_system_schema, 'titles' => $titles, 'empty_table' => $empty_table, 'drop_query' => $drop_query, 'drop_message' => $drop_message, 'collation' => $collation, 'formatted_size' => $formatted_size, 'unit' => $unit, 'overhead' => $overhead, 'create_time' => isset($create_time) ? $create_time : '', 'update_time' => isset($update_time) ? $update_time : '', 'check_time' => isset($check_time) ? $check_time : '', 'is_show_stats' => $this->_is_show_stats, 'ignored' => $ignored, 'do' => $do, 'colspan_for_structure' => $GLOBALS['colspan_for_structure'], 'approx_rows' => $approx_rows, 'show_superscript' => $show_superscript, 'already_favorite' => $this->checkFavoriteTable($current_table['TABLE_NAME']))));
         $odd_row = !$odd_row;
         $overall_approx_rows = $overall_approx_rows || $approx_rows;
     }
     // end foreach
     $this->response->addHTML('</tbody>');
     $db_collation = PMA_getDbCollation($this->db);
     // Show Summary
     $this->response->addHTML(Template::get('database/structure/body_for_table_summary')->render(array('num_tables' => $this->_num_tables, 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'db_is_system_schema' => $this->_db_is_system_schema, 'sum_entries' => $sum_entries, 'db_collation' => $db_collation, 'is_show_stats' => $this->_is_show_stats, 'sum_size' => $sum_size, 'overhead_size' => $overhead_size, 'create_time_all' => $create_time_all, 'update_time_all' => $update_time_all, 'check_time_all' => $check_time_all, 'approx_rows' => $overall_approx_rows)));
     $this->response->addHTML('</table>');
     //check all
     $this->response->addHTML(Template::get('database/structure/check_all_tables')->render(array('pmaThemeImage' => $GLOBALS['pmaThemeImage'], 'text_dir' => $GLOBALS['text_dir'], 'overhead_check' => $overhead_check, 'db_is_system_schema' => $this->_db_is_system_schema, 'hidden_fields' => $hidden_fields)));
     $this->response->addHTML('</form>');
     //end of form
 }
All Usage Examples Of PMA\libraries\Util::buildActionTitles
Util