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