Merge branch 'MDL-65149-master' of git://github.com/damyon/moodle

This commit is contained in:
Adrian Greeve
2019-05-01 14:58:21 +08:00
4 changed files with 15 additions and 5 deletions
+2 -2
View File
@@ -36,7 +36,7 @@ function atto_emoticon_strings_for_js() {
// Load the strings required by the emotes.
$manager = get_emoticon_manager();
foreach ($manager->get_emoticons() as $emote) {
foreach ($manager->get_emoticons(true) as $emote) {
$PAGE->requires->string_for_js($emote->altidentifier, $emote->altcomponent);
}
}
@@ -49,6 +49,6 @@ function atto_emoticon_strings_for_js() {
function atto_emoticon_params_for_js($elementid, $options, $fpoptions) {
$manager = get_emoticon_manager();
return array(
'emoticons' => $manager->get_emoticons()
'emoticons' => $manager->get_emoticons(true)
);
}
@@ -51,7 +51,7 @@ header('X-UA-Compatible: IE=edge');
<table border="0" align="center" style="width:100%;">
<?php
$emoticons = $emoticonmanager->get_emoticons();
$emoticons = $emoticonmanager->get_emoticons(true);
// 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
@@ -52,7 +52,7 @@ class tinymce_moodleemoticon extends editor_tinymce_plugin {
// Extra params specifically for emoticon plugin.
$manager = get_emoticon_manager();
$emoticons = $manager->get_emoticons();
$emoticons = $manager->get_emoticons(true);
$imgs = array();
// See the TinyMCE plugin moodleemoticon for how the emoticon index is (ab)used.
$index = 0;
+11 -1
View File
@@ -7381,10 +7381,12 @@ class emoticon_manager {
/**
* Returns the currently enabled emoticons
*
* @param boolean $selectable - If true, only return emoticons that should be selectable from a list.
* @return array of emoticon objects
*/
public function get_emoticons() {
public function get_emoticons($selectable = false) {
global $CFG;
$notselectable = ['martin', 'egg'];
if (empty($CFG->emoticons)) {
return array();
@@ -7397,6 +7399,14 @@ class emoticon_manager {
debugging('Invalid format of emoticons setting, please resave the emoticons settings form', DEBUG_NORMAL);
return array();
}
if ($selectable) {
foreach ($emoticons as $index => $emote) {
if (in_array($emote->altidentifier, $notselectable)) {
// Skip this one.
unset($emoticons[$index]);
}
}
}
return $emoticons;
}