jaxon-php /
jaxon-mono
| 1 | <?php |
||
| 2 | |||
| 3 | use Jaxon\App\PageComponent; |
||
| 4 | use Jaxon\App\PageDatabagTrait; |
||
| 5 | |||
| 6 | /** |
||
| 7 | * @databag page |
||
| 8 | */ |
||
| 9 | class PageContent extends PageComponent |
||
| 10 | { |
||
| 11 | use PageDatabagTrait; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @inheritDoc |
||
| 15 | */ |
||
| 16 | protected function bagName(): string |
||
| 17 | { |
||
| 18 | return 'page'; |
||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @inheritDoc |
||
| 23 | */ |
||
| 24 | protected function bagAttr(): string |
||
| 25 | { |
||
| 26 | return 'number'; |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @inheritDoc |
||
| 31 | */ |
||
| 32 | protected function limit(): int |
||
| 33 | { |
||
| 34 | return 10; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @inheritDoc |
||
| 39 | */ |
||
| 40 | protected function count(): int |
||
| 41 | { |
||
| 42 | return 150; |
||
| 43 | } |
||
| 44 | |||
| 45 | public function html(): string |
||
| 46 | { |
||
| 47 | return '<div style="margin-bottom:10px;font-weight:bold;">' . |
||
| 48 | $this->bag('page')->get('title') . |
||
| 49 | '</div>Showing page number ' . $this->currentPage(); |
||
| 50 | } |
||
| 51 | |||
| 52 | public function showPage(int $pageNumber) |
||
| 53 | { |
||
| 54 | // Get the paginator. This will also set the final page number value. |
||
| 55 | $paginator = $this->paginator($pageNumber); |
||
| 56 | // Render the page content. |
||
| 57 | $this->render(); |
||
| 58 | // Render the pagination component. |
||
| 59 | $paginator->render($this->rq()->showPage(je()->rd()->page())); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 60 | } |
||
| 61 | |||
| 62 | public function show() |
||
| 63 | { |
||
| 64 | $title = 'This is the page title'; |
||
| 65 | $this->bag('page')->set('title', $title); |
||
| 66 | $this->showPage(1); |
||
| 67 | } |
||
| 68 | } |
||
| 69 | |||
| 70 | jaxon()->app()->setup(configFile('component.php')); |
||
| 71 |