@@ -52,34 +52,35 @@ public function viewAction($categoryId = 0)
52
52
53
53
//All posts from the selected category
54
54
$ 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 ' ;
57
57
$ msg = (!empty ($ catName )) ? 'There are still no posts in category <b> ' . $ catName . '</b>. ' : 'Wrong parameter passed, please try again later. ' ;
58
58
} else {
59
59
60
60
// prepare pagination vars
61
61
$ this ->_view ->targetPage = 'categories/view/id/ ' . $ categoryId ;
62
62
$ this ->_view ->currentPage = A::app ()->getRequest ()->getQuery ('page ' , 'integer ' , 1 );
63
63
$ 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 ' ;
71
70
$ 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 ' );
83
84
}
84
85
85
86
public function indexAction ($ msg = '' )
@@ -107,25 +108,35 @@ public function indexAction($msg = '')
107
108
$ msgType = 'Wrong parameter passed! Check category ID. ' ;
108
109
$ msgType = 'error ' ;
109
110
}
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
114
117
$ this ->_view ->targetPage = 'categories/index ' ;
115
118
$ this ->_view ->currentPage = A::app ()->getRequest ()->getQuery ('page ' , 'integer ' , 1 );
116
119
$ this ->_view ->pageSize = '15 ' ;
117
120
$ 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 ' );
129
140
}
130
141
131
142
public function addAction ()
0 commit comments