commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / packages / HTML / QuickForm / joomlaeditor.php
1 <?php
2
3 require_once'HTML/QuickForm/textarea.php';
4
5 /**
6 * HTML Quickform element for Joomla Default Editor
7 *
8 * Joomla global configuration includes the selection of a default editor
9 * This class imports and translates the default editor into CiviCRM forms
10 *
11 * @author Brian Shaughnessy, based on other editor classes
12 * @access public
13 */
14 class HTML_QuickForm_JoomlaEditor extends HTML_QuickForm_textarea
15 {
16 /**
17 * The width of the editor in pixels or percent
18 *
19 * @var string
20 * @access public
21 */
22 var $width = '94%';
23
24 /**
25 * The height of the editor in pixels or percent
26 *
27 * @var string
28 * @access public
29 */
30 var $height = '400';
31
32 /**
33 * Class constructor
34 *
35 * @param string Editor instance name
36 * @param string Editor instance label
37 * @param array Config settings for editor
38 * @param string Attributes for the textarea
39 * @access public
40 * @return void
41 */
42 function HTML_QuickForm_JoomlaEditor( $elementName=null, $elementLabel=null, $attributes=null, $options=array() )
43 {
44
45 HTML_QuickForm_element::HTML_QuickForm_element( $elementName, $elementLabel, $attributes );
46 $this->_persistantFreeze = true;
47 $this->_type = 'JoomlaEditor';
48 // set editor height smaller if schema defines rows as 4 or less
49 if ( is_array( $attributes ) &&
50 array_key_exists( 'rows', $attributes ) &&
51 $attributes['rows'] <= 4
52 ) {
53 $this->height = 200;
54 }
55 }
56
57 /**
58 * Return the htmlarea in HTML
59 *
60 * @access public
61 * @return string
62 */
63 function toHtml()
64 {
65 jimport( 'joomla.html.editor' );
66 $editor = JFactory::getEditor();
67
68 if ( $this->_flagFrozen ) {
69 return $this->getFrozenHtml();
70 } else {
71 $name = $this->getAttribute( 'name' );
72 $html = null;
73
74 //tinymce and its relatives require 'double-loading' when inside jquery tab
75 $editorName = $editor->get( '_name' );
76 if ( $editorName == 'jce' ||
77 $editorName == 'tinymce'
78 ) {
79 $html .= sprintf( '<script type="text/javascript">
80 //reset the controls if called in jquery tab or via ajax
81 tinyMCE.execCommand( "mceRemoveControl", false,"' . $this->_attributes['id'] .'" );
82 tinyMCE.execCommand( "mceAddControl" , true, "' . $this->_attributes['id'] .'" );
83 </script>' );
84
85 $html .= sprintf( '<style type="text/css"> <!--
86 #crm-container table.mceLayout td { border: none; } .button2-left { display:none; }
87 --> </style> ' );
88 }
89
90 $html .= $editor->display( $name, $this->getValue(), $this->width, $this->height, '94', '20', false );
91 return $html;
92 }
93 }
94
95 /**
96 * Returns the htmlarea content in HTML
97 *
98 * @access public
99 * @return string
100 */
101 function getFrozenHtml()
102 {
103 return $this->getValue();
104 }
105 }