mirror of
https://github.com/moodle/moodle.git
synced 2025-07-12 09:56:45 +02:00
MDL-65149 emoticons: Do not show all emoticons
Allow some emoticons to still work, but not be selectable from the text editor plugins.
This commit is contained in:
@ -36,7 +36,7 @@ function atto_emoticon_strings_for_js() {
|
|||||||
|
|
||||||
// Load the strings required by the emotes.
|
// Load the strings required by the emotes.
|
||||||
$manager = get_emoticon_manager();
|
$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);
|
$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) {
|
function atto_emoticon_params_for_js($elementid, $options, $fpoptions) {
|
||||||
$manager = get_emoticon_manager();
|
$manager = get_emoticon_manager();
|
||||||
return array(
|
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%;">
|
<table border="0" align="center" style="width:100%;">
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$emoticons = $emoticonmanager->get_emoticons();
|
$emoticons = $emoticonmanager->get_emoticons(true);
|
||||||
// This is tricky - we must somehow include the information about the original
|
// 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.
|
// 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
|
// 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.
|
// Extra params specifically for emoticon plugin.
|
||||||
$manager = get_emoticon_manager();
|
$manager = get_emoticon_manager();
|
||||||
$emoticons = $manager->get_emoticons();
|
$emoticons = $manager->get_emoticons(true);
|
||||||
$imgs = array();
|
$imgs = array();
|
||||||
// See the TinyMCE plugin moodleemoticon for how the emoticon index is (ab)used.
|
// See the TinyMCE plugin moodleemoticon for how the emoticon index is (ab)used.
|
||||||
$index = 0;
|
$index = 0;
|
||||||
|
@ -7348,10 +7348,12 @@ class emoticon_manager {
|
|||||||
/**
|
/**
|
||||||
* Returns the currently enabled emoticons
|
* 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
|
* @return array of emoticon objects
|
||||||
*/
|
*/
|
||||||
public function get_emoticons() {
|
public function get_emoticons($selectable = false) {
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
$notselectable = ['martin', 'egg'];
|
||||||
|
|
||||||
if (empty($CFG->emoticons)) {
|
if (empty($CFG->emoticons)) {
|
||||||
return array();
|
return array();
|
||||||
@ -7364,6 +7366,14 @@ class emoticon_manager {
|
|||||||
debugging('Invalid format of emoticons setting, please resave the emoticons settings form', DEBUG_NORMAL);
|
debugging('Invalid format of emoticons setting, please resave the emoticons settings form', DEBUG_NORMAL);
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
if ($selectable) {
|
||||||
|
foreach ($emoticons as $index => $emote) {
|
||||||
|
if (in_array($emote->altidentifier, $notselectable)) {
|
||||||
|
// Skip this one.
|
||||||
|
unset($emoticons[$index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $emoticons;
|
return $emoticons;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user