@@ -52,34 +52,35 @@ public function viewAction($categoryId = 0)
5252
5353 //All posts from the selected category
5454 $ postsModel = Posts::model ();
55- if (! $ postsModel ->count ('category_id = :category_id ' , array ( ':category_id ' => $ categoryId) )) {
56- $ msgType = 'warning ' ;
55+ if ( ! $ postsModel ->count ('category_id = :category_id ' , [ ':category_id ' => $ categoryId] )) {
56+ $ msgType = 'warning ' ;
5757 $ msg = (!empty ($ catName )) ? 'There are still no posts in category <b> ' . $ catName . '</b>. ' : 'Wrong parameter passed, please try again later. ' ;
5858 } else {
5959
6060 // prepare pagination vars
6161 $ this ->_view ->targetPage = 'categories/view/id/ ' . $ categoryId ;
6262 $ this ->_view ->currentPage = A::app ()->getRequest ()->getQuery ('page ' , 'integer ' , 1 );
6363 $ this ->_view ->pageSize = '5 ' ;
64- $ this ->_view ->totalRecords = Posts::model ()->count (array (
65- 'condition ' => 'category_id = :category_id ' ,
66- ),
67- array (':category_id ' => $ categoryId )
68- );
69-
70- $ msgType = 'info ' ;
64+ $ this ->_view ->totalRecords = Posts::model ()->count (
65+ ['condition ' => 'category_id = :category_id ' ,],
66+ [':category_id ' => $ categoryId ]
67+ );
68+
69+ $ msgType = 'info ' ;
7170 $ msg = 'Category: ' . $ catName ;
72-
73- $ this ->_view ->posts = $ postsModel ->findAll (array (
74- 'condition ' => 'category_id = :category_id ' ,
75- 'limit ' => (($ this ->_view ->currentPage - 1 ) * $ this ->_view ->pageSize ) . ', ' . $ this ->_view ->pageSize ,
76- 'order ' => 'post_datetime DESC ' ,
77- ),
78- array (':category_id ' => $ categoryId )
79- );
80- }
81- $ this ->_view ->mainText = CWidget::create ('CMessage ' , array ($ msgType , $ msg , array ('button ' => false )));
82- $ this ->_view ->render ('categories/view ' );
71+
72+ $ this ->_view ->posts = $ postsModel ->findAll (
73+ [
74+ 'condition ' => 'category_id = :category_id ' ,
75+ 'limit ' => (($ this ->_view ->currentPage - 1 ) * $ this ->_view ->pageSize ).', '
76+ .$ this ->_view ->pageSize ,
77+ 'order ' => 'post_datetime DESC ' ,
78+ ],
79+ [':category_id ' => $ categoryId ]
80+ );
81+ }
82+ $ this ->_view ->mainText = CWidget::create ('CMessage ' , [$ msgType , $ msg , ['button ' => false ]]);
83+ $ this ->_view ->render ('categories/view ' );
8384 }
8485
8586 public function indexAction ($ msg = '' )
@@ -107,25 +108,35 @@ public function indexAction($msg = '')
107108 $ msgType = 'Wrong parameter passed! Check category ID. ' ;
108109 $ msgType = 'error ' ;
109110 }
110- if (!empty ($ msgType )) $ this ->_view ->actionMessage = CWidget::create ('CMessage ' , array ($ msgType , $ msgType , array ('button ' => true )));
111- }
112-
113- // prepare pagination vars
111+ if ( ! empty ($ msgType )) {
112+ $ this ->_view ->actionMessage = CWidget::create ('CMessage ' , [$ msgType , $ msgType , ['button ' => true ]]);
113+ }
114+ }
115+
116+ // prepare pagination vars
114117 $ this ->_view ->targetPage = 'categories/index ' ;
115118 $ this ->_view ->currentPage = A::app ()->getRequest ()->getQuery ('page ' , 'integer ' , 1 );
116119 $ this ->_view ->pageSize = '15 ' ;
117120 $ this ->_view ->totalRecords = Categories::model ()->count ();
118-
119- if (!$ this ->_view ->currentPage ) {
120- $ this ->_view ->actionMessage = CWidget::create ('CMessage ' , array ('error ' , 'Wrong parameter passed! Please try again later. ' , array ('button ' => true )));
121- } else {
122- $ this ->_view ->categories = Categories::model ()->findAll (array (
123- 'limit ' => (($ this ->_view ->currentPage - 1 ) * $ this ->_view ->pageSize ) . ', ' . $ this ->_view ->pageSize ,
124- 'order ' => 'id ASC ' ,
125- ));
126- }
127-
128- $ this ->_view ->render ('categories/index ' );
121+
122+ if ( ! $ this ->_view ->currentPage ) {
123+ $ this ->_view ->actionMessage = CWidget::create ('CMessage ' ,
124+ [
125+ 'error ' ,
126+ 'Wrong parameter passed! Please try again later. ' ,
127+ ['button ' => true ]
128+ ]
129+ );
130+ } else {
131+ $ this ->_view ->categories = Categories::model ()->findAll (
132+ [
133+ 'limit ' => (($ this ->_view ->currentPage - 1 ) * $ this ->_view ->pageSize ).', ' .$ this ->_view ->pageSize ,
134+ 'order ' => 'id ASC ' ,
135+ ]
136+ );
137+ }
138+
139+ $ this ->_view ->render ('categories/index ' );
129140 }
130141
131142 public function addAction ()
0 commit comments