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