mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-17 14:57:23 +08:00
Merge branch 'master' of https://github.com/LAV45/yii2
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
return array(
|
return array(
|
||||||
'id' => 'hello',
|
'id' => 'hello',
|
||||||
'basePath' => dirname(__DIR__),
|
'basePath' => dirname(__DIR__),
|
||||||
|
'preload' => array('log'),
|
||||||
'components' => array(
|
'components' => array(
|
||||||
'cache' => array(
|
'cache' => array(
|
||||||
'class' => 'yii\caching\FileCache',
|
'class' => 'yii\caching\FileCache',
|
||||||
@@ -14,6 +15,15 @@ return array(
|
|||||||
'assetManager' => array(
|
'assetManager' => array(
|
||||||
'bundles' => require(__DIR__ . '/assets.php'),
|
'bundles' => require(__DIR__ . '/assets.php'),
|
||||||
),
|
),
|
||||||
|
'log' => array(
|
||||||
|
'class' => 'yii\logging\Router',
|
||||||
|
'targets' => array(
|
||||||
|
'file' => array(
|
||||||
|
'class' => 'yii\logging\FileTarget',
|
||||||
|
'levels' => array('error', 'warning'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
'params' => array(
|
'params' => array(
|
||||||
'adminEmail' => 'admin@example.com',
|
'adminEmail' => 'admin@example.com',
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\Menu;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var $this \yii\base\View
|
* @var $this \yii\base\View
|
||||||
* @var $content string
|
* @var $content string
|
||||||
*/
|
*/
|
||||||
use yii\helpers\Html;
|
|
||||||
$this->registerAssetBundle('app');
|
$this->registerAssetBundle('app');
|
||||||
?>
|
?>
|
||||||
<?php $this->beginPage(); ?>
|
<?php $this->beginPage(); ?>
|
||||||
@@ -23,7 +25,7 @@ $this->registerAssetBundle('app');
|
|||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<div class="navbar-inner">
|
<div class="navbar-inner">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<?php $this->widget('yii\widgets\Menu', array(
|
<?php $this->widget(Menu::className(), array(
|
||||||
'options' => array('class' => 'nav'),
|
'options' => array('class' => 'nav'),
|
||||||
'items' => array(
|
'items' => array(
|
||||||
array('label' => 'Home', 'url' => array('/site/index')),
|
array('label' => 'Home', 'url' => array('/site/index')),
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var yii\base\View $this
|
* @var yii\base\View $this
|
||||||
* @var yii\widgets\ActiveForm $form
|
* @var yii\widgets\ActiveForm $form
|
||||||
@@ -20,7 +22,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
If you have business inquiries or other questions, please fill out the following form to contact us. Thank you.
|
If you have business inquiries or other questions, please fill out the following form to contact us. Thank you.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<?php $form = $this->beginWidget('yii\widgets\ActiveForm', array(
|
<?php $form = $this->beginWidget(ActiveForm::className(), array(
|
||||||
'options' => array('class' => 'form-horizontal'),
|
'options' => array('class' => 'form-horizontal'),
|
||||||
'fieldConfig' => array('inputOptions' => array('class' => 'input-xlarge')),
|
'fieldConfig' => array('inputOptions' => array('class' => 'input-xlarge')),
|
||||||
)); ?>
|
)); ?>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var yii\base\View $this
|
* @var yii\base\View $this
|
||||||
* @var yii\widgets\ActiveForm $form
|
* @var yii\widgets\ActiveForm $form
|
||||||
@@ -12,7 +14,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
|
|
||||||
<p>Please fill out the following fields to login:</p>
|
<p>Please fill out the following fields to login:</p>
|
||||||
|
|
||||||
<?php $form = $this->beginWidget('yii\widgets\ActiveForm', array('options' => array('class' => 'form-horizontal'))); ?>
|
<?php $form = $this->beginWidget(ActiveForm::className(), array('options' => array('class' => 'form-horizontal'))); ?>
|
||||||
<?php echo $form->field($model, 'username')->textInput(); ?>
|
<?php echo $form->field($model, 'username')->textInput(); ?>
|
||||||
<?php echo $form->field($model, 'password')->passwordInput(); ?>
|
<?php echo $form->field($model, 'password')->passwordInput(); ?>
|
||||||
<?php echo $form->field($model, 'rememberMe')->checkbox(); ?>
|
<?php echo $form->field($model, 'rememberMe')->checkbox(); ?>
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
namespace yii\base;
|
namespace yii\base;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\helpers\FileHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application is the base class for all application classes.
|
* Application is the base class for all application classes.
|
||||||
|
|||||||
@@ -14,6 +14,14 @@ namespace yii\base;
|
|||||||
*/
|
*/
|
||||||
class Object
|
class Object
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @return string the fully qualified name of this class.
|
||||||
|
*/
|
||||||
|
public static function className()
|
||||||
|
{
|
||||||
|
return get_called_class();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* The default implementation does two things:
|
* The default implementation does two things:
|
||||||
|
|||||||
@@ -36,10 +36,12 @@ class Controller extends \yii\base\Controller
|
|||||||
public $interactive = true;
|
public $interactive = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool whether to enable ANSI style in output. If not set it will be auto detected.
|
* @var bool whether to enable ANSI style in output.
|
||||||
* Default is disabled on Windows systems and enabled on linux.
|
* Setting this will affect [[ansiFormat()]], [[stdout()]] and [[stderr()]].
|
||||||
|
* If not set it will be auto detected using [[yii\helpers\Console::streamSupportsAnsiColors()]] with STDOUT
|
||||||
|
* for [[ansiFormat()]] and [[stdout()]] and STDERR for [[stderr()]].
|
||||||
*/
|
*/
|
||||||
public $ansi;
|
public $colors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs an action with the specified action ID and parameters.
|
* Runs an action with the specified action ID and parameters.
|
||||||
@@ -128,13 +130,13 @@ class Controller extends \yii\base\Controller
|
|||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* ~~~
|
* ~~~
|
||||||
* $this->formatString('This will be red and underlined.', Console::FG_RED, Console::UNDERLINE);
|
* $this->ansiFormat('This will be red and underlined.', Console::FG_RED, Console::UNDERLINE);
|
||||||
* ~~~
|
* ~~~
|
||||||
*
|
*
|
||||||
* @param string $string the string to be formatted
|
* @param string $string the string to be formatted
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function formatString($string)
|
public function ansiFormat($string)
|
||||||
{
|
{
|
||||||
if ($this->ansi === true || $this->ansi === null && Console::streamSupportsAnsiColors(STDOUT)) {
|
if ($this->ansi === true || $this->ansi === null && Console::streamSupportsAnsiColors(STDOUT)) {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
@@ -192,47 +194,6 @@ class Controller extends \yii\base\Controller
|
|||||||
return fwrite(STDERR, $string);
|
return fwrite(STDERR, $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Asks the user for input. Ends when the user types a carriage return (PHP_EOL). Optionally, It also provides a
|
|
||||||
* prompt.
|
|
||||||
*
|
|
||||||
* @param string $prompt the prompt (optional)
|
|
||||||
* @return string the user's input
|
|
||||||
*/
|
|
||||||
public function input($prompt = null)
|
|
||||||
{
|
|
||||||
if (isset($prompt)) {
|
|
||||||
static::stdout($prompt);
|
|
||||||
}
|
|
||||||
return static::stdin();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints text to STDOUT appended with a carriage return (PHP_EOL).
|
|
||||||
*
|
|
||||||
* @param string $text
|
|
||||||
* @param bool $raw
|
|
||||||
*
|
|
||||||
* @return mixed Number of bytes printed or bool false on error
|
|
||||||
*/
|
|
||||||
public function output($text = null)
|
|
||||||
{
|
|
||||||
return static::stdout($text . PHP_EOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints text to STDERR appended with a carriage return (PHP_EOL).
|
|
||||||
*
|
|
||||||
* @param string $text
|
|
||||||
* @param bool $raw
|
|
||||||
*
|
|
||||||
* @return mixed Number of bytes printed or false on error
|
|
||||||
*/
|
|
||||||
public function error($text = null)
|
|
||||||
{
|
|
||||||
return static::stderr($text . PHP_EOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prompts the user for input and validates it
|
* Prompts the user for input and validates it
|
||||||
*
|
*
|
||||||
@@ -248,7 +209,11 @@ class Controller extends \yii\base\Controller
|
|||||||
*/
|
*/
|
||||||
public function prompt($text, $options = array())
|
public function prompt($text, $options = array())
|
||||||
{
|
{
|
||||||
|
if ($this->interactive) {
|
||||||
return Console::prompt($text, $options);
|
return Console::prompt($text, $options);
|
||||||
|
} else {
|
||||||
|
return isset($options['default']) ? $options['default'] : '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -276,7 +241,7 @@ class Controller extends \yii\base\Controller
|
|||||||
*
|
*
|
||||||
* @return string An option character the user chose
|
* @return string An option character the user chose
|
||||||
*/
|
*/
|
||||||
public static function select($prompt, $options = array())
|
public function select($prompt, $options = array())
|
||||||
{
|
{
|
||||||
return Console::select($prompt, $options);
|
return Console::select($prompt, $options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace yii\logging;
|
namespace yii\logging;
|
||||||
use yii\base\InvalidConfigException;
|
|
||||||
|
use \yii\base\Component;
|
||||||
|
use \yii\base\InvalidConfigException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger records logged messages in memory.
|
* Logger records logged messages in memory.
|
||||||
@@ -17,7 +19,7 @@ use yii\base\InvalidConfigException;
|
|||||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
class Logger extends \yii\base\Component
|
class Logger extends Component
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Error message level. An error message is one that indicates the abnormal termination of the
|
* Error message level. An error message is one that indicates the abnormal termination of the
|
||||||
|
|||||||
@@ -28,16 +28,16 @@ use yii\base\Application;
|
|||||||
* 'preload' => array('log'),
|
* 'preload' => array('log'),
|
||||||
* 'components' => array(
|
* 'components' => array(
|
||||||
* 'log' => array(
|
* 'log' => array(
|
||||||
* 'class' => '\yii\logging\Router',
|
* 'class' => 'yii\logging\Router',
|
||||||
* 'targets' => array(
|
* 'targets' => array(
|
||||||
* 'file' => array(
|
* 'file' => array(
|
||||||
* 'class' => '\yii\logging\FileTarget',
|
* 'class' => 'yii\logging\FileTarget',
|
||||||
* 'levels' => 'trace, info',
|
* 'levels' => array('trace', 'info'),
|
||||||
* 'categories' => 'yii\*',
|
* 'categories' => array('yii\*'),
|
||||||
* ),
|
* ),
|
||||||
* 'email' => array(
|
* 'email' => array(
|
||||||
* 'class' => '\yii\logging\EmailTarget',
|
* 'class' => 'yii\logging\EmailTarget',
|
||||||
* 'levels' => 'error, warning',
|
* 'levels' => array('error', 'warning'),
|
||||||
* 'emails' => array('admin@example.com'),
|
* 'emails' => array('admin@example.com'),
|
||||||
* ),
|
* ),
|
||||||
* ),
|
* ),
|
||||||
@@ -73,7 +73,6 @@ class Router extends Component
|
|||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
|
|
||||||
foreach ($this->targets as $name => $target) {
|
foreach ($this->targets as $name => $target) {
|
||||||
if (!$target instanceof Target) {
|
if (!$target instanceof Target) {
|
||||||
$this->targets[$name] = Yii::createObject($target);
|
$this->targets[$name] = Yii::createObject($target);
|
||||||
|
|||||||
@@ -71,13 +71,13 @@ class DbSession extends Session
|
|||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
parent::init();
|
|
||||||
if (is_string($this->db)) {
|
if (is_string($this->db)) {
|
||||||
$this->db = Yii::$app->getComponent($this->db);
|
$this->db = Yii::$app->getComponent($this->db);
|
||||||
}
|
}
|
||||||
if (!$this->db instanceof Connection) {
|
if (!$this->db instanceof Connection) {
|
||||||
throw new InvalidConfigException("DbSession::db must be either a DB connection instance or the application component ID of a DB connection.");
|
throw new InvalidConfigException("DbSession::db must be either a DB connection instance or the application component ID of a DB connection.");
|
||||||
}
|
}
|
||||||
|
parent::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user