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