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(); } }
function edit() { $registry = Registry::getInstance(); $application = Application::getInstance(); $locale = $registry->get('locale'); $locales = LocaleManager::getLocales(); $exercise = new Exercise(intval($_GET['id'])); if ($_POST['action'] == 'save') { //d($_POST, 1); $exercise->name = trim($_POST['name']); $exercise->description = trim($_POST['description']); $exercise->controller = trim($_POST['controller']); $exercise->configTemplate = trim($_POST['config_template']); $exercise->save(); header('Location: /cms/exercise/list'); exit; } else { $i18n = new I18n($registry->get('i18n_path') . 'exercise.xml'); $data = ['exercise' => $exercise]; $renderer = new Renderer(Page::MODE_NORMAL); $pTitle = $i18n->get($exercise->id ? 'update_mode' : 'append_mode'); $renderer->page->set('title', $pTitle)->set('h1', $pTitle)->set('content', ExerciseEditView::get($data)); $renderer->loadPage(); $renderer->output(); } }
function edit() { $registry = Registry::getInstance(); $locales = LocaleManager::getLocales(); $id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT); if (!$id) { $lesson = new Lesson(filter_input(INPUT_GET, 'lesson_id', FILTER_VALIDATE_INT)); $lessonId = $lesson->id; if (!$lessonId) { header('Location: /cms/course/list'); exit; } } $stage = new Stage($id); if ($_POST['action'] == 'save') { //d($_POST, 1); if (!$stage->id) { $exercise = new Exercise(filter_input(INPUT_POST, 'exercise_id', FILTER_VALIDATE_INT)); $exerciseId = $exercise->id; //die(print_r($_POST)); if (!$exerciseId) { header('Location: /cms/course/list'); exit; } $stage->lessonId = $lessonId; $stage->exerciseId = $exerciseId; $stage->settings = $exercise->configTemplate; } foreach (array_keys($locales) as $localeId) { $stage->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])]); } $stage->name = filter_input(INPUT_POST, 'name'); $stage->save(); header('Location: /cms/lesson/edit?id=' . $stage->lessonId); exit; } else { $i18n = new I18n($registry->get('i18n_path') . 'stage.xml'); $data['stage'] = $stage; $data['materials'] = Material::getList($this->id); if ($stage->id) { $exercise = new Exercise($stage->exerciseId); $data['exerciseName'] = $exercise->name; } else { $data['exercises'] = Exercise::getList(); } $renderer = new Renderer(Page::MODE_NORMAL); $pTitle = $i18n->get($lesson->id ? 'update_mode' : 'append_mode'); $renderer->page->set('title', $pTitle)->set('h1', $pTitle)->set('content', StageEditView::get($data)); $renderer->loadPage(); $renderer->output(); } }
static function get($data) { $registry = Registry::getInstance(); $application = Application::getInstance(); $localeId = $registry->get('locale'); $localeData = LocaleManager::getLocaleData($localeId); $tpl = new Template($registry->get('template_path') . 'course.htm'); $tpli = new template($registry->get('template_path') . 'course_item.htm'); $listItems = ''; foreach ($data['list'] as $item) { $listItems .= $tpli->apply(['id' => $item->id, 'name' => $item->l10n->get('name', $localeId), 'owner' => $data['ownerList'][$item->ownerId]->name, 'dateCreate' => date($localeData['dateFormat'], $item->dateCreate), 'dateUpdate' => $item->dateUpdate ? date($localeData['dateFormat'], $item->dateUpdate) : '', 'active' => $item->state, 'rights' => $item->rights]); } return $tpl->apply(['items' => $listItems, 'site_root' => $application->siteRoot]); }
static function get($data) { $application = Application::getInstance(); $registry = Registry::getInstance(); $i18n = new I18n($registry->get('i18n_path') . 'admin.xml'); $localeData = LocaleManager::getLocaleData($registry->get('locale')); $tpl = new Template($registry->get('template_path') . 'admin.htm'); $tpli = new template($registry->get('template_path') . 'admin_item.htm'); $listItems = ''; foreach ($data['list'] as $item) { $listItems .= $tpli->apply(['id' => $item->id, 'description' => $item->description, 'email' => $item->email, 'login' => $item->login, 'name' => $item->name, 'state' => $i18n->get('state' . $item->state), 'rights' => $item->rights, 'dateCreate' => date($localeData['dateFormat'], $item->dateCreate), 'dateLogin' => $item->dateLogin ? date($localeData['dateFormat'], $item->dateLogin) : '', 'locale' => $item->locale]); } return $tpl->apply(['items' => $listItems, 'site_root' => $application->siteRoot]); }
static function get($data) { $application = Application::getInstance(); $registry = Registry::getInstance(); $locale = $registry->get('locale'); $locales = LocaleManager::getLocales(); $tplso = new Template($registry->get('template_path') . 'select_option.htm'); $admin = $data['admin']; $localeItems = ''; foreach ($locales as $locale => $localeData) { $localeItems .= $tplso->apply(['name' => $localeData['name'], 'value' => $locale, 'selected' => $locale == $admin->locale]); } $localeData = LocaleManager::getLocaleData($registry->get('locale')); $tpl = new Template($registry->get('template_path') . 'admin_edit.htm'); return $tpl->apply(['id' => $admin->id, 'description' => htmlspecialchars($admin->description), 'email' => htmlspecialchars($admin->email), 'login' => htmlspecialchars($admin->login), 'name' => htmlspecialchars($admin->name), 'rights' => $admin->rights, 'state' => $admin->state, 'localeItems' => $localeItems, 'dateCreate' => date($localeData['dateFormat'], $admin->dateCreate), 'dateLogin' => $admin->dateLogin ? date($localeData['dateFormat'] . ' H:i', $admin->dateLogin) : '', 'site_root' => $application->siteRoot]); }
static function get($data) { $registry = Registry::getInstance(); $application = Application::getInstance(); $locales = LocaleManager::getLocales(); $locale = $registry->get('locale'); $tpl = new Template($registry->get('template_path') . 'stage_edit.htm'); $tplTab = new Template($registry->get('template_path') . 'stage_edit_tab.htm'); $tplTabContent = new Template($registry->get('template_path') . 'stage_edit_tab_content.htm'); $tplMaterialItem = new Template($registry->get('template_path') . 'material_item.htm'); $tplMaterialL10hHeaderItem = new Template($registry->get('template_path') . 'material_l10n_header_item.htm'); $tplMaterialL10nItem = new Template($registry->get('template_path') . 'material_l10n_item.htm'); $tplMaterialAddItem = new Template($registry->get('template_path') . 'material_add_item.htm'); $tplMaterialAddL10nItem = new Template($registry->get('template_path') . 'material_add_l10n_item.htm'); $tplso = new Template($registry->get('template_path') . 'select_option.htm'); $stage = $data['stage']; $tabItems = ''; $tabContentItems = ''; $materialL10nItems = ''; foreach ($locales as $localeId => $localeData) { $tabItems .= $tplTab->apply(['localeId' => $localeId, 'name' => $localeData['name']]); $tabContentItems .= $tplTabContent->apply(['name' => htmlspecialchars($stage->l10n->get('name', $localeId)), 'meta' => htmlspecialchars($stage->l10n->get('meta', $localeId)), 'description' => htmlspecialchars($stage->l10n->get('description', $localeId)), 'brief' => htmlspecialchars($stage->l10n->get('brief', $localeId)), 'url' => htmlspecialchars($stage->l10n->get('url', $localeId)), 'title' => htmlspecialchars($stage->l10n->get('title', $localeId)), 'localeId' => $localeId]); $materialL10nHeaderItems .= $tplMaterialL10hHeaderItem->apply(['locale' => $localeData['name']]); } $materialItems = ''; foreach ($data['materials'] as $materialId => $material) { $materialL10nItems = ''; foreach ($locales as $localeId => $localeData) { $materialL10nItems .= $tplMaterialL10nItem->apply(['localeId' => $localeId, 'materialId' => $material->id, 'mimeType' => $material->l10n->get('mimeType', $localeId)]); } $materialItems .= $tplMaterialItem->apply(['id' => $materialId, 'hash' => $material->hash, 'name' => $material->l10n->get('name', $registry->get('locale')), 'description' => $material->l10n->get('description', $registry->get('locale')), 'l10nItems' => $materialL10nItems]); } $materialAddL10nItems = ''; foreach ($locales as $localeId => $localeData) { $materialAddL10nItems .= $tplMaterialAddL10nItem->apply(['materialId' => 0, 'localeId' => $localeId]); } $materialItems = $tplMaterialAddItem->apply(['l10nItems' => $materialAddL10nItems]); if (!$stage->id) { $exerciseItems = ''; foreach ($data['exercises'] as $exerciseId => $exercise) { $exerciseItems .= $tplso->apply(['name' => $exercise->name, 'value' => $exerciseId, 'selected' => FALSE]); } } return $tpl->apply(['id' => $stage->id, 'lessonId' => $data['lessonId'], 'name' => $stage->name, 'config' => $stage->settings, 'tabItems' => $tabItems, 'tabContentItems' => $tabContentItems, 'materialL10nHeaderItems' => $materialL10nHeaderItems, 'materialItems' => $materialItems, 'exerciseName' => $data['exerciseName'], 'exerciseItems' => $exerciseItems, 'site_root' => $application->siteRoot]); }
function edit() { $registry = Registry::getInstance(); $application = Application::getInstance(); $locale = $registry->get('locale'); $locales = LocaleManager::getLocales(); $id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT); $lesson = new Lesson($id); if (!$lesson->id) { $course = new Course(filter_input(INPUT_GET, 'course_id', FILTER_VALIDATE_INT)); } else { $course = new Course($lesson->courseId); } if (!$course->id) { header('Location: /cms/course/list'); exit; } if ('save' == filter_input(INPUT_POST, 'action')) { if (!$lesson->id) { $lesson->courseId = $course->id; } foreach (array_keys($locales) as $localeId) { $lesson->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])]); } $lesson->save(); header('Location: /cms/course/edit?id=' . $lesson->courseId); exit; } else { $i18n = new I18n($registry->get('i18n_path') . 'lesson.xml'); $data['lesson'] = $lesson; $data['exercises'] = Exercise::getList(); $data['stages'] = Stage::getList($lesson->id); $renderer = new Renderer(Page::MODE_NORMAL); $pTitle = $i18n->get($lesson->id ? 'update_mode' : 'append_mode'); $renderer->page->set('title', $pTitle)->set('h1', $pTitle)->set('content', LessonEditView::get($data)); $renderer->loadPage(); $renderer->output(); } }
static function get($data) { $registry = Registry::getInstance(); $application = Application::getInstance(); $locale = $registry->get('locale'); $locales = LocaleManager::getLocales(); $tpl = new Template($registry->get('template_path') . 'course_edit.htm'); $tplTab = new Template($registry->get('template_path') . 'course_edit_tab.htm'); $tplTabContent = new Template($registry->get('template_path') . 'course_edit_tab_content.htm'); $tplLessonItem = new Template($registry->get('template_path') . 'lesson_item.htm'); $course = $data['course']; $tabItems = ''; $tabContentItems = ''; foreach ($locales as $localeId => $localeData) { $tabItems .= $tplTab->apply(['localeId' => $localeId, 'name' => $localeData['name']]); $tabContentItems .= $tplTabContent->apply(['name' => htmlspecialchars($course->l10n->get('name', $localeId)), 'meta' => htmlspecialchars($course->l10n->get('meta', $localeId)), 'description' => htmlspecialchars($course->l10n->get('description', $localeId)), 'brief' => htmlspecialchars($course->l10n->get('brief', $localeId)), 'url' => htmlspecialchars($course->l10n->get('url', $localeId)), 'title' => htmlspecialchars($course->l10n->get('title', $localeId)), 'state' => $course->l10n->get('state', $localeId), 'localeId' => $localeId]); } $lessonItems = ''; foreach ($data['lessons'] as $lessonId => $lesson) { $lessonItems .= $tplLessonItem->apply(['id' => $lessonId, 'order' => $lesson->order, 'name' => $lesson->l10n->get('name', $locale)]); } return $tpl->apply(['id' => $course->id, 'courseName' => $course->l10n->get('name', $locale), 'state' => $course->state, 'ownerName' => $data['owner']->name ? $data['owner']->name : $_SESSION['admin']['name'], 'tabItems' => $tabItems, 'tabContentItems' => $tabContentItems, 'dateCreate' => $course->dateCreate ? date($localeData['dateFormat'], $course->dateCreate) : '', 'dateUpdate' => $course->dateUpdate ? date($localeData['dateFormat'] . ' H:i', $course->dateUpdate) : '', 'lessonItems' => $lessonItems, 'site_root' => $application->siteRoot]); }
static function get($data) { $application = Application::getInstance(); $registry = Registry::getInstance(); $tpl = new Template($registry->get('template_path') . 'lesson_edit.htm'); $tplTab = new Template($registry->get('template_path') . 'lesson_edit_tab.htm'); $tplTabContent = new Template($registry->get('template_path') . 'lesson_edit_tab_content.htm'); $tplStageItem = new Template($registry->get('template_path') . 'stage_item.htm'); $locales = LocaleManager::getLocales(); $locale = $registry->get('locale'); $tabItems = ''; $tabContentItems = ''; $lesson = $data['lesson']; foreach ($locales as $localeId => $localeData) { $tabItems .= $tplTab->apply(['localeId' => $localeId, 'name' => $localeData['name']]); $tabContentItems .= $tplTabContent->apply(['name' => htmlspecialchars($lesson->l10n->get('name', $localeId)), 'meta' => htmlspecialchars($lesson->l10n->get('meta', $localeId)), 'description' => htmlspecialchars($lesson->l10n->get('description', $localeId)), 'brief' => htmlspecialchars($lesson->l10n->get('brief', $localeId)), 'url' => htmlspecialchars($lesson->l10n->get('url', $localeId)), 'title' => htmlspecialchars($lesson->l10n->get('title', $localeId)), 'localeId' => $localeId]); } $exercises = $data['exercises']; $stageItems = ''; foreach ($data['stages'] as $stageId => $stage) { $stageItems .= $tplStageItem->apply(['id' => $stageId, 'order' => $stage->order, 'name' => $stage->name, 'exerciseName' => $exercises[$stage->exerciseId]->name]); } return $tpl->apply(['id' => $lesson->id, 'courseId' => $data['courseId'], 'name' => $lesson->l10n->get('name', $locale), 'tabItems' => $tabItems, 'tabContentItems' => $tabContentItems, 'stageItems' => $stageItems, 'site_root' => $application->siteRoot]); }
function getLocales() { return LocaleManager::getLocales(); }
$basePath = implode(DIRECTORY_SEPARATOR, $basePathComponents) . DIRECTORY_SEPARATOR; $registry->set('db', $db); $registry->set('setup', new Setup()); $registry->set('base_path', $basePath); $registry->set('i18n_path', $basePath . 'i18n' . DIRECTORY_SEPARATOR); $registry->set('site_root_absolute', $site_root_absolute); $registry->set('template_path', $site_root_absolute . 'tpl' . DIRECTORY_SEPARATOR); $registry->set('site_image_path', $site_root_absolute . 'img' . DIRECTORY_SEPARATOR); $registry->set('material_path', $basePath . 'material' . DIRECTORY_SEPARATOR); $registry->set('site_attachment_root', $site_root_absolute . 'attachments' . DIRECTORY_SEPARATOR); $registry->set('site_css_root', $site_root_absolute . 'css' . DIRECTORY_SEPARATOR); $registry->set('site_js_root', $site_root_absolute . 'js' . DIRECTORY_SEPARATOR); $registry->set('counters_enabled', true); $registry->set('i18n_path', $basePath . 'i18n/'); $registry->set('template_path', $registry->get('i18n_path') . 'templates' . DIRECTORY_SEPARATOR . $registry->get('locale') . DIRECTORY_SEPARATOR); LocaleManager::setApplicationLocale(); @(include_once 'variables.local.php'); $registry->set('site_name', 'wbt.com'); $registry->set('site_protocol', $site_protocol); $registry->set('site_root', $site_protocol . $_SERVER['HTTP_HOST'] . '/'); $registry->set('site_attachment_path', 'attachments/'); $registry->set('site_i18n_root', $site_root_absolute . 'i18n/'); parse_str($_SERVER["REDIRECT_QUERY_STRING"], $__GET); if (get_magic_quotes_gpc()) { $_POST = Utils::stripslashes_deep($_POST); $_GET = Utils::stripslashes_deep($_GET); // $__GET = Utils::stripslashes_deep($__GET); $_COOKIE = Utils::stripslashes_deep($_COOKIE); $_REQUEST = Utils::stripslashes_deep($_REQUEST); } $registry->set('attachment_settings', array('news' => array('name' => 'Новости', 'list_page' => 'news.php', 'edit_page' => 'news_edit.php', 'path' => 'news/'), 'block' => array('name' => 'Блоки', 'list_page' => 'block.php', 'edit_page' => 'block_edit.php', 'path' => 'block/'), 'page' => array('name' => 'Страницы', 'list_page' => 'page.php', 'edit_page' => 'page_edit.php', 'path' => 'page/'), 'tape' => array('name' => 'Ленты', 'list_page' => 'tape.php', 'edit_page' => 'tape_edit.php', 'path' => 'tape/'), 'template' => array('name' => 'Шаблоны страниц', 'list_page' => 'template.php', 'edit_page' => 'template_edit.php', 'path' => 'template/'), 'email_template' => array('name' => 'Шаблоны уведомлений', 'list_page' => 'email_template.php', 'edit_page' => 'email_template_edit.php', 'path' => 'email_template/')));
static function createLocale() { $locales = LocaleManager::getLocales(); $locale = new StageL10n(); foreach (array_keys($locales) as $localeId) { $l10n[$localeId] = (object) ['name' => 'name_' . rand() . '_' . $localeId, 'brief' => 'brief_' . rand() . '_' . $localeId, 'description' => 'unitTest_description_' . rand() . '_' . $localeId, 'meta' => 'meta_' . rand() . '_' . $localeId, 'title' => 'title_' . rand() . '_' . $localeId, 'url' => 'url_' . rand() . ' ' . $localeId]; $locale->load($localeId, $l10n[$localeId]); } return $locale; }
static function updateLocale($sourceFile, $locale) { $locales = LocaleManager::getLocales(); $extension = pathinfo($sourceFile, PATHINFO_EXTENSION); $path = pathinfo($sourceFile, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR; foreach (array_keys($locales) as $localeId) { $localeFileName = $path . "unitTest_" . $localeId . '.' . $extension; copy($sourceFile, $localeFileName); $locale->prepareToReceiveFile($localeFileName, basename($sourceFile), $localeId); } #print_r($locale); #echo PHP_EOL . self::getTestFileSpec() . PHP_EOL; return $locale; }