. /** * Displays the TinyMCE popup window to insert a Moodle emoticon * * @package tinymceplugin * @subpackage 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 define('NO_UPGRADE_CHECK', true); // Ignore upgrade check require_once(dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))))) . '/config.php'); $PAGE->set_context(get_system_context()); $emoticonmanager = get_emoticon_manager(); $stringmanager = get_string_manager(); $editor = get_texteditor('tinymce'); ?> <?php print_string('moodleemoticon:desc', 'editor_tinymce'); ?> 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++; } ?>