e8465fa17176a6d3d4ac712e8c12dc827590f4e2
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / Classes / BrowseLinks.php
1 <?php
2 namespace TYPO3\CMS\Rtehtmlarea;
3
4 use TYPO3\CMS\Backend\Utility\BackendUtility;
5 use TYPO3\CMS\Core\Utility\GeneralUtility;
6
7 /**
8 * Script class for the Element Browser window.
9 *
10 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
11 */
12 class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
13
14 public $editorNo;
15 /**
16 * TYPO3 language code of the content language
17 */
18 public $contentTypo3Language;
19
20 public $contentTypo3Charset = 'utf-8';
21 /**
22 * Language service object for localization to the content language
23 */
24 protected $contentLanguageService;
25
26 public $additionalAttributes = array();
27
28 public $buttonConfig = array();
29
30 public $RTEProperties = array();
31
32 public $anchorTypes = array('page', 'url', 'file', 'mail', 'spec');
33
34 public $classesAnchorDefault = array();
35
36 public $classesAnchorDefaultTitle = array();
37
38 public $classesAnchorClassTitle = array();
39
40 public $classesAnchorDefaultTarget = array();
41
42 public $classesAnchorJSOptions = array();
43
44 protected $defaultLinkTarget;
45
46 public $allowedItems;
47
48 /**
49 * Constructor:
50 * Initializes a lot of variables, setting JavaScript functions in header etc.
51 *
52 * @return void
53 * @todo Define visibility
54 */
55 public function init() {
56 $this->initVariables();
57 // Create content language service
58 $this->contentLanguageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Lang\\LanguageService');
59 $this->contentLanguageService->init($this->contentTypo3Language);
60 $this->initConfiguration();
61
62 $this->initDocumentTemplate();
63
64 // Initializing hooking browsers
65 $this->initHookObjects('ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php');
66 $this->initCurrentUrl();
67 // Determine nature of current url:
68 $this->act = GeneralUtility::_GP('act');
69 if (!$this->act) {
70 $this->act = $this->curUrlInfo['act'];
71 }
72 // Setting initial values for link attributes
73 $this->initLinkAttributes();
74 }
75
76 /**
77 * Initialize class variables
78 *
79 * @return void
80 */
81 public function initVariables() {
82 parent::initVariables();
83
84 // Process bparams
85 $pArr = explode('|', $this->bparams);
86 $pRteArr = explode(':', $pArr[1]);
87 $this->editorNo = $pRteArr[0];
88 $this->contentTypo3Language = $pRteArr[1];
89 $this->RTEtsConfigParams = $pArr[2];
90 if (!$this->editorNo) {
91 $this->editorNo = GeneralUtility::_GP('editorNo');
92 $this->contentTypo3Language = GeneralUtility::_GP('contentTypo3Language');
93 $this->RTEtsConfigParams = GeneralUtility::_GP('RTEtsConfigParams');
94 }
95 $pArr[1] = implode(':', array($this->editorNo, $this->contentTypo3Language, $this->contentTypo3Charset));
96 $pArr[2] = $this->RTEtsConfigParams;
97 $this->bparams = implode('|', $pArr);
98 }
99
100 /**
101 * Initializes the configuration variables
102 *
103 * @return void
104 */
105 public function initConfiguration() {
106 $this->thisConfig = $this->getRTEConfig();
107 $this->buttonConfig = $this->getButtonConfig('link');
108 }
109
110 /**
111 * Initialize document template object
112 *
113 * @return void
114 */
115 protected function initDocumentTemplate() {
116 parent::initDocumentTemplate();
117 $this->doc->getContextMenuCode();
118 // Apply the same styles as those of the base script
119 $this->doc->bodyTagId = 'typo3-browse-links-php';
120 $this->doc->getPageRenderer()->addCssFile($this->doc->backPath . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('t3skin') . 'rtehtmlarea/htmlarea.css');
121 // Add attributes to body tag. Note: getBodyTagAdditions will invoke the hooks
122 $this->doc->bodyTagAdditions = $this->getBodyTagAdditions();
123 // Adding RTE JS code
124 $this->doc->JScodeArray['rtehtmlarea'] = $this->getJSCode();
125 }
126
127 /**
128 * Initialize $this->curUrlArray and $this->curUrlInfo based on script parameters
129 *
130 * @return void
131 */
132 protected function initCurrentUrl() {
133 // CurrentUrl - the current link url must be passed around if it exists
134 $this->curUrlArray = GeneralUtility::_GP('curUrl');
135 if ($this->curUrlArray['all']) {
136 $this->curUrlArray = GeneralUtility::get_tag_attributes($this->curUrlArray['all']);
137 $this->curUrlArray['href'] = htmlspecialchars_decode($this->curUrlArray['href']);
138 }
139 // Note: parseCurUrl will invoke the hooks
140 $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'], $this->siteURL);
141 if (isset($this->curUrlArray['data-htmlarea-external']) && $this->curUrlInfo['act'] != 'mail') {
142 $this->curUrlInfo['act'] = 'url';
143 $this->curUrlInfo['info'] = $this->curUrlArray['href'];
144 }
145 }
146
147 /**
148 * Get the RTE configuration from Page TSConfig
149 *
150 * @return array RTE configuration array
151 */
152 protected function getRTEConfig() {
153 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
154 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
155 $this->RTEProperties = $RTEsetup['properties'];
156 return BackendUtility::RTEsetup($this->RTEProperties, $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
157 }
158
159 /**
160 * Get the configuration of the button
161 *
162 * @param string $buttonName: the name of the button
163 * @return array the configuration array of the image button
164 */
165 protected function getButtonConfig($buttonName) {
166 return is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.'][$buttonName . '.'])
167 ? $this->thisConfig['buttons.'][$buttonName . '.']
168 : array();
169 }
170
171 /**
172 * Initialize the current or default values of the link attributes
173 *
174 * @return void
175 */
176 protected function initLinkAttributes() {
177 // Initializing the title value
178 $this->setTitle = $this->curUrlArray['title'];
179 // Processing the classes configuration
180 $classSelected = array();
181 if ($this->buttonConfig['properties.']['class.']['allowedClasses']) {
182 $this->setClass = $this->curUrlArray['class'];
183 $classesAnchorArray = GeneralUtility::trimExplode(',', $this->buttonConfig['properties.']['class.']['allowedClasses'], TRUE);
184 $classesAnchorConfigArray = array();
185 // Collecting allowed classes and configured default values
186 $classesAnchor = array();
187 $classesAnchor['all'] = array();
188 $titleReadOnly = $this->buttonConfig['properties.']['title.']['readOnly'] || $this->buttonConfig[$this->act . '.']['properties.']['title.']['readOnly'];
189 if (is_array($this->RTEProperties['classesAnchor.'])) {
190 foreach ($this->RTEProperties['classesAnchor.'] as $label => $conf) {
191 if (in_array($conf['class'], $classesAnchorArray)) {
192 $classesAnchor['all'][] = $conf['class'];
193 if (in_array($conf['type'], $this->anchorTypes)) {
194 $classesAnchor[$conf['type']][] = $conf['class'];
195 if ($this->buttonConfig[$conf['type'] . '.']['properties.']['class.']['default'] == $conf['class']) {
196 $this->classesAnchorDefault[$conf['type']] = $conf['class'];
197 if ($conf['titleText']) {
198 $this->classesAnchorDefaultTitle[$conf['type']] = $this->getLLContent(trim($conf['titleText']));
199 }
200 if ($conf['target']) {
201 $this->classesAnchorDefaultTarget[$conf['type']] = trim($conf['target']);
202 }
203 }
204 }
205 if ($titleReadOnly && $conf['titleText']) {
206 $this->classesAnchorClassTitle[$conf['class']] = ($this->classesAnchorDefaultTitle[$conf['type']] = $this->getLLContent(trim($conf['titleText'])));
207 }
208 }
209 }
210 }
211 // Constructing the class selector options
212 foreach ($this->anchorTypes as $anchorType) {
213 foreach ($classesAnchorArray as $class) {
214 if (!in_array($class, $classesAnchor['all']) || in_array($class, $classesAnchor['all']) && is_array($classesAnchor[$anchorType]) && in_array($class, $classesAnchor[$anchorType])) {
215 $selected = '';
216 if ($this->setClass == $class || !$this->setClass && $this->classesAnchorDefault[$anchorType] == $class) {
217 $selected = 'selected="selected"';
218 $classSelected[$anchorType] = TRUE;
219 }
220 $classLabel = is_array($this->RTEProperties['classes.']) && is_array($this->RTEProperties['classes.'][$class . '.']) && $this->RTEProperties['classes.'][$class . '.']['name'] ? $this->getPageConfigLabel($this->RTEProperties['classes.'][$class . '.']['name'], 0) : $class;
221 $classStyle = is_array($this->RTEProperties['classes.']) && is_array($this->RTEProperties['classes.'][$class . '.']) && $this->RTEProperties['classes.'][$class . '.']['value'] ? $this->RTEProperties['classes.'][$class . '.']['value'] : '';
222 $this->classesAnchorJSOptions[$anchorType] .= '<option ' . $selected . ' value="' . $class . '"' . ($classStyle ? ' style="' . $classStyle . '"' : '') . '>' . $classLabel . '</option>';
223 }
224 }
225 if ($this->classesAnchorJSOptions[$anchorType] && !($this->buttonConfig['properties.']['class.']['required'] || $this->buttonConfig[$this->act . '.']['properties.']['class.']['required'])) {
226 $selected = '';
227 if (!$this->setClass && !$this->classesAnchorDefault[$anchorType]) {
228 $selected = 'selected="selected"';
229 }
230 $this->classesAnchorJSOptions[$anchorType] = '<option ' . $selected . ' value=""></option>' . $this->classesAnchorJSOptions[$anchorType];
231 }
232 }
233 }
234 // Initializing the target value
235 // Unset the target if it is set to a value different than default and if no class is selected and the target field is not displayed
236 // In other words, do not forward the target if we changed tab and the target field is not displayed
237 $this->defaultLinkTarget = isset($this->buttonConfig['properties.']['target.']['default']) ? $this->buttonConfig['properties.']['target.']['default'] : '';
238 $this->setTarget = '';
239 if (isset($this->curUrlArray['target']) && !($this->curUrlArray['target'] != $this->defaultLinkTarget && !$classSelected[$this->act] && is_array($this->buttonConfig['targetSelector.']) && $this->buttonConfig['targetSelector.']['disabled'] && is_array($this->buttonConfig['popupSelector.']) && $this->buttonConfig['popupSelector.']['disabled'])) {
240 $this->setTarget = $this->curUrlArray['target'];
241 }
242 if ($this->defaultLinkTarget && !isset($this->curUrlArray['target'])) {
243 $this->setTarget = $this->defaultLinkTarget;
244 }
245 // Initializing additional attributes
246 if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes']) {
247 $addAttributes = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes'], TRUE);
248 foreach ($addAttributes as $attribute) {
249 $this->additionalAttributes[$attribute] = isset($this->curUrlArray[$attribute]) ? $this->curUrlArray[$attribute] : '';
250 }
251 }
252 }
253
254 /**
255 * Provide the additional parameters to be included in the template body tag
256 *
257 * @return string the body tag additions
258 */
259 public function getBodyTagAdditions() {
260 $bodyTagAdditions = array();
261 // call hook for extra additions
262 foreach ($this->hookObjects as $hookObject) {
263 if (method_exists($hookObject, 'addBodyTagAdditions')) {
264 $bodyTagAdditions = $hookObject->addBodyTagAdditions($bodyTagAdditions);
265 }
266 }
267 return GeneralUtility::implodeAttributes($bodyTagAdditions, TRUE);
268 }
269
270 /**
271 * Generate JS code to be used on the link insert/modify dialogue
272 *
273 * @return string the generated JS code
274 * @todo Define visibility
275 */
276 public function getJSCode() {
277 // BEGIN accumulation of header JavaScript:
278 $JScode = '';
279 $JScode .= '
280 var plugin = window.parent.RTEarea["' . $this->editorNo . '"].editor.getPlugin("TYPO3Link");
281 var HTMLArea = window.parent.HTMLArea;
282 var add_href=' . GeneralUtility::quoteJSvalue($this->curUrlArray['href'] ? '&curUrl[href]=' . rawurlencode($this->curUrlArray['href']) : '') . ';
283 var add_target=' . GeneralUtility::quoteJSvalue($this->setTarget ? '&curUrl[target]=' . rawurlencode($this->setTarget) : '') . ';
284 var add_class=' . GeneralUtility::quoteJSvalue($this->setClass ? '&curUrl[class]=' . rawurlencode($this->setClass) : '') . ';
285 var add_title=' . GeneralUtility::quoteJSvalue($this->setTitle ? '&curUrl[title]=' . rawurlencode($this->setTitle) : '') . ';
286 var add_params=' . GeneralUtility::quoteJSvalue($this->bparams ? '&bparams=' . rawurlencode($this->bparams) : '') . ';
287 var additionalValues = ' . (count($this->additionalAttributes) ? json_encode($this->additionalAttributes, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT) : '{}') . ';';
288 // Attributes setting functions
289 $JScode .= '
290 var cur_href=' . GeneralUtility::quoteJSvalue($this->curUrlArray['href'] ? ($this->curUrlInfo['query'] ? substr($this->curUrlArray['href'], 0, -strlen($this->curUrlInfo['query'])) : $this->curUrlArray['href']) : '') . ';
291 var cur_target=' . GeneralUtility::quoteJSvalue($this->setTarget ?: '') . ';
292 var cur_class=' . GeneralUtility::quoteJSvalue($this->setClass ?: '') . ';
293 var cur_title=' . GeneralUtility::quoteJSvalue($this->setTitle ?: '') . ';
294
295 function browse_links_setTarget(value) {
296 cur_target=value;
297 add_target="&curUrl[target]="+encodeURIComponent(value);
298 }
299 function browse_links_setClass(value) {
300 cur_class=value;
301 add_class="&curUrl[class]="+encodeURIComponent(value);
302 }
303 function browse_links_setTitle(value) {
304 cur_title=value;
305 add_title="&curUrl[title]="+encodeURIComponent(value);
306 }
307 function browse_links_setHref(value) {
308 cur_href=value;
309 add_href="&curUrl[href]="+value;
310 }
311 function browse_links_setAdditionalValue(name, value) {
312 additionalValues[name] = value;
313 }
314 ';
315 // Link setting functions
316 $JScode .= '
317 function link_typo3Page(id,anchor) {
318 var parameters = (document.ltargetform.query_parameters && document.ltargetform.query_parameters.value) ? (document.ltargetform.query_parameters.value.charAt(0) == "&" ? "" : "&") + document.ltargetform.query_parameters.value : "";
319 var theLink = \'' . $this->siteURL . '?id=\' + id + parameters + (anchor ? anchor : "");
320 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
321 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
322 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
323 if (document.ltargetform.lrel) browse_links_setAdditionalValue("rel", document.ltargetform.lrel.value);
324 browse_links_setAdditionalValue("data-htmlarea-external", "");
325 plugin.createLink(theLink,cur_target,cur_class,cur_title,additionalValues);
326 return false;
327 }
328 function link_folder(folder) {
329 if (folder && folder.substr(0, 5) == "file:") {
330 var theLink = \'' . $this->siteURL . '?file:\' + encodeURIComponent(folder.substr(5));
331 } else {
332 var theLink = \'' . $this->siteURL . '?\' + folder;
333 }
334 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
335 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
336 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
337 if (document.ltargetform.lrel) browse_links_setAdditionalValue("rel", document.ltargetform.lrel.value);
338 browse_links_setAdditionalValue("data-htmlarea-external", "");
339 plugin.createLink(theLink,cur_target,cur_class,cur_title,additionalValues);
340 return false;
341 }
342 function link_spec(theLink) {
343 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
344 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
345 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
346 browse_links_setAdditionalValue("data-htmlarea-external", "");
347 plugin.createLink(theLink,cur_target,cur_class,cur_title,additionalValues);
348 return false;
349 }
350 function link_current() {
351 var parameters = (document.ltargetform.query_parameters && document.ltargetform.query_parameters.value) ? (document.ltargetform.query_parameters.value.charAt(0) == "&" ? "" : "&") + document.ltargetform.query_parameters.value : "";
352 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
353 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
354 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
355 if (document.ltargetform.lrel) browse_links_setAdditionalValue("rel", document.ltargetform.lrel.value);
356 if (cur_href!="http://" && cur_href!="mailto:") {
357 plugin.createLink(cur_href + parameters,cur_target,cur_class,cur_title,additionalValues);
358 }
359 return false;
360 }
361 ';
362 // General "jumpToUrl" and launchView functions:
363 $JScode .= '
364 function jumpToUrl(URL,anchor) {
365 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo=' . $this->editorNo . '" : "";
366 var add_contentTypo3Language = URL.indexOf("contentTypo3Language=")==-1 ? "&contentTypo3Language=' . $this->contentTypo3Language . '" : "";
367 var add_act = URL.indexOf("act=")==-1 ? "&act=' . $this->act . '" : "";
368 var add_mode = URL.indexOf("mode=")==-1 ? "&mode=' . $this->mode . '" : "";
369 var add_additionalValues = "";
370 if (plugin.pageTSConfiguration && plugin.pageTSConfiguration.additionalAttributes) {
371 var additionalAttributes = plugin.pageTSConfiguration.additionalAttributes.split(",");
372 for (var i = additionalAttributes.length; --i >= 0;) {
373 if (additionalValues[additionalAttributes[i]] != "") {
374 add_additionalValues += "&curUrl[" + additionalAttributes[i] + "]=" + encodeURIComponent(additionalValues[additionalAttributes[i]]);
375 }
376 }
377 }
378 var theLocation = URL+add_act+add_editorNo+add_contentTypo3Language+add_mode+add_href+add_target+add_class+add_title+add_additionalValues+add_params+(anchor?anchor:"");
379 window.location.href = theLocation;
380 return false;
381 }
382 function launchView(url) {
383 var thePreviewWindow="";
384 thePreviewWindow = window.open("' . $GLOBALS['BACK_PATH'] . 'show_item.php?table="+url,"ShowItem","height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
385 if (thePreviewWindow && thePreviewWindow.focus) {
386 thePreviewWindow.focus();
387 }
388 }
389 ';
390 // Hook to overwrite or extend javascript functions
391 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['extendJScode']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['extendJScode'])) {
392 $conf = array();
393 $_params = array(
394 'conf' => &$conf
395 );
396 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['extendJScode'] as $objRef) {
397 $processor =& GeneralUtility::getUserObj($objRef);
398 $JScode .= $processor->extendJScode($_params, $this);
399 }
400 }
401 return $JScode;
402 }
403
404 /******************************************************************
405 *
406 * Main functions
407 *
408 ******************************************************************/
409 /**
410 * Rich Text Editor (RTE) link selector (MAIN function)
411 * Generates the link selector for the Rich Text Editor.
412 * Can also be used to select links for the TCEforms (see $wiz)
413 *
414 * @param boolean If set, the "remove link" is not shown in the menu: Used for the "Select link" wizard which is used by the TCEforms
415 * @return string Modified content variable.
416 * @todo Define visibility
417 */
418 public function main_rte($wiz = 0) {
419 // Starting content:
420 $content = $this->doc->startPage($GLOBALS['LANG']->getLL('Insert/Modify Link', TRUE));
421 // Default allowed values
422 $this->allowedItems = explode(',', 'page,file,folder,url,mail,spec');
423 // Calling hook for extra options
424 foreach ($this->hookObjects as $hookObject) {
425 $this->allowedItems = $hookObject->addAllowedItems($this->allowedItems);
426 }
427 // Removing items as per configuration
428 if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
429 $this->allowedItems = array_diff($this->allowedItems, GeneralUtility::trimExplode(',', $this->buttonConfig['options.']['removeItems'], TRUE));
430 }
431 reset($this->allowedItems);
432 if (!in_array($this->act, $this->allowedItems)) {
433 $this->act = current($this->allowedItems);
434 }
435 // Making menu in top:
436 $menuDef = array();
437 if (!$wiz && $this->curUrlArray['href']) {
438 $menuDef['removeLink']['isActive'] = $this->act == 'removeLink';
439 $menuDef['removeLink']['label'] = $GLOBALS['LANG']->getLL('removeLink', TRUE);
440 $menuDef['removeLink']['url'] = '#';
441 $menuDef['removeLink']['addParams'] = 'onclick="plugin.unLink();return false;"';
442 }
443 if (in_array('page', $this->allowedItems)) {
444 $menuDef['page']['isActive'] = $this->act == 'page';
445 $menuDef['page']['label'] = $GLOBALS['LANG']->getLL('page', TRUE);
446 $menuDef['page']['url'] = '#';
447 $menuDef['page']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue(($this->getThisScript() . 'act=page&mode=' . $this->mode . '&bparams=' . $this->bparams)) . ');return false;"';
448 }
449 if (in_array('file', $this->allowedItems)) {
450 $menuDef['file']['isActive'] = $this->act == 'file';
451 $menuDef['file']['label'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.xlf:file', TRUE);
452 $menuDef['file']['url'] = '#';
453 $menuDef['file']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue(($this->getThisScript() . 'act=file&mode=' . $this->mode . '&bparams=' . $this->bparams)) . ');return false;"';
454 }
455 if (in_array('folder', $this->allowedItems)) {
456 $menuDef['folder']['isActive'] = $this->act == 'folder';
457 $menuDef['folder']['label'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.xlf:folder', TRUE);
458 $menuDef['folder']['url'] = '#';
459 $menuDef['folder']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue(($this->getThisScript() . 'act=folder&mode=' . $this->mode . '&bparams=' . $this->bparams)) . ');return false;"';
460 }
461 if (in_array('url', $this->allowedItems)) {
462 $menuDef['url']['isActive'] = $this->act == 'url';
463 $menuDef['url']['label'] = $GLOBALS['LANG']->getLL('extUrl', TRUE);
464 $menuDef['url']['url'] = '#';
465 $menuDef['url']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue(($this->getThisScript() . 'act=url&mode=' . $this->mode . '&bparams=' . $this->bparams)) . ');return false;"';
466 }
467 if (in_array('mail', $this->allowedItems)) {
468 $menuDef['mail']['isActive'] = $this->act == 'mail';
469 $menuDef['mail']['label'] = $GLOBALS['LANG']->getLL('email', TRUE);
470 $menuDef['mail']['url'] = '#';
471 $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue(($this->getThisScript() . 'act=mail&mode=' . $this->mode . '&bparams=' . $this->bparams)) . ');return false;"';
472 }
473 if (is_array($this->thisConfig['userLinks.']) && in_array('spec', $this->allowedItems)) {
474 $menuDef['spec']['isActive'] = $this->act == 'spec';
475 $menuDef['spec']['label'] = $GLOBALS['LANG']->getLL('special', TRUE);
476 $menuDef['spec']['url'] = '#';
477 $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue(($this->getThisScript() . 'act=spec&mode=' . $this->mode . '&bparams=' . $this->bparams)) . ');return false;"';
478 }
479 // call hook for extra options
480 foreach ($this->hookObjects as $hookObject) {
481 $menuDef = $hookObject->modifyMenuDefinition($menuDef);
482 }
483 $content .= $this->doc->getTabMenuRaw($menuDef);
484 // Adding the menu and header to the top of page:
485 $content .= $this->printCurrentUrl($this->curUrlInfo['info']) . '<br />';
486 // Depending on the current action we will create the actual module content for selecting a link:
487 switch ($this->act) {
488 case 'mail':
489 $extUrl = '
490 <!--
491 Enter mail address:
492 -->
493 <tr>
494 <td><label>' . $GLOBALS['LANG']->getLL('emailAddress', TRUE) . ':</label></td>
495 <td><input type="text" name="lemail"' . $this->doc->formWidth(20) . ' value="' . htmlspecialchars(($this->curUrlInfo['act'] == 'mail' ? $this->curUrlInfo['info'] : '')) . '" /> ' . '<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', TRUE) . '" onclick="browse_links_setTarget(\'\');browse_links_setHref(\'mailto:\'+document.ltargetform.lemail.value);browse_links_setAdditionalValue(\'data-htmlarea-external\', \'\');return link_current();" /></td>
496 </tr>';
497 //$content .= $extUrl;
498 $content .= $this->addAttributesForm($extUrl);
499 break;
500 case 'url':
501 $extUrl = '
502 <!--
503 Enter External URL:
504 -->
505 <tr>
506 <td><label>URL:</label></td>
507 <td colspan="3"><input type="text" name="lurl"' . $this->doc->formWidth(20) . ' value="' . htmlspecialchars(($this->curUrlInfo['act'] == 'url' ? $this->curUrlInfo['info'] : 'http://')) . '" /> ' . '<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', TRUE) . '" onclick="if (/^[A-Za-z0-9_+]{1,8}:/.test(document.ltargetform.lurl.value)) { browse_links_setHref(document.ltargetform.lurl.value); } else { browse_links_setHref(\'http://\'+document.ltargetform.lurl.value); }; browse_links_setAdditionalValue(\'data-htmlarea-external\', \'1\'); return link_current();" /></td>
508 </tr>';
509 $content .= $this->addAttributesForm($extUrl);
510 break;
511 case 'file':
512 case 'folder':
513 $content .= $this->addAttributesForm();
514 // Create folder tree:
515 $this->doc->JScode .= $this->doc->wrapScriptTags('
516 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
517 ');
518 $foldertree = GeneralUtility::makeInstance('TYPO3\\CMS\\Rtehtmlarea\\FolderTree');
519 $foldertree->thisScript = $this->thisScript;
520 $tree = $foldertree->getBrowsableTree();
521 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act) {
522 $cmpPath = '';
523 } else {
524 $cmpPath = $this->curUrlInfo['value'];
525 if (!isset($this->expandFolder)) {
526 $this->expandFolder = $cmpPath;
527 }
528 }
529 // Get the selected folder
530 $selectedFolder = FALSE;
531 if ($this->expandFolder) {
532 try {
533 $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
534 } catch (\Exception $e) {
535 // No path is selected
536 }
537 if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
538 // It's a folder
539 $selectedFolder = $fileOrFolderObject;
540 } elseif ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
541 // It's a file
542 $selectedFolder = $fileOrFolderObject->getParentFolder();
543 }
544 }
545 // If no folder is selected, get the user's default upload folder
546 if (!$selectedFolder) {
547 try {
548 $selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
549 } catch (\Exception $e) {
550 // The configured default user folder does not exist
551 }
552 }
553 // Build the file upload and folder creation forms
554 $uploadForm = '';
555 $createFolder = '';
556 if ($selectedFolder) {
557 $uploadForm = ($this->act === 'file') ? $this->uploadForm($selectedFolder) : '';
558 $createFolder = $this->createFolder($selectedFolder);
559 }
560 // Insert the upload form on top, if so configured
561 if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
562 $content .= $uploadForm;
563 }
564 // Render the filelist if there is a folder selected
565 if ($selectedFolder) {
566 $files = $this->expandFolder($selectedFolder, $this->P['params']['allowedExtensions']);
567 }
568 $content .= '
569
570 <!--
571 Wrapper table for folder tree / file/folder list:
572 -->
573 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
574 <tr>
575 <td class="c-wCell" valign="top">' . $this->barheader(($GLOBALS['LANG']->getLL('folderTree') . ':')) . $tree . '</td>
576 <td class="c-wCell" valign="top">' . $files . '</td>
577 </tr>
578 </table>
579 ';
580 // Adding create folder + upload form if applicable
581 if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
582 $content .= $uploadForm;
583 }
584 $content .= '<br />';
585 $content .= $createFolder;
586 $content .= '<br />';
587 break;
588 case 'spec':
589 if (is_array($this->thisConfig['userLinks.'])) {
590 $subcats = array();
591 $v = $this->thisConfig['userLinks.'];
592 foreach ($v as $k2 => $dummyValue) {
593 $k2i = (int)$k2;
594 if (substr($k2, -1) == '.' && is_array($v[$k2i . '.'])) {
595 // Title:
596 $title = trim($v[$k2i]);
597 if (!$title) {
598 $title = $v[$k2i . '.']['url'];
599 } else {
600 $title = $GLOBALS['LANG']->sL($title);
601 }
602 // Description:
603 $description = $v[$k2i . '.']['description'] ? $GLOBALS['LANG']->sL($v[($k2i . '.')]['description'], TRUE) . '<br />' : '';
604 // URL + onclick event:
605 $onClickEvent = '';
606 if (isset($v[$k2i . '.']['target'])) {
607 $onClickEvent .= 'TYPO3\\CMS\\Recordlist\\Browser\\ElementBrowser_setTarget(\'' . $v[($k2i . '.')]['target'] . '\');';
608 }
609 $v[$k2i . '.']['url'] = str_replace('###_URL###', $this->siteURL, $v[$k2i . '.']['url']);
610 if (substr($v[$k2i . '.']['url'], 0, 7) == 'http://' || substr($v[$k2i . '.']['url'], 0, 7) == 'mailto:') {
611 $onClickEvent .= 'cur_href=' . GeneralUtility::quoteJSvalue($v[($k2i . '.')]['url']) . ';link_current();';
612 } else {
613 $onClickEvent .= 'link_spec(' . GeneralUtility::quoteJSvalue($this->siteURL . $v[($k2i . '.')]['url']) . ');';
614 }
615 // Link:
616 $A = array('<a href="#" onclick="' . htmlspecialchars($onClickEvent) . 'return false;">', '</a>');
617 // Adding link to menu of user defined links:
618 $subcats[$k2i] = '
619 <tr>
620 <td class="bgColor4">' . $A[0] . '<strong>' . htmlspecialchars($title) . ($this->curUrlInfo['info'] == $v[$k2i . '.']['url'] ? '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_right.gif', 'width="5" height="9"') . ' class="c-blinkArrowR" alt="" />' : '') . '</strong><br />' . $description . $A[1] . '</td>
621 </tr>';
622 }
623 }
624 // Sort by keys:
625 ksort($subcats);
626 // Add menu to content:
627 $content .= '
628 <!--
629 Special userdefined menu:
630 -->
631 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
632 <tr>
633 <td class="bgColor5" class="c-wCell" valign="top"><strong>' . $GLOBALS['LANG']->getLL('special', TRUE) . '</strong></td>
634 </tr>
635 ' . implode('', $subcats) . '
636 </table>
637 ';
638 }
639 break;
640 case 'page':
641 $content .= $this->addAttributesForm();
642 $pagetree = GeneralUtility::makeInstance('TYPO3\\CMS\\Rtehtmlarea\\PageTree');
643 $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
644 $pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
645 $pagetree->addField('nav_title');
646 $tree = $pagetree->getBrowsableTree();
647 $cElements = $this->expandPage();
648 $dbmount = $this->getTemporaryTreeMountCancelNotice();
649 $content .= '
650 <!--
651 Wrapper table for page tree / record list:
652 -->
653 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
654 <tr>
655 <td class="c-wCell" valign="top">' . $this->barheader(($GLOBALS['LANG']->getLL('pageTree') . ':')) . $dbmount . $tree . '</td>
656 <td class="c-wCell" valign="top">' . $cElements . '</td>
657 </tr>
658 </table>
659 ';
660 break;
661 default:
662 // call hook
663 foreach ($this->hookObjects as $hookObject) {
664 $content .= $hookObject->getTab($this->act);
665 }
666 }
667 // End page, return content:
668 $content .= $this->doc->endPage();
669 $content = $this->doc->insertStylesAndJS($content);
670 return $content;
671 }
672
673 /**
674 * Creates a form for link attributes
675 *
676 * @param string $rows: html code for some initial rows of the table to be wrapped in form
677 * @return string The HTML code of the form
678 */
679 public function addAttributesForm($rows = '') {
680 $ltargetForm = '';
681 $additionalAttributeFields = '';
682 // Add page id, target, class selector box, title and parameters fields:
683 $lpageId = $this->addPageIdSelector();
684 $queryParameters = $this->addQueryParametersSelector();
685 $ltarget = $this->addTargetSelector();
686 $lclass = $this->addClassSelector();
687 $ltitle = $this->addTitleSelector();
688 $rel = $this->addRelField();
689 // additional fields for links
690 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['addAttributeFields']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['addAttributeFields'])) {
691 $conf = array();
692 $_params = array(
693 'conf' => &$conf
694 );
695 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['addAttributeFields'] as $objRef) {
696 $processor =& GeneralUtility::getUserObj($objRef);
697 $additionalAttributeFields .= $processor->getAttributefields($_params, $this);
698 }
699 }
700 if ($rows || $lpageId || $queryParameters || $lclass || $ltitle || $ltarget || $rel) {
701 $ltargetForm = $this->wrapInForm($rows . $lpageId . $queryParameters . $lclass . $ltitle . $ltarget . $rel . $additionalAttributeFields);
702 }
703 return $ltargetForm;
704 }
705
706 /**
707 * @todo Define visibility
708 */
709 public function wrapInForm($string) {
710 $form = '
711 <!--
712 Selecting target for link:
713 -->
714 <form action="" name="ltargetform" id="ltargetform">
715 <table id="typo3-linkTarget" class="htmlarea-window-table">' . $string;
716 if ($this->act == $this->curUrlInfo['act'] && $this->act != 'mail' && $this->curUrlArray['href']) {
717 $form .= '
718 <tr>
719 <td>
720 </td>
721 <td colspan="3">
722 <input type="submit" value="' . $GLOBALS['LANG']->getLL('update', TRUE) . '" onclick="' . ($this->act == 'url' ? 'browse_links_setAdditionalValue(\'data-htmlarea-external\', \'1\'); ' : '') . 'return link_current();" />
723 </td>
724 </tr>';
725 }
726 $form .= '
727 </table>
728 </form>';
729 return $form;
730 }
731
732 /**
733 * @todo Define visibility
734 */
735 public function addPageIdSelector() {
736 return $this->act == 'page' && $this->buttonConfig && is_array($this->buttonConfig['pageIdSelector.']) && $this->buttonConfig['pageIdSelector.']['enabled'] ? '
737 <tr>
738 <td><label>' . $GLOBALS['LANG']->getLL('page_id', TRUE) . ':</label></td>
739 <td colspan="3">
740 <input type="text" size="6" name="luid" />&nbsp;<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', TRUE) . '" onclick="return link_typo3Page(document.ltargetform.luid.value);" />
741 </td>
742 </tr>' : '';
743 }
744
745 /**
746 * @todo Define visibility
747 */
748 public function addRelField() {
749 return ($this->act == 'page' || $this->act == 'url' || $this->act == 'file') && $this->buttonConfig && is_array($this->buttonConfig['relAttribute.']) && $this->buttonConfig['relAttribute.']['enabled'] ? '
750 <tr>
751 <td><label>' . $GLOBALS['LANG']->getLL('linkRelationship', TRUE) . ':</label></td>
752 <td colspan="3">
753 <input type="text" name="lrel" value="' . $this->additionalAttributes['rel'] . '" ' . $this->doc->formWidth(30) . ' />
754 </td>
755 </tr>' : '';
756 }
757
758 /**
759 * @todo Define visibility
760 */
761 public function addQueryParametersSelector() {
762 return $this->act == 'page' && $this->buttonConfig && is_array($this->buttonConfig['queryParametersSelector.']) && $this->buttonConfig['queryParametersSelector.']['enabled'] ? '
763 <tr>
764 <td><label>' . $GLOBALS['LANG']->getLL('query_parameters', TRUE) . ':</label></td>
765 <td colspan="3">
766 <input type="text" name="query_parameters" value="' . ($this->curUrlInfo['query'] ?: '') . '" ' . $this->doc->formWidth(30) . ' />
767 </td>
768 </tr>' : '';
769 }
770
771 /**
772 * @todo Define visibility
773 */
774 public function addTargetSelector() {
775 $targetSelectorConfig = array();
776 $popupSelectorConfig = array();
777 if (is_array($this->buttonConfig['targetSelector.'])) {
778 $targetSelectorConfig = $this->buttonConfig['targetSelector.'];
779 }
780 if (is_array($this->buttonConfig['popupSelector.'])) {
781 $popupSelectorConfig = $this->buttonConfig['popupSelector.'];
782 }
783 $ltarget = '';
784 if ($this->act != 'mail') {
785 $ltarget .= '
786 <tr id="ltargetrow"' . ($targetSelectorConfig['disabled'] && $popupSelectorConfig['disabled'] ? ' style="display: none;"' : '') . '>
787 <td><label>' . $GLOBALS['LANG']->getLL('target', TRUE) . ':</label></td>
788 <td><input type="text" name="ltarget" onchange="browse_links_setTarget(this.value);" value="' . htmlspecialchars(($this->setTarget ? $this->setTarget : ($this->setClass || !$this->classesAnchorDefault[$this->act] ? '' : $this->classesAnchorDefaultTarget[$this->act]))) . '"' . $this->doc->formWidth(10) . ' /></td>';
789 $ltarget .= '
790 <td colspan="2">';
791 if (!$targetSelectorConfig['disabled']) {
792 $ltarget .= '
793 <select name="ltarget_type" onchange="browse_links_setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
794 <option></option>
795 <option value="_top">' . $GLOBALS['LANG']->getLL('top', TRUE) . '</option>
796 <option value="_blank">' . $GLOBALS['LANG']->getLL('newWindow', TRUE) . '</option>
797 </select>';
798 }
799 $ltarget .= '
800 </td>
801 </tr>';
802 if (!$popupSelectorConfig['disabled']) {
803 $selectJS = 'if (document.ltargetform.popup_width.options[document.ltargetform.popup_width.selectedIndex].value>0 && document.ltargetform.popup_height.options[document.ltargetform.popup_height.selectedIndex].value>0) {
804 document.ltargetform.ltarget.value = document.ltargetform.popup_width.options[document.ltargetform.popup_width.selectedIndex].value+\'x\'+document.ltargetform.popup_height.options[document.ltargetform.popup_height.selectedIndex].value;
805 browse_links_setTarget(document.ltargetform.ltarget.value);
806 document.ltargetform.popup_width.selectedIndex=0;
807 document.ltargetform.popup_height.selectedIndex=0;
808 }';
809 $ltarget .= '
810 <tr>
811 <td><label>' . $GLOBALS['LANG']->getLL('target_popUpWindow', TRUE) . ':</label></td>
812 <td colspan="3">
813 <select name="popup_width" onchange="' . $selectJS . '">
814 <option value="0">' . $GLOBALS['LANG']->getLL('target_popUpWindow_width', TRUE) . '</option>
815 <option value="300">300</option>
816 <option value="400">400</option>
817 <option value="500">500</option>
818 <option value="600">600</option>
819 <option value="700">700</option>
820 <option value="800">800</option>
821 </select>
822 x
823 <select name="popup_height" onchange="' . $selectJS . '">
824 <option value="0">' . $GLOBALS['LANG']->getLL('target_popUpWindow_height', TRUE) . '</option>
825 <option value="200">200</option>
826 <option value="300">300</option>
827 <option value="400">400</option>
828 <option value="500">500</option>
829 <option value="600">600</option>
830 </select>
831 </td>
832 </tr>';
833 }
834 }
835 return $ltarget;
836 }
837
838 /**
839 * Return html code for the class selector
840 *
841 * @return string the html code to be added to the form
842 */
843 public function addClassSelector() {
844 $selectClass = '';
845 if ($this->classesAnchorJSOptions[$this->act]) {
846 $selectClass = '
847 <tr>
848 <td><label>' . $GLOBALS['LANG']->getLL('anchor_class', TRUE) . ':</label></td>
849 <td colspan="3">
850 <select name="anchor_class" onchange="' . $this->getClassOnChangeJS() . '">
851 ' . $this->classesAnchorJSOptions[$this->act] . '
852 </select>
853 </td>
854 </tr>';
855 }
856 return $selectClass;
857 }
858
859 /**
860 * Return JS code for the class selector onChange event
861 *
862 * @return string class selector onChange JS code
863 */
864 public function getClassOnChangeJS() {
865 return '
866 if (document.ltargetform.anchor_class) {
867 document.ltargetform.anchor_class.value = document.ltargetform.anchor_class.options[document.ltargetform.anchor_class.selectedIndex].value;
868 if (document.ltargetform.anchor_class.value && HTMLArea.classesAnchorSetup) {
869 for (var i = HTMLArea.classesAnchorSetup.length; --i >= 0;) {
870 var anchorClass = HTMLArea.classesAnchorSetup[i];
871 if (anchorClass[\'name\'] == document.ltargetform.anchor_class.value) {
872 if (anchorClass[\'titleText\'] && document.ltargetform.anchor_title) {
873 document.ltargetform.anchor_title.value = anchorClass[\'titleText\'];
874 document.getElementById(\'rtehtmlarea-browse-links-title-readonly\').innerHTML = anchorClass[\'titleText\'];
875 browse_links_setTitle(anchorClass[\'titleText\']);
876 }
877 if (anchorClass[\'target\']) {
878 if (document.ltargetform.ltarget) {
879 document.ltargetform.ltarget.value = anchorClass[\'target\'];
880 }
881 browse_links_setTarget(anchorClass[\'target\']);
882 } else if (document.ltargetform.ltarget && document.getElementById(\'ltargetrow\').style.display == \'none\') {
883 // Reset target to default if field is not displayed and class has no configured target
884 document.ltargetform.ltarget.value = \'' . ($this->defaultLinkTarget ?: '') . '\';
885 browse_links_setTarget(document.ltargetform.ltarget.value);
886 }
887 break;
888 }
889 }
890 }
891 browse_links_setClass(document.ltargetform.anchor_class.value);
892 }
893 ';
894 }
895
896 /**
897 * @todo Define visibility
898 */
899 public function addTitleSelector() {
900 $title = $this->setTitle ?: ($this->setClass || !$this->classesAnchorDefault[$this->act] ? '' : $this->classesAnchorDefaultTitle[$this->act]);
901 $readOnly = $this->buttonConfig['properties.']['title.']['readOnly'] || $this->buttonConfig[$this->act . '.']['properties.']['title.']['readOnly'];
902 if ($readOnly) {
903 $title = $this->setClass ? $this->classesAnchorClassTitle[$this->setClass] : $this->classesAnchorDefaultTitle[$this->act];
904 }
905 return '
906 <tr>
907 <td><label for="rtehtmlarea-browse-links-anchor_title" id="rtehtmlarea-browse-links-title-label">' . $GLOBALS['LANG']->getLL('anchor_title', TRUE) . ':</label></td>
908 <td colspan="3">
909 <span id="rtehtmlarea-browse-links-title-input" style="display: ' . ($readOnly ? 'none' : 'inline') . ';">
910 <input type="text" id="rtehtmlarea-browse-links-anchor_title" name="anchor_title" value="' . $title . '" ' . $this->doc->formWidth(30) . ' />
911 </span>
912 <span id="rtehtmlarea-browse-links-title-readonly" style="display: ' . ($readOnly ? 'inline' : 'none') . ';">' . $title . '</span>
913 </td>
914 </tr>';
915 }
916
917 /**
918 * Localize a string using the language of the content element rather than the language of the BE interface
919 *
920 * @param string string: the label to be localized
921 * @return string Localized string.
922 */
923 public function getLLContent($string) {
924 return $this->contentLanguageService->sL($string);
925 }
926
927 /**
928 * Localize a label obtained from Page TSConfig
929 *
930 * @param string $string The label to be localized
931 * @param boolean $JScharCode If needs to be converted to a array of char numbers
932 * @return string Localized string.
933 */
934 public function getPageConfigLabel($string, $JScharCode = 1) {
935 if (substr($string, 0, 4) !== 'LLL:') {
936 $label = $string;
937 } else {
938 $label = $GLOBALS['LANG']->sL(trim($string));
939 }
940 $label = str_replace('"', '\\"', str_replace('\\\'', '\'', $label));
941 $label = $JScharCode ? GeneralUtility::quoteJSvalue($label) : $label;
942 return $label;
943 }
944
945 }