PageRenderTime 93ms CodeModel.GetById 6ms app.highlight 49ms RepoModel.GetById 12ms app.codeStats 3ms

/framework/yiilite.php

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

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