diff --git a/apps/advanced/frontend/controllers/SiteController.php b/apps/advanced/frontend/controllers/SiteController.php index 285b553..c4f7f53 100644 --- a/apps/advanced/frontend/controllers/SiteController.php +++ b/apps/advanced/frontend/controllers/SiteController.php @@ -16,7 +16,7 @@ class SiteController extends Controller { return array( 'captcha' => array( - 'class' => 'yii\web\CaptchaAction', + 'class' => 'yii\captcha\CaptchaAction', ), ); } diff --git a/apps/advanced/frontend/views/site/contact.php b/apps/advanced/frontend/views/site/contact.php index 62bb9ef..3a3fb0c 100644 --- a/apps/advanced/frontend/views/site/contact.php +++ b/apps/advanced/frontend/views/site/contact.php @@ -1,7 +1,7 @@ array( - 'class' => 'yii\web\CaptchaAction', + 'class' => 'yii\captcha\CaptchaAction', 'fixedVerifyCode' => YII_ENV_DEV ? 'testme' : null, ), ); diff --git a/apps/basic/views/site/contact.php b/apps/basic/views/site/contact.php index c0e3bff..1997267 100644 --- a/apps/basic/views/site/contact.php +++ b/apps/basic/views/site/contact.php @@ -1,7 +1,7 @@ 'password2', 'on' => 'register'), * // an inline validator defined via the "authenticate()" method in the model class * array('password', 'authenticate', 'on' => 'login'), - * // a validator of class "CaptchaValidator" - * array('captcha', 'CaptchaValidator'), + * // a validator of class "DateRangeValidator" + * array('dateRange', 'DateRangeValidator'), * ); * ~~~ * diff --git a/framework/yii/widgets/Captcha.php b/framework/yii/captcha/Captcha.php similarity index 98% rename from framework/yii/widgets/Captcha.php rename to framework/yii/captcha/Captcha.php index 1c538fb..c09399f 100644 --- a/framework/yii/widgets/Captcha.php +++ b/framework/yii/captcha/Captcha.php @@ -5,13 +5,14 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\widgets; +namespace yii\Captcha; use Yii; use yii\base\InvalidConfigException; use yii\helpers\Html; use yii\helpers\Json; -use yii\web\CaptchaAction; +use yii\widgets\InputWidget; + /** * Captcha renders a CAPTCHA image and an input field that takes user-entered verification code. diff --git a/framework/yii/web/CaptchaAction.php b/framework/yii/captcha/CaptchaAction.php similarity index 97% rename from framework/yii/web/CaptchaAction.php rename to framework/yii/captcha/CaptchaAction.php index fef44fd..771cc02 100644 --- a/framework/yii/web/CaptchaAction.php +++ b/framework/yii/captcha/CaptchaAction.php @@ -5,12 +5,11 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\web; +namespace yii\captcha; use Yii; use yii\base\Action; use yii\base\InvalidConfigException; -use yii\widgets\Captcha; /** * CaptchaAction renders a CAPTCHA image. @@ -85,7 +84,7 @@ class CaptchaAction extends Action /** * @var string the TrueType font file. This can be either a file path or path alias. */ - public $fontFile = '@yii/web/SpicyRice.ttf'; + public $fontFile = '@yii/captcha/SpicyRice.ttf'; /** * @var string the fixed verification code. When this property is set, * [[getVerifyCode()]] will always return the value of this property. @@ -116,12 +115,14 @@ class CaptchaAction extends Action if (isset($_GET[self::REFRESH_GET_VAR])) { // AJAX request for regenerating code $code = $this->getVerifyCode(true); + /** @var \yii\web\Controller $controller */ + $controller = $this->controller; return json_encode(array( 'hash1' => $this->generateValidationHash($code), 'hash2' => $this->generateValidationHash(strtolower($code)), // we add a random 'v' parameter so that FireFox can refresh the image // when src attribute of image tag is changed - 'url' => $this->controller->createUrl($this->id, array('v' => uniqid())), + 'url' => $controller->createUrl($this->id, array('v' => uniqid())), )); } else { $this->setHttpHeaders(); @@ -153,7 +154,7 @@ class CaptchaAction extends Action return $this->fixedVerifyCode; } - $session = Yii::$app->session; + $session = Yii::$app->getSession(); $session->open(); $name = $this->getSessionKey(); if ($session[$name] === null || $regenerate) { diff --git a/framework/yii/widgets/CaptchaAsset.php b/framework/yii/captcha/CaptchaAsset.php similarity index 94% rename from framework/yii/widgets/CaptchaAsset.php rename to framework/yii/captcha/CaptchaAsset.php index 4322e8e..50c75b7 100644 --- a/framework/yii/widgets/CaptchaAsset.php +++ b/framework/yii/captcha/CaptchaAsset.php @@ -5,7 +5,8 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\widgets; +namespace yii\captcha; + use yii\web\AssetBundle; /** diff --git a/framework/yii/validators/CaptchaValidator.php b/framework/yii/captcha/CaptchaValidator.php similarity index 96% rename from framework/yii/validators/CaptchaValidator.php rename to framework/yii/captcha/CaptchaValidator.php index 2a16f57..e710573 100644 --- a/framework/yii/validators/CaptchaValidator.php +++ b/framework/yii/captcha/CaptchaValidator.php @@ -5,11 +5,13 @@ * @license http://www.yiiframework.com/license/ */ -namespace yii\validators; +namespace yii\captcha; use Yii; use yii\base\InvalidConfigException; use yii\helpers\Html; +use yii\validators\ValidationAsset; +use yii\validators\Validator; /** * CaptchaValidator validates that the attribute value is the same as the verification code displayed in the CAPTCHA. @@ -74,7 +76,7 @@ class CaptchaValidator extends Validator /** * Returns the CAPTCHA action object. * @throws InvalidConfigException - * @return \yii\web\CaptchaAction the action object + * @return \yii\captcha\CaptchaAction the action object */ public function getCaptchaAction() { diff --git a/framework/yii/web/SpicyRice.md b/framework/yii/captcha/SpicyRice.md similarity index 100% rename from framework/yii/web/SpicyRice.md rename to framework/yii/captcha/SpicyRice.md diff --git a/framework/yii/web/SpicyRice.ttf b/framework/yii/captcha/SpicyRice.ttf similarity index 100% rename from framework/yii/web/SpicyRice.ttf rename to framework/yii/captcha/SpicyRice.ttf diff --git a/framework/yii/classes.php b/framework/yii/classes.php index 41c9a3a..a638dc0 100644 --- a/framework/yii/classes.php +++ b/framework/yii/classes.php @@ -91,6 +91,10 @@ return array( 'yii\caching\WinCache' => YII_PATH . '/caching/WinCache.php', 'yii\caching\XCache' => YII_PATH . '/caching/XCache.php', 'yii\caching\ZendDataCache' => YII_PATH . '/caching/ZendDataCache.php', + 'yii\captcha\Captcha' => YII_PATH . '/captcha/Captcha.php', + 'yii\captcha\CaptchaAction' => YII_PATH . '/captcha/CaptchaAction.php', + 'yii\captcha\CaptchaAsset' => YII_PATH . '/captcha/CaptchaAsset.php', + 'yii\captcha\CaptchaValidator' => YII_PATH . '/captcha/CaptchaValidator.php', 'yii\data\ActiveDataProvider' => YII_PATH . '/data/ActiveDataProvider.php', 'yii\data\ArrayDataProvider' => YII_PATH . '/data/ArrayDataProvider.php', 'yii\data\DataProvider' => YII_PATH . '/data/DataProvider.php', @@ -167,7 +171,6 @@ return array( 'yii\rbac\PhpManager' => YII_PATH . '/rbac/PhpManager.php', 'yii\requirements\YiiRequirementChecker' => YII_PATH . '/requirements/YiiRequirementChecker.php', 'yii\validators\BooleanValidator' => YII_PATH . '/validators/BooleanValidator.php', - 'yii\validators\CaptchaValidator' => YII_PATH . '/validators/CaptchaValidator.php', 'yii\validators\CompareValidator' => YII_PATH . '/validators/CompareValidator.php', 'yii\validators\DateValidator' => YII_PATH . '/validators/DateValidator.php', 'yii\validators\DefaultValueValidator' => YII_PATH . '/validators/DefaultValueValidator.php', @@ -193,7 +196,6 @@ return array( 'yii\web\AssetConverter' => YII_PATH . '/web/AssetConverter.php', 'yii\web\AssetManager' => YII_PATH . '/web/AssetManager.php', 'yii\web\CacheSession' => YII_PATH . '/web/CacheSession.php', - 'yii\web\CaptchaAction' => YII_PATH . '/web/CaptchaAction.php', 'yii\web\Controller' => YII_PATH . '/web/Controller.php', 'yii\web\Cookie' => YII_PATH . '/web/Cookie.php', 'yii\web\CookieCollection' => YII_PATH . '/web/CookieCollection.php', @@ -225,14 +227,18 @@ return array( 'yii\widgets\ActiveFormAsset' => YII_PATH . '/widgets/ActiveFormAsset.php', 'yii\widgets\Block' => YII_PATH . '/widgets/Block.php', 'yii\widgets\Breadcrumbs' => YII_PATH . '/widgets/Breadcrumbs.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\DetailView' => YII_PATH . '/widgets/DetailView.php', 'yii\widgets\FragmentCache' => YII_PATH . '/widgets/FragmentCache.php', + 'yii\widgets\grid\CheckboxColumn' => YII_PATH . '/widgets/grid/CheckboxColumn.php', + 'yii\widgets\grid\Column' => YII_PATH . '/widgets/grid/Column.php', + 'yii\widgets\grid\DataColumn' => YII_PATH . '/widgets/grid/DataColumn.php', + 'yii\widgets\GridView' => YII_PATH . '/widgets/GridView.php', 'yii\widgets\InputWidget' => YII_PATH . '/widgets/InputWidget.php', 'yii\widgets\LinkPager' => YII_PATH . '/widgets/LinkPager.php', - 'yii\widgets\ListPager' => YII_PATH . '/widgets/ListPager.php', + 'yii\widgets\LinkSorter' => YII_PATH . '/widgets/LinkSorter.php', + 'yii\widgets\ListView' => YII_PATH . '/widgets/ListView.php', + 'yii\widgets\ListViewBase' => YII_PATH . '/widgets/ListViewBase.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', diff --git a/framework/yii/validators/Validator.php b/framework/yii/validators/Validator.php index fe31936..c519706 100644 --- a/framework/yii/validators/Validator.php +++ b/framework/yii/validators/Validator.php @@ -49,7 +49,7 @@ abstract class Validator extends Component */ public static $builtInValidators = array( 'boolean' => 'yii\validators\BooleanValidator', - 'captcha' => 'yii\validators\CaptchaValidator', + 'captcha' => 'yii\captcha\CaptchaValidator', 'compare' => 'yii\validators\CompareValidator', 'date' => 'yii\validators\DateValidator', 'default' => 'yii\validators\DefaultValueValidator', diff --git a/tests/unit/data/base/Singer.php b/tests/unit/data/base/Singer.php index f1b91e1..5e9111d 100644 --- a/tests/unit/data/base/Singer.php +++ b/tests/unit/data/base/Singer.php @@ -15,7 +15,7 @@ class Singer extends Model return array( array('lastName', 'default', 'value' => 'Lennon'), array('lastName', 'required'), - array('underscore_style', 'yii\validators\CaptchaValidator'), + array('underscore_style', 'yii\captcha\CaptchaValidator'), ); } }