예제 #1
0
파일: lib.php 프로젝트: vinoth4891/clinique
 protected function update_init_params(array &$params, context $context, array $options = null)
 {
     global $OUTPUT;
     if ($this->get_config('requireemoticon', 1)) {
         // If emoticon filter is disabled, do not add button.
         $filters = filter_get_active_in_context($context);
         if (!array_key_exists('filter/emoticon', $filters)) {
             return;
         }
     }
     // Add button after 'image' in advancedbuttons3.
     $this->add_button_after($params, 3, 'moodleemoticon', 'image');
     // Add JS file, which uses default name.
     $this->add_js_plugin($params);
     // Extra params specifically for emoticon plugin.
     $manager = get_emoticon_manager();
     $emoticons = $manager->get_emoticons();
     $imgs = array();
     // See the TinyMCE plugin moodleemoticon for how the emoticon index is (ab)used.
     $index = 0;
     foreach ($emoticons as $emoticon) {
         $imgs[$emoticon->text] = $OUTPUT->render($manager->prepare_renderable_emoticon($emoticon, array('class' => 'emoticon emoticon-index-' . $index++)));
     }
     $params['moodleemoticon_emoticons'] = json_encode($imgs);
 }
예제 #2
0
파일: filter.php 프로젝트: evltuma/moodle
 /**
  * Replace emoticons found in the text with their images
  *
  * @param string $text to modify
  * @return void
  */
 protected function replace_emoticons(&$text)
 {
     global $CFG, $OUTPUT, $PAGE;
     static $emoticontexts = array();
     // internal cache used for replacing
     static $emoticonimgs = array();
     // internal cache used for replacing
     $lang = current_language();
     $theme = $PAGE->theme->name;
     if (!isset($emoticontexts[$lang][$theme]) or !isset($emoticonimgs[$lang][$theme])) {
         // prepare internal caches
         $manager = get_emoticon_manager();
         $emoticons = $manager->get_emoticons();
         $emoticontexts[$lang][$theme] = array();
         $emoticonimgs[$lang][$theme] = array();
         foreach ($emoticons as $emoticon) {
             $emoticontexts[$lang][$theme][] = $emoticon->text;
             $emoticonimgs[$lang][$theme][] = $OUTPUT->render($manager->prepare_renderable_emoticon($emoticon));
         }
         unset($emoticons);
     }
     if (empty($emoticontexts[$lang][$theme])) {
         // No emoticons defined, nothing to process here
         return;
     }
     // detect all the <script> zones to take out
     $excludes = array();
     preg_match_all('/<script language(.+?)<\\/script>/is', $text, $listofexcludes);
     // take out all the <script> zones from text
     foreach (array_unique($listofexcludes[0]) as $key => $value) {
         $excludes['<+' . $key . '+>'] = $value;
     }
     if ($excludes) {
         $text = str_replace($excludes, array_keys($excludes), $text);
     }
     // this is the meat of the code - this is run every time
     $text = str_replace($emoticontexts[$lang][$theme], $emoticonimgs[$lang][$theme], $text);
     // Recover all the <script> zones to text
     if ($excludes) {
         $text = str_replace(array_keys($excludes), $excludes, $text);
     }
 }
예제 #3
0
 /**
  * Save selected settings
  *
  * @param array $data Array of settings to save
  * @return bool
  */
 public function write_setting($data)
 {
     $manager = get_emoticon_manager();
     $emoticons = $this->process_form_data($data);
     if ($emoticons === false) {
         return false;
     }
     if ($this->config_write($this->name, $manager->encode_stored_config($emoticons))) {
         return '';
         // success
     } else {
         return get_string('errorsetting', 'admin') . $this->visiblename . html_writer::empty_tag('br');
     }
 }
예제 #4
0
파일: lib.php 프로젝트: nickread/moodle
 protected function get_init_params($elementid, array $options = null)
 {
     global $CFG, $PAGE, $OUTPUT;
     //TODO: we need to implement user preferences that affect the editor setup too
     $directionality = get_string('thisdirection', 'langconfig');
     $strtime = get_string('strftimetime');
     $strdate = get_string('strftimedaydate');
     $lang = current_language();
     $contentcss = $PAGE->theme->editor_css_url()->out(false);
     $context = empty($options['context']) ? get_context_instance(CONTEXT_SYSTEM) : $options['context'];
     $xmedia = 'moodlemedia,';
     // HQ thinks it should be always on, so it is no matter if it will actually work or not
     /*
             if (!empty($options['legacy'])) {
                 $xmedia = 'moodlemedia,';
             } else {
                 if (!empty($options['noclean']) or !empty($options['trusted'])) {
                 }
             }*/
     $filters = filter_get_active_in_context($context);
     if (array_key_exists('filter/tex', $filters)) {
         $xdragmath = 'dragmath,';
     } else {
         $xdragmath = '';
     }
     if (array_key_exists('filter/emoticon', $filters)) {
         $xemoticon = 'moodleemoticon,';
     } else {
         $xemoticon = '';
     }
     $params = array('mode' => "exact", 'elements' => $elementid, 'relative_urls' => false, 'document_base_url' => $CFG->httpswwwroot, 'content_css' => $contentcss, 'language' => $lang, 'directionality' => $directionality, 'plugin_insertdate_dateFormat ' => $strdate, 'plugin_insertdate_timeFormat ' => $strtime, 'theme' => "advanced", 'skin' => "o2k7", 'skin_variant' => "silver", 'apply_source_formatting' => true, 'remove_script_host' => false, 'entity_encoding' => "raw", 'plugins' => "{$xmedia}advimage,safari,table,style,layer,advhr,advlink,emotions,inlinepopups,searchreplace,paste,directionality,fullscreen,moodlenolink,{$xemoticon}{$xdragmath}nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak,spellchecker", 'theme_advanced_font_sizes' => "1,2,3,4,5,6,7", 'theme_advanced_layout_manager' => "SimpleLayout", 'theme_advanced_toolbar_align' => "left", 'theme_advanced_buttons1' => "fontselect,fontsizeselect,formatselect", 'theme_advanced_buttons1_add' => "|,undo,redo,|,search,replace,|,fullscreen", 'theme_advanced_buttons2' => "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright", 'theme_advanced_buttons2_add' => "|,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl", 'theme_advanced_buttons3' => "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,|,image,{$xemoticon}{$xmedia}{$xdragmath}nonbreaking,charmap", 'theme_advanced_buttons3_add' => "table,|,code,spellchecker", 'theme_advanced_fonts' => "Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings", 'theme_advanced_resize_horizontal' => true, 'theme_advanced_resizing' => true, 'theme_advanced_resizing_min_height' => 30, 'theme_advanced_toolbar_location' => "top", 'theme_advanced_statusbar_location' => "bottom", 'spellchecker_rpc_url' => $CFG->wwwroot . "/lib/editor/tinymce/tiny_mce/{$this->version}/plugins/spellchecker/rpc.php", 'spellchecker_languages' => get_config('editor_tinymce', 'spelllanguagelist'));
     if ($xemoticon) {
         $manager = get_emoticon_manager();
         $emoticons = $manager->get_emoticons();
         $imgs = array();
         // see the TinyMCE plugin moodleemoticon for how the emoticon index is (ab)used :-S
         $index = 0;
         foreach ($emoticons as $emoticon) {
             $imgs[$emoticon->text] = $OUTPUT->render($manager->prepare_renderable_emoticon($emoticon, array('class' => 'emoticon emoticon-index-' . $index++)));
         }
         $params['moodleemoticon_emoticons'] = json_encode($imgs);
     }
     if (empty($CFG->xmlstrictheaders) and (!empty($options['legacy']) or !empty($options['noclean']) or !empty($options['trusted']))) {
         // now deal somehow with non-standard tags, people scream when we do not make moodle code xtml strict,
         // but they scream even more when we strip all tags that are not strict :-(
         $params['valid_elements'] = 'script[src|type],*[*]';
         // for some reason the *[*] does not inlcude javascript src attribute MDL-25836
         $params['invalid_elements'] = '';
     }
     if (empty($options['legacy'])) {
         if (isset($options['maxfiles']) and $options['maxfiles'] != 0) {
             $params['file_browser_callback'] = "M.editor_tinymce.filepicker";
         }
     }
     //Add onblur event for client side text validation
     if (!empty($options['required'])) {
         $params['init_instance_callback'] = 'M.editor_tinymce.onblur_event';
     }
     return $params;
 }
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * 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();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title><?php 
print_string('moodleemoticon:desc', 'editor_tinymce');
?>
</title>
    <script type="text/javascript" src="../../tiny_mce_popup.js?v=3.4.2"></script>
    <script type="text/javascript" src="js/rev2/dialog.js?v=3.4.2"></script>
</head>
<body>

    <table border="0" align="center" style="width:100%;">
예제 #6
0
파일: lib.php 프로젝트: evltuma/moodle
/**
 * Sends the parameters to JS module.
 *
 * @return array
 */
function atto_emoticon_params_for_js($elementid, $options, $fpoptions)
{
    $manager = get_emoticon_manager();
    return array('emoticons' => $manager->get_emoticons());
}