2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Set of functions related to designer
8 if (! defined('PHPMYADMIN')) {
12 require_once 'libraries/relation.lib.php';
13 require_once 'libraries/Template.class.php';
16 * Function to get html to display a page selector
18 * @param array $cfgRelation information about the configuration storage
19 * @param string $db database name
21 * @return string html content
23 function PMA_getHtmlForPageSelector($cfgRelation, $db)
25 return PMA\Template
::get('designer/page_selector')
29 'cfgRelation' => $cfgRelation
35 * Function to get html for displaying the page edit/delete form
37 * @param string $db database name
38 * @param string $operation 'edit' or 'delete' depending on the operation
40 * @return string html content
42 function PMA_getHtmlForEditOrDeletePages($db, $operation)
44 return PMA\Template
::get('designer/edit_delete_pages')
48 'operation' => $operation
54 * Function to get html for displaying the page save as form
56 * @param string $db database name
58 * @return string html content
60 function PMA_getHtmlForPageSaveAs($db)
62 return PMA\Template
::get('designer/page_save_as')
71 * Retrieve IDs and names of schema pages
73 * @param string $db database name
75 * @return array array of schema page id and names
77 function PMA_getPageIdsAndNames($db)
79 $cfgRelation = PMA_getRelationsParam();
80 $page_query = "SELECT `page_nr`, `page_descr` FROM "
81 . PMA_Util
::backquote($cfgRelation['db']) . "."
82 . PMA_Util
::backquote($cfgRelation['pdf_pages'])
83 . " WHERE db_name = '" . PMA_Util
::sqlAddSlashes($db) . "'"
84 . " ORDER BY `page_descr`";
85 $page_rs = PMA_queryAsControlUser(
86 $page_query, false, PMA_DatabaseInterface
::QUERY_STORE
90 while ($curr_page = $GLOBALS['dbi']->fetchAssoc($page_rs)) {
91 $result[$curr_page['page_nr']] = $curr_page['page_descr'];
97 * Function to get html for displaying the schema export
99 * @param string $db database name
100 * @param int $page the page to be exported
104 function PMA_getHtmlForSchemaExport($db, $page)
106 /* Scan for schema plugins */
107 $export_list = PMA_getPlugins(
109 'libraries/plugins/schema/',
113 /* Fail if we didn't find any schema plugin */
114 if (empty($export_list)) {
115 return PMA_Message
::error(
116 __('Could not load schema plugins, please check your installation!')
120 return PMA\Template
::get('designer/schema_export')
125 'export_list' => $export_list
131 * Returns HTML for including some variable to be accessed by JavaScript
133 * @param array $script_tables array on foreign key support for each table
134 * @param array $script_contr initialization data array
135 * @param array $script_display_field display fields of each table
136 * @param int $display_page page number of the selected page
138 * @return string html
140 function PMA_getHtmlForJSFields(
141 $script_tables, $script_contr, $script_display_field, $display_page
143 return PMA\Template
::get('designer/js_fields')
146 'script_tables' => $script_tables,
147 'script_contr' => $script_contr,
148 'script_display_field' => $script_display_field,
149 'display_page' => $display_page
155 * Returns HTML for the menu bar of the designer page
157 * @param boolean $visualBuilder whether this is visual query builder
158 * @param string $selected_page name of the selected page
160 * @return string html
162 function PMA_getDesignerPageMenu($visualBuilder, $selected_page)
164 return PMA\Template
::get('designer/side_menu')
167 'visualBuilder' => $visualBuilder,
168 'selected_page' => $selected_page
174 * Returns HTML for the canvas element
176 * @return string html
178 function PMA_getHTMLCanvas()
180 return PMA\Template
::get('designer/canvas')->render();
184 * Return HTML for the table list
186 * @param array $tab_pos table positions
187 * @param int $display_page page number of the selected page
189 * @return string html
191 function PMA_getHTMLTableList($tab_pos, $display_page)
193 return PMA\Template
::get('designer/table_list')
196 'tab_pos' => $tab_pos,
197 'display_page' => $display_page
203 * Get HTML to display tables on designer page
205 * @param array $tab_pos tables positions
206 * @param int $display_page page number of the selected page
207 * @param array $tab_column table column info
208 * @param array $tables_all_keys all indices
209 * @param array $tables_pk_or_unique_keys unique or primary indices
211 * @return string html
213 function PMA_getDatabaseTables(
214 $tab_pos, $display_page, $tab_column, $tables_all_keys, $tables_pk_or_unique_keys
216 return PMA\Template
::get('designer/database_tables')
219 'tab_pos' => $tab_pos,
220 'display_page' => $display_page,
221 'tab_column' => $tab_column,
222 'tables_all_keys' => $tables_all_keys,
223 'tables_pk_or_unique_keys' => $tables_pk_or_unique_keys
229 * Returns HTML for the new relations panel.
231 * @return string html
233 function PMA_getNewRelationPanel()
235 return PMA\Template
::get('designer/new_relation_panel')->render();
239 * Returns HTML for the relations delete panel
241 * @return string html
243 function PMA_getDeleteRelationPanel()
245 return PMA\Template
::get('designer/delete_relation_panel')->render();
249 * Returns HTML for the options panel
251 * @return string html
253 function PMA_getOptionsPanel()
255 return PMA\Template
::get('designer/options_panel')->render();
259 * Get HTML for the 'rename to' panel
261 * @return string html
263 function PMA_getRenameToPanel()
265 return PMA\Template
::get('designer/rename_to_panel')->render();
269 * Returns HTML for the 'having' panel
271 * @return string html
273 function PMA_getHavingQueryPanel()
275 return PMA\Template
::get('designer/having_query_panel')->render();
279 * Returns HTML for the 'aggregate' panel
281 * @return string html
283 function PMA_getAggregateQueryPanel()
285 return PMA\Template
::get('designer/aggregate_query_panel')->render();
289 * Returns HTML for the 'where' panel
291 * @return string html
293 function PMA_getWhereQueryPanel()
295 return PMA\Template
::get('designer/where_query_panel')->render();
299 * Returns HTML for the query details panel
301 * @return string html
303 function PMA_getQueryDetails()
305 return PMA\Template
::get('designer/query_details')->render();