commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / packages / HTML / QuickForm / drupalwysiwyg.php
1 <?php
2
3 require_once('HTML/QuickForm/textarea.php');
4
5 /**
6 * HTML Quickform element for TinyMCE Editor
7 *
8 * TinyMCE is a WYSIWYG HTML editor which can be obtained from
9 * http://tinymce.moxiecode.com/.
10 *
11 * @access public
12 */
13 class HTML_QuickForm_DrupalWysiwyg extends HTML_QuickForm_textarea
14 {
15
16 var $format = NULL;
17
18 /**
19 * Class constructor
20 *
21 * @param string TinyMCE instance name
22 * @param string TinyMCE instance label
23 * @param array Config settings for TinyMCE
24 * @param string Attributes for the textarea
25 * @access public
26 * @return void
27 */
28 function HTML_QuickForm_DrupalWysiwyg($elementName=null, $elementLabel=null, $attributes=null, $options=array())
29 {
30 HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
31 $this->_persistantFreeze = true;
32 $this->_type = 'DrupalWysiwyg';
33
34 }
35
36 /**
37 * Called by HTML_QuickForm whenever form event is made on this element
38 *
39 * @param string $event Name of event
40 * @param mixed $arg event arguments
41 * @param object &$caller calling object
42 * @since 1.0
43 * @access public
44 * @return void
45 */
46 function onQuickFormEvent($event, $arg, &$caller)
47 {
48 switch ($event) {
49 case 'updateValue':
50 civicrm_drupal_wysiwyg_update_value($this, $caller);
51 break;
52 case 'addElement':
53 $format = $arg[0] . '_format';
54 $this->format = $caller->get($format);
55 if (!$this->format) $this->format = variable_get('civicrm_wysiwyg_input_format', (defined('FILTER_FORMAT_DEFAULT')?FILTER_FORMAT_DEFAULT:null));
56 $caller->set($format, $this->format);
57 parent::onQuickFormEvent($event, $arg, $caller);
58 break;
59 default:
60 parent::onQuickFormEvent($event, $arg, $caller);
61 }
62 return true;
63 } // end func onQuickFormLoad
64
65 /**
66 * Return the htmlarea in HTML
67 *
68 * @access public
69 * @return string
70 */
71 function toHtml()
72 {
73 $html = null;
74 // return frozen state
75 if ($this->_flagFrozen) {
76 return $this->getFrozenHtml();
77 } else {
78 $html = civicrm_drupal_get_wysiwyg_html($this->_attributes, $this->getValue(), $this->format);
79 return '<div class="civicrm-drupal-wysiwyg">' . $html . '</div>';
80 }
81 }
82
83 function exportValue(&$submitValues, $assoc = false) {
84 return $this->_prepareValue($this->getValue(), $assoc);
85 }
86
87 /**
88 * Returns the htmlarea content in HTML
89 *
90 * @access public
91 * @return string
92 */
93 function getFrozenHtml()
94 {
95 return $this->getValue();
96 }
97 }