PageRenderTime 912ms CodeModel.GetById 290ms app.highlight 448ms RepoModel.GetById 156ms app.codeStats 1ms

/framework/yiilite.php

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

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