Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Displays the TinyMCE popup window to insert a Moodle emoticon
  19   *
  20   * @package   tinymce_moodleemoticon
  21   * @copyright 2010 David Mudrak <david@moodle.com>
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  define('NO_MOODLE_COOKIES', true); // Session not used here.
  26  
  27  require(__DIR__ . '/../../../../../config.php');
  28  
  29  $PAGE->set_context(context_system::instance());
  30  $PAGE->set_url('/lib/editor/tinymce/plugins/moodleemoticon/dialog.php');
  31  
  32  $emoticonmanager = get_emoticon_manager();
  33  $stringmanager = get_string_manager();
  34  
  35  $editor = get_texteditor('tinymce');
  36  $plugin = $editor->get_plugin('moodleemoticon');
  37  
  38  $htmllang = get_html_lang();
  39  header('Content-Type: text/html; charset=utf-8');
  40  header('X-UA-Compatible: IE=edge');
  41  ?>
  42  <!DOCTYPE html>
  43  <html <?php echo $htmllang ?>
  44  <head>
  45      <title><?php print_string('moodleemoticon:desc', 'tinymce_moodleemoticon'); ?></title>
  46      <script type="text/javascript" src="<?php echo $editor->get_tinymce_base_url(); ?>/tiny_mce_popup.js"></script>
  47      <script type="text/javascript" src="<?php echo $plugin->get_tinymce_file_url('js/dialog.js'); ?>"></script>
  48  </head>
  49  <body>
  50  
  51      <table border="0" align="center" style="width:100%;">
  52  <?php
  53  
  54  $emoticons = $emoticonmanager->get_emoticons(true);
  55  // This is tricky - we must somehow include the information about the original
  56  // emoticon text so that we can replace the image back with it on editor save.
  57  // so we are going to encode the index of the emoticon. this will break when the
  58  // admin changes the mapping table while the user has the editor opened
  59  // but I am not able to come with better solution at the moment :-/
  60  $index = 0;
  61  foreach ($emoticons as $emoticon) {
  62      $txt = $emoticon->text;
  63      $img = $OUTPUT->render(
  64          $emoticonmanager->prepare_renderable_emoticon($emoticon, array('class' => 'emoticon emoticon-index-'.$index)));
  65      if ($stringmanager->string_exists($emoticon->altidentifier, $emoticon->altcomponent)) {
  66          $alt = get_string($emoticon->altidentifier, $emoticon->altcomponent);
  67      } else {
  68          $alt = '';
  69      }
  70      echo html_writer::tag('tr',
  71              html_writer::tag('td', $img, array('style' => 'width:20%;text-align:center;')) .
  72              html_writer::tag('td', s($txt), array('style' => 'width:40%;text-align:center;font-family:monospace;')) .
  73              html_writer::tag('td', $alt),
  74          array(
  75              'class' => 'emoticoninfo emoticoninfo-index-'.$index,
  76          )
  77      );
  78      $index++;
  79  }
  80  
  81  ?>
  82      </table>
  83  
  84      <div class="mceActionPanel">
  85          <input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
  86      </div>
  87  
  88  </body>
  89  </html>