Exemplo n.º 1
0
 function edit()
 {
     $registry = Registry::getInstance();
     $locales = LocaleManager::getLocales();
     $course = new Course(intval($_GET['id']));
     $owner = new Admin($course->ownerId);
     if ($_POST['action'] == 'save') {
         //d($_POST, 1);
         $course->ownerId = intval($_SESSION['admin']['id']);
         $course->state = intval($_POST['state'] == 'on');
         foreach (array_keys($locales) as $localeId) {
             $course->l10n->loadDataFromArray($localeId, ['name' => trim($_POST['name_' . $localeId]), 'meta' => trim($_POST['meta_' . $localeId]), 'description' => trim($_POST['description_' . $localeId]), 'brief' => trim($_POST['brief_' . $localeId]), 'url' => trim($_POST['url_' . $localeId]), 'title' => trim($_POST['title_' . $localeId]), 'state' => intval($_POST['state_' . $localeId])]);
         }
         $course->save();
         header('Location: /cms/course/list');
         exit;
     } else {
         $i18n = new I18n($registry->get('i18n_path') . 'course.xml');
         $data = ['course' => $course, 'lessons' => Lesson::getList($course->id), 'owner' => $owner];
         $renderer = new Renderer(Page::MODE_NORMAL);
         $pTitle = $i18n->get($course->id ? 'update_mode' : 'append_mode');
         $renderer->page->set('title', $pTitle)->set('h1', $pTitle)->set('content', CourseEditView::get($data));
         $renderer->loadPage();
         $renderer->output();
     }
 }
Exemplo n.º 2
0
 static function createCourse($ownerId)
 {
     $course = new Course();
     $course->ownerId = $ownerId;
     $course->state = 8;
     $course->l10n = self::createLocale();
     $course->save();
     return $course;
 }