PageRenderTime 108ms CodeModel.GetById 624ms app.highlight 465ms RepoModel.GetById 471ms app.codeStats 3ms

/htdocs/yii/1.1.5/framework/yiilite.php

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

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