|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009-2011 Oliver Hader <oliver@typo3.org> 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 00028 /** 00029 * Matching TypoScript conditions for frontend disposal. 00030 * 00031 * Used with the TypoScript parser. 00032 * Matches browserinfo, IPnumbers for use with templates 00033 * 00034 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00035 * @package TYPO3 00036 * @subpackage t3lib 00037 */ 00038 class t3lib_matchCondition_frontend extends t3lib_matchCondition_abstract { 00039 00040 /** 00041 * Evaluates a TypoScript condition given as input, eg. "[browser=net][...(other conditions)...]" 00042 * 00043 * @param string $string: The condition to match against its criterias. 00044 * @return boolean Whether the condition matched 00045 * @see t3lib_tsparser::parse() 00046 */ 00047 protected function evaluateCondition($string) { 00048 list($key, $value) = t3lib_div::trimExplode('=', $string, FALSE, 2); 00049 00050 $result = parent::evaluateConditionCommon($key, $value); 00051 00052 if (is_bool($result)) { 00053 return $result; 00054 } else { 00055 switch ($key) { 00056 case 'usergroup': 00057 $groupList = $this->getGroupList(); 00058 if ($groupList != '0,-1') { // '0,-1' is the default usergroups when not logged in! 00059 $values = t3lib_div::trimExplode(',', $value, TRUE); 00060 foreach ($values as $test) { 00061 if ($test == '*' || t3lib_div::inList($groupList, $test)) { 00062 return TRUE; 00063 } 00064 } 00065 } 00066 break; 00067 case 'treeLevel': 00068 $values = t3lib_div::trimExplode(',', $value, TRUE); 00069 $treeLevel = count($this->rootline) - 1; 00070 foreach ($values as $test) { 00071 if ($test == $treeLevel) { 00072 return TRUE; 00073 } 00074 } 00075 break; 00076 case 'PIDupinRootline': 00077 case 'PIDinRootline': 00078 $values = t3lib_div::trimExplode(',', $value, TRUE); 00079 if (($key == 'PIDinRootline') || (!in_array($this->pageId, $values))) { 00080 foreach ($values as $test) { 00081 foreach ($this->rootline as $rl_dat) { 00082 if ($rl_dat['uid'] == $test) { 00083 return TRUE; 00084 } 00085 } 00086 } 00087 } 00088 break; 00089 } 00090 } 00091 00092 return FALSE; 00093 } 00094 00095 /** 00096 * Returns GP / ENV / TSFE vars 00097 * 00098 * @param string Identifier 00099 * @return mixed The value of the variable pointed to. 00100 */ 00101 protected function getVariable($var) { 00102 $vars = explode(':', $var, 2); 00103 00104 $val = parent::getVariableCommon($vars); 00105 00106 if (is_null($val)) { 00107 $splitAgain = explode('|', $vars[1], 2); 00108 $k = trim($splitAgain[0]); 00109 if ($k) { 00110 switch ((string) trim($vars[0])) { 00111 case 'TSFE': 00112 $val = $this->getGlobal('TSFE|' . $vars[1]); 00113 break; 00114 } 00115 } 00116 } 00117 00118 return $val; 00119 } 00120 00121 /** 00122 * Get the usergroup list of the current user. 00123 * 00124 * @return string The usergroup list of the current user 00125 */ 00126 protected function getGroupList() { 00127 $groupList = $GLOBALS['TSFE']->gr_list; 00128 return $groupList; 00129 } 00130 00131 /** 00132 * Determines the current page Id. 00133 * 00134 * @return integer The current page Id 00135 */ 00136 protected function determinePageId() { 00137 return (int) $GLOBALS['TSFE']->id; 00138 } 00139 00140 /** 00141 * Gets the properties for the current page. 00142 * 00143 * @return array The properties for the current page. 00144 */ 00145 protected function getPage() { 00146 return $GLOBALS['TSFE']->page; 00147 } 00148 00149 /** 00150 * Determines the rootline for the current page. 00151 * 00152 * @return array The rootline for the current page. 00153 */ 00154 protected function determineRootline() { 00155 $rootline = (array) $GLOBALS['TSFE']->tmpl->rootLine; 00156 return $rootline; 00157 } 00158 00159 /** 00160 * Get prefix for user functions (normally 'user_'). 00161 * 00162 * @return string The prefix for user functions (normally 'user_'). 00163 */ 00164 protected function getUserFuncClassPrefix() { 00165 $userFuncClassPrefix = $GLOBALS['TSFE']->TYPO3_CONF_VARS['FE']['userFuncClassPrefix']; 00166 return $userFuncClassPrefix; 00167 } 00168 00169 /** 00170 * Get the id of the current user. 00171 * 00172 * @return integer The id of the current user 00173 */ 00174 protected function getUserId() { 00175 $userId = $GLOBALS['TSFE']->fe_user->user['uid']; 00176 return $userId; 00177 } 00178 00179 /** 00180 * Determines if a user is logged in. 00181 * 00182 * @return boolean Determines if a user is logged in 00183 */ 00184 protected function isUserLoggedIn() { 00185 $userLoggedIn = FALSE; 00186 if ($GLOBALS['TSFE']->loginUser) { 00187 $userLoggedIn = TRUE; 00188 } 00189 return $userLoggedIn; 00190 } 00191 00192 /** 00193 * Set/write a log message. 00194 * 00195 * @param string $message: The log message to set/write 00196 * @return void 00197 */ 00198 protected function log($message) { 00199 if (is_object($GLOBALS['TT'])) { 00200 $GLOBALS['TT']->setTSlogMessage($message, 3); 00201 } 00202 } 00203 } 00204 00205 00206 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/matchcondition/class.t3lib_matchcondition_frontend.php'])) { 00207 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/matchcondition/class.t3lib_matchcondition_frontend.php']); 00208 } 00209 00210 ?>
1.8.0