TYPO3 CMS  TYPO3_7-6
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 
47  {
48  $this->linkParameterProvider = $linkParameterProvider;
49  $this->thisScript = $linkParameterProvider->getScriptUrl();
50  }
51 
61  public function wrapIcon($icon, $folderObject)
62  {
63  // Add title attribute to input icon tag
64  $theFolderIcon = '';
65 
66  // Wrap icon in link (in ElementBrowser only the "titlelink" is used).
67  if ($this->ext_IconMode === 'titlelink' && $this->ext_isLinkable($folderObject)) {
68  $parameters = GeneralUtility::implodeArrayForUrl('', $this->linkParameterProvider->getUrlParameters(['identifier' => $folderObject->getCombinedIdentifier()]));
69  $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . ltrim($parameters, '&')) . ');';
70  $theFolderIcon = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
71  }
72 
73  return $theFolderIcon;
74  }
75 
84  public function wrapTitle($title, $folderObject, $bank = 0)
85  {
86  if ($this->ext_isLinkable($folderObject)) {
87  $parameters = GeneralUtility::implodeArrayForUrl('', $this->linkParameterProvider->getUrlParameters(['identifier' => $folderObject->getCombinedIdentifier()]));
88  return '<a href="#" onclick="return jumpToUrl(' . htmlspecialchars(GeneralUtility::quoteJSvalue($this->getThisScript() . ltrim($parameters, '&'))) . ');">' . $title . '</a>';
89  } else {
90  return '<span class="text-muted">' . $title . '</span>';
91  }
92  }
93 
100  public function ext_isLinkable(Folder $folderObject)
101  {
102  $identifier = $folderObject->getIdentifier();
103  return !$this->ext_noTempRecyclerDirs || substr($identifier, -7) !== '_temp_/' && substr($identifier, -11) !== '_recycler_/';
104  }
105 
111  protected function renderPMIconAndLink($cmd, $isOpen)
112  {
113  if (get_class($this) === __CLASS__) {
114  return $this->PMiconATagWrap('', $cmd, !$isOpen);
115  }
116  return parent::renderPMIconAndLink($cmd, $isOpen);
117  }
118 
129  public function PM_ATagWrap($icon, $cmd, $bMark = '', $isOpen = false)
130  {
131  $anchor = $bMark ? '#' . $bMark : '';
132  $name = $bMark ? ' name=' . $bMark : '';
133  $urlParameters = $this->linkParameterProvider->getUrlParameters([]);
134  $urlParameters['PM'] = $cmd;
135  $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . ltrim(GeneralUtility::implodeArrayForUrl('', $urlParameters), '&')) . ',' . GeneralUtility::quoteJSvalue($anchor) . ');';
136  return '<a href="#"' . htmlspecialchars($name) . ' onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
137  }
138 
148  public function PMiconATagWrap($icon, $cmd, $isExpand = true)
149  {
150  if (empty($this->scope)) {
151  $this->scope = [
152  'class' => get_class($this),
153  'script' => $this->thisScript,
154  'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs,
155  'browser' => $this->linkParameterProvider->getUrlParameters([]),
156  ];
157  }
158 
159  return parent::PMiconATagWrap($icon, $cmd, $isExpand);
160  }
161 }
setLinkParameterProvider(LinkParameterProviderInterface $linkParameterProvider)
static implodeArrayForUrl($name, array $theArray, $str='', $skipBlank=false, $rawurlencodeParamName=false)