TYPO3 CMS  TYPO3_6-2
Typo3Link.php
Go to the documentation of this file.
1 <?php
3 
18 
25 
26  protected $extensionKey = 'rtehtmlarea';
27 
28  // The key of the extension that is extending htmlArea RTE
29  protected $pluginName = 'TYPO3Link';
30 
31  // The name of the plugin registered by the extension
33 
34  // Path to this main locallang file of the extension relative to the extension dir.
35  protected $relativePathToSkin = 'extensions/TYPO3Link/skin/htmlarea.css';
36 
37  // Path to the skin (css) file relative to the extension dir.
38  protected $htmlAreaRTE;
39 
40  // Reference to the invoking object
41  protected $thisConfig;
42 
43  // Reference to RTE PageTSConfig
44  protected $toolbar;
45 
46  // Reference to RTE toolbar array
47  protected $LOCAL_LANG;
48 
49  // Frontend language array
50  protected $pluginButtons = 'link, unlink';
51 
53  'link' => 'CreateLink',
54  'unlink' => 'UnLink'
55  );
56 
57  public function main($parentObject) {
58  $enabled = parent::main($parentObject);
59  // Check if this should be enabled based on Page TSConfig
60  return $enabled && !$this->thisConfig['buttons.']['link.']['TYPO3Browser.']['disabled'];
61  }
62 
69  public function buildJavascriptConfiguration($RTEcounter) {
70  $registerRTEinJavascriptString = '';
71  $button = 'link';
72  if (in_array($button, $this->toolbar)) {
73  if (!is_array($this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.'][($button . '.')])) {
74  $registerRTEinJavascriptString .= '
75  RTEarea[' . $RTEcounter . '].buttons.' . $button . ' = new Object();';
76  }
77  $registerRTEinJavascriptString .= '
78  RTEarea[' . $RTEcounter . '].buttons.' . $button . '.pathLinkModule = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('rtehtmlarea_wizard_element_browser'));
79  if ($this->htmlAreaRTE->is_FE()) {
80  $RTEProperties = $this->htmlAreaRTE->RTEsetup;
81  } else {
82  $RTEProperties = $this->htmlAreaRTE->RTEsetup['properties'];
83  }
84  if (is_array($RTEProperties['classesAnchor.'])) {
85  $registerRTEinJavascriptString .= '
86  RTEarea[' . $RTEcounter . '].buttons.' . $button . '.classesAnchorUrl = "' . $this->htmlAreaRTE->writeTemporaryFile('', ('classesAnchor_' . $this->htmlAreaRTE->contentLanguageUid), 'js', $this->buildJSClassesAnchorArray(), TRUE) . '";';
87  }
88  $registerRTEinJavascriptString .= '
89  RTEarea[' . $RTEcounter . '].buttons.' . $button . '.additionalAttributes = "data-htmlarea-external' . ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey]['plugins'][$this->pluginName]['additionalAttributes'] ? ',' . $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey]['plugins'][$this->pluginName]['additionalAttributes'] : '') . '";';
90  }
91  return $registerRTEinJavascriptString;
92  }
93 
99  public function buildJSClassesAnchorArray() {
100  global $LANG;
101  $JSClassesAnchorArray .= 'HTMLArea.classesAnchorSetup = [ ' . LF;
102  $classesAnchorIndex = 0;
103  foreach ($this->htmlAreaRTE->RTEsetup['properties']['classesAnchor.'] as $label => $conf) {
104  if (is_array($conf) && $conf['class']) {
105  $JSClassesAnchorArray .= ($classesAnchorIndex++ ? ',' : '') . ' { ' . LF;
106  $index = 0;
107  $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'name : "' . str_replace('"', '', str_replace('\'', '', $conf['class'])) . '"' . LF;
108  if ($conf['type']) {
109  $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'type : "' . str_replace('"', '', str_replace('\'', '', $conf['type'])) . '"' . LF;
110  }
111  if (trim(str_replace('\'', '', str_replace('"', '', $conf['image'])))) {
112  $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'image : "' . $this->htmlAreaRTE->siteURL . \TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath((TYPO3_mainDir . $this->htmlAreaRTE->getFullFileName(trim(str_replace('\'', '', str_replace('"', '', $conf['image'])))))) . '"' . LF;
113  }
114  $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'addIconAfterLink : ' . ($conf['addIconAfterLink'] ? 'true' : 'false') . LF;
115  if (trim($conf['altText'])) {
116  $string = $this->htmlAreaRTE->getLLContent(trim($conf['altText']));
117  $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'altText : ' . str_replace('"', '\\"', str_replace('\\\'', '\'', $string)) . LF;
118  }
119  if (trim($conf['titleText'])) {
120  $string = $this->htmlAreaRTE->getLLContent(trim($conf['titleText']));
121  $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'titleText : ' . str_replace('"', '\\"', str_replace('\\\'', '\'', $string)) . LF;
122  }
123  if (trim($conf['target'])) {
124  $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'target : "' . trim($conf['target']) . '"' . LF;
125  }
126  $JSClassesAnchorArray .= '}' . LF;
127  }
128  }
129  $JSClassesAnchorArray .= '];' . LF;
130  return $JSClassesAnchorArray;
131  }
132 
139  public function applyToolbarConstraints($show) {
140  // We will not allow unlink if link is not enabled
141  if (!in_array('link', $show)) {
142  return array_diff($show, \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->pluginButtons));
143  } else {
144  return $show;
145  }
146  }
147 
148 }
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
static getModuleUrl($moduleName, $urlParameters=array(), $backPathOverride=FALSE, $returnAbsoluteUrl=FALSE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]