add support for venue pagination
This commit is contained in:
@@ -1455,7 +1455,71 @@ class BibtexbrowserTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertEquals(0, count($results));
|
$this->assertEquals(0, count($results));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_venuevc_pagination() {
|
||||||
|
// Define the page size for pagination
|
||||||
|
bibtexbrowser_configure('VENUE_SIZE', 2);
|
||||||
|
|
||||||
|
// Create a test BibTeX database with multiple entries
|
||||||
|
$bibtex = "@article{paper1,title={Paper One},journal={Journal A},year=2020}
|
||||||
|
@article{paper2,title={Paper Two},journal={Journal A},year=2020}
|
||||||
|
@article{paper3,title={Paper Three},journal={Journal B},year=2020}
|
||||||
|
@article{paper4,title={Paper Four},journal={Journal B},year=2020}
|
||||||
|
@article{paper5,title={Paper Five},journal={Journal C},year=2020}
|
||||||
|
@article{paper6,title={Paper Six},journal={Journal C},year=2020}";
|
||||||
|
|
||||||
|
$test_data = fopen('php://memory','r+');
|
||||||
|
fwrite($test_data, $bibtex);
|
||||||
|
fseek($test_data, 0);
|
||||||
|
|
||||||
|
$db = new BibDataBase();
|
||||||
|
$db->update_internal("inline", $test_data);
|
||||||
|
|
||||||
|
// Create VenueVC display
|
||||||
|
$display = new MenuManager();
|
||||||
|
$display->setDB($db);
|
||||||
|
|
||||||
|
// First, test without pagination parameter
|
||||||
|
$_GET["venue_page"] = '1';
|
||||||
|
ob_start();
|
||||||
|
$display->display();
|
||||||
|
$output = ob_get_clean();
|
||||||
|
|
||||||
|
// Verify all entries are shown when no pagination is specified
|
||||||
|
$this->assertStringContainsString('Journal A', $output);
|
||||||
|
$this->assertStringContainsString('Journal B', $output);
|
||||||
|
|
||||||
|
// Test with pagination parameter
|
||||||
|
$_GET["venue_page"] = '1';
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
$display->display();
|
||||||
|
$output1 = ob_get_clean();
|
||||||
|
|
||||||
|
// Create XML parser to properly analyze the HTML structure
|
||||||
|
$xml = new SimpleXMLElement("<doc>".$output1."</doc>");
|
||||||
|
|
||||||
|
// Count number of entries displayed on first page
|
||||||
|
//$result = $xml->xpath('//tr[contains(@class, "btb-menu-items")]');
|
||||||
|
//$this->assertEquals($PAGE_SIZE, count($result));
|
||||||
|
|
||||||
|
// Verify pagination links existence
|
||||||
|
$this->assertStringContainsString('venue_page=2', $output1);
|
||||||
|
|
||||||
|
// Test second page
|
||||||
|
$_GET["venue_page"] = '2';
|
||||||
|
ob_start();
|
||||||
|
$display->display();
|
||||||
|
$output2 = ob_get_clean();
|
||||||
|
|
||||||
|
// Verify navigation links
|
||||||
|
$this->assertStringContainsString('venue_page=1', $output2); // Link to previous page
|
||||||
|
|
||||||
|
// Verify different entries on second page
|
||||||
|
$this->assertStringContainsString('Journal C', $output2);
|
||||||
|
|
||||||
|
// Clean up
|
||||||
|
unset($_GET["venue_page"]);
|
||||||
|
}
|
||||||
} // end class
|
} // end class
|
||||||
|
|
||||||
// Test implementation that records events
|
// Test implementation that records events
|
||||||
|
|||||||
+16
-14
@@ -181,6 +181,7 @@ if (defined('ENCODING')) {
|
|||||||
@define('YEAR_SIZE',20); // number of years per table
|
@define('YEAR_SIZE',20); // number of years per table
|
||||||
@define('AUTHORS_SIZE',30); // number of authors per table
|
@define('AUTHORS_SIZE',30); // number of authors per table
|
||||||
@define('TAGS_SIZE',30); // number of keywords per table
|
@define('TAGS_SIZE',30); // number of keywords per table
|
||||||
|
@define('VENUE_SIZE',30); // number of venues per table
|
||||||
@define('READLINE_LIMIT',1024);
|
@define('READLINE_LIMIT',1024);
|
||||||
@define('Q_YEAR', 'year');
|
@define('Q_YEAR', 'year');
|
||||||
@define('Q_YEAR_PAGE', 'year_page');
|
@define('Q_YEAR_PAGE', 'year_page');
|
||||||
@@ -2874,7 +2875,6 @@ usage:
|
|||||||
$db = zetDB('bibacid-utf8.bib');
|
$db = zetDB('bibacid-utf8.bib');
|
||||||
$menu = new MenuManager();
|
$menu = new MenuManager();
|
||||||
$menu->setDB($db);
|
$menu->setDB($db);
|
||||||
$menu->year_size=100;// should display all years :)
|
|
||||||
$menu->display();
|
$menu->display();
|
||||||
</pre>
|
</pre>
|
||||||
*/
|
*/
|
||||||
@@ -2883,11 +2883,6 @@ class MenuManager {
|
|||||||
/** The bibliographic database, an instance of class BibDataBase. */
|
/** The bibliographic database, an instance of class BibDataBase. */
|
||||||
var $db;
|
var $db;
|
||||||
|
|
||||||
var $type_size = TYPES_SIZE;
|
|
||||||
var $year_size = YEAR_SIZE;
|
|
||||||
var $author_size = AUTHORS_SIZE;
|
|
||||||
var $tag_size = TAGS_SIZE;
|
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2952,17 +2947,24 @@ class MenuManager {
|
|||||||
}
|
}
|
||||||
else $page = 1;
|
else $page = 1;
|
||||||
|
|
||||||
$this->displayMenu('Types', $types, $page, $this->type_size, Q_TYPE_PAGE, Q_INNER_TYPE);
|
$this->displayMenu('Types', $types, $page, bibtexbrowser_configuration("TYPES_SIZE"), Q_TYPE_PAGE, Q_INNER_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Displays and controls the venues. */
|
/** Displays and controls the venues. */
|
||||||
function venueVC() {
|
function venueVC() {
|
||||||
// retrieve authors list to display
|
// retrieve venues list to display
|
||||||
$data = $this->db->venueIndex();
|
$venues = $this->db->venueIndex();
|
||||||
|
|
||||||
$this->displayMenu('Venues', $data, 1, 100000, Q_SEARCH,
|
// determine the venues page to display
|
||||||
Q_SEARCH);
|
if (isset($_GET['venue_page'])) {
|
||||||
|
$page = $_GET['venue_page'];
|
||||||
|
} else $page = 1;
|
||||||
|
|
||||||
|
if (count($venues) > 0) {
|
||||||
|
$this->displayMenu('Venues', $venues, $page, bibtexbrowser_configuration("VENUE_SIZE"), 'venue_page',
|
||||||
|
Q_SEARCH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Displays and controls the authors menu in a table. */
|
/** Displays and controls the authors menu in a table. */
|
||||||
@@ -2977,7 +2979,7 @@ class MenuManager {
|
|||||||
else $page = 1;
|
else $page = 1;
|
||||||
|
|
||||||
|
|
||||||
$this->displayMenu('Authors', $authors, $page, $this->author_size, Q_AUTHOR_PAGE,
|
$this->displayMenu('Authors', $authors, $page, bibtexbrowser_configuration("AUTHORS_SIZE"), Q_AUTHOR_PAGE,
|
||||||
Q_AUTHOR);
|
Q_AUTHOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2992,7 +2994,7 @@ class MenuManager {
|
|||||||
} else $page = 1;
|
} else $page = 1;
|
||||||
|
|
||||||
|
|
||||||
if (count($tags)>0) $this->displayMenu('Keywords', $tags, $page, $this->tag_size, Q_TAG_PAGE,
|
if (count($tags)>0) $this->displayMenu('Keywords', $tags, $page, bibtexbrowser_configuration("MENU_SIZE"), Q_TAG_PAGE,
|
||||||
Q_TAG);
|
Q_TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3008,7 +3010,7 @@ class MenuManager {
|
|||||||
else $page = 1;
|
else $page = 1;
|
||||||
|
|
||||||
|
|
||||||
$this->displayMenu('Years', $years, $page, $this->year_size, Q_YEAR_PAGE,
|
$this->displayMenu('Years', $years, $page, bibtexbrowser_configuration("YEAR_SIZE"), Q_YEAR_PAGE,
|
||||||
Q_YEAR);
|
Q_YEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user