123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <?php
- include_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
- $TBL_INTRODUCTION = Database::get_course_table(TABLE_TOOL_INTRO);
- $intro_editAllowed = $is_allowed_to_edit;
- global $charset;
- $intro_cmdEdit = (empty($_GET['intro_cmdEdit'])?'':$_GET['intro_cmdEdit']);
- $intro_cmdUpdate = isset($_POST['intro_cmdUpdate'])?true:false;
- $intro_cmdDel= (empty($_GET['intro_cmdDel'])?'':$_GET['intro_cmdDel']);
- $intro_cmdAdd= (empty($_GET['intro_cmdAdd'])?'':$_GET['intro_cmdAdd']);
- if (!empty ($GLOBALS["_cid"])) {
- $form = new FormValidator('introduction_text', 'post', api_get_self()."?".api_get_cidreq());
- } else {
- $form = new FormValidator('introduction_text');
- }
- $renderer =& $form->defaultRenderer();
- $renderer->setElementTemplate('<div style="width: 80%; margin: 0px auto; padding-bottom: 10px; ">{element}</div>');
- $toolbar_set = 'Introduction';
- $width = '100%';
- $height = '300';
- global $fck_attribute;
- if (is_array($fck_attribute)) {
- if (isset($fck_attribute['ToolbarSet'])) {
- $toolbar_set = $fck_attribute['ToolbarSet'];
- }
- if (isset($fck_attribute['Width'])) {
- $toolbar_set = $fck_attribute['Width'];
- }
- if (isset($fck_attribute['Height'])) {
- $toolbar_set = $fck_attribute['Height'];
- }
- }
- if (is_array($editor_config)) {
- if (!isset($editor_config['ToolbarSet'])) {
- $editor_config['ToolbarSet'] = $toolbar_set;
- }
- if (!isset($editor_config['Width'])) {
- $editor_config['Width'] = $width;
- }
- if (!isset($editor_config['Height'])) {
- $editor_config['Height'] = $height;
- }
- } else {
- $editor_config = array('ToolbarSet' => $toolbar_set, 'Width' => $width, 'Height' => $height);
- }
- $form->add_html_editor('intro_content', null, null, false, $editor_config);
- $form->addElement('style_submit_button', 'intro_cmdUpdate', get_lang('SaveIntroText'), 'class="save"');
- if ($intro_editAllowed) {
-
- if ( $intro_cmdUpdate ) {
- if ( $form->validate()) {
- $form_values = $form->exportValues();
- $intro_content = Security::remove_XSS(stripslashes(api_html_entity_decode($form_values['intro_content'])), COURSEMANAGERLOWSECURITY);
- if ( ! empty($intro_content) ) {
- $sql = "REPLACE $TBL_INTRODUCTION SET id='$moduleId',intro_text='".Database::escape_string($intro_content)."'";
- Database::query($sql,__FILE__,__LINE__);
- Display::display_confirmation_message(get_lang('IntroductionTextUpdated'),false);
- } else {
- $intro_cmdDel = true;
- }
- } else {
- $intro_cmdEdit = true;
- }
- }
-
- if ($intro_cmdDel) {
- Database::query("DELETE FROM $TBL_INTRODUCTION WHERE id='".$moduleId."'",__FILE__,__LINE__);
- Display::display_confirmation_message(get_lang('IntroductionTextDeleted'));
- }
- }
- $sql = "SELECT intro_text FROM $TBL_INTRODUCTION WHERE id='".$moduleId."'";
- $intro_dbQuery = Database::query($sql,__FILE__,__LINE__);
- $intro_dbResult = Database::fetch_array($intro_dbQuery);
- $intro_content = $intro_dbResult['intro_text'];
- if ($intro_cmdEdit || $intro_cmdAdd) {
- $intro_dispDefault = false;
- $intro_dispForm = true;
- $intro_dispCommand = false;
- } else {
- $intro_dispDefault = true;
- $intro_dispForm = false;
- if ($intro_editAllowed) {
- $intro_dispCommand = true;
- } else {
- $intro_dispCommand = false;
- }
- }
- if ($intro_dispForm) {
- $default['intro_content'] = $intro_content;
- $form->setDefaults($default);
-
- echo '<div id="courseintro" style="width: 100%">';
- $form->display();
- echo '</div>';
- }
- if ($intro_dispDefault) {
-
- $intro_content = text_filter($intro_content);
- if (!empty($intro_content)) {
- echo "<table align='center' style='width: 80%;'><tr><td>$intro_content</td></tr></table>";
- }
- }
- if ($intro_dispCommand) {
- if ( empty($intro_content) ) {
-
- echo "<div id=\"courseintro\"><p>\n";
- if (!empty ($GLOBALS["_cid"])) {
- echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&intro_cmdAdd=1\">\n".get_lang('AddIntro')."</a>\n";
- } else {
- echo "<a href=\"".api_get_self()."?intro_cmdAdd=1\">\n".get_lang('AddIntro')."</a>\n";
- }
- echo "</p>\n</div>";
- } else {
-
- echo "<div id=\"courseintro_icons\"><p>\n";
- if (!empty ($GLOBALS["_cid"])) {
- echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&intro_cmdEdit=1\"><img src=\"".api_get_path(WEB_CODE_PATH)."img/edit.gif\" alt=\"".get_lang('Modify')."\" border=\"0\" /></a>\n";
- echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&intro_cmdDel=1\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."')) return false;\"><img src=\"".api_get_path(WEB_CODE_PATH)."img/delete.gif\" alt=\"".get_lang('Delete')."\" border=\"0\" /></a>\n";
- } else {
- echo "<a href=\"".api_get_self()."?intro_cmdEdit=1\"><img src=\"".api_get_path(WEB_CODE_PATH)."img/edit.gif\" alt=\"".get_lang('Modify')."\" border=\"0\" /></a>\n";
- echo "<a href=\"".api_get_self()."?intro_cmdDel=1\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."')) return false;\"><img src=\"".api_get_path(WEB_CODE_PATH)."img/delete.gif\" alt=\"".get_lang('Delete')."\" border=\"0\" /></a>\n";
- }
- echo "</p>\n</div>";
- }
- }
- ?>
|