Example #1
0
 /**
  * Constructor
  *
  * @param string $elementName (optional) name of the html editor
  * @param string $elementLabel (optional) editor label
  * @param array $options set of options to create html editor
  * @param array $attributes (optional) Either a typical HTML attribute string
  *              or an associative array
  */
 function MoodleQuickForm_htmleditor($elementName = null, $elementLabel = null, $options = array(), $attributes = null)
 {
     parent::MoodleQuickForm_textarea($elementName, $elementLabel, $attributes);
     // set the options, do not bother setting bogus ones
     if (is_array($options)) {
         foreach ($options as $name => $value) {
             if (array_key_exists($name, $this->_options)) {
                 if (is_array($value) && is_array($this->_options[$name])) {
                     $this->_options[$name] = @array_merge($this->_options[$name], $value);
                 } else {
                     $this->_options[$name] = $value;
                 }
             }
         }
     }
     if ($this->_options['canUseHtmlEditor'] == 'detect') {
         $this->_options['canUseHtmlEditor'] = can_use_html_editor();
     }
     if ($this->_options['canUseHtmlEditor']) {
         $this->_type = 'htmleditor';
         //$this->_elementTemplateType='wide';
     } else {
         $this->_type = 'textarea';
     }
     $this->_canUseHtmlEditor = $this->_options['canUseHtmlEditor'];
     editors_head_setup();
 }
Example #2
0
    function toHtml() {
        $textarea = parent::toHtml();

        return $this->{
            $this->wikiformat."Editor"}
            ($textarea);
    }
Example #3
0
 /**
  * set html for help button
  *
  * @access   public
  * @param array $help array of arguments to make a help button
  * @param string $function function name to call to get html
  */
 function setHelpButton($helpbuttonargs, $function = 'helpbutton')
 {
     if (!$this->_canUseHtmlEditor) {
         if ('editorhelpbutton' == $function) {
             $key = array_search('richtext', $helpbuttonargs);
             if ($key !== FALSE) {
                 array_splice($helpbuttonargs, $key, 1, array('text', 'emoticons'));
             }
         } elseif ('helpbutton' == $function && $helpbuttonargs[0] == 'richtext' && (!isset($helpbuttonargs[2]) || $helpbuttonargs[2] == 'moodle')) {
             //replace single 'richtext' help button with text and emoticon button when htmleditor off.
             return $this->setHelpButton(array('text', 'emoticons'), 'editorhelpbutton');
         }
     }
     return parent::setHelpButton($helpbuttonargs, $function);
 }
Example #4
0
 /**
  * Constructor
  *
  * @param string $elementName (optional) name of the html editor
  * @param string $elementLabel (optional) editor label
  * @param array $options set of options to create html editor
  * @param array $attributes (optional) Either a typical HTML attribute string
  *              or an associative array
  */
 function MoodleQuickForm_htmleditor($elementName = null, $elementLabel = null, $options = array(), $attributes = null)
 {
     parent::MoodleQuickForm_textarea($elementName, $elementLabel, $attributes);
     // set the options, do not bother setting bogus ones
     if (is_array($options)) {
         foreach ($options as $name => $value) {
             if (array_key_exists($name, $this->_options)) {
                 if (is_array($value) && is_array($this->_options[$name])) {
                     $this->_options[$name] = @array_merge($this->_options[$name], $value);
                 } else {
                     $this->_options[$name] = $value;
                 }
             }
         }
     }
     $this->_type = 'htmleditor';
     editors_head_setup();
 }
 /**
  * Returns HTML for this form element.
  */
 public function toHtml()
 {
     global $PAGE;
     $jsargs = array($this->getButtonId(), $this->getTextareaId());
     $PAGE->requires->js_init_call('M.poasquestion_text_and_button.set_handler', $jsargs, true, $this->jsmodule);
     return parent::toHtml() . '<a href="#" name="button_' . $this->getTextareaId() . '" id="' . $this->getButtonId() . '" title="' . $this->getTooltip() . '" style="margin-left: 5px" >' . '<img src="' . $this->linkToBtnImage . '" />' . '</a>';
 }