Commit 1b358723 by Carsten Brandt

Merge branch 'master' of github.com:yiisoft/yii2

* 'master' of github.com:yiisoft/yii2: typo fixed extension list file location. doc fix. moved extension list under yiisoft. updated read me. updated license information. reorganized extension directories. Adjusted jui directories. moved mutex back from extensions. Changed the exit status to normal. Specify the exact type of the exception. Small typos PhpDoc comment Missing return statement Changed php-diff dependency to use code from master (they haven't tagged changes we need yet) Added ability to get all GET, POST, PUT, DELETE or PATCH parameters to Request Add batchInsert method to yii\db\Migration Fixes #1117: added support to map a single view directory to multiple themed view directories. Fixes #1116.
parents c8c377e6 fc05ded1
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008-2013 by Yii Software LLC (http://www.yiisoft.com)
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
......@@ -29,4 +29,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
POSSIBILITY OF SUCH DAMAGE.
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008-2013 by Yii Software LLC (http://www.yiisoft.com)
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
......@@ -29,4 +29,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
POSSIBILITY OF SUCH DAMAGE.
......@@ -15,7 +15,7 @@ return [
'preload' => ['log'],
'controllerNamespace' => 'backend\controllers',
'modules' => [],
'extensions' => require(__DIR__ . '/../../vendor/yii-extensions.php'),
'extensions' => require(__DIR__ . '/../../vendor/yiisoft/extensions.php'),
'components' => [
'request' => [
'enableCsrfValidation' => true,
......
......@@ -15,7 +15,7 @@ return [
'controllerNamespace' => 'console\controllers',
'modules' => [
],
'extensions' => require(__DIR__ . '/../../vendor/yii-extensions.php'),
'extensions' => require(__DIR__ . '/../../vendor/yiisoft/extensions.php'),
'components' => [
'db' => $params['components.db'],
'cache' => $params['components.cache'],
......
......@@ -16,7 +16,7 @@ return [
'modules' => [
'gii' => 'yii\gii\Module'
],
'extensions' => require(__DIR__ . '/../../vendor/yii-extensions.php'),
'extensions' => require(__DIR__ . '/../../vendor/yiisoft/extensions.php'),
'components' => [
'request' => [
'enableCsrfValidation' => true,
......
......@@ -18,7 +18,7 @@ if (empty($params['env'])) {
if (!ctype_digit($answer) || !in_array($answer, range(0, count($envs) - 1))) {
echo "\n Quit initialization.\n";
exit(1);
exit(0);
}
if (isset($envNames[$answer])) {
......@@ -42,7 +42,7 @@ if (empty($params['env'])) {
$answer = trim(fgets(STDIN));
if (strncasecmp($answer, 'y', 1)) {
echo "\n Quit initialization.\n";
exit(1);
exit(0);
}
}
......
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008-2013 by Yii Software LLC (http://www.yiisoft.com)
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
......@@ -29,4 +29,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
POSSIBILITY OF SUCH DAMAGE.
......@@ -6,7 +6,7 @@ return [
'preload' => ['log'],
'controllerPath' => dirname(__DIR__) . '/commands',
'controllerNamespace' => 'app\commands',
'extensions' => require(__DIR__ . '/../vendor/yii-extensions.php'),
'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
......
......@@ -3,7 +3,7 @@ $params = require(__DIR__ . '/params.php');
$config = [
'id' => 'bootstrap',
'basePath' => dirname(__DIR__),
'extensions' => require(__DIR__ . '/../vendor/yii-extensions.php'),
'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
'components' => [
'request' => [
'enableCsrfValidation' => true,
......
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008-2013 by Yii Software LLC (http://www.yiisoft.com)
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
......@@ -29,4 +29,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
POSSIBILITY OF SUCH DAMAGE.
ActiveRecord implements the [Active Record design pattern](http://en.wikipedia.org/wiki/Active_record).
The idea is that an ActiveRecord object is associated with a row in a database table
so object properties are mapped to colums of the corresponding database row.
so object properties are mapped to columns of the corresponding database row.
For example, a `Customer` object is associated with a row in the `tbl_customer`
table. Instead of writing raw SQL statements to access the data in the table,
you can call intuitive methods available in the corresponding ActiveRecord class
......
......@@ -7,7 +7,7 @@ of controlling it.
Access control basics
---------------------
Basic acces control is very simple to implement using [[\yii\web\AccessControl]]:
Basic access control is very simple to implement using [[\yii\web\AccessControl]]:
```php
class SiteController extends Controller
......
......@@ -121,7 +121,7 @@ extension. After installing and enabling it you will be able to use extended syn
that allows you to specify formatting style.
Full reference is [available at ICU website](http://icu-project.org/apiref/icu4c/classMessageFormat.html) but since it's
a bit crypric we have our own reference below.
a bit cryptic we have our own reference below.
### Numbers
......
......@@ -45,7 +45,7 @@ $query->select(['tbl_user.name AS author', 'tbl_post.title as title']) // <-- sp
->leftJoin('tbl_post', 'tbl_post.user_id = tbl_user.id'); // <-- join with another table
```
In the code above we've used `leftJoin` method to select from two related tables at the same time. Firsrt parameter
In the code above we've used `leftJoin` method to select from two related tables at the same time. First parameter
specifies table name and the second is the join condition. Query builder has the following methods to join tables:
- `innerJoin`
......
......@@ -8,7 +8,7 @@ Standard Yii validators
-----------------------
Standard Yii validators could be specified using aliases instead of referring to class names. Here's the list of all
validators budled with Yii with their most useful properties:
validators bundled with Yii with their most useful properties:
### `boolean`: [[BooleanValidator]]
......
......@@ -38,7 +38,7 @@ Widgets
Widgets are a self-contained building blocks for your views. A widget may contain advanced logic, typically takes some
configuration and data and returns HTML. There is a good number of widgets bundled with Yii such as [active form](form.md),
breadcrumbs, menu or [wrappers around bootstrap component framework](boostrap-widgets.md). Additionally there are
breadcrumbs, menu or [wrappers around bootstrap component framework](bootstrap-widgets.md). Additionally there are
extensions providing additional widgets such as official one for jQueryUI components.
In order to use widget you need to do the following:
......
......@@ -85,13 +85,13 @@ class Installer extends LibraryInstaller
protected function loadExtensions()
{
$file = $this->vendorDir . '/yii-extensions.php';
$file = $this->vendorDir . '/yiisoft/extensions.php';
return is_file($file) ? require($file) : [];
}
protected function saveExtensions(array $extensions)
{
$file = $this->vendorDir . '/yii-extensions.php';
$file = $this->vendorDir . '/yiisoft/extensions.php';
file_put_contents($file, "<?php\nreturn " . var_export($extensions, true) . ";\n");
}
......
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008-2013 by Yii Software LLC (http://www.yiisoft.com)
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
......
......@@ -26,8 +26,9 @@ class Plugin implements PluginInterface
{
$installer = new Installer($io, $composer);
$composer->getInstallationManager()->addInstaller($installer);
$file = rtrim($composer->getConfig()->get('vendor-dir'), '/') . '/yii-extensions.php';
$file = rtrim($composer->getConfig()->get('vendor-dir'), '/') . '/yiisoft/extensions.php';
if (!is_file($file)) {
@mkdir(dirname($file));
file_put_contents($file, "<?php\nreturn [];\n");
}
}
......
Yii 2.0 Public Preview - Composer Installer
===========================================
Thank you for choosing Yii - a high-performance component-based PHP framework.
If you are looking for a production-ready PHP framework, please use
[Yii v1.1](https://github.com/yiisoft/yii).
Yii 2.0 is still under heavy development. We may make significant changes
without prior notices. **Yii 2.0 is not ready for production use yet.**
Yii 2 Composer Installer
========================
[![Build Status](https://secure.travis-ci.org/yiisoft/yii2.png)](http://travis-ci.org/yiisoft/yii2)
This is the yii2 composer installer.
This is the composer installer for Yii 2 extensions. It implements a new composer package type named `yii2-extension`,
which should be used by all Yii 2 extensions if they are distributed as composer packages.
Installation
------------
Usage
-----
This extension offers you enhanced Composer handling for your yii2-project. It will therefore require you to use Composer.
To use Yii 2 composer installer, simply set `type` to be `yii2-extension` in your `composer.json`,
like the following:
```json
{
"type": "yii2-extension",
"require": {
"yiisoft/yii2": "*"
},
...
}
```
php composer.phar require yiisoft/yii2-composer "*"
```
*Note: You might have to run `php composer.phar selfupdate` before using this extension.*
Usage & Documentation
---------------------
This extension allows you to hook to certain composer events and automate preparing your Yii2 application for further usage.
After the package is installed, the `composer.json` file has to be modified to enable this extension.
To see it in action take a look at the example apps in the repository:
- [Basic](https://github.com/suralc/yii2/blob/master/apps/basic/composer.json#L27)
- [Advanced](https://github.com/suralc/yii2/blob/extensions-readme/apps/advanced/composer.json)
However it might be useful to read through the official composer [documentation](http://getcomposer.org/doc/articles/scripts.md)
to understand what this extension can do for you and what it can't.
You may specify a bootstrap class in the `extra` section. The `init()` method of the class will be executed each time
the Yii 2 application is responding to a request. For example,
```json
{
"type": "yii2-extension",
...,
"extra": {
"bootstrap": "yii\\jui\\Extension"
}
}
```
You can also use this as a template to create your own composer additions to ease development and deployment of your app.
The `Installer` class also implements a static method `setPermission()` that can be called after
a Yii 2 projected is installed, through the `post-create-project-cmd` composer script.
The method will set specified directories or files to be writable or executable, depending on
the corresponding parameters set in the `extra` section of the `composer.json` file.
For example,
```json
{
"name": "yiisoft/yii2-app-basic",
"type": "project",
...
"scripts": {
"post-create-project-cmd": [
"yii\\composer\\Installer::setPermission"
]
},
"extra": {
"writable": [
"runtime",
"web/assets"
],
"executable": [
"yii"
]
}
}
```
......@@ -21,6 +21,7 @@
"autoload": {
"psr-0": { "yii\\composer\\": "" }
},
"target-dir": "yii/composer",
"extra": {
"class": "yii\\composer\\Plugin"
},
......
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008-2013 by Yii Software LLC (http://www.yiisoft.com)
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
......
......@@ -18,6 +18,7 @@
"autoload": {
"psr-0": { "yii\\jui\\": "" }
},
"target-dir": "yii/jui",
"extra": {
"bootstrap": "yii\\jui\\Extension"
}
......
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008-2013 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Yii Software LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Yii 2.0 Public Preview - Mutex Extension
========================================
Thank you for choosing Yii - a high-performance component-based PHP framework.
If you are looking for a production-ready PHP framework, please use
[Yii v1.1](https://github.com/yiisoft/yii).
Yii 2.0 is still under heavy development. We may make significant changes
without prior notices. **Yii 2.0 is not ready for production use yet.**
[![Build Status](https://secure.travis-ci.org/yiisoft/yii2.png)](http://travis-ci.org/yiisoft/yii2)
This is the yii2-mutex extension.
Installation
------------
The prefered way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require yiisoft/yii2-mutex "*"
```
or add
```
"yiisoft/yii2-mutex": "*"
```
to the require section of your composer.json.
*Note: You might have to run `php composer.phar selfupdate`*
Usage & Documentation
---------------------
This component can be used to perform actions similar to the concept of [mutual exclusion](http://en.wikipedia.org/wiki/Mutual_exclusion).
For concrete examples and advanced usage refer to the yii guide.
{
"name": "yiisoft/yii2-mutex",
"description": "Mutual exclusion extension for the Yii framework",
"keywords": ["yii", "mutex"],
"type": "yii2-extension",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"authors": [
{
"name": "resurtm",
"email": "resurtm@gmail.com"
}
],
"minimum-stability": "dev",
"require": {
"yiisoft/yii2": "*"
},
"autoload": {
"psr-0": { "yii\\mutex\\": "" }
}
}
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008-2013 by Yii Software LLC (http://www.yiisoft.com)
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
......
......@@ -24,5 +24,6 @@
},
"autoload": {
"psr-0": { "yii\\smarty\\": "" }
}
},
"target-dir": "yii/smarty"
}
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008-2013 by Yii Software LLC (http://www.yiisoft.com)
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
......
......@@ -24,5 +24,6 @@
},
"autoload": {
"psr-0": { "yii\\twig\\": "" }
}
},
"target-dir": "yii/twig"
}
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008-2013 by Yii Software LLC (http://www.yiisoft.com)
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
......@@ -29,4 +29,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
POSSIBILITY OF SUCH DAMAGE.
......@@ -68,7 +68,7 @@
"yiisoft/yii2-composer": "*",
"ext-mbstring": "*",
"lib-pcre": "*",
"phpspec/php-diff": "1.0.*",
"phpspec/php-diff": "dev-master",
"ezyang/htmlpurifier": "4.5.*"
},
"autoload": {
......
......@@ -241,7 +241,7 @@ abstract class Module extends Component
* Sets the directory that contains the controller classes.
* @param string $path the directory that contains the controller classes.
* This can be either a directory name or a path alias.
* @throws Exception if the directory is invalid
* @throws InvalidParamException if the directory is invalid
*/
public function setControllerPath($path)
{
......@@ -264,7 +264,7 @@ abstract class Module extends Component
/**
* Sets the directory that contains the view files.
* @param string $path the root directory of view files.
* @throws Exception if the directory is invalid
* @throws InvalidParamException if the directory is invalid
*/
public function setViewPath($path)
{
......@@ -287,7 +287,7 @@ abstract class Module extends Component
/**
* Sets the directory that contains the layout files.
* @param string $path the root directory of layout files.
* @throws Exception if the directory is invalid
* @throws InvalidParamException if the directory is invalid
*/
public function setLayoutPath($path)
{
......
......@@ -13,17 +13,38 @@ use yii\helpers\FileHelper;
/**
* Theme represents an application theme.
*
* A theme is directory consisting of view and layout files which are meant to replace their
* non-themed counterparts.
* When [[View]] renders a view file, it will check the [[Application::theme|active theme]]
* to see if there is a themed version of the view file exists. If so, the themed version will be rendered instead.
*
* Theme uses [[pathMap]] to achieve the file replacement. A view or layout file will be replaced
* with its themed version if part of its path matches one of the keys in [[pathMap]].
* Then the matched part will be replaced with the corresponding array value.
* A theme is a directory consisting of view files which are meant to replace their non-themed counterparts.
*
* Theme uses [[pathMap]] to achieve the view file replacement:
*
* 1. It first looks for a key in [[pathMap]] that is a substring of the given view file path;
* 2. If such a key exists, the corresponding value will be used to replace the corresponding part
* in the view file path;
* 3. It will then check if the updated view file exists or not. If so, that file will be used
* to replace the original view file.
* 4. If Step 2 or 3 fails, the original view file will be used.
*
* For example, if [[pathMap]] is `['/web/views' => '/web/themes/basic']`,
* then the themed version for a view file `/web/views/site/index.php` will be
* `/web/themes/basic/site/index.php`.
*
* It is possible to map a single path to multiple paths. For example,
*
* ~~~
* 'pathMap' => [
* '/web/views' => [
* '/web/themes/christmas',
* '/web/themes/basic',
* ],
* ]
* ~~~
*
* In this case, the themed version could be either `/web/themes/christmas/site/index.php` or
* `/web/themes/basic/site/index.php`. The former has precedence over the latter if both files exist.
*
* To use a theme, you should configure the [[View::theme|theme]] property of the "view" application
* component like the following:
*
......@@ -75,16 +96,18 @@ class Theme extends Component
if (empty($this->pathMap)) {
if ($this->basePath !== null) {
$this->basePath = Yii::getAlias($this->basePath);
$this->pathMap = [Yii::$app->getBasePath() => $this->basePath];
$this->pathMap = [Yii::$app->getBasePath() => [$this->basePath]];
} else {
throw new InvalidConfigException('The "basePath" property must be set.');
}
}
$paths = [];
foreach ($this->pathMap as $from => $to) {
foreach ($this->pathMap as $from => $tos) {
$from = FileHelper::normalizePath(Yii::getAlias($from));
$to = FileHelper::normalizePath(Yii::getAlias($to));
$paths[$from . DIRECTORY_SEPARATOR] = $to . DIRECTORY_SEPARATOR;
foreach ((array)$tos as $to) {
$to = FileHelper::normalizePath(Yii::getAlias($to));
$paths[$from . DIRECTORY_SEPARATOR][] = $to . DIRECTORY_SEPARATOR;
}
}
$this->pathMap = $paths;
if ($this->baseUrl === null) {
......@@ -103,12 +126,14 @@ class Theme extends Component
public function applyTo($path)
{
$path = FileHelper::normalizePath($path);
foreach ($this->pathMap as $from => $to) {
foreach ($this->pathMap as $from => $tos) {
if (strpos($path, $from) === 0) {
$n = strlen($from);
$file = $to . substr($path, $n);
if (is_file($file)) {
return $file;
foreach ($tos as $to) {
$file = $to . substr($path, $n);
if (is_file($file)) {
return $file;
}
}
}
}
......
......@@ -1266,6 +1266,8 @@ class ActiveRecord extends Model
$relation = $this->$getter();
if ($relation instanceof ActiveRelation) {
return $relation;
} else {
return null;
}
} catch (UnknownMethodException $e) {
throw new InvalidParamException(get_class($this) . ' has no relation named "' . $name . '".', 0, $e);
......
......@@ -158,6 +158,21 @@ class Migration extends \yii\base\Component
}
/**
* Creates and executes an batch INSERT SQL statement.
* The method will properly escape the column names, and bind the values to be inserted.
* @param string $table the table that new rows will be inserted into.
* @param array $columns the column names.
* @param array $rows the rows to be batch inserted into the table
*/
public function batchInsert($table, $columns, $rows)
{
echo " > insert into $table ...";
$time = microtime(true);
$this->db->createCommand()->batchInsert($table, $columns, $rows)->execute();
echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n";
}
/**
* Creates and executes an UPDATE SQL statement.
* The method will properly escape the column names and bind the values to be updated.
* @param string $table the table to be updated.
......
......@@ -118,6 +118,8 @@ class Schema extends \yii\db\Schema
if ($this->findColumns($table)) {
$this->findForeignKeys($table);
return $table;
} else {
return null;
}
}
......
......@@ -80,6 +80,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
* @param boolean $check whether to turn on or off the integrity check.
* @param string $schema the schema of the tables. Meaningless for SQLite.
* @param string $table the table name. Meaningless for SQLite.
* @return string the SQL statement for checking integrity
* @throws NotSupportedException this is not supported by SQLite
*/
public function checkIntegrity($check = true, $schema = '', $table = '')
......
......@@ -14,7 +14,7 @@ yii.gii = (function ($) {
};
var initStickyInputs = function () {
$('.sticky:not(.error) input[type="text"],select,textarea').each(function () {
$('.sticky:not(.error)').find('input[type="text"],select,textarea').each(function () {
var value;
if (this.tagName === 'SELECT') {
value = this.options[this.selectedIndex].text;
......
......@@ -54,6 +54,7 @@ class GettextMoFile extends GettextFile
* @param string $context message context
* @return array message translations. Array keys are source messages and array values are translated messages:
* source message => translated message.
* @throws Exception if unable to read the MO file
*/
public function load($filePath, $context)
{
......@@ -128,6 +129,7 @@ class GettextMoFile extends GettextFile
* @param array $messages message translations. Array keys are source messages and array values are
* translated messages: source message => translated message. Note if the message has a context,
* the message ID must be prefixed with the context with chr(4) as the separator.
* @throws Exception if unable to save the MO file
*/
public function save($filePath, $messages)
{
......@@ -203,6 +205,8 @@ class GettextMoFile extends GettextFile
{
if ($byteCount > 0) {
return fread($fileHandle, $byteCount);
} else {
return null;
}
}
......
......@@ -290,59 +290,74 @@ class Request extends \yii\base\Request
/**
* Returns the named GET parameter value.
* If the GET parameter does not exist, the second parameter to this method will be returned.
* @param string $name the GET parameter name
* @param string $name the GET parameter name. If not specified, whole $_GET is returned.
* @param mixed $defaultValue the default parameter value if the GET parameter does not exist.
* @return mixed the GET parameter value
* @see getPost
*/
public function get($name, $defaultValue = null)
public function get($name = null, $defaultValue = null)
{
if ($name === null) {
return $_GET;
}
return isset($_GET[$name]) ? $_GET[$name] : $defaultValue;
}
/**
* Returns the named POST parameter value.
* If the POST parameter does not exist, the second parameter to this method will be returned.
* @param string $name the POST parameter name
* @param string $name the POST parameter name. If not specified, whole $_POST is returned.
* @param mixed $defaultValue the default parameter value if the POST parameter does not exist.
* @return mixed the POST parameter value
* @see getParam
*/
public function getPost($name, $defaultValue = null)
public function getPost($name = null, $defaultValue = null)
{
if ($name === null) {
return $_POST;
}
return isset($_POST[$name]) ? $_POST[$name] : $defaultValue;
}
/**
* Returns the named DELETE parameter value.
* @param string $name the DELETE parameter name
* @param string $name the DELETE parameter name. If not specified, an array of DELETE parameters is returned.
* @param mixed $defaultValue the default parameter value if the DELETE parameter does not exist.
* @return mixed the DELETE parameter value
*/
public function getDelete($name, $defaultValue = null)
public function getDelete($name = null, $defaultValue = null)
{
if ($name === null) {
return $this->getRestParams();
}
return $this->getIsDelete() ? $this->getRestParam($name, $defaultValue) : null;
}
/**
* Returns the named PUT parameter value.
* @param string $name the PUT parameter name
* @param string $name the PUT parameter name. If not specified, an array of PUT parameters is returned.
* @param mixed $defaultValue the default parameter value if the PUT parameter does not exist.
* @return mixed the PUT parameter value
*/
public function getPut($name, $defaultValue = null)
public function getPut($name = null, $defaultValue = null)
{
if ($name === null) {
return $this->getRestParams();
}
return $this->getIsPut() ? $this->getRestParam($name, $defaultValue) : null;
}
/**
* Returns the named PATCH parameter value.
* @param string $name the PATCH parameter name
* @param string $name the PATCH parameter name. If not specified, an array of PATCH parameters is returned.
* @param mixed $defaultValue the default parameter value if the PATCH parameter does not exist.
* @return mixed the PATCH parameter value
*/
public function getPatch($name, $defaultValue = null)
public function getPatch($name = null, $defaultValue = null)
{
if ($name === null) {
return $this->getRestParams();
}
return $this->getIsPatch() ? $this->getRestParam($name, $defaultValue) : null;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment