class.t3lib_matchcondition.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2010 Kasper Skaarhoj (kasperYYYY@typo3.com)
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  * Contains class for Matching TypoScript conditions
00029  *
00030  * $Id: class.t3lib_matchcondition.php 7905 2010-06-13 14:42:33Z ohader $
00031  * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
00032  *
00033  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00034  */
00035 /**
00036  * [CLASS/FUNCTION INDEX of SCRIPT]
00037  *
00038  *
00039  *
00040  *   80: class t3lib_matchCondition
00041  *   87:     function __construct()
00042  *  105:     function t3lib_matchCondition()
00043  *  115:     function match($condition_line)
00044  *  160:     function evalConditionStr($string)
00045  *  381:     function testNumber($test,$value)
00046  *  405:     function matchWild($haystack,$needle)
00047  *  429:     function whichDevice($useragent)
00048  *  498:     function browserInfo($useragent)
00049  *  611:     function browserInfo_version($tmp)
00050  *  624:     function getGlobal($var, $source=NULL)
00051  *  658:     function getGP_ENV_TSFE($var)
00052  *
00053  * TOTAL FUNCTIONS: 11
00054  * (This index is automatically created/updated by the extension "extdeveval")
00055  *
00056  */
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 /**
00070  * Matching TypoScript conditions
00071  *
00072  * Used with the TypoScript parser.
00073  * Matches browserinfo, IPnumbers for use with templates
00074  *
00075  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00076  * @package TYPO3
00077  * @subpackage t3lib
00078  * @see t3lib_TStemplate::matching(), t3lib_TStemplate::generateConfig()
00079  */
00080 class t3lib_matchCondition extends t3lib_matchCondition_frontend {
00081     var $matchAlternative=array();      // If this array has elements, the matching returns true if a whole "matchline" is found in the array!
00082     var $matchAll=0;                    // If set all is matched!
00083 
00084     var $altRootLine=array();
00085     var $hookObjectsArr = array();
00086 
00087     /**
00088      * Constructor for this class
00089      *
00090      * @return  void
00091      * @deprecated  since TYPO3 4.3, will be removed in TYPO3 4.5 - The functionality was moved to t3lib_matchCondition_frontend
00092      */
00093     function __construct()  {
00094         t3lib_div::logDeprecatedFunction();
00095 
00096         parent::__construct();
00097     }
00098 
00099     /**
00100      * Matching TS condition
00101      *
00102      * @param   string      Line to match
00103      * @return  boolean     True if matched
00104      */
00105     function match($condition_line) {
00106         if ($this->matchAll) {
00107             parent::setSimulateMatchResult(true);
00108         }
00109         if (count($this->matchAlternative)) {
00110             parent::setSimulateMatchConditions($this->matchAlternative);
00111         }
00112 
00113         return parent::match($condition_line);
00114     }
00115 
00116 
00117     /**
00118      * Evaluates a TypoScript condition given as input, eg. "[browser=net][...(other conditions)...]"
00119      *
00120      * @param   string      The condition to match against its criterias.
00121      * @return  boolean     Returns true or false based on the evaluation.
00122      * @see t3lib_tsparser::parse()
00123      * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=292&cHash=c6c7d43d2f
00124      */
00125     function evalConditionStr($string)  {
00126         return parent::evaluateCondition($string);
00127     }
00128 
00129     /**
00130      * Evaluates a $leftValue based on an operator: "<", ">", "<=", ">=", "!=" or "="
00131      *
00132      * @param   string      $test: The value to compare with on the form [operator][number]. Eg. "< 123"
00133      * @param   integer     $leftValue: The value on the left side
00134      * @return  boolean     If $value is "50" and $test is "< 123" then it will return true.
00135      */
00136     function testNumber($test, $leftValue) {
00137         return parent::compareNumber($test, $leftValue);
00138     }
00139 
00140     /**
00141      * Matching two strings against each other, supporting a "*" wildcard or (if wrapped in "/") PCRE regular expressions
00142      *
00143      * @param   string      The string in which to find $needle.
00144      * @param   string      The string to find in $haystack
00145      * @return  boolean     Returns true if $needle matches or is found in (according to wildcards) in $haystack. Eg. if $haystack is "Netscape 6.5" and $needle is "Net*" or "Net*ape" then it returns true.
00146      */
00147     function matchWild($haystack, $needle) {
00148         return parent::searchStringWildcard($haystack, $needle);
00149     }
00150 
00151     /**
00152      * Returns a code for a browsing device based on the input useragent string
00153      *
00154      * @param   string      User agent string from browser, t3lib_div::getIndpEnv('HTTP_USER_AGENT')
00155      * @return  string      A code. See link.
00156      * @access private
00157      * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=296&cHash=a8ae66c7d6
00158      */
00159     function whichDevice($useragent)    {
00160         return parent::getDeviceType($useragent);
00161     }
00162 
00163     /**
00164      * Generates an array with abstracted browser information
00165      * This method is used in the function match() in this class
00166      *
00167      * @param   string      The useragent string, t3lib_div::getIndpEnv('HTTP_USER_AGENT')
00168      * @return  array       Contains keys "browser", "version", "system"
00169      * @access private
00170      * @see match()
00171      */
00172     function browserInfo($useragent)    {
00173         return parent::getBrowserInfo($useragent);
00174     }
00175 
00176     /**
00177      * Returns the version of a browser; Basically getting doubleval() of the input string, stripping of any non-numeric values in the beginning of the string first.
00178      *
00179      * @param   string      A string with version number, eg. "/7.32 blablabla"
00180      * @return  double      Returns double value, eg. "7.32"
00181      * @deprecated  since TYPO3 4.3 - use t3lib_utility_Client::getVersion() instead
00182      */
00183     function browserInfo_version($tmp)  {
00184         t3lib_div::logDeprecatedFunction();
00185         return t3lib_utility_Client::getVersion($tmp);
00186     }
00187 
00188     /**
00189      * Return global variable where the input string $var defines array keys separated by "|"
00190      * Example: $var = "HTTP_SERVER_VARS | something" will return the value $GLOBALS['HTTP_SERVER_VARS']['something'] value
00191      *
00192      * @param   string      Global var key, eg. "HTTP_GET_VAR" or "HTTP_GET_VARS|id" to get the GET parameter "id" back.
00193      * @param   array       Alternative array than $GLOBAL to get variables from.
00194      * @return  mixed       Whatever value. If none, then blank string.
00195      * @access private
00196      */
00197     function getGlobal($var, $source=NULL)  {
00198         return parent::getGlobal($var, $source);
00199     }
00200 
00201     /**
00202      * Returns GP / ENV / TSFE vars
00203      *
00204      * @param   string      Identifier
00205      * @return  mixed       The value of the variable pointed to.
00206      * @access private
00207      * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=311&cHash=487cbd5cdf
00208      */
00209     function getGP_ENV_TSFE($var) {
00210         return parent::getVariable($var);
00211     }
00212 }
00213 
00214 
00215 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_matchcondition.php'])    {
00216     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_matchcondition.php']);
00217 }
00218 
00219 ?>

Generated on Sat Jul 24 04:17:17 2010 for TYPO3 API by  doxygen 1.4.7