Code Duplication    Length = 29-35 lines in 2 locations

src/Chamilo/CoreBundle/Framework/PageController.php 2 locations

@@ 614-648 (lines=35) @@
611
     *
612
     * @return bool
613
     */
614
    public function returnMyCourseCategories($user_id, $filter, $page)
615
    {
616
        if (empty($user_id)) {
617
            return false;
618
        }
619
        $loadDirs = api_get_setting('document.show_documents_preview') == 'true' ? true : false;
620
        $start    = ($page - 1) * $this->maxPerPage;
621
622
        $nbResults = (int)CourseManager::displayPersonalCourseCategories($user_id, $filter, $loadDirs, true);
623
624
        $html = CourseManager::displayPersonalCourseCategories(
625
            $user_id,
626
            $filter,
627
            $loadDirs,
628
            false,
629
            $start,
630
            $this->maxPerPage
631
        );
632
633
        $adapter    = new FixedAdapter($nbResults, array());
634
        $pagerfanta = new Pagerfanta($adapter);
635
        $pagerfanta->setMaxPerPage($this->maxPerPage); // 10 by default
636
        $pagerfanta->setCurrentPage($page); // 1 by default
637
638
        $this->app['pagerfanta.view.router.name']   = 'userportal';
639
        $this->app['pagerfanta.view.router.params'] = array(
640
            'filter' => $filter,
641
            'type'   => 'courses',
642
            'page'   => $page
643
        );
644
        $this->app['template']->assign('pagination', $pagerfanta);
645
646
        return $html;
647
648
    }
649
650
    function returnSpecialCourses($user_id, $filter, $page)
651
    {
@@ 650-678 (lines=29) @@
647
648
    }
649
650
    function returnSpecialCourses($user_id, $filter, $page)
651
    {
652
        if (empty($user_id)) {
653
            return false;
654
        }
655
656
        $loadDirs = api_get_setting('document.show_documents_preview') == 'true' ? true : false;
657
        $start    = ($page - 1) * $this->maxPerPage;
658
659
        $nbResults = CourseManager::displaySpecialCourses($user_id, $filter, $loadDirs, true);
660
661
        $html = CourseManager::displaySpecialCourses($user_id, $filter, $loadDirs, false, $start, $this->maxPerPage);
662
        if (!empty($html)) {
663
664
            $adapter    = new FixedAdapter($nbResults, array());
665
            $pagerfanta = new Pagerfanta($adapter);
666
            $pagerfanta->setMaxPerPage($this->maxPerPage); // 10 by default
667
            $pagerfanta->setCurrentPage($page); // 1 by default
668
            $this->app['pagerfanta.view.router.name']   = 'userportal';
669
            $this->app['pagerfanta.view.router.params'] = array(
670
                'filter' => $filter,
671
                'type'   => 'courses',
672
                'page'   => $page
673
            );
674
            $this->app['template']->assign('pagination', $pagerfanta);
675
        }
676
677
        return $html;
678
    }
679
680
    /**
681
    * The most important function here, prints the session and course list (user_portal.php)