TYPO3 CMS  TYPO3_6-2
InlineElements.php
Go to the documentation of this file.
1 <?php
3 
22 
23  protected $extensionKey = 'rtehtmlarea';
24 
25  // The key of the extension that is extending htmlArea RTE
26  protected $pluginName = 'InlineElements';
27 
28  // The name of the plugin registered by the extension
29  protected $relativePathToLocallangFile = 'extensions/InlineElements/locallang.xlf';
30 
31  // Path to this main locallang file of the extension relative to the extension dir.
32  protected $relativePathToSkin = 'extensions/InlineElements/skin/htmlarea.css';
33 
34  // Path to the skin (css) file relative to the extension dir.
35  protected $htmlAreaRTE;
36 
37  // Reference to the invoking object
38  protected $thisConfig;
39 
40  // Reference to RTE PageTSConfig
41  protected $toolbar;
42 
43  // Reference to RTE toolbar array
44  protected $LOCAL_LANG;
45 
46  // Frontend language array
47  protected $pluginButtons = 'formattext, bidioverride, big, bold, citation, code, definition, deletedtext, emphasis, insertedtext, italic, keyboard, quotation, sample, small, span, strikethrough, strong, subscript, superscript, underline, variable';
48 
50  'formattext' => 'FormatText',
51  'bidioverride' => 'BiDiOverride',
52  'big' => 'Big',
53  'bold' => 'Bold',
54  'citation' => 'Citation',
55  'code' => 'Code',
56  'definition' => 'Definition',
57  'deletedtext' => 'DeletedText',
58  'emphasis' => 'Emphasis',
59  'insertedtext' => 'InsertedText',
60  'italic' => 'Italic',
61  'keyboard' => 'Keyboard',
62  'monospaced' => 'MonoSpaced',
63  'quotation' => 'Quotation',
64  'sample' => 'Sample',
65  'small' => 'Small',
66  'span' => 'Span',
67  'strikethrough' => 'StrikeThrough',
68  'strong' => 'Strong',
69  'subscript' => 'Subscript',
70  'superscript' => 'Superscript',
71  'underline' => 'Underline',
72  'variable' => 'Variable'
73  );
74 
75  protected $defaultInlineElements = array(
76  'none' => 'No markup',
77  'b' => 'Bold',
78  'bdo' => 'BiDi override',
79  'big' => 'Large text',
80  'cite' => 'Citation',
81  'code' => 'Code',
82  'del' => 'Deleted text',
83  'dfn' => 'Definition',
84  'em' => 'Emphasis',
85  'i' => 'Italic',
86  'ins' => 'Inserted text',
87  'kbd' => 'Keyboard',
88  'q' => 'Quotation',
89  'samp' => 'Sample',
90  'small' => 'Small text',
91  'span' => 'Style container',
92  'strike' => 'Strike-through',
93  'strong' => 'Strong emphasis',
94  'sub' => 'Subscript',
95  'sup' => 'Superscript',
96  'tt' => 'Monospaced text',
97  'u' => 'Underline',
98  'var' => 'Variable'
99  );
100 
101  protected $defaultInlineElementsOrder = 'none, bidioverride, big, bold, citation, code, definition, deletedtext, emphasis, insertedtext, italic, keyboard,
102  monospaced, quotation, sample, small, span, strikethrough, strong, subscript, superscript, underline, variable';
103 
104  protected $buttonToInlineElement = array(
105  'none' => 'none',
106  'bidioverride' => 'bdo',
107  'big' => 'big',
108  'bold' => 'b',
109  'citation' => 'cite',
110  'code' => 'code',
111  'definition' => 'dfn',
112  'deletedtext' => 'del',
113  'emphasis' => 'em',
114  'insertedtext' => 'ins',
115  'italic' => 'i',
116  'keyboard' => 'kbd',
117  'monospaced' => 'tt',
118  'quotation' => 'q',
119  'sample' => 'samp',
120  'small' => 'small',
121  'span' => 'span',
122  'strikethrough' => 'strike',
123  'strong' => 'strong',
124  'subscript' => 'sub',
125  'superscript' => 'sup',
126  'underline' => 'u',
127  'variable' => 'var'
128  );
129 
136  public function buildJavascriptConfiguration($RTEcounter) {
137  global $TSFE, $LANG;
138  $registerRTEinJavascriptString = '';
139  if (in_array('formattext', $this->toolbar)) {
140  if (!is_array($this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.']['formattext.'])) {
141  $registerRTEinJavascriptString .= '
142  RTEarea[' . $RTEcounter . '].buttons.formattext = new Object();';
143  }
144  // Default inline elements
145  $hideItems = array();
146  $restrictTo = array('*');
147  $inlineElementsOrder = $this->defaultInlineElementsOrder;
148  $prefixLabelWithTag = FALSE;
149  $postfixLabelWithTag = FALSE;
150  // Processing PageTSConfig
151  if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['formattext.'])) {
152  // Removing elements
153  if ($this->thisConfig['buttons.']['formattext.']['removeItems']) {
154  $hideItems = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->htmlAreaRTE->cleanList($this->thisConfig['buttons.']['formattext.']['removeItems']), TRUE);
155  }
156  // Restriction clause
157  if ($this->thisConfig['buttons.']['formattext.']['restrictTo']) {
158  $restrictTo = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->htmlAreaRTE->cleanList('none,' . $this->thisConfig['buttons.']['formattext.']['restrictTo']), TRUE);
159  } elseif ($this->thisConfig['buttons.']['formattext.']['restrictToItems']) {
160  $restrictTo = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->htmlAreaRTE->cleanList('none,' . $this->thisConfig['buttons.']['formattext.']['restrictToItems']), TRUE);
161  }
162  // Elements order
163  if ($this->thisConfig['buttons.']['formattext.']['orderItems']) {
164  $inlineElementsOrder = 'none,' . $this->thisConfig['buttons.']['formattext.']['orderItems'];
165  }
166  $prefixLabelWithTag = $this->thisConfig['buttons.']['formattext.']['prefixLabelWithTag'] ? TRUE : $prefixLabelWithTag;
167  $postfixLabelWithTag = $this->thisConfig['buttons.']['formattext.']['postfixLabelWithTag'] ? TRUE : $postfixLabelWithTag;
168  }
169  $inlineElementsOrder = array_diff(\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->htmlAreaRTE->cleanList($inlineElementsOrder), TRUE), $hideItems);
170  if (!in_array('*', $restrictTo)) {
171  $inlineElementsOrder = array_intersect($inlineElementsOrder, $restrictTo);
172  }
173  // Localizing the options
174  $inlineElementsOptions = array();
175  foreach ($inlineElementsOrder as $item) {
176  if ($this->htmlAreaRTE->is_FE()) {
177  $inlineElementsOptions[$this->buttonToInlineElement[$item]] = $TSFE->getLLL($this->defaultInlineElements[$this->buttonToInlineElement[$item]], $this->LOCAL_LANG);
178  } else {
179  $inlineElementsOptions[$this->buttonToInlineElement[$item]] = $LANG->getLL($this->defaultInlineElements[$this->buttonToInlineElement[$item]]);
180  }
181  $inlineElementsOptions[$this->buttonToInlineElement[$item]] = ($prefixLabelWithTag && $item != 'none' ? $this->buttonToInlineElement[$item] . ' - ' : '') . $inlineElementsOptions[$this->buttonToInlineElement[$item]] . ($postfixLabelWithTag && $item != 'none' ? ' - ' . $this->buttonToInlineElement[$item] : '');
182  }
183  $first = array_shift($inlineElementsOptions);
184  // Sorting the options
185  if (!is_array($this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.']['formattext.']) || !$this->thisConfig['buttons.']['formattext.']['orderItems']) {
186  asort($inlineElementsOptions);
187  }
188  // Generating the javascript options
189  $JSInlineElements = array();
190  $JSInlineElements[] = array($first, 'none');
191  foreach ($inlineElementsOptions as $item => $label) {
192  $JSInlineElements[] = array($label, $item);
193  }
194  if ($this->htmlAreaRTE->is_FE()) {
195  $GLOBALS['TSFE']->csConvObj->convArray($JSInlineElements, $this->htmlAreaRTE->OutputCharset, 'utf-8');
196  }
197  $registerRTEinJavascriptString .= '
198  RTEarea[' . $RTEcounter . '].buttons.formattext.options = ' . json_encode($JSInlineElements) . ';';
199  }
200  return $registerRTEinJavascriptString;
201  }
202 
203 }
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
$TSFE
Definition: index_ts.php:72
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]