TYPO3  7.6
MetaInformation.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Template\Components;
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 
17 use TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException;
18 use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
27 
32 {
33 
40  protected $recordArray = [];
41 
49  public function setRecordArray(array $recordArray)
50  {
51  $this->recordArray = $recordArray;
52  }
53 
59  public function getPath()
60  {
61  $pageRecord = $this->recordArray;
62  $title = '';
63  // Is this a real page
64  if (is_array($pageRecord) && $pageRecord['uid']) {
65  $title = substr($pageRecord['_thePathFull'], 0, -1);
66  // Remove current page title
67  $pos = strrpos($title, $pageRecord['title']);
68  if ($pos !== false) {
69  $title = substr($title, 0, $pos);
70  }
71  } elseif (!empty($pageRecord['combined_identifier'])) {
72  try {
73  $resourceObject = ResourceFactory::getInstance()->getInstance()->getObjectFromCombinedIdentifier($pageRecord['combined_identifier']);
74  $title = $resourceObject->getStorage()->getName() . ':';
75  $title .= $resourceObject->getParentFolder()->getReadablePath();
76  } catch (ResourceDoesNotExistException $e) {
78  }
79  }
80  // Setting the path of the page
81  // crop the title to title limit (or 50, if not defined)
82  $beUser = $this->getBackendUser();
83  $cropLength = empty($beUser->uc['titleLen']) ? 50 : $beUser->uc['titleLen'];
84  $croppedTitle = GeneralUtility::fixed_lgd_cs($title, -$cropLength);
85  if ($croppedTitle !== $title) {
86  $pagePath = '<abbr title="' . htmlspecialchars($title) . '">' . htmlspecialchars($croppedTitle) . '</abbr>';
87  } else {
88  $pagePath = htmlspecialchars($title);
89  }
90  return $pagePath;
91  }
92 
98  public function getRecordInformation()
99  {
100  $pageRecord = $this->recordArray;
101  if (empty($pageRecord)) {
102  return '';
103  }
104 
105  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
106  $uid = '';
107  $title = '';
108  $additionalInfo = (!empty($pageRecord['_additional_info']) ? $pageRecord['_additional_info'] : '');
109  // Add icon with clickMenu, etc:
110  // If there IS a real page
111  if (is_array($pageRecord) && $pageRecord['uid']) {
112  $toolTip = BackendUtility::getRecordToolTip($pageRecord, 'pages');
113  $iconImg = '<span ' . $toolTip . '>' . $iconFactory->getIconForRecord('pages', $pageRecord, Icon::SIZE_SMALL)->render() . '</span>';
114  // Make Icon:
115  $theIcon = BackendUtility::wrapClickMenuOnIcon($iconImg, 'pages', $pageRecord['uid']);
116  $uid = $pageRecord['uid'];
117  $title = BackendUtility::getRecordTitle('pages', $pageRecord);
118  // If the module is about a FAL resource
119  } elseif (is_array($pageRecord) && !empty($pageRecord['combined_identifier'])) {
120  try {
121  $resourceObject = ResourceFactory::getInstance()->getInstance()->getObjectFromCombinedIdentifier($pageRecord['combined_identifier']);
122  $fileMountTitle = $resourceObject->getStorage()->getFileMounts()[$resourceObject->getIdentifier()]['title'];
123  $title = $fileMountTitle ?: $resourceObject->getName();
124  // If this is a folder but not in within file mount boundaries this is the root folder
125  if ($resourceObject instanceof FolderInterface && !$resourceObject->getStorage()->isWithinFileMountBoundaries($resourceObject)) {
126  $iconImg = '<span title="' . htmlspecialchars($title) . '">' . $iconFactory->getIconForResource(
127  $resourceObject,
129  null,
130  array('mount-root' => true)
131  )->render() . '</span>';
132  } else {
133  $iconImg = '<span title="' . htmlspecialchars($title) . '">' . $iconFactory->getIconForResource(
134  $resourceObject,
136  )->render() . '</span>';
137  }
138  $theIcon = BackendUtility::wrapClickMenuOnIcon($iconImg, $pageRecord['combined_identifier']);
139  } catch (ResourceDoesNotExistException $e) {
140  $theIcon = '';
141  }
142  } else {
143  // On root-level of page tree
144  // Make Icon
145  $iconImg = '<span title="' .
146  htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) .
147  '">' .
148  $iconFactory->getIcon('apps-pagetree-root', Icon::SIZE_SMALL)->render() . '</span>';
149  if ($this->getBackendUser()->isAdmin()) {
150  $theIcon = BackendUtility::wrapClickMenuOnIcon($iconImg, 'pages', 0);
151  } else {
152  $theIcon = $iconImg;
153  }
154  $uid = '0';
155  $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
156  }
157  // Setting icon with clickMenu + uid
158  return $theIcon .
159  ' <strong>' . htmlspecialchars($title) . ($uid !== '' ? '&nbsp;[' . $uid . ']' : '') . '</strong>' .
160  (!empty($additionalInfo) ? ' ' . htmlspecialchars($additionalInfo) : '');
161  }
162 
168  protected function getLanguageService()
169  {
170  return $GLOBALS['LANG'];
171  }
172 
178  protected function getBackendUser()
179  {
180  return $GLOBALS['BE_USER'];
181  }
182 }