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 1
1
<?php
2
2
3
- namespace BNETDocs \Controllers ;
3
+ namespace BNETDocs \Controllers \ News ;
4
4
5
5
use \BNETDocs \Libraries \User \User ;
6
6
7
- class News extends Base
7
+ class Index extends \ BNETDocs \ Controllers \ Base
8
8
{
9
9
public const NEWS_PER_PAGE = 5 ;
10
10
@@ -13,7 +13,7 @@ class News extends Base
13
13
*/
14
14
public function __construct ()
15
15
{
16
- $ this ->model = new \BNETDocs \Models \News ();
16
+ $ this ->model = new \BNETDocs \Models \News \ Index ();
17
17
}
18
18
19
19
/**
Original file line number Diff line number Diff line change 4
4
5
5
use \OutOfBoundsException ;
6
6
7
- class Pagination
7
+ class Pagination implements \JsonSerializable
8
8
{
9
9
private array $ dataset ;
10
10
private int $ limit ;
@@ -43,6 +43,16 @@ public function getPage(): array
43
43
return $ set ;
44
44
}
45
45
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
+
46
56
public function nextPage (): int
47
57
{
48
58
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 1
1
<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */
2
- namespace BNETDocs \Templates ;
2
+ namespace BNETDocs \Templates \ News ;
3
3
use \BNETDocs \Libraries \User \User ;
4
4
use \CarlBennett \MVC \Libraries \Common ;
5
5
use \CarlBennett \MVC \Libraries \Pair ;
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- namespace BNETDocs \Templates ;
3
+ namespace BNETDocs \Templates \ News ;
4
4
5
5
use \CarlBennett \MVC \Libraries \Common ;
6
6
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