Browse Source

refactored helper organization.

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
a6cd7b72bb
  1. 8
      apps/advanced/common/models/User.php
  2. 4
      apps/advanced/frontend/models/SendPasswordResetTokenForm.php
  3. 50
      framework/yii/classes.php
  4. 6
      framework/yii/console/Controller.php
  5. 4
      framework/yii/helpers/ArrayHelper.php
  6. 9
      framework/yii/helpers/ArrayHelperBase.php
  7. 2
      framework/yii/helpers/Console.php
  8. 18
      framework/yii/helpers/ConsoleBase.php
  9. 2
      framework/yii/helpers/FileHelper.php
  10. 15
      framework/yii/helpers/FileHelperBase.php
  11. 2
      framework/yii/helpers/Html.php
  12. 8
      framework/yii/helpers/HtmlBase.php
  13. 2
      framework/yii/helpers/HtmlPurifier.php
  14. 8
      framework/yii/helpers/HtmlPurifierBase.php
  15. 2
      framework/yii/helpers/Inflector.php
  16. 8
      framework/yii/helpers/InflectorBase.php
  17. 6
      framework/yii/helpers/Json.php
  18. 11
      framework/yii/helpers/JsonBase.php
  19. 2
      framework/yii/helpers/Markdown.php
  20. 21
      framework/yii/helpers/MarkdownBase.php
  21. 8
      framework/yii/helpers/Security.php
  22. 20
      framework/yii/helpers/SecurityBase.php
  23. 2
      framework/yii/helpers/StringHelper.php
  24. 8
      framework/yii/helpers/StringHelperBase.php
  25. 2
      framework/yii/helpers/VarDumper.php
  26. 15
      framework/yii/helpers/VarDumperBase.php
  27. 0
      framework/yii/helpers/mimeTypes.php
  28. 6
      framework/yii/web/Request.php
  29. 4
      framework/yii/web/Response.php
  30. 2
      tests/unit/framework/helpers/FileHelperTest.php

8
apps/advanced/common/models/User.php

@ -2,7 +2,7 @@
namespace common\models; namespace common\models;
use yii\db\ActiveRecord; use yii\db\ActiveRecord;
use yii\helpers\SecurityHelper; use yii\helpers\Security;
use yii\web\Identity; use yii\web\Identity;
/** /**
@ -72,7 +72,7 @@ class User extends ActiveRecord implements Identity
public function validatePassword($password) public function validatePassword($password)
{ {
return SecurityHelper::validatePassword($password, $this->password_hash); return Security::validatePassword($password, $this->password_hash);
} }
public function rules() public function rules()
@ -105,10 +105,10 @@ class User extends ActiveRecord implements Identity
{ {
if (parent::beforeSave($insert)) { if (parent::beforeSave($insert)) {
if (($this->isNewRecord || $this->getScenario() === 'resetPassword') && !empty($this->password)) { if (($this->isNewRecord || $this->getScenario() === 'resetPassword') && !empty($this->password)) {
$this->password_hash = SecurityHelper::generatePasswordHash($this->password); $this->password_hash = Security::generatePasswordHash($this->password);
} }
if ($this->isNewRecord) { if ($this->isNewRecord) {
$this->auth_key = SecurityHelper::generateRandomKey(); $this->auth_key = Security::generateRandomKey();
} }
return true; return true;
} }

4
apps/advanced/frontend/models/SendPasswordResetTokenForm.php

@ -4,7 +4,7 @@ namespace frontend\models;
use yii\base\Model; use yii\base\Model;
use common\models\User; use common\models\User;
use yii\base\View; use yii\base\View;
use yii\helpers\SecurityHelper; use yii\helpers\Security;
/** /**
* SendPasswordResetTokenForm is the model behind requesting password reset token form. * SendPasswordResetTokenForm is the model behind requesting password reset token form.
@ -33,7 +33,7 @@ class SendPasswordResetTokenForm extends Model
'status' => User::STATUS_ACTIVE, 'status' => User::STATUS_ACTIVE,
)); ));
if ($user) { if ($user) {
$user->password_reset_token = SecurityHelper::generateRandomKey(); $user->password_reset_token = Security::generateRandomKey();
if ($user->save(false)) { if ($user->save(false)) {
$view = new View(array( $view = new View(array(
'context' => \Yii::$app->controller, 'context' => \Yii::$app->controller,

50
framework/yii/classes.php

@ -46,19 +46,34 @@ return array(
'yii\base\ViewRenderer' => YII_PATH . '/base/ViewRenderer.php', 'yii\base\ViewRenderer' => YII_PATH . '/base/ViewRenderer.php',
'yii\base\Widget' => YII_PATH . '/base/Widget.php', 'yii\base\Widget' => YII_PATH . '/base/Widget.php',
'yii\behaviors\AutoTimestamp' => YII_PATH . '/behaviors/AutoTimestamp.php', 'yii\behaviors\AutoTimestamp' => YII_PATH . '/behaviors/AutoTimestamp.php',
'yii\bootstrap\AffixAsset' => YII_PATH . '/bootstrap/AffixAsset.php',
'yii\bootstrap\Alert' => YII_PATH . '/bootstrap/Alert.php', 'yii\bootstrap\Alert' => YII_PATH . '/bootstrap/Alert.php',
'yii\bootstrap\AlertAsset' => YII_PATH . '/bootstrap/AlertAsset.php',
'yii\bootstrap\BootstrapAsset' => YII_PATH . '/bootstrap/BootstrapAsset.php',
'yii\bootstrap\Button' => YII_PATH . '/bootstrap/Button.php', 'yii\bootstrap\Button' => YII_PATH . '/bootstrap/Button.php',
'yii\bootstrap\ButtonAsset' => YII_PATH . '/bootstrap/ButtonAsset.php',
'yii\bootstrap\ButtonDropdown' => YII_PATH . '/bootstrap/ButtonDropdown.php', 'yii\bootstrap\ButtonDropdown' => YII_PATH . '/bootstrap/ButtonDropdown.php',
'yii\bootstrap\ButtonGroup' => YII_PATH . '/bootstrap/ButtonGroup.php', 'yii\bootstrap\ButtonGroup' => YII_PATH . '/bootstrap/ButtonGroup.php',
'yii\bootstrap\Carousel' => YII_PATH . '/bootstrap/Carousel.php', 'yii\bootstrap\Carousel' => YII_PATH . '/bootstrap/Carousel.php',
'yii\bootstrap\CarouselAsset' => YII_PATH . '/bootstrap/CarouselAsset.php',
'yii\bootstrap\Collapse' => YII_PATH . '/bootstrap/Collapse.php', 'yii\bootstrap\Collapse' => YII_PATH . '/bootstrap/Collapse.php',
'yii\bootstrap\CollapseAsset' => YII_PATH . '/bootstrap/CollapseAsset.php',
'yii\bootstrap\Dropdown' => YII_PATH . '/bootstrap/Dropdown.php', 'yii\bootstrap\Dropdown' => YII_PATH . '/bootstrap/Dropdown.php',
'yii\bootstrap\DropdownAsset' => YII_PATH . '/bootstrap/DropdownAsset.php',
'yii\bootstrap\Modal' => YII_PATH . '/bootstrap/Modal.php', 'yii\bootstrap\Modal' => YII_PATH . '/bootstrap/Modal.php',
'yii\bootstrap\ModalAsset' => YII_PATH . '/bootstrap/ModalAsset.php',
'yii\bootstrap\Nav' => YII_PATH . '/bootstrap/Nav.php', 'yii\bootstrap\Nav' => YII_PATH . '/bootstrap/Nav.php',
'yii\bootstrap\NavBar' => YII_PATH . '/bootstrap/NavBar.php', 'yii\bootstrap\NavBar' => YII_PATH . '/bootstrap/NavBar.php',
'yii\bootstrap\PopoverAsset' => YII_PATH . '/bootstrap/PopoverAsset.php',
'yii\bootstrap\Progress' => YII_PATH . '/bootstrap/Progress.php', 'yii\bootstrap\Progress' => YII_PATH . '/bootstrap/Progress.php',
'yii\bootstrap\ResponsiveAsset' => YII_PATH . '/bootstrap/ResponsiveAsset.php',
'yii\bootstrap\ScrollspyAsset' => YII_PATH . '/bootstrap/ScrollspyAsset.php',
'yii\bootstrap\TabAsset' => YII_PATH . '/bootstrap/TabAsset.php',
'yii\bootstrap\Tabs' => YII_PATH . '/bootstrap/Tabs.php', 'yii\bootstrap\Tabs' => YII_PATH . '/bootstrap/Tabs.php',
'yii\bootstrap\TypeAhead' => YII_PATH . '/bootstrap/TypeAhead.php', 'yii\bootstrap\TooltipAsset' => YII_PATH . '/bootstrap/TooltipAsset.php',
'yii\bootstrap\TransitionAsset' => YII_PATH . '/bootstrap/TransitionAsset.php',
'yii\bootstrap\Typeahead' => YII_PATH . '/bootstrap/Typeahead.php',
'yii\bootstrap\TypeaheadAsset' => YII_PATH . '/bootstrap/TypeaheadAsset.php',
'yii\bootstrap\Widget' => YII_PATH . '/bootstrap/Widget.php', 'yii\bootstrap\Widget' => YII_PATH . '/bootstrap/Widget.php',
'yii\caching\ApcCache' => YII_PATH . '/caching/ApcCache.php', 'yii\caching\ApcCache' => YII_PATH . '/caching/ApcCache.php',
'yii\caching\Cache' => YII_PATH . '/caching/Cache.php', 'yii\caching\Cache' => YII_PATH . '/caching/Cache.php',
@ -109,27 +124,27 @@ return array(
'yii\db\TableSchema' => YII_PATH . '/db/TableSchema.php', 'yii\db\TableSchema' => YII_PATH . '/db/TableSchema.php',
'yii\db\Transaction' => YII_PATH . '/db/Transaction.php', 'yii\db\Transaction' => YII_PATH . '/db/Transaction.php',
'yii\helpers\ArrayHelper' => YII_PATH . '/helpers/ArrayHelper.php', 'yii\helpers\ArrayHelper' => YII_PATH . '/helpers/ArrayHelper.php',
'yii\helpers\base\ArrayHelper' => YII_PATH . '/helpers/base/ArrayHelper.php', 'yii\helpers\ArrayHelperBase' => YII_PATH . '/helpers/ArrayHelperBase.php',
'yii\helpers\base\Console' => YII_PATH . '/helpers/base/Console.php',
'yii\helpers\base\FileHelper' => YII_PATH . '/helpers/base/FileHelper.php',
'yii\helpers\base\Html' => YII_PATH . '/helpers/base/Html.php',
'yii\helpers\base\HtmlPurifier' => YII_PATH . '/helpers/base/HtmlPurifier.php',
'yii\helpers\base\Inflector' => YII_PATH . '/helpers/base/Inflector.php',
'yii\helpers\base\Json' => YII_PATH . '/helpers/base/Json.php',
'yii\helpers\base\Markdown' => YII_PATH . '/helpers/base/Markdown.php',
'yii\helpers\base\SecurityHelper' => YII_PATH . '/helpers/base/SecurityHelper.php',
'yii\helpers\base\StringHelper' => YII_PATH . '/helpers/base/StringHelper.php',
'yii\helpers\base\VarDumper' => YII_PATH . '/helpers/base/VarDumper.php',
'yii\helpers\Console' => YII_PATH . '/helpers/Console.php', 'yii\helpers\Console' => YII_PATH . '/helpers/Console.php',
'yii\helpers\ConsoleBase' => YII_PATH . '/helpers/ConsoleBase.php',
'yii\helpers\FileHelper' => YII_PATH . '/helpers/FileHelper.php', 'yii\helpers\FileHelper' => YII_PATH . '/helpers/FileHelper.php',
'yii\helpers\FileHelperBase' => YII_PATH . '/helpers/FileHelperBase.php',
'yii\helpers\Html' => YII_PATH . '/helpers/Html.php', 'yii\helpers\Html' => YII_PATH . '/helpers/Html.php',
'yii\helpers\HtmlBase' => YII_PATH . '/helpers/HtmlBase.php',
'yii\helpers\HtmlPurifier' => YII_PATH . '/helpers/HtmlPurifier.php', 'yii\helpers\HtmlPurifier' => YII_PATH . '/helpers/HtmlPurifier.php',
'yii\helpers\HtmlPurifierBase' => YII_PATH . '/helpers/HtmlPurifierBase.php',
'yii\helpers\Inflector' => YII_PATH . '/helpers/Inflector.php', 'yii\helpers\Inflector' => YII_PATH . '/helpers/Inflector.php',
'yii\helpers\InflectorBase' => YII_PATH . '/helpers/InflectorBase.php',
'yii\helpers\Json' => YII_PATH . '/helpers/Json.php', 'yii\helpers\Json' => YII_PATH . '/helpers/Json.php',
'yii\helpers\JsonBase' => YII_PATH . '/helpers/JsonBase.php',
'yii\helpers\Markdown' => YII_PATH . '/helpers/Markdown.php', 'yii\helpers\Markdown' => YII_PATH . '/helpers/Markdown.php',
'yii\helpers\SecurityHelper' => YII_PATH . '/helpers/SecurityHelper.php', 'yii\helpers\MarkdownBase' => YII_PATH . '/helpers/MarkdownBase.php',
'yii\helpers\Security' => YII_PATH . '/helpers/Security.php',
'yii\helpers\SecurityBase' => YII_PATH . '/helpers/SecurityBase.php',
'yii\helpers\StringHelper' => YII_PATH . '/helpers/StringHelper.php', 'yii\helpers\StringHelper' => YII_PATH . '/helpers/StringHelper.php',
'yii\helpers\StringHelperBase' => YII_PATH . '/helpers/StringHelperBase.php',
'yii\helpers\VarDumper' => YII_PATH . '/helpers/VarDumper.php', 'yii\helpers\VarDumper' => YII_PATH . '/helpers/VarDumper.php',
'yii\helpers\VarDumperBase' => YII_PATH . '/helpers/VarDumperBase.php',
'yii\i18n\DbMessageSource' => YII_PATH . '/i18n/DbMessageSource.php', 'yii\i18n\DbMessageSource' => YII_PATH . '/i18n/DbMessageSource.php',
'yii\i18n\Formatter' => YII_PATH . '/i18n/Formatter.php', 'yii\i18n\Formatter' => YII_PATH . '/i18n/Formatter.php',
'yii\i18n\GettextFile' => YII_PATH . '/i18n/GettextFile.php', 'yii\i18n\GettextFile' => YII_PATH . '/i18n/GettextFile.php',
@ -162,12 +177,14 @@ return array(
'yii\validators\FilterValidator' => YII_PATH . '/validators/FilterValidator.php', 'yii\validators\FilterValidator' => YII_PATH . '/validators/FilterValidator.php',
'yii\validators\InlineValidator' => YII_PATH . '/validators/InlineValidator.php', 'yii\validators\InlineValidator' => YII_PATH . '/validators/InlineValidator.php',
'yii\validators\NumberValidator' => YII_PATH . '/validators/NumberValidator.php', 'yii\validators\NumberValidator' => YII_PATH . '/validators/NumberValidator.php',
'yii\validators\PunycodeAsset' => YII_PATH . '/validators/PunycodeAsset.php',
'yii\validators\RangeValidator' => YII_PATH . '/validators/RangeValidator.php', 'yii\validators\RangeValidator' => YII_PATH . '/validators/RangeValidator.php',
'yii\validators\RegularExpressionValidator' => YII_PATH . '/validators/RegularExpressionValidator.php', 'yii\validators\RegularExpressionValidator' => YII_PATH . '/validators/RegularExpressionValidator.php',
'yii\validators\RequiredValidator' => YII_PATH . '/validators/RequiredValidator.php', 'yii\validators\RequiredValidator' => YII_PATH . '/validators/RequiredValidator.php',
'yii\validators\StringValidator' => YII_PATH . '/validators/StringValidator.php', 'yii\validators\StringValidator' => YII_PATH . '/validators/StringValidator.php',
'yii\validators\UniqueValidator' => YII_PATH . '/validators/UniqueValidator.php', 'yii\validators\UniqueValidator' => YII_PATH . '/validators/UniqueValidator.php',
'yii\validators\UrlValidator' => YII_PATH . '/validators/UrlValidator.php', 'yii\validators\UrlValidator' => YII_PATH . '/validators/UrlValidator.php',
'yii\validators\ValidationAsset' => YII_PATH . '/validators/ValidationAsset.php',
'yii\validators\Validator' => YII_PATH . '/validators/Validator.php', 'yii\validators\Validator' => YII_PATH . '/validators/Validator.php',
'yii\web\AccessControl' => YII_PATH . '/web/AccessControl.php', 'yii\web\AccessControl' => YII_PATH . '/web/AccessControl.php',
'yii\web\AccessRule' => YII_PATH . '/web/AccessRule.php', 'yii\web\AccessRule' => YII_PATH . '/web/AccessRule.php',
@ -186,6 +203,7 @@ return array(
'yii\web\HttpException' => YII_PATH . '/web/HttpException.php', 'yii\web\HttpException' => YII_PATH . '/web/HttpException.php',
'yii\web\IAssetConverter' => YII_PATH . '/web/IAssetConverter.php', 'yii\web\IAssetConverter' => YII_PATH . '/web/IAssetConverter.php',
'yii\web\Identity' => YII_PATH . '/web/Identity.php', 'yii\web\Identity' => YII_PATH . '/web/Identity.php',
'yii\web\JqueryAsset' => YII_PATH . '/web/JqueryAsset.php',
'yii\web\JsExpression' => YII_PATH . '/web/JsExpression.php', 'yii\web\JsExpression' => YII_PATH . '/web/JsExpression.php',
'yii\web\PageCache' => YII_PATH . '/web/PageCache.php', 'yii\web\PageCache' => YII_PATH . '/web/PageCache.php',
'yii\web\Request' => YII_PATH . '/web/Request.php', 'yii\web\Request' => YII_PATH . '/web/Request.php',
@ -201,20 +219,22 @@ return array(
'yii\web\UserEvent' => YII_PATH . '/web/UserEvent.php', 'yii\web\UserEvent' => YII_PATH . '/web/UserEvent.php',
'yii\web\VerbFilter' => YII_PATH . '/web/VerbFilter.php', 'yii\web\VerbFilter' => YII_PATH . '/web/VerbFilter.php',
'yii\web\XmlResponseFormatter' => YII_PATH . '/web/XmlResponseFormatter.php', 'yii\web\XmlResponseFormatter' => YII_PATH . '/web/XmlResponseFormatter.php',
'yii\web\YiiAsset' => YII_PATH . '/web/YiiAsset.php',
'yii\widgets\ActiveField' => YII_PATH . '/widgets/ActiveField.php', 'yii\widgets\ActiveField' => YII_PATH . '/widgets/ActiveField.php',
'yii\widgets\ActiveForm' => YII_PATH . '/widgets/ActiveForm.php', 'yii\widgets\ActiveForm' => YII_PATH . '/widgets/ActiveForm.php',
'yii\widgets\BaseListView' => YII_PATH . '/widgets/BaseListView.php', 'yii\widgets\ActiveFormAsset' => YII_PATH . '/widgets/ActiveFormAsset.php',
'yii\widgets\Block' => YII_PATH . '/widgets/Block.php', 'yii\widgets\Block' => YII_PATH . '/widgets/Block.php',
'yii\widgets\Breadcrumbs' => YII_PATH . '/widgets/Breadcrumbs.php', 'yii\widgets\Breadcrumbs' => YII_PATH . '/widgets/Breadcrumbs.php',
'yii\widgets\Captcha' => YII_PATH . '/widgets/Captcha.php', 'yii\widgets\Captcha' => YII_PATH . '/widgets/Captcha.php',
'yii\widgets\CaptchaAsset' => YII_PATH . '/widgets/CaptchaAsset.php',
'yii\widgets\ContentDecorator' => YII_PATH . '/widgets/ContentDecorator.php', 'yii\widgets\ContentDecorator' => YII_PATH . '/widgets/ContentDecorator.php',
'yii\widgets\DetailView' => YII_PATH . '/widgets/DetailView.php', 'yii\widgets\DetailView' => YII_PATH . '/widgets/DetailView.php',
'yii\widgets\FragmentCache' => YII_PATH . '/widgets/FragmentCache.php', 'yii\widgets\FragmentCache' => YII_PATH . '/widgets/FragmentCache.php',
'yii\widgets\InputWidget' => YII_PATH . '/widgets/InputWidget.php', 'yii\widgets\InputWidget' => YII_PATH . '/widgets/InputWidget.php',
'yii\widgets\LinkPager' => YII_PATH . '/widgets/LinkPager.php', 'yii\widgets\LinkPager' => YII_PATH . '/widgets/LinkPager.php',
'yii\widgets\ListPager' => YII_PATH . '/widgets/ListPager.php', 'yii\widgets\ListPager' => YII_PATH . '/widgets/ListPager.php',
'yii\widgets\ListView' => YII_PATH . '/widgets/ListView.php',
'yii\widgets\MaskedInput' => YII_PATH . '/widgets/MaskedInput.php', 'yii\widgets\MaskedInput' => YII_PATH . '/widgets/MaskedInput.php',
'yii\widgets\MaskedInputAsset' => YII_PATH . '/widgets/MaskedInputAsset.php',
'yii\widgets\Menu' => YII_PATH . '/widgets/Menu.php', 'yii\widgets\Menu' => YII_PATH . '/widgets/Menu.php',
'yii\widgets\Spaceless' => YII_PATH . '/widgets/Spaceless.php', 'yii\widgets\Spaceless' => YII_PATH . '/widgets/Spaceless.php',
); );

6
framework/yii/console/Controller.php

@ -137,7 +137,7 @@ class Controller extends \yii\base\Controller
/** /**
* Formats a string with ANSI codes * Formats a string with ANSI codes
* *
* You may pass additional parameters using the constants defined in [[yii\helpers\base\Console]]. * You may pass additional parameters using the constants defined in [[yii\helpers\Console]].
* *
* Example: * Example:
* *
@ -162,7 +162,7 @@ class Controller extends \yii\base\Controller
* Prints a string to STDOUT * Prints a string to STDOUT
* *
* You may optionally format the string with ANSI codes by * You may optionally format the string with ANSI codes by
* passing additional parameters using the constants defined in [[yii\helpers\base\Console]]. * passing additional parameters using the constants defined in [[yii\helpers\Console]].
* *
* Example: * Example:
* *
@ -187,7 +187,7 @@ class Controller extends \yii\base\Controller
* Prints a string to STDERR * Prints a string to STDERR
* *
* You may optionally format the string with ANSI codes by * You may optionally format the string with ANSI codes by
* passing additional parameters using the constants defined in [[yii\helpers\base\Console]]. * passing additional parameters using the constants defined in [[yii\helpers\Console]].
* *
* Example: * Example:
* *

4
framework/yii/helpers/ArrayHelper.php

@ -8,12 +8,12 @@
namespace yii\helpers; namespace yii\helpers;
/** /**
* ArrayHelper provides additional array functionality you can use in your * ArrayHelper provides additional array functionality that you can use in your
* application. * application.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class ArrayHelper extends base\ArrayHelper class ArrayHelper extends ArrayHelperBase
{ {
} }

9
framework/yii/helpers/base/ArrayHelper.php → framework/yii/helpers/ArrayHelperBase.php

@ -5,20 +5,21 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\helpers\base; namespace yii\helpers;
use Yii; use Yii;
use yii\base\Arrayable; use yii\base\Arrayable;
use yii\base\InvalidParamException; use yii\base\InvalidParamException;
/** /**
* ArrayHelper provides additional array functionality you can use in your * ArrayHelperBase provides concrete implementation for [[ArrayHelper]].
* application. *
* Do not use ArrayHelperBase. Use [[ArrayHelper]] instead.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class ArrayHelper class ArrayHelperBase
{ {
/** /**
* Converts an object or an array of objects into an array. * Converts an object or an array of objects into an array.

2
framework/yii/helpers/Console.php

@ -17,6 +17,6 @@ namespace yii\helpers;
* @author Carsten Brandt <mail@cebe.cc> * @author Carsten Brandt <mail@cebe.cc>
* @since 2.0 * @since 2.0
*/ */
class Console extends base\Console class Console extends ConsoleBase
{ {
} }

18
framework/yii/helpers/base/Console.php → framework/yii/helpers/ConsoleBase.php

@ -5,27 +5,17 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\helpers\base; namespace yii\helpers;
/** /**
* TODO adjust phpdoc * ConsoleBase provides concrete implementation for [[Console]].
* TODO test this on all kinds of terminals, especially windows (check out lib ncurses)
*
* Console View is the base class for console view components
*
* A console view provides functionality to create rich console application by allowing to format output
* by adding color and font style to it.
*
* The following constants are available for formatting:
*
* TODO document constants
*
* *
* Do not use ConsoleBase. Use [[Console]] instead.
* *
* @author Carsten Brandt <mail@cebe.cc> * @author Carsten Brandt <mail@cebe.cc>
* @since 2.0 * @since 2.0
*/ */
class Console class ConsoleBase
{ {
const FG_BLACK = 30; const FG_BLACK = 30;
const FG_RED = 31; const FG_RED = 31;

2
framework/yii/helpers/FileHelper.php

@ -16,6 +16,6 @@ namespace yii\helpers;
* @author Alex Makarov <sam@rmcreative.ru> * @author Alex Makarov <sam@rmcreative.ru>
* @since 2.0 * @since 2.0
*/ */
class FileHelper extends base\FileHelper class FileHelper extends FileHelperBase
{ {
} }

15
framework/yii/helpers/base/FileHelper.php → framework/yii/helpers/FileHelperBase.php

@ -7,19 +7,20 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\helpers\base; namespace yii\helpers;
use Yii; use Yii;
use yii\helpers\StringHelper as StringHelper2;
/** /**
* Filesystem helper * FileHelperBase provides concrete implementation for [[FileHelper]].
*
* Do not use FileHelperBase. Use [[FileHelper]] instead.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @author Alex Makarov <sam@rmcreative.ru> * @author Alex Makarov <sam@rmcreative.ru>
* @since 2.0 * @since 2.0
*/ */
class FileHelper class FileHelperBase
{ {
/** /**
* Normalizes a file/directory path. * Normalizes a file/directory path.
@ -279,11 +280,11 @@ class FileHelper
if ($isDir = is_dir($path)) { if ($isDir = is_dir($path)) {
$path .= '/'; $path .= '/';
} }
$n = StringHelper2::strlen($path); $n = StringHelper::strlen($path);
if (!empty($options['except'])) { if (!empty($options['except'])) {
foreach ($options['except'] as $name) { foreach ($options['except'] as $name) {
if (StringHelper2::substr($path, -StringHelper2::strlen($name), $n) === $name) { if (StringHelper::substr($path, -StringHelper::strlen($name), $n) === $name) {
return false; return false;
} }
} }
@ -291,7 +292,7 @@ class FileHelper
if (!$isDir && !empty($options['only'])) { if (!$isDir && !empty($options['only'])) {
foreach ($options['only'] as $name) { foreach ($options['only'] as $name) {
if (StringHelper2::substr($path, -StringHelper2::strlen($name), $n) === $name) { if (StringHelper::substr($path, -StringHelper::strlen($name), $n) === $name) {
return true; return true;
} }
} }

2
framework/yii/helpers/Html.php

@ -13,6 +13,6 @@ namespace yii\helpers;
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class Html extends base\Html class Html extends HtmlBase
{ {
} }

8
framework/yii/helpers/base/Html.php → framework/yii/helpers/HtmlBase.php

@ -5,7 +5,7 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\helpers\base; namespace yii\helpers;
use Yii; use Yii;
use yii\base\InvalidParamException; use yii\base\InvalidParamException;
@ -13,12 +13,14 @@ use yii\web\Request;
use yii\base\Model; use yii\base\Model;
/** /**
* Html provides a set of static methods for generating commonly used HTML tags. * HtmlBase provides concrete implementation for [[Html]].
*
* Do not use HtmlBase. Use [[Html]] instead.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class Html class HtmlBase
{ {
/** /**
* @var array list of void elements (element name => 1) * @var array list of void elements (element name => 1)

2
framework/yii/helpers/HtmlPurifier.php

@ -32,6 +32,6 @@ namespace yii\helpers;
* @author Alexander Makarov <sam@rmcreative.ru> * @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0 * @since 2.0
*/ */
class HtmlPurifier extends base\HtmlPurifier class HtmlPurifier extends HtmlPurifierBase
{ {
} }

8
framework/yii/helpers/base/HtmlPurifier.php → framework/yii/helpers/HtmlPurifierBase.php

@ -4,17 +4,17 @@
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\helpers\base; namespace yii\helpers;
/** /**
* HtmlPurifier is the concrete implementation of the [[yii\helpers\HtmlPurifier]] class. * HtmlPurifierBase provides concrete implementation for [[HtmlPurifier]].
* *
* You should use [[yii\helpers\HtmlPurifier]] instead of this class in your application. * Do not use HtmlPurifierBase. Use [[HtmlPurifier]] instead.
* *
* @author Alexander Makarov <sam@rmcreative.ru> * @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0 * @since 2.0
*/ */
class HtmlPurifier class HtmlPurifierBase
{ {
/** /**
* Passes markup through HTMLPurifier making it safe to output to end user * Passes markup through HTMLPurifier making it safe to output to end user

2
framework/yii/helpers/Inflector.php

@ -13,6 +13,6 @@ namespace yii\helpers;
* @author Antonio Ramirez <amigo.cobos@gmail.com> * @author Antonio Ramirez <amigo.cobos@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class Inflector extends base\Inflector class Inflector extends InflectorBase
{ {
} }

8
framework/yii/helpers/base/Inflector.php → framework/yii/helpers/InflectorBase.php

@ -5,17 +5,19 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\helpers\base; namespace yii\helpers;
use Yii; use Yii;
/** /**
* Inflector pluralizes and singularizes English nouns. It also contains some other useful methods. * InflectorBase provides concrete implementation for [[Inflector]].
*
* Do not use InflectorBase. Use [[Inflector]] instead.
* *
* @author Antonio Ramirez <amigo.cobos@gmail.com> * @author Antonio Ramirez <amigo.cobos@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class Inflector class InflectorBase
{ {
/** /**
* @var array the rules for converting a word into its plural form. * @var array the rules for converting a word into its plural form.

6
framework/yii/helpers/Json.php

@ -8,10 +8,12 @@
namespace yii\helpers; namespace yii\helpers;
/** /**
* * Json is a helper class providing JSON data encoding and decoding.
* It enhances the PHP built-in functions `json_encode()` and `json_decode()`
* by supporting encoding JavaScript expressions and throwing exceptions when decoding fails.
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class Json extends base\Json class Json extends JsonBase
{ {
} }

11
framework/yii/helpers/base/Json.php → framework/yii/helpers/JsonBase.php

@ -5,20 +5,21 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\helpers\base; namespace yii\helpers;
use yii\base\InvalidParamException; use yii\base\InvalidParamException;
use yii\base\Arrayable; use yii\base\Arrayable;
use yii\web\JsExpression; use yii\web\JsExpression;
/** /**
* Json is a helper class providing JSON data encoding and decoding. * JsonBase provides concrete implementation for [[Json]].
* It enhances the PHP built-in functions `json_encode()` and `json_decode()` *
* by supporting encoding JavaScript expressions and throwing exceptions when decoding fails. * Do not use JsonBase. Use [[Json]] instead.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class Json class JsonBase
{ {
/** /**
* Encodes the given value into a JSON string. * Encodes the given value into a JSON string.

2
framework/yii/helpers/Markdown.php

@ -28,6 +28,6 @@ namespace yii\helpers;
* @author Alexander Makarov <sam@rmcreative.ru> * @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0 * @since 2.0
*/ */
class Markdown extends base\Markdown class Markdown extends MarkdownBase
{ {
} }

21
framework/yii/helpers/base/Markdown.php → framework/yii/helpers/MarkdownBase.php

@ -5,32 +5,19 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\helpers\base; namespace yii\helpers;
use Michelf\MarkdownExtra; use Michelf\MarkdownExtra;
/** /**
* Markdown provides an ability to transform markdown into HTML. * MarkdownBase provides concrete implementation for [[Markdown]].
* *
* Basic usage is the following: * Do not use MarkdownBase. Use [[Markdown]] instead.
* *
* ```php
* $myHtml = Markdown::process($myText);
* ```
*
* If you want to configure the parser:
*
* ```php
* $myHtml = Markdown::process($myText, array(
* 'fn_id_prefix' => 'footnote_',
* ));
* ```
*
* For more details please refer to [PHP Markdown library documentation](http://michelf.ca/projects/php-markdown/).
* @author Alexander Makarov <sam@rmcreative.ru> * @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0 * @since 2.0
*/ */
class Markdown class MarkdownBase
{ {
/** /**
* @var MarkdownExtra * @var MarkdownExtra

8
framework/yii/helpers/SecurityHelper.php → framework/yii/helpers/Security.php

@ -8,15 +8,15 @@
namespace yii\helpers; namespace yii\helpers;
/** /**
* SecurityHelper provides a set of methods to handle common security-related tasks. * Security provides a set of methods to handle common security-related tasks.
* *
* In particular, SecurityHelper supports the following features: * In particular, Security supports the following features:
* *
* - Encryption/decryption: [[encrypt()]] and [[decrypt()]] * - Encryption/decryption: [[encrypt()]] and [[decrypt()]]
* - Data tampering prevention: [[hashData()]] and [[validateData()]] * - Data tampering prevention: [[hashData()]] and [[validateData()]]
* - Password validation: [[generatePasswordHash()]] and [[validatePassword()]] * - Password validation: [[generatePasswordHash()]] and [[validatePassword()]]
* *
* Additionally, SecurityHelper provides [[getSecretKey()]] to support generating * Additionally, Security provides [[getSecretKey()]] to support generating
* named secret keys. These secret keys, once generated, will be stored in a file * named secret keys. These secret keys, once generated, will be stored in a file
* and made available in future requests. * and made available in future requests.
* *
@ -24,6 +24,6 @@ namespace yii\helpers;
* @author Tom Worster <fsb@thefsb.org> * @author Tom Worster <fsb@thefsb.org>
* @since 2.0 * @since 2.0
*/ */
class SecurityHelper extends base\SecurityHelper class Security extends SecurityBase
{ {
} }

20
framework/yii/helpers/base/SecurityHelper.php → framework/yii/helpers/SecurityBase.php

@ -5,7 +5,7 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\helpers\base; namespace yii\helpers;
use Yii; use Yii;
use yii\base\Exception; use yii\base\Exception;
@ -13,23 +13,15 @@ use yii\base\InvalidConfigException;
use yii\base\InvalidParamException; use yii\base\InvalidParamException;
/** /**
* SecurityHelper provides a set of methods to handle common security-related tasks. * SecurityBase provides concrete implementation for [[Security]].
* *
* In particular, SecurityHelper supports the following features: * Do not use SecurityBase. Use [[Security]] instead.
*
* - Encryption/decryption: [[encrypt()]] and [[decrypt()]]
* - Data tampering prevention: [[hashData()]] and [[validateData()]]
* - Password validation: [[generatePasswordHash()]] and [[validatePassword()]]
*
* Additionally, SecurityHelper provides [[getSecretKey()]] to support generating
* named secret keys. These secret keys, once generated, will be stored in a file
* and made available in future requests.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @author Tom Worster <fsb@thefsb.org> * @author Tom Worster <fsb@thefsb.org>
* @since 2.0 * @since 2.0
*/ */
class SecurityHelper class SecurityBase
{ {
/** /**
* Encrypts data. * Encrypts data.
@ -182,11 +174,11 @@ class SecurityHelper
* *
* ~~~ * ~~~
* // generates the hash (usually done during user registration or when the password is changed) * // generates the hash (usually done during user registration or when the password is changed)
* $hash = SecurityHelper::generatePasswordHash($password); * $hash = Security::generatePasswordHash($password);
* // ...save $hash in database... * // ...save $hash in database...
* *
* // during login, validate if the password entered is correct using $hash fetched from database * // during login, validate if the password entered is correct using $hash fetched from database
* if (SecurityHelper::validatePassword($password, $hash) { * if (Security::validatePassword($password, $hash) {
* // password is good * // password is good
* } else { * } else {
* // password is bad * // password is bad

2
framework/yii/helpers/StringHelper.php

@ -14,6 +14,6 @@ namespace yii\helpers;
* @author Alex Makarov <sam@rmcreative.ru> * @author Alex Makarov <sam@rmcreative.ru>
* @since 2.0 * @since 2.0
*/ */
class StringHelper extends base\StringHelper class StringHelper extends StringHelperBase
{ {
} }

8
framework/yii/helpers/base/StringHelper.php → framework/yii/helpers/StringHelperBase.php

@ -5,16 +5,18 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\helpers\base; namespace yii\helpers;
/** /**
* StringHelper * StringHelperBase provides concrete implementation for [[StringHelper]].
*
* Do not use StringHelperBase. Use [[StringHelper]] instead.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @author Alex Makarov <sam@rmcreative.ru> * @author Alex Makarov <sam@rmcreative.ru>
* @since 2.0 * @since 2.0
*/ */
class StringHelper class StringHelperBase
{ {
/** /**
* Returns the number of bytes in the given string. * Returns the number of bytes in the given string.

2
framework/yii/helpers/VarDumper.php

@ -23,6 +23,6 @@ namespace yii\helpers;
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class VarDumper extends base\VarDumper class VarDumper extends VarDumperBase
{ {
} }

15
framework/yii/helpers/base/VarDumper.php → framework/yii/helpers/VarDumperBase.php

@ -6,24 +6,17 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\helpers\base; namespace yii\helpers;
/** /**
* VarDumper is intended to replace the buggy PHP function var_dump and print_r. * VarDumperBase provides concrete implementation for [[VarDumper]].
* It can correctly identify the recursively referenced objects in a complex
* object structure. It also has a recursive depth control to avoid indefinite
* recursive display of some peculiar variables.
* *
* VarDumper can be used as follows, * Do not use VarDumperBase. Use [[VarDumper]] instead.
*
* ~~~
* VarDumper::dump($var);
* ~~~
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class VarDumper class VarDumperBase
{ {
private static $_objects; private static $_objects;
private static $_output; private static $_output;

0
framework/yii/helpers/base/mimeTypes.php → framework/yii/helpers/mimeTypes.php

6
framework/yii/web/Request.php

@ -9,7 +9,7 @@ namespace yii\web;
use Yii; use Yii;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
use yii\helpers\SecurityHelper; use yii\helpers\Security;
/** /**
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
@ -823,7 +823,7 @@ class Request extends \yii\base\Request
if ($this->enableCookieValidation) { if ($this->enableCookieValidation) {
$key = $this->getCookieValidationKey(); $key = $this->getCookieValidationKey();
foreach ($_COOKIE as $name => $value) { foreach ($_COOKIE as $name => $value) {
if (is_string($value) && ($value = SecurityHelper::validateData($value, $key)) !== false) { if (is_string($value) && ($value = Security::validateData($value, $key)) !== false) {
$cookies[$name] = new Cookie(array( $cookies[$name] = new Cookie(array(
'name' => $name, 'name' => $name,
'value' => @unserialize($value), 'value' => @unserialize($value),
@ -850,7 +850,7 @@ class Request extends \yii\base\Request
public function getCookieValidationKey() public function getCookieValidationKey()
{ {
if ($this->_cookieValidationKey === null) { if ($this->_cookieValidationKey === null) {
$this->_cookieValidationKey = SecurityHelper::getSecretKey(__CLASS__ . '/' . Yii::$app->id); $this->_cookieValidationKey = Security::getSecretKey(__CLASS__ . '/' . Yii::$app->id);
} }
return $this->_cookieValidationKey; return $this->_cookieValidationKey;
} }

4
framework/yii/web/Response.php

@ -13,7 +13,7 @@ use yii\base\InvalidParamException;
use yii\helpers\FileHelper; use yii\helpers\FileHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\helpers\Json; use yii\helpers\Json;
use yii\helpers\SecurityHelper; use yii\helpers\Security;
use yii\helpers\StringHelper; use yii\helpers\StringHelper;
/** /**
@ -313,7 +313,7 @@ class Response extends \yii\base\Response
foreach ($this->getCookies() as $cookie) { foreach ($this->getCookies() as $cookie) {
$value = $cookie->value; $value = $cookie->value;
if ($cookie->expire != 1 && isset($validationKey)) { if ($cookie->expire != 1 && isset($validationKey)) {
$value = SecurityHelper::hashData(serialize($value), $validationKey); $value = Security::hashData(serialize($value), $validationKey);
} }
setcookie($cookie->name, $value, $cookie->expire, $cookie->path, $cookie->domain, $cookie->secure, $cookie->httpOnly); setcookie($cookie->name, $value, $cookie->expire, $cookie->path, $cookie->domain, $cookie->secure, $cookie->httpOnly);
} }

2
tests/unit/framework/helpers/FileHelperTest.php

@ -4,7 +4,7 @@ use yii\helpers\FileHelper;
use yii\test\TestCase; use yii\test\TestCase;
/** /**
* Unit test for [[yii\helpers\base\FileHelper]] * Unit test for [[yii\helpers\FileHelper]]
* @see FileHelper * @see FileHelper
*/ */
class FileHelperTest extends TestCase class FileHelperTest extends TestCase

Loading…
Cancel
Save