TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
frontend/Classes/Configuration/TypoScript/ConditionMatching/ConditionMatcher.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching;
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 
28 {
38  protected function evaluateCondition($string)
39  {
40  list($key, $value) = GeneralUtility::trimExplode('=', $string, false, 2);
41  $result = $this->evaluateConditionCommon($key, $value);
42 
43  if (is_bool($result)) {
44  return $result;
45  } else {
46  switch ($key) {
47  case 'usergroup':
48  $groupList = $this->getGroupList();
49  // '0,-1' is the default usergroups when not logged in!
50  if ($groupList != '0,-1') {
51  $values = GeneralUtility::trimExplode(',', $value, true);
52  foreach ($values as $test) {
53  if ($test == '*' || GeneralUtility::inList($groupList, $test)) {
54  return true;
55  }
56  }
57  }
58  break;
59  case 'treeLevel':
60  $values = GeneralUtility::trimExplode(',', $value, true);
61  $treeLevel = count($this->rootline) - 1;
62  foreach ($values as $test) {
63  if ($test == $treeLevel) {
64  return true;
65  }
66  }
67  break;
68  case 'PIDupinRootline':
69  case 'PIDinRootline':
70  $values = GeneralUtility::trimExplode(',', $value, true);
71  if ($key == 'PIDinRootline' || !in_array($this->pageId, $values)) {
72  foreach ($values as $test) {
73  foreach ($this->rootline as $rlDat) {
74  if ($rlDat['uid'] == $test) {
75  return true;
76  }
77  }
78  }
79  }
80  break;
81  default:
82  $conditionResult = $this->evaluateCustomDefinedCondition($string);
83  if ($conditionResult !== null) {
84  return $conditionResult;
85  }
86  }
87  }
88 
89  return false;
90  }
91 
98  protected function getVariable($var)
99  {
100  $vars = explode(':', $var, 2);
101  $val = $this->getVariableCommon($vars);
102  if (is_null($val)) {
103  $splitAgain = explode('|', $vars[1], 2);
104  $k = trim($splitAgain[0]);
105  if ($k) {
106  switch ((string)trim($vars[0])) {
107  case 'TSFE':
108  $val = $this->getGlobal('TSFE|' . $vars[1]);
109  break;
110  default:
111  }
112  }
113  }
114  return $val;
115  }
116 
122  protected function getGroupList()
123  {
124  return $this->getTypoScriptFrontendController()->gr_list;
125  }
126 
132  protected function determinePageId()
133  {
134  return (int)$this->getTypoScriptFrontendController()->id;
135  }
136 
142  protected function getPage()
143  {
144  return $this->getTypoScriptFrontendController()->page;
145  }
146 
152  protected function determineRootline()
153  {
154  return (array)$this->getTypoScriptFrontendController()->tmpl->rootLine;
155  }
156 
162  protected function getUserId()
163  {
164  return $this->getTypoScriptFrontendController()->fe_user->user['uid'];
165  }
166 
172  protected function isUserLoggedIn()
173  {
174  return (bool)$this->getTypoScriptFrontendController()->loginUser;
175  }
176 
183  protected function log($message)
184  {
185  if ($this->getTimeTracker() !== null) {
186  $this->getTimeTracker()->setTSlogMessage($message, 3);
187  }
188  }
189 
193  protected function getTypoScriptFrontendController()
194  {
195  return $GLOBALS['TSFE'];
196  }
197 
201  protected function getTimeTracker()
202  {
203  return GeneralUtility::makeInstance(TimeTracker::class);
204  }
205 }
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)