PageRenderTime 133ms CodeModel.GetById 28ms app.highlight 80ms RepoModel.GetById 1ms app.codeStats 2ms

/yii/framework/yiilite.php

https://bitbucket.org/ddonthula/zurmounl
PHP | 10023 lines | 9966 code | 2 blank | 55 comment | 707 complexity | 9f23d140de371469908a3c3fab54062e MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1<?php
   2/**
   3 * Yii bootstrap file.
   4 *
   5 * This file is automatically generated using 'build lite' command.
   6 * It is the result of merging commonly used Yii class files with
   7 * comments and trace statements removed away.
   8 *
   9 * By using this file instead of yii.php, an Yii application may
  10 * improve performance due to the reduction of PHP parsing time.
  11 * The performance improvement is especially obvious when PHP APC extension
  12 * is enabled.
  13 *
  14 * DO NOT modify this file manually.
  15 *
  16 * @author Qiang Xue <qiang.xue@gmail.com>
  17 * @link http://www.yiiframework.com/
  18 * @copyright Copyright &copy; 2008-2012 Yii Software LLC
  19 * @license http://www.yiiframework.com/license/
  20 * @version $Id: $
  21 * @since 1.0
  22 */
  23
  24
  25defined('YII_BEGIN_TIME') or define('YII_BEGIN_TIME',microtime(true));
  26defined('YII_DEBUG') or define('YII_DEBUG',false);
  27defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',0);
  28defined('YII_ENABLE_EXCEPTION_HANDLER') or define('YII_ENABLE_EXCEPTION_HANDLER',true);
  29defined('YII_ENABLE_ERROR_HANDLER') or define('YII_ENABLE_ERROR_HANDLER',true);
  30defined('YII_PATH') or define('YII_PATH',dirname(__FILE__));
  31defined('YII_ZII_PATH') or define('YII_ZII_PATH',YII_PATH.DIRECTORY_SEPARATOR.'zii');
  32class YiiBase
  33{
  34	public static $classMap=array();
  35	public static $enableIncludePath=true;
  36	private static $_aliases=array('system'=>YII_PATH,'zii'=>YII_ZII_PATH); // alias => path
  37	private static $_imports=array();					// alias => class name or directory
  38	private static $_includePaths;						// list of include paths
  39	private static $_app;
  40	private static $_logger;
  41	public static function getVersion()
  42	{
  43		return '1.1.13';
  44	}
  45	public static function createWebApplication($config=null)
  46	{
  47		return self::createApplication('CWebApplication',$config);
  48	}
  49	public static function createConsoleApplication($config=null)
  50	{
  51		return self::createApplication('CConsoleApplication',$config);
  52	}
  53	public static function createApplication($class,$config=null)
  54	{
  55		return new $class($config);
  56	}
  57	public static function app()
  58	{
  59		return self::$_app;
  60	}
  61	public static function setApplication($app)
  62	{
  63		if(self::$_app===null || $app===null)
  64			self::$_app=$app;
  65		else
  66			throw new CException(Yii::t('yii','Yii application can only be created once.'));
  67	}
  68	public static function getFrameworkPath()
  69	{
  70		return YII_PATH;
  71	}
  72	public static function createComponent($config)
  73	{
  74		if(is_string($config))
  75		{
  76			$type=$config;
  77			$config=array();
  78		}
  79		elseif(isset($config['class']))
  80		{
  81			$type=$config['class'];
  82			unset($config['class']);
  83		}
  84		else
  85			throw new CException(Yii::t('yii','Object configuration must be an array containing a "class" element.'));
  86		if(!class_exists($type,false))
  87			$type=Yii::import($type,true);
  88		if(($n=func_num_args())>1)
  89		{
  90			$args=func_get_args();
  91			if($n===2)
  92				$object=new $type($args[1]);
  93			elseif($n===3)
  94				$object=new $type($args[1],$args[2]);
  95			elseif($n===4)
  96				$object=new $type($args[1],$args[2],$args[3]);
  97			else
  98			{
  99				unset($args[0]);
 100				$class=new ReflectionClass($type);
 101				// Note: ReflectionClass::newInstanceArgs() is available for PHP 5.1.3+
 102				// $object=$class->newInstanceArgs($args);
 103				$object=call_user_func_array(array($class,'newInstance'),$args);
 104			}
 105		}
 106		else
 107			$object=new $type;
 108		foreach($config as $key=>$value)
 109			$object->$key=$value;
 110		return $object;
 111	}
 112	public static function import($alias,$forceInclude=false)
 113	{
 114		if(isset(self::$_imports[$alias]))  // previously imported
 115			return self::$_imports[$alias];
 116		if(class_exists($alias,false) || interface_exists($alias,false))
 117			return self::$_imports[$alias]=$alias;
 118		if(($pos=strrpos($alias,'\\'))!==false) // a class name in PHP 5.3 namespace format
 119		{
 120			$namespace=str_replace('\\','.',ltrim(substr($alias,0,$pos),'\\'));
 121			if(($path=self::getPathOfAlias($namespace))!==false)
 122			{
 123				$classFile=$path.DIRECTORY_SEPARATOR.substr($alias,$pos+1).'.php';
 124				if($forceInclude)
 125				{
 126					if(is_file($classFile))
 127						require($classFile);
 128					else
 129						throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing PHP file and the file is readable.',array('{alias}'=>$alias)));
 130					self::$_imports[$alias]=$alias;
 131				}
 132				else
 133					self::$classMap[$alias]=$classFile;
 134				return $alias;
 135			}
 136			else
 137				throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing directory.',
 138					array('{alias}'=>$namespace)));
 139		}
 140		if(($pos=strrpos($alias,'.'))===false)  // a simple class name
 141		{
 142			if($forceInclude && self::autoload($alias))
 143				self::$_imports[$alias]=$alias;
 144			return $alias;
 145		}
 146		$className=(string)substr($alias,$pos+1);
 147		$isClass=$className!=='*';
 148		if($isClass && (class_exists($className,false) || interface_exists($className,false)))
 149			return self::$_imports[$alias]=$className;
 150		if(($path=self::getPathOfAlias($alias))!==false)
 151		{
 152			if($isClass)
 153			{
 154				if($forceInclude)
 155				{
 156					if(is_file($path.'.php'))
 157						require($path.'.php');
 158					else
 159						throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing PHP file and the file is readable.',array('{alias}'=>$alias)));
 160					self::$_imports[$alias]=$className;
 161				}
 162				else
 163					self::$classMap[$className]=$path.'.php';
 164				return $className;
 165			}
 166			else  // a directory
 167			{
 168				if(self::$_includePaths===null)
 169				{
 170					self::$_includePaths=array_unique(explode(PATH_SEPARATOR,get_include_path()));
 171					if(($pos=array_search('.',self::$_includePaths,true))!==false)
 172						unset(self::$_includePaths[$pos]);
 173				}
 174				array_unshift(self::$_includePaths,$path);
 175				if(self::$enableIncludePath && set_include_path('.'.PATH_SEPARATOR.implode(PATH_SEPARATOR,self::$_includePaths))===false)
 176					self::$enableIncludePath=false;
 177				return self::$_imports[$alias]=$path;
 178			}
 179		}
 180		else
 181			throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing directory or file.',
 182				array('{alias}'=>$alias)));
 183	}
 184	public static function getPathOfAlias($alias)
 185	{
 186		if(isset(self::$_aliases[$alias]))
 187			return self::$_aliases[$alias];
 188		elseif(($pos=strpos($alias,'.'))!==false)
 189		{
 190			$rootAlias=substr($alias,0,$pos);
 191			if(isset(self::$_aliases[$rootAlias]))
 192				return self::$_aliases[$alias]=rtrim(self::$_aliases[$rootAlias].DIRECTORY_SEPARATOR.str_replace('.',DIRECTORY_SEPARATOR,substr($alias,$pos+1)),'*'.DIRECTORY_SEPARATOR);
 193			elseif(self::$_app instanceof CWebApplication)
 194			{
 195				if(self::$_app->findModule($rootAlias)!==null)
 196					return self::getPathOfAlias($alias);
 197			}
 198		}
 199		return false;
 200	}
 201	public static function setPathOfAlias($alias,$path)
 202	{
 203		if(empty($path))
 204			unset(self::$_aliases[$alias]);
 205		else
 206			self::$_aliases[$alias]=rtrim($path,'\\/');
 207	}
 208	public static function autoload($className)
 209	{
 210		// use include so that the error PHP file may appear
 211		if(isset(self::$classMap[$className]))
 212			include(self::$classMap[$className]);
 213		elseif(isset(self::$_coreClasses[$className]))
 214			include(YII_PATH.self::$_coreClasses[$className]);
 215		else
 216		{
 217			// include class file relying on include_path
 218			if(strpos($className,'\\')===false)  // class without namespace
 219			{
 220				if(self::$enableIncludePath===false)
 221				{
 222					foreach(self::$_includePaths as $path)
 223					{
 224						$classFile=$path.DIRECTORY_SEPARATOR.$className.'.php';
 225						if(is_file($classFile))
 226						{
 227							include($classFile);
 228							if(YII_DEBUG && basename(realpath($classFile))!==$className.'.php')
 229								throw new CException(Yii::t('yii','Class name "{class}" does not match class file "{file}".', array(
 230									'{class}'=>$className,
 231									'{file}'=>$classFile,
 232								)));
 233							break;
 234						}
 235					}
 236				}
 237				else
 238					include($className.'.php');
 239			}
 240			else  // class name with namespace in PHP 5.3
 241			{
 242				$namespace=str_replace('\\','.',ltrim($className,'\\'));
 243				if(($path=self::getPathOfAlias($namespace))!==false)
 244					include($path.'.php');
 245				else
 246					return false;
 247			}
 248			return class_exists($className,false) || interface_exists($className,false);
 249		}
 250		return true;
 251	}
 252	public static function trace($msg,$category='application')
 253	{
 254		if(YII_DEBUG)
 255			self::log($msg,CLogger::LEVEL_TRACE,$category);
 256	}
 257	public static function log($msg,$level=CLogger::LEVEL_INFO,$category='application')
 258	{
 259		if(self::$_logger===null)
 260			self::$_logger=new CLogger;
 261		if(YII_DEBUG && YII_TRACE_LEVEL>0 && $level!==CLogger::LEVEL_PROFILE)
 262		{
 263			$traces=debug_backtrace();
 264			$count=0;
 265			foreach($traces as $trace)
 266			{
 267				if(isset($trace['file'],$trace['line']) && strpos($trace['file'],YII_PATH)!==0)
 268				{
 269					$msg.="\nin ".$trace['file'].' ('.$trace['line'].')';
 270					if(++$count>=YII_TRACE_LEVEL)
 271						break;
 272				}
 273			}
 274		}
 275		self::$_logger->log($msg,$level,$category);
 276	}
 277	public static function beginProfile($token,$category='application')
 278	{
 279		self::log('begin:'.$token,CLogger::LEVEL_PROFILE,$category);
 280	}
 281	public static function endProfile($token,$category='application')
 282	{
 283		self::log('end:'.$token,CLogger::LEVEL_PROFILE,$category);
 284	}
 285	public static function getLogger()
 286	{
 287		if(self::$_logger!==null)
 288			return self::$_logger;
 289		else
 290			return self::$_logger=new CLogger;
 291	}
 292	public static function setLogger($logger)
 293	{
 294		self::$_logger=$logger;
 295	}
 296	public static function powered()
 297	{
 298		return Yii::t('yii','Powered by {yii}.', array('{yii}'=>'<a href="http://www.yiiframework.com/" rel="external">Yii Framework</a>'));
 299	}
 300	public static function t($category,$message,$params=array(),$source=null,$language=null)
 301	{
 302		if(self::$_app!==null)
 303		{
 304			if($source===null)
 305				$source=($category==='yii'||$category==='zii')?'coreMessages':'messages';
 306			if(($source=self::$_app->getComponent($source))!==null)
 307				$message=$source->translate($category,$message,$language);
 308		}
 309		if($params===array())
 310			return $message;
 311		if(!is_array($params))
 312			$params=array($params);
 313		if(isset($params[0])) // number choice
 314		{
 315			if(strpos($message,'|')!==false)
 316			{
 317				if(strpos($message,'#')===false)
 318				{
 319					$chunks=explode('|',$message);
 320					$expressions=self::$_app->getLocale($language)->getPluralRules();
 321					if($n=min(count($chunks),count($expressions)))
 322					{
 323						for($i=0;$i<$n;$i++)
 324							$chunks[$i]=$expressions[$i].'#'.$chunks[$i];
 325						$message=implode('|',$chunks);
 326					}
 327				}
 328				$message=CChoiceFormat::format($message,$params[0]);
 329			}
 330			if(!isset($params['{n}']))
 331				$params['{n}']=$params[0];
 332			unset($params[0]);
 333		}
 334		return $params!==array() ? strtr($message,$params) : $message;
 335	}
 336	public static function registerAutoloader($callback, $append=false)
 337	{
 338		if($append)
 339		{
 340			self::$enableIncludePath=false;
 341			spl_autoload_register($callback);
 342		}
 343		else
 344		{
 345			spl_autoload_unregister(array('YiiBase','autoload'));
 346			spl_autoload_register($callback);
 347			spl_autoload_register(array('YiiBase','autoload'));
 348		}
 349	}
 350	private static $_coreClasses=array(
 351		'CApplication' => '/base/CApplication.php',
 352		'CApplicationComponent' => '/base/CApplicationComponent.php',
 353		'CBehavior' => '/base/CBehavior.php',
 354		'CComponent' => '/base/CComponent.php',
 355		'CErrorEvent' => '/base/CErrorEvent.php',
 356		'CErrorHandler' => '/base/CErrorHandler.php',
 357		'CException' => '/base/CException.php',
 358		'CExceptionEvent' => '/base/CExceptionEvent.php',
 359		'CHttpException' => '/base/CHttpException.php',
 360		'CModel' => '/base/CModel.php',
 361		'CModelBehavior' => '/base/CModelBehavior.php',
 362		'CModelEvent' => '/base/CModelEvent.php',
 363		'CModule' => '/base/CModule.php',
 364		'CSecurityManager' => '/base/CSecurityManager.php',
 365		'CStatePersister' => '/base/CStatePersister.php',
 366		'CApcCache' => '/caching/CApcCache.php',
 367		'CCache' => '/caching/CCache.php',
 368		'CDbCache' => '/caching/CDbCache.php',
 369		'CDummyCache' => '/caching/CDummyCache.php',
 370		'CEAcceleratorCache' => '/caching/CEAcceleratorCache.php',
 371		'CFileCache' => '/caching/CFileCache.php',
 372		'CMemCache' => '/caching/CMemCache.php',
 373		'CWinCache' => '/caching/CWinCache.php',
 374		'CXCache' => '/caching/CXCache.php',
 375		'CZendDataCache' => '/caching/CZendDataCache.php',
 376		'CCacheDependency' => '/caching/dependencies/CCacheDependency.php',
 377		'CChainedCacheDependency' => '/caching/dependencies/CChainedCacheDependency.php',
 378		'CDbCacheDependency' => '/caching/dependencies/CDbCacheDependency.php',
 379		'CDirectoryCacheDependency' => '/caching/dependencies/CDirectoryCacheDependency.php',
 380		'CExpressionDependency' => '/caching/dependencies/CExpressionDependency.php',
 381		'CFileCacheDependency' => '/caching/dependencies/CFileCacheDependency.php',
 382		'CGlobalStateCacheDependency' => '/caching/dependencies/CGlobalStateCacheDependency.php',
 383		'CAttributeCollection' => '/collections/CAttributeCollection.php',
 384		'CConfiguration' => '/collections/CConfiguration.php',
 385		'CList' => '/collections/CList.php',
 386		'CListIterator' => '/collections/CListIterator.php',
 387		'CMap' => '/collections/CMap.php',
 388		'CMapIterator' => '/collections/CMapIterator.php',
 389		'CQueue' => '/collections/CQueue.php',
 390		'CQueueIterator' => '/collections/CQueueIterator.php',
 391		'CStack' => '/collections/CStack.php',
 392		'CStackIterator' => '/collections/CStackIterator.php',
 393		'CTypedList' => '/collections/CTypedList.php',
 394		'CTypedMap' => '/collections/CTypedMap.php',
 395		'CConsoleApplication' => '/console/CConsoleApplication.php',
 396		'CConsoleCommand' => '/console/CConsoleCommand.php',
 397		'CConsoleCommandBehavior' => '/console/CConsoleCommandBehavior.php',
 398		'CConsoleCommandEvent' => '/console/CConsoleCommandEvent.php',
 399		'CConsoleCommandRunner' => '/console/CConsoleCommandRunner.php',
 400		'CHelpCommand' => '/console/CHelpCommand.php',
 401		'CDbCommand' => '/db/CDbCommand.php',
 402		'CDbConnection' => '/db/CDbConnection.php',
 403		'CDbDataReader' => '/db/CDbDataReader.php',
 404		'CDbException' => '/db/CDbException.php',
 405		'CDbMigration' => '/db/CDbMigration.php',
 406		'CDbTransaction' => '/db/CDbTransaction.php',
 407		'CActiveFinder' => '/db/ar/CActiveFinder.php',
 408		'CActiveRecord' => '/db/ar/CActiveRecord.php',
 409		'CActiveRecordBehavior' => '/db/ar/CActiveRecordBehavior.php',
 410		'CDbColumnSchema' => '/db/schema/CDbColumnSchema.php',
 411		'CDbCommandBuilder' => '/db/schema/CDbCommandBuilder.php',
 412		'CDbCriteria' => '/db/schema/CDbCriteria.php',
 413		'CDbExpression' => '/db/schema/CDbExpression.php',
 414		'CDbSchema' => '/db/schema/CDbSchema.php',
 415		'CDbTableSchema' => '/db/schema/CDbTableSchema.php',
 416		'CMssqlColumnSchema' => '/db/schema/mssql/CMssqlColumnSchema.php',
 417		'CMssqlCommandBuilder' => '/db/schema/mssql/CMssqlCommandBuilder.php',
 418		'CMssqlPdoAdapter' => '/db/schema/mssql/CMssqlPdoAdapter.php',
 419		'CMssqlSchema' => '/db/schema/mssql/CMssqlSchema.php',
 420		'CMssqlSqlsrvPdoAdapter' => '/db/schema/mssql/CMssqlSqlsrvPdoAdapter.php',
 421		'CMssqlTableSchema' => '/db/schema/mssql/CMssqlTableSchema.php',
 422		'CMysqlColumnSchema' => '/db/schema/mysql/CMysqlColumnSchema.php',
 423		'CMysqlCommandBuilder' => '/db/schema/mysql/CMysqlCommandBuilder.php',
 424		'CMysqlSchema' => '/db/schema/mysql/CMysqlSchema.php',
 425		'CMysqlTableSchema' => '/db/schema/mysql/CMysqlTableSchema.php',
 426		'COciColumnSchema' => '/db/schema/oci/COciColumnSchema.php',
 427		'COciCommandBuilder' => '/db/schema/oci/COciCommandBuilder.php',
 428		'COciSchema' => '/db/schema/oci/COciSchema.php',
 429		'COciTableSchema' => '/db/schema/oci/COciTableSchema.php',
 430		'CPgsqlColumnSchema' => '/db/schema/pgsql/CPgsqlColumnSchema.php',
 431		'CPgsqlSchema' => '/db/schema/pgsql/CPgsqlSchema.php',
 432		'CPgsqlTableSchema' => '/db/schema/pgsql/CPgsqlTableSchema.php',
 433		'CSqliteColumnSchema' => '/db/schema/sqlite/CSqliteColumnSchema.php',
 434		'CSqliteCommandBuilder' => '/db/schema/sqlite/CSqliteCommandBuilder.php',
 435		'CSqliteSchema' => '/db/schema/sqlite/CSqliteSchema.php',
 436		'CChoiceFormat' => '/i18n/CChoiceFormat.php',
 437		'CDateFormatter' => '/i18n/CDateFormatter.php',
 438		'CDbMessageSource' => '/i18n/CDbMessageSource.php',
 439		'CGettextMessageSource' => '/i18n/CGettextMessageSource.php',
 440		'CLocale' => '/i18n/CLocale.php',
 441		'CMessageSource' => '/i18n/CMessageSource.php',
 442		'CNumberFormatter' => '/i18n/CNumberFormatter.php',
 443		'CPhpMessageSource' => '/i18n/CPhpMessageSource.php',
 444		'CGettextFile' => '/i18n/gettext/CGettextFile.php',
 445		'CGettextMoFile' => '/i18n/gettext/CGettextMoFile.php',
 446		'CGettextPoFile' => '/i18n/gettext/CGettextPoFile.php',
 447		'CChainedLogFilter' => '/logging/CChainedLogFilter.php',
 448		'CDbLogRoute' => '/logging/CDbLogRoute.php',
 449		'CEmailLogRoute' => '/logging/CEmailLogRoute.php',
 450		'CFileLogRoute' => '/logging/CFileLogRoute.php',
 451		'CLogFilter' => '/logging/CLogFilter.php',
 452		'CLogRoute' => '/logging/CLogRoute.php',
 453		'CLogRouter' => '/logging/CLogRouter.php',
 454		'CLogger' => '/logging/CLogger.php',
 455		'CProfileLogRoute' => '/logging/CProfileLogRoute.php',
 456		'CWebLogRoute' => '/logging/CWebLogRoute.php',
 457		'CDateTimeParser' => '/utils/CDateTimeParser.php',
 458		'CFileHelper' => '/utils/CFileHelper.php',
 459		'CFormatter' => '/utils/CFormatter.php',
 460		'CMarkdownParser' => '/utils/CMarkdownParser.php',
 461		'CPropertyValue' => '/utils/CPropertyValue.php',
 462		'CTimestamp' => '/utils/CTimestamp.php',
 463		'CVarDumper' => '/utils/CVarDumper.php',
 464		'CBooleanValidator' => '/validators/CBooleanValidator.php',
 465		'CCaptchaValidator' => '/validators/CCaptchaValidator.php',
 466		'CCompareValidator' => '/validators/CCompareValidator.php',
 467		'CDateValidator' => '/validators/CDateValidator.php',
 468		'CDefaultValueValidator' => '/validators/CDefaultValueValidator.php',
 469		'CEmailValidator' => '/validators/CEmailValidator.php',
 470		'CExistValidator' => '/validators/CExistValidator.php',
 471		'CFileValidator' => '/validators/CFileValidator.php',
 472		'CFilterValidator' => '/validators/CFilterValidator.php',
 473		'CInlineValidator' => '/validators/CInlineValidator.php',
 474		'CNumberValidator' => '/validators/CNumberValidator.php',
 475		'CRangeValidator' => '/validators/CRangeValidator.php',
 476		'CRegularExpressionValidator' => '/validators/CRegularExpressionValidator.php',
 477		'CRequiredValidator' => '/validators/CRequiredValidator.php',
 478		'CSafeValidator' => '/validators/CSafeValidator.php',
 479		'CStringValidator' => '/validators/CStringValidator.php',
 480		'CTypeValidator' => '/validators/CTypeValidator.php',
 481		'CUniqueValidator' => '/validators/CUniqueValidator.php',
 482		'CUnsafeValidator' => '/validators/CUnsafeValidator.php',
 483		'CUrlValidator' => '/validators/CUrlValidator.php',
 484		'CValidator' => '/validators/CValidator.php',
 485		'CActiveDataProvider' => '/web/CActiveDataProvider.php',
 486		'CArrayDataProvider' => '/web/CArrayDataProvider.php',
 487		'CAssetManager' => '/web/CAssetManager.php',
 488		'CBaseController' => '/web/CBaseController.php',
 489		'CCacheHttpSession' => '/web/CCacheHttpSession.php',
 490		'CClientScript' => '/web/CClientScript.php',
 491		'CController' => '/web/CController.php',
 492		'CDataProvider' => '/web/CDataProvider.php',
 493		'CDataProviderIterator' => '/web/CDataProviderIterator.php',
 494		'CDbHttpSession' => '/web/CDbHttpSession.php',
 495		'CExtController' => '/web/CExtController.php',
 496		'CFormModel' => '/web/CFormModel.php',
 497		'CHttpCookie' => '/web/CHttpCookie.php',
 498		'CHttpRequest' => '/web/CHttpRequest.php',
 499		'CHttpSession' => '/web/CHttpSession.php',
 500		'CHttpSessionIterator' => '/web/CHttpSessionIterator.php',
 501		'COutputEvent' => '/web/COutputEvent.php',
 502		'CPagination' => '/web/CPagination.php',
 503		'CSort' => '/web/CSort.php',
 504		'CSqlDataProvider' => '/web/CSqlDataProvider.php',
 505		'CTheme' => '/web/CTheme.php',
 506		'CThemeManager' => '/web/CThemeManager.php',
 507		'CUploadedFile' => '/web/CUploadedFile.php',
 508		'CUrlManager' => '/web/CUrlManager.php',
 509		'CWebApplication' => '/web/CWebApplication.php',
 510		'CWebModule' => '/web/CWebModule.php',
 511		'CWidgetFactory' => '/web/CWidgetFactory.php',
 512		'CAction' => '/web/actions/CAction.php',
 513		'CInlineAction' => '/web/actions/CInlineAction.php',
 514		'CViewAction' => '/web/actions/CViewAction.php',
 515		'CAccessControlFilter' => '/web/auth/CAccessControlFilter.php',
 516		'CAuthAssignment' => '/web/auth/CAuthAssignment.php',
 517		'CAuthItem' => '/web/auth/CAuthItem.php',
 518		'CAuthManager' => '/web/auth/CAuthManager.php',
 519		'CBaseUserIdentity' => '/web/auth/CBaseUserIdentity.php',
 520		'CDbAuthManager' => '/web/auth/CDbAuthManager.php',
 521		'CPhpAuthManager' => '/web/auth/CPhpAuthManager.php',
 522		'CUserIdentity' => '/web/auth/CUserIdentity.php',
 523		'CWebUser' => '/web/auth/CWebUser.php',
 524		'CFilter' => '/web/filters/CFilter.php',
 525		'CFilterChain' => '/web/filters/CFilterChain.php',
 526		'CHttpCacheFilter' => '/web/filters/CHttpCacheFilter.php',
 527		'CInlineFilter' => '/web/filters/CInlineFilter.php',
 528		'CForm' => '/web/form/CForm.php',
 529		'CFormButtonElement' => '/web/form/CFormButtonElement.php',
 530		'CFormElement' => '/web/form/CFormElement.php',
 531		'CFormElementCollection' => '/web/form/CFormElementCollection.php',
 532		'CFormInputElement' => '/web/form/CFormInputElement.php',
 533		'CFormStringElement' => '/web/form/CFormStringElement.php',
 534		'CGoogleApi' => '/web/helpers/CGoogleApi.php',
 535		'CHtml' => '/web/helpers/CHtml.php',
 536		'CJSON' => '/web/helpers/CJSON.php',
 537		'CJavaScript' => '/web/helpers/CJavaScript.php',
 538		'CJavaScriptExpression' => '/web/helpers/CJavaScriptExpression.php',
 539		'CPradoViewRenderer' => '/web/renderers/CPradoViewRenderer.php',
 540		'CViewRenderer' => '/web/renderers/CViewRenderer.php',
 541		'CWebService' => '/web/services/CWebService.php',
 542		'CWebServiceAction' => '/web/services/CWebServiceAction.php',
 543		'CWsdlGenerator' => '/web/services/CWsdlGenerator.php',
 544		'CActiveForm' => '/web/widgets/CActiveForm.php',
 545		'CAutoComplete' => '/web/widgets/CAutoComplete.php',
 546		'CClipWidget' => '/web/widgets/CClipWidget.php',
 547		'CContentDecorator' => '/web/widgets/CContentDecorator.php',
 548		'CFilterWidget' => '/web/widgets/CFilterWidget.php',
 549		'CFlexWidget' => '/web/widgets/CFlexWidget.php',
 550		'CHtmlPurifier' => '/web/widgets/CHtmlPurifier.php',
 551		'CInputWidget' => '/web/widgets/CInputWidget.php',
 552		'CMarkdown' => '/web/widgets/CMarkdown.php',
 553		'CMaskedTextField' => '/web/widgets/CMaskedTextField.php',
 554		'CMultiFileUpload' => '/web/widgets/CMultiFileUpload.php',
 555		'COutputCache' => '/web/widgets/COutputCache.php',
 556		'COutputProcessor' => '/web/widgets/COutputProcessor.php',
 557		'CStarRating' => '/web/widgets/CStarRating.php',
 558		'CTabView' => '/web/widgets/CTabView.php',
 559		'CTextHighlighter' => '/web/widgets/CTextHighlighter.php',
 560		'CTreeView' => '/web/widgets/CTreeView.php',
 561		'CWidget' => '/web/widgets/CWidget.php',
 562		'CCaptcha' => '/web/widgets/captcha/CCaptcha.php',
 563		'CCaptchaAction' => '/web/widgets/captcha/CCaptchaAction.php',
 564		'CBasePager' => '/web/widgets/pagers/CBasePager.php',
 565		'CLinkPager' => '/web/widgets/pagers/CLinkPager.php',
 566		'CListPager' => '/web/widgets/pagers/CListPager.php',
 567	);
 568}
 569spl_autoload_register(array('YiiBase','autoload'));
 570class Yii extends YiiBase
 571{
 572}
 573class CComponent
 574{
 575	private $_e;
 576	private $_m;
 577	public function __get($name)
 578	{
 579		$getter='get'.$name;
 580		if(method_exists($this,$getter))
 581			return $this->$getter();
 582		elseif(strncasecmp($name,'on',2)===0 && method_exists($this,$name))
 583		{
 584			// duplicating getEventHandlers() here for performance
 585			$name=strtolower($name);
 586			if(!isset($this->_e[$name]))
 587				$this->_e[$name]=new CList;
 588			return $this->_e[$name];
 589		}
 590		elseif(isset($this->_m[$name]))
 591			return $this->_m[$name];
 592		elseif(is_array($this->_m))
 593		{
 594			foreach($this->_m as $object)
 595			{
 596				if($object->getEnabled() && (property_exists($object,$name) || $object->canGetProperty($name)))
 597					return $object->$name;
 598			}
 599		}
 600		throw new CException(Yii::t('yii','Property "{class}.{property}" is not defined.',
 601			array('{class}'=>get_class($this), '{property}'=>$name)));
 602	}
 603	public function __set($name,$value)
 604	{
 605		$setter='set'.$name;
 606		if(method_exists($this,$setter))
 607			return $this->$setter($value);
 608		elseif(strncasecmp($name,'on',2)===0 && method_exists($this,$name))
 609		{
 610			// duplicating getEventHandlers() here for performance
 611			$name=strtolower($name);
 612			if(!isset($this->_e[$name]))
 613				$this->_e[$name]=new CList;
 614			return $this->_e[$name]->add($value);
 615		}
 616		elseif(is_array($this->_m))
 617		{
 618			foreach($this->_m as $object)
 619			{
 620				if($object->getEnabled() && (property_exists($object,$name) || $object->canSetProperty($name)))
 621					return $object->$name=$value;
 622			}
 623		}
 624		if(method_exists($this,'get'.$name))
 625			throw new CException(Yii::t('yii','Property "{class}.{property}" is read only.',
 626				array('{class}'=>get_class($this), '{property}'=>$name)));
 627		else
 628			throw new CException(Yii::t('yii','Property "{class}.{property}" is not defined.',
 629				array('{class}'=>get_class($this), '{property}'=>$name)));
 630	}
 631	public function __isset($name)
 632	{
 633		$getter='get'.$name;
 634		if(method_exists($this,$getter))
 635			return $this->$getter()!==null;
 636		elseif(strncasecmp($name,'on',2)===0 && method_exists($this,$name))
 637		{
 638			$name=strtolower($name);
 639			return isset($this->_e[$name]) && $this->_e[$name]->getCount();
 640		}
 641		elseif(is_array($this->_m))
 642		{
 643 			if(isset($this->_m[$name]))
 644 				return true;
 645			foreach($this->_m as $object)
 646			{
 647				if($object->getEnabled() && (property_exists($object,$name) || $object->canGetProperty($name)))
 648					return $object->$name!==null;
 649			}
 650		}
 651		return false;
 652	}
 653	public function __unset($name)
 654	{
 655		$setter='set'.$name;
 656		if(method_exists($this,$setter))
 657			$this->$setter(null);
 658		elseif(strncasecmp($name,'on',2)===0 && method_exists($this,$name))
 659			unset($this->_e[strtolower($name)]);
 660		elseif(is_array($this->_m))
 661		{
 662			if(isset($this->_m[$name]))
 663				$this->detachBehavior($name);
 664			else
 665			{
 666				foreach($this->_m as $object)
 667				{
 668					if($object->getEnabled())
 669					{
 670						if(property_exists($object,$name))
 671							return $object->$name=null;
 672						elseif($object->canSetProperty($name))
 673							return $object->$setter(null);
 674					}
 675				}
 676			}
 677		}
 678		elseif(method_exists($this,'get'.$name))
 679			throw new CException(Yii::t('yii','Property "{class}.{property}" is read only.',
 680				array('{class}'=>get_class($this), '{property}'=>$name)));
 681	}
 682	public function __call($name,$parameters)
 683	{
 684		if($this->_m!==null)
 685		{
 686			foreach($this->_m as $object)
 687			{
 688				if($object->getEnabled() && method_exists($object,$name))
 689					return call_user_func_array(array($object,$name),$parameters);
 690			}
 691		}
 692		if(class_exists('Closure', false) && $this->canGetProperty($name) && $this->$name instanceof Closure)
 693			return call_user_func_array($this->$name, $parameters);
 694		throw new CException(Yii::t('yii','{class} and its behaviors do not have a method or closure named "{name}".',
 695			array('{class}'=>get_class($this), '{name}'=>$name)));
 696	}
 697	public function asa($behavior)
 698	{
 699		return isset($this->_m[$behavior]) ? $this->_m[$behavior] : null;
 700	}
 701	public function attachBehaviors($behaviors)
 702	{
 703		foreach($behaviors as $name=>$behavior)
 704			$this->attachBehavior($name,$behavior);
 705	}
 706	public function detachBehaviors()
 707	{
 708		if($this->_m!==null)
 709		{
 710			foreach($this->_m as $name=>$behavior)
 711				$this->detachBehavior($name);
 712			$this->_m=null;
 713		}
 714	}
 715	public function attachBehavior($name,$behavior)
 716	{
 717		if(!($behavior instanceof IBehavior))
 718			$behavior=Yii::createComponent($behavior);
 719		$behavior->setEnabled(true);
 720		$behavior->attach($this);
 721		return $this->_m[$name]=$behavior;
 722	}
 723	public function detachBehavior($name)
 724	{
 725		if(isset($this->_m[$name]))
 726		{
 727			$this->_m[$name]->detach($this);
 728			$behavior=$this->_m[$name];
 729			unset($this->_m[$name]);
 730			return $behavior;
 731		}
 732	}
 733	public function enableBehaviors()
 734	{
 735		if($this->_m!==null)
 736		{
 737			foreach($this->_m as $behavior)
 738				$behavior->setEnabled(true);
 739		}
 740	}
 741	public function disableBehaviors()
 742	{
 743		if($this->_m!==null)
 744		{
 745			foreach($this->_m as $behavior)
 746				$behavior->setEnabled(false);
 747		}
 748	}
 749	public function enableBehavior($name)
 750	{
 751		if(isset($this->_m[$name]))
 752			$this->_m[$name]->setEnabled(true);
 753	}
 754	public function disableBehavior($name)
 755	{
 756		if(isset($this->_m[$name]))
 757			$this->_m[$name]->setEnabled(false);
 758	}
 759	public function hasProperty($name)
 760	{
 761		return method_exists($this,'get'.$name) || method_exists($this,'set'.$name);
 762	}
 763	public function canGetProperty($name)
 764	{
 765		return method_exists($this,'get'.$name);
 766	}
 767	public function canSetProperty($name)
 768	{
 769		return method_exists($this,'set'.$name);
 770	}
 771	public function hasEvent($name)
 772	{
 773		return !strncasecmp($name,'on',2) && method_exists($this,$name);
 774	}
 775	public function hasEventHandler($name)
 776	{
 777		$name=strtolower($name);
 778		return isset($this->_e[$name]) && $this->_e[$name]->getCount()>0;
 779	}
 780	public function getEventHandlers($name)
 781	{
 782		if($this->hasEvent($name))
 783		{
 784			$name=strtolower($name);
 785			if(!isset($this->_e[$name]))
 786				$this->_e[$name]=new CList;
 787			return $this->_e[$name];
 788		}
 789		else
 790			throw new CException(Yii::t('yii','Event "{class}.{event}" is not defined.',
 791				array('{class}'=>get_class($this), '{event}'=>$name)));
 792	}
 793	public function attachEventHandler($name,$handler)
 794	{
 795		$this->getEventHandlers($name)->add($handler);
 796	}
 797	public function detachEventHandler($name,$handler)
 798	{
 799		if($this->hasEventHandler($name))
 800			return $this->getEventHandlers($name)->remove($handler)!==false;
 801		else
 802			return false;
 803	}
 804	public function raiseEvent($name,$event)
 805	{
 806		$name=strtolower($name);
 807		if(isset($this->_e[$name]))
 808		{
 809			foreach($this->_e[$name] as $handler)
 810			{
 811				if(is_string($handler))
 812					call_user_func($handler,$event);
 813				elseif(is_callable($handler,true))
 814				{
 815					if(is_array($handler))
 816					{
 817						// an array: 0 - object, 1 - method name
 818						list($object,$method)=$handler;
 819						if(is_string($object))	// static method call
 820							call_user_func($handler,$event);
 821						elseif(method_exists($object,$method))
 822							$object->$method($event);
 823						else
 824							throw new CException(Yii::t('yii','Event "{class}.{event}" is attached with an invalid handler "{handler}".',
 825								array('{class}'=>get_class($this), '{event}'=>$name, '{handler}'=>$handler[1])));
 826					}
 827					else // PHP 5.3: anonymous function
 828						call_user_func($handler,$event);
 829				}
 830				else
 831					throw new CException(Yii::t('yii','Event "{class}.{event}" is attached with an invalid handler "{handler}".',
 832						array('{class}'=>get_class($this), '{event}'=>$name, '{handler}'=>gettype($handler))));
 833				// stop further handling if param.handled is set true
 834				if(($event instanceof CEvent) && $event->handled)
 835					return;
 836			}
 837		}
 838		elseif(YII_DEBUG && !$this->hasEvent($name))
 839			throw new CException(Yii::t('yii','Event "{class}.{event}" is not defined.',
 840				array('{class}'=>get_class($this), '{event}'=>$name)));
 841	}
 842	public function evaluateExpression($_expression_,$_data_=array())
 843	{
 844		if(is_string($_expression_))
 845		{
 846			extract($_data_);
 847			return eval('return '.$_expression_.';');
 848		}
 849		else
 850		{
 851			$_data_[]=$this;
 852			return call_user_func_array($_expression_, $_data_);
 853		}
 854	}
 855}
 856class CEvent extends CComponent
 857{
 858	public $sender;
 859	public $handled=false;
 860	public $params;
 861	public function __construct($sender=null,$params=null)
 862	{
 863		$this->sender=$sender;
 864		$this->params=$params;
 865	}
 866}
 867class CEnumerable
 868{
 869}
 870abstract class CModule extends CComponent
 871{
 872	public $preload=array();
 873	public $behaviors=array();
 874	private $_id;
 875	private $_parentModule;
 876	private $_basePath;
 877	private $_modulePath;
 878	private $_params;
 879	private $_modules=array();
 880	private $_moduleConfig=array();
 881	private $_components=array();
 882	private $_componentConfig=array();
 883	public function __construct($id,$parent,$config=null)
 884	{
 885		$this->_id=$id;
 886		$this->_parentModule=$parent;
 887		// set basePath at early as possible to avoid trouble
 888		if(is_string($config))
 889			$config=require($config);
 890		if(isset($config['basePath']))
 891		{
 892			$this->setBasePath($config['basePath']);
 893			unset($config['basePath']);
 894		}
 895		Yii::setPathOfAlias($id,$this->getBasePath());
 896		$this->preinit();
 897		$this->configure($config);
 898		$this->attachBehaviors($this->behaviors);
 899		$this->preloadComponents();
 900		$this->init();
 901	}
 902	public function __get($name)
 903	{
 904		if($this->hasComponent($name))
 905			return $this->getComponent($name);
 906		else
 907			return parent::__get($name);
 908	}
 909	public function __isset($name)
 910	{
 911		if($this->hasComponent($name))
 912			return $this->getComponent($name)!==null;
 913		else
 914			return parent::__isset($name);
 915	}
 916	public function getId()
 917	{
 918		return $this->_id;
 919	}
 920	public function setId($id)
 921	{
 922		$this->_id=$id;
 923	}
 924	public function getBasePath()
 925	{
 926		if($this->_basePath===null)
 927		{
 928			$class=new ReflectionClass(get_class($this));
 929			$this->_basePath=dirname($class->getFileName());
 930		}
 931		return $this->_basePath;
 932	}
 933	public function setBasePath($path)
 934	{
 935		if(($this->_basePath=realpath($path))===false || !is_dir($this->_basePath))
 936			throw new CException(Yii::t('yii','Base path "{path}" is not a valid directory.',
 937				array('{path}'=>$path)));
 938	}
 939	public function getParams()
 940	{
 941		if($this->_params!==null)
 942			return $this->_params;
 943		else
 944		{
 945			$this->_params=new CAttributeCollection;
 946			$this->_params->caseSensitive=true;
 947			return $this->_params;
 948		}
 949	}
 950	public function setParams($value)
 951	{
 952		$params=$this->getParams();
 953		foreach($value as $k=>$v)
 954			$params->add($k,$v);
 955	}
 956	public function getModulePath()
 957	{
 958		if($this->_modulePath!==null)
 959			return $this->_modulePath;
 960		else
 961			return $this->_modulePath=$this->getBasePath().DIRECTORY_SEPARATOR.'modules';
 962	}
 963	public function setModulePath($value)
 964	{
 965		if(($this->_modulePath=realpath($value))===false || !is_dir($this->_modulePath))
 966			throw new CException(Yii::t('yii','The module path "{path}" is not a valid directory.',
 967				array('{path}'=>$value)));
 968	}
 969	public function setImport($aliases)
 970	{
 971		foreach($aliases as $alias)
 972			Yii::import($alias);
 973	}
 974	public function setAliases($mappings)
 975	{
 976		foreach($mappings as $name=>$alias)
 977		{
 978			if(($path=Yii::getPathOfAlias($alias))!==false)
 979				Yii::setPathOfAlias($name,$path);
 980			else
 981				Yii::setPathOfAlias($name,$alias);
 982		}
 983	}
 984	public function getParentModule()
 985	{
 986		return $this->_parentModule;
 987	}
 988	public function getModule($id)
 989	{
 990		if(isset($this->_modules[$id]) || array_key_exists($id,$this->_modules))
 991			return $this->_modules[$id];
 992		elseif(isset($this->_moduleConfig[$id]))
 993		{
 994			$config=$this->_moduleConfig[$id];
 995			if(!isset($config['enabled']) || $config['enabled'])
 996			{
 997				$class=$config['class'];
 998				unset($config['class'], $config['enabled']);
 999				if($this===Yii::app())
1000					$module=Yii::createComponent($class,$id,null,$config);
1001				else
1002					$module=Yii::createComponent($class,$this->getId().'/'.$id,$this,$config);
1003				return $this->_modules[$id]=$module;
1004			}
1005		}
1006	}
1007	public function hasModule($id)
1008	{
1009		return isset($this->_moduleConfig[$id]) || isset($this->_modules[$id]);
1010	}
1011	public function getModules()
1012	{
1013		return $this->_moduleConfig;
1014	}
1015	public function setModules($modules)
1016	{
1017		foreach($modules as $id=>$module)
1018		{
1019			if(is_int($id))
1020			{
1021				$id=$module;
1022				$module=array();
1023			}
1024			if(!isset($module['class']))
1025			{
1026				Yii::setPathOfAlias($id,$this->getModulePath().DIRECTORY_SEPARATOR.$id);
1027				$module['class']=$id.'.'.ucfirst($id).'Module';
1028			}
1029			if(isset($this->_moduleConfig[$id]))
1030				$this->_moduleConfig[$id]=CMap::mergeArray($this->_moduleConfig[$id],$module);
1031			else
1032				$this->_moduleConfig[$id]=$module;
1033		}
1034	}
1035	public function hasComponent($id)
1036	{
1037		return isset($this->_components[$id]) || isset($this->_componentConfig[$id]);
1038	}
1039	public function getComponent($id,$createIfNull=true)
1040	{
1041		if(isset($this->_components[$id]))
1042			return $this->_components[$id];
1043		elseif(isset($this->_componentConfig[$id]) && $createIfNull)
1044		{
1045			$config=$this->_componentConfig[$id];
1046			if(!isset($config['enabled']) || $config['enabled'])
1047			{
1048				unset($config['enabled']);
1049				$component=Yii::createComponent($config);
1050				$component->init();
1051				return $this->_components[$id]=$component;
1052			}
1053		}
1054	}
1055	public function setComponent($id,$component,$merge=true)
1056	{
1057		if($component===null)
1058		{
1059			unset($this->_components[$id]);
1060			return;
1061		}
1062		elseif($component instanceof IApplicationComponent)
1063		{
1064			$this->_components[$id]=$component;
1065			if(!$component->getIsInitialized())
1066				$component->init();
1067			return;
1068		}
1069		elseif(isset($this->_components[$id]))
1070		{
1071			if(isset($component['class']) && get_class($this->_components[$id])!==$component['class'])
1072			{
1073				unset($this->_components[$id]);
1074				$this->_componentConfig[$id]=$component; //we should ignore merge here
1075				return;
1076			}
1077			foreach($component as $key=>$value)
1078			{
1079				if($key!=='class')
1080					$this->_components[$id]->$key=$value;
1081			}
1082		}
1083		elseif(isset($this->_componentConfig[$id]['class'],$component['class'])
1084			&& $this->_componentConfig[$id]['class']!==$component['class'])
1085		{
1086			$this->_componentConfig[$id]=$component; //we should ignore merge here
1087			return;
1088		}
1089		if(isset($this->_componentConfig[$id]) && $merge)
1090			$this->_componentConfig[$id]=CMap::mergeArray($this->_componentConfig[$id],$component);
1091		else
1092			$this->_componentConfig[$id]=$component;
1093	}
1094	public function getComponents($loadedOnly=true)
1095	{
1096		if($loadedOnly)
1097			return $this->_components;
1098		else
1099			return array_merge($this->_componentConfig, $this->_components);
1100	}
1101	public function setComponents($components,$merge=true)
1102	{
1103		foreach($components as $id=>$component)
1104			$this->setComponent($id,$component,$merge);
1105	}
1106	public function configure($config)
1107	{
1108		if(is_array($config))
1109		{
1110			foreach($config as $key=>$value)
1111				$this->$key=$value;
1112		}
1113	}
1114	protected function preloadComponents()
1115	{
1116		foreach($this->preload as $id)
1117			$this->getComponent($id);
1118	}
1119	protected function preinit()
1120	{
1121	}
1122	protected function init()
1123	{
1124	}
1125}
1126abstract class CApplication extends CModule
1127{
1128	public $name='My Application';
1129	public $charset='UTF-8';
1130	public $sourceLanguage='en_us';
1131	private $_id;
1132	private $_basePath;
1133	private $_runtimePath;
1134	private $_extensionPath;
1135	private $_globalState;
1136	private $_stateChanged;
1137	private $_ended=false;
1138	private $_language;
1139	private $_homeUrl;
1140	abstract public function processRequest();
1141	public function __construct($config=null)
1142	{
1143		Yii::setApplication($this);
1144		// set basePath at early as possible to avoid trouble
1145		if(is_string($config))
1146			$config=require($config);
1147		if(isset($config['basePath']))
1148		{
1149			$this->setBasePath($config['basePath']);
1150			unset($config['basePath']);
1151		}
1152		else
1153			$this->setBasePath('protected');
1154		Yii::setPathOfAlias('application',$this->getBasePath());
1155		Yii::setPathOfAlias('webroot',dirname($_SERVER['SCRIPT_FILENAME']));
1156		Yii::setPathOfAlias('ext',$this->getBasePath().DIRECTORY_SEPARATOR.'extensions');
1157		$this->preinit();
1158		$this->initSystemHandlers();
1159		$this->registerCoreComponents();
1160		$this->configure($config);
1161		$this->attachBehaviors($this->behaviors);
1162		$this->preloadComponents();
1163		$this->init();
1164	}
1165	public function run()
1166	{
1167		if($this->hasEventHandler('onBeginRequest'))
1168			$this->onBeginRequest(new CEvent($this));
1169		register_shutdown_function(array($this,'end'),0,false);
1170		$this->processRequest();
1171		if($this->hasEventHandler('onEndRequest'))
1172			$this->onEndRequest(new CEvent($this));
1173	}
1174	public function end($status=0,$exit=true)
1175	{
1176		if($this->hasEventHandler('onEndRequest'))
1177			$this->onEndRequest(new CEvent($this));
1178		if($exit)
1179			exit($status);
1180	}
1181	public function onBeginRequest($event)
1182	{
1183		$this->raiseEvent('onBeginRequest',$event);
1184	}
1185	public function onEndRequest($event)
1186	{
1187		if(!$this->_ended)
1188		{
1189			$this->_ended=true;
1190			$this->raiseEvent('onEndRequest',$event);
1191		}
1192	}
1193	public function getId()
1194	{
1195		if($this->_id!==null)
1196			return $this->_id;
1197		else
1198			return $this->_id=sprintf('%x',crc32($this->getBasePath().$this->name));
1199	}
1200	public function setId($id)
1201	{
1202		$this->_id=$id;
1203	}
1204	public function getBasePath()
1205	{
1206		return $this->_basePath;
1207	}
1208	public function setBasePath($path)
1209	{
1210		if(($this->_basePath=realpath($path))===false || !is_dir($this->_basePath))
1211			throw new CException(Yii::t('yii','Application base path "{path}" is not a valid directory.',
1212				array('{path}'=>$path)));
1213	}
1214	public function getRuntimePath()
1215	{
1216		if($this->_runtimePath!==null)
1217			return $this->_runtimePath;
1218		else
1219		{
1220			$this->setRuntimePath($this->getBasePath().DIRECTORY_SEPARATOR.'runtime');
1221			return $this->_runtimePath;
1222		}
1223	}
1224	public function setRuntimePath($path)
1225	{
1226		if(($runtimePath=realpath($path))===false || !is_dir($runtimePath) || !is_writable($runtimePath))
1227			throw new CException(Yii::t('yii','Application runtime path "{path}" is not valid. Please make sure it is a directory writable by the Web server process.',
1228				array('{path}'=>$path)));
1229		$this->_runtimePath=$runtimePath;
1230	}
1231	public function getExtensionPath()
1232	{
1233		return Yii::getPathOfAlias('ext');
1234	}
1235	public function setExtensionPath($path)
1236	{
1237		if(($extensionPath=realpath($path))===false || !is_dir($extensionPath))
1238			throw new CException(Yii::t('yii','Extension path "{path}" does not exist.',
1239				array('{path}'=>$path)));
1240		Yii::setPathOfAlias('ext',$extensionPath);
1241	}
1242	public function getLanguage()
1243	{
1244		return $this->_language===null ? $this->sourceLanguage : $this->_language;
1245	}
1246	public function setLanguage($language)
1247	{
1248		$this->_language=$language;
1249	}
1250	public function getTimeZone()
1251	{
1252		return date_default_timezone_get();
1253	}
1254	public function setTimeZone($value)
1255	{
1256		date_default_timezone_set($value);
1257	}
1258	public function findLocalizedFile($srcFile,$srcLanguage=null,$language=null)
1259	{
1260		if($srcLanguage===null)
1261			$srcLanguage=$this->sourceLanguage;
1262		if($language===null)
1263			$language=$this->getLanguage();
1264		if($language===$srcLanguage)
1265			return $srcFile;
1266		$desiredFile=dirname($srcFile).DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.basename($srcFile);
1267		return is_file($desiredFile) ? $desiredFile : $srcFile;
1268	}
1269	public function getLocale($localeID=null)
1270	{
1271		return CLocale::getInstance($localeID===null?$this->getLanguage():$localeID);
1272	}
1273	public function getLocaleDataPath()
1274	{
1275		return CLocale::$dataPath===null ? Yii::getPathOfAlias('system.i18n.data') : CLocale::$dataPath;
1276	}
1277	public function setLocaleDataPath($value)
1278	{
1279		CLocale::$dataPath=$value;
1280	}
1281	public function getNumberFormatter()
1282	{
1283		return $this->getLocale()->getNumberFormatter();
1284	}
1285	public function getDateFormatter()
1286	{
1287		return $this->getLocale()->getDateFormatter();
1288	}
1289	public function getDb()
1290	{
1291		return $this->getComponent('db');
1292	}
1293	public function getErrorHandler()
1294	{
1295		return $this->getComponent('errorHandler');
1296	}
1297	public function getSecurityManager()
1298	{
1299		return $this->getComponent('securityManager');
1300	}
1301	public function getStatePersister()
1302	{
1303		return $this->getComponent('statePersister');
1304	}
1305	public function getCache()
1306	{
1307		return $this->getComponent('cache');
1308	}
1309	public function getCoreMessages()
1310	{
1311		return $this->getComponent('coreMessages');
1312	}
1313	public function getMessages()
1314	{
1315		return $this->getComponent('messages');
1316	}
1317	public function getRequest()
1318	{
1319		return $this->getComponent('request');
1320	}
1321	public function getUrlManager()
1322	{
1323		return $this->getComponent('urlManager');
1324	}
1325	public function getController()
1326	{
1327		return null;
1328	}
1329	public function createUrl($route,$params=array(),$ampersand='&')
1330	{
1331		return $this->getUrlManager()->createUrl($route,$params,$ampersand);
1332	}
1333	public function createAbsoluteUrl($route,$params=array(),$schema='',$ampersand='&')
1334	{
1335		$url=$this->createUrl($route,$params,$ampersand);
1336		if(strpos($url,'http')===0)
1337			return $url;
1338		else
1339			return $this->getRequest()->getHostInfo($schema).$url;
1340	}
1341	public function getBaseUrl($absolute=false)
1342	{
1343		return $this->getRequest()->getBaseUrl($absolute);
1344	}
1345	public function getHomeUrl()
1346	{
1347		if($this->_homeUrl===null)
1348		{
1349			if($this->getUrlManager()->showScriptName)
1350				return $this->getRequest()->getScriptUrl();
1351			else
1352				return $this->getRequest()->getBaseUrl().'/';
1353		}
1354		else
1355			return $this->_homeUrl;
1356	}
1357	public function setHomeUrl($value)
1358	{
1359		$this->_homeUrl=$value;
1360	}
1361	public function getGlobalState($key,$defaultValue=null)
1362	{
1363		if($this->_globalState===null)
1364			$this->loadGlobalState();
1365		if(isset($this->_globalState[$key]))
1366			return $this->_globalState[$key];
1367		else
1368			return $defaultValue;
1369	}
1370	public function setGlobalState($key,$value,$defaultValue=null)
1371	{
1372		if($this->_globalState===null)
1373			$this->loadGlobalState();
1374		$changed=$this->_stateChanged;
1375		if($value===$defaultValue)
1376		{
1377			if(isset($this->_globalState[$key]))
1378			{
1379				unset($this->_globalState[$key]);
1380				$this->_stateChanged=true;
1381			}
1382		}
1383		elseif(!isset($this->_globalState[$key]) || $this->_globalState[$key]!==$value)
1384		{
1385			$this->_globalState[$key]=$value;
1386			$this->_stateChanged=true;
1387		}
1388		if($this->_stateChanged!==$changed)
1389			$this->attachEventHandler('onEndRequest',array($this,'saveGlobalState'));
1390	}
1391	public function clearGlobalState($key)
1392	{
1393		$this->setGlobalState($key,true,true);
1394	}
1395	public function loadGlobalState()
1396	{
1397		$persister=$this->getStatePersister();
1398		if(($this->_globalState=$persister->load())===null)
1399			$this->_globalState=array();
1400		$this->_stateChanged=false;
1401		$this->detachEventHandler('onEndRequest',array($this,'saveGlobalState'));
1402	}
1403	public function saveGlobalState()
1404	{
1405		if($this->_stateChanged)
1406		{
1407			$this->_stateChanged=false;
1408			$this->detachEventHandler('onEndRequest',array($this,'saveGlobalState'));
1409			$this->getStatePersister()->save($this->_globalState);
1410		}
1411	}
1412	public function handleException($exception)
1413	{
1414		// disable error capturing to avoid recursive errors
1415		restore_error_handler();
1416		restore_exception_handler();
1417		$category='exception.'.get_class($exception);
1418		if($exception instanceof CHttpException)
1419			$category.='.'.$exception->statusCode;
1420		// php <5.2 doesn't support string conversion auto-magically
1421		$message=$exception->__toString();
1422		if(isset($_SERVER['REQUEST_URI']))
1423			$message.="\nREQUEST_URI=".$_SERVER['REQUEST_URI'];
1424		if(isset($_SERVER['HTTP_REFERER']))
1425			$message.="\nHTTP_REFERER=".$_SERVER['HTTP_REFERER'];
1426		$message.="\n---";
1427		Yii::log($message,CLogger::LEVEL_ERROR,$category);
1428		try
1429		{
1430			$event=new CExceptionEvent($this,$exception);
1431			$this->onException($event);
1432			if(!$event->handled)
1433			{
1434				// try an error handler
1435				if(($handler=$this->getErrorHandler())!==null)
1436					$handler->handle($event);
1437				else
1438					$this->displayException($exception);
1439			}
1440		}
1441		catch(Exception $e)
1442		{
1443			$this->displayException($e);
1444		}
1445		try
1446		{
1447			$this->end(1);
1448		}
1449		catch(Exception $e)
1450		{
1451			// use the most primitive way to log error
1452			$msg = get_class($e).': '.$e->getMessage().' ('.$e->getFile().':'.$e->getLine().")\n";
1453			$msg .= $e->getTraceAsString()."\n";
1454			$msg .= "Previous exception:\n";
1455			$msg .= get_class($exception).': '.$exception->getMessage().' ('.$exception->getFile().':'.$exception->getLine().")\n";
1456			$msg .= $exception->getTraceAsString()."\n";
1457			$msg .= '$_SERVER='.var_export($_SERVER,true);
1458			error_log($msg);
1459			exit(1);
1460		}
1461	}
1462	public function handleError($code,$message,$file,$line)
1463	{
1464		if($code & error_reporting())
1465		{
1466			// disable error capturing to avoid recursive errors
1467			restore_error_handler();
1468			restore_exception_handler();
1469			$log="$message ($file:$line)\nStack trace:\n";
1470			$trace=debug_backtrace();
1471			// skip the first 3 stacks as they do not tell the error position
1472			if(count($trace)>3)
1473				$trace=array_slice($trace,3);
1474			foreach($trace as $i=>$t)
1475			{
1476				if(!isset($t['file']))
1477					$t['file']='unknown';
1478				if(!isset($t['line']))
1479					$t['line']=0;
1480				if(!isset($t['function']))
1481					$t['function']='unknown';
1482				$log.="#$i {$t['file']}({$t['line']}): ";
1483				if(isset($t['object']) && is_object($t['object']))
1484					$log.=get_class($t['object']).'->';
1485				$log.="{$t['function']}()\n";
1486			}
1487			if(isset($_SERVER['REQUEST_URI']))
1488				$log.='REQUEST_URI='.$_SERVER['REQUEST_URI'];
1489			Yii::log($log,CLogger::LEVEL_ERROR,'php');
1490			try
1491			{
1492				Yii::import('CErrorEvent',true);
1493				$event=new CErrorEvent($this,$code,$message,$file,$line);
1494				$this->onError($event);
1495				if(!$event->handled)
1496				{
1497					// try an error handler
1498					if(($handler=$this->getErrorHandler())!==null)
1499						$handler->handle($event);
1500					else
1501						$this->displayError($code,$message,$file,$line);
1502				}
1503			}
1504			catch(Exception $e)
1505			{
1506				$this->displayException($e);
1507			}
1508			try
1509			{
1510				$this->end(1);
1511			}
1512			catch(Exception $e)
1513			{
1514				// use the most primitive way to log error
1515				$msg = get_class($e).': '.$e->getMessage().' ('.$e->getFile().':'.$e->getLine().")\n";
1516				$msg .= $e->getTraceAsString()."\n";
1517				$msg .= "Previous error:\n";
1518				$msg .= $log."\n";
1519				$msg .= '$_SERVER='.var_export($_SERVER,true);
1520				error_log($msg);
1521				exit(1);
1522			}
1523		}
1524	}
1525	public function onException($event)
1526	{
1527		$this->raiseEvent('onException',$event);
1528	}
1529	public function onError($event)
1530	{
1531		$this->raiseEvent('onError',$event);
1532	}
1533	public function displayError($code,$message,$file,$line)
1534	{
1535		if(YII_DEBUG)
1536		{
1537			echo "<h1>PHP Error [$code]</h1>\n";
1538			echo "<p>$message ($file:$line)</p>\n";
1539			echo '<pre>';
1540			$trace=debug_backtrace();
1541			// skip the first 3 stacks as they do not tell the error position
1542			if(count($trace)>3)
1543				$trace=array_slice($trace,3);
1544			foreach($trace as $i=>$t)
1545			{
1546				if(!isset($t['file']))
1547					$t['file']='unknown';
1548				if(!isset($t['line']))
1549					$t['line']=0;
1550				if(!isset($t['function']))
1551					$t['function']='unknown';
1552				echo "#$i {$t['file']}({$t['line']}): ";
1553				if(isset($t['object']) && is_object($t['object']))
1554					echo get_class($t['object']).'->';
1555				echo "{$t['function']}()\n";
1556			}
1557			echo '</pre>';
1558		}
1559		else
1560		{
1561			echo "<h1>PHP Error [$code]</h1>\n";
1562			echo "<p>$message</p>\n";
1563		}
1564	}
1565	public function displayException($exception)
1566	{
1567		if(YII_DEBUG)
1568		{
1569			echo '<h1>'.get_class($exception)."</h1>\n";
1570			echo '<p>'.$exception->getMessage().' ('.$exception->getFile().':'.$exception->getLine().')</p>';
1571			echo '<pre>'.$exception->getTraceAsString().'</pre>';
1572		}
1573		else
1574		{
1575			echo '<h1>'.get_class($exception)."</h1>\n";
1576			echo '<p>'.$exception->getMessage().'</p>';
1577		}
1578	}
1579	protected function initSystemHandlers()
1580	{
1581		if(YII_ENABLE_EXCEPTION_HANDLER)
1582			set_exception_handler(array($this,'handleException'));
1583		if(YII_ENABLE_ERROR_HANDLER)
1584			set_error_handler(array($this,'handleError'),error_reporting());
1585	}
1586	protected function registerCoreComponents()

Large files files are truncated, but you can click here to view the full file