├── CONTRIBUTING.md
├── LICENSE.md
├── README.md
├── composer.json
├── composer.lock
└── framework
├── .gitignore
├── .htaccess
├── BaseYii.php
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── UPGRADE.md
├── Yii.php
├── assets
├── yii.activeForm.js
├── yii.captcha.js
├── yii.gridView.js
├── yii.js
└── yii.validation.js
├── base
├── Action.php
├── ActionEvent.php
├── ActionFilter.php
├── Application.php
├── ArrayAccessTrait.php
├── Arrayable.php
├── ArrayableTrait.php
├── Behavior.php
├── BootstrapInterface.php
├── Component.php
├── Configurable.php
├── Controller.php
├── DynamicModel.php
├── ErrorException.php
├── ErrorHandler.php
├── Event.php
├── Exception.php
├── ExitException.php
├── InlineAction.php
├── InvalidCallException.php
├── InvalidConfigException.php
├── InvalidParamException.php
├── InvalidRouteException.php
├── InvalidValueException.php
├── Model.php
├── ModelEvent.php
├── Module.php
├── NotSupportedException.php
├── Object.php
├── Request.php
├── Response.php
├── Security.php
├── Theme.php
├── UnknownClassException.php
├── UnknownMethodException.php
├── UnknownPropertyException.php
├── UserException.php
├── View.php
├── ViewContextInterface.php
├── ViewEvent.php
├── ViewRenderer.php
└── Widget.php
├── behaviors
├── AttributeBehavior.php
├── BlameableBehavior.php
├── SluggableBehavior.php
└── TimestampBehavior.php
├── caching
├── ApcCache.php
├── ArrayCache.php
├── Cache.php
├── ChainedDependency.php
├── DbCache.php
├── DbDependency.php
├── Dependency.php
├── DummyCache.php
├── ExpressionDependency.php
├── FileCache.php
├── FileDependency.php
├── MemCache.php
├── MemCacheServer.php
├── TagDependency.php
├── WinCache.php
├── XCache.php
├── ZendDataCache.php
└── migrations
│ ├── m150909_153426_cache_init.php
│ ├── schema-mssql.sql
│ ├── schema-mysql.sql
│ ├── schema-oci.sql
│ ├── schema-pgsql.sql
│ └── schema-sqlite.sql
├── captcha
├── Captcha.php
├── CaptchaAction.php
├── CaptchaAsset.php
├── CaptchaValidator.php
├── SpicyRice.md
└── SpicyRice.ttf
├── classes.php
├── composer.json
├── console
├── Application.php
├── Controller.php
├── ErrorHandler.php
├── Exception.php
├── Markdown.php
├── Request.php
├── Response.php
├── controllers
│ ├── AssetController.php
│ ├── BaseMigrateController.php
│ ├── CacheController.php
│ ├── FixtureController.php
│ ├── HelpController.php
│ ├── MessageController.php
│ ├── MigrateController.php
│ └── ServeController.php
└── runtime
│ └── .gitignore
├── data
├── ActiveDataProvider.php
├── ArrayDataProvider.php
├── BaseDataProvider.php
├── DataProviderInterface.php
├── Pagination.php
├── Sort.php
└── SqlDataProvider.php
├── db
├── ActiveQuery.php
├── ActiveQueryInterface.php
├── ActiveQueryTrait.php
├── ActiveRecord.php
├── ActiveRecordInterface.php
├── ActiveRelationTrait.php
├── AfterSaveEvent.php
├── BaseActiveRecord.php
├── BatchQueryResult.php
├── ColumnSchema.php
├── ColumnSchemaBuilder.php
├── Command.php
├── Connection.php
├── DataReader.php
├── Exception.php
├── Expression.php
├── IntegrityException.php
├── Migration.php
├── MigrationInterface.php
├── Query.php
├── QueryBuilder.php
├── QueryInterface.php
├── QueryTrait.php
├── Schema.php
├── SchemaBuilderTrait.php
├── StaleObjectException.php
├── TableSchema.php
├── Transaction.php
├── cubrid
│ ├── QueryBuilder.php
│ └── Schema.php
├── mssql
│ ├── PDO.php
│ ├── QueryBuilder.php
│ ├── Schema.php
│ ├── SqlsrvPDO.php
│ └── TableSchema.php
├── mysql
│ ├── QueryBuilder.php
│ └── Schema.php
├── oci
│ ├── ColumnSchemaBuilder.php
│ ├── QueryBuilder.php
│ └── Schema.php
├── pgsql
│ ├── QueryBuilder.php
│ └── Schema.php
└── sqlite
│ ├── QueryBuilder.php
│ └── Schema.php
├── di
├── Container.php
├── Instance.php
└── ServiceLocator.php
├── filters
├── AccessControl.php
├── AccessRule.php
├── ContentNegotiator.php
├── Cors.php
├── HttpCache.php
├── PageCache.php
├── RateLimitInterface.php
├── RateLimiter.php
├── VerbFilter.php
└── auth
│ ├── AuthInterface.php
│ ├── AuthMethod.php
│ ├── CompositeAuth.php
│ ├── HttpBasicAuth.php
│ ├── HttpBearerAuth.php
│ └── QueryParamAuth.php
├── grid
├── ActionColumn.php
├── CheckboxColumn.php
├── Column.php
├── DataColumn.php
├── GridView.php
├── GridViewAsset.php
└── SerialColumn.php
├── helpers
├── ArrayHelper.php
├── BaseArrayHelper.php
├── BaseConsole.php
├── BaseFileHelper.php
├── BaseFormatConverter.php
├── BaseHtml.php
├── BaseHtmlPurifier.php
├── BaseInflector.php
├── BaseJson.php
├── BaseMarkdown.php
├── BaseStringHelper.php
├── BaseUrl.php
├── BaseVarDumper.php
├── Console.php
├── FileHelper.php
├── FormatConverter.php
├── Html.php
├── HtmlPurifier.php
├── Inflector.php
├── Json.php
├── Markdown.php
├── StringHelper.php
├── Url.php
├── VarDumper.php
└── mimeTypes.php
├── i18n
├── DbMessageSource.php
├── Formatter.php
├── GettextFile.php
├── GettextMessageSource.php
├── GettextMoFile.php
├── GettextPoFile.php
├── I18N.php
├── MessageFormatter.php
├── MessageSource.php
├── MissingTranslationEvent.php
└── PhpMessageSource.php
├── log
├── DbTarget.php
├── Dispatcher.php
├── EmailTarget.php
├── FileTarget.php
├── Logger.php
├── SyslogTarget.php
├── Target.php
└── migrations
│ ├── m141106_185632_log_init.php
│ ├── schema-mssql.sql
│ ├── schema-mysql.sql
│ ├── schema-oci.sql
│ ├── schema-pgsql.sql
│ └── schema-sqlite.sql
├── mail
├── BaseMailer.php
├── BaseMessage.php
├── MailEvent.php
├── MailerInterface.php
└── MessageInterface.php
├── messages
├── ar
│ └── yii.php
├── az
│ └── yii.php
├── bg
│ └── yii.php
├── bs
│ └── yii.php
├── ca
│ └── yii.php
├── config.php
├── cs
│ └── yii.php
├── da
│ └── yii.php
├── de
│ └── yii.php
├── el
│ └── yii.php
├── es
│ └── yii.php
├── et
│ └── yii.php
├── fa
│ └── yii.php
├── fi
│ └── yii.php
├── fr
│ └── yii.php
├── he
│ └── yii.php
├── hr
│ └── yii.php
├── hu
│ └── yii.php
├── id
│ └── yii.php
├── it
│ └── yii.php
├── ja
│ └── yii.php
├── ka
│ └── yii.php
├── kk
│ └── yii.php
├── ko
│ └── yii.php
├── lt
│ └── yii.php
├── lv
│ └── yii.php
├── ms
│ └── yii.php
├── nb-NO
│ └── yii.php
├── nl
│ └── yii.php
├── pl
│ └── yii.php
├── pt-BR
│ └── yii.php
├── pt
│ └── yii.php
├── ro
│ └── yii.php
├── ru
│ └── yii.php
├── sk
│ └── yii.php
├── sl
│ └── yii.php
├── sr-Latn
│ └── yii.php
├── sr
│ └── yii.php
├── sv
│ └── yii.php
├── th
│ └── yii.php
├── tj
│ └── yii.php
├── tr
│ └── yii.php
├── uk
│ └── yii.php
├── uz
│ └── yii.php
├── vi
│ └── yii.php
├── zh-CN
│ └── yii.php
└── zh-TW
│ └── yii.php
├── mutex
├── DbMutex.php
├── FileMutex.php
├── Mutex.php
└── MysqlMutex.php
├── rbac
├── Assignment.php
├── BaseManager.php
├── DbManager.php
├── Item.php
├── ManagerInterface.php
├── Permission.php
├── PhpManager.php
├── Role.php
├── Rule.php
└── migrations
│ ├── m140506_102106_rbac_init.php
│ ├── schema-mssql.sql
│ ├── schema-mysql.sql
│ ├── schema-oci.sql
│ ├── schema-pgsql.sql
│ └── schema-sqlite.sql
├── requirements
├── YiiRequirementChecker.php
├── requirements.php
└── views
│ ├── console
│ └── index.php
│ └── web
│ ├── css.php
│ └── index.php
├── rest
├── Action.php
├── ActiveController.php
├── Controller.php
├── CreateAction.php
├── DeleteAction.php
├── IndexAction.php
├── OptionsAction.php
├── Serializer.php
├── UpdateAction.php
├── UrlRule.php
└── ViewAction.php
├── test
├── ActiveFixture.php
├── ArrayFixture.php
├── BaseActiveFixture.php
├── DbFixture.php
├── Fixture.php
├── FixtureTrait.php
└── InitDbFixture.php
├── validators
├── BooleanValidator.php
├── CompareValidator.php
├── DateValidator.php
├── DefaultValueValidator.php
├── EachValidator.php
├── EmailValidator.php
├── ExistValidator.php
├── FileValidator.php
├── FilterValidator.php
├── ImageValidator.php
├── InlineValidator.php
├── IpValidator.php
├── NumberValidator.php
├── PunycodeAsset.php
├── RangeValidator.php
├── RegularExpressionValidator.php
├── RequiredValidator.php
├── SafeValidator.php
├── StringValidator.php
├── UniqueValidator.php
├── UrlValidator.php
├── ValidationAsset.php
└── Validator.php
├── views
├── addColumnMigration.php
├── createJunctionMigration.php
├── createTableMigration.php
├── dropColumnMigration.php
├── dropTableMigration.php
├── errorHandler
│ ├── callStackItem.php
│ ├── error.php
│ ├── exception.php
│ └── previousException.php
├── messageConfig.php
└── migration.php
├── web
├── Application.php
├── AssetBundle.php
├── AssetConverter.php
├── AssetConverterInterface.php
├── AssetManager.php
├── BadRequestHttpException.php
├── CacheSession.php
├── CompositeUrlRule.php
├── ConflictHttpException.php
├── Controller.php
├── Cookie.php
├── CookieCollection.php
├── DbSession.php
├── ErrorAction.php
├── ErrorHandler.php
├── ForbiddenHttpException.php
├── GoneHttpException.php
├── GroupUrlRule.php
├── HeaderCollection.php
├── HtmlResponseFormatter.php
├── HttpException.php
├── IdentityInterface.php
├── JqueryAsset.php
├── JsExpression.php
├── JsonParser.php
├── JsonResponseFormatter.php
├── Link.php
├── Linkable.php
├── MethodNotAllowedHttpException.php
├── MultiFieldSession.php
├── NotAcceptableHttpException.php
├── NotFoundHttpException.php
├── Request.php
├── RequestParserInterface.php
├── Response.php
├── ResponseFormatterInterface.php
├── ServerErrorHttpException.php
├── Session.php
├── SessionIterator.php
├── TooManyRequestsHttpException.php
├── UnauthorizedHttpException.php
├── UnprocessableEntityHttpException.php
├── UnsupportedMediaTypeHttpException.php
├── UploadedFile.php
├── UrlManager.php
├── UrlRule.php
├── UrlRuleInterface.php
├── User.php
├── UserEvent.php
├── View.php
├── ViewAction.php
├── XmlResponseFormatter.php
└── YiiAsset.php
├── widgets
├── ActiveField.php
├── ActiveForm.php
├── ActiveFormAsset.php
├── BaseListView.php
├── Block.php
├── Breadcrumbs.php
├── ContentDecorator.php
├── DetailView.php
├── FragmentCache.php
├── InputWidget.php
├── LinkPager.php
├── LinkSorter.php
├── ListView.php
├── MaskedInput.php
├── MaskedInputAsset.php
├── Menu.php
├── Pjax.php
├── PjaxAsset.php
└── Spaceless.php
├── yii
└── yii.bat
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contributing to Yii2
2 | ====================
3 |
4 | - [Report an issue](docs/internals/report-an-issue.md)
5 | - [Translate documentation or messages](docs/internals/translation-workflow.md)
6 | - [Give us feedback or start a design discussion](http://www.yiiframework.com/forum/index.php/forum/42-general-discussions-for-yii-20/)
7 | - [Contribute to the core code or fix bugs](docs/internals/git-workflow.md)
8 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The Yii framework is free software. It is released under the terms of
2 | the following BSD License.
3 |
4 | Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | * Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 | * Redistributions in binary form must reproduce the above copyright
14 | notice, this list of conditions and the following disclaimer in
15 | the documentation and/or other materials provided with the
16 | distribution.
17 | * Neither the name of Yii Software LLC nor the names of its
18 | contributors may be used to endorse or promote products derived
19 | from this software without specific prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | POSSIBILITY OF SUCH DAMAGE.
33 |
--------------------------------------------------------------------------------
/framework/.gitignore:
--------------------------------------------------------------------------------
1 | phpunit.xml
2 | composer.lock
3 |
4 |
--------------------------------------------------------------------------------
/framework/.htaccess:
--------------------------------------------------------------------------------
1 | deny from all
2 |
--------------------------------------------------------------------------------
/framework/LICENSE.md:
--------------------------------------------------------------------------------
1 | The Yii framework is free software. It is released under the terms of
2 | the following BSD License.
3 |
4 | Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | * Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 | * Redistributions in binary form must reproduce the above copyright
14 | notice, this list of conditions and the following disclaimer in
15 | the documentation and/or other materials provided with the
16 | distribution.
17 | * Neither the name of Yii Software LLC nor the names of its
18 | contributors may be used to endorse or promote products derived
19 | from this software without specific prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | POSSIBILITY OF SUCH DAMAGE.
33 |
--------------------------------------------------------------------------------
/framework/README.md:
--------------------------------------------------------------------------------
1 | Yii PHP Framework Version 2
2 | ===========================
3 |
4 | This is the core framework code of [Yii 2](https://github.com/yiisoft/yii2#readme).
5 |
6 | This repository is a read-only git subsplit of .
7 | Please submit issue reports and pull requests to the main repository.
8 | For license information check the [LICENSE](LICENSE.md)-file.
9 |
10 | Installation
11 | ------------
12 |
13 | The preferred way to install the Yii framework is through [composer](http://getcomposer.org/download/).
14 |
15 | Either run
16 |
17 | ```
18 | composer global require "fxp/composer-asset-plugin:~1.1.1"
19 | composer require yiisoft/yii2
20 | ```
21 |
22 | or add
23 |
24 | ```json
25 | "yiisoft/yii2": "~2.0.0",
26 | ```
27 |
28 | to the require section of your composer.json.
29 |
--------------------------------------------------------------------------------
/framework/Yii.php:
--------------------------------------------------------------------------------
1 |
19 | * @since 2.0
20 | */
21 | class Yii extends \yii\BaseYii
22 | {
23 | }
24 |
25 | spl_autoload_register(['Yii', 'autoload'], true, true);
26 | Yii::$classMap = require(__DIR__ . '/classes.php');
27 | Yii::$container = new yii\di\Container();
28 |
--------------------------------------------------------------------------------
/framework/assets/yii.captcha.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Yii Captcha widget.
3 | *
4 | * This is the JavaScript widget used by the yii\captcha\Captcha widget.
5 | *
6 | * @link http://www.yiiframework.com/
7 | * @copyright Copyright (c) 2008 Yii Software LLC
8 | * @license http://www.yiiframework.com/license/
9 | * @author Qiang Xue
10 | * @since 2.0
11 | */
12 | (function ($) {
13 | $.fn.yiiCaptcha = function (method) {
14 | if (methods[method]) {
15 | return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
16 | } else if (typeof method === 'object' || !method) {
17 | return methods.init.apply(this, arguments);
18 | } else {
19 | $.error('Method ' + method + ' does not exist on jQuery.yiiCaptcha');
20 | return false;
21 | }
22 | };
23 |
24 | var defaults = {
25 | refreshUrl: undefined,
26 | hashKey: undefined
27 | };
28 |
29 | var methods = {
30 | init: function (options) {
31 | return this.each(function () {
32 | var $e = $(this);
33 | var settings = $.extend({}, defaults, options || {});
34 | $e.data('yiiCaptcha', {
35 | settings: settings
36 | });
37 |
38 | $e.on('click.yiiCaptcha', function () {
39 | methods.refresh.apply($e);
40 | return false;
41 | });
42 |
43 | });
44 | },
45 |
46 | refresh: function () {
47 | var $e = this,
48 | settings = this.data('yiiCaptcha').settings;
49 | $.ajax({
50 | url: $e.data('yiiCaptcha').settings.refreshUrl,
51 | dataType: 'json',
52 | cache: false,
53 | success: function (data) {
54 | $e.attr('src', data.url);
55 | $('body').data(settings.hashKey, [data.hash1, data.hash2]);
56 | }
57 | });
58 | },
59 |
60 | destroy: function () {
61 | return this.each(function () {
62 | $(window).unbind('.yiiCaptcha');
63 | $(this).removeData('yiiCaptcha');
64 | });
65 | },
66 |
67 | data: function () {
68 | return this.data('yiiCaptcha');
69 | }
70 | };
71 | })(window.jQuery);
72 |
73 |
--------------------------------------------------------------------------------
/framework/base/ActionEvent.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | class ActionEvent extends Event
19 | {
20 | /**
21 | * @var Action the action currently being executed
22 | */
23 | public $action;
24 | /**
25 | * @var mixed the action result. Event handlers may modify this property to change the action result.
26 | */
27 | public $result;
28 | /**
29 | * @var boolean whether to continue running the action. Event handlers of
30 | * [[Controller::EVENT_BEFORE_ACTION]] may set this property to decide whether
31 | * to continue running the current action.
32 | */
33 | public $isValid = true;
34 |
35 |
36 | /**
37 | * Constructor.
38 | * @param Action $action the action associated with this action event.
39 | * @param array $config name-value pairs that will be used to initialize the object properties
40 | */
41 | public function __construct($action, $config = [])
42 | {
43 | $this->action = $action;
44 | parent::__construct($config);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/framework/base/ArrayAccessTrait.php:
--------------------------------------------------------------------------------
1 |
19 | * @since 2.0
20 | */
21 | trait ArrayAccessTrait
22 | {
23 | /**
24 | * Returns an iterator for traversing the data.
25 | * This method is required by the SPL interface [[\IteratorAggregate]].
26 | * It will be implicitly called when you use `foreach` to traverse the collection.
27 | * @return \ArrayIterator an iterator for traversing the cookies in the collection.
28 | */
29 | public function getIterator()
30 | {
31 | return new \ArrayIterator($this->data);
32 | }
33 |
34 | /**
35 | * Returns the number of data items.
36 | * This method is required by Countable interface.
37 | * @return integer number of data elements.
38 | */
39 | public function count()
40 | {
41 | return count($this->data);
42 | }
43 |
44 | /**
45 | * This method is required by the interface [[\ArrayAccess]].
46 | * @param mixed $offset the offset to check on
47 | * @return boolean
48 | */
49 | public function offsetExists($offset)
50 | {
51 | return isset($this->data[$offset]);
52 | }
53 |
54 | /**
55 | * This method is required by the interface [[\ArrayAccess]].
56 | * @param integer $offset the offset to retrieve element.
57 | * @return mixed the element at the offset, null if no element is found at the offset
58 | */
59 | public function offsetGet($offset)
60 | {
61 | return isset($this->data[$offset]) ? $this->data[$offset] : null;
62 | }
63 |
64 | /**
65 | * This method is required by the interface [[\ArrayAccess]].
66 | * @param integer $offset the offset to set element
67 | * @param mixed $item the element value
68 | */
69 | public function offsetSet($offset, $item)
70 | {
71 | $this->data[$offset] = $item;
72 | }
73 |
74 | /**
75 | * This method is required by the interface [[\ArrayAccess]].
76 | * @param mixed $offset the offset to unset element
77 | */
78 | public function offsetUnset($offset)
79 | {
80 | unset($this->data[$offset]);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/framework/base/BootstrapInterface.php:
--------------------------------------------------------------------------------
1 | [
38 | * "path\\to\\MyBootstrapClass1",
39 | * [
40 | * 'class' => "path\\to\\MyBootstrapClass2",
41 | * 'prop1' => 'value1',
42 | * 'prop2' => 'value2',
43 | * ],
44 | * ],
45 | * ];
46 | * ```
47 | *
48 | * As you can see, you can register a bootstrapping class in terms of either a class name or a configuration class.
49 | *
50 | * @author Qiang Xue
51 | * @since 2.0
52 | */
53 | interface BootstrapInterface
54 | {
55 | /**
56 | * Bootstrap method to be called during application bootstrap stage.
57 | * @param Application $app the application currently running
58 | */
59 | public function bootstrap($app);
60 | }
61 |
--------------------------------------------------------------------------------
/framework/base/Configurable.php:
--------------------------------------------------------------------------------
1 |
27 | * @since 2.0.3
28 | */
29 | interface Configurable
30 | {
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/framework/base/Exception.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class Exception extends \Exception
17 | {
18 | /**
19 | * @return string the user-friendly name of this exception
20 | */
21 | public function getName()
22 | {
23 | return 'Exception';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/framework/base/ExitException.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | class ExitException extends \Exception
19 | {
20 | /**
21 | * @var integer the exit status code
22 | */
23 | public $statusCode;
24 |
25 |
26 | /**
27 | * Constructor.
28 | * @param integer $status the exit status code
29 | * @param string $message error message
30 | * @param integer $code error code
31 | * @param \Exception $previous The previous exception used for the exception chaining.
32 | */
33 | public function __construct($status = 0, $message = null, $code = 0, \Exception $previous = null)
34 | {
35 | $this->statusCode = $status;
36 | parent::__construct($message, $code, $previous);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/framework/base/InlineAction.php:
--------------------------------------------------------------------------------
1 |
19 | * @since 2.0
20 | */
21 | class InlineAction extends Action
22 | {
23 | /**
24 | * @var string the controller method that this inline action is associated with
25 | */
26 | public $actionMethod;
27 |
28 |
29 | /**
30 | * @param string $id the ID of this action
31 | * @param Controller $controller the controller that owns this action
32 | * @param string $actionMethod the controller method that this inline action is associated with
33 | * @param array $config name-value pairs that will be used to initialize the object properties
34 | */
35 | public function __construct($id, $controller, $actionMethod, $config = [])
36 | {
37 | $this->actionMethod = $actionMethod;
38 | parent::__construct($id, $controller, $config);
39 | }
40 |
41 | /**
42 | * Runs this action with the specified parameters.
43 | * This method is mainly invoked by the controller.
44 | * @param array $params action parameters
45 | * @return mixed the result of the action
46 | */
47 | public function runWithParams($params)
48 | {
49 | $args = $this->controller->bindActionParams($this, $params);
50 | Yii::trace('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__);
51 | if (Yii::$app->requestedParams === null) {
52 | Yii::$app->requestedParams = $args;
53 | }
54 |
55 | return call_user_func_array([$this->controller, $this->actionMethod], $args);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/framework/base/InvalidCallException.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class InvalidCallException extends \BadMethodCallException
17 | {
18 | /**
19 | * @return string the user-friendly name of this exception
20 | */
21 | public function getName()
22 | {
23 | return 'Invalid Call';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/framework/base/InvalidConfigException.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class InvalidConfigException extends Exception
17 | {
18 | /**
19 | * @return string the user-friendly name of this exception
20 | */
21 | public function getName()
22 | {
23 | return 'Invalid Configuration';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/framework/base/InvalidParamException.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class InvalidParamException extends \BadMethodCallException
17 | {
18 | /**
19 | * @return string the user-friendly name of this exception
20 | */
21 | public function getName()
22 | {
23 | return 'Invalid Parameter';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/framework/base/InvalidRouteException.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class InvalidRouteException extends UserException
17 | {
18 | /**
19 | * @return string the user-friendly name of this exception
20 | */
21 | public function getName()
22 | {
23 | return 'Invalid Route';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/framework/base/InvalidValueException.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class InvalidValueException extends \UnexpectedValueException
17 | {
18 | /**
19 | * @return string the user-friendly name of this exception
20 | */
21 | public function getName()
22 | {
23 | return 'Invalid Return Value';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/framework/base/ModelEvent.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class ModelEvent extends Event
17 | {
18 | /**
19 | * @var boolean whether the model is in valid status. Defaults to true.
20 | * A model is in valid status if it passes validations or certain checks.
21 | */
22 | public $isValid = true;
23 | }
24 |
--------------------------------------------------------------------------------
/framework/base/NotSupportedException.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class NotSupportedException extends Exception
17 | {
18 | /**
19 | * @return string the user-friendly name of this exception
20 | */
21 | public function getName()
22 | {
23 | return 'Not Supported';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/framework/base/Response.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class Response extends Component
17 | {
18 | /**
19 | * @var integer the exit status. Exit statuses should be in the range 0 to 254.
20 | * The status 0 means the program terminates successfully.
21 | */
22 | public $exitStatus = 0;
23 |
24 |
25 | /**
26 | * Sends the response to client.
27 | */
28 | public function send()
29 | {
30 | }
31 |
32 | /**
33 | * Removes all existing output buffers.
34 | */
35 | public function clearOutputBuffers()
36 | {
37 | // the following manual level counting is to deal with zlib.output_compression set to On
38 | for ($level = ob_get_level(); $level > 0; --$level) {
39 | if (!@ob_end_clean()) {
40 | ob_clean();
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/framework/base/UnknownClassException.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class UnknownClassException extends Exception
17 | {
18 | /**
19 | * @return string the user-friendly name of this exception
20 | */
21 | public function getName()
22 | {
23 | return 'Unknown Class';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/framework/base/UnknownMethodException.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class UnknownMethodException extends \BadMethodCallException
17 | {
18 | /**
19 | * @return string the user-friendly name of this exception
20 | */
21 | public function getName()
22 | {
23 | return 'Unknown Method';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/framework/base/UnknownPropertyException.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class UnknownPropertyException extends Exception
17 | {
18 | /**
19 | * @return string the user-friendly name of this exception
20 | */
21 | public function getName()
22 | {
23 | return 'Unknown Property';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/framework/base/UserException.php:
--------------------------------------------------------------------------------
1 |
15 | * @since 2.0
16 | */
17 | class UserException extends Exception
18 | {
19 | }
20 |
--------------------------------------------------------------------------------
/framework/base/ViewContextInterface.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | interface ViewContextInterface
19 | {
20 | /**
21 | * @return string the view path that may be prefixed to a relative view name.
22 | */
23 | public function getViewPath();
24 | }
25 |
--------------------------------------------------------------------------------
/framework/base/ViewEvent.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class ViewEvent extends Event
17 | {
18 | /**
19 | * @var string the view file being rendered.
20 | */
21 | public $viewFile;
22 | /**
23 | * @var array the parameter array passed to the [[View::render()]] method.
24 | */
25 | public $params;
26 | /**
27 | * @var string the rendering result of [[View::renderFile()]].
28 | * Event handlers may modify this property and the modified output will be
29 | * returned by [[View::renderFile()]]. This property is only used
30 | * by [[View::EVENT_AFTER_RENDER]] event.
31 | */
32 | public $output;
33 | /**
34 | * @var boolean whether to continue rendering the view file. Event handlers of
35 | * [[View::EVENT_BEFORE_RENDER]] may set this property to decide whether
36 | * to continue rendering the current view file.
37 | */
38 | public $isValid = true;
39 | }
40 |
--------------------------------------------------------------------------------
/framework/base/ViewRenderer.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | abstract class ViewRenderer extends Component
17 | {
18 | /**
19 | * Renders a view file.
20 | *
21 | * This method is invoked by [[View]] whenever it tries to render a view.
22 | * Child classes must implement this method to render the given view file.
23 | *
24 | * @param View $view the view object used for rendering the file.
25 | * @param string $file the view file.
26 | * @param array $params the parameters to be passed to the view file.
27 | * @return string the rendering result
28 | */
29 | abstract public function render($view, $file, $params);
30 | }
31 |
--------------------------------------------------------------------------------
/framework/caching/ArrayCache.php:
--------------------------------------------------------------------------------
1 |
19 | * @since 2.0
20 | */
21 | class ArrayCache extends Cache
22 | {
23 | private $_cache;
24 |
25 |
26 | /**
27 | * @inheritdoc
28 | */
29 | public function exists($key)
30 | {
31 | $key = $this->buildKey($key);
32 | return isset($this->_cache[$key]) && ($this->_cache[$key][1] === 0 || $this->_cache[$key][1] > microtime(true));
33 | }
34 |
35 | /**
36 | * @inheritdoc
37 | */
38 | protected function getValue($key)
39 | {
40 | if (isset($this->_cache[$key]) && ($this->_cache[$key][1] === 0 || $this->_cache[$key][1] > microtime(true))) {
41 | return $this->_cache[$key][0];
42 | } else {
43 | return false;
44 | }
45 | }
46 |
47 | /**
48 | * @inheritdoc
49 | */
50 | protected function setValue($key, $value, $duration)
51 | {
52 | $this->_cache[$key] = [$value, $duration === 0 ? 0 : microtime(true) + $duration];
53 | return true;
54 | }
55 |
56 | /**
57 | * @inheritdoc
58 | */
59 | protected function addValue($key, $value, $duration)
60 | {
61 | if (isset($this->_cache[$key]) && ($this->_cache[$key][1] === 0 || $this->_cache[$key][1] > microtime(true))) {
62 | return false;
63 | } else {
64 | $this->_cache[$key] = [$value, $duration === 0 ? 0 : microtime(true) + $duration];
65 | return true;
66 | }
67 | }
68 |
69 | /**
70 | * @inheritdoc
71 | */
72 | protected function deleteValue($key)
73 | {
74 | unset($this->_cache[$key]);
75 | return true;
76 | }
77 |
78 | /**
79 | * @inheritdoc
80 | */
81 | protected function flushValues()
82 | {
83 | $this->_cache = [];
84 | return true;
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/framework/caching/DbDependency.php:
--------------------------------------------------------------------------------
1 |
22 | * @since 2.0
23 | */
24 | class DbDependency extends Dependency
25 | {
26 | /**
27 | * @var string the application component ID of the DB connection.
28 | */
29 | public $db = 'db';
30 | /**
31 | * @var string the SQL query whose result is used to determine if the dependency has been changed.
32 | * Only the first row of the query result will be used.
33 | */
34 | public $sql;
35 | /**
36 | * @var array the parameters (name => value) to be bound to the SQL statement specified by [[sql]].
37 | */
38 | public $params = [];
39 |
40 |
41 | /**
42 | * Generates the data needed to determine if dependency has been changed.
43 | * This method returns the value of the global state.
44 | * @param Cache $cache the cache component that is currently evaluating this dependency
45 | * @return mixed the data needed to determine if dependency has been changed.
46 | * @throws InvalidConfigException if [[db]] is not a valid application component ID
47 | */
48 | protected function generateDependencyData($cache)
49 | {
50 | $db = Instance::ensure($this->db, Connection::className());
51 | if ($this->sql === null) {
52 | throw new InvalidConfigException('DbDependency::sql must be set.');
53 | }
54 |
55 | if ($db->enableQueryCache) {
56 | // temporarily disable and re-enable query caching
57 | $db->enableQueryCache = false;
58 | $result = $db->createCommand($this->sql, $this->params)->queryOne();
59 | $db->enableQueryCache = true;
60 | } else {
61 | $result = $db->createCommand($this->sql, $this->params)->queryOne();
62 | }
63 |
64 | return $result;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/framework/caching/ExpressionDependency.php:
--------------------------------------------------------------------------------
1 |
21 | * @since 2.0
22 | */
23 | class ExpressionDependency extends Dependency
24 | {
25 | /**
26 | * @var string the string representation of a PHP expression whose result is used to determine the dependency.
27 | * A PHP expression can be any PHP code that evaluates to a value. To learn more about what an expression is,
28 | * please refer to the [php manual](http://www.php.net/manual/en/language.expressions.php).
29 | */
30 | public $expression = 'true';
31 | /**
32 | * @var mixed custom parameters associated with this dependency. You may get the value
33 | * of this property in [[expression]] using `$this->params`.
34 | */
35 | public $params;
36 |
37 |
38 | /**
39 | * Generates the data needed to determine if dependency has been changed.
40 | * This method returns the result of the PHP expression.
41 | * @param Cache $cache the cache component that is currently evaluating this dependency
42 | * @return mixed the data needed to determine if dependency has been changed.
43 | */
44 | protected function generateDependencyData($cache)
45 | {
46 | return eval("return {$this->expression};");
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/framework/caching/FileDependency.php:
--------------------------------------------------------------------------------
1 |
20 | * @since 2.0
21 | */
22 | class FileDependency extends Dependency
23 | {
24 | /**
25 | * @var string the file path or path alias whose last modification time is used to
26 | * check if the dependency has been changed.
27 | */
28 | public $fileName;
29 |
30 |
31 | /**
32 | * Generates the data needed to determine if dependency has been changed.
33 | * This method returns the file's last modification time.
34 | * @param Cache $cache the cache component that is currently evaluating this dependency
35 | * @return mixed the data needed to determine if dependency has been changed.
36 | * @throws InvalidConfigException if [[fileName]] is not set
37 | */
38 | protected function generateDependencyData($cache)
39 | {
40 | if ($this->fileName === null) {
41 | throw new InvalidConfigException('FileDependency::fileName must be set');
42 | }
43 |
44 | return @filemtime(Yii::getAlias($this->fileName));
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/framework/caching/MemCacheServer.php:
--------------------------------------------------------------------------------
1 |
17 | * @since 2.0
18 | */
19 | class MemCacheServer extends \yii\base\Object
20 | {
21 | /**
22 | * @var string memcache server hostname or IP address
23 | */
24 | public $host;
25 | /**
26 | * @var integer memcache server port
27 | */
28 | public $port = 11211;
29 | /**
30 | * @var integer probability of using this server among all servers.
31 | */
32 | public $weight = 1;
33 | /**
34 | * @var boolean whether to use a persistent connection. This is used by memcache only.
35 | */
36 | public $persistent = true;
37 | /**
38 | * @var integer timeout in milliseconds which will be used for connecting to the server.
39 | * This is used by memcache only. For old versions of memcache that only support specifying
40 | * timeout in seconds this will be rounded up to full seconds.
41 | */
42 | public $timeout = 1000;
43 | /**
44 | * @var integer how often a failed server will be retried (in seconds). This is used by memcache only.
45 | */
46 | public $retryInterval = 15;
47 | /**
48 | * @var boolean if the server should be flagged as online upon a failure. This is used by memcache only.
49 | */
50 | public $status = true;
51 | /**
52 | * @var \Closure this callback function will run upon encountering an error.
53 | * The callback is run before fail over is attempted. The function takes two parameters,
54 | * the [[host]] and the [[port]] of the failed server.
55 | * This is used by memcache only.
56 | */
57 | public $failureCallback;
58 | }
59 |
--------------------------------------------------------------------------------
/framework/caching/migrations/m150909_153426_cache_init.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0.7
17 | */
18 | class m150909_153426_cache_init extends Migration
19 | {
20 |
21 | /**
22 | * @throws yii\base\InvalidConfigException
23 | * @return DbCache
24 | */
25 | protected function getCache()
26 | {
27 | $cache = Yii::$app->getCache();
28 | if (!$cache instanceof DbCache) {
29 | throw new InvalidConfigException('You should configure "cache" component to use database before executing this migration.');
30 | }
31 | return $cache;
32 | }
33 |
34 | /**
35 | * @inheritdoc
36 | */
37 | public function up()
38 | {
39 | $cache = $this->getCache();
40 | $this->db = $cache->db;
41 |
42 | $tableOptions = null;
43 | if ($this->db->driverName === 'mysql') {
44 | // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
45 | $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
46 | }
47 |
48 | $this->createTable($cache->cacheTable, [
49 | 'id' => $this->string(128)->notNull(),
50 | 'expire' => $this->integer(),
51 | 'data' => $this->binary(),
52 | 'PRIMARY KEY ([[id]])',
53 | ], $tableOptions);
54 | }
55 |
56 | /**
57 | * @inheritdoc
58 | */
59 | public function down()
60 | {
61 | $cache = $this->getCache();
62 | $this->db = $cache->db;
63 |
64 | $this->dropTable($cache->cacheTable);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/framework/caching/migrations/schema-mssql.sql:
--------------------------------------------------------------------------------
1 | /**
2 | * Database schema required by \yii\caching\DbCache.
3 | *
4 | * @author Qiang Xue
5 | * @author Misbahul D Munir
6 | * @link http://www.yiiframework.com/
7 | * @copyright 2008 Yii Software LLC
8 | * @license http://www.yiiframework.com/license/
9 | * @since 2.0.7
10 | */
11 |
12 | drop table if exists [cache];
13 |
14 | create table [cache]
15 | (
16 | [id] varchar(128) not null,
17 | [expire] integer,
18 | [data] BLOB,
19 | primary key ([id])
20 | );
21 |
--------------------------------------------------------------------------------
/framework/caching/migrations/schema-mysql.sql:
--------------------------------------------------------------------------------
1 | /**
2 | * Database schema required by \yii\caching\DbCache.
3 | *
4 | * @author Qiang Xue
5 | * @author Misbahul D Munir
6 | * @link http://www.yiiframework.com/
7 | * @copyright 2008 Yii Software LLC
8 | * @license http://www.yiiframework.com/license/
9 | * @since 2.0.7
10 | */
11 |
12 | drop table if exists `cache`;
13 |
14 | create table `cache`
15 | (
16 | `id` varchar(128) not null,
17 | `expire` integer,
18 | `data` LONGBLOB,
19 | primary key (`id`)
20 | ) engine InnoDB;
21 |
--------------------------------------------------------------------------------
/framework/caching/migrations/schema-oci.sql:
--------------------------------------------------------------------------------
1 | /**
2 | * Database schema required by \yii\caching\DbCache.
3 | *
4 | * @author Qiang Xue
5 | * @author Misbahul D Munir
6 | * @link http://www.yiiframework.com/
7 | * @copyright 2008 Yii Software LLC
8 | * @license http://www.yiiframework.com/license/
9 | * @since 2.0.7
10 | */
11 |
12 | drop table if exists "cache";
13 |
14 | create table "cache"
15 | (
16 | "id" varchar(128) not null,
17 | "expire" integer,
18 | "data" BYTEA,
19 | primary key ("id")
20 | );
21 |
--------------------------------------------------------------------------------
/framework/caching/migrations/schema-pgsql.sql:
--------------------------------------------------------------------------------
1 | /**
2 | * Database schema required by \yii\caching\DbCache.
3 | *
4 | * @author Qiang Xue
5 | * @author Misbahul D Munir
6 | * @link http://www.yiiframework.com/
7 | * @copyright 2008 Yii Software LLC
8 | * @license http://www.yiiframework.com/license/
9 | * @since 2.0.7
10 | */
11 |
12 | drop table if exists "cache";
13 |
14 | create table "cache"
15 | (
16 | "id" varchar(128) not null,
17 | "expire" integer,
18 | "data" BLOB,
19 | primary key ("id")
20 | );
21 |
--------------------------------------------------------------------------------
/framework/caching/migrations/schema-sqlite.sql:
--------------------------------------------------------------------------------
1 | /**
2 | * Database schema required by \yii\caching\DbCache.
3 | *
4 | * @author Qiang Xue
5 | * @author Misbahul D Munir
6 | * @link http://www.yiiframework.com/
7 | * @copyright 2008 Yii Software LLC
8 | * @license http://www.yiiframework.com/license/
9 | * @since 2.0.7
10 | */
11 |
12 | drop table if exists "cache";
13 |
14 | create table "cache"
15 | (
16 | "id" varchar(128) not null,
17 | "expire" integer,
18 | "data" BLOB,
19 | primary key ("id")
20 | );
21 |
--------------------------------------------------------------------------------
/framework/captcha/CaptchaAsset.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | class CaptchaAsset extends AssetBundle
19 | {
20 | public $sourcePath = '@yii/assets';
21 | public $js = [
22 | 'yii.captcha.js',
23 | ];
24 | public $depends = [
25 | 'yii\web\YiiAsset',
26 | ];
27 | }
28 |
--------------------------------------------------------------------------------
/framework/captcha/SpicyRice.md:
--------------------------------------------------------------------------------
1 | ## Spicy Rice font
2 |
3 | * **Author:** Brian J. Bonislawsky, Astigmatic (AOETI, Astigmatic One Eye Typographic Institute)
4 | * **License:** SIL Open Font License (OFL), version 1.1, [notes and FAQ](http://scripts.sil.org/OFL)
5 |
6 | ## Links
7 |
8 | * [Astigmatic](http://www.astigmatic.com/)
9 | * [Google WebFonts](http://www.google.com/webfonts/specimen/Spicy+Rice)
10 | * [fontsquirrel.com](http://www.fontsquirrel.com/fonts/spicy-rice)
11 | * [fontspace.com](http://www.fontspace.com/astigmatic-one-eye-typographic-institute/spicy-rice)
12 |
--------------------------------------------------------------------------------
/framework/captcha/SpicyRice.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yii2-chinesization/yii2/e0962a5ebaeeed1efd55774d70e19227d23e9a09/framework/captcha/SpicyRice.ttf
--------------------------------------------------------------------------------
/framework/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "yiisoft/yii2",
3 | "description": "Yii PHP Framework Version 2",
4 | "keywords": [
5 | "yii2",
6 | "framework"
7 | ],
8 | "homepage": "http://www.yiiframework.com/",
9 | "type": "library",
10 | "license": "BSD-3-Clause",
11 | "authors": [
12 | {
13 | "name": "Qiang Xue",
14 | "email": "qiang.xue@gmail.com",
15 | "homepage": "http://www.yiiframework.com/",
16 | "role": "Founder and project lead"
17 | },
18 | {
19 | "name": "Alexander Makarov",
20 | "email": "sam@rmcreative.ru",
21 | "homepage": "http://rmcreative.ru/",
22 | "role": "Core framework development"
23 | },
24 | {
25 | "name": "Maurizio Domba",
26 | "homepage": "http://mdomba.info/",
27 | "role": "Core framework development"
28 | },
29 | {
30 | "name": "Carsten Brandt",
31 | "email": "mail@cebe.cc",
32 | "homepage": "http://cebe.cc/",
33 | "role": "Core framework development"
34 | },
35 | {
36 | "name": "Timur Ruziev",
37 | "email": "resurtm@gmail.com",
38 | "homepage": "http://resurtm.com/",
39 | "role": "Core framework development"
40 | },
41 | {
42 | "name": "Paul Klimov",
43 | "email": "klimov.paul@gmail.com",
44 | "role": "Core framework development"
45 | },
46 | {
47 | "name": "Dmitry Naumenko",
48 | "email": "d.naumenko.a@gmail.com",
49 | "role": "Core framework development"
50 | }
51 | ],
52 | "support": {
53 | "issues": "https://github.com/yiisoft/yii2/issues?state=open",
54 | "forum": "http://www.yiiframework.com/forum/",
55 | "wiki": "http://www.yiiframework.com/wiki/",
56 | "irc": "irc://irc.freenode.net/yii",
57 | "source": "https://github.com/yiisoft/yii2"
58 | },
59 | "require": {
60 | "php": ">=5.4.0",
61 | "ext-mbstring": "*",
62 | "ext-ctype": "*",
63 | "lib-pcre": "*",
64 | "yiisoft/yii2-composer": "*",
65 | "ezyang/htmlpurifier": "4.6.*",
66 | "cebe/markdown": "~1.0.0 | ~1.1.0",
67 | "bower-asset/jquery": "2.1.*@stable | 1.11.*@stable",
68 | "bower-asset/jquery.inputmask": "~3.2.2",
69 | "bower-asset/punycode": "1.3.*",
70 | "bower-asset/yii2-pjax": ">=2.0.1"
71 | },
72 | "autoload": {
73 | "psr-4": {"yii\\": ""}
74 | },
75 | "bin": [
76 | "yii"
77 | ],
78 | "extra": {
79 | "branch-alias": {
80 | "dev-master": "2.0.x-dev"
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/framework/console/Exception.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | class Exception extends UserException
19 | {
20 | /**
21 | * @return string the user-friendly name of this exception
22 | */
23 | public function getName()
24 | {
25 | return 'Error';
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/framework/console/Request.php:
--------------------------------------------------------------------------------
1 |
19 | * @since 2.0
20 | */
21 | class Request extends \yii\base\Request
22 | {
23 | private $_params;
24 |
25 |
26 | /**
27 | * Returns the command line arguments.
28 | * @return array the command line arguments. It does not include the entry script name.
29 | */
30 | public function getParams()
31 | {
32 | if ($this->_params === null) {
33 | if (isset($_SERVER['argv'])) {
34 | $this->_params = $_SERVER['argv'];
35 | array_shift($this->_params);
36 | } else {
37 | $this->_params = [];
38 | }
39 | }
40 |
41 | return $this->_params;
42 | }
43 |
44 | /**
45 | * Sets the command line arguments.
46 | * @param array $params the command line arguments
47 | */
48 | public function setParams($params)
49 | {
50 | $this->_params = $params;
51 | }
52 |
53 | /**
54 | * Resolves the current request into a route and the associated parameters.
55 | * @return array the first element is the route, and the second is the associated parameters.
56 | */
57 | public function resolve()
58 | {
59 | $rawParams = $this->getParams();
60 | if (isset($rawParams[0])) {
61 | $route = $rawParams[0];
62 | array_shift($rawParams);
63 | } else {
64 | $route = '';
65 | }
66 |
67 | $params = [];
68 | foreach ($rawParams as $param) {
69 | if (preg_match('/^--(\w+)(=(.*))?$/', $param, $matches)) {
70 | $name = $matches[1];
71 | if ($name !== Application::OPTION_APPCONFIG) {
72 | $params[$name] = isset($matches[3]) ? $matches[3] : true;
73 | }
74 | } else {
75 | $params[] = $param;
76 | }
77 | }
78 |
79 | return [$route, $params];
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/framework/console/Response.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class Response extends \yii\base\Response
17 | {
18 | }
19 |
--------------------------------------------------------------------------------
/framework/console/runtime/.gitignore:
--------------------------------------------------------------------------------
1 | *
--------------------------------------------------------------------------------
/framework/data/DataProviderInterface.php:
--------------------------------------------------------------------------------
1 |
17 | * @since 2.0
18 | */
19 | interface DataProviderInterface
20 | {
21 | /**
22 | * Prepares the data models and keys.
23 | *
24 | * This method will prepare the data models and keys that can be retrieved via
25 | * [[getModels()]] and [[getKeys()]].
26 | *
27 | * This method will be implicitly called by [[getModels()]] and [[getKeys()]] if it has not been called before.
28 | *
29 | * @param boolean $forcePrepare whether to force data preparation even if it has been done before.
30 | */
31 | public function prepare($forcePrepare = false);
32 |
33 | /**
34 | * Returns the number of data models in the current page.
35 | * This is equivalent to `count($provider->getModels())`.
36 | * When [[getPagination|pagination]] is false, this is the same as [[getTotalCount|totalCount]].
37 | * @return integer the number of data models in the current page.
38 | */
39 | public function getCount();
40 |
41 | /**
42 | * Returns the total number of data models.
43 | * When [[getPagination|pagination]] is false, this is the same as [[getCount|count]].
44 | * @return integer total number of possible data models.
45 | */
46 | public function getTotalCount();
47 |
48 | /**
49 | * Returns the data models in the current page.
50 | * @return array the list of data models in the current page.
51 | */
52 | public function getModels();
53 |
54 | /**
55 | * Returns the key values associated with the data models.
56 | * @return array the list of key values corresponding to [[getModels|models]]. Each data model in [[getModels|models]]
57 | * is uniquely identified by the corresponding key value in this array.
58 | */
59 | public function getKeys();
60 |
61 | /**
62 | * @return Sort the sorting object. If this is false, it means the sorting is disabled.
63 | */
64 | public function getSort();
65 |
66 | /**
67 | * @return Pagination the pagination object. If this is false, it means the pagination is disabled.
68 | */
69 | public function getPagination();
70 | }
71 |
--------------------------------------------------------------------------------
/framework/db/AfterSaveEvent.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | class AfterSaveEvent extends Event
19 | {
20 | /**
21 | * @var array The attribute values that had changed and were saved.
22 | */
23 | public $changedAttributes;
24 | }
25 |
--------------------------------------------------------------------------------
/framework/db/Exception.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class Exception extends \yii\base\Exception
17 | {
18 | /**
19 | * @var array the error info provided by a PDO exception. This is the same as returned
20 | * by [PDO::errorInfo](http://www.php.net/manual/en/pdo.errorinfo.php).
21 | */
22 | public $errorInfo = [];
23 |
24 |
25 | /**
26 | * Constructor.
27 | * @param string $message PDO error message
28 | * @param array $errorInfo PDO error info
29 | * @param integer $code PDO error code
30 | * @param \Exception $previous The previous exception used for the exception chaining.
31 | */
32 | public function __construct($message, $errorInfo = [], $code = 0, \Exception $previous = null)
33 | {
34 | $this->errorInfo = $errorInfo;
35 | parent::__construct($message, $code, $previous);
36 | }
37 |
38 | /**
39 | * @return string the user-friendly name of this exception
40 | */
41 | public function getName()
42 | {
43 | return 'Database Exception';
44 | }
45 |
46 | /**
47 | * @return string readable representation of exception
48 | */
49 | public function __toString()
50 | {
51 | return parent::__toString() . PHP_EOL
52 | . 'Additional Information:' . PHP_EOL . print_r($this->errorInfo, true);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/framework/db/Expression.php:
--------------------------------------------------------------------------------
1 |
24 | * @since 2.0
25 | */
26 | class Expression extends \yii\base\Object
27 | {
28 | /**
29 | * @var string the DB expression
30 | */
31 | public $expression;
32 | /**
33 | * @var array list of parameters that should be bound for this expression.
34 | * The keys are placeholders appearing in [[expression]] and the values
35 | * are the corresponding parameter values.
36 | */
37 | public $params = [];
38 |
39 |
40 | /**
41 | * Constructor.
42 | * @param string $expression the DB expression
43 | * @param array $params parameters
44 | * @param array $config name-value pairs that will be used to initialize the object properties
45 | */
46 | public function __construct($expression, $params = [], $config = [])
47 | {
48 | $this->expression = $expression;
49 | $this->params = $params;
50 | parent::__construct($config);
51 | }
52 |
53 | /**
54 | * String magic method
55 | * @return string the DB expression
56 | */
57 | public function __toString()
58 | {
59 | return $this->expression;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/framework/db/IntegrityException.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class IntegrityException extends Exception
17 | {
18 | /**
19 | * @return string the user-friendly name of this exception
20 | */
21 | public function getName()
22 | {
23 | return 'Integrity constraint violation';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/framework/db/MigrationInterface.php:
--------------------------------------------------------------------------------
1 |
17 | * @since 2.0
18 | */
19 | interface MigrationInterface
20 | {
21 | /**
22 | * This method contains the logic to be executed when applying this migration.
23 | * @return boolean return a false value to indicate the migration fails
24 | * and should not proceed further. All other return values mean the migration succeeds.
25 | */
26 | public function up();
27 |
28 | /**
29 | * This method contains the logic to be executed when removing this migration.
30 | * The default implementation throws an exception indicating the migration cannot be removed.
31 | * @return boolean return a false value to indicate the migration fails
32 | * and should not proceed further. All other return values mean the migration succeeds.
33 | */
34 | public function down();
35 | }
36 |
--------------------------------------------------------------------------------
/framework/db/StaleObjectException.php:
--------------------------------------------------------------------------------
1 |
12 | * @since 2.0
13 | */
14 | class StaleObjectException extends Exception
15 | {
16 | /**
17 | * @return string the user-friendly name of this exception
18 | */
19 | public function getName()
20 | {
21 | return 'Stale Object Exception';
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/framework/db/mssql/PDO.php:
--------------------------------------------------------------------------------
1 |
15 | * @since 2.0
16 | */
17 | class PDO extends \PDO
18 | {
19 | /**
20 | * Returns value of the last inserted ID.
21 | * @param string|null $sequence the sequence name. Defaults to null.
22 | * @return integer last inserted ID value.
23 | */
24 | public function lastInsertId($sequence = null)
25 | {
26 | return $this->query('SELECT CAST(COALESCE(SCOPE_IDENTITY(), @@IDENTITY) AS bigint)')->fetchColumn();
27 | }
28 |
29 | /**
30 | * Starts a transaction. It is necessary to override PDO's method as MSSQL PDO driver does not
31 | * natively support transactions.
32 | * @return boolean the result of a transaction start.
33 | */
34 | public function beginTransaction()
35 | {
36 | $this->exec('BEGIN TRANSACTION');
37 |
38 | return true;
39 | }
40 |
41 | /**
42 | * Commits a transaction. It is necessary to override PDO's method as MSSQL PDO driver does not
43 | * natively support transactions.
44 | * @return boolean the result of a transaction commit.
45 | */
46 | public function commit()
47 | {
48 | $this->exec('COMMIT TRANSACTION');
49 |
50 | return true;
51 | }
52 |
53 | /**
54 | * Rollbacks a transaction. It is necessary to override PDO's method as MSSQL PDO driver does not
55 | * natively support transactions.
56 | * @return boolean the result of a transaction roll back.
57 | */
58 | public function rollBack()
59 | {
60 | $this->exec('ROLLBACK TRANSACTION');
61 |
62 | return true;
63 | }
64 |
65 | /**
66 | * Retrieve a database connection attribute.
67 | * It is necessary to override PDO's method as some MSSQL PDO driver (e.g. dblib) does not
68 | * support getting attributes
69 | * @param integer $attribute One of the PDO::ATTR_* constants.
70 | * @return mixed A successful call returns the value of the requested PDO attribute.
71 | * An unsuccessful call returns null.
72 | */
73 | public function getAttribute($attribute)
74 | {
75 | try {
76 | return parent::getAttribute($attribute);
77 | } catch (\PDOException $e) {
78 | switch ($attribute) {
79 | case PDO::ATTR_SERVER_VERSION:
80 | return $this->query("SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR)")->fetchColumn();
81 | default:
82 | throw $e;
83 | }
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/framework/db/mssql/SqlsrvPDO.php:
--------------------------------------------------------------------------------
1 |
15 | * @since 2.0
16 | */
17 | class SqlsrvPDO extends \PDO
18 | {
19 | /**
20 | * Returns value of the last inserted ID.
21 | *
22 | * SQLSRV driver implements [[PDO::lastInsertId()]] method but with a single peculiarity:
23 | * when `$sequence` value is a null or an empty string it returns an empty string.
24 | * But when parameter is not specified it works as expected and returns actual
25 | * last inserted ID (like the other PDO drivers).
26 | * @param string|null $sequence the sequence name. Defaults to null.
27 | * @return integer last inserted ID value.
28 | */
29 | public function lastInsertId($sequence = null)
30 | {
31 | return !$sequence ? parent::lastInsertId() : parent::lastInsertId($sequence);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/framework/db/mssql/TableSchema.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class TableSchema extends \yii\db\TableSchema
17 | {
18 | /**
19 | * @var string name of the catalog (database) that this table belongs to.
20 | * Defaults to null, meaning no catalog (or the current database).
21 | */
22 | public $catalogName;
23 | }
24 |
--------------------------------------------------------------------------------
/framework/db/oci/ColumnSchemaBuilder.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0.6
17 | */
18 | class ColumnSchemaBuilder extends AbstractColumnSchemaBuilder
19 | {
20 | /**
21 | * @inheritdoc
22 | */
23 | public function __toString()
24 | {
25 | return
26 | $this->type .
27 | $this->buildLengthString() .
28 | $this->buildDefaultString() .
29 | $this->buildNotNullString() .
30 | $this->buildCheckString();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/framework/filters/RateLimitInterface.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | interface RateLimitInterface
17 | {
18 | /**
19 | * Returns the maximum number of allowed requests and the window size.
20 | * @param \yii\web\Request $request the current request
21 | * @param \yii\base\Action $action the action to be executed
22 | * @return array an array of two elements. The first element is the maximum number of allowed requests,
23 | * and the second element is the size of the window in seconds.
24 | */
25 | public function getRateLimit($request, $action);
26 |
27 | /**
28 | * Loads the number of allowed requests and the corresponding timestamp from a persistent storage.
29 | * @param \yii\web\Request $request the current request
30 | * @param \yii\base\Action $action the action to be executed
31 | * @return array an array of two elements. The first element is the number of allowed requests,
32 | * and the second element is the corresponding UNIX timestamp.
33 | */
34 | public function loadAllowance($request, $action);
35 |
36 | /**
37 | * Saves the number of allowed requests and the corresponding timestamp to a persistent storage.
38 | * @param \yii\web\Request $request the current request
39 | * @param \yii\base\Action $action the action to be executed
40 | * @param integer $allowance the number of allowed requests remaining.
41 | * @param integer $timestamp the current timestamp.
42 | */
43 | public function saveAllowance($request, $action, $allowance, $timestamp);
44 | }
45 |
--------------------------------------------------------------------------------
/framework/filters/auth/AuthInterface.php:
--------------------------------------------------------------------------------
1 |
20 | * @since 2.0
21 | */
22 | interface AuthInterface
23 | {
24 | /**
25 | * Authenticates the current user.
26 | * @param User $user
27 | * @param Request $request
28 | * @param Response $response
29 | * @return IdentityInterface the authenticated user identity. If authentication information is not provided, null will be returned.
30 | * @throws UnauthorizedHttpException if authentication information is provided but is invalid.
31 | */
32 | public function authenticate($user, $request, $response);
33 |
34 | /**
35 | * Generates challenges upon authentication failure.
36 | * For example, some appropriate HTTP headers may be generated.
37 | * @param Response $response
38 | */
39 | public function challenge($response);
40 |
41 | /**
42 | * Handles authentication failure.
43 | * The implementation should normally throw UnauthorizedHttpException to indicate authentication failure.
44 | * @param Response $response
45 | * @throws UnauthorizedHttpException
46 | */
47 | public function handleFailure($response);
48 | }
49 |
--------------------------------------------------------------------------------
/framework/filters/auth/HttpBearerAuth.php:
--------------------------------------------------------------------------------
1 | [
20 | * 'class' => \yii\filters\auth\HttpBearerAuth::className(),
21 | * ],
22 | * ];
23 | * }
24 | * ```
25 | *
26 | * @author Qiang Xue
27 | * @since 2.0
28 | */
29 | class HttpBearerAuth extends AuthMethod
30 | {
31 | /**
32 | * @var string the HTTP authentication realm
33 | */
34 | public $realm = 'api';
35 |
36 |
37 | /**
38 | * @inheritdoc
39 | */
40 | public function authenticate($user, $request, $response)
41 | {
42 | $authHeader = $request->getHeaders()->get('Authorization');
43 | if ($authHeader !== null && preg_match('/^Bearer\s+(.*?)$/', $authHeader, $matches)) {
44 | $identity = $user->loginByAccessToken($matches[1], get_class($this));
45 | if ($identity === null) {
46 | $this->handleFailure($response);
47 | }
48 | return $identity;
49 | }
50 |
51 | return null;
52 | }
53 |
54 | /**
55 | * @inheritdoc
56 | */
57 | public function challenge($response)
58 | {
59 | $response->getHeaders()->set('WWW-Authenticate', "Bearer realm=\"{$this->realm}\"");
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/framework/filters/auth/QueryParamAuth.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class QueryParamAuth extends AuthMethod
17 | {
18 | /**
19 | * @var string the parameter name for passing the access token
20 | */
21 | public $tokenParam = 'access-token';
22 |
23 |
24 | /**
25 | * @inheritdoc
26 | */
27 | public function authenticate($user, $request, $response)
28 | {
29 | $accessToken = $request->get($this->tokenParam);
30 | if (is_string($accessToken)) {
31 | $identity = $user->loginByAccessToken($accessToken, get_class($this));
32 | if ($identity !== null) {
33 | return $identity;
34 | }
35 | }
36 | if ($accessToken !== null) {
37 | $this->handleFailure($response);
38 | }
39 |
40 | return null;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/framework/grid/GridViewAsset.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | class GridViewAsset extends AssetBundle
19 | {
20 | public $sourcePath = '@yii/assets';
21 | public $js = [
22 | 'yii.gridView.js',
23 | ];
24 | public $depends = [
25 | 'yii\web\YiiAsset',
26 | ];
27 | }
28 |
--------------------------------------------------------------------------------
/framework/grid/SerialColumn.php:
--------------------------------------------------------------------------------
1 | [
17 | * // ...
18 | * [
19 | * 'class' => 'yii\grid\SerialColumn',
20 | * // you may configure additional properties here
21 | * ],
22 | * ]
23 | * ```
24 | *
25 | * @author Qiang Xue
26 | * @since 2.0
27 | */
28 | class SerialColumn extends Column
29 | {
30 | /**
31 | * @inheritdoc
32 | */
33 | public $header = '#';
34 |
35 |
36 | /**
37 | * @inheritdoc
38 | */
39 | protected function renderDataCellContent($model, $key, $index)
40 | {
41 | $pagination = $this->grid->dataProvider->getPagination();
42 | if ($pagination !== false) {
43 | return $pagination->getOffset() + $index + 1;
44 | } else {
45 | return $index + 1;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/framework/helpers/ArrayHelper.php:
--------------------------------------------------------------------------------
1 |
15 | * @since 2.0
16 | */
17 | class ArrayHelper extends BaseArrayHelper
18 | {
19 | }
20 |
--------------------------------------------------------------------------------
/framework/helpers/BaseHtmlPurifier.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | class BaseHtmlPurifier
19 | {
20 | /**
21 | * Passes markup through HTMLPurifier making it safe to output to end user
22 | *
23 | * @param string $content The HTML content to purify
24 | * @param array|\Closure|null $config The config to use for HtmlPurifier.
25 | * If not specified or `null` the default config will be used.
26 | * You can use an array or an anonymous function to provide configuration options:
27 | *
28 | * - An array will be passed to the `HTMLPurifier_Config::create()` method.
29 | * - An anonymous function will be called after the config was created.
30 | * The signature should be: `function($config)` where `$config` will be an
31 | * instance of `HTMLPurifier_Config`.
32 | *
33 | * Here is a usage example of such a function:
34 | *
35 | * ```php
36 | * // Allow the HTML5 data attribute `data-type` on `img` elements.
37 | * $content = HtmlPurifier::process($content, function ($config) {
38 | * $config->getHTMLDefinition(true)
39 | * ->addAttribute('img', 'data-type', 'Text');
40 | * });
41 | * ```
42 | *
43 | * @return string the purified HTML content.
44 | */
45 | public static function process($content, $config = null)
46 | {
47 | $configInstance = \HTMLPurifier_Config::create($config instanceof \Closure ? null : $config);
48 | $configInstance->autoFinalize = false;
49 | $purifier = \HTMLPurifier::instance($configInstance);
50 | $purifier->config->set('Cache.SerializerPath', \Yii::$app->getRuntimePath());
51 | $purifier->config->set('Cache.SerializerPermissions', 0775);
52 |
53 | if ($config instanceof \Closure) {
54 | call_user_func($config, $configInstance);
55 | }
56 | static::configure($configInstance);
57 |
58 | return $purifier->purify($content);
59 | }
60 |
61 | /**
62 | * Allow the extended HtmlPurifier class to set some default config options.
63 | * @param \HTMLPurifier_Config $config
64 | * @since 2.0.3
65 | */
66 | protected static function configure($config)
67 | {
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/framework/helpers/Console.php:
--------------------------------------------------------------------------------
1 |
15 | * @since 2.0
16 | */
17 | class Console extends BaseConsole
18 | {
19 | }
20 |
--------------------------------------------------------------------------------
/framework/helpers/FileHelper.php:
--------------------------------------------------------------------------------
1 |
14 | * @author Alex Makarov
15 | * @since 2.0
16 | */
17 | class FileHelper extends BaseFileHelper
18 | {
19 | }
20 |
--------------------------------------------------------------------------------
/framework/helpers/FormatConverter.php:
--------------------------------------------------------------------------------
1 |
16 | * @author Enrica Ruedin
17 | * @since 2.0
18 | */
19 | class FormatConverter extends BaseFormatConverter
20 | {
21 | }
22 |
--------------------------------------------------------------------------------
/framework/helpers/Html.php:
--------------------------------------------------------------------------------
1 |
18 | * @since 2.0
19 | */
20 | class Html extends BaseHtml
21 | {
22 | }
23 |
--------------------------------------------------------------------------------
/framework/helpers/HtmlPurifier.php:
--------------------------------------------------------------------------------
1 | true,
24 | * ]);
25 | * ```
26 | *
27 | * For more details please refer to [HTMLPurifier documentation](http://htmlpurifier.org/).
28 | *
29 | * @author Alexander Makarov
30 | * @since 2.0
31 | */
32 | class HtmlPurifier extends BaseHtmlPurifier
33 | {
34 | }
35 |
--------------------------------------------------------------------------------
/framework/helpers/Inflector.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class Inflector extends BaseInflector
17 | {
18 | }
19 |
--------------------------------------------------------------------------------
/framework/helpers/Json.php:
--------------------------------------------------------------------------------
1 |
15 | * @since 2.0
16 | */
17 | class Json extends BaseJson
18 | {
19 | }
20 |
--------------------------------------------------------------------------------
/framework/helpers/Markdown.php:
--------------------------------------------------------------------------------
1 |
26 | * @since 2.0
27 | */
28 | class Markdown extends BaseMarkdown
29 | {
30 | }
31 |
--------------------------------------------------------------------------------
/framework/helpers/StringHelper.php:
--------------------------------------------------------------------------------
1 |
14 | * @author Alex Makarov
15 | * @since 2.0
16 | */
17 | class StringHelper extends BaseStringHelper
18 | {
19 | }
20 |
--------------------------------------------------------------------------------
/framework/helpers/Url.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class Url extends BaseUrl
17 | {
18 | }
19 |
--------------------------------------------------------------------------------
/framework/helpers/VarDumper.php:
--------------------------------------------------------------------------------
1 |
23 | * @since 2.0
24 | */
25 | class VarDumper extends BaseVarDumper
26 | {
27 | }
28 |
--------------------------------------------------------------------------------
/framework/i18n/GettextFile.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | abstract class GettextFile extends Component
19 | {
20 | /**
21 | * Loads messages from a file.
22 | * @param string $filePath file path
23 | * @param string $context message context
24 | * @return array message translations. Array keys are source messages and array values are translated messages:
25 | * source message => translated message.
26 | */
27 | abstract public function load($filePath, $context);
28 |
29 | /**
30 | * Saves messages to a file.
31 | * @param string $filePath file path
32 | * @param array $messages message translations. Array keys are source messages and array values are
33 | * translated messages: source message => translated message. Note if the message has a context,
34 | * the message ID must be prefixed with the context with chr(4) as the separator.
35 | */
36 | abstract public function save($filePath, $messages);
37 | }
38 |
--------------------------------------------------------------------------------
/framework/i18n/MissingTranslationEvent.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | class MissingTranslationEvent extends Event
19 | {
20 | /**
21 | * @var string the message to be translated. An event handler may use this to provide a fallback translation
22 | * and set [[translatedMessage]] if possible.
23 | */
24 | public $message;
25 | /**
26 | * @var string the translated message. An event handler may overwrite this property
27 | * with a translated version of [[message]] if possible. If not set (null), it means the message is not translated.
28 | */
29 | public $translatedMessage;
30 | /**
31 | * @var string the category that the message belongs to
32 | */
33 | public $category;
34 | /**
35 | * @var string the language ID (e.g. en-US) that the message is to be translated to
36 | */
37 | public $language;
38 | }
39 |
--------------------------------------------------------------------------------
/framework/log/SyslogTarget.php:
--------------------------------------------------------------------------------
1 |
17 | * @since 2.0
18 | */
19 | class SyslogTarget extends Target
20 | {
21 | /**
22 | * @var string syslog identity
23 | */
24 | public $identity;
25 | /**
26 | * @var integer syslog facility.
27 | */
28 | public $facility = LOG_USER;
29 |
30 | /**
31 | * @var array syslog levels
32 | */
33 | private $_syslogLevels = [
34 | Logger::LEVEL_TRACE => LOG_DEBUG,
35 | Logger::LEVEL_PROFILE_BEGIN => LOG_DEBUG,
36 | Logger::LEVEL_PROFILE_END => LOG_DEBUG,
37 | Logger::LEVEL_INFO => LOG_INFO,
38 | Logger::LEVEL_WARNING => LOG_WARNING,
39 | Logger::LEVEL_ERROR => LOG_ERR,
40 | ];
41 |
42 |
43 | /**
44 | * Writes log messages to syslog
45 | */
46 | public function export()
47 | {
48 | openlog($this->identity, LOG_ODELAY | LOG_PID, $this->facility);
49 | foreach ($this->messages as $message) {
50 | syslog($this->_syslogLevels[$message[1]], $this->formatMessage($message));
51 | }
52 | closelog();
53 | }
54 |
55 | /**
56 | * @inheritdoc
57 | */
58 | public function formatMessage($message)
59 | {
60 | list($text, $level, $category, $timestamp) = $message;
61 | $level = Logger::getLevelName($level);
62 | if (!is_string($text)) {
63 | // exceptions may not be serializable if in the call stack somewhere is a Closure
64 | if ($text instanceof \Exception) {
65 | $text = (string) $text;
66 | } else {
67 | $text = VarDumper::export($text);
68 | }
69 | }
70 |
71 | $prefix = $this->getMessagePrefix($message);
72 | return "{$prefix}[$level][$category] $text";
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/framework/log/migrations/schema-mssql.sql:
--------------------------------------------------------------------------------
1 | /**
2 | * Database schema required by \yii\log\DbTarget.
3 | *
4 | * The indexes declared are not required. They are mainly used to improve the performance
5 | * of some queries about message levels and categories. Depending on your actual needs, you may
6 | * want to create additional indexes (e.g. index on `log_time`).
7 | *
8 | * @author Alexander Makarov
9 | * @link http://www.yiiframework.com/
10 | * @copyright 2008 Yii Software LLC
11 | * @license http://www.yiiframework.com/license/
12 | * @since 2.0.1
13 | */
14 |
15 | drop table if exists [log];
16 |
17 | create table [log]
18 | (
19 | [id] bigint IDENTITY PRIMARY KEY,
20 | [level] integer,
21 | [category] varchar(255),
22 | [log_time] float,
23 | [prefix] text,
24 | [message] text
25 | );
26 |
27 | create index [idx_log_level] on [log] ([level]);
28 | create index [idx_log_category] on [log] ([category]);
29 |
--------------------------------------------------------------------------------
/framework/log/migrations/schema-mysql.sql:
--------------------------------------------------------------------------------
1 | /**
2 | * Database schema required by \yii\log\DbTarget.
3 | *
4 | * The indexes declared are not required. They are mainly used to improve the performance
5 | * of some queries about message levels and categories. Depending on your actual needs, you may
6 | * want to create additional indexes (e.g. index on `log_time`).
7 | *
8 | * @author Alexander Makarov
9 | * @link http://www.yiiframework.com/
10 | * @copyright 2008 Yii Software LLC
11 | * @license http://www.yiiframework.com/license/
12 | * @since 2.0.1
13 | */
14 |
15 | drop table if exists `log`;
16 |
17 | create table `log`
18 | (
19 | `id` bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
20 | `level` integer,
21 | `category` varchar(255),
22 | `log_time` double,
23 | `prefix` text,
24 | `message` text,
25 | key `idx_log_level` (`level`),
26 | key `idx_log_category` (`category`)
27 | ) engine InnoDB;
28 |
--------------------------------------------------------------------------------
/framework/log/migrations/schema-oci.sql:
--------------------------------------------------------------------------------
1 | /**
2 | * Database schema required by \yii\log\DbTarget.
3 | *
4 | * The indexes declared are not required. They are mainly used to improve the performance
5 | * of some queries about message levels and categories. Depending on your actual needs, you may
6 | * want to create additional indexes (e.g. index on `log_time`).
7 | *
8 | * @author Alexander Makarov
9 | * @link http://www.yiiframework.com/
10 | * @copyright 2008 Yii Software LLC
11 | * @license http://www.yiiframework.com/license/
12 | * @since 2.0.1
13 | */
14 |
15 | drop table if exists "log";
16 |
17 | create table "log"
18 | (
19 | "id" number(20) NOT NULL PRIMARY KEY,
20 | "level" integer,
21 | "category" varchar(255),
22 | "log_time" number,
23 | "prefix" text,
24 | "message" text,
25 | key "idx_log_level" ("level"),
26 | key "idx_log_category" ("category")
27 | );
28 |
--------------------------------------------------------------------------------
/framework/log/migrations/schema-pgsql.sql:
--------------------------------------------------------------------------------
1 | /**
2 | * Database schema required by \yii\log\DbTarget.
3 | *
4 | * The indexes declared are not required. They are mainly used to improve the performance
5 | * of some queries about message levels and categories. Depending on your actual needs, you may
6 | * want to create additional indexes (e.g. index on `log_time`).
7 | *
8 | * @author Alexander Makarov
9 | * @link http://www.yiiframework.com/
10 | * @copyright 2008 Yii Software LLC
11 | * @license http://www.yiiframework.com/license/
12 | * @since 2.0.1
13 | */
14 |
15 | drop table if exists "log";
16 |
17 | create table "log"
18 | (
19 | "id" bigserial NOT NULL PRIMARY KEY,
20 | "level" integer,
21 | "category" varchar(255),
22 | "log_time" double precision,
23 | "prefix" text,
24 | "message" text
25 | );
26 |
27 | create index "idx_log_level" on "log" ("level");
28 | create index "idx_log_category" on "log" ("category");
--------------------------------------------------------------------------------
/framework/log/migrations/schema-sqlite.sql:
--------------------------------------------------------------------------------
1 | /**
2 | * Database schema required by \yii\log\DbTarget.
3 | *
4 | * The indexes declared are not required. They are mainly used to improve the performance
5 | * of some queries about message levels and categories. Depending on your actual needs, you may
6 | * want to create additional indexes (e.g. index on `log_time`).
7 | *
8 | * @author Alexander Makarov
9 | * @link http://www.yiiframework.com/
10 | * @copyright 2008 Yii Software LLC
11 | * @license http://www.yiiframework.com/license/
12 | * @since 2.0.1
13 | */
14 |
15 | drop table if exists "log";
16 |
17 | create table "log"
18 | (
19 | "id" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
20 | "level" integer,
21 | "category" varchar(255),
22 | "log_time" double,
23 | "prefix" text,
24 | "message" text
25 | );
26 |
27 | create index "idx_log_level" on "log" ("level");
28 | create index "idx_log_category" on "log" ("category");
--------------------------------------------------------------------------------
/framework/mail/BaseMessage.php:
--------------------------------------------------------------------------------
1 |
23 | * @since 2.0
24 | */
25 | abstract class BaseMessage extends Object implements MessageInterface
26 | {
27 | /**
28 | * @var MailerInterface the mailer instance that created this message.
29 | * For independently created messages this is `null`.
30 | */
31 | public $mailer;
32 |
33 |
34 | /**
35 | * Sends this email message.
36 | * @param MailerInterface $mailer the mailer that should be used to send this message.
37 | * If no mailer is given it will first check if [[mailer]] is set and if not,
38 | * the "mail" application component will be used instead.
39 | * @return boolean whether this message is sent successfully.
40 | */
41 | public function send(MailerInterface $mailer = null)
42 | {
43 | if ($mailer === null && $this->mailer === null) {
44 | $mailer = Yii::$app->getMailer();
45 | } elseif ($mailer === null) {
46 | $mailer = $this->mailer;
47 | }
48 | return $mailer->send($this);
49 | }
50 |
51 | /**
52 | * PHP magic method that returns the string representation of this object.
53 | * @return string the string representation of this object.
54 | */
55 | public function __toString()
56 | {
57 | // __toString cannot throw exception
58 | // use trigger_error to bypass this limitation
59 | try {
60 | return $this->toString();
61 | } catch (\Exception $e) {
62 | ErrorHandler::convertExceptionToError($e);
63 | return '';
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/framework/mail/MailEvent.php:
--------------------------------------------------------------------------------
1 |
18 | * @since 2.0
19 | */
20 | class MailEvent extends Event
21 | {
22 | /**
23 | * @var \yii\mail\MessageInterface the mail message being send.
24 | */
25 | public $message;
26 | /**
27 | * @var boolean if message was sent successfully.
28 | */
29 | public $isSuccessful;
30 | /**
31 | * @var boolean whether to continue sending an email. Event handlers of
32 | * [[\yii\mail\BaseMailer::EVENT_BEFORE_SEND]] may set this property to decide whether
33 | * to continue send or not.
34 | */
35 | public $isValid = true;
36 | }
37 |
--------------------------------------------------------------------------------
/framework/mail/MailerInterface.php:
--------------------------------------------------------------------------------
1 | mailer->compose('contact/html', ['contactForm' => $form])
18 | * ->setFrom('from@domain.com')
19 | * ->setTo($form->email)
20 | * ->setSubject($form->subject)
21 | * ->send();
22 | * ```
23 | *
24 | * @see MessageInterface
25 | *
26 | * @author Paul Klimov
27 | * @since 2.0
28 | */
29 | interface MailerInterface
30 | {
31 | /**
32 | * Creates a new message instance and optionally composes its body content via view rendering.
33 | *
34 | * @param string|array $view the view to be used for rendering the message body. This can be:
35 | *
36 | * - a string, which represents the view name or path alias for rendering the HTML body of the email.
37 | * In this case, the text body will be generated by applying `strip_tags()` to the HTML body.
38 | * - an array with 'html' and/or 'text' elements. The 'html' element refers to the view name or path alias
39 | * for rendering the HTML body, while 'text' element is for rendering the text body. For example,
40 | * `['html' => 'contact-html', 'text' => 'contact-text']`.
41 | * - null, meaning the message instance will be returned without body content.
42 | *
43 | * @param array $params the parameters (name-value pairs) that will be extracted and made available in the view file.
44 | * @return MessageInterface message instance.
45 | */
46 | public function compose($view = null, array $params = []);
47 |
48 | /**
49 | * Sends the given email message.
50 | * @param MessageInterface $message email message instance to be sent
51 | * @return boolean whether the message has been sent successfully
52 | */
53 | public function send($message);
54 |
55 | /**
56 | * Sends multiple messages at once.
57 | *
58 | * This method may be implemented by some mailers which support more efficient way of sending multiple messages in the same batch.
59 | *
60 | * @param array $messages list of email messages, which should be sent.
61 | * @return integer number of messages that are successfully sent.
62 | */
63 | public function sendMultiple(array $messages);
64 | }
65 |
--------------------------------------------------------------------------------
/framework/mutex/DbMutex.php:
--------------------------------------------------------------------------------
1 |
21 | * @since 2.0
22 | */
23 | abstract class DbMutex extends Mutex
24 | {
25 | /**
26 | * @var Connection|array|string the DB connection object or the application component ID of the DB connection.
27 | * After the Mutex object is created, if you want to change this property, you should only assign
28 | * it with a DB connection object.
29 | * Starting from version 2.0.2, this can also be a configuration array for creating the object.
30 | */
31 | public $db = 'db';
32 |
33 |
34 | /**
35 | * Initializes generic database table based mutex implementation.
36 | * @throws InvalidConfigException if [[db]] is invalid.
37 | */
38 | public function init()
39 | {
40 | parent::init();
41 | $this->db = Instance::ensure($this->db, Connection::className());
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/framework/mutex/MysqlMutex.php:
--------------------------------------------------------------------------------
1 | [
21 | * 'db' => [
22 | * 'class' => 'yii\db\Connection',
23 | * 'dsn' => 'mysql:host=127.0.0.1;dbname=demo',
24 | * ]
25 | * 'mutex' => [
26 | * 'class' => 'yii\mutex\MysqlMutex',
27 | * ],
28 | * ],
29 | * ]
30 | * ```
31 | *
32 | * @see Mutex
33 | *
34 | * @author resurtm
35 | * @since 2.0
36 | */
37 | class MysqlMutex extends DbMutex
38 | {
39 | /**
40 | * Initializes MySQL specific mutex component implementation.
41 | * @throws InvalidConfigException if [[db]] is not MySQL connection.
42 | */
43 | public function init()
44 | {
45 | parent::init();
46 | if ($this->db->driverName !== 'mysql') {
47 | throw new InvalidConfigException('In order to use MysqlMutex connection must be configured to use MySQL database.');
48 | }
49 | }
50 |
51 | /**
52 | * Acquires lock by given name.
53 | * @param string $name of the lock to be acquired.
54 | * @param integer $timeout to wait for lock to become released.
55 | * @return boolean acquiring result.
56 | * @see http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_get-lock
57 | */
58 | protected function acquireLock($name, $timeout = 0)
59 | {
60 | return (bool) $this->db
61 | ->createCommand('SELECT GET_LOCK(:name, :timeout)', [':name' => $name, ':timeout' => $timeout])
62 | ->queryScalar();
63 | }
64 |
65 | /**
66 | * Releases lock by given name.
67 | * @param string $name of the lock to be released.
68 | * @return boolean release result.
69 | * @see http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_release-lock
70 | */
71 | protected function releaseLock($name)
72 | {
73 | return (bool) $this->db
74 | ->createCommand('SELECT RELEASE_LOCK(:name)', [':name' => $name])
75 | ->queryScalar();
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/framework/rbac/Assignment.php:
--------------------------------------------------------------------------------
1 |
17 | * @author Alexander Kochetov
18 | * @since 2.0
19 | */
20 | class Assignment extends Object
21 | {
22 | /**
23 | * @var string|integer user ID (see [[\yii\web\User::id]])
24 | */
25 | public $userId;
26 | /**
27 | * @var string the role name
28 | */
29 | public $roleName;
30 | /**
31 | * @var integer UNIX timestamp representing the assignment creation time
32 | */
33 | public $createdAt;
34 | }
35 |
--------------------------------------------------------------------------------
/framework/rbac/Item.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class Item extends Object
17 | {
18 | const TYPE_ROLE = 1;
19 | const TYPE_PERMISSION = 2;
20 |
21 | /**
22 | * @var integer the type of the item. This should be either [[TYPE_ROLE]] or [[TYPE_PERMISSION]].
23 | */
24 | public $type;
25 | /**
26 | * @var string the name of the item. This must be globally unique.
27 | */
28 | public $name;
29 | /**
30 | * @var string the item description
31 | */
32 | public $description;
33 | /**
34 | * @var string name of the rule associated with this item
35 | */
36 | public $ruleName;
37 | /**
38 | * @var mixed the additional data associated with this item
39 | */
40 | public $data;
41 | /**
42 | * @var integer UNIX timestamp representing the item creation time
43 | */
44 | public $createdAt;
45 | /**
46 | * @var integer UNIX timestamp representing the item updating time
47 | */
48 | public $updatedAt;
49 | }
50 |
--------------------------------------------------------------------------------
/framework/rbac/Permission.php:
--------------------------------------------------------------------------------
1 |
12 | * @since 2.0
13 | */
14 | class Permission extends Item
15 | {
16 | /**
17 | * @inheritdoc
18 | */
19 | public $type = self::TYPE_PERMISSION;
20 | }
21 |
--------------------------------------------------------------------------------
/framework/rbac/Role.php:
--------------------------------------------------------------------------------
1 |
12 | * @since 2.0
13 | */
14 | class Role extends Item
15 | {
16 | /**
17 | * @inheritdoc
18 | */
19 | public $type = self::TYPE_ROLE;
20 | }
21 |
--------------------------------------------------------------------------------
/framework/rbac/Rule.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | abstract class Rule extends Object
19 | {
20 | /**
21 | * @var string name of the rule
22 | */
23 | public $name;
24 | /**
25 | * @var integer UNIX timestamp representing the rule creation time
26 | */
27 | public $createdAt;
28 | /**
29 | * @var integer UNIX timestamp representing the rule updating time
30 | */
31 | public $updatedAt;
32 |
33 |
34 | /**
35 | * Executes the rule.
36 | *
37 | * @param string|integer $user the user ID. This should be either an integer or a string representing
38 | * the unique identifier of a user. See [[\yii\web\User::id]].
39 | * @param Item $item the role or permission that this rule is associated with
40 | * @param array $params parameters passed to [[ManagerInterface::checkAccess()]].
41 | * @return boolean a value indicating whether the rule permits the auth item it is associated with.
42 | */
43 | abstract public function execute($user, $item, $params);
44 | }
45 |
--------------------------------------------------------------------------------
/framework/rbac/migrations/schema-mysql.sql:
--------------------------------------------------------------------------------
1 | /**
2 | * Database schema required by \yii\rbac\DbManager.
3 | *
4 | * @author Qiang Xue
5 | * @author Alexander Kochetov
6 | * @link http://www.yiiframework.com/
7 | * @copyright 2008 Yii Software LLC
8 | * @license http://www.yiiframework.com/license/
9 | * @since 2.0
10 | */
11 |
12 | drop table if exists `auth_assignment`;
13 | drop table if exists `auth_item_child`;
14 | drop table if exists `auth_item`;
15 | drop table if exists `auth_rule`;
16 |
17 | create table `auth_rule`
18 | (
19 | `name` varchar(64) not null,
20 | `data` text,
21 | `created_at` integer,
22 | `updated_at` integer,
23 | primary key (`name`)
24 | ) engine InnoDB;
25 |
26 | create table `auth_item`
27 | (
28 | `name` varchar(64) not null,
29 | `type` integer not null,
30 | `description` text,
31 | `rule_name` varchar(64),
32 | `data` text,
33 | `created_at` integer,
34 | `updated_at` integer,
35 | primary key (`name`),
36 | foreign key (`rule_name`) references `auth_rule` (`name`) on delete set null on update cascade,
37 | key `type` (`type`)
38 | ) engine InnoDB;
39 |
40 | create table `auth_item_child`
41 | (
42 | `parent` varchar(64) not null,
43 | `child` varchar(64) not null,
44 | primary key (`parent`, `child`),
45 | foreign key (`parent`) references `auth_item` (`name`) on delete cascade on update cascade,
46 | foreign key (`child`) references `auth_item` (`name`) on delete cascade on update cascade
47 | ) engine InnoDB;
48 |
49 | create table `auth_assignment`
50 | (
51 | `item_name` varchar(64) not null,
52 | `user_id` varchar(64) not null,
53 | `created_at` integer,
54 | primary key (`item_name`, `user_id`),
55 | foreign key (`item_name`) references `auth_item` (`name`) on delete cascade on update cascade
56 | ) engine InnoDB;
57 |
--------------------------------------------------------------------------------
/framework/rbac/migrations/schema-oci.sql:
--------------------------------------------------------------------------------
1 | /**
2 | * Database schema required by \yii\rbac\DbManager.
3 | *
4 | * @author Qiang Xue
5 | * @author Alexander Kochetov
6 | * @link http://www.yiiframework.com/
7 | * @copyright 2008 Yii Software LLC
8 | * @license http://www.yiiframework.com/license/
9 | * @since 2.0
10 | */
11 |
12 | drop table if exists "auth_assignment";
13 | drop table if exists "auth_item_child";
14 | drop table if exists "auth_item";
15 | drop table if exists "auth_rule";
16 |
17 | create table "auth_rule"
18 | (
19 | "name" varchar(64) not null,
20 | "data" text,
21 | "created_at" integer,
22 | "updated_at" integer,
23 | primary key ("name")
24 | );
25 |
26 | create table "auth_item"
27 | (
28 | "name" varchar(64) not null,
29 | "type" integer not null,
30 | "description" text,
31 | "rule_name" varchar(64),
32 | "data" text,
33 | "created_at" integer,
34 | "updated_at" integer,
35 | primary key ("name"),
36 | foreign key ("rule_name") references "auth_rule" ("name") on delete set null on update cascade,
37 | key "type" ("type")
38 | );
39 |
40 | create table "auth_item_child"
41 | (
42 | "parent" varchar(64) not null,
43 | "child" varchar(64) not null,
44 | primary key ("parent","child"),
45 | foreign key ("parent") references "auth_item" ("name") on delete cascade on update cascade,
46 | foreign key ("child") references "auth_item" ("name") on delete cascade on update cascade
47 | );
48 |
49 | create table "auth_assignment"
50 | (
51 | "item_name" varchar(64) not null,
52 | "user_id" varchar(64) not null,
53 | "created_at" integer,
54 | primary key ("item_name","user_id"),
55 | foreign key ("item_name") references "auth_item" ("name") on delete cascade on update cascade
56 | );
57 |
--------------------------------------------------------------------------------
/framework/rbac/migrations/schema-pgsql.sql:
--------------------------------------------------------------------------------
1 | /**
2 | * Database schema required by \yii\rbac\DbManager.
3 | *
4 | * @author Qiang Xue
5 | * @author Alexander Kochetov
6 | * @link http://www.yiiframework.com/
7 | * @copyright 2008 Yii Software LLC
8 | * @license http://www.yiiframework.com/license/
9 | * @since 2.0
10 | */
11 |
12 | drop table if exists "auth_assignment";
13 | drop table if exists "auth_item_child";
14 | drop table if exists "auth_item";
15 | drop table if exists "auth_rule";
16 |
17 | create table "auth_rule"
18 | (
19 | "name" varchar(64) not null,
20 | "data" text,
21 | "created_at" integer,
22 | "updated_at" integer,
23 | primary key ("name")
24 | );
25 |
26 | create table "auth_item"
27 | (
28 | "name" varchar(64) not null,
29 | "type" integer not null,
30 | "description" text,
31 | "rule_name" varchar(64),
32 | "data" text,
33 | "created_at" integer,
34 | "updated_at" integer,
35 | primary key ("name"),
36 | foreign key ("rule_name") references "auth_rule" ("name") on delete set null on update cascade
37 | );
38 |
39 | create index auth_item_type_idx on "auth_item" ("type");
40 |
41 | create table "auth_item_child"
42 | (
43 | "parent" varchar(64) not null,
44 | "child" varchar(64) not null,
45 | primary key ("parent","child"),
46 | foreign key ("parent") references "auth_item" ("name") on delete cascade on update cascade,
47 | foreign key ("child") references "auth_item" ("name") on delete cascade on update cascade
48 | );
49 |
50 | create table "auth_assignment"
51 | (
52 | "item_name" varchar(64) not null,
53 | "user_id" varchar(64) not null,
54 | "created_at" integer,
55 | primary key ("item_name","user_id"),
56 | foreign key ("item_name") references "auth_item" ("name") on delete cascade on update cascade
57 | );
58 |
--------------------------------------------------------------------------------
/framework/rbac/migrations/schema-sqlite.sql:
--------------------------------------------------------------------------------
1 | /**
2 | * Database schema required by \yii\rbac\DbManager.
3 | *
4 | * @author Qiang Xue
5 | * @author Alexander Kochetov
6 | * @link http://www.yiiframework.com/
7 | * @copyright 2008 Yii Software LLC
8 | * @license http://www.yiiframework.com/license/
9 | * @since 2.0
10 | */
11 |
12 | drop table if exists "auth_assignment";
13 | drop table if exists "auth_item_child";
14 | drop table if exists "auth_item";
15 | drop table if exists "auth_rule";
16 |
17 | create table "auth_rule"
18 | (
19 | "name" varchar(64) not null,
20 | "data" text,
21 | "created_at" integer,
22 | "updated_at" integer,
23 | primary key ("name")
24 | );
25 |
26 | create table "auth_item"
27 | (
28 | "name" varchar(64) not null,
29 | "type" integer not null,
30 | "description" text,
31 | "rule_name" varchar(64),
32 | "data" text,
33 | "created_at" integer,
34 | "updated_at" integer,
35 | primary key ("name"),
36 | foreign key ("rule_name") references "auth_rule" ("name") on delete set null on update cascade
37 | );
38 |
39 | create index "auth_item_type_idx" on "auth_item" ("type");
40 |
41 | create table "auth_item_child"
42 | (
43 | "parent" varchar(64) not null,
44 | "child" varchar(64) not null,
45 | primary key ("parent","child"),
46 | foreign key ("parent") references "auth_item" ("name") on delete cascade on update cascade,
47 | foreign key ("child") references "auth_item" ("name") on delete cascade on update cascade
48 | );
49 |
50 | create table "auth_assignment"
51 | (
52 | "item_name" varchar(64) not null,
53 | "user_id" varchar(64) not null,
54 | "created_at" integer,
55 | primary key ("item_name","user_id"),
56 | foreign key ("item_name") references "auth_item" ("name") on delete cascade on update cascade
57 | );
58 |
--------------------------------------------------------------------------------
/framework/requirements/views/console/index.php:
--------------------------------------------------------------------------------
1 | $requirement) {
18 | if ($requirement['condition']) {
19 | echo $requirement['name'].": OK\n";
20 | echo "\n";
21 | } else {
22 | echo $requirement['name'].': '.($requirement['mandatory'] ? 'FAILED!!!' : 'WARNING!!!')."\n";
23 | echo 'Required by: '.strip_tags($requirement['by'])."\n";
24 | $memo = strip_tags($requirement['memo']);
25 | if (!empty($memo)) {
26 | echo 'Memo: '.strip_tags($requirement['memo'])."\n";
27 | }
28 | echo "\n";
29 | }
30 | }
31 |
32 | $summaryString = 'Errors: '.$summary['errors'].' Warnings: '.$summary['warnings'].' Total checks: '.$summary['total'];
33 | echo str_pad('', strlen($summaryString), '-')."\n";
34 | echo $summaryString;
35 |
36 | echo "\n\n";
37 |
--------------------------------------------------------------------------------
/framework/rest/CreateAction.php:
--------------------------------------------------------------------------------
1 |
19 | * @since 2.0
20 | */
21 | class CreateAction extends Action
22 | {
23 | /**
24 | * @var string the scenario to be assigned to the new model before it is validated and saved.
25 | */
26 | public $scenario = Model::SCENARIO_DEFAULT;
27 | /**
28 | * @var string the name of the view action. This property is need to create the URL when the model is successfully created.
29 | */
30 | public $viewAction = 'view';
31 |
32 |
33 | /**
34 | * Creates a new model.
35 | * @return \yii\db\ActiveRecordInterface the model newly created
36 | * @throws ServerErrorHttpException if there is any error when creating the model
37 | */
38 | public function run()
39 | {
40 | if ($this->checkAccess) {
41 | call_user_func($this->checkAccess, $this->id);
42 | }
43 |
44 | /* @var $model \yii\db\ActiveRecord */
45 | $model = new $this->modelClass([
46 | 'scenario' => $this->scenario,
47 | ]);
48 |
49 | $model->load(Yii::$app->getRequest()->getBodyParams(), '');
50 | if ($model->save()) {
51 | $response = Yii::$app->getResponse();
52 | $response->setStatusCode(201);
53 | $id = implode(',', array_values($model->getPrimaryKey(true)));
54 | $response->getHeaders()->set('Location', Url::toRoute([$this->viewAction, 'id' => $id], true));
55 | } elseif (!$model->hasErrors()) {
56 | throw new ServerErrorHttpException('Failed to create the object for unknown reason.');
57 | }
58 |
59 | return $model;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/framework/rest/DeleteAction.php:
--------------------------------------------------------------------------------
1 |
17 | * @since 2.0
18 | */
19 | class DeleteAction extends Action
20 | {
21 | /**
22 | * Deletes a model.
23 | * @param mixed $id id of the model to be deleted.
24 | * @throws ServerErrorHttpException on failure.
25 | */
26 | public function run($id)
27 | {
28 | $model = $this->findModel($id);
29 |
30 | if ($this->checkAccess) {
31 | call_user_func($this->checkAccess, $this->id, $model);
32 | }
33 |
34 | if ($model->delete() === false) {
35 | throw new ServerErrorHttpException('Failed to delete the object for unknown reason.');
36 | }
37 |
38 | Yii::$app->getResponse()->setStatusCode(204);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/framework/rest/IndexAction.php:
--------------------------------------------------------------------------------
1 |
15 | * @since 2.0
16 | */
17 | class IndexAction extends Action
18 | {
19 | /**
20 | * @var callable a PHP callable that will be called to prepare a data provider that
21 | * should return a collection of the models. If not set, [[prepareDataProvider()]] will be used instead.
22 | * The signature of the callable should be:
23 | *
24 | * ```php
25 | * function ($action) {
26 | * // $action is the action object currently running
27 | * }
28 | * ```
29 | *
30 | * The callable should return an instance of [[ActiveDataProvider]].
31 | */
32 | public $prepareDataProvider;
33 |
34 |
35 | /**
36 | * @return ActiveDataProvider
37 | */
38 | public function run()
39 | {
40 | if ($this->checkAccess) {
41 | call_user_func($this->checkAccess, $this->id);
42 | }
43 |
44 | return $this->prepareDataProvider();
45 | }
46 |
47 | /**
48 | * Prepares the data provider that should return the requested collection of the models.
49 | * @return ActiveDataProvider
50 | */
51 | protected function prepareDataProvider()
52 | {
53 | if ($this->prepareDataProvider !== null) {
54 | return call_user_func($this->prepareDataProvider, $this);
55 | }
56 |
57 | /* @var $modelClass \yii\db\BaseActiveRecord */
58 | $modelClass = $this->modelClass;
59 |
60 | return new ActiveDataProvider([
61 | 'query' => $modelClass::find(),
62 | ]);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/framework/rest/OptionsAction.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | class OptionsAction extends \yii\base\Action
19 | {
20 | /**
21 | * @var array the HTTP verbs that are supported by the collection URL
22 | */
23 | public $collectionOptions = ['GET', 'POST', 'HEAD', 'OPTIONS'];
24 | /**
25 | * @var array the HTTP verbs that are supported by the resource URL
26 | */
27 | public $resourceOptions = ['GET', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'];
28 |
29 |
30 | /**
31 | * Responds to the OPTIONS request.
32 | * @param string $id
33 | */
34 | public function run($id = null)
35 | {
36 | if (Yii::$app->getRequest()->getMethod() !== 'OPTIONS') {
37 | Yii::$app->getResponse()->setStatusCode(405);
38 | }
39 | $options = $id === null ? $this->collectionOptions : $this->resourceOptions;
40 | Yii::$app->getResponse()->getHeaders()->set('Allow', implode(', ', $options));
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/framework/rest/UpdateAction.php:
--------------------------------------------------------------------------------
1 |
19 | * @since 2.0
20 | */
21 | class UpdateAction extends Action
22 | {
23 | /**
24 | * @var string the scenario to be assigned to the model before it is validated and updated.
25 | */
26 | public $scenario = Model::SCENARIO_DEFAULT;
27 |
28 |
29 | /**
30 | * Updates an existing model.
31 | * @param string $id the primary key of the model.
32 | * @return \yii\db\ActiveRecordInterface the model being updated
33 | * @throws ServerErrorHttpException if there is any error when updating the model
34 | */
35 | public function run($id)
36 | {
37 | /* @var $model ActiveRecord */
38 | $model = $this->findModel($id);
39 |
40 | if ($this->checkAccess) {
41 | call_user_func($this->checkAccess, $this->id, $model);
42 | }
43 |
44 | $model->scenario = $this->scenario;
45 | $model->load(Yii::$app->getRequest()->getBodyParams(), '');
46 | if ($model->save() === false && !$model->hasErrors()) {
47 | throw new ServerErrorHttpException('Failed to update the object for unknown reason.');
48 | }
49 |
50 | return $model;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/framework/rest/ViewAction.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | class ViewAction extends Action
19 | {
20 | /**
21 | * Displays a model.
22 | * @param string $id the primary key of the model.
23 | * @return \yii\db\ActiveRecordInterface the model being displayed
24 | */
25 | public function run($id)
26 | {
27 | $model = $this->findModel($id);
28 | if ($this->checkAccess) {
29 | call_user_func($this->checkAccess, $this->id, $model);
30 | }
31 |
32 | return $model;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/framework/test/ArrayFixture.php:
--------------------------------------------------------------------------------
1 |
18 | * @since 2.0
19 | */
20 | class ArrayFixture extends Fixture implements \IteratorAggregate, \ArrayAccess, \Countable
21 | {
22 | use ArrayAccessTrait;
23 |
24 | /**
25 | * @var array the data rows. Each array element represents one row of data (column name => column value).
26 | */
27 | public $data = [];
28 | /**
29 | * @var string|boolean the file path or path alias of the data file that contains the fixture data
30 | * to be returned by [[getData()]]. You can set this property to be false to prevent loading any data.
31 | */
32 | public $dataFile;
33 |
34 |
35 | /**
36 | * Loads the fixture.
37 | *
38 | * The default implementation simply stores the data returned by [[getData()]] in [[data]].
39 | * You should usually override this method by putting the data into the underlying database.
40 | */
41 | public function load()
42 | {
43 | $this->data = $this->getData();
44 | }
45 |
46 | /**
47 | * Returns the fixture data.
48 | *
49 | * The default implementation will try to return the fixture data by including the external file specified by [[dataFile]].
50 | * The file should return the data array that will be stored in [[data]] after inserting into the database.
51 | *
52 | * @return array the data to be put into the database
53 | * @throws InvalidConfigException if the specified data file does not exist.
54 | */
55 | protected function getData()
56 | {
57 | if ($this->dataFile === false || $this->dataFile === null) {
58 | return [];
59 | }
60 | $dataFile = Yii::getAlias($this->dataFile);
61 | if (is_file($dataFile)) {
62 | return require($dataFile);
63 | } else {
64 | throw new InvalidConfigException("Fixture data file does not exist: {$this->dataFile}");
65 | }
66 | }
67 |
68 | /**
69 | * @inheritdoc
70 | */
71 | public function unload()
72 | {
73 | parent::unload();
74 | $this->data = [];
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/framework/test/DbFixture.php:
--------------------------------------------------------------------------------
1 |
21 | * @since 2.0
22 | */
23 | abstract class DbFixture extends Fixture
24 | {
25 | /**
26 | * @var Connection|array|string the DB connection object or the application component ID of the DB connection.
27 | * After the DbFixture object is created, if you want to change this property, you should only assign it
28 | * with a DB connection object.
29 | * Starting from version 2.0.2, this can also be a configuration array for creating the object.
30 | */
31 | public $db = 'db';
32 |
33 |
34 | /**
35 | * @inheritdoc
36 | */
37 | public function init()
38 | {
39 | parent::init();
40 | $this->db = Instance::ensure($this->db, Object::className());
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/framework/test/Fixture.php:
--------------------------------------------------------------------------------
1 |
28 | * @since 2.0
29 | */
30 | class Fixture extends Component
31 | {
32 | /**
33 | * @var array the fixtures that this fixture depends on. This must be a list of the dependent
34 | * fixture class names.
35 | */
36 | public $depends = [];
37 |
38 |
39 | /**
40 | * Loads the fixture.
41 | * This method is called before performing every test method.
42 | * You should override this method with concrete implementation about how to set up the fixture.
43 | */
44 | public function load()
45 | {
46 | }
47 |
48 | /**
49 | * This method is called BEFORE any fixture data is loaded for the current test.
50 | */
51 | public function beforeLoad()
52 | {
53 | }
54 |
55 | /**
56 | * This method is called AFTER all fixture data have been loaded for the current test.
57 | */
58 | public function afterLoad()
59 | {
60 | }
61 |
62 | /**
63 | * Unloads the fixture.
64 | * This method is called after every test method finishes.
65 | * You may override this method to perform necessary cleanup work for the fixture.
66 | */
67 | public function unload()
68 | {
69 | }
70 |
71 | /**
72 | * This method is called BEFORE any fixture data is unloaded for the current test.
73 | */
74 | public function beforeUnload()
75 | {
76 | }
77 |
78 | /**
79 | * This method is called AFTER all fixture data have been unloaded for the current test.
80 | */
81 | public function afterUnload()
82 | {
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/framework/validators/DefaultValueValidator.php:
--------------------------------------------------------------------------------
1 |
17 | * @since 2.0
18 | */
19 | class DefaultValueValidator extends Validator
20 | {
21 | /**
22 | * @var mixed the default value or an anonymous function that returns the default value which will
23 | * be assigned to the attributes being validated if they are empty. The signature of the anonymous function
24 | * should be as follows,
25 | *
26 | * ```php
27 | * function($model, $attribute) {
28 | * // compute value
29 | * return $value;
30 | * }
31 | * ```
32 | */
33 | public $value;
34 | /**
35 | * @var boolean this property is overwritten to be false so that this validator will
36 | * be applied when the value being validated is empty.
37 | */
38 | public $skipOnEmpty = false;
39 |
40 |
41 | /**
42 | * @inheritdoc
43 | */
44 | public function validateAttribute($model, $attribute)
45 | {
46 | if ($this->isEmpty($model->$attribute)) {
47 | if ($this->value instanceof \Closure) {
48 | $model->$attribute = call_user_func($this->value, $model, $attribute);
49 | } else {
50 | $model->$attribute = $this->value;
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/framework/validators/InlineValidator.php:
--------------------------------------------------------------------------------
1 |
23 | * @since 2.0
24 | */
25 | class InlineValidator extends Validator
26 | {
27 | /**
28 | * @var string|\Closure an anonymous function or the name of a model class method that will be
29 | * called to perform the actual validation. The signature of the method should be like the following,
30 | * where `$attribute` is the name of the attribute to be validated, and `$params` contains the value
31 | * of [[params]] that you specify when declaring the inline validation rule:
32 | *
33 | * ```php
34 | * function foo($attribute, $params)
35 | * ```
36 | */
37 | public $method;
38 | /**
39 | * @var mixed additional parameters that are passed to the validation method
40 | */
41 | public $params;
42 | /**
43 | * @var string|\Closure an anonymous function or the name of a model class method that returns the client validation code.
44 | * The signature of the method should be like the following:
45 | *
46 | * ```php
47 | * function foo($attribute, $params)
48 | * {
49 | * return "javascript";
50 | * }
51 | * ```
52 | *
53 | * where `$attribute` refers to the attribute name to be validated.
54 | *
55 | * Please refer to [[clientValidateAttribute()]] for details on how to return client validation code.
56 | */
57 | public $clientValidate;
58 |
59 |
60 | /**
61 | * @inheritdoc
62 | */
63 | public function validateAttribute($model, $attribute)
64 | {
65 | $method = $this->method;
66 | if (is_string($method)) {
67 | $method = [$model, $method];
68 | }
69 | call_user_func($method, $attribute, $this->params);
70 | }
71 |
72 | /**
73 | * @inheritdoc
74 | */
75 | public function clientValidateAttribute($model, $attribute, $view)
76 | {
77 | if ($this->clientValidate !== null) {
78 | $method = $this->clientValidate;
79 | if (is_string($method)) {
80 | $method = [$model, $method];
81 | }
82 |
83 | return call_user_func($method, $attribute, $this->params);
84 | } else {
85 | return null;
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/framework/validators/PunycodeAsset.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | class PunycodeAsset extends AssetBundle
19 | {
20 | public $sourcePath = '@bower/punycode';
21 | public $js = [
22 | 'punycode.js',
23 | ];
24 | }
25 |
--------------------------------------------------------------------------------
/framework/validators/RegularExpressionValidator.php:
--------------------------------------------------------------------------------
1 |
22 | * @since 2.0
23 | */
24 | class RegularExpressionValidator extends Validator
25 | {
26 | /**
27 | * @var string the regular expression to be matched with
28 | */
29 | public $pattern;
30 | /**
31 | * @var boolean whether to invert the validation logic. Defaults to false. If set to true,
32 | * the regular expression defined via [[pattern]] should NOT match the attribute value.
33 | */
34 | public $not = false;
35 |
36 |
37 | /**
38 | * @inheritdoc
39 | */
40 | public function init()
41 | {
42 | parent::init();
43 | if ($this->pattern === null) {
44 | throw new InvalidConfigException('The "pattern" property must be set.');
45 | }
46 | if ($this->message === null) {
47 | $this->message = Yii::t('yii', '{attribute} is invalid.');
48 | }
49 | }
50 |
51 | /**
52 | * @inheritdoc
53 | */
54 | protected function validateValue($value)
55 | {
56 | $valid = !is_array($value) &&
57 | (!$this->not && preg_match($this->pattern, $value)
58 | || $this->not && !preg_match($this->pattern, $value));
59 |
60 | return $valid ? null : [$this->message, []];
61 | }
62 |
63 | /**
64 | * @inheritdoc
65 | */
66 | public function clientValidateAttribute($model, $attribute, $view)
67 | {
68 | $pattern = Html::escapeJsRegularExpression($this->pattern);
69 |
70 | $options = [
71 | 'pattern' => new JsExpression($pattern),
72 | 'not' => $this->not,
73 | 'message' => Yii::$app->getI18n()->format($this->message, [
74 | 'attribute' => $model->getAttributeLabel($attribute),
75 | ], Yii::$app->language),
76 | ];
77 | if ($this->skipOnEmpty) {
78 | $options['skipOnEmpty'] = 1;
79 | }
80 |
81 | ValidationAsset::register($view);
82 |
83 | return 'yii.validation.regularExpression(value, messages, ' . Json::htmlEncode($options) . ');';
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/framework/validators/SafeValidator.php:
--------------------------------------------------------------------------------
1 |
22 | * @since 2.0
23 | */
24 | class SafeValidator extends Validator
25 | {
26 | /**
27 | * @inheritdoc
28 | */
29 | public function validateAttribute($model, $attribute)
30 | {
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/framework/validators/ValidationAsset.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | class ValidationAsset extends AssetBundle
19 | {
20 | public $sourcePath = '@yii/assets';
21 | public $js = [
22 | 'yii.validation.js',
23 | ];
24 | public $depends = [
25 | 'yii\web\YiiAsset',
26 | ];
27 | }
28 |
--------------------------------------------------------------------------------
/framework/views/addColumnMigration.php:
--------------------------------------------------------------------------------
1 |
12 |
13 | use yii\db\Migration;
14 |
15 | class = $className ?> extends Migration
16 | {
17 | public function up()
18 | {
19 |
20 | $this->addColumn(= "'$table', '" . $field['property'] . "', \$this->" . $field['decorators'] ?>);
21 |
22 | }
23 |
24 | public function down()
25 | {
26 |
27 | $this->dropColumn(= "'$table', '" . $field['property'] . "'" ?>);
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/framework/views/createJunctionMigration.php:
--------------------------------------------------------------------------------
1 |
13 |
14 | use yii\db\Migration;
15 |
16 | class = $className ?> extends Migration
17 | {
18 | public function up()
19 | {
20 | $this->createTable('= $table ?>', [
21 | '= $field_first ?>_id' => $this->integer(),
22 | '= $field_second ?>_id' => $this->integer(),
23 | 'PRIMARY KEY(= $field_first ?>_id, = $field_second ?>_id)'
24 | ]);
25 |
26 | $this->createIndex('idx-= $table . '-' . $field_first ?>_id', '= $table ?>', '= $field_first ?>_id');
27 | $this->createIndex('idx-= $table . '-' . $field_second ?>_id', '= $table ?>', '= $field_second ?>_id');
28 |
29 | $this->addForeignKey('fk-= $table . '-' . $field_first ?>_id', '= $table ?>', '= $field_first ?>_id', '= $field_first ?>', 'id', 'CASCADE');
30 | $this->addForeignKey('fk-= $table . '-' . $field_second ?>_id', '= $table ?>', '= $field_second ?>_id', '= $field_second ?>', 'id', 'CASCADE');
31 | }
32 |
33 | public function down()
34 | {
35 | $this->dropTable('= $table ?>');
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/framework/views/createTableMigration.php:
--------------------------------------------------------------------------------
1 |
12 |
13 | use yii\db\Migration;
14 |
15 | class = $className ?> extends Migration
16 | {
17 | public function up()
18 | {
19 | $this->createTable('= $table ?>', [
20 |
21 |
22 | '= $field['property'] ?>' => $this->= $field['decorators'] . "\n"?>
23 |
24 | '= $field['property'] ?>' => $this->= $field['decorators'] . ",\n"?>
25 |
26 |
27 | ]);
28 | }
29 |
30 | public function down()
31 | {
32 | $this->dropTable('= $table ?>');
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/framework/views/dropColumnMigration.php:
--------------------------------------------------------------------------------
1 |
12 |
13 | use yii\db\Migration;
14 |
15 | class = $className ?> extends Migration
16 | {
17 | public function up()
18 | {
19 |
20 | $this->dropColumn(= "'$table', '" . $field['property'] . "'" ?>);
21 |
22 | }
23 |
24 | public function down()
25 | {
26 |
27 | $this->addColumn(= "'$table', '" . $field['property'] . "', \$this->" . $field['decorators'] ?>);
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/framework/views/dropTableMigration.php:
--------------------------------------------------------------------------------
1 |
12 |
13 | use yii\db\Migration;
14 |
15 | class = $className ?> extends Migration
16 | {
17 | public function up()
18 | {
19 | $this->dropTable('= $table ?>');
20 | }
21 |
22 | public function down()
23 | {
24 | $this->createTable('= $table ?>', [
25 |
26 |
27 | '= $field['property'] ?>' => $this->= $field['decorators'] . "\n"?>
28 |
29 | '= $field['property'] ?>' => $this->= $field['decorators'] . ",\n"?>
30 |
31 |
32 | ]);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/framework/views/errorHandler/callStackItem.php:
--------------------------------------------------------------------------------
1 |
13 |
15 |
16 |
17 | = (int) $index ?>.
18 | htmlEncode($file); ?>
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | = ($class !== null ? $handler->addTypeLinks("$class::$method") : $handler->htmlEncode($method)) . '(' . $handler->argumentsToString($args) . ')' ?>
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
= (int) ($i + 1) ?>
37 |
htmlEncode($lines[$i]);
41 | }
42 | ?>
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/framework/views/errorHandler/error.php:
--------------------------------------------------------------------------------
1 | statusCode;
6 | } else {
7 | $code = $exception->getCode();
8 | }
9 | $name = $handler->getExceptionName($exception);
10 | if ($name === null) {
11 | $name = 'Error';
12 | }
13 | if ($code) {
14 | $name .= " (#$code)";
15 | }
16 |
17 | if ($exception instanceof \yii\base\UserException) {
18 | $message = $exception->getMessage();
19 | } else {
20 | $message = 'An internal server error occurred.';
21 | }
22 |
23 | if (method_exists($this, 'beginPage')) {
24 | $this->beginPage();
25 | }
26 | ?>
27 |
28 |
29 |
30 |
31 | = $handler->htmlEncode($name) ?>
32 |
33 |
69 |
70 |
71 |
72 | = $handler->htmlEncode($name) ?>
73 | = nl2br($handler->htmlEncode($message)) ?>
74 |
75 | The above error occurred while the Web server was processing your request.
76 |
77 |
78 | Please contact us if you think this is a server error. Thank you.
79 |
80 |
81 | = date('Y-m-d H:i:s', time()) ?>
82 |
83 | endBody(); // to allow injecting code into body (mostly by Yii Debug Toolbar)
86 | }
87 | ?>
88 |
89 |
90 | endPage();
93 | }
94 |
--------------------------------------------------------------------------------
/framework/views/errorHandler/previousException.php:
--------------------------------------------------------------------------------
1 |
5 |
6 |
↵
7 |
8 | Caused by:
9 | getExceptionName($exception);
10 | if ($name !== null): ?>
11 | = $handler->htmlEncode($name) ?> –
12 | = $handler->addTypeLinks(get_class($exception)) ?>
13 |
14 | = $handler->htmlEncode(get_class($exception)) ?>
15 |
16 |
17 |
= nl2br($handler->htmlEncode($exception->getMessage())) ?>
18 |
in = $exception->getFile() ?> at line = $exception->getLine() ?>
19 | errorInfo)) {
20 | echo '
Error Info: ' . print_r($exception->errorInfo, true) . '
';
21 | } ?>
22 | = $handler->renderPreviousExceptions($exception) ?>
23 |
24 |
--------------------------------------------------------------------------------
/framework/views/migration.php:
--------------------------------------------------------------------------------
1 |
10 |
11 | use yii\db\Migration;
12 |
13 | class = $className ?> extends Migration
14 | {
15 | public function up()
16 | {
17 |
18 | }
19 |
20 | public function down()
21 | {
22 | echo "= $className ?> cannot be reverted.\n";
23 |
24 | return false;
25 | }
26 |
27 | /*
28 | // Use safeUp/safeDown to run migration code within a transaction
29 | public function safeUp()
30 | {
31 | }
32 |
33 | public function safeDown()
34 | {
35 | }
36 | */
37 | }
38 |
--------------------------------------------------------------------------------
/framework/web/AssetConverterInterface.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | interface AssetConverterInterface
17 | {
18 | /**
19 | * Converts a given asset file into a CSS or JS file.
20 | * @param string $asset the asset file path, relative to $basePath
21 | * @param string $basePath the directory the $asset is relative to.
22 | * @return string the converted asset file path, relative to $basePath.
23 | */
24 | public function convert($asset, $basePath);
25 | }
26 |
--------------------------------------------------------------------------------
/framework/web/BadRequestHttpException.php:
--------------------------------------------------------------------------------
1 |
20 | * @since 2.0
21 | */
22 | class BadRequestHttpException extends HttpException
23 | {
24 | /**
25 | * Constructor.
26 | * @param string $message error message
27 | * @param integer $code error code
28 | * @param \Exception $previous The previous exception used for the exception chaining.
29 | */
30 | public function __construct($message = null, $code = 0, \Exception $previous = null)
31 | {
32 | parent::__construct(400, $message, $code, $previous);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/framework/web/CompositeUrlRule.php:
--------------------------------------------------------------------------------
1 |
17 | * @since 2.0
18 | */
19 | abstract class CompositeUrlRule extends Object implements UrlRuleInterface
20 | {
21 | /**
22 | * @var UrlRuleInterface[] the URL rules contained in this composite rule.
23 | * This property is set in [[init()]] by the return value of [[createRules()]].
24 | */
25 | protected $rules = [];
26 |
27 |
28 | /**
29 | * Creates the URL rules that should be contained within this composite rule.
30 | * @return UrlRuleInterface[] the URL rules
31 | */
32 | abstract protected function createRules();
33 |
34 | /**
35 | * @inheritdoc
36 | */
37 | public function init()
38 | {
39 | parent::init();
40 | $this->rules = $this->createRules();
41 | }
42 |
43 | /**
44 | * @inheritdoc
45 | */
46 | public function parseRequest($manager, $request)
47 | {
48 | foreach ($this->rules as $rule) {
49 | /* @var $rule \yii\web\UrlRule */
50 | if (($result = $rule->parseRequest($manager, $request)) !== false) {
51 | Yii::trace("Request parsed with URL rule: {$rule->name}", __METHOD__);
52 |
53 | return $result;
54 | }
55 | }
56 |
57 | return false;
58 | }
59 |
60 | /**
61 | * @inheritdoc
62 | */
63 | public function createUrl($manager, $route, $params)
64 | {
65 | foreach ($this->rules as $rule) {
66 | /* @var $rule \yii\web\UrlRule */
67 | if (($url = $rule->createUrl($manager, $route, $params)) !== false) {
68 | return $url;
69 | }
70 | }
71 |
72 | return false;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/framework/web/ConflictHttpException.php:
--------------------------------------------------------------------------------
1 |
15 | * @since 2.0
16 | */
17 | class ConflictHttpException extends HttpException
18 | {
19 | /**
20 | * Constructor.
21 | * @param string $message error message
22 | * @param integer $code error code
23 | * @param \Exception $previous The previous exception used for the exception chaining.
24 | */
25 | public function __construct($message = null, $code = 0, \Exception $previous = null)
26 | {
27 | parent::__construct(409, $message, $code, $previous);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/framework/web/Cookie.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class Cookie extends \yii\base\Object
17 | {
18 | /**
19 | * @var string name of the cookie
20 | */
21 | public $name;
22 | /**
23 | * @var string value of the cookie
24 | */
25 | public $value = '';
26 | /**
27 | * @var string domain of the cookie
28 | */
29 | public $domain = '';
30 | /**
31 | * @var integer the timestamp at which the cookie expires. This is the server timestamp.
32 | * Defaults to 0, meaning "until the browser is closed".
33 | */
34 | public $expire = 0;
35 | /**
36 | * @var string the path on the server in which the cookie will be available on. The default is '/'.
37 | */
38 | public $path = '/';
39 | /**
40 | * @var boolean whether cookie should be sent via secure connection
41 | */
42 | public $secure = false;
43 | /**
44 | * @var boolean whether the cookie should be accessible only through the HTTP protocol.
45 | * By setting this property to true, the cookie will not be accessible by scripting languages,
46 | * such as JavaScript, which can effectively help to reduce identity theft through XSS attacks.
47 | */
48 | public $httpOnly = true;
49 |
50 |
51 | /**
52 | * Magic method to turn a cookie object into a string without having to explicitly access [[value]].
53 | *
54 | * ```php
55 | * if (isset($request->cookies['name'])) {
56 | * $value = (string) $request->cookies['name'];
57 | * }
58 | * ```
59 | *
60 | * @return string The value of the cookie. If the value property is null, an empty string will be returned.
61 | */
62 | public function __toString()
63 | {
64 | return (string) $this->value;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/framework/web/ForbiddenHttpException.php:
--------------------------------------------------------------------------------
1 |
21 | * @since 2.0
22 | */
23 | class ForbiddenHttpException extends HttpException
24 | {
25 | /**
26 | * Constructor.
27 | * @param string $message error message
28 | * @param integer $code error code
29 | * @param \Exception $previous The previous exception used for the exception chaining.
30 | */
31 | public function __construct($message = null, $code = 0, \Exception $previous = null)
32 | {
33 | parent::__construct(403, $message, $code, $previous);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/framework/web/GoneHttpException.php:
--------------------------------------------------------------------------------
1 |
20 | * @since 2.0
21 | */
22 | class GoneHttpException extends HttpException
23 | {
24 | /**
25 | * Constructor.
26 | * @param string $message error message
27 | * @param integer $code error code
28 | * @param \Exception $previous The previous exception used for the exception chaining.
29 | */
30 | public function __construct($message = null, $code = 0, \Exception $previous = null)
31 | {
32 | parent::__construct(410, $message, $code, $previous);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/framework/web/HtmlResponseFormatter.php:
--------------------------------------------------------------------------------
1 |
18 | * @since 2.0
19 | */
20 | class HtmlResponseFormatter extends Component implements ResponseFormatterInterface
21 | {
22 | /**
23 | * @var string the Content-Type header for the response
24 | */
25 | public $contentType = 'text/html';
26 |
27 |
28 | /**
29 | * Formats the specified response.
30 | * @param Response $response the response to be formatted.
31 | */
32 | public function format($response)
33 | {
34 | if (stripos($this->contentType, 'charset') === false) {
35 | $this->contentType .= '; charset=' . $response->charset;
36 | }
37 | $response->getHeaders()->set('Content-Type', $this->contentType);
38 | if ($response->data !== null) {
39 | $response->content = $response->data;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/framework/web/HttpException.php:
--------------------------------------------------------------------------------
1 |
28 | * @since 2.0
29 | */
30 | class HttpException extends UserException
31 | {
32 | /**
33 | * @var integer HTTP status code, such as 403, 404, 500, etc.
34 | */
35 | public $statusCode;
36 |
37 |
38 | /**
39 | * Constructor.
40 | * @param integer $status HTTP status code, such as 404, 500, etc.
41 | * @param string $message error message
42 | * @param integer $code error code
43 | * @param \Exception $previous The previous exception used for the exception chaining.
44 | */
45 | public function __construct($status, $message = null, $code = 0, \Exception $previous = null)
46 | {
47 | $this->statusCode = $status;
48 | parent::__construct($message, $code, $previous);
49 | }
50 |
51 | /**
52 | * @return string the user-friendly name of this exception
53 | */
54 | public function getName()
55 | {
56 | if (isset(Response::$httpStatuses[$this->statusCode])) {
57 | return Response::$httpStatuses[$this->statusCode];
58 | } else {
59 | return 'Error';
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/framework/web/JqueryAsset.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class JqueryAsset extends AssetBundle
17 | {
18 | public $sourcePath = '@bower/jquery/dist';
19 | public $js = [
20 | 'jquery.js',
21 | ];
22 | }
23 |
--------------------------------------------------------------------------------
/framework/web/JsExpression.php:
--------------------------------------------------------------------------------
1 |
19 | * @since 2.0
20 | */
21 | class JsExpression extends Object
22 | {
23 | /**
24 | * @var string the JavaScript expression represented by this object
25 | */
26 | public $expression;
27 |
28 |
29 | /**
30 | * Constructor.
31 | * @param string $expression the JavaScript expression represented by this object
32 | * @param array $config additional configurations for this object
33 | */
34 | public function __construct($expression, $config = [])
35 | {
36 | $this->expression = $expression;
37 | parent::__construct($config);
38 | }
39 |
40 | /**
41 | * The PHP magic function converting an object into a string.
42 | * @return string the JavaScript expression.
43 | */
44 | public function __toString()
45 | {
46 | return $this->expression;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/framework/web/JsonParser.php:
--------------------------------------------------------------------------------
1 | [
20 | * 'parsers' => [
21 | * 'application/json' => 'yii\web\JsonParser',
22 | * ]
23 | * ]
24 | * ```
25 | *
26 | * @author Dan Schmidt
27 | * @since 2.0
28 | */
29 | class JsonParser implements RequestParserInterface
30 | {
31 | /**
32 | * @var boolean whether to return objects in terms of associative arrays.
33 | */
34 | public $asArray = true;
35 | /**
36 | * @var boolean whether to throw a [[BadRequestHttpException]] if the body is invalid json
37 | */
38 | public $throwException = true;
39 |
40 |
41 | /**
42 | * Parses a HTTP request body.
43 | * @param string $rawBody the raw HTTP request body.
44 | * @param string $contentType the content type specified for the request body.
45 | * @return array parameters parsed from the request body
46 | * @throws BadRequestHttpException if the body contains invalid json and [[throwException]] is `true`.
47 | */
48 | public function parse($rawBody, $contentType)
49 | {
50 | try {
51 | return Json::decode($rawBody, $this->asArray);
52 | } catch (InvalidParamException $e) {
53 | if ($this->throwException) {
54 | throw new BadRequestHttpException('Invalid JSON data in request body: ' . $e->getMessage());
55 | }
56 | return null;
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/framework/web/Link.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | class Link extends Object
19 | {
20 | /**
21 | * The self link.
22 | */
23 | const REL_SELF = 'self';
24 |
25 | /**
26 | * @var string a URI [RFC3986](https://tools.ietf.org/html/rfc3986) or
27 | * URI template [RFC6570](https://tools.ietf.org/html/rfc6570). This property is required.
28 | */
29 | public $href;
30 | /**
31 | * @var string a secondary key for selecting Link Objects which share the same relation type
32 | */
33 | public $name;
34 | /**
35 | * @var string a hint to indicate the media type expected when dereferencing the target resource
36 | */
37 | public $type;
38 | /**
39 | * @var boolean a value indicating whether [[href]] refers to a URI or URI template.
40 | */
41 | public $templated = false;
42 | /**
43 | * @var string a URI that hints about the profile of the target resource.
44 | */
45 | public $profile;
46 | /**
47 | * @var string a label describing the link
48 | */
49 | public $title;
50 | /**
51 | * @var string the language of the target resource
52 | */
53 | public $hreflang;
54 |
55 |
56 | /**
57 | * Serializes a list of links into proper array format.
58 | * @param array $links the links to be serialized
59 | * @return array the proper array representation of the links.
60 | */
61 | public static function serialize(array $links)
62 | {
63 | foreach ($links as $rel => $link) {
64 | if (is_array($link)) {
65 | foreach ($link as $i => $l) {
66 | $link[$i] = $l instanceof self ? array_filter((array) $l) : ['href' => $l];
67 | }
68 | $links[$rel] = $link;
69 | } elseif (!$link instanceof self) {
70 | $links[$rel] = ['href' => $link];
71 | }
72 | }
73 |
74 | return $links;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/framework/web/Linkable.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | interface Linkable
17 | {
18 | /**
19 | * Returns a list of links.
20 | *
21 | * Each link is either a URI or a [[Link]] object. The return value of this method should
22 | * be an array whose keys are the relation names and values the corresponding links.
23 | *
24 | * If a relation name corresponds to multiple links, use an array to represent them.
25 | *
26 | * For example,
27 | *
28 | * ```php
29 | * [
30 | * 'self' => 'http://example.com/users/1',
31 | * 'friends' => [
32 | * 'http://example.com/users/2',
33 | * 'http://example.com/users/3',
34 | * ],
35 | * 'manager' => $managerLink, // $managerLink is a Link object
36 | * ]
37 | * ```
38 | *
39 | * @return array the links
40 | */
41 | public function getLinks();
42 | }
43 |
--------------------------------------------------------------------------------
/framework/web/MethodNotAllowedHttpException.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class MethodNotAllowedHttpException extends HttpException
17 | {
18 | /**
19 | * Constructor.
20 | * @param string $message error message
21 | * @param integer $code error code
22 | * @param \Exception $previous The previous exception used for the exception chaining.
23 | */
24 | public function __construct($message = null, $code = 0, \Exception $previous = null)
25 | {
26 | parent::__construct(405, $message, $code, $previous);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/framework/web/NotAcceptableHttpException.php:
--------------------------------------------------------------------------------
1 |
19 | * @since 2.0
20 | */
21 | class NotAcceptableHttpException extends HttpException
22 | {
23 | /**
24 | * Constructor.
25 | * @param string $message error message
26 | * @param integer $code error code
27 | * @param \Exception $previous The previous exception used for the exception chaining.
28 | */
29 | public function __construct($message = null, $code = 0, \Exception $previous = null)
30 | {
31 | parent::__construct(406, $message, $code, $previous);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/framework/web/NotFoundHttpException.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class NotFoundHttpException extends HttpException
17 | {
18 | /**
19 | * Constructor.
20 | * @param string $message error message
21 | * @param integer $code error code
22 | * @param \Exception $previous The previous exception used for the exception chaining.
23 | */
24 | public function __construct($message = null, $code = 0, \Exception $previous = null)
25 | {
26 | parent::__construct(404, $message, $code, $previous);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/framework/web/RequestParserInterface.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | interface RequestParserInterface
17 | {
18 | /**
19 | * Parses a HTTP request body.
20 | * @param string $rawBody the raw HTTP request body.
21 | * @param string $contentType the content type specified for the request body.
22 | * @return array parameters parsed from the request body
23 | */
24 | public function parse($rawBody, $contentType);
25 | }
26 |
--------------------------------------------------------------------------------
/framework/web/ResponseFormatterInterface.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | interface ResponseFormatterInterface
17 | {
18 | /**
19 | * Formats the specified response.
20 | * @param Response $response the response to be formatted.
21 | */
22 | public function format($response);
23 | }
24 |
--------------------------------------------------------------------------------
/framework/web/ServerErrorHttpException.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class ServerErrorHttpException extends HttpException
17 | {
18 | /**
19 | * Constructor.
20 | * @param string $message error message
21 | * @param integer $code error code
22 | * @param \Exception $previous The previous exception used for the exception chaining.
23 | */
24 | public function __construct($message = null, $code = 0, \Exception $previous = null)
25 | {
26 | parent::__construct(500, $message, $code, $previous);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/framework/web/SessionIterator.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class SessionIterator implements \Iterator
17 | {
18 | /**
19 | * @var array list of keys in the map
20 | */
21 | private $_keys;
22 | /**
23 | * @var mixed current key
24 | */
25 | private $_key;
26 |
27 |
28 | /**
29 | * Constructor.
30 | */
31 | public function __construct()
32 | {
33 | $this->_keys = array_keys($_SESSION);
34 | }
35 |
36 | /**
37 | * Rewinds internal array pointer.
38 | * This method is required by the interface [[\Iterator]].
39 | */
40 | public function rewind()
41 | {
42 | $this->_key = reset($this->_keys);
43 | }
44 |
45 | /**
46 | * Returns the key of the current array element.
47 | * This method is required by the interface [[\Iterator]].
48 | * @return mixed the key of the current array element
49 | */
50 | public function key()
51 | {
52 | return $this->_key;
53 | }
54 |
55 | /**
56 | * Returns the current array element.
57 | * This method is required by the interface [[\Iterator]].
58 | * @return mixed the current array element
59 | */
60 | public function current()
61 | {
62 | return isset($_SESSION[$this->_key]) ? $_SESSION[$this->_key] : null;
63 | }
64 |
65 | /**
66 | * Moves the internal pointer to the next array element.
67 | * This method is required by the interface [[\Iterator]].
68 | */
69 | public function next()
70 | {
71 | do {
72 | $this->_key = next($this->_keys);
73 | } while (!isset($_SESSION[$this->_key]) && $this->_key !== false);
74 | }
75 |
76 | /**
77 | * Returns whether there is an element at current position.
78 | * This method is required by the interface [[\Iterator]].
79 | * @return boolean
80 | */
81 | public function valid()
82 | {
83 | return $this->_key !== false;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/framework/web/TooManyRequestsHttpException.php:
--------------------------------------------------------------------------------
1 |
19 | * @since 2.0
20 | */
21 | class TooManyRequestsHttpException extends HttpException
22 | {
23 | /**
24 | * Constructor.
25 | * @param string $message error message
26 | * @param integer $code error code
27 | * @param \Exception $previous The previous exception used for the exception chaining.
28 | */
29 | public function __construct($message = null, $code = 0, \Exception $previous = null)
30 | {
31 | parent::__construct(429, $message, $code, $previous);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/framework/web/UnauthorizedHttpException.php:
--------------------------------------------------------------------------------
1 |
20 | * @since 2.0
21 | */
22 | class UnauthorizedHttpException extends HttpException
23 | {
24 | /**
25 | * Constructor.
26 | * @param string $message error message
27 | * @param integer $code error code
28 | * @param \Exception $previous The previous exception used for the exception chaining.
29 | */
30 | public function __construct($message = null, $code = 0, \Exception $previous = null)
31 | {
32 | parent::__construct(401, $message, $code, $previous);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/framework/web/UnprocessableEntityHttpException.php:
--------------------------------------------------------------------------------
1 |
21 | * @since 2.0.7
22 | */
23 | class UnprocessableEntityHttpException extends HttpException
24 | {
25 | /**
26 | * Constructor.
27 | * @param string $message error message
28 | * @param integer $code error code
29 | * @param \Exception $previous The previous exception used for the exception chaining.
30 | */
31 | public function __construct($message = null, $code = 0, \Exception $previous = null)
32 | {
33 | parent::__construct(422, $message, $code, $previous);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/framework/web/UnsupportedMediaTypeHttpException.php:
--------------------------------------------------------------------------------
1 |
20 | * @since 2.0
21 | */
22 | class UnsupportedMediaTypeHttpException extends HttpException
23 | {
24 | /**
25 | * Constructor.
26 | * @param string $message error message
27 | * @param integer $code error code
28 | * @param \Exception $previous The previous exception used for the exception chaining.
29 | */
30 | public function __construct($message = null, $code = 0, \Exception $previous = null)
31 | {
32 | parent::__construct(415, $message, $code, $previous);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/framework/web/UrlRuleInterface.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | interface UrlRuleInterface
17 | {
18 | /**
19 | * Parses the given request and returns the corresponding route and parameters.
20 | * @param UrlManager $manager the URL manager
21 | * @param Request $request the request component
22 | * @return array|boolean the parsing result. The route and the parameters are returned as an array.
23 | * If false, it means this rule cannot be used to parse this path info.
24 | */
25 | public function parseRequest($manager, $request);
26 |
27 | /**
28 | * Creates a URL according to the given route and parameters.
29 | * @param UrlManager $manager the URL manager
30 | * @param string $route the route. It should not have slashes at the beginning or the end.
31 | * @param array $params the parameters
32 | * @return string|boolean the created URL, or false if this rule cannot be used for creating this URL.
33 | */
34 | public function createUrl($manager, $route, $params);
35 | }
36 |
--------------------------------------------------------------------------------
/framework/web/UserEvent.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | class UserEvent extends Event
19 | {
20 | /**
21 | * @var IdentityInterface the identity object associated with this event
22 | */
23 | public $identity;
24 | /**
25 | * @var boolean whether the login is cookie-based. This property is only meaningful
26 | * for [[User::EVENT_BEFORE_LOGIN]] and [[User::EVENT_AFTER_LOGIN]] events.
27 | */
28 | public $cookieBased;
29 | /**
30 | * @var integer $duration number of seconds that the user can remain in logged-in status.
31 | * If 0, it means login till the user closes the browser or the session is manually destroyed.
32 | */
33 | public $duration;
34 | /**
35 | * @var boolean whether the login or logout should proceed.
36 | * Event handlers may modify this property to determine whether the login or logout should proceed.
37 | * This property is only meaningful for [[User::EVENT_BEFORE_LOGIN]] and [[User::EVENT_BEFORE_LOGOUT]] events.
38 | */
39 | public $isValid = true;
40 | }
41 |
--------------------------------------------------------------------------------
/framework/web/YiiAsset.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class YiiAsset extends AssetBundle
17 | {
18 | public $sourcePath = '@yii/assets';
19 | public $js = [
20 | 'yii.js',
21 | ];
22 | public $depends = [
23 | 'yii\web\JqueryAsset',
24 | ];
25 | }
26 |
--------------------------------------------------------------------------------
/framework/widgets/ActiveFormAsset.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 2.0
15 | */
16 | class ActiveFormAsset extends AssetBundle
17 | {
18 | public $sourcePath = '@yii/assets';
19 | public $js = [
20 | 'yii.activeForm.js',
21 | ];
22 | public $depends = [
23 | 'yii\web\YiiAsset',
24 | ];
25 | }
26 |
--------------------------------------------------------------------------------
/framework/widgets/Block.php:
--------------------------------------------------------------------------------
1 | beginBlock('messages', true) ?>
21 | * Nothing.
22 | * endBlock() ?>
23 | * ```
24 | *
25 | * And then overriding default in sub-views:
26 | *
27 | * ```php
28 | * beginBlock('username') ?>
29 | * Umm... hello?
30 | * endBlock() ?>
31 | * ```
32 | *
33 | * Second parameter defines if block content should be outputted which is desired when rendering its content but isn't
34 | * desired when redefining it in subviews.
35 | *
36 | * @author Qiang Xue
37 | * @since 2.0
38 | */
39 | class Block extends Widget
40 | {
41 | /**
42 | * @var boolean whether to render the block content in place. Defaults to false,
43 | * meaning the captured block content will not be displayed.
44 | */
45 | public $renderInPlace = false;
46 |
47 |
48 | /**
49 | * Starts recording a block.
50 | */
51 | public function init()
52 | {
53 | ob_start();
54 | ob_implicit_flush(false);
55 | }
56 |
57 | /**
58 | * Ends recording a block.
59 | * This method stops output buffering and saves the rendering result as a named block in the view.
60 | */
61 | public function run()
62 | {
63 | $block = ob_get_clean();
64 | if ($this->renderInPlace) {
65 | echo $block;
66 | }
67 | $this->view->blocks[$this->getId()] = $block;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/framework/widgets/ContentDecorator.php:
--------------------------------------------------------------------------------
1 | '@app/views/layouts/base.php',
20 | * 'params' => [],
21 | * 'view' => $this,
22 | * ]) ?>
23 | *
24 | * some content here
25 | *
26 | *
27 | * ```
28 | *
29 | * There are [[\yii\base\View::beginContent()]] and [[\yii\base\View::endContent()]] wrapper methods in the
30 | * [[\yii\base\View]] component to make syntax more friendly. In the view these could be used as follows:
31 | *
32 | * ```php
33 | * beginContent('@app/views/layouts/base.php') ?>
34 | *
35 | * some content here
36 | *
37 | * endContent() ?>
38 | * ```
39 | *
40 | * @author Qiang Xue
41 | * @since 2.0
42 | */
43 | class ContentDecorator extends Widget
44 | {
45 | /**
46 | * @var string the view file that will be used to decorate the content enclosed by this widget.
47 | * This can be specified as either the view file path or path alias.
48 | */
49 | public $viewFile;
50 | /**
51 | * @var array the parameters (name => value) to be extracted and made available in the decorative view.
52 | */
53 | public $params = [];
54 |
55 |
56 | /**
57 | * Starts recording a clip.
58 | */
59 | public function init()
60 | {
61 | if ($this->viewFile === null) {
62 | throw new InvalidConfigException('ContentDecorator::viewFile must be set.');
63 | }
64 | ob_start();
65 | ob_implicit_flush(false);
66 | }
67 |
68 | /**
69 | * Ends recording a clip.
70 | * This method stops output buffering and saves the rendering result as a named clip in the controller.
71 | */
72 | public function run()
73 | {
74 | $params = $this->params;
75 | $params['content'] = ob_get_clean();
76 | // render under the existing context
77 | echo $this->view->renderFile($this->viewFile, $params);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/framework/widgets/InputWidget.php:
--------------------------------------------------------------------------------
1 | field($model, 'from_date')->widget('WidgetClassName', [
28 | * // configure additional widget properties here
29 | * ]) ?>
30 | * ```
31 | *
32 | * @author Qiang Xue
33 | * @since 2.0
34 | */
35 | class InputWidget extends Widget
36 | {
37 | /**
38 | * @var Model the data model that this widget is associated with.
39 | */
40 | public $model;
41 | /**
42 | * @var string the model attribute that this widget is associated with.
43 | */
44 | public $attribute;
45 | /**
46 | * @var string the input name. This must be set if [[model]] and [[attribute]] are not set.
47 | */
48 | public $name;
49 | /**
50 | * @var string the input value.
51 | */
52 | public $value;
53 | /**
54 | * @var array the HTML attributes for the input tag.
55 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
56 | */
57 | public $options = [];
58 |
59 |
60 | /**
61 | * Initializes the widget.
62 | * If you override this method, make sure you call the parent implementation first.
63 | */
64 | public function init()
65 | {
66 | if ($this->name === null && !$this->hasModel()) {
67 | throw new InvalidConfigException("Either 'name', or 'model' and 'attribute' properties must be specified.");
68 | }
69 | if (!isset($this->options['id'])) {
70 | $this->options['id'] = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->getId();
71 | }
72 | parent::init();
73 | }
74 |
75 | /**
76 | * @return boolean whether this widget is associated with a data model.
77 | */
78 | protected function hasModel()
79 | {
80 | return $this->model instanceof Model && $this->attribute !== null;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/framework/widgets/LinkSorter.php:
--------------------------------------------------------------------------------
1 |
22 | * @since 2.0
23 | */
24 | class LinkSorter extends Widget
25 | {
26 | /**
27 | * @var Sort the sort definition
28 | */
29 | public $sort;
30 | /**
31 | * @var array list of the attributes that support sorting. If not set, it will be determined
32 | * using [[Sort::attributes]].
33 | */
34 | public $attributes;
35 | /**
36 | * @var array HTML attributes for the sorter container tag.
37 | * @see \yii\helpers\Html::ul() for special attributes.
38 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
39 | */
40 | public $options = ['class' => 'sorter'];
41 | /**
42 | * @var array HTML attributes for the link in a sorter container tag which are passed to [[Sort::link()]].
43 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
44 | * @since 2.0.6
45 | */
46 | public $linkOptions = [];
47 |
48 |
49 | /**
50 | * Initializes the sorter.
51 | */
52 | public function init()
53 | {
54 | if ($this->sort === null) {
55 | throw new InvalidConfigException('The "sort" property must be set.');
56 | }
57 | }
58 |
59 | /**
60 | * Executes the widget.
61 | * This method renders the sort links.
62 | */
63 | public function run()
64 | {
65 | echo $this->renderSortLinks();
66 | }
67 |
68 | /**
69 | * Renders the sort links.
70 | * @return string the rendering result
71 | */
72 | protected function renderSortLinks()
73 | {
74 | $attributes = empty($this->attributes) ? array_keys($this->sort->attributes) : $this->attributes;
75 | $links = [];
76 | foreach ($attributes as $name) {
77 | $links[] = $this->sort->link($name, $this->linkOptions);
78 | }
79 |
80 | return Html::ul($links, array_merge($this->options, ['encode' => false]));
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/framework/widgets/MaskedInputAsset.php:
--------------------------------------------------------------------------------
1 |
18 | * @since 2.0
19 | */
20 | class MaskedInputAsset extends AssetBundle
21 | {
22 | public $sourcePath = '@bower/jquery.inputmask/dist';
23 | public $js = [
24 | 'jquery.inputmask.bundle.js'
25 | ];
26 | public $depends = [
27 | 'yii\web\YiiAsset'
28 | ];
29 | }
30 |
--------------------------------------------------------------------------------
/framework/widgets/PjaxAsset.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 2.0
17 | */
18 | class PjaxAsset extends AssetBundle
19 | {
20 | public $sourcePath = '@bower/yii2-pjax';
21 | public $js = [
22 | 'jquery.pjax.js',
23 | ];
24 | public $depends = [
25 | 'yii\web\YiiAsset',
26 | ];
27 | }
28 |
--------------------------------------------------------------------------------
/framework/widgets/Spaceless.php:
--------------------------------------------------------------------------------
1 |
20 | *
21 | *
22 | *
23 | *
24 | *
25 | *
26 | *
27 | *
28 | *
35 | *