Code Duplication    Length = 26-26 lines in 5 locations

Apps/Controller/Admin/Comments.php 2 locations

@@ 40-65 (lines=26) @@
37
     * @throws \Ffcms\Core\Exception\NativeException
38
     * @throws \Ffcms\Core\Exception\SyntaxException
39
     */
40
    public function actionIndex()
41
    {
42
        // set current page and offset
43
        $page = (int)$this->request->query->get('page');
44
        $offset = $page * self::ITEM_PER_PAGE;
45
46
        // initialize active record model
47
        $query = new CommentPost();
48
49
        // make pagination
50
        $pagination = new SimplePagination([
51
            'url' => ['comments/index'],
52
            'page' => $page,
53
            'step' => self::ITEM_PER_PAGE,
54
            'total' => $query->count()
55
        ]);
56
57
        // get result as active records object with offset
58
        $records = $query->orderBy('id', 'desc')->skip($offset)->take(self::ITEM_PER_PAGE)->get();
59
60
        // render output view
61
        return $this->view->render('index', [
62
            'records' => $records,
63
            'pagination' => $pagination
64
        ]);
65
    }
66
67
    /**
68
     * List comment - read comment and list answers
@@ 246-271 (lines=26) @@
243
     * @throws \Ffcms\Core\Exception\SyntaxException
244
     * @throws \Ffcms\Core\Exception\NativeException
245
     */
246
    public function actionAnswerlist()
247
    {
248
        // set current page and offset
249
        $page = (int)$this->request->query->get('page');
250
        $offset = $page * self::ITEM_PER_PAGE;
251
252
        // initialize ar answers model
253
        $query = new CommentAnswer();
254
255
        // build pagination list
256
        $pagination = new SimplePagination([
257
            'url' => ['comments/answerlist'],
258
            'page' => $page,
259
            'step' => self::ITEM_PER_PAGE,
260
            'total' => $query->count()
261
        ]);
262
263
        // get result as active records object with offset
264
        $records = $query->orderBy('id', 'desc')->skip($offset)->take(self::ITEM_PER_PAGE)->get();
265
266
        // render output view
267
        return $this->view->render('answer_list', [
268
            'records' => $records,
269
            'pagination' => $pagination
270
        ]);
271
    }
272
273
    /**
274
     * Comment widget global settings

Apps/Controller/Admin/Feedback.php 1 location

@@ 33-58 (lines=26) @@
30
     * @throws \Ffcms\Core\Exception\NativeException
31
     * @throws \Ffcms\Core\Exception\SyntaxException
32
     */
33
    public function actionIndex()
34
    {
35
        // set current page and offset
36
        $page = (int)$this->request->query->get('page');
37
        $offset = $page * self::ITEM_PER_PAGE;
38
39
        // get feedback posts AR table
40
        $query = new FeedbackPost();
41
42
        // build pagination
43
        $pagination = new SimplePagination([
44
            'url' => ['feedback/index'],
45
            'page' => $page,
46
            'step' => self::ITEM_PER_PAGE,
47
            'total' => $query->count()
48
        ]);
49
50
        // build listing objects
51
        $records = $query->orderBy('id', 'desc')->skip($offset)->take(self::ITEM_PER_PAGE)->get();
52
53
        // render output
54
        return $this->view->render('index', [
55
            'records' => $records,
56
            'pagination' => $pagination
57
        ]);
58
    }
59
60
    /**
61
     * Read feedback post and answer and add answer to thread post

Apps/Controller/Admin/User.php 1 location

@@ 37-62 (lines=26) @@
34
     * @throws \Ffcms\Core\Exception\NativeException
35
     * @throws \Ffcms\Core\Exception\SyntaxException
36
     */
37
    public function actionIndex()
38
    {
39
        // init Active Record
40
        $query = new UserRecords();
41
42
        // set current page and offset
43
        $page = (int)$this->request->query->get('page', 0);
44
        $offset = $page * self::ITEM_PER_PAGE;
45
46
        // build pagination
47
        $pagination = new SimplePagination([
48
            'url' => ['user/index'],
49
            'page' => $page,
50
            'step' => self::ITEM_PER_PAGE,
51
            'total' => $query->count()
52
        ]);
53
54
        // build listing objects
55
        $records = $query->orderBy('id', 'desc')->skip($offset)->take(self::ITEM_PER_PAGE)->get();
56
57
        // display viewer
58
        return $this->view->render('index', [
59
            'records' => $records,
60
            'pagination' => $pagination
61
        ]);
62
    }
63
64
    /**
65
     * Edit user profile by id

Apps/Controller/Admin/Profile.php 1 location

@@ 34-59 (lines=26) @@
31
     * @throws \Ffcms\Core\Exception\NativeException
32
     * @throws \Ffcms\Core\Exception\SyntaxException
33
     */
34
    public function actionIndex()
35
    {
36
        // init Active Record
37
        $query = new ProfileRecords();
38
39
        // set current page and offset
40
        $page = (int)$this->request->query->get('page');
41
        $offset = $page * self::ITEM_PER_PAGE;
42
43
        // build pagination
44
        $pagination = new SimplePagination([
45
            'url' => ['profile/index'],
46
            'page' => $page,
47
            'step' => self::ITEM_PER_PAGE,
48
            'total' => $query->count()
49
        ]);
50
51
        // build listing objects
52
        $records = $query->orderBy('id', 'desc')->skip($offset)->take(self::ITEM_PER_PAGE)->get();
53
54
        // display viewer
55
        return $this->view->render('index', [
56
            'records' => $records,
57
            'pagination' => $pagination
58
        ]);
59
    }
60
61
    /**
62
     * Redirect to user controller