TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
ShortcutButton.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Template\Components\Buttons\Action;
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 
24 
39 {
43  protected $moduleName;
44 
48  protected $displayName;
49 
53  protected $setVariables = [];
54 
58  protected $getVariables = [];
59 
63  protected $controllerContext;
64 
70  public function getModuleName()
71  {
72  return $this->moduleName;
73  }
74 
81  public function setModuleName($moduleName)
82  {
83  $this->moduleName = $moduleName;
84  return $this;
85  }
86 
92  public function getDisplayName()
93  {
94  return $this->displayName;
95  }
96 
103  public function setDisplayName($displayName)
104  {
105  $this->displayName = $displayName;
106  return $this;
107  }
108 
114  public function getSetVariables()
115  {
116  return $this->setVariables;
117  }
118 
125  public function setSetVariables(array $setVariables)
126  {
127  $this->setVariables = $setVariables;
128  return $this;
129  }
130 
136  public function getGetVariables()
137  {
138  return $this->getVariables;
139  }
140 
147  public function setGetVariables(array $getVariables)
148  {
149  $this->getVariables = $getVariables;
150  return $this;
151  }
152 
158  public function getPosition()
159  {
161  }
162 
168  public function getGroup()
169  {
170  return 91;
171  }
172 
178  public function getType()
179  {
180  return get_class($this);
181  }
182 
190  public function isValid()
191  {
192  $this->preProcess();
193 
194  return
195  !empty($this->moduleName)
196  ;
197  }
198 
204  public function __toString()
205  {
206  return $this->render();
207  }
208 
214  public function render()
215  {
216  if ($this->getBackendUser()->mayMakeShortcut()) {
218  $moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
219  $shortcutMarkup = $moduleTemplate->makeShortcutIcon(
220  implode(',', $this->getVariables),
221  implode(',', $this->setVariables),
222  $this->moduleName,
223  '',
224  $this->displayName
225  );
226  } else {
227  $shortcutMarkup = '';
228  }
229 
230  return $shortcutMarkup;
231  }
232 
236  protected function preProcess()
237  {
238  $emptyGetVariables = (count($this->getVariables) === 0);
239 
240  // Set default GET parameters
241  if ($emptyGetVariables) {
242  $this->getVariables = ['id', 'M'];
243  }
244 
245  // Automatically determine module name in Extbase context
246  if ($this->controllerContext !== null) {
247  $currentRequest = $this->controllerContext->getRequest();
248  $extensionName = $currentRequest->getControllerExtensionName();
249  $this->moduleName = $currentRequest->getPluginName();
250  // Extend default GET parameters
251  if ($emptyGetVariables) {
252  $modulePrefix = strtolower('tx_' . $extensionName . '_' . $this->moduleName);
253  $this->getVariables[] = $modulePrefix;
254  }
255  }
256  }
257 
261  protected function getBackendUser()
262  {
263  return $GLOBALS['BE_USER'];
264  }
265 }
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)