Skip to content

Commit

Permalink
MDL-14741: Simplifies the activation of the htmleditor. This is a wor…
Browse files Browse the repository at this point in the history
…k-in-progress at this stage, but it's an improvement on the current state.
  • Loading branch information
scyrma committed Jun 11, 2008
1 parent bd526cb commit 8c37106
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
8 changes: 2 additions & 6 deletions lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ function output_html($data, $query='') {
}

return format_admin_setting($this, $this->visiblename,
'<div class="form-textarea" ><textarea rows="'.$this->rows.'" cols="'.$this->cols.'" id="'.$this->get_id().'" name="'.$this->get_full_name().'">'.s($data).'</textarea></div>',
'<div class="form-textarea form-textarea-advanced" ><textarea rows="'. $this->rows .'" cols="'. $this->cols .'" id="'. $this->get_id() .'" name="'. $this->get_full_name() .'">'. s($data) .'</textarea></div>',
$this->description, true, '', $defaultinfo, $query);
}
}
Expand Down Expand Up @@ -2633,11 +2633,7 @@ function output_html($data, $query='') {
global $CFG, $htmlEditorObject;

$CFG->adminusehtmleditor = can_use_html_editor();
$return = '<div class="form-htmlarea">'.print_textarea($CFG->adminusehtmleditor, 15, 60, 0, 0, $this->get_full_name(), $data, 0, true, 'summary');
if ($CFG->adminusehtmleditor && !is_null($htmlEditorObject)) {
$return .= $htmlEditorObject->activateEditor($this->get_full_name, 'summary');
}
$return .= '</div>';
$return = '<div class="form-htmlarea">'.print_textarea($CFG->adminusehtmleditor, 15, 60, 0, 0, $this->get_full_name(), $data, 0, true, 'summary') .'</div>';

return format_admin_setting($this, $this->visiblename, $return, $this->description, false, '', NULL, $query);
}
Expand Down
15 changes: 8 additions & 7 deletions lib/form/htmleditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ function setHelpButton($helpbuttonargs, $function='helpbutton'){
}

function toHtml(){
if ($this->_canUseHtmlEditor && !$this->_flagFrozen){
global $htmlEditorObject;
$script = $htmlEditorObject->activateEditor($this->getName(), $this->getAttribute('id'));
} else {
$script='';
}
//if ($this->_canUseHtmlEditor && !$this->_flagFrozen){
//global $htmlEditorObject;
//$script = $htmlEditorObject->activateEditor($this->getName(), $this->getAttribute('id'));
// $script = '';
//} else {
// $script='';
//}
if ($this->_flagFrozen) {
return $this->getFrozenHtml();
} else {
Expand All @@ -79,7 +80,7 @@ function toHtml(){
preg_replace("/(\r\n|\n|\r)/", '&#010;',$this->getValue()),
$this->_options['course'],
true,
$this->getAttribute('id')).$script;
$this->getAttribute('id'));//.$script;
}
} //end func toHtml

Expand Down
39 changes: 26 additions & 13 deletions lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4746,23 +4746,27 @@ function print_recent_activity_note($time, $user, $text, $link, $return=false, $
/**
* Prints a basic textarea field.
*
* When using this function, you should
*
* @uses $CFG
* @param boolean $usehtmleditor ?
* @param int $rows ?
* @param int $cols ?
* @param null $width <b>Legacy field no longer used!</b> Set to zero to get control over mincols
* @param null $height <b>Legacy field no longer used!</b> Set to zero to get control over minrows
* @param string $name ?
* @param string $value ?
* @param int $courseid ?
* @todo Finish documenting this function
*/
function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0, $return=false, $id='') {
* @param bool $usehtmleditor Enables the use of the htmleditor for this field.
* @param int $rows Number of rows to display (minimum of 10 when $height is non-null)
* @param int $cols Number of columns to display (minimum of 65 when $width is non-null)
* @param null $width (Deprecated) Width of the element; if a value is passed, the minimum value for $cols will be 65. Value is otherwise ignored.
* @param null $height (Deprecated) Height of the element; if a value is passe, the minimum value for $rows will be 10. Value is otherwise ignored.
* @param string $name Name to use for the textarea element.
* @param string $value Initial content to display in the textarea.
* @param int $courseid Course ID to pass to the file manager (defaults to global $COURSE->id).
* @param bool $return If false, will output string. If true, will return string value.
* @param string $id CSS ID to add to the textarea element.
* @param string $class CSS classes to add to the textarea element. Use 'form-textarea-simple' to get a basic editor. Defaults to 'form-textarea-advanced' (complete editor).
*/
function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0, $return=false, $id='', $class='form-textarea-advanced') {
/// $width and height are legacy fields and no longer used as pixels like they used to be.
/// However, you can set them to zero to override the mincols and minrows values below.

global $CFG, $COURSE, $HTTPSPAGEREQUIRED;
static $scriptcount = 0; // For loading the htmlarea script only once.
//static $scriptcount = 0; // For loading the htmlarea script only once.

$mincols = 65;
$minrows = 10;
Expand Down Expand Up @@ -4806,7 +4810,7 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
}
}
}
$str .= '<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';
$str .= "\n".'<textarea class="form-textarea '. $class .'" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">'."\n";
if ($usehtmleditor) {
$str .= htmlspecialchars($value); // needed for editing of cleaned text!
} else {
Expand All @@ -4816,6 +4820,8 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v

if ($usehtmleditor) {
// Show shortcuts button if HTML editor is in use, but only if JavaScript is enabled (MDL-9556)
$str .= '';
$str .= '<a href="javascript:toggleEditor(\''. $id .'\');"><img width="50" height="17" src="'. $CFG->httpswwwroot .'/lib/editor/tinymce/images/toggle.gif" alt="'. get_string('editortoggle') .'" title="'. get_string('editortoggle') .'" /></a>';
$str .= '<script type="text/javascript">
//<![CDATA[
document.write(\''.addslashes_js(editorshortcutshelpbutton()).'\');
Expand Down Expand Up @@ -5899,6 +5905,13 @@ function emoticonhelpbutton($form, $field, $return = false) {
}
}

/**
* Print a button to toggle the html editor.
*/
function editortogglebutton($id) {

}

/**
* Print a help button.
*
Expand Down

0 comments on commit 8c37106

Please sign in to comment.