Skip to content

Commit

Permalink
Load in visual query builder the default pdf page if such exists
Browse files Browse the repository at this point in the history
Signed-off-by: Madhura Jayaratne <[email protected]>
  • Loading branch information
madhuracj committed Jun 24, 2015
1 parent 57a8421 commit ee7564a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
6 changes: 4 additions & 2 deletions db_designer.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,13 @@
$display_page = -1;
$selected_page = null;

if (! isset($_REQUEST['query'])) {
if (isset($_REQUEST['query'])) {
$display_page = PMA_getDefaultPage($_REQUEST['db']);
} else {
if (! empty($_REQUEST['page'])) {
$display_page = $_REQUEST['page'];
} else {
$display_page = PMA_getDefaultPage($_REQUEST['db']);
$display_page = PMA_getLoadingPage($_REQUEST['db']);
}
}
if ($display_page != -1) {
Expand Down
31 changes: 26 additions & 5 deletions libraries/pmd_common.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,10 @@ function PMA_deletePage($pg)
/**
* Returns the id of the default pdf page of the database.
* Default page is the one which has the same name as the database.
* If no such exists, returns the id of the first page of the database.
*
* @param string $db database
*
* @return int id of the first pdf page, default is -1
* @return int id of the default pdf page for the database
*/
function PMA_getDefaultPage($db)
{
Expand All @@ -350,8 +349,6 @@ function PMA_getDefaultPage($db)
return null;
}

$page_no = -1;

$query = "SELECT `page_nr`"
. " FROM " . PMA_Util::backquote($cfgRelation['db'])
. "." . PMA_Util::backquote($cfgRelation['pdf_pages'])
Expand All @@ -367,7 +364,31 @@ function PMA_getDefaultPage($db)
);

if (count($default_page_no)) {
$page_no = $default_page_no[0];
return $default_page_no[0];
}
return -1;
}

/**
* Get the id of the page to load. If a default page exists it will be returned.
* If no such exists, returns the id of the first page of the database.
*
* @param string $db database
*
* @return int id of the page to load
*/
function PMA_getLoadingPage($db)
{
$cfgRelation = PMA_getRelationsParam();
if (! $cfgRelation['pdfwork']) {
return null;
}

$page_no = -1;

$default_page_no = PMA_getDefaultPage($db);
if ($default_page_no != -1) {
$page_no = $default_page_no;
} else {
$query = "SELECT MIN(`page_nr`)"
. " FROM " . PMA_Util::backquote($cfgRelation['db'])
Expand Down

0 comments on commit ee7564a

Please sign in to comment.