コード例 #1
0
/**
 * Returns the html for Table footer buttons
 *
 * @param bool $is_allowUserDropDb Allow user drop database
 * @param bool $is_superuser       User status
 *
 * @return string
 */
function PMA_getHtmlForTableFooterButtons($is_allowUserDropDb, $is_superuser)
{
    if (!$is_superuser && !$is_allowUserDropDb) {
        return '';
    }
    $html = PMA\libraries\Util::getWithSelected($GLOBALS['pmaThemeImage'], $GLOBALS['text_dir'], "dbStatsForm");
    $html .= PMA\libraries\Util::getButtonOrImage('', 'mult_submit' . ' ajax', 'drop_selected_dbs', __('Drop'), 'b_deltbl.png');
    return $html;
}
コード例 #2
0
/**
 * Display tracked tables
 *
 * @param string $db                current database
 * @param object $all_tables_result result set of tracked tables
 * @param string $url_query         url query string
 * @param string $pmaThemeImage     path to theme's image folder
 * @param string $text_dir          text direction
 * @param array  $cfgRelation       configuration storage info
 *
 * @return void
 */
function PMA_displayTrackedTables($db, $all_tables_result, $url_query, $pmaThemeImage, $text_dir, $cfgRelation)
{
    ?>
    <div id="tracked_tables">
    <h3><?php 
    echo __('Tracked tables');
    ?>
</h3>

    <form method="post" action="db_tracking.php" name="trackedForm"
        id="trackedForm" class="ajax">
    <?php 
    echo PMA_URL_getHiddenInputs($db);
    ?>
    <table id="versions" class="data">
    <thead>
    <tr>
        <th></th>
        <th><?php 
    echo __('Table');
    ?>
</th>
        <th><?php 
    echo __('Last version');
    ?>
</th>
        <th><?php 
    echo __('Created');
    ?>
</th>
        <th><?php 
    echo __('Updated');
    ?>
</th>
        <th><?php 
    echo __('Status');
    ?>
</th>
        <th><?php 
    echo __('Action');
    ?>
</th>
        <th><?php 
    echo __('Show');
    ?>
</th>
    </tr>
    </thead>
    <tbody>
    <?php 
    // Print out information about versions
    $delete = PMA\libraries\Util::getIcon('b_drop.png', __('Delete tracking'));
    $versions = PMA\libraries\Util::getIcon('b_versions.png', __('Versions'));
    $report = PMA\libraries\Util::getIcon('b_report.png', __('Tracking report'));
    $structure = PMA\libraries\Util::getIcon('b_props.png', __('Structure snapshot'));
    $style = 'odd';
    while ($one_result = $GLOBALS['dbi']->fetchArray($all_tables_result)) {
        list($table_name, $version_number) = $one_result;
        $table_query = ' SELECT * FROM ' . PMA\libraries\Util::backquote($cfgRelation['db']) . '.' . PMA\libraries\Util::backquote($cfgRelation['tracking']) . ' WHERE `db_name` = \'' . PMA\libraries\Util::sqlAddSlashes($_REQUEST['db']) . '\' AND `table_name`  = \'' . PMA\libraries\Util::sqlAddSlashes($table_name) . '\' AND `version` = \'' . $version_number . '\'';
        $table_result = PMA_queryAsControlUser($table_query);
        $version_data = $GLOBALS['dbi']->fetchArray($table_result);
        $tbl_link = 'tbl_tracking.php' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']);
        $delete_link = 'db_tracking.php' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']) . '&amp;delete_tracking=true&amp';
        $checkbox_id = "selected_tbl_" . htmlspecialchars($version_data['table_name']);
        ?>
        <tr class="<?php 
        echo $style;
        ?>
">
            <td class="center">
                <input type="checkbox" name="selected_tbl[]"
                class="checkall" id="<?php 
        echo $checkbox_id;
        ?>
"
                value="<?php 
        echo htmlspecialchars($version_data['table_name']);
        ?>
"/>
            </td>
            <th>
                <label for="<?php 
        echo $checkbox_id;
        ?>
">
                    <?php 
        echo htmlspecialchars($version_data['table_name']);
        ?>
                </label>
            </th>
            <td class="right"><?php 
        echo $version_data['version'];
        ?>
</td>
            <td><?php 
        echo $version_data['date_created'];
        ?>
</td>
            <td><?php 
        echo $version_data['date_updated'];
        ?>
</td>
            <td>
            <?php 
        PMA_displayStatusButton($version_data, $tbl_link);
        ?>
            </td>
            <td>
            <a class="delete_tracking_anchor ajax"
               href="<?php 
        echo $delete_link;
        ?>
" >
            <?php 
        echo $delete;
        ?>
</a>
        <?php 
        echo '</td>', '<td>', '<a href="', $tbl_link, '">', $versions, '</a>', '&nbsp;&nbsp;', '<a href="', $tbl_link, '&amp;report=true&amp;version=', $version_data['version'], '">', $report, '</a>', '&nbsp;&nbsp;', '<a href="' . $tbl_link, '&amp;snapshot=true&amp;version=', $version_data['version'], '">', $structure, '</a>', '</td>', '</tr>';
        if ($style == 'even') {
            $style = 'odd';
        } else {
            $style = 'even';
        }
    }
    ?>
    </tbody>
    </table>
    <?php 
    echo PMA\libraries\Util::getWithSelected($pmaThemeImage, $text_dir, "trackedForm");
    echo PMA\libraries\Util::getButtonOrImage('submit_mult', 'mult_submit', 'submit_mult_delete_tracking', __('Delete tracking'), 'b_drop.png', 'delete_tracking');
    ?>
    </form>
    </div>
    <?php 
}
コード例 #3
0
/**
 * Creates a list of items containing the relevant
 * information and some action links.
 *
 * @param string $type  One of ['routine'|'trigger'|'event']
 * @param array  $items An array of items
 *
 * @return string HTML code of the list of items
 */
function PMA_RTE_getList($type, $items)
{
    global $table;
    /**
     * Conditional classes switch the list on or off
     */
    $class1 = 'hide';
    $class2 = '';
    if (!$items) {
        $class1 = '';
        $class2 = ' hide';
    }
    /**
     * Generate output
     */
    $retval = "<!-- LIST OF " . PMA_RTE_getWord('docu') . " START -->\n";
    $retval .= '<form id="rteListForm" class="ajax" action="';
    switch ($type) {
        case 'routine':
            $retval .= 'db_routines.php';
            break;
        case 'trigger':
            if (!empty($table)) {
                $retval .= 'tbl_triggers.php';
            } else {
                $retval .= 'db_triggers.php';
            }
            break;
        case 'event':
            $retval .= 'db_events.php';
            break;
        default:
            break;
    }
    $retval .= '">';
    $retval .= PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']);
    $retval .= "<fieldset>\n";
    $retval .= "    <legend>\n";
    $retval .= "        " . PMA_RTE_getWord('title') . "\n";
    $retval .= "        " . PMA\libraries\Util::showMySQLDocu(PMA_RTE_getWord('docu')) . "\n";
    $retval .= "    </legend>\n";
    $retval .= "    <div class='{$class1}' id='nothing2display'>\n";
    $retval .= "      " . PMA_RTE_getWord('nothing') . "\n";
    $retval .= "    </div>\n";
    $retval .= "    <table class='data{$class2}'>\n";
    $retval .= "        <!-- TABLE HEADERS -->\n";
    $retval .= "        <tr>\n";
    // th cells with a colspan need corresponding td cells, according to W3C
    switch ($type) {
        case 'routine':
            $retval .= "            <th></th>\n";
            $retval .= "            <th>" . __('Name') . "</th>\n";
            $retval .= "            <th colspan='4'>" . __('Action') . "</th>\n";
            $retval .= "            <th>" . __('Type') . "</th>\n";
            $retval .= "            <th>" . __('Returns') . "</th>\n";
            $retval .= "        </tr>\n";
            $retval .= "        <tr style='display: none'>\n";
            // see comment above
            for ($i = 0; $i < 7; $i++) {
                $retval .= "            <td></td>\n";
            }
            break;
        case 'trigger':
            $retval .= "            <th></th>\n";
            $retval .= "            <th>" . __('Name') . "</th>\n";
            if (empty($table)) {
                $retval .= "            <th>" . __('Table') . "</th>\n";
            }
            $retval .= "            <th colspan='3'>" . __('Action') . "</th>\n";
            $retval .= "            <th>" . __('Time') . "</th>\n";
            $retval .= "            <th>" . __('Event') . "</th>\n";
            $retval .= "        </tr>\n";
            $retval .= "        <tr style='display: none'>\n";
            // see comment above
            for ($i = 0; $i < (empty($table) ? 7 : 6); $i++) {
                $retval .= "            <td></td>\n";
            }
            break;
        case 'event':
            $retval .= "            <th></th>\n";
            $retval .= "            <th>" . __('Name') . "</th>\n";
            $retval .= "            <th>" . __('Status') . "</th>\n";
            $retval .= "            <th colspan='3'>" . __('Action') . "</th>\n";
            $retval .= "            <th>" . __('Type') . "</th>\n";
            $retval .= "        </tr>\n";
            $retval .= "        <tr style='display: none'>\n";
            // see comment above
            for ($i = 0; $i < 6; $i++) {
                $retval .= "            <td></td>\n";
            }
            break;
        default:
            break;
    }
    $retval .= "        </tr>\n";
    $retval .= "        <!-- TABLE DATA -->\n";
    $count = 0;
    foreach ($items as $item) {
        $rowclass = $count % 2 == 0 ? 'odd' : 'even';
        if ($GLOBALS['is_ajax_request'] && empty($_REQUEST['ajax_page_request'])) {
            $rowclass .= ' ajaxInsert hide';
        }
        // Get each row from the correct function
        switch ($type) {
            case 'routine':
                $retval .= PMA_RTN_getRowForList($item, $rowclass);
                break;
            case 'trigger':
                $retval .= PMA_TRI_getRowForList($item, $rowclass);
                break;
            case 'event':
                $retval .= PMA_EVN_getRowForList($item, $rowclass);
                break;
            default:
                break;
        }
        $count++;
    }
    $retval .= "    </table>\n";
    if (count($items)) {
        $retval .= '<div class="withSelected">';
        $retval .= PMA\libraries\Util::getWithSelected($GLOBALS['pmaThemeImage'], $GLOBALS['text_dir'], 'rteListForm');
        $retval .= PMA\libraries\Util::getButtonOrImage('submit_mult', 'mult_submit', 'submit_mult_export', __('Export'), 'b_export.png', 'export');
        $retval .= PMA\libraries\Util::getButtonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', __('Drop'), 'b_drop.png', 'drop');
        $retval .= '</div>';
    }
    $retval .= "</fieldset>\n";
    $retval .= "</form>\n";
    $retval .= "<!-- LIST OF " . PMA_RTE_getWord('docu') . " END -->\n";
    return $retval;
}