Ejemplo n.º 1
0
 /**
  * Display form
  *
  * @param $cancelUrl string url of the cancel button
  * @return string html output of form
  */
 public function displayForm($cancelUrl = null)
 {
     JavascriptLoader::getInstance()->load('course_form');
     $languageList = get_language_to_display_list('availableLanguagesForCourses');
     $categoriesList = claroCategory::getAllCategoriesFlat();
     $linkedCategoriesListHtml = '';
     // Categories linked to the course
     $unlinkedCategoriesListHtml = '';
     // Other categories (not linked to the course)
     foreach ($categoriesList as $category) {
         // Is that category linked to the current course or not ?
         $match = false;
         foreach ($this->categories as $searchCategory) {
             if ($category['id'] == (int) $searchCategory->id) {
                 $match = true;
                 break;
             } else {
                 $match = false;
             }
         }
         // Dispatch in the lists
         if ($match) {
             $linkedCategoriesListHtml .= '<option ' . (!$category['visible'] ? 'class="hidden" ' : '') . 'value="' . $category['id'] . '">' . $category['path'] . '</option>' . "\n";
         } else {
             if ($category['canHaveCoursesChild'] || claro_is_platform_admin()) {
                 $unlinkedCategoriesListHtml .= '<option ' . (!$category['visible'] ? 'class="hidden" ' : '') . 'value="' . $category['id'] . '">' . $category['path'] . '</option>' . "\n";
             }
         }
     }
     $publicDisabled = !(get_conf('allowPublicCourses', true) || claro_is_platform_admin()) ? ' disabled="disabled"' : '';
     $publicCssClass = !(get_conf('allowPublicCourses', true) || claro_is_platform_admin()) ? ' class="notice"' : '';
     $publicMessage = $this->access != 'public' && !(get_conf('allowPublicCourses', true) || claro_is_platform_admin()) ? '<br /><span class="notice">' . get_lang('If you need to create a public course, please contact the platform administrator') . '</span>' : '';
     $cancelUrl = is_null($cancelUrl) ? get_path('clarolineRepositoryWeb') . 'course/index.php?cid=' . claro_htmlspecialchars($this->courseId) : $cancelUrl;
     $template = new CoreTemplate('course_form.tpl.php');
     $template->assign('formAction', $_SERVER['PHP_SELF']);
     $template->assign('relayContext', claro_form_relay_context());
     $template->assign('course', $this);
     $template->assign('linkedCategoriesListHtml', $linkedCategoriesListHtml);
     $template->assign('unlinkedCategoriesListHtml', $unlinkedCategoriesListHtml);
     $template->assign('languageList', $languageList);
     $template->assign('publicDisabled', $publicDisabled);
     $template->assign('publicCssClass', $publicCssClass);
     $template->assign('publicMessage', $publicMessage);
     $template->assign('cancelUrl', $cancelUrl);
     $template->assign('nonRootCategoryRequired', !get_conf('clcrs_rootCategoryAllowed', true));
     return $template->render();
 }