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