Skip to content

Commit

Permalink
Merge pull request #2 from nazartsev/master
Browse files Browse the repository at this point in the history
Update install
  • Loading branch information
firstrow committed Sep 21, 2016
2 parents 79c102c + fb32000 commit 51a0378
Show file tree
Hide file tree
Showing 1,322 changed files with 238,431 additions and 59,435 deletions.
37 changes: 30 additions & 7 deletions framework/YiiBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC
* @copyright 2008-2013 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @package system
* @since 1.0
Expand Down Expand Up @@ -80,7 +80,7 @@ class YiiBase
*/
public static function getVersion()
{
return '1.1.13';
return '1.1.17';
}

/**
Expand Down Expand Up @@ -287,13 +287,20 @@ public static function import($alias,$forceInclude=false)
return $alias;
}
else
throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing directory.',
array('{alias}'=>$namespace)));
{
// try to autoload the class with an autoloader
if (class_exists($alias,true))
return self::$_imports[$alias]=$alias;
else
throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing directory or file.',
array('{alias}'=>$namespace)));
}
}

if(($pos=strrpos($alias,'.'))===false) // a simple class name
{
if($forceInclude && self::autoload($alias))
// try to autoload the class with an autoloader if $forceInclude is true
if($forceInclude && (Yii::autoload($alias,true) || class_exists($alias,true)))
self::$_imports[$alias]=$alias;
return $alias;
}
Expand Down Expand Up @@ -386,15 +393,19 @@ public static function setPathOfAlias($alias,$path)
* Class autoload loader.
* This method is provided to be invoked within an __autoload() magic method.
* @param string $className class name
* @param bool $classMapOnly whether to load classes via classmap only
* @return boolean whether the class has been loaded successfully
* @throws CException When class name does not match class file in debug mode.
*/
public static function autoload($className)
public static function autoload($className,$classMapOnly=false)
{
// use include so that the error PHP file may appear
if(isset(self::$classMap[$className]))
include(self::$classMap[$className]);
elseif(isset(self::$_coreClasses[$className]))
include(YII_PATH.self::$_coreClasses[$className]);
elseif($classMapOnly)
return false;
else
{
// include class file relying on include_path
Expand Down Expand Up @@ -423,7 +434,7 @@ public static function autoload($className)
else // class name with namespace in PHP 5.3
{
$namespace=str_replace('\\','.',ltrim($className,'\\'));
if(($path=self::getPathOfAlias($namespace))!==false)
if(($path=self::getPathOfAlias($namespace))!==false && is_file($path.'.php'))
include($path.'.php');
else
return false;
Expand Down Expand Up @@ -612,6 +623,9 @@ public static function t($category,$message,$params=array(),$source=null,$langua
* any other existing autoloaders.
* @param callback $callback a valid PHP callback (function name or array($className,$methodName)).
* @param boolean $append whether to append the new autoloader after the default Yii autoloader.
* Be careful using this option as it will disable {@link enableIncludePath autoloading via include path}
* when set to true. After this the Yii autoloader can not rely on loading classes via simple include anymore
* and you have to {@link import} all classes explicitly.
*/
public static function registerAutoloader($callback, $append=false)
{
Expand All @@ -638,6 +652,7 @@ public static function registerAutoloader($callback, $append=false)
'CApplicationComponent' => '/base/CApplicationComponent.php',
'CBehavior' => '/base/CBehavior.php',
'CComponent' => '/base/CComponent.php',
'CDbStatePersister' => '/base/CDbStatePersister.php',
'CErrorEvent' => '/base/CErrorEvent.php',
'CErrorHandler' => '/base/CErrorHandler.php',
'CException' => '/base/CException.php',
Expand All @@ -656,6 +671,7 @@ public static function registerAutoloader($callback, $append=false)
'CEAcceleratorCache' => '/caching/CEAcceleratorCache.php',
'CFileCache' => '/caching/CFileCache.php',
'CMemCache' => '/caching/CMemCache.php',
'CRedisCache' => '/caching/CRedisCache.php',
'CWinCache' => '/caching/CWinCache.php',
'CXCache' => '/caching/CXCache.php',
'CZendDataCache' => '/caching/CZendDataCache.php',
Expand Down Expand Up @@ -699,6 +715,9 @@ public static function registerAutoloader($callback, $append=false)
'CDbExpression' => '/db/schema/CDbExpression.php',
'CDbSchema' => '/db/schema/CDbSchema.php',
'CDbTableSchema' => '/db/schema/CDbTableSchema.php',
'CCubridColumnSchema' => '/db/schema/cubrid/CCubridColumnSchema.php',
'CCubridSchema' => '/db/schema/cubrid/CCubridSchema.php',
'CCubridTableSchema' => '/db/schema/cubrid/CCubridTableSchema.php',
'CMssqlColumnSchema' => '/db/schema/mssql/CMssqlColumnSchema.php',
'CMssqlCommandBuilder' => '/db/schema/mssql/CMssqlCommandBuilder.php',
'CMssqlPdoAdapter' => '/db/schema/mssql/CMssqlPdoAdapter.php',
Expand All @@ -714,6 +733,7 @@ public static function registerAutoloader($callback, $append=false)
'COciSchema' => '/db/schema/oci/COciSchema.php',
'COciTableSchema' => '/db/schema/oci/COciTableSchema.php',
'CPgsqlColumnSchema' => '/db/schema/pgsql/CPgsqlColumnSchema.php',
'CPgsqlCommandBuilder' => '/db/schema/pgsql/CPgsqlCommandBuilder.php',
'CPgsqlSchema' => '/db/schema/pgsql/CPgsqlSchema.php',
'CPgsqlTableSchema' => '/db/schema/pgsql/CPgsqlTableSchema.php',
'CSqliteColumnSchema' => '/db/schema/sqlite/CSqliteColumnSchema.php',
Expand All @@ -739,11 +759,14 @@ public static function registerAutoloader($callback, $append=false)
'CLogRouter' => '/logging/CLogRouter.php',
'CLogger' => '/logging/CLogger.php',
'CProfileLogRoute' => '/logging/CProfileLogRoute.php',
'CSysLogRoute' => '/logging/CSysLogRoute.php',
'CWebLogRoute' => '/logging/CWebLogRoute.php',
'CDateTimeParser' => '/utils/CDateTimeParser.php',
'CFileHelper' => '/utils/CFileHelper.php',
'CFormatter' => '/utils/CFormatter.php',
'CLocalizedFormatter' => '/utils/CLocalizedFormatter.php',
'CMarkdownParser' => '/utils/CMarkdownParser.php',
'CPasswordHelper' => '/utils/CPasswordHelper.php',
'CPropertyValue' => '/utils/CPropertyValue.php',
'CTimestamp' => '/utils/CTimestamp.php',
'CVarDumper' => '/utils/CVarDumper.php',
Expand Down
46 changes: 38 additions & 8 deletions framework/base/CApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC
* @copyright 2008-2013 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/

Expand Down Expand Up @@ -42,7 +42,7 @@
* CApplication will undergo the following lifecycles when processing a user request:
* <ol>
* <li>load application configuration;</li>
* <li>set up class autoloader and error handling;</li>
* <li>set up error handling;</li>
* <li>load static application components;</li>
* <li>{@link onBeginRequest}: preprocess the user request;</li>
* <li>{@link processRequest}: process the user request;</li>
Expand Down Expand Up @@ -73,6 +73,7 @@
* @property CPhpMessageSource $coreMessages The core message translations.
* @property CMessageSource $messages The application message translations.
* @property CHttpRequest $request The request component.
* @property CFormatter $format The formatter component.
* @property CUrlManager $urlManager The URL manager component.
* @property CController $controller The currently active controller. Null is returned in this base class.
* @property string $baseUrl The relative URL for the application.
Expand All @@ -97,6 +98,10 @@ abstract class CApplication extends CModule
* the language that the messages and view files are in. Defaults to 'en_us' (US English).
*/
public $sourceLanguage='en_us';
/**
* @var string the class used to get locale data. Defaults to 'CLocale'.
*/
public $localeClass='CLocale';

private $_id;
private $_basePath;
Expand Down Expand Up @@ -140,7 +145,18 @@ public function __construct($config=null)
$this->setBasePath('protected');
Yii::setPathOfAlias('application',$this->getBasePath());
Yii::setPathOfAlias('webroot',dirname($_SERVER['SCRIPT_FILENAME']));
Yii::setPathOfAlias('ext',$this->getBasePath().DIRECTORY_SEPARATOR.'extensions');
if(isset($config['extensionPath']))
{
$this->setExtensionPath($config['extensionPath']);
unset($config['extensionPath']);
}
else
Yii::setPathOfAlias('ext',$this->getBasePath().DIRECTORY_SEPARATOR.'extensions');
if(isset($config['aliases']))
{
$this->setAliases($config['aliases']);
unset($config['aliases']);
}

$this->preinit();

Expand Down Expand Up @@ -292,6 +308,7 @@ public function getExtensionPath()
/**
* Sets the root directory that holds all third-party extensions.
* @param string $path the directory that contains all third-party extensions.
* @throws CException if the directory does not exist
*/
public function setExtensionPath($path)
{
Expand Down Expand Up @@ -383,11 +400,11 @@ public function findLocalizedFile($srcFile,$srcLanguage=null,$language=null)
/**
* Returns the locale instance.
* @param string $localeID the locale ID (e.g. en_US). If null, the {@link getLanguage application language ID} will be used.
* @return CLocale the locale instance
* @return an instance of CLocale
*/
public function getLocale($localeID=null)
{
return CLocale::getInstance($localeID===null?$this->getLanguage():$localeID);
return call_user_func_array(array($this->localeClass, 'getInstance'),array($localeID===null?$this->getLanguage():$localeID));
}

/**
Expand All @@ -397,7 +414,10 @@ public function getLocale($localeID=null)
*/
public function getLocaleDataPath()
{
return CLocale::$dataPath===null ? Yii::getPathOfAlias('system.i18n.data') : CLocale::$dataPath;
$vars=get_class_vars($this->localeClass);
if(empty($vars['dataPath']))
return Yii::getPathOfAlias('system.i18n.data');
return $vars['dataPath'];
}

/**
Expand All @@ -407,7 +427,8 @@ public function getLocaleDataPath()
*/
public function setLocaleDataPath($value)
{
CLocale::$dataPath=$value;
$property=new ReflectionProperty($this->localeClass,'dataPath');
$property->setValue($value);
}

/**
Expand Down Expand Up @@ -510,6 +531,15 @@ public function getUrlManager()
return $this->getComponent('urlManager');
}

/**
* Returns the formatter component.
* @return CFormatter the formatter component
*/
public function getFormat()
{
return $this->getComponent('format');
}

/**
* @return CController the currently active controller. Null is returned in this base class.
* @since 1.1.8
Expand Down Expand Up @@ -925,7 +955,7 @@ public function displayException($exception)
}

/**
* Initializes the class autoloader and error handlers.
* Initializes the error handlers.
*/
protected function initSystemHandlers()
{
Expand Down
4 changes: 2 additions & 2 deletions framework/base/CApplicationComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC
* @copyright 2008-2013 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/

Expand Down Expand Up @@ -47,7 +47,7 @@ public function init()
}

/**
* Checks if this application component bas been initialized.
* Checks if this application component has been initialized.
* @return boolean whether this application component has been initialized (ie, {@link init()} is invoked).
*/
public function getIsInitialized()
Expand Down
2 changes: 1 addition & 1 deletion framework/base/CBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC
* @copyright 2008-2013 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/

Expand Down
12 changes: 9 additions & 3 deletions framework/base/CComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC
* @copyright 2008-2013 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/

Expand Down Expand Up @@ -248,6 +248,7 @@ public function __unset($name)
* to implement the behavior feature.
* @param string $name the method name
* @param array $parameters method parameters
* @throws CException if current class and its behaviors do not have a method or closure with the given name
* @return mixed the method return value
*/
public function __call($name,$parameters)
Expand All @@ -260,7 +261,7 @@ public function __call($name,$parameters)
return call_user_func_array(array($object,$name),$parameters);
}
}
if(class_exists('Closure', false) && $this->canGetProperty($name) && $this->$name instanceof Closure)
if(class_exists('Closure', false) && ($this->canGetProperty($name) || property_exists($this, $name)) && $this->$name instanceof Closure)
return call_user_func_array($this->$name, $parameters);
throw new CException(Yii::t('yii','{class} and its behaviors do not have a method or closure named "{name}".',
array('{class}'=>get_class($this), '{name}'=>$name)));
Expand Down Expand Up @@ -318,6 +319,8 @@ public function detachBehaviors()
* @param string $name the behavior's name. It should uniquely identify this behavior.
* @param mixed $behavior the behavior configuration. This is passed as the first
* parameter to {@link YiiBase::createComponent} to create the behavior object.
* You can also pass an already created behavior instance (the new behavior will replace an already created
* behavior with the same name, if it exists).
* @return IBehavior the behavior object
*/
public function attachBehavior($name,$behavior)
Expand Down Expand Up @@ -496,7 +499,7 @@ public function getEventHandlers($name)
* $component->getEventHandlers($eventName)->add($eventHandler);
* </pre>
*
* Using {@link getEventHandlers}, one can also specify the excution order
* Using {@link getEventHandlers}, one can also specify the execution order
* of multiple handlers attaching to the same event. For example:
* <pre>
* $component->getEventHandlers($eventName)->insertAt(0,$eventHandler);
Expand Down Expand Up @@ -593,6 +596,9 @@ public function raiseEvent($name,$event)
* that can be directly accessed in the expression. See {@link http://us.php.net/manual/en/function.extract.php PHP extract}
* for more details. In the expression, the component object can be accessed using $this.
*
* A PHP expression can be any PHP code that has a value. To learn more about what an expression is,
* please refer to the {@link http://www.php.net/manual/en/language.expressions.php php manual}.
*
* @param mixed $_expression_ a PHP expression or PHP callback to be evaluated.
* @param array $_data_ additional parameters to be passed to the above expression/callback.
* @return mixed the expression result
Expand Down
Loading

0 comments on commit 51a0378

Please sign in to comment.