Ejemplo n.º 1
0
 public function testEnsureOnlyOnePageAppearsByDefault()
 {
     $pages = array();
     Pager::getPageNumbers(0, $pages, $number_of_pages);
     $this->assertEquals($pages['start'], 0);
     $this->assertEquals($pages['end'], 0);
     $this->assertEquals(1, $number_of_pages);
 }
Ejemplo n.º 2
0
 public function testWhetherPagesRunMultiplesOfTen()
 {
     $pages = array();
     $number_of_pages = 0;
     $_GET['p'] = 1;
     Pager::getPageNumbers(1000, $pages, $number_of_pages);
     $this->assertEquals(1, $pages['start']);
     $this->assertEquals(10, $pages['end']);
     $_GET['p'] = 4;
     Pager::getPageNumbers(1000, $pages, $number_of_pages);
     $this->assertEquals(1, $pages['start']);
     $this->assertEquals(10, $pages['end']);
     $_GET['p'] = 11;
     Pager::getPageNumbers(1000, $pages, $number_of_pages);
     $this->assertEquals(11, $pages['start']);
     $this->assertEquals(20, $pages['end']);
     $_GET['p'] = 20;
     Pager::getPageNumbers(1000, $pages, $number_of_pages);
     $this->assertEquals(11, $pages['start']);
     $this->assertEquals(20, $pages['end']);
     $_GET['p'] = 100;
     Pager::getPageNumbers(1000, $pages, $number_of_pages);
     $this->assertEquals(91, $pages['start']);
     $this->assertEquals(100, $pages['end']);
     $_GET['p'] = 0;
     Pager::getPageNumbers(1000, $pages, $number_of_pages);
     $this->assertEquals(1, $pages['start']);
     $this->assertEquals(10, $pages['end']);
     $_GET['p'] = -1;
     Pager::getPageNumbers(1000, $pages, $number_of_pages);
     $this->assertEquals(1, $pages['start']);
     $this->assertEquals(10, $pages['end']);
 }
Ejemplo n.º 3
0
 public static function manage()
 {
     $numberOfPages = 1;
     $autoresponder_id = $_GET['id'];
     try {
         $autoresponder = Autoresponder::getAutoresponder((int) $autoresponder_id);
     } catch (NonExistentAutoresponderException $exp) {
         wp_redirect("admin.php?page=_wpr/autoresponders");
     }
     Pager::getPageNumbers($autoresponder->getNumberOfMessages(), $pages, $numberOfPages);
     $current_page = $pages['current_page'];
     $messages = $autoresponder->getMessages(Pager::getStartIndexOfRecordSet(), Pager::getRowsPerPage());
     _wpr_set('number_of_pages', $numberOfPages);
     _wpr_set('current_page', $current_page);
     _wpr_set('pages', $pages);
     _wpr_set("messages", $messages);
     _wpr_set('base_url', 'admin.php?page=_wpr/autoresponders&action=manage&id=' . $autoresponder_id);
     _wpr_set("autoresponder", $autoresponder);
     _wpr_setview("autoresponder_manage");
 }