mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
CS fixes.
This commit is contained in:
@ -255,7 +255,7 @@ class ErrorHandler extends Component
|
|||||||
if (isset($_SERVER['SERVER_SOFTWARE'])) {
|
if (isset($_SERVER['SERVER_SOFTWARE'])) {
|
||||||
foreach ($serverUrls as $url => $keywords) {
|
foreach ($serverUrls as $url => $keywords) {
|
||||||
foreach ($keywords as $keyword) {
|
foreach ($keywords as $keyword) {
|
||||||
if (stripos($_SERVER['SERVER_SOFTWARE'], $keyword) !== false ) {
|
if (stripos($_SERVER['SERVER_SOFTWARE'], $keyword) !== false) {
|
||||||
return '<a href="' . $url . '" target="_blank">' . $this->htmlEncode($_SERVER['SERVER_SOFTWARE']) . '</a>';
|
return '<a href="' . $url . '" target="_blank">' . $this->htmlEncode($_SERVER['SERVER_SOFTWARE']) . '</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ use DateTime;
|
|||||||
use yii\helpers\HtmlPurifier;
|
use yii\helpers\HtmlPurifier;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formatter provides a set of commonly used data formatting methods.
|
* Formatter provides a set of commonly used data formatting methods.
|
||||||
*
|
*
|
||||||
|
@ -23,4 +23,3 @@ class InvalidCallException extends Exception
|
|||||||
return \Yii::t('yii', 'Invalid Call');
|
return \Yii::t('yii', 'Invalid Call');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,4 +23,3 @@ class InvalidConfigException extends Exception
|
|||||||
return \Yii::t('yii', 'Invalid Configuration');
|
return \Yii::t('yii', 'Invalid Configuration');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,4 +23,3 @@ class InvalidParamException extends Exception
|
|||||||
return \Yii::t('yii', 'Invalid Parameter');
|
return \Yii::t('yii', 'Invalid Parameter');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,4 +23,3 @@ class InvalidRouteException extends UserException
|
|||||||
return \Yii::t('yii', 'Invalid Route');
|
return \Yii::t('yii', 'Invalid Route');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,5 +18,5 @@ interface Jsonable
|
|||||||
/**
|
/**
|
||||||
* @return string the JSON representation of this object
|
* @return string the JSON representation of this object
|
||||||
*/
|
*/
|
||||||
function toJson();
|
public function toJson();
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -23,4 +23,3 @@ class NotSupportedException extends Exception
|
|||||||
return \Yii::t('yii', 'Not Supported');
|
return \Yii::t('yii', 'Not Supported');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class Theme extends Component
|
|||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
if (empty($this->pathMap)) {
|
if (empty($this->pathMap)) {
|
||||||
if ($this->basePath !== null) {
|
if ($this->basePath !== null) {
|
||||||
$this->basePath = Yii::getAlias($this->basePath);
|
$this->basePath = Yii::getAlias($this->basePath);
|
||||||
|
@ -23,4 +23,3 @@ class UnknownClassException extends Exception
|
|||||||
return \Yii::t('yii', 'Unknown Class');
|
return \Yii::t('yii', 'Unknown Class');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,4 +23,3 @@ class UnknownMethodException extends Exception
|
|||||||
return \Yii::t('yii', 'Unknown Method');
|
return \Yii::t('yii', 'Unknown Method');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,4 +23,3 @@ class UnknownPropertyException extends Exception
|
|||||||
return \Yii::t('yii', 'Unknown Property');
|
return \Yii::t('yii', 'Unknown Property');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,9 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace yii\bootstrap;
|
namespace yii\bootstrap;
|
||||||
use yii\base\InvalidConfigException;
|
|
||||||
use yii\helpers\Html;
|
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Button renders a bootstrap button.
|
* Button renders a bootstrap button.
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace yii\bootstrap;
|
namespace yii\bootstrap;
|
||||||
use yii\helpers\Html;
|
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ButtonDropdown renders a group or split button dropdown bootstrap component.
|
* ButtonDropdown renders a group or split button dropdown bootstrap component.
|
||||||
|
@ -10,7 +10,6 @@ namespace yii\bootstrap;
|
|||||||
use yii\helpers\base\ArrayHelper;
|
use yii\helpers\base\ArrayHelper;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ButtonGroup renders a button group bootstrap component.
|
* ButtonGroup renders a button group bootstrap component.
|
||||||
*
|
*
|
||||||
|
@ -130,4 +130,4 @@ class Collapse extends Widget
|
|||||||
|
|
||||||
return implode("\n", $group);
|
return implode("\n", $group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ use yii\base\InvalidConfigException;
|
|||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dropdown renders a Bootstrap dropdown menu component.
|
* Dropdown renders a Bootstrap dropdown menu component.
|
||||||
*
|
*
|
||||||
|
@ -118,7 +118,7 @@ class Nav extends Widget
|
|||||||
$url = Html::url(ArrayHelper::getValue($item, 'url', '#'));
|
$url = Html::url(ArrayHelper::getValue($item, 'url', '#'));
|
||||||
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', array());
|
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', array());
|
||||||
|
|
||||||
if(ArrayHelper::getValue($item, 'active')) {
|
if (ArrayHelper::getValue($item, 'active')) {
|
||||||
$this->addCssClass($options, 'active');
|
$this->addCssClass($options, 'active');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ use yii\base\InvalidConfigException;
|
|||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Progress renders a bootstrap progress bar component.
|
* Progress renders a bootstrap progress bar component.
|
||||||
*
|
*
|
||||||
|
@ -11,7 +11,6 @@ use Yii;
|
|||||||
use yii\base\View;
|
use yii\base\View;
|
||||||
use yii\helpers\Json;
|
use yii\helpers\Json;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \yii\bootstrap\Widget is the base class for all bootstrap widgets.
|
* \yii\bootstrap\Widget is the base class for all bootstrap widgets.
|
||||||
*
|
*
|
||||||
|
@ -170,7 +170,7 @@ class DbCache extends Cache
|
|||||||
} else {
|
} else {
|
||||||
return $this->addValue($key, $value, $expire);
|
return $this->addValue($key, $value, $expire);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a value identified by a key into cache if the cache does not contain this key.
|
* Stores a value identified by a key into cache if the cache does not contain this key.
|
||||||
|
@ -86,4 +86,3 @@ class XCache extends Cache
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,4 +25,3 @@ class Exception extends UserException
|
|||||||
return \Yii::t('yii', 'Error');
|
return \Yii::t('yii', 'Error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,8 @@ class AssetController extends Controller
|
|||||||
* @param array $result already loaded bundles list.
|
* @param array $result already loaded bundles list.
|
||||||
* @throws \yii\console\Exception on failure.
|
* @throws \yii\console\Exception on failure.
|
||||||
*/
|
*/
|
||||||
protected function loadBundleDependency($name, $bundle, &$result) {
|
protected function loadBundleDependency($name, $bundle, &$result)
|
||||||
|
{
|
||||||
if (!empty($bundle->depends)) {
|
if (!empty($bundle->depends)) {
|
||||||
$assetManager = $this->getAssetManager();
|
$assetManager = $this->getAssetManager();
|
||||||
foreach ($bundle->depends as $dependencyName) {
|
foreach ($bundle->depends as $dependencyName) {
|
||||||
@ -572,7 +573,7 @@ EOD;
|
|||||||
$inputFileRelativePathParts = explode('/', $inputFileRelativePath);
|
$inputFileRelativePathParts = explode('/', $inputFileRelativePath);
|
||||||
$outputFileRelativePathParts = explode('/', $outputFileRelativePath);
|
$outputFileRelativePathParts = explode('/', $outputFileRelativePath);
|
||||||
|
|
||||||
$callback = function($matches) use ($inputFileRelativePathParts, $outputFileRelativePathParts) {
|
$callback = function ($matches) use ($inputFileRelativePathParts, $outputFileRelativePathParts) {
|
||||||
$fullMatch = $matches[0];
|
$fullMatch = $matches[0];
|
||||||
$inputUrl = $matches[1];
|
$inputUrl = $matches[1];
|
||||||
|
|
||||||
|
@ -179,8 +179,7 @@ class MessageController extends Controller
|
|||||||
}
|
}
|
||||||
ksort($translated);
|
ksort($translated);
|
||||||
foreach ($translated as $message => $translation) {
|
foreach ($translated as $message => $translation) {
|
||||||
if (!isset($merged[$message]) && !isset($todo[$message]) && !$removeOld)
|
if (!isset($merged[$message]) && !isset($todo[$message]) && !$removeOld) {
|
||||||
{
|
|
||||||
if (substr($translation, 0, 2) === '@@' && substr($translation, -2) === '@@') {
|
if (substr($translation, 0, 2) === '@@' && substr($translation, -2) === '@@') {
|
||||||
$todo[$message]=$translation;
|
$todo[$message]=$translation;
|
||||||
} else {
|
} else {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -305,8 +305,7 @@ class Connection extends Component
|
|||||||
$this->pdo = $this->createPdoInstance();
|
$this->pdo = $this->createPdoInstance();
|
||||||
$this->initConnection();
|
$this->initConnection();
|
||||||
Yii::endProfile($token, __METHOD__);
|
Yii::endProfile($token, __METHOD__);
|
||||||
}
|
} catch (\PDOException $e) {
|
||||||
catch (\PDOException $e) {
|
|
||||||
Yii::endProfile($token, __METHOD__);
|
Yii::endProfile($token, __METHOD__);
|
||||||
Yii::error("Failed to open DB connection ({$this->dsn}): " . $e->getMessage(), __METHOD__);
|
Yii::error("Failed to open DB connection ({$this->dsn}): " . $e->getMessage(), __METHOD__);
|
||||||
$message = YII_DEBUG ? 'Failed to open DB connection: ' . $e->getMessage() : 'Failed to open DB connection.';
|
$message = YII_DEBUG ? 'Failed to open DB connection: ' . $e->getMessage() : 'Failed to open DB connection.';
|
||||||
@ -508,7 +507,7 @@ class Connection extends Component
|
|||||||
{
|
{
|
||||||
$db = $this;
|
$db = $this;
|
||||||
return preg_replace_callback('/(\\{\\{([%\w\-\. ]+)\\}\\}|\\[\\[([\w\-\. ]+)\\]\\])/',
|
return preg_replace_callback('/(\\{\\{([%\w\-\. ]+)\\}\\}|\\[\\[([\w\-\. ]+)\\]\\])/',
|
||||||
function($matches) use($db) {
|
function ($matches) use ($db) {
|
||||||
if (isset($matches[3])) {
|
if (isset($matches[3])) {
|
||||||
return $db->quoteColumnName($matches[3]);
|
return $db->quoteColumnName($matches[3]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -14,4 +14,4 @@ namespace yii\debug;
|
|||||||
class Module extends \yii\base\Module
|
class Module extends \yii\base\Module
|
||||||
{
|
{
|
||||||
public $controllerNamespace = 'yii\debug\controllers';
|
public $controllerNamespace = 'yii\debug\controllers';
|
||||||
}
|
}
|
||||||
|
@ -31,4 +31,4 @@ class DefaultController extends Controller
|
|||||||
echo "Unable to find debug data tagged with '$tag'.";
|
echo "Unable to find debug data tagged with '$tag'.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,5 +14,4 @@ namespace yii\helpers;
|
|||||||
*/
|
*/
|
||||||
class Json extends base\Json
|
class Json extends base\Json
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@ class Console
|
|||||||
* You can pass any of the FG_*, BG_* and TEXT_* constants and also [[xtermFgColor]] and [[xtermBgColor]].
|
* You can pass any of the FG_*, BG_* and TEXT_* constants and also [[xtermFgColor]] and [[xtermBgColor]].
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function ansiFormat($string, $format=array())
|
public static function ansiFormat($string, $format = array())
|
||||||
{
|
{
|
||||||
$code = implode(';', $format);
|
$code = implode(';', $format);
|
||||||
return "\033[0m" . ($code !== '' ? "\033[" . $code . "m" : '') . $string . "\033[0m";
|
return "\033[0m" . ($code !== '' ? "\033[" . $code . "m" : '') . $string . "\033[0m";
|
||||||
@ -589,11 +589,10 @@ class Console
|
|||||||
if (static::isRunningOnWindows()) {
|
if (static::isRunningOnWindows()) {
|
||||||
$output = array();
|
$output = array();
|
||||||
exec('mode con', $output);
|
exec('mode con', $output);
|
||||||
if(isset($output) && strpos($output[1], 'CON')!==false) {
|
if (isset($output) && strpos($output[1], 'CON') !== false) {
|
||||||
return $size = array((int)preg_replace('~[^0-9]~', '', $output[3]), (int)preg_replace('~[^0-9]~', '', $output[4]));
|
return $size = array((int)preg_replace('~[^0-9]~', '', $output[3]), (int)preg_replace('~[^0-9]~', '', $output[4]));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// try stty if available
|
// try stty if available
|
||||||
$stty = array();
|
$stty = array();
|
||||||
if (exec('stty -a 2>&1', $stty) && preg_match('/rows\s+(\d+);\s*columns\s+(\d+);/mi', implode(' ', $stty), $matches)) {
|
if (exec('stty -a 2>&1', $stty) && preg_match('/rows\s+(\d+);\s*columns\s+(\d+);/mi', implode(' ', $stty), $matches)) {
|
||||||
|
@ -1479,5 +1479,4 @@ class Html
|
|||||||
$name = strtolower(static::getInputName($model, $attribute));
|
$name = strtolower(static::getInputName($model, $attribute));
|
||||||
return str_replace(array('[]', '][', '[', ']', ' '), array('', '-', '-', '', '-'), $name);
|
return str_replace(array('[]', '][', '[', ']', ' '), array('', '-', '-', '', '-'), $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ class Inflector
|
|||||||
'/(ax|cris|test)is$/i' => '\1es',
|
'/(ax|cris|test)is$/i' => '\1es',
|
||||||
'/s$/' => 's',
|
'/s$/' => 's',
|
||||||
'/^$/' => '',
|
'/^$/' => '',
|
||||||
'/$/' => 's',
|
'/$/' => 's',
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* @var array the rules for converting a word into its singular form.
|
* @var array the rules for converting a word into its singular form.
|
||||||
@ -94,7 +94,7 @@ class Inflector
|
|||||||
'/(n)ews$/i' => '\1\2ews',
|
'/(n)ews$/i' => '\1\2ews',
|
||||||
'/eaus$/' => 'eau',
|
'/eaus$/' => 'eau',
|
||||||
'/^(.*us)$/' => '\\1',
|
'/^(.*us)$/' => '\\1',
|
||||||
'/s$/i' => '',
|
'/s$/i' => '',
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* @var array the special rules for converting a word between its plural form and singular form.
|
* @var array the special rules for converting a word between its plural form and singular form.
|
||||||
@ -468,7 +468,7 @@ class Inflector
|
|||||||
if (in_array(($number % 100), range(11, 13))) {
|
if (in_array(($number % 100), range(11, 13))) {
|
||||||
return $number . 'th';
|
return $number . 'th';
|
||||||
}
|
}
|
||||||
switch (($number % 10)) {
|
switch ($number % 10) {
|
||||||
case 1: return $number . 'st';
|
case 1: return $number . 'st';
|
||||||
case 2: return $number . 'nd';
|
case 2: return $number . 'nd';
|
||||||
case 3: return $number . 'rd';
|
case 3: return $number . 'rd';
|
||||||
|
@ -118,4 +118,3 @@ class MessageSource extends Component
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ class Accordion extends Widget
|
|||||||
$items[] = Html::tag($headerTag, $item['header'], $headerOptions);
|
$items[] = Html::tag($headerTag, $item['header'], $headerOptions);
|
||||||
$options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', array()));
|
$options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', array()));
|
||||||
$tag = ArrayHelper::remove($options, 'tag', 'div');
|
$tag = ArrayHelper::remove($options, 'tag', 'div');
|
||||||
$items[] = Html::tag($tag, $item['content'], $options);;
|
$items[] = Html::tag($tag, $item['content'], $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode("\n", $items);
|
return implode("\n", $items);
|
||||||
|
@ -10,7 +10,6 @@ namespace yii\jui;
|
|||||||
use Yii;
|
use Yii;
|
||||||
use yii\helpers\Json;
|
use yii\helpers\Json;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Menu renders a menu jQuery UI widget.
|
* Menu renders a menu jQuery UI widget.
|
||||||
*
|
*
|
||||||
|
@ -10,7 +10,6 @@ namespace yii\jui;
|
|||||||
use Yii;
|
use Yii;
|
||||||
use yii\helpers\Json;
|
use yii\helpers\Json;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \yii\jui\Widget is the base class for all jQuery UI widgets.
|
* \yii\jui\Widget is the base class for all jQuery UI widgets.
|
||||||
*
|
*
|
||||||
|
@ -493,8 +493,9 @@ class DbManager extends Manager
|
|||||||
'bizRule' => $row['biz_rule'],
|
'bizRule' => $row['biz_rule'],
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
));
|
));
|
||||||
} else
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -468,7 +468,7 @@ class PhpManager extends Manager
|
|||||||
'bizRule' => $assignment['bizRule'],
|
'bizRule' => $assignment['bizRule'],
|
||||||
'data' => $assignment['data'],
|
'data' => $assignment['data'],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,4 +45,4 @@ return array(
|
|||||||
'by' => '<a href="http://www.php.net/manual/en/book.intl.php">Internationalization</a> support',
|
'by' => '<a href="http://www.php.net/manual/en/book.intl.php">Internationalization</a> support',
|
||||||
'memo' => 'PHP Intl extension 1.0.2 or higher is required when you want to use <abbr title="Internationalized domain names">IDN</abbr>-feature of EmailValidator or UrlValidator or the <code>yii\i18n\Formatter</code> class.'
|
'memo' => 'PHP Intl extension 1.0.2 or higher is required when you want to use <abbr title="Internationalized domain names">IDN</abbr>-feature of EmailValidator or UrlValidator or the <code>yii\i18n\Formatter</code> class.'
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -117,4 +117,3 @@ class CaptchaValidator extends Validator
|
|||||||
return 'yii.validation.captcha(value, messages, ' . json_encode($options) . ');';
|
return 'yii.validation.captcha(value, messages, ' . json_encode($options) . ');';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,4 +73,3 @@ class DateValidator extends Validator
|
|||||||
return DateTime::createFromFormat($this->format, $value) !== false;
|
return DateTime::createFromFormat($this->format, $value) !== false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,4 +40,3 @@ class DefaultValueValidator extends Validator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,4 +99,3 @@ class ExistValidator extends Validator
|
|||||||
return $query->exists();
|
return $query->exists();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace yii\validators;
|
namespace yii\validators;
|
||||||
|
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +35,7 @@ class RangeValidator extends Validator
|
|||||||
* @var boolean whether to invert the validation logic. Defaults to false. If set to true,
|
* @var boolean whether to invert the validation logic. Defaults to false. If set to true,
|
||||||
* the attribute value should NOT be among the list of values defined via [[range]].
|
* the attribute value should NOT be among the list of values defined via [[range]].
|
||||||
**/
|
**/
|
||||||
public $not = false;
|
public $not = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the validator.
|
* Initializes the validator.
|
||||||
|
@ -32,7 +32,7 @@ class RegularExpressionValidator extends Validator
|
|||||||
* the regular expression defined via [[pattern]] should NOT match the attribute value.
|
* the regular expression defined via [[pattern]] should NOT match the attribute value.
|
||||||
* @throws InvalidConfigException if the "pattern" is not a valid regular expression
|
* @throws InvalidConfigException if the "pattern" is not a valid regular expression
|
||||||
**/
|
**/
|
||||||
public $not = false;
|
public $not = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the validator.
|
* Initializes the validator.
|
||||||
|
@ -174,4 +174,3 @@ class StringValidator extends Validator
|
|||||||
return 'yii.validation.string(value, messages, ' . json_encode($options) . ');';
|
return 'yii.validation.string(value, messages, ' . json_encode($options) . ');';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class UrlValidator extends Validator
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->enableIDN) {
|
if ($this->enableIDN) {
|
||||||
$value = preg_replace_callback('/:\/\/([^\/]+)/', function($matches) {
|
$value = preg_replace_callback('/:\/\/([^\/]+)/', function ($matches) {
|
||||||
return '://' . idn_to_ascii($matches[1]);
|
return '://' . idn_to_ascii($matches[1]);
|
||||||
}, $value);
|
}, $value);
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ abstract class Validator extends Component
|
|||||||
}
|
}
|
||||||
foreach ($attributes as $attribute) {
|
foreach ($attributes as $attribute) {
|
||||||
$skip = $this->skipOnError && $object->hasErrors($attribute)
|
$skip = $this->skipOnError && $object->hasErrors($attribute)
|
||||||
|| $this->skipOnEmpty && $this->isEmpty($object->$attribute);
|
|| $this->skipOnEmpty && $this->isEmpty($object->$attribute);
|
||||||
if (!$skip) {
|
if (!$skip) {
|
||||||
$this->validateAttribute($object, $attribute);
|
$this->validateAttribute($object, $attribute);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ use Yii;
|
|||||||
use yii\base\Object;
|
use yii\base\Object;
|
||||||
use ArrayIterator;
|
use ArrayIterator;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HeaderCollection is used by [[Response]] to maintain the currently registered HTTP headers.
|
* HeaderCollection is used by [[Response]] to maintain the currently registered HTTP headers.
|
||||||
*
|
*
|
||||||
|
@ -1,104 +1,104 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @link http://www.yiiframework.com/
|
* @link http://www.yiiframework.com/
|
||||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||||
* @license http://www.yiiframework.com/license/
|
* @license http://www.yiiframework.com/license/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace yii\web;
|
namespace yii\web;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\ActionFilter;
|
use yii\base\ActionFilter;
|
||||||
use yii\base\Action;
|
use yii\base\Action;
|
||||||
use yii\base\View;
|
use yii\base\View;
|
||||||
use yii\caching\Dependency;
|
use yii\caching\Dependency;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
class PageCache extends ActionFilter
|
class PageCache extends ActionFilter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var boolean whether the content being cached should be differentiated according to the route.
|
* @var boolean whether the content being cached should be differentiated according to the route.
|
||||||
* A route consists of the requested controller ID and action ID. Defaults to true.
|
* A route consists of the requested controller ID and action ID. Defaults to true.
|
||||||
*/
|
*/
|
||||||
public $varyByRoute = true;
|
public $varyByRoute = true;
|
||||||
/**
|
/**
|
||||||
* @var string the application component ID of the [[\yii\caching\Cache|cache]] object.
|
* @var string the application component ID of the [[\yii\caching\Cache|cache]] object.
|
||||||
*/
|
*/
|
||||||
public $cache = 'cache';
|
public $cache = 'cache';
|
||||||
/**
|
/**
|
||||||
* @var integer number of seconds that the data can remain valid in cache.
|
* @var integer number of seconds that the data can remain valid in cache.
|
||||||
* Use 0 to indicate that the cached data will never expire.
|
* Use 0 to indicate that the cached data will never expire.
|
||||||
*/
|
*/
|
||||||
public $duration = 60;
|
public $duration = 60;
|
||||||
/**
|
/**
|
||||||
* @var array|Dependency the dependency that the cached content depends on.
|
* @var array|Dependency the dependency that the cached content depends on.
|
||||||
* This can be either a [[Dependency]] object or a configuration array for creating the dependency object.
|
* This can be either a [[Dependency]] object or a configuration array for creating the dependency object.
|
||||||
* For example,
|
* For example,
|
||||||
*
|
*
|
||||||
* ~~~
|
* ~~~
|
||||||
* array(
|
* array(
|
||||||
* 'class' => 'yii\caching\DbDependency',
|
* 'class' => 'yii\caching\DbDependency',
|
||||||
* 'sql' => 'SELECT MAX(lastModified) FROM Post',
|
* 'sql' => 'SELECT MAX(lastModified) FROM Post',
|
||||||
* )
|
* )
|
||||||
* ~~~
|
* ~~~
|
||||||
*
|
*
|
||||||
* would make the output cache depends on the last modified time of all posts.
|
* would make the output cache depends on the last modified time of all posts.
|
||||||
* If any post has its modification time changed, the cached content would be invalidated.
|
* If any post has its modification time changed, the cached content would be invalidated.
|
||||||
*/
|
*/
|
||||||
public $dependency;
|
public $dependency;
|
||||||
/**
|
/**
|
||||||
* @var array list of factors that would cause the variation of the content being cached.
|
* @var array list of factors that would cause the variation of the content being cached.
|
||||||
* Each factor is a string representing a variation (e.g. the language, a GET parameter).
|
* Each factor is a string representing a variation (e.g. the language, a GET parameter).
|
||||||
* The following variation setting will cause the content to be cached in different versions
|
* The following variation setting will cause the content to be cached in different versions
|
||||||
* according to the current application language:
|
* according to the current application language:
|
||||||
*
|
*
|
||||||
* ~~~
|
* ~~~
|
||||||
* array(
|
* array(
|
||||||
* Yii::$app->language,
|
* Yii::$app->language,
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public $variations;
|
public $variations;
|
||||||
/**
|
/**
|
||||||
* @var boolean whether to enable the fragment cache. You may use this property to turn on and off
|
* @var boolean whether to enable the fragment cache. You may use this property to turn on and off
|
||||||
* the fragment cache according to specific setting (e.g. enable fragment cache only for GET requests).
|
* the fragment cache according to specific setting (e.g. enable fragment cache only for GET requests).
|
||||||
*/
|
*/
|
||||||
public $enabled = true;
|
public $enabled = true;
|
||||||
|
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
if ($this->view === null) {
|
if ($this->view === null) {
|
||||||
$this->view = Yii::$app->getView();
|
$this->view = Yii::$app->getView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is invoked right before an action is to be executed (after all possible filters.)
|
* This method is invoked right before an action is to be executed (after all possible filters.)
|
||||||
* You may override this method to do last-minute preparation for the action.
|
* You may override this method to do last-minute preparation for the action.
|
||||||
* @param Action $action the action to be executed.
|
* @param Action $action the action to be executed.
|
||||||
* @return boolean whether the action should continue to be executed.
|
* @return boolean whether the action should continue to be executed.
|
||||||
*/
|
*/
|
||||||
public function beforeAction($action)
|
public function beforeAction($action)
|
||||||
{
|
{
|
||||||
$properties = array();
|
$properties = array();
|
||||||
foreach (array('cache', 'duration', 'dependency', 'variations', 'enabled') as $name) {
|
foreach (array('cache', 'duration', 'dependency', 'variations', 'enabled') as $name) {
|
||||||
$properties[$name] = $this->$name;
|
$properties[$name] = $this->$name;
|
||||||
}
|
}
|
||||||
$id = $this->varyByRoute ? $action->getUniqueId() : __CLASS__;
|
$id = $this->varyByRoute ? $action->getUniqueId() : __CLASS__;
|
||||||
return $this->view->beginCache($id, $properties);
|
return $this->view->beginCache($id, $properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is invoked right after an action is executed.
|
* This method is invoked right after an action is executed.
|
||||||
* You may override this method to do some postprocessing for the action.
|
* You may override this method to do some postprocessing for the action.
|
||||||
* @param Action $action the action just executed.
|
* @param Action $action the action just executed.
|
||||||
*/
|
*/
|
||||||
public function afterAction($action)
|
public function afterAction($action)
|
||||||
{
|
{
|
||||||
$this->view->endCache();
|
$this->view->endCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -792,4 +792,3 @@ class Request extends \yii\base\Request
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ class User extends Component
|
|||||||
if ($destroySession) {
|
if ($destroySession) {
|
||||||
Yii::$app->getSession()->destroy();
|
Yii::$app->getSession()->destroy();
|
||||||
}
|
}
|
||||||
$this->afterLogout($identity);
|
$this->afterLogout($identity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,174 +1,174 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @link http://www.yiiframework.com/
|
* @link http://www.yiiframework.com/
|
||||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||||
* @license http://www.yiiframework.com/license/
|
* @license http://www.yiiframework.com/license/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace yii\widgets;
|
namespace yii\widgets;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Widget;
|
use yii\base\Widget;
|
||||||
use yii\caching\Cache;
|
use yii\caching\Cache;
|
||||||
use yii\caching\Dependency;
|
use yii\caching\Dependency;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
class FragmentCache extends Widget
|
class FragmentCache extends Widget
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Cache|string the cache object or the application component ID of the cache object.
|
* @var Cache|string the cache object or the application component ID of the cache object.
|
||||||
* After the FragmentCache object is created, if you want to change this property,
|
* After the FragmentCache object is created, if you want to change this property,
|
||||||
* you should only assign it with a cache object.
|
* you should only assign it with a cache object.
|
||||||
*/
|
*/
|
||||||
public $cache = 'cache';
|
public $cache = 'cache';
|
||||||
/**
|
/**
|
||||||
* @var integer number of seconds that the data can remain valid in cache.
|
* @var integer number of seconds that the data can remain valid in cache.
|
||||||
* Use 0 to indicate that the cached data will never expire.
|
* Use 0 to indicate that the cached data will never expire.
|
||||||
*/
|
*/
|
||||||
public $duration = 60;
|
public $duration = 60;
|
||||||
/**
|
/**
|
||||||
* @var array|Dependency the dependency that the cached content depends on.
|
* @var array|Dependency the dependency that the cached content depends on.
|
||||||
* This can be either a [[Dependency]] object or a configuration array for creating the dependency object.
|
* This can be either a [[Dependency]] object or a configuration array for creating the dependency object.
|
||||||
* For example,
|
* For example,
|
||||||
*
|
*
|
||||||
* ~~~
|
* ~~~
|
||||||
* array(
|
* array(
|
||||||
* 'class' => 'yii\caching\DbDependency',
|
* 'class' => 'yii\caching\DbDependency',
|
||||||
* 'sql' => 'SELECT MAX(lastModified) FROM Post',
|
* 'sql' => 'SELECT MAX(lastModified) FROM Post',
|
||||||
* )
|
* )
|
||||||
* ~~~
|
* ~~~
|
||||||
*
|
*
|
||||||
* would make the output cache depends on the last modified time of all posts.
|
* would make the output cache depends on the last modified time of all posts.
|
||||||
* If any post has its modification time changed, the cached content would be invalidated.
|
* If any post has its modification time changed, the cached content would be invalidated.
|
||||||
*/
|
*/
|
||||||
public $dependency;
|
public $dependency;
|
||||||
/**
|
/**
|
||||||
* @var array list of factors that would cause the variation of the content being cached.
|
* @var array list of factors that would cause the variation of the content being cached.
|
||||||
* Each factor is a string representing a variation (e.g. the language, a GET parameter).
|
* Each factor is a string representing a variation (e.g. the language, a GET parameter).
|
||||||
* The following variation setting will cause the content to be cached in different versions
|
* The following variation setting will cause the content to be cached in different versions
|
||||||
* according to the current application language:
|
* according to the current application language:
|
||||||
*
|
*
|
||||||
* ~~~
|
* ~~~
|
||||||
* array(
|
* array(
|
||||||
* Yii::$app->language,
|
* Yii::$app->language,
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public $variations;
|
public $variations;
|
||||||
/**
|
/**
|
||||||
* @var boolean whether to enable the fragment cache. You may use this property to turn on and off
|
* @var boolean whether to enable the fragment cache. You may use this property to turn on and off
|
||||||
* the fragment cache according to specific setting (e.g. enable fragment cache only for GET requests).
|
* the fragment cache according to specific setting (e.g. enable fragment cache only for GET requests).
|
||||||
*/
|
*/
|
||||||
public $enabled = true;
|
public $enabled = true;
|
||||||
/**
|
/**
|
||||||
* @var array a list of placeholders for embedding dynamic contents. This property
|
* @var array a list of placeholders for embedding dynamic contents. This property
|
||||||
* is used internally to implement the content caching feature. Do not modify it.
|
* is used internally to implement the content caching feature. Do not modify it.
|
||||||
*/
|
*/
|
||||||
public $dynamicPlaceholders;
|
public $dynamicPlaceholders;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the FragmentCache object.
|
* Initializes the FragmentCache object.
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
|
|
||||||
if (!$this->enabled) {
|
if (!$this->enabled) {
|
||||||
$this->cache = null;
|
$this->cache = null;
|
||||||
} elseif (is_string($this->cache)) {
|
} elseif (is_string($this->cache)) {
|
||||||
$this->cache = Yii::$app->getComponent($this->cache);
|
$this->cache = Yii::$app->getComponent($this->cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getCachedContent() === false) {
|
if ($this->getCachedContent() === false) {
|
||||||
$this->view->cacheStack[] = $this;
|
$this->view->cacheStack[] = $this;
|
||||||
ob_start();
|
ob_start();
|
||||||
ob_implicit_flush(false);
|
ob_implicit_flush(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks the end of content to be cached.
|
* Marks the end of content to be cached.
|
||||||
* Content displayed before this method call and after {@link init()}
|
* Content displayed before this method call and after {@link init()}
|
||||||
* will be captured and saved in cache.
|
* will be captured and saved in cache.
|
||||||
* This method does nothing if valid content is already found in cache.
|
* This method does nothing if valid content is already found in cache.
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
if (($content = $this->getCachedContent()) !== false) {
|
if (($content = $this->getCachedContent()) !== false) {
|
||||||
echo $content;
|
echo $content;
|
||||||
} elseif ($this->cache instanceof Cache) {
|
} elseif ($this->cache instanceof Cache) {
|
||||||
$content = ob_get_clean();
|
$content = ob_get_clean();
|
||||||
array_pop($this->view->cacheStack);
|
array_pop($this->view->cacheStack);
|
||||||
if (is_array($this->dependency)) {
|
if (is_array($this->dependency)) {
|
||||||
$this->dependency = Yii::createObject($this->dependency);
|
$this->dependency = Yii::createObject($this->dependency);
|
||||||
}
|
}
|
||||||
$data = array($content, $this->dynamicPlaceholders);
|
$data = array($content, $this->dynamicPlaceholders);
|
||||||
$this->cache->set($this->calculateKey(), $data, $this->duration, $this->dependency);
|
$this->cache->set($this->calculateKey(), $data, $this->duration, $this->dependency);
|
||||||
|
|
||||||
if (empty($this->view->cacheStack) && !empty($this->dynamicPlaceholders)) {
|
if (empty($this->view->cacheStack) && !empty($this->dynamicPlaceholders)) {
|
||||||
$content = $this->updateDynamicContent($content, $this->dynamicPlaceholders);
|
$content = $this->updateDynamicContent($content, $this->dynamicPlaceholders);
|
||||||
}
|
}
|
||||||
echo $content;
|
echo $content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string|boolean the cached content. False if the content is not cached.
|
* @var string|boolean the cached content. False if the content is not cached.
|
||||||
*/
|
*/
|
||||||
private $_content;
|
private $_content;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the cached content if available.
|
* Returns the cached content if available.
|
||||||
* @return string|boolean the cached content. False is returned if valid content is not found in the cache.
|
* @return string|boolean the cached content. False is returned if valid content is not found in the cache.
|
||||||
*/
|
*/
|
||||||
public function getCachedContent()
|
public function getCachedContent()
|
||||||
{
|
{
|
||||||
if ($this->_content === null) {
|
if ($this->_content === null) {
|
||||||
$this->_content = false;
|
$this->_content = false;
|
||||||
if ($this->cache instanceof Cache) {
|
if ($this->cache instanceof Cache) {
|
||||||
$key = $this->calculateKey();
|
$key = $this->calculateKey();
|
||||||
$data = $this->cache->get($key);
|
$data = $this->cache->get($key);
|
||||||
if (is_array($data) && count($data) === 2) {
|
if (is_array($data) && count($data) === 2) {
|
||||||
list ($content, $placeholders) = $data;
|
list ($content, $placeholders) = $data;
|
||||||
if (is_array($placeholders) && count($placeholders) > 0) {
|
if (is_array($placeholders) && count($placeholders) > 0) {
|
||||||
if (empty($this->view->cacheStack)) {
|
if (empty($this->view->cacheStack)) {
|
||||||
// outermost cache: replace placeholder with dynamic content
|
// outermost cache: replace placeholder with dynamic content
|
||||||
$content = $this->updateDynamicContent($content, $placeholders);
|
$content = $this->updateDynamicContent($content, $placeholders);
|
||||||
}
|
}
|
||||||
foreach ($placeholders as $name => $statements) {
|
foreach ($placeholders as $name => $statements) {
|
||||||
$this->view->addDynamicPlaceholder($name, $statements);
|
$this->view->addDynamicPlaceholder($name, $statements);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->_content = $content;
|
$this->_content = $content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->_content;
|
return $this->_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function updateDynamicContent($content, $placeholders)
|
protected function updateDynamicContent($content, $placeholders)
|
||||||
{
|
{
|
||||||
foreach ($placeholders as $name => $statements) {
|
foreach ($placeholders as $name => $statements) {
|
||||||
$placeholders[$name] = $this->view->evaluateDynamicContent($statements);
|
$placeholders[$name] = $this->view->evaluateDynamicContent($statements);
|
||||||
}
|
}
|
||||||
return strtr($content, $placeholders);
|
return strtr($content, $placeholders);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a unique key used for storing the content in cache.
|
* Generates a unique key used for storing the content in cache.
|
||||||
* The key generated depends on both [[id]] and [[variations]].
|
* The key generated depends on both [[id]] and [[variations]].
|
||||||
* @return mixed a valid cache key
|
* @return mixed a valid cache key
|
||||||
*/
|
*/
|
||||||
protected function calculateKey()
|
protected function calculateKey()
|
||||||
{
|
{
|
||||||
$factors = array(__CLASS__, $this->getId());
|
$factors = array(__CLASS__, $this->getId());
|
||||||
if (is_array($this->variations)) {
|
if (is_array($this->variations)) {
|
||||||
foreach ($this->variations as $factor) {
|
foreach ($this->variations as $factor) {
|
||||||
$factors[] = $factor;
|
$factors[] = $factor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $factors;
|
return $factors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,5 +91,4 @@ class ListPager extends Widget
|
|||||||
'{page}' => $page + 1,
|
'{page}' => $page + 1,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user