File tree Expand file tree Collapse file tree 11 files changed +79
-59
lines changed Expand file tree Collapse file tree 11 files changed +79
-59
lines changed Original file line number Diff line number Diff line change 11<?php
22
3- namespace BNETDocs \Controllers ;
3+ namespace BNETDocs \Controllers \ News ;
44
55use \BNETDocs \Libraries \User \User ;
66
7- class News extends Base
7+ class Index extends \ BNETDocs \ Controllers \ Base
88{
99 public const NEWS_PER_PAGE = 5 ;
1010
@@ -13,7 +13,7 @@ class News extends Base
1313 */
1414 public function __construct ()
1515 {
16- $ this ->model = new \BNETDocs \Models \News ();
16+ $ this ->model = new \BNETDocs \Models \News \ Index ();
1717 }
1818
1919 /**
Original file line number Diff line number Diff line change 44
55use \OutOfBoundsException ;
66
7- class Pagination
7+ class Pagination implements \JsonSerializable
88{
99 private array $ dataset ;
1010 private int $ limit ;
@@ -43,6 +43,16 @@ public function getPage(): array
4343 return $ set ;
4444 }
4545
46+ public function jsonSerialize (): mixed
47+ {
48+ return [
49+ 'current_page ' => $ this ->currentPage (),
50+ 'page_count ' => $ this ->pageCount (),
51+ 'items_per_page ' => $ this ->limit ,
52+ 'page_items ' => $ this ->getPage (),
53+ ];
54+ }
55+
4656 public function nextPage (): int
4757 {
4858 if ($ this ->page >= $ this ->pageCount ())
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace BNETDocs \Models \News ;
4+
5+ class Index extends \BNETDocs \Models \ActiveUser implements \JsonSerializable
6+ {
7+ public bool $ acl_allowed = false ;
8+ public ?array $ news_posts = null ;
9+ public ?\BNETDocs \Libraries \Core \Pagination $ pagination = null ;
10+
11+ public function jsonSerialize (): mixed
12+ {
13+ return \array_merge (parent ::jsonSerialize (), [
14+ 'acl_allowed ' => $ this ->acl_allowed ,
15+ 'news_posts ' => $ this ->news_posts ,
16+ 'pagination ' => $ this ->pagination ,
17+ ]);
18+ }
19+ }
Original file line number Diff line number Diff line change 11<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */
2- namespace BNETDocs \Templates ;
2+ namespace BNETDocs \Templates \ News ;
33use \BNETDocs \Libraries \User \User ;
44use \CarlBennett \MVC \Libraries \Common ;
55use \CarlBennett \MVC \Libraries \Pair ;
Original file line number Diff line number Diff line change 11<?php
22
3- namespace BNETDocs \Templates ;
3+ namespace BNETDocs \Templates \ News ;
44
55use \CarlBennett \MVC \Libraries \Common ;
66
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace BNETDocs \Views \News ;
4+
5+ class IndexHtml extends \BNETDocs \Views \Base \Html
6+ {
7+ public static function invoke (\BNETDocs \Interfaces \Model $ model ): void
8+ {
9+ if (!$ model instanceof \BNETDocs \Models \News \Index)
10+ {
11+ throw new \BNETDocs \Exceptions \InvalidModelException ($ model );
12+ }
13+
14+ (new \BNETDocs \Libraries \Core \Template ($ model , 'News/Index ' ))->invoke ();
15+ $ model ->_responseHeaders ['Content-Type ' ] = self ::mimeType ();
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace BNETDocs \Views \News ;
4+
5+ class IndexRSS extends \BNETDocs \Views \Base \RSS
6+ {
7+ public static function invoke (\BNETDocs \Interfaces \Model $ model ): void
8+ {
9+ if (!$ model instanceof \BNETDocs \Models \News \Index)
10+ {
11+ throw new \BNETDocs \Exceptions \InvalidModelException ($ model );
12+ }
13+
14+ (new \BNETDocs \Libraries \Core \Template ($ model , 'News/Index.rss ' ))->invoke ();
15+ $ model ->_responseHeaders ['Content-Type ' ] = self ::mimeType ();
16+ }
17+ }
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments