PageRenderTime 1166ms CodeModel.GetById 152ms app.highlight 774ms RepoModel.GetById 143ms app.codeStats 78ms

/framework/yiilite.php

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

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