TYPO3 CMS  TYPO3_8-7
ElementBrowserFolderTreeView.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
30 {
34  public $ext_IconMode = 'titlelink';
35 
40 
45  {
46  $this->linkParameterProvider = $linkParameterProvider;
47  $this->thisScript = $linkParameterProvider->getScriptUrl();
48  }
49 
59  public function wrapIcon($icon, $folderObject)
60  {
61  // Add title attribute to input icon tag
62  $theFolderIcon = '';
63 
64  // Wrap icon in link (in ElementBrowser only the "titlelink" is used).
65  if ($this->ext_IconMode === 'titlelink' && $this->ext_isLinkable($folderObject)) {
66  $parameters = GeneralUtility::implodeArrayForUrl('', $this->linkParameterProvider->getUrlParameters(['identifier' => $folderObject->getCombinedIdentifier()]));
67  $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . ltrim($parameters, '&')) . ');';
68  $theFolderIcon = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
69  }
70 
71  return $theFolderIcon;
72  }
73 
82  public function wrapTitle($title, $folderObject, $bank = 0)
83  {
84  if ($this->ext_isLinkable($folderObject)) {
85  $parameters = GeneralUtility::implodeArrayForUrl('', $this->linkParameterProvider->getUrlParameters(['identifier' => $folderObject->getCombinedIdentifier()]));
86  return '<a href="#" onclick="return jumpToUrl(' . htmlspecialchars(GeneralUtility::quoteJSvalue($this->getThisScript() . ltrim($parameters, '&'))) . ');">' . $title . '</a>';
87  }
88  return '<span class="text-muted">' . $title . '</span>';
89  }
90 
97  public function ext_isLinkable(Folder $folderObject)
98  {
99  $identifier = $folderObject->getIdentifier();
100  return !$this->ext_noTempRecyclerDirs || substr($identifier, -7) !== '_temp_/' && substr($identifier, -11) !== '_recycler_/';
101  }
102 
108  protected function renderPMIconAndLink($cmd, $isOpen)
109  {
110  if (get_class($this) === __CLASS__) {
111  return $this->PMiconATagWrap('', $cmd, !$isOpen);
112  }
113  return parent::renderPMIconAndLink($cmd, $isOpen);
114  }
115 
126  public function PM_ATagWrap($icon, $cmd, $bMark = '', $isOpen = false)
127  {
128  $anchor = $bMark ? '#' . $bMark : '';
129  $name = $bMark ? ' name=' . $bMark : '';
130  $urlParameters = $this->linkParameterProvider->getUrlParameters([]);
131  $urlParameters['PM'] = $cmd;
132  $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . ltrim(GeneralUtility::implodeArrayForUrl('', $urlParameters), '&')) . ',' . GeneralUtility::quoteJSvalue($anchor) . ');';
133  return '<a href="#"' . htmlspecialchars($name) . ' onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
134  }
135 
145  public function PMiconATagWrap($icon, $cmd, $isExpand = true)
146  {
147  if (empty($this->scope)) {
148  $this->scope = [
149  'class' => get_class($this),
150  'script' => $this->thisScript,
151  'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs,
152  'browser' => $this->linkParameterProvider->getUrlParameters([]),
153  ];
154  }
155 
156  return parent::PMiconATagWrap($icon, $cmd, $isExpand);
157  }
158 }
setLinkParameterProvider(LinkParameterProviderInterface $linkParameterProvider)
static implodeArrayForUrl($name, array $theArray, $str='', $skipBlank=false, $rawurlencodeParamName=false)