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