22
33namespace wcf \system \box ;
44
5- use wcf \data \ article \ AccessibleArticleList ;
5+ use wcf \system \ listView \ user \ ArticleListView ;
66use wcf \system \WCF ;
77
88/**
1313 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
1414 * @since 3.0
1515 *
16- * @extends AbstractDatabaseObjectListBoxController<AccessibleArticleList >
16+ * @extends AbstractListViewBoxController<ArticleListView >
1717 */
18- class ArticleListBoxController extends AbstractDatabaseObjectListBoxController
18+ class ArticleListBoxController extends AbstractListViewBoxController
1919{
2020 /**
2121 * @inheritDoc
@@ -51,12 +51,8 @@ class ArticleListBoxController extends AbstractDatabaseObjectListBoxController
5151 public $ validSortFields = [
5252 'time ' ,
5353 'views ' ,
54- 'random ' ,
5554 ];
5655
57- /**
58- * @inheritDoc
59- */
6056 public function __construct ()
6157 {
6258 if (!empty ($ this ->validSortFields ) && MODULE_LIKE ) {
@@ -66,35 +62,46 @@ public function __construct()
6662 parent ::__construct ();
6763 }
6864
69- /**
70- * @inheritDoc
71- */
65+ #[\Override]
7266 protected function getObjectList ()
7367 {
74- $ objectList = new AccessibleArticleList ();
68+ $ objectList = $ this -> getListView ()-> getObjectList ();
7569
7670 switch ($ this ->sortField ) {
7771 case 'views ' :
7872 $ objectList ->getConditionBuilder ()->add ('article.views > ? ' , [0 ]);
7973 break ;
8074 }
8175
82- if ($ this ->sortField === 'random ' ) {
83- $ this ->sortField = 'RAND() ' ;
76+ return $ objectList ;
77+ }
78+
79+ #[\Override]
80+ protected function createListView (): ArticleListView
81+ {
82+ if (!isset ($ this ->listView )) {
83+ $ this ->listView = new ArticleListView ();
8484 }
8585
86- return $ objectList ;
86+ return $ this -> listView ;
8787 }
8888
89- /**
90- * @inheritDoc
91- */
89+ #[\Override]
90+ public function getContainerCssClassName (): string
91+ {
92+ return 'entryCardList__container ' ;
93+ }
94+
95+ #[\Override]
9296 protected function getTemplate ()
9397 {
94- return WCF ::getTPL ()->render ('wcf ' , 'boxArticleList ' , [
95- 'boxArticleList ' => $ this ->objectList ,
96- 'boxSortField ' => $ this ->sortField ,
97- 'boxPosition ' => $ this ->box ->position ,
98- ]);
98+ return match ($ this ->box ->position ) {
99+ 'top ' , 'bottom ' , 'contentTop ' , 'contentBottom ' => parent ::getTemplate (),
100+ default => WCF ::getTPL ()->render ('wcf ' , 'boxArticleList ' , [
101+ 'boxArticleList ' => $ this ->getListView ()->getItems (),
102+ 'boxSortField ' => $ this ->sortField ,
103+ 'boxPosition ' => $ this ->box ->position ,
104+ ])
105+ };
99106 }
100107}
0 commit comments