Skip to content

Commit

Permalink
№1: Обновлен Yii framework до версии 1.1.16
Browse files Browse the repository at this point in the history
№2: Заменен текстовый редактор на CKEDITOR
№3: Обновлен модуль ElFinder
№4: обновлен модуль Banners
№5: Заменен текстовый редактор в виджете IncludeFiles
  • Loading branch information
bahdall committed Sep 30, 2015
1 parent da2a942 commit d08d4b5
Show file tree
Hide file tree
Showing 1,670 changed files with 263,214 additions and 39,197 deletions.
15 changes: 12 additions & 3 deletions framework/YiiBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class YiiBase
*/
public static function getVersion()
{
return '1.1.14';
return '1.1.16';
}

/**
Expand Down Expand Up @@ -299,7 +299,8 @@ public static function import($alias,$forceInclude=false)

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 @@ -392,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 @@ -709,6 +714,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 Down Expand Up @@ -750,6 +758,7 @@ 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',
Expand Down
20 changes: 14 additions & 6 deletions framework/base/CApplication.php
Original file line number Diff line number Diff line change
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 @@ -97,6 +97,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 @@ -395,11 +399,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 @@ -409,7 +413,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 @@ -419,7 +426,8 @@ public function getLocaleDataPath()
*/
public function setLocaleDataPath($value)
{
CLocale::$dataPath=$value;
$property=new ReflectionProperty($this->localeClass,'dataPath');
$property->setValue($value);
}

/**
Expand Down Expand Up @@ -937,7 +945,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/CComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,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 @@ -499,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
85 changes: 62 additions & 23 deletions framework/base/CErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* {@link CApplication::getErrorHandler()}.
*
* @property array $error The error details. Null if there is no error.
* @property Exception|null $exception exception instance. Null if there is no exception.
*
* @author Qiang Xue <[email protected]>
* @package system.base
Expand Down Expand Up @@ -82,6 +83,7 @@ class CErrorHandler extends CApplicationComponent
public $errorAction;

private $_error;
private $_exception;

/**
* Handles the exception/error event.
Expand Down Expand Up @@ -150,6 +152,15 @@ public function getError()
return $this->_error;
}

/**
* Returns the instance of the exception that is currently being handled.
* @return Exception|null exception instance. Null if there is no exception.
*/
public function getException()
{
return $this->_exception;
}

/**
* Handles the exception.
* @param Exception $exception the exception captured
Expand Down Expand Up @@ -186,6 +197,7 @@ protected function handleException($exception)
unset($trace[$i]['object']);
}

$this->_exception=$exception;
$this->_error=$data=array(
'code'=>($exception instanceof CHttpException)?$exception->statusCode:500,
'type'=>get_class($exception),
Expand All @@ -198,17 +210,12 @@ protected function handleException($exception)
);

if(!headers_sent())
header("HTTP/1.0 {$data['code']} ".$this->getHttpHeader($data['code'], get_class($exception)));

if($exception instanceof CHttpException || !YII_DEBUG)
$this->render('error',$data);
else
{
if($this->isAjaxRequest())
$app->displayException($exception);
else
$this->render('exception',$data);
$httpVersion=Yii::app()->request->getHttpVersion();
header("HTTP/$httpVersion {$data['code']} ".$this->getHttpHeader($data['code'], get_class($exception)));
}

$this->renderException();
}
else
$app->displayException($exception);
Expand Down Expand Up @@ -270,7 +277,8 @@ protected function handleError($event)
default:
$type = 'PHP error';
}
$this->_error=$data=array(
$this->_exception=null;
$this->_error=array(
'code'=>500,
'type'=>$type,
'message'=>$event->message,
Expand All @@ -280,13 +288,12 @@ protected function handleError($event)
'traces'=>$trace,
);
if(!headers_sent())
header("HTTP/1.0 500 Internal Server Error");
if($this->isAjaxRequest())
$app->displayError($event->code,$event->message,$event->file,$event->line);
elseif(YII_DEBUG)
$this->render('exception',$data);
else
$this->render('error',$data);
{
$httpVersion=Yii::app()->request->getHttpVersion();
header("HTTP/$httpVersion 500 Internal Server Error");
}

$this->renderError();
}
else
$app->displayError($event->code,$event->message,$event->file,$event->line);
Expand Down Expand Up @@ -327,15 +334,47 @@ protected function getExactTrace($exception)
*/
protected function render($view,$data)
{
if($view==='error' && $this->errorAction!==null)
$data['version']=$this->getVersionInfo();
$data['time']=time();
$data['admin']=$this->adminInfo;
include($this->getViewFile($view,$data['code']));
}

/**
* Renders the exception information.
* This method will display information from current {@link error} value.
*/
protected function renderException()
{
$exception=$this->getException();
if($exception instanceof CHttpException || !YII_DEBUG)
$this->renderError();
else
{
if($this->isAjaxRequest())
Yii::app()->displayException($exception);
else
$this->render('exception',$this->getError());
}
}

/**
* Renders the current error information.
* This method will display information from current {@link error} value.
*/
protected function renderError()
{
if($this->errorAction!==null)
Yii::app()->runController($this->errorAction);
else
{
// additional information to be passed to view
$data['version']=$this->getVersionInfo();
$data['time']=time();
$data['admin']=$this->adminInfo;
include($this->getViewFile($view,$data['code']));
$data=$this->getError();
if($this->isAjaxRequest())
Yii::app()->displayError($data['code'],$data['message'],$data['file'],$data['line']);
elseif(YII_DEBUG)
$this->render('exception',$data);
else
$this->render('error',$data);
}
}

Expand Down
2 changes: 1 addition & 1 deletion framework/base/CModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ abstract public function attributeNames();
* <li>except: this specifies the scenarios when the validation rule should not be performed.
* Separate different scenarios with commas. Please see {@link scenario} for more details about this option.</li>
* <li>additional parameters are used to initialize the corresponding validator properties.
* Please refer to individal validator class API for possible properties.</li>
* Please refer to individual validator class API for possible properties.</li>
* </ul>
*
* The following are some examples:
Expand Down
23 changes: 15 additions & 8 deletions framework/base/CModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,13 @@ public function getModules()
* You may also enable or disable a module by specifying the 'enabled' option in the configuration.
*
* @param array $modules module configurations.
* @param boolean $merge whether to merge the new module configuration
* with the existing one. Defaults to true, meaning the previously registered
* module configuration with the same ID will be merged with the new configuration.
* If set to false, the existing configuration will be replaced completely.
* This parameter is available since 1.1.16.
*/
public function setModules($modules)
public function setModules($modules,$merge=true)
{
foreach($modules as $id=>$module)
{
Expand All @@ -342,16 +347,18 @@ public function setModules($modules)
$id=$module;
$module=array();
}
if(!isset($module['class']))
{
Yii::setPathOfAlias($id,$this->getModulePath().DIRECTORY_SEPARATOR.$id);
$module['class']=$id.'.'.ucfirst($id).'Module';
}

if(isset($this->_moduleConfig[$id]))
if(isset($this->_moduleConfig[$id]) && $merge)
$this->_moduleConfig[$id]=CMap::mergeArray($this->_moduleConfig[$id],$module);
else
{
if(!isset($module['class']))
{
if (Yii::getPathOfAlias($id)===false)
Yii::setPathOfAlias($id,$this->getModulePath().DIRECTORY_SEPARATOR.$id);
$module['class']=$id.'.'.ucfirst($id).'Module';
}
$this->_moduleConfig[$id]=$module;
}
}
}

Expand Down
Loading

0 comments on commit d08d4b5

Please sign in to comment.