/** * Test for testGetDefaultPage() when there is no default page * * @return void */ public function testGetDefaultPageWithNoDefaultPage() { $db = 'db'; $dbi = $this->getMockBuilder('PMA_DatabaseInterface')->disableOriginalConstructor()->getMock(); $dbi->expects($this->at(0))->method('fetchResult')->with("SELECT `page_nr` FROM `pmadb`.`pdf_pages`" . " WHERE `db_name` = '" . $db . "'" . " AND `page_descr` = '" . $db . "'", null, null, 2, PMA_DatabaseInterface::QUERY_STORE)->will($this->returnValue(array())); $GLOBALS['dbi'] = $dbi; $result = PMA_getDefaultPage($db); $this->assertEquals(-1, $result); }
/** * 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']) . "." . PMA_Util::backquote($cfgRelation['pdf_pages']) . " WHERE `db_name` = '" . PMA_Util::sqlAddSlashes($db) . "'"; $min_page_no = $GLOBALS['dbi']->fetchResult($query, null, null, $GLOBALS['controllink'], PMA_DatabaseInterface::QUERY_STORE); if (count($min_page_no[0])) { $page_no = $min_page_no[0]; } } return $page_no; }
} elseif ($_REQUEST['operation'] == 'save_setting_value') { $success = PMA_saveDesignerSetting($_REQUEST['index'], $_REQUEST['value']); $response->setRequestStatus($success); } return; } $script_display_field = PMA_getTablesInfo(); $tab_column = PMA_getColumnsInfo(); $script_tables = PMA_getScriptTabs(); $tables_pk_or_unique_keys = PMA_getPKOrUniqueKeys(); $tables_all_keys = PMA_getAllKeys(); $classes_side_menu = PMA_returnClassNamesFromMenuButtons(); $display_page = -1; $selected_page = null; if (isset($_REQUEST['query'])) { $display_page = PMA_getDefaultPage($_REQUEST['db']); } else { if (!empty($_REQUEST['page'])) { $display_page = $_REQUEST['page']; } else { $display_page = PMA_getLoadingPage($_REQUEST['db']); } } if ($display_page != -1) { $selected_page = PMA_getPageName($display_page); } $tab_pos = PMA_getTablePositions($display_page); $script_contr = PMA_getScriptContr(); $params = array('lang' => $GLOBALS['lang']); if (isset($_GET['db'])) { $params['db'] = $_GET['db'];