PageRenderTime 11ms CodeModel.GetById 47ms app.highlight 93ms RepoModel.GetById 1ms app.codeStats 5ms

/yii/framework/yiilite.php

https://bitbucket.org/ddonthula/zurmo
PHP | 9814 lines | 9762 code | 2 blank | 50 comment | 742 complexity | 9520e0fa165bc53602c506c99869d23d MD5 | raw file

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

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

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