Code Duplication    Length = 29-35 lines in 2 locations

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

@@ 874-908 (lines=35) @@
871
     *
872
     * @return bool
873
     */
874
    public function returnMyCourseCategories($user_id, $filter, $page)
875
    {
876
        if (empty($user_id)) {
877
            return false;
878
        }
879
        $loadDirs = api_get_setting('document.show_documents_preview') == 'true' ? true : false;
880
        $start    = ($page - 1) * $this->maxPerPage;
881
882
        $nbResults = (int)CourseManager::displayPersonalCourseCategories($user_id, $filter, $loadDirs, true);
883
884
        $html = CourseManager::displayPersonalCourseCategories(
885
            $user_id,
886
            $filter,
887
            $loadDirs,
888
            false,
889
            $start,
890
            $this->maxPerPage
891
        );
892
893
        $adapter    = new FixedAdapter($nbResults, array());
894
        $pagerfanta = new Pagerfanta($adapter);
895
        $pagerfanta->setMaxPerPage($this->maxPerPage); // 10 by default
896
        $pagerfanta->setCurrentPage($page); // 1 by default
897
898
        $this->app['pagerfanta.view.router.name']   = 'userportal';
899
        $this->app['pagerfanta.view.router.params'] = array(
900
            'filter' => $filter,
901
            'type'   => 'courses',
902
            'page'   => $page
903
        );
904
        $this->app['template']->assign('pagination', $pagerfanta);
905
906
        return $html;
907
908
    }
909
910
    function returnSpecialCourses($user_id, $filter, $page)
911
    {
@@ 910-938 (lines=29) @@
907
908
    }
909
910
    function returnSpecialCourses($user_id, $filter, $page)
911
    {
912
        if (empty($user_id)) {
913
            return false;
914
        }
915
916
        $loadDirs = api_get_setting('document.show_documents_preview') == 'true' ? true : false;
917
        $start    = ($page - 1) * $this->maxPerPage;
918
919
        $nbResults = CourseManager::displaySpecialCourses($user_id, $filter, $loadDirs, true);
920
921
        $html = CourseManager::displaySpecialCourses($user_id, $filter, $loadDirs, false, $start, $this->maxPerPage);
922
        if (!empty($html)) {
923
924
            $adapter    = new FixedAdapter($nbResults, array());
925
            $pagerfanta = new Pagerfanta($adapter);
926
            $pagerfanta->setMaxPerPage($this->maxPerPage); // 10 by default
927
            $pagerfanta->setCurrentPage($page); // 1 by default
928
            $this->app['pagerfanta.view.router.name']   = 'userportal';
929
            $this->app['pagerfanta.view.router.params'] = array(
930
                'filter' => $filter,
931
                'type'   => 'courses',
932
                'page'   => $page
933
            );
934
            $this->app['template']->assign('pagination', $pagerfanta);
935
        }
936
937
        return $html;
938
    }
939
940
    /**
941
    * The most important function here, prints the session and course list (user_portal.php)