diff --git a/LICENSE.md b/LICENSE.md index 6edcc4f..e98f03d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,7 @@ 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. diff --git a/apps/advanced/LICENSE.md b/apps/advanced/LICENSE.md index 6edcc4f..e98f03d 100644 --- a/apps/advanced/LICENSE.md +++ b/apps/advanced/LICENSE.md @@ -1,7 +1,7 @@ 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. diff --git a/apps/advanced/backend/config/main.php b/apps/advanced/backend/config/main.php index 9c33d1f..cb68bbe 100644 --- a/apps/advanced/backend/config/main.php +++ b/apps/advanced/backend/config/main.php @@ -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, diff --git a/apps/advanced/console/config/main.php b/apps/advanced/console/config/main.php index 17e79c7..8c7459a 100644 --- a/apps/advanced/console/config/main.php +++ b/apps/advanced/console/config/main.php @@ -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'], diff --git a/apps/advanced/frontend/config/main.php b/apps/advanced/frontend/config/main.php index a6a3861..f420832 100644 --- a/apps/advanced/frontend/config/main.php +++ b/apps/advanced/frontend/config/main.php @@ -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, diff --git a/apps/advanced/init b/apps/advanced/init index c8f7f73..4015748 100755 --- a/apps/advanced/init +++ b/apps/advanced/init @@ -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); } } diff --git a/apps/basic/LICENSE.md b/apps/basic/LICENSE.md index 6edcc4f..e98f03d 100644 --- a/apps/basic/LICENSE.md +++ b/apps/basic/LICENSE.md @@ -1,7 +1,7 @@ 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. diff --git a/apps/basic/config/console.php b/apps/basic/config/console.php index 598316f..c70993e 100644 --- a/apps/basic/config/console.php +++ b/apps/basic/config/console.php @@ -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', diff --git a/apps/basic/config/web.php b/apps/basic/config/web.php index e27754f..5b9907c 100644 --- a/apps/basic/config/web.php +++ b/apps/basic/config/web.php @@ -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, diff --git a/apps/benchmark/LICENSE.md b/apps/benchmark/LICENSE.md index 6edcc4f..e98f03d 100644 --- a/apps/benchmark/LICENSE.md +++ b/apps/benchmark/LICENSE.md @@ -1,7 +1,7 @@ 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. diff --git a/docs/api/db/ActiveRecord.md b/docs/api/db/ActiveRecord.md index 70f171b..ef050d0 100644 --- a/docs/api/db/ActiveRecord.md +++ b/docs/api/db/ActiveRecord.md @@ -1,6 +1,6 @@ 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 diff --git a/docs/guide/authorization.md b/docs/guide/authorization.md index 47b9409..b49f1af 100644 --- a/docs/guide/authorization.md +++ b/docs/guide/authorization.md @@ -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 diff --git a/docs/guide/i18n.md b/docs/guide/i18n.md index 33f7758..6524801 100644 --- a/docs/guide/i18n.md +++ b/docs/guide/i18n.md @@ -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 diff --git a/docs/guide/query-builder.md b/docs/guide/query-builder.md index ffc9871..7625c0b 100644 --- a/docs/guide/query-builder.md +++ b/docs/guide/query-builder.md @@ -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` diff --git a/docs/guide/validation.md b/docs/guide/validation.md index c8c8674..59242f5 100644 --- a/docs/guide/validation.md +++ b/docs/guide/validation.md @@ -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]] diff --git a/docs/guide/view.md b/docs/guide/view.md index ee469e6..1069e89 100644 --- a/docs/guide/view.md +++ b/docs/guide/view.md @@ -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: diff --git a/extensions/composer/yii/composer/Installer.php b/extensions/composer/Installer.php similarity index 96% rename from extensions/composer/yii/composer/Installer.php rename to extensions/composer/Installer.php index 0dda073..3a77671 100644 --- a/extensions/composer/yii/composer/Installer.php +++ b/extensions/composer/Installer.php @@ -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, "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, " '/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; + } } } } diff --git a/framework/yii/db/ActiveRecord.php b/framework/yii/db/ActiveRecord.php index 79d5146..2c1689c 100644 --- a/framework/yii/db/ActiveRecord.php +++ b/framework/yii/db/ActiveRecord.php @@ -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); diff --git a/framework/yii/db/Migration.php b/framework/yii/db/Migration.php index 307b02a..37fdf3f 100644 --- a/framework/yii/db/Migration.php +++ b/framework/yii/db/Migration.php @@ -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. diff --git a/framework/yii/db/mssql/Schema.php b/framework/yii/db/mssql/Schema.php index 0bb5924..deb92f9 100644 --- a/framework/yii/db/mssql/Schema.php +++ b/framework/yii/db/mssql/Schema.php @@ -118,6 +118,8 @@ class Schema extends \yii\db\Schema if ($this->findColumns($table)) { $this->findForeignKeys($table); return $table; + } else { + return null; } } diff --git a/framework/yii/db/sqlite/QueryBuilder.php b/framework/yii/db/sqlite/QueryBuilder.php index 2a6f345..4a5407f 100644 --- a/framework/yii/db/sqlite/QueryBuilder.php +++ b/framework/yii/db/sqlite/QueryBuilder.php @@ -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 = '') diff --git a/framework/yii/gii/assets/gii.js b/framework/yii/gii/assets/gii.js index b581d3b..a95221e 100644 --- a/framework/yii/gii/assets/gii.js +++ b/framework/yii/gii/assets/gii.js @@ -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; diff --git a/framework/yii/i18n/GettextMoFile.php b/framework/yii/i18n/GettextMoFile.php index a92293c..b4a016d 100644 --- a/framework/yii/i18n/GettextMoFile.php +++ b/framework/yii/i18n/GettextMoFile.php @@ -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; } } diff --git a/extensions/mutex/yii/mutex/DbMutex.php b/framework/yii/mutex/DbMutex.php similarity index 100% rename from extensions/mutex/yii/mutex/DbMutex.php rename to framework/yii/mutex/DbMutex.php diff --git a/extensions/mutex/yii/mutex/FileMutex.php b/framework/yii/mutex/FileMutex.php similarity index 100% rename from extensions/mutex/yii/mutex/FileMutex.php rename to framework/yii/mutex/FileMutex.php diff --git a/extensions/mutex/yii/mutex/Mutex.php b/framework/yii/mutex/Mutex.php similarity index 100% rename from extensions/mutex/yii/mutex/Mutex.php rename to framework/yii/mutex/Mutex.php diff --git a/extensions/mutex/yii/mutex/MysqlMutex.php b/framework/yii/mutex/MysqlMutex.php similarity index 100% rename from extensions/mutex/yii/mutex/MysqlMutex.php rename to framework/yii/mutex/MysqlMutex.php diff --git a/framework/yii/web/Request.php b/framework/yii/web/Request.php index 610e907..a6a92fa 100644 --- a/framework/yii/web/Request.php +++ b/framework/yii/web/Request.php @@ -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; }