$values['group'] = isset($values['group']) ? $values['group'] : '0'; $form->addElement('checkbox', 'send_mail', null, get_lang('SendMail')); if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') { $form->addElement('checkbox', 'add_to_calendar', null, get_lang('AddToCalendar')); $text = get_lang('AddNews'); $class = 'add'; $form->addElement('hidden', 'action', 'add'); } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') { $text = get_lang('EditNews'); $class = 'save'; $form->addElement('hidden', 'action', 'edit'); } $form->addElement('checkbox', 'send_email_test', null, get_lang('SendOnlyAnEmailToMySelfToTest')); $form->addElement('style_submit_button', 'submit', $text, 'class="' . $class . '"'); if (api_get_setting('wcag_anysurfer_public_pages') == 'true') { $values['content'] = WCAG_Rendering::HTML_to_text($values['content']); } $form->setDefaults($values); if ($form->validate()) { $values = $form->exportValues(); if (!isset($values['visible_teacher'])) { $values['visible_teacher'] = false; } if (!isset($values['visible_student'])) { $values['visible_student'] = false; } if (!isset($values['visible_guest'])) { $values['visible_guest'] = false; } if ($values['lang'] == 'all') { $values['lang'] = null;
/** * It's used for adding a course description, * render to listing or add view */ public function add() { $course_description = new CourseDescription(); $session_id = api_get_session_id(); $course_description->set_session_id($session_id); $data = array(); if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { if (!empty($_POST['title']) && !empty($_POST['contentDescription'])) { $check = Security::check_token(); if ($check) { $title = $_POST['title']; if (api_get_setting('wcag_anysurfer_public_pages') == 'true') { $content = WCAG_Rendering::prepareXHTML(); } else { $content = $_POST['contentDescription']; } $description_type = $_POST['description_type']; if ($description_type >= ADD_BLOCK) { $course_description->set_description_type($description_type); $course_description->set_title($title); $course_description->set_content($content); $affected_rows = $course_description->insert(api_get_course_int_id()); } Security::clear_token(); } if ($affected_rows) { $message['add'] = true; } $this->listing(false, $message); } else { $data['error'] = 1; $data['default_description_titles'] = $course_description->get_default_description_title(); $data['default_description_title_editable'] = $course_description->get_default_description_title_editable(); $data['default_description_icon'] = $course_description->get_default_description_icon(); $data['question'] = $course_description->get_default_question(); $data['information'] = $course_description->get_default_information(); $data['description_title'] = $_POST['title']; $data['description_content'] = $_POST['contentDescription']; $data['description_type'] = $_POST['description_type']; $this->view->set_data($data); $this->view->set_layout('layout'); $this->view->set_template('add'); $this->view->render(); } } else { $data['default_description_titles'] = $course_description->get_default_description_title(); $data['default_description_title_editable'] = $course_description->get_default_description_title_editable(); $data['default_description_icon'] = $course_description->get_default_description_icon(); $data['question'] = $course_description->get_default_question(); $data['information'] = $course_description->get_default_information(); $data['description_type'] = $course_description->get_max_description_type(); // render to the view $this->view->set_data($data); $this->view->set_layout('layout'); $this->view->set_template('add'); $this->view->render(); } }
foreach ($_languages['name'] as $key => $value) { $english_name = $_languages['folder'][$key]; if ($language == $english_name) { $html .= '<option value="' . $english_name . '" selected="selected">' . $value . '</option>'; } else { $html .= '<option value="' . $english_name . '">' . $value . '</option>'; } } $html .= '</select></td></tr>'; $form->addElement('html', $html); } if (api_get_setting('wcag_anysurfer_public_pages') == 'true') { //TODO: review these lines // Print WCAG-specific HTML editor $html = '<tr><td>'; $html .= WCAG_Rendering::create_xhtml($open); $html .= '</td></tr>'; $form->addElement('html', $html); } else { $default[$name] = str_replace('{rel_path}', api_get_path(REL_PATH), $open); $form->add_html_editor($name, '', true, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400')); } $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"'); $form->setDefaults($default); $form->display(); break; default: // When no action applies, default page to update campus homepage ?> <table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr>
// display form $form = new FormValidator('course_description', 'POST', 'index.php?action=edit&id=' . $original_id . '&description_type=' . $description_type . '&' . api_get_cidreq()); $form->addElement('header', '', $header); $form->addElement('hidden', 'id', $original_id); $form->addElement('hidden', 'description_type', $description_type); $form->addElement('hidden', 'sec_token', $token); $form->add_textfield('title', get_lang('Title'), true, array('size' => '50')); $form->applyFilter('title', 'html_filter'); if (api_get_setting('wcag_anysurfer_public_pages') == 'true') { WCAG_rendering::prepare_admin_form($description_content, $form); } else { $form->add_html_editor('contentDescription', get_lang('Content'), true, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200')); } $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"'); // Set some default values $default['title'] = Security::remove_XSS($description_title); $default['contentDescription'] = Security::remove_XSS($description_content, COURSEMANAGERLOWSECURITY); $default['description_type'] = $description_type; $form->setDefaults($default); if (isset($question[$description_type])) { $message = '<strong>' . get_lang('QuestionPlan') . '</strong><br />'; $message .= $question[$description_type]; Display::display_normal_message($message, false); } if (api_get_setting('wcag_anysurfer_public_pages') == 'true') { echo WCAG_Rendering::editor_header(); } $form->display(); if (api_get_setting('wcag_anysurfer_public_pages') == 'true') { echo WCAG_Rendering::editor_footer(); }
function &create_xhtml($xhtml) { $values = WCAG_Rendering::extract_data($xhtml); $xhtml = WCAG_Rendering::editor_header(); $xhtml .= get_lang('WCAGContent') . '<br />'; $xhtml .= '<textarea name="text">' . $values['text'] . '</textarea>'; $xhtml .= get_lang('WCAGImage') . '<br />'; $xhtml .= '<input type="text" name="imagefile" value="' . $values['imagefile'] . '"/>'; $xhtml .= '<br />'; $xhtml .= '<a href="#" onclick="OpenFileBrowser (\'' . api_get_path(WEB_PATH) . 'main/inc/lib/fckeditor/' . 'editor/plugins/ImageManagerStandalone/genericManager.php?uploadPath=/\');">' . get_lang('SelectPicture') . '</a>'; $xhtml .= '<br />'; $xhtml .= get_lang('WCAGLabel') . '<br />'; $xhtml .= '<input type="text" name="imageLabel" value="' . $values['imageLabel'] . '"/>'; $xhtml .= get_lang('WCAGLink') . '<br />'; $xhtml .= '<input type="text" name="link" value="' . $values['link'] . '"/>'; $xhtml .= get_lang('WCAGLinkLabel') . '<br />'; $xhtml .= '<input type="text" name="linkLabel" value="' . $values['linkLabel'] . '"/>'; $xhtml .= WCAG_Rendering::editor_footer(); return $xhtml; }
if ($form->validate()) { $values = $form->exportValues(); if (!isset($values['visible_teacher'])) { $values['visible_teacher'] = false; } if (!isset($values['visible_student'])) { $values['visible_student'] = false; } if (!isset($values['visible_guest'])) { $values['visible_guest'] = false; } if ($values['lang'] == 'all') { $values['lang'] = null; } if (api_get_setting('wcag_anysurfer_public_pages') == 'true') { $values['content'] = WCAG_Rendering::text_to_HTML($values['content']); } switch ($values['action']) { case 'add': $announcement_id = SystemAnnouncementManager::add_announcement($values['title'], $values['content'], $values['start'], $values['end'], $values['visible_teacher'], $values['visible_student'], $values['visible_guest'], $values['lang'], $values['send_mail'], $values['add_to_calendar']); if ($announcement_id !== false) { SystemAnnouncementManager::announcement_for_groups($announcement_id, array($values['group'])); Display::display_confirmation_message(get_lang('AnnouncementAdded')); } else { $show_announcement_list = false; $form->display(); } break; case 'edit': if (SystemAnnouncementManager::update_announcement($values['id'], $values['title'], $values['content'], $values['start'], $values['end'], $values['visible_teacher'], $values['visible_student'], $values['visible_guest'], $values['lang'], $values['send_mail'])) { SystemAnnouncementManager::announcement_for_groups($values['id'], array($values['group']));