. /** * Displays the TinyMCE popup window to insert a Moodle emoticon * * @package tinymce_moodleemoticon * @copyright 2010 David Mudrak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define('NO_MOODLE_COOKIES', true); // Session not used here. require(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/config.php'); $PAGE->set_context(context_system::instance()); $PAGE->set_url('/lib/editor/tinymce/plugins/moodleemoticon/dialog.php'); $emoticonmanager = get_emoticon_manager(); $stringmanager = get_string_manager(); $editor = get_texteditor('tinymce'); $plugin = $editor->get_plugin('moodleemoticon'); $htmllang = get_html_lang(); header('Content-Type: text/html; charset=utf-8'); header('X-UA-Compatible: IE=edge'); ?> <?php print_string('moodleemoticon:desc', 'tinymce_moodleemoticon'); ?> get_emoticons(); // This is tricky - we must somehow include the information about the original // emoticon text so that we can replace the image back with it on editor save. // so we are going to encode the index of the emoticon. this will break when the // admin changes the mapping table while the user has the editor opened // but I am not able to come with better solution at the moment :-/ $index = 0; foreach ($emoticons as $emoticon) { $txt = $emoticon->text; $img = $OUTPUT->render( $emoticonmanager->prepare_renderable_emoticon($emoticon, array('class' => 'emoticon emoticon-index-'.$index))); if ($stringmanager->string_exists($emoticon->altidentifier, $emoticon->altcomponent)) { $alt = get_string($emoticon->altidentifier, $emoticon->altcomponent); } else { $alt = ''; } echo html_writer::tag('tr', html_writer::tag('td', $img, array('style' => 'width:20%;text-align:center;')) . html_writer::tag('td', s($txt), array('style' => 'width:40%;text-align:center;font-family:monospace;')) . html_writer::tag('td', $alt), array( 'class' => 'emoticoninfo emoticoninfo-index-'.$index, ) ); $index++; } ?>