Welcome to mirror list, hosted at ThFree Co, Russian Federation.

designer.lib.php « libraries - github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ad6689721ab94e01807fe88493a1cf98b294cc18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Set of functions related to designer
 *
 * @package PhpMyAdmin
 */
if (! defined('PHPMYADMIN')) {
    exit;
}

require_once 'libraries/relation.lib.php';

/**
 * Function to get html for displaying the page edit/delete form
 *
 * @param string $db        databasae name
 * @param string $operation 'edit' or 'delete' depending on the operation
 *
 * @return string html content
 */
function PMA_getHtmlForEditOrDeletePages($db, $operation)
{
    $html  = '<form action="pmd_general.php" method="post"'
        . ' name="edit_delete_pages" id="edit_delete_pages" class="ajax">';
    $html .= PMA_URL_getHiddenInputs($db);
    $html .= '<fieldset id="page_edit_delete_options">';
    $html .= '<input type="hidden" name="operation" value="' . $operation . '" />';
    $html .= '<label for="selected_page">';
    if ($operation == 'edit') {
        $html .= __("Page to open");
    } else {
        $html .= __("Page to delete");
    }
    $html .= ': </label>';
    $html .= '<select name="selected_page" id="selected_page">';
    $html .= '<option value="0">-- ' . __('Select page').' --</option>';
    $pages = PMA_getPageIdsAndNames($db);
    foreach ($pages as $nr => $desc) {
        $html .= '<option value="' . $nr . '">';
        $html .= htmlspecialchars($desc) . '</option>';
    }
    $html .= '</select>';
    $html .= '</fieldset>';
    $html .= '</form>';
    return $html;
}

/**
 * Function to get html for displaying the page save as form
 *
 * @param string $db databasae name
 *
 * @return string html content
 */
function PMA_getHtmlForPageSaveAs($db)
{
    $choices = array(
        'same' => __('Save to selected page'),
        'new' => __('Create a page and save to it')
    );

    $html  = '<form action="pmd_general.php" method="post"'
        . ' name="save_as_pages" id="save_as_pages" class="ajax">';
    $html .= PMA_URL_getHiddenInputs($db);
    $html .= '<fieldset id="page_save_as_options">';
    $html .= '<table><tbody>';

    $html .= '<tr>';
    $html .= '<td>';
    $html .= '<input type="hidden" name="operation" value="save" />';
    $html .= '<select name="selected_page" id="selected_page">';
    $html .= '<option value="0">-- ' . __('Select page') . ' --</option>';

    $pages = PMA_getPageIdsAndNames($db);
    foreach ($pages as $nr => $desc) {
        $html .= '<option value="' . $nr . '">';
        $html .= htmlspecialchars($desc) . '</option>';
    }
    $html .= '</select>';
    $html .= '</td>';
    $html .= '</tr>';

    $html .= '<tr>';
    $html .= '<td>';
    $html .= PMA_Util::getRadioFields('save_page', $choices, 'same', true);
    $html .= '</td>';
    $html .= '</tr>';

    $html .= '<tr>';
    $html .= '<td>';
    $html .= '<label for="selected_value">' . __('New page name') . '</label>';
    $html .= '<input type="text" name="selected_value" id="selected_value" />';
    $html .= '</td>';
    $html .= '</tr>';

    $html .= '</tbody></table>';
    $html .= '</fieldset>';
    $html .= '</form>';

    return $html;
}

/**
 * Retrieve IDs and names of schema pages
 *
 * @param string $db database name
 *
 * @return array array of schema page id and names
 */
function PMA_getPageIdsAndNames($db)
{
    $cfgRelation = PMA_getRelationsParam();
    $page_query = "SELECT `page_nr`, `page_descr` FROM "
        . PMA_Util::backquote($cfgRelation['db']) . "."
        . PMA_Util::backquote($cfgRelation['pdf_pages'])
        . " WHERE db_name = '" . PMA_Util::sqlAddSlashes($db) . "'"
        . " ORDER BY `page_nr`";
    $page_rs = PMA_queryAsControlUser(
        $page_query, false, PMA_DatabaseInterface::QUERY_STORE
    );

    $result = array();
    while ($curr_page = $GLOBALS['dbi']->fetchAssoc($page_rs)) {
        $result[$curr_page['page_nr']] = $curr_page['page_descr'];
    }
    return $result;
}

/**
 * Function to get html for displaying the schema export
 *
 * @param string $db   database name
 * @param int    $page the page to be exported
 *
 * @return string
 */
function PMA_getHtmlForSchemaExport($db, $page)
{
    $htmlString = '<form method="post" action="schema_export.php"'
        . ' class="disableAjax" id="id_export_pages">'
        . '<fieldset>'
        . PMA_URL_getHiddenInputs($db)
        . '<select name="export_type" id="export_type">';

    if (file_exists(TCPDF_INC)) {
        $htmlString .= '<option value="pdf" selected="selected">PDF</option>';
    }

    $htmlString .=' <option value="svg">SVG</option>'
        . '<option value="dia">DIA</option>'
        . '<option value="eps">EPS</option>'
        . '</select>'
        . '<label>' . __('Select Export Relational Type') . '</label><br />';

    $htmlString .= '<input type="hidden" name="chpage" value="' . htmlspecialchars($page) . '" />'
        . '<input type="checkbox" name="show_grid" id="show_grid_opt" />'
        . '<label for="show_grid_opt">' . __('Show grid') . '</label><br />'
        . '<input type="checkbox" name="show_color"'
        . ' id="show_color_opt" checked="checked" />'
        . '<label for="show_color_opt">' . __('Show color') . '</label>'
        . '<br />'
        . '<input type="checkbox" name="show_table_dimension"'
        . ' id="show_table_dim_opt" />'
        . '<label for="show_table_dim_opt">'
        . __('Show dimension of tables')
        . '</label><br />'
        . '<input type="checkbox" name="all_tables_same_width"'
        . ' id="all_tables_same_width" />'
        . '<label for="all_tables_same_width">'
        . __('Same width for all tables')
        . '</label><br />'
        . '<input type="checkbox" name="with_doc"'
        . ' id="with_doc" checked="checked" />'
        . '<label for="with_doc">' . __('Data Dictionary') . '</label><br />'
        . '<input type="checkbox" name="show_keys" id="show_keys" />'
        . '<label for="show_keys">' . __('Only show keys') . '</label><br />'
        . '<select name="orientation" id="orientation_opt" class="paper-change">'
        . '<option value="L">' . __('Landscape') . '</option>'
        . '<option value="P">' . __('Portrait') . '</option>'
        . '</select>'
        . '<label for="orientation_opt">' . __('Orientation') . '</label>'
        . '<br />'
        . '<select name="paper" id="paper_opt" class="paper-change">';

    foreach ($GLOBALS['cfg']['PDFPageSizes'] as $val) {
        $htmlString .= '<option value="' . htmlspecialchars($val) . '"';
        if ($val == $GLOBALS['cfg']['PDFDefaultPageSize']) {
            $htmlString .= ' selected="selected"';
        }
        $htmlString .= '>' . htmlspecialchars($val) . '</option>' . "\n";
    }

    $htmlString  .= '</select>'
        . '<label for="paper_opt">' . __('Paper size') . '</label>'
        . '</fieldset>'
        . '</form>';

    return $htmlString;
}
?>